stream: Add and use helper function osmo_ipa_push_headers()

Related OS#5753, OS#5751

Change-Id: I61e1fe59166c46595efe8c1f32b8f2607cb6c529
This commit is contained in:
arehbein 2023-06-24 17:23:55 +02:00 committed by daniel
parent 64d9b5487a
commit 106b63907a
5 changed files with 27 additions and 10 deletions

View File

@ -93,9 +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_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 "

View File

@ -51,9 +51,7 @@ int read_cb(struct osmo_stream_srv *conn, struct msgb *msg)
{
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;
}

View File

@ -65,4 +65,6 @@ int osmo_ipa_parse_msg_id_resp(struct msgb *msg, struct ipaccess_unit *unit_data
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

View File

@ -436,3 +436,15 @@ int osmo_ipa_segmentation_cb(struct msgb *msg)
}
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);
}

View File

@ -384,12 +384,17 @@ static const uint8_t ipac_msg_pong[] = {
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 @@ int test_segm_ipa_stream_srv_srv_read_cb(struct osmo_stream_srv *conn, struct ms
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 @@ static int test_segm_ipa_stream_cli_cli_read_cb(struct osmo_stream_cli *osc, str
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;