arehbein has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/33083 )


Change subject: gsm/ipa: Add segmentation callback
......................................................................

gsm/ipa: Add segmentation callback

Add segmentation callback to be used by the streaming backend of libosmo-netif

Related: OS#5753, OS#5751
Change-Id: I3a639e6896cc3b3fc8e9b2e1a58254710efa0d3f
---
M include/osmocom/gsm/ipa.h
M src/gsm/ipa.c
M src/gsm/libosmogsm.map
3 files changed, 36 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/83/33083/1

diff --git a/include/osmocom/gsm/ipa.h b/include/osmocom/gsm/ipa.h
index 851b58e..8fb91b0 100644
--- a/include/osmocom/gsm/ipa.h
+++ b/include/osmocom/gsm/ipa.h
@@ -5,6 +5,7 @@
 #include <stdint.h>

 #include <osmocom/core/msgb.h>
+#include <osmocom/core/osmo_io.h>
 #include <osmocom/gsm/tlv.h>

 struct osmo_fd;
@@ -69,6 +70,9 @@
 /* Common handling of IPA CCM, BTS side */
 int ipa_ccm_rcvmsg_bts_base(struct msgb *msg, struct osmo_fd *bfd);

+/* Callback for segmenting TCP stream data into IPA packets */
+int ipa_iofd_segmentation_cb(struct msgb *msg, int read);
+
 /* prepend (push) an ipaccess_head_ext to the msgb */
 void ipa_prepend_header_ext(struct msgb *msg, int proto);

@@ -79,3 +83,5 @@

 int ipa_msg_recv(int fd, struct msgb **rmsg);
 int ipa_msg_recv_buffered(int fd, struct msgb **rmsg, struct msgb **tmp_msg);
+
+int ipa_segmentation_cb(struct msgb *msg);
diff --git a/src/gsm/ipa.c b/src/gsm/ipa.c
index 447e8e3..25a7aa4 100644
--- a/src/gsm/ipa.c
+++ b/src/gsm/ipa.c
@@ -39,6 +39,7 @@
 #include <osmocom/core/logging.h>
 #include <osmocom/core/macaddr.h>
 #include <osmocom/core/select.h>
+#include <osmocom/core/osmo_io.h>

 #include <osmocom/gsm/tlv.h>
 #include <osmocom/gsm/protocol/ipaccess.h>
@@ -718,4 +719,20 @@
        return nmsg;
 }

+int ipa_segmentation_cb(struct msgb *msg)
+{
+       if (msgb_length(msg) < sizeof(struct ipaccess_head))
+               /* Haven't even the read entire header */
+               return -EAGAIN;
+       struct ipaccess_head *hh = (struct ipaccess_head *) msg->data;
+       size_t payload_len = osmo_ntohs(hh->len);;
+       size_t total_len = payload_len + sizeof(*hh);
+       if (payload_len < 0 || msg->data_len < total_len) {
+               LOGP(DLINP, LOGL_ERROR, "bad message length of %zu bytes, "
+                                       "received %d bytes\n", payload_len, 
msg->len);
+               return -EIO;
+       }
+       return total_len;
+}
+
 /*! @} */
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 0018e1c..0c074f6 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -638,6 +638,7 @@
 ipa_ccm_id_resp_parse;
 ipa_ccm_make_id_resp;
 ipa_ccm_make_id_resp_from_req;
+ipa_segmentation_cb;
 ipa_msg_alloc;
 ipa_msg_recv;
 ipa_msg_recv_buffered;

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/33083
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I3a639e6896cc3b3fc8e9b2e1a58254710efa0d3f
Gerrit-Change-Number: 33083
Gerrit-PatchSet: 1
Gerrit-Owner: arehbein <arehb...@sysmocom.de>
Gerrit-MessageType: newchange

Reply via email to