This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.orgNeels Hofmeyr has submitted this change and it was merged. ( https://gerrit.osmocom.org/10584 ) Change subject: cosmetic: drop code dup in mgcp_client_fsm.c CRCX ...................................................................... cosmetic: drop code dup in mgcp_client_fsm.c CRCX Both make_crcx_msg_bind() and make_crcx_msg_bind_connect() were mostly identical. Rather, compose the CRCX bits in one common function and just add the audio bits in another. Prepares cosmetically for adding X-Osmo-IGN header. Change-Id: Ie51cc86e90ffeca5b66bcb8f6db0d389241abe57 --- M src/libosmo-mgcp-client/mgcp_client_fsm.c 1 file changed, 19 insertions(+), 38 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/libosmo-mgcp-client/mgcp_client_fsm.c b/src/libosmo-mgcp-client/mgcp_client_fsm.c index a0dc0fb..770db5e 100644 --- a/src/libosmo-mgcp-client/mgcp_client_fsm.c +++ b/src/libosmo-mgcp-client/mgcp_client_fsm.c @@ -104,48 +104,28 @@ {0, NULL} }; -static struct msgb *make_crcx_msg_bind(struct mgcp_ctx *mgcp_ctx) +static void make_crcx_msg(struct mgcp_msg *mgcp_msg, struct mgcp_conn_peer *info) { - struct mgcp_msg mgcp_msg; - - mgcp_msg = (struct mgcp_msg) { + *mgcp_msg = (struct mgcp_msg) { .verb = MGCP_VERB_CRCX, - .presence = (MGCP_MSG_PRESENCE_ENDPOINT | MGCP_MSG_PRESENCE_CALL_ID | MGCP_MSG_PRESENCE_CONN_MODE), - .call_id = mgcp_ctx->conn_peer_local.call_id, + .presence = (MGCP_MSG_PRESENCE_ENDPOINT | MGCP_MSG_PRESENCE_CALL_ID + | MGCP_MSG_PRESENCE_CONN_MODE), + .call_id = info->call_id, .conn_mode = MGCP_CONN_RECV_ONLY, - .ptime = mgcp_ctx->conn_peer_local.ptime, - .codecs_len = mgcp_ctx->conn_peer_local.codecs_len, - .ptmap_len = mgcp_ctx->conn_peer_local.ptmap_len + .ptime = info->ptime, + .codecs_len = info->codecs_len, + .ptmap_len = info->ptmap_len }; - osmo_strlcpy(mgcp_msg.endpoint, mgcp_ctx->conn_peer_local.endpoint, MGCP_ENDPOINT_MAXLEN); - memcpy(mgcp_msg.codecs, mgcp_ctx->conn_peer_local.codecs, sizeof(mgcp_msg.codecs)); - memcpy(mgcp_msg.ptmap, mgcp_ctx->conn_peer_local.ptmap, sizeof(mgcp_msg.ptmap)); - - return mgcp_msg_gen(mgcp_ctx->mgcp, &mgcp_msg); + osmo_strlcpy(mgcp_msg->endpoint, info->endpoint, MGCP_ENDPOINT_MAXLEN); + memcpy(mgcp_msg->codecs, info->codecs, sizeof(mgcp_msg->codecs)); + memcpy(mgcp_msg->ptmap, info->ptmap, sizeof(mgcp_msg->ptmap)); } -static struct msgb *make_crcx_msg_bind_connect(struct mgcp_ctx *mgcp_ctx) +static void add_audio(struct mgcp_msg *mgcp_msg, struct mgcp_conn_peer *info) { - struct mgcp_msg mgcp_msg; - - mgcp_msg = (struct mgcp_msg) { - .verb = MGCP_VERB_CRCX, - .presence = (MGCP_MSG_PRESENCE_ENDPOINT | MGCP_MSG_PRESENCE_CALL_ID | - MGCP_MSG_PRESENCE_CONN_MODE | MGCP_MSG_PRESENCE_AUDIO_IP | - MGCP_MSG_PRESENCE_AUDIO_PORT), - .call_id = mgcp_ctx->conn_peer_local.call_id, - .conn_mode = MGCP_CONN_RECV_SEND, - .audio_ip = mgcp_ctx->conn_peer_local.addr, - .audio_port = mgcp_ctx->conn_peer_local.port, - .ptime = mgcp_ctx->conn_peer_local.ptime, - .codecs_len = mgcp_ctx->conn_peer_local.codecs_len, - .ptmap_len = mgcp_ctx->conn_peer_local.ptmap_len - }; - osmo_strlcpy(mgcp_msg.endpoint, mgcp_ctx->conn_peer_local.endpoint, MGCP_ENDPOINT_MAXLEN); - memcpy(mgcp_msg.codecs, mgcp_ctx->conn_peer_local.codecs, sizeof(mgcp_msg.codecs)); - memcpy(mgcp_msg.ptmap, mgcp_ctx->conn_peer_local.ptmap, sizeof(mgcp_msg.ptmap)); - - return mgcp_msg_gen(mgcp_ctx->mgcp, &mgcp_msg); + mgcp_msg->presence |= MGCP_MSG_PRESENCE_AUDIO_IP | MGCP_MSG_PRESENCE_AUDIO_PORT; + mgcp_msg->audio_ip = info->addr; + mgcp_msg->audio_port = info->port; } static struct msgb *make_mdcx_msg(struct mgcp_ctx *mgcp_ctx) @@ -197,6 +177,7 @@ { struct mgcp_ctx *mgcp_ctx = data; struct mgcp_client *mgcp; + struct mgcp_msg mgcp_msg; struct msgb *msg; int rc; @@ -209,10 +190,10 @@ LOGPFSML(fi, LOGL_DEBUG, "MGW/CRCX: creating connection on MGW endpoint:%s...\n", mgcp_ctx->conn_peer_local.endpoint); + make_crcx_msg(&mgcp_msg, &mgcp_ctx->conn_peer_local); if (mgcp_ctx->conn_peer_local.port) - msg = make_crcx_msg_bind_connect(mgcp_ctx); - else - msg = make_crcx_msg_bind(mgcp_ctx); + add_audio(&mgcp_msg, &mgcp_ctx->conn_peer_local); + msg = mgcp_msg_gen(mgcp_ctx->mgcp, &mgcp_msg); OSMO_ASSERT(msg); mgcp_ctx->mgw_pending_trans = mgcp_msg_trans_id(msg); -- To view, visit https://gerrit.osmocom.org/10584 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: Ie51cc86e90ffeca5b66bcb8f6db0d389241abe57 Gerrit-Change-Number: 10584 Gerrit-PatchSet: 2 Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder (1000002) Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180825/268e07b0/attachment.htm>