arehbein has uploaded this change for review. (
https://gerrit.osmocom.org/c/libosmocore/+/33192 )
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, 37 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/92/33192/1
diff --git a/include/osmocom/gsm/ipa.h b/include/osmocom/gsm/ipa.h
index 851b58e..37672d6 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;
@@ -79,3 +80,6 @@
int ipa_msg_recv(int fd, struct msgb **rmsg);
int ipa_msg_recv_buffered(int fd, struct msgb **rmsg, struct msgb **tmp_msg);
+
+/* Callback for segmenting TCP stream data into IPA packets */
+int ipa_segmentation_cb(struct msgb *msg);
diff --git a/src/gsm/ipa.c b/src/gsm/ipa.c
index 447e8e3..de04537 100644
--- a/src/gsm/ipa.c
+++ b/src/gsm/ipa.c
@@ -30,6 +30,7 @@
#include <stdint.h>
#include <errno.h>
#include <stdlib.h>
+#include <inttypes.h>
#include <sys/types.h>
@@ -39,6 +40,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 +720,22 @@
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 (msg->data_len < total_len) {
+ LOGP(DLINP, LOGL_ERROR, "bad message length of %zu bytes, "
+ "received %" PRIu16 "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/+/33192
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: arehbein/osmo_io_ipa
Gerrit-Change-Id: I3a639e6896cc3b3fc8e9b2e1a58254710efa0d3f
Gerrit-Change-Number: 33192
Gerrit-PatchSet: 1
Gerrit-Owner: arehbein <arehbein(a)sysmocom.de>
Gerrit-MessageType: newchange