This API provides the interface between the Controller library and the underlying data link implementation, which is platform and transport specific.
◆ MMAGIC_DATALINK_CONTROLLER_ARGS_INIT
| #define MMAGIC_DATALINK_CONTROLLER_ARGS_INIT { 0 } |
◆ mmagic_datalink_controller_rx_buffer_cb_t
| typedef void(* mmagic_datalink_controller_rx_buffer_cb_t) (struct mmagic_datalink_controller *controller_dl, void *arg, struct mmbuf *buf) |
Prototype for callback function invoked when the mmagic_datalink_controller receives a data payload.
- Note
- The callback function will executed in a thread context.
- Parameters
-
| controller_dl | The datalink handle. |
| arg | User argument that was given when the callback was registered. |
| buf | mmbuf containing the received data. The callback takes ownership of the buffer and is responsible for releasing it. |
Definition at line 74 of file mmagic_datalink_controller.h.
◆ mmagic_datalink_controller_alloc_buffer_for_tx()
| struct mmbuf * mmagic_datalink_controller_alloc_buffer_for_tx |
( |
struct mmagic_datalink_controller * |
controller_dl, |
|
|
size_t |
header_size, |
|
|
size_t |
payload_size |
|
) |
| |
Allocates a buffer that can subsequently used with mmagic_datalink_controller_tx_buffer().
The allocated buffer may also include additional space at the end of the payload to allow for things like CRC bits.
- Parameters
-
| controller_dl | Reference to the datalink handle. |
| header_size | The size of any headers that may be required. |
| payload_size | The size of the payload. |
- Returns
- An
mmbuf with the required space pre allocated. NULL on error.
◆ mmagic_datalink_controller_deinit()
| void mmagic_datalink_controller_deinit |
( |
struct mmagic_datalink_controller * |
controller_dl | ) |
|
Deinitialize the mmagic_datalink_controller.
Any resources used will be freed.
- Parameters
-
| controller_dl | Reference to the datalink handle. |
◆ mmagic_datalink_controller_init()
Initialize the mmagic_datalink_controller.
- Parameters
-
| args | Reference to the initialization arguments for the mmagic_datalink_controller. |
- Returns
- Reference to the create controller_dl handle on success.
Null on error.
◆ mmagic_datalink_controller_tx_buffer()
| int mmagic_datalink_controller_tx_buffer |
( |
struct mmagic_datalink_controller * |
controller_dl, |
|
|
struct mmbuf * |
buf |
|
) |
| |
Transmits the given buffer as a packet to the agent.
This function will block until the whole packet has been transmitted or an error occurs. mmagic_datalink_controller_alloc_buffer_for_tx() should be used to allocated the buffer.
- Parameters
-
| controller_dl | Reference to the datalink handle. |
| buf | The buffer containing the data to be framed and sent to the agent. This function takes ownership of the buffer and is responsible for releasing it. |
- Returns
- The number of bytes transmitted on success. Negative value on error.