daniel has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-netif/+/33201?usp=email )
Change subject: stream: Add and use helper function osmo_ipa_push_headers() ...................................................................... stream: Add and use helper function osmo_ipa_push_headers() Related OS#5753, OS#5751 Change-Id: I61e1fe59166c46595efe8c1f32b8f2607cb6c529 --- M examples/ipa-stream-client.c M examples/ipa-stream-server.c M include/osmocom/netif/ipa.h M src/ipa.c M tests/stream/stream_test.c 5 files changed, 38 insertions(+), 10 deletions(-) Approvals: daniel: Looks good to me, approved pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/examples/ipa-stream-client.c b/examples/ipa-stream-client.c index db7d441..cb07ef6 100644 --- a/examples/ipa-stream-client.c +++ b/examples/ipa-stream-client.c @@ -93,9 +93,7 @@ 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_ipa_msg_push_headers(msg, osmo_ipa_msgb_cb_proto(msg), osmo_ipa_msgb_cb_proto_ext(msg)); osmo_stream_cli_send(conn, msg); LOGP(DIPATEST, LOGL_DEBUG, "enqueueing msg %d of " diff --git a/examples/ipa-stream-server.c b/examples/ipa-stream-server.c index d31b752..5317921 100644 --- a/examples/ipa-stream-server.c +++ b/examples/ipa-stream-server.c @@ -51,9 +51,7 @@ { LOGP(DSTREAMTEST, LOGL_DEBUG, "received message from stream (payload len=%d)\n", msgb_length(msg)); - ipa_prepend_header_ext(msg, IPAC_PROTO_EXT_MGCP); - osmo_ipa_msg_push_header(msg, IPAC_PROTO_OSMO); - + osmo_ipa_msg_push_headers(msg, osmo_ipa_msgb_cb_proto(msg), osmo_ipa_msgb_cb_proto_ext(msg)); osmo_stream_srv_send(conn, msg); return 0; } diff --git a/include/osmocom/netif/ipa.h b/include/osmocom/netif/ipa.h index 7826895..038b9ac 100644 --- a/include/osmocom/netif/ipa.h +++ b/include/osmocom/netif/ipa.h @@ -65,4 +65,6 @@ int osmo_ipa_segmentation_cb(struct msgb *msg); +void osmo_ipa_msg_push_headers(struct msgb *msg, enum ipaccess_proto p, enum ipaccess_proto_ext pe); + #endif diff --git a/src/ipa.c b/src/ipa.c index a67521f..8720427 100644 --- a/src/ipa.c +++ b/src/ipa.c @@ -436,3 +436,15 @@ } return total_len; } + +/*! Push IPA headers to a message + * If we have IPAC_PROTO_OSMO this also takes care of the extension header + * \param[out] msg Target message + * \param p Target IPA protocol + * \param pe Target IPA protocol extension. Ignored, unless p equals IPAC_PROTO_OSMO. */ +void osmo_ipa_msg_push_headers(struct msgb *msg, enum ipaccess_proto p, enum ipaccess_proto_ext pe) +{ + if (p == IPAC_PROTO_OSMO) + ipa_prepend_header_ext(msg, pe); + osmo_ipa_msg_push_header(msg, p); +} diff --git a/tests/stream/stream_test.c b/tests/stream/stream_test.c index 960d8fa..4830302 100644 --- a/tests/stream/stream_test.c +++ b/tests/stream/stream_test.c @@ -384,12 +384,17 @@ IPAC_PROTO_IPACCESS, IPAC_MSGT_PONG }; +#define IPAC_MSG_IDREQ_PAYLOAD_INITIALIZER \ + IPAC_MSGT_ID_GET, \ + 0x01, IPAC_IDTAG_UNITNAME +static const uint8_t ipac_msg_idreq_payload[] = { + IPAC_MSG_IDREQ_PAYLOAD_INITIALIZER +}; #define IPAC_MSG_ID_REQ_LEN 0x03 static const uint8_t ipac_msg_idreq[] = { 0x00, IPAC_MSG_ID_REQ_LEN, IPAC_PROTO_IPACCESS, - IPAC_MSGT_ID_GET, - 0x01, IPAC_IDTAG_UNITNAME + IPAC_MSG_IDREQ_PAYLOAD_INITIALIZER }; #define ipac_msg_idreq_third (sizeof(ipac_msg_idreq)/3) #define ipac_msg_idreq_last_third (sizeof(ipac_msg_idreq) - 2 * ipac_msg_idreq_third) @@ -574,7 +579,8 @@ fprintf(stderr, "Cannot allocate message\n"); return -ENOMEM; } - put_ipa_msg(data, m, ipac_msg_idreq); + put_ipa_msg(data, m, ipac_msg_idreq_payload); + osmo_ipa_msg_push_headers(m, IPAC_PROTO_IPACCESS, -1); osmo_stream_srv_send(conn, m); } else if (msgnum_srv == 7 && *msgt == IPAC_MSGT_PONG) { test_segm_ipa_stream_srv_all_msgs_processed = true; @@ -766,7 +772,8 @@ fprintf(stderr, "Cannot allocate message\n"); return -ENOMEM; } - put_ipa_msg(data, m, ipac_msg_idreq); + put_ipa_msg(data, m, ipac_msg_idreq_payload); + osmo_ipa_msg_push_headers(m, IPAC_PROTO_IPACCESS, -1); osmo_stream_cli_send(osc, m); } else if (msgnum_cli == 7 && *msgt == IPAC_MSGT_PONG) { test_segm_ipa_stream_cli_all_msgs_processed = true; -- To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/33201?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Change-Id: I61e1fe59166c46595efe8c1f32b8f2607cb6c529 Gerrit-Change-Number: 33201 Gerrit-PatchSet: 23 Gerrit-Owner: arehbein <arehb...@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillm...@sysmocom.de> Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de> Gerrit-Reviewer: laforge <lafo...@osmocom.org> Gerrit-Reviewer: pespin <pes...@sysmocom.de> Gerrit-MessageType: merged