libosmocore UNKNOWN
Osmocom core library
Loading...
Searching...
No Matches
osmo_io_ops::[struct].__unnamed0__ Struct Reference

Data Fields

void(*) read_cb (struct osmo_io_fd *iofd, int res, struct msgb *msg)
 completion call-back function when something was read from fd.
void(*) write_cb (struct osmo_io_fd *iofd, int res, struct msgb *msg)
 completion call-back function when write issued via osmo_iofd_write_msgb() has completed on fd.
int(*) segmentation_cb (struct msgb *msg)
 optional call-back function to segment the data at message boundaries.
int(*) segmentation_cb2 (struct osmo_io_fd *iofd, struct msgb *msg)
 optional call-back function to segment the data at message boundaries.

Field Documentation

◆ read_cb

void(*) osmo_io_ops::[struct].__unnamed0__(struct osmo_io_fd *iofd, int res, struct msgb *msg)

completion call-back function when something was read from fd.

Only valid in OSMO_IO_FD_MODE_READ_WRITE.

Parameters
[in]iofdosmo_io_fd for which read() has completed.
[in]resreturn value of the read() call, or -errno in case of error.
[in]msgmessage buffer containing the read data. Ownership is transferred to the call-back, and it must make sure to msgb_free() it eventually!

NOTE: If segmentation_cb is in use, the bytes read in res value may be different than those provided in the msg parameter!

◆ segmentation_cb

optional call-back function to segment the data at message boundaries.

Parameters
[in]msgmessage buffer whose data is to be segmented
Returns
See full function description.

This is useful when message boundaries are to be preserved over a SOCK_STREAM transport socket like TCP. Can be NULL for any application not requiring de-segmentation of received data.

The call-back needs to return the size of the next message. If it returns -EAGAIN or a value larger than msgb_length() (message is incomplete) osmo_io will wait for more data to be read. Other negative values cause the msg to be discarded. If a full message was received (segmentation_cb() returns a value <= msgb_length()) the msgb will be trimmed to size by osmo_io and forwarded to the read call-back. Any parsing done to the msgb by segmentation_cb() will be preserved for the read_cb() (e.g. setting lxh or msgb->cb).

Only one (or none) of both segmentation_cb and segmentation_cb2 shall be set. Having both set will be considered an error during iofd setup.

◆ segmentation_cb2

int(*) osmo_io_ops::[struct].__unnamed0__(struct osmo_io_fd *iofd, struct msgb *msg)

optional call-back function to segment the data at message boundaries.

Parameters
[in]iofdhandling msg
[in]msgmessage buffer whose data is to be segmented
Returns
See full function description.

Same as segmentation_cb above, with an extra parameter to have access to the iofd and its related functionalities (eg data pointer). This is useful for users requiring to store global state or access external objects while segmenting.

The provided iofd shall not be freed by the user during the callback.

Only one (or none) of both segmentation_cb and segmentation_cb2 shall be set. Having both set will be considered an error during iofd setup.

◆ write_cb

void(*) osmo_io_ops::[struct].__unnamed0__(struct osmo_io_fd *iofd, int res, struct msgb *msg)

completion call-back function when write issued via osmo_iofd_write_msgb() has completed on fd.

Only valid in OSMO_IO_FD_MODE_READ_WRITE.

Parameters
[in]iofdon which a write() has completed.
[in]resreturn value of the write() call, or -errno in case of error.
[in]msgmessage buffer whose write has completed. Ownership is not transferred to the call-back; it is automatically freed after the call-back terminates!

The documentation for this struct was generated from the following files: