aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarehbein <arehbein@sysmocom.de>2023-05-22 17:09:49 +0200
committerDaniel Willmann <dwillmann@sysmocom.de>2023-08-07 16:50:22 +0200
commit8712af589cb0a9a5d73e10957e696cd05f9fdc68 (patch)
tree69bf24c16ddee091b1b95625a1bb37c3bc401fa4
parent7fe21f67f647a1cede87042911588e57b17580c6 (diff)
examples: Add extension header octet to example
Mainly to make data/packets look (pseudo-)correct in Wireshark. Also: Add helper for allocating message buffers with extended headroom for IPA. Change-Id: I962b9edcba65cdc98da00d2f8753dc5acd481502
-rw-r--r--examples/ipa-stream-client.c5
-rw-r--r--include/osmocom/netif/ipa.h2
-rw-r--r--src/ipa.c5
3 files changed, 10 insertions, 2 deletions
diff --git a/examples/ipa-stream-client.c b/examples/ipa-stream-client.c
index b66d93a..10eb786 100644
--- a/examples/ipa-stream-client.c
+++ b/examples/ipa-stream-client.c
@@ -74,7 +74,7 @@ static int connect_cb(struct osmo_stream_cli *conn)
char *ptr;
int x;
- msg = osmo_ipa_msg_alloc(0);
+ msg = osmo_ipa_ext_msg_alloc(0);
if (msg == NULL) {
LOGP(DLINP, LOGL_ERROR, "cannot alloc msg\n");
return -1;
@@ -93,6 +93,7 @@ static int connect_cb(struct osmo_stream_cli *conn)
msg_sent->num = i;
llist_add(&msg_sent->head, &msg_sent_list);
+ ipa_prepend_header_ext(msg, IPAC_PROTO_EXT_MGCP);
osmo_ipa_msg_push_header(msg, IPAC_PROTO_OSMO);
osmo_stream_cli_send(conn, msg);
@@ -115,7 +116,7 @@ static int read_cb(struct osmo_stream_cli *conn, struct msgb *msg)
int num;
struct msg_sent *cur, *tmp, *found = NULL;
- num = ntohl(*((int *)(msg->data + sizeof(struct ipa_head))));
+ num = ntohl(*((int *)(msg->data + sizeof(struct ipa_head) + sizeof(struct ipa_head_ext))));
LOGP(DLINP, LOGL_DEBUG, "received msg number %d\n", num);
llist_for_each_entry_safe(cur, tmp, &msg_sent_list, head) {
diff --git a/include/osmocom/netif/ipa.h b/include/osmocom/netif/ipa.h
index 0d1085f..7494d8d 100644
--- a/include/osmocom/netif/ipa.h
+++ b/include/osmocom/netif/ipa.h
@@ -19,6 +19,8 @@ struct ipa_head_ext {
} __attribute__ ((packed));
struct msgb *osmo_ipa_msg_alloc(int headroom);
+struct msgb *osmo_ipa_ext_msg_alloc(size_t headroom);
+
void osmo_ipa_msg_push_header(struct msgb *msg, uint8_t proto);
int osmo_ipa_process_msg(struct msgb *msg);
diff --git a/src/ipa.c b/src/ipa.c
index 197a47f..5f62e88 100644
--- a/src/ipa.c
+++ b/src/ipa.c
@@ -97,6 +97,11 @@ struct msgb *osmo_ipa_msg_alloc(int headroom)
return msg;
}
+struct msgb *osmo_ipa_ext_msg_alloc(size_t headroom)
+{
+ return osmo_ipa_msg_alloc(sizeof(struct ipa_head_ext) + headroom);
+}
+
void osmo_ipa_msg_push_header(struct msgb *msg, uint8_t proto)
{
struct ipa_head *hh;