-
Notifications
You must be signed in to change notification settings - Fork 0
ut_control_plane: Overview (ut_control_plane.h)
Ulrond edited this page Jul 22, 2024
·
1 revision
Purpose:
This module provides a framework for building a "control plane" within a larger system. A control plane, typically:
- Monitors: Listens for incoming messages or events on a specific port.
- Reacts: Triggers pre-registered callback functions based on the content of received messages.
- Manages: Handles registration and unregistration of these callback functions.
Key Features:
-
Initialization (
UT_ControlPlane_Init
):- Creates a control plane instance.
- Specifies the network port to monitor.
-
Callback Registration (
UT_ControlPlane_RegisterCallbackOnMessage
):- Associates specific message "keys" (strings) with callback functions.
- When a message with a matching key is received, the corresponding callback is executed.
- Supports user-defined data to be passed to the callback.
-
Operation (
UT_ControlPlane_Start
,UT_ControlPlane_Stop
):- Starts and stops the active monitoring process.
-
Clean-up (
UT_ControlPlane_Exit
):- Releases all resources used by the control plane.
Data Structures:
-
ut_controlPlane_instance_t
: An opaque handle representing a control plane instance. -
ut_control_plane_status_t
: An enumeration of possible status codes (success, failure reasons). -
ut_control_callback_t
: A function pointer type defining the signature of a callback function.
Typical Usage:
-
Initialize: Create a control plane instance (
UT_ControlPlane_Init
). -
Register Callbacks: For each type of message you want to handle, associate a callback function and optional user data (
UT_ControlPlane_RegisterCallbackOnMessage
). -
Start: Begin listening for messages (
UT_ControlPlane_Start
). - (Internal operation) The control plane runs continuously, calling registered callbacks when matching messages arrive.
-
Stop (optional): If needed, pause message processing (
UT_ControlPlane_Stop
). -
Exit: Clean up the control plane when finished (
UT_ControlPlane_Exit
).
Additional Notes:
-
Maximum Callbacks: There's a limit of 32 registered callbacks (
UT_CONTROL_PLANE_MAX_CALLBACK_ENTRIES
).