aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom/core
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2023-05-17 12:38:14 +0200
committerdaniel <dwillmann@sysmocom.de>2023-05-19 12:50:21 +0000
commitd4d03705f90e4a346f21ee2f328348b9ba37a201 (patch)
tree8cdd8b6024b70033231164a1bda9d1edab4f1a83 /include/osmocom/core
parent0c374c68a1f77e95de3043577c7b6058dcf23026 (diff)
osmo_io: Improve handling and documentation of segmentation_cb
The read length is not needed in the segmentation callback, msgb already has all the necessary information, the parameter previously was just msgb_length(msg). Also handle negative return values (except -EAGAIN) of the callback as errors which cause the msg to be dropped. -EAGAIN will defer the msg. Change-Id: I6a0eebb8d4490f09a3cc6eb97d4ff47b4a8fd377
Diffstat (limited to 'include/osmocom/core')
-rw-r--r--include/osmocom/core/osmo_io.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/include/osmocom/core/osmo_io.h b/include/osmocom/core/osmo_io.h
index c19ca678..d7402d6f 100644
--- a/include/osmocom/core/osmo_io.h
+++ b/include/osmocom/core/osmo_io.h
@@ -42,8 +42,12 @@ struct osmo_io_ops {
/*! call-back function when write has completed on fd */
void (*write_cb)(struct osmo_io_fd *iofd, int res,
const struct msgb *msg);
- /*! call-back function to segment the data returned by read_cb */
- int (*segmentation_cb)(struct msgb *msg, int data_len);
+ /*! call-back function to segment the data at message boundaries.
+ * 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. */
+ int (*segmentation_cb)(struct msgb *msg);
};
/* mode OSMO_IO_FD_MODE_RECVFROM_SENDTO: */