pespin has uploaded this change for review.

View Change

osmo_io: Add iofd param to segmentation_cb

See related ticket for full rant and historical facts about this
callback.
Since anyway we are still developing osmo_io stuff and there will be ABI
breaks when releasing new version, let's udpate the callback signature
too.

Related: OS#6437
Change-Id: Ib8d77e30b1ea759ee5ac2a69d704e81ea71e3079
---
M include/osmocom/core/osmo_io.h
M include/osmocom/gsm/cbsp.h
M src/core/osmo_io.c
M src/gsm/cbsp.c
4 files changed, 30 insertions(+), 7 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/82/36582/1
diff --git a/include/osmocom/core/osmo_io.h b/include/osmocom/core/osmo_io.h
index 8c931dd..f86e968 100644
--- a/include/osmocom/core/osmo_io.h
+++ b/include/osmocom/core/osmo_io.h
@@ -100,6 +100,7 @@
* \param[in] msg message buffer containing the read data. Ownership is transferred to the
* call-back, and it must make sure to msgb_free() it eventually! */
void (*read_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. Only valid in OSMO_IO_FD_MODE_READ_WRITE.
* \param[in] iofd on which a write() has completed.
@@ -108,9 +109,15 @@
* call-back; it is automatically freed after the call-back terminates! */
void (*write_cb)(struct osmo_io_fd *iofd, int res,
struct msgb *msg);
- /*! optional call-back function to segment the data at message boundaries. 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.
+
+ /*! optional call-back function to segment the data at message boundaries.
+ * \param[in] iofd handling msg
+ * \param[in] msg message 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)
@@ -120,7 +127,7 @@
* 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). */
- int (*segmentation_cb)(struct msgb *msg);
+ int (*segmentation_cb)(struct osmo_io_fd *iofd, struct msgb *msg);
};

/* mode OSMO_IO_FD_MODE_RECVFROM_SENDTO: */
diff --git a/include/osmocom/gsm/cbsp.h b/include/osmocom/gsm/cbsp.h
index efa4ce6..d15e6f8 100644
--- a/include/osmocom/gsm/cbsp.h
+++ b/include/osmocom/gsm/cbsp.h
@@ -312,4 +312,4 @@
struct osmo_cbsp_decoded *osmo_cbsp_decoded_alloc(void *ctx, enum cbsp_msg_type msg_type);

int osmo_cbsp_recv_buffered(void *ctx, int fd, struct msgb **rmsg, struct msgb **tmp_msg);
-int osmo_cbsp_segmentation_cb(struct msgb *msg);
+int osmo_cbsp_segmentation_cb(struct osmo_io_fd *iofd, struct msgb *msg);
diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c
index b589cb7..f908e80 100644
--- a/src/core/osmo_io.c
+++ b/src/core/osmo_io.c
@@ -280,7 +280,7 @@
return IOFD_SEG_ACT_HANDLE_ONE;
}

- int expected_len = iofd->io_ops.segmentation_cb(msg);
+ int expected_len = iofd->io_ops.segmentation_cb(iofd, msg);
if (expected_len == -EAGAIN) {
goto defer;
} else if (expected_len < 0) {
diff --git a/src/gsm/cbsp.c b/src/gsm/cbsp.c
index a5e58f4..dbc3830 100644
--- a/src/gsm/cbsp.c
+++ b/src/gsm/cbsp.c
@@ -1570,7 +1570,7 @@
/*! call-back function to segment the data at message boundaries.
* Returns the size of the next message. If it returns -EAGAIN or a value larger than msgb_length() (message
* is incomplete), the caller (e.g. osmo_io) has to wait for more data to be read. */
-int osmo_cbsp_segmentation_cb(struct msgb *msg)
+int osmo_cbsp_segmentation_cb(struct osmo_io_fd *iofd, struct msgb *msg)
{
const struct cbsp_header *h;
int len;

To view, visit change 36582. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ib8d77e30b1ea759ee5ac2a69d704e81ea71e3079
Gerrit-Change-Number: 36582
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>
Gerrit-MessageType: newchange