pespin has uploaded this change for review.

View Change

mgcp-cli: Improve error handling around mgcp_msg_gen() return

Change-Id: Ib9b02b7e6b37472c8e38b3380bc990a2bbac0657
---
M src/libosmo-mgcp-client/mgcp_client.c
M src/libosmo-mgcp-client/mgcp_client_fsm.c
2 files changed, 17 insertions(+), 3 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/79/39179/1
diff --git a/src/libosmo-mgcp-client/mgcp_client.c b/src/libosmo-mgcp-client/mgcp_client.c
index 09b1953..1c89e69 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -864,6 +864,10 @@
};
osmo_strlcpy(mgcp_msg_dlcx.endpoint, epname, sizeof(mgcp_msg_dlcx.endpoint));
msgb_dlcx = mgcp_msg_gen(mgcp, &mgcp_msg_dlcx);
+ if (msgb_dlcx) {
+ LOGPMGW(mgcp, LOGL_ERROR, "Failed generating MGCP DLCX %s\n", epname);
+ return;
+ }
mgcp_client_tx(mgcp, msgb_dlcx, &_ignore_mgcp_response, NULL);
}

@@ -877,6 +881,10 @@
};
OSMO_STRLCPY_ARRAY(mgcp_msg_auep.endpoint, epname);
msgb_auep = mgcp_msg_gen(mgcp, &mgcp_msg_auep);
+ if (msgb_auep) {
+ LOGPMGW(mgcp, LOGL_ERROR, "Failed generating MGCP AUEP %s\n", epname);
+ return;
+ }
mgcp_client_tx(mgcp, msgb_auep, &_ignore_mgcp_response, NULL);
}

@@ -1336,7 +1344,9 @@
MSGB_PRINTF_OR_RET("v=0\r\n");

/* Determine local IP-Address */
- if (osmo_sock_local_ip(local_ip, mgcp->actual.remote_addr) < 0) {
+ if (mgcp->actual.local_addr) {
+ OSMO_STRLCPY_ARRAY(local_ip, mgcp->actual.local_addr);
+ } else if (osmo_sock_local_ip(local_ip, mgcp->actual.remote_addr) < 0) {
LOGPMGW(mgcp, LOGL_ERROR,
"Could not determine local IP-Address!\n");
return -EINVAL;
diff --git a/src/libosmo-mgcp-client/mgcp_client_fsm.c b/src/libosmo-mgcp-client/mgcp_client_fsm.c
index e638d1e..7a6fed8 100644
--- a/src/libosmo-mgcp-client/mgcp_client_fsm.c
+++ b/src/libosmo-mgcp-client/mgcp_client_fsm.c
@@ -157,6 +157,7 @@
mgcp_msg->conn_mode = conn_mode;
}

+/* returns message buffer containing MGXP MDCX on success, NULL on error. */
static struct msgb *make_mdcx_msg(struct mgcp_ctx *mgcp_ctx)
{
struct mgcp_msg mgcp_msg;
@@ -192,6 +193,7 @@
return mgcp_msg_gen(mgcp_ctx->mgcp, &mgcp_msg);
}

+/* returns message buffer containing MGXP DLCX on success, NULL on error. */
struct msgb *make_dlcx_msg(struct mgcp_ctx *mgcp_ctx)
{
struct mgcp_msg mgcp_msg;
@@ -231,8 +233,10 @@
set_conn_mode(&mgcp_msg, &mgcp_ctx->conn_peer_local);

msg = mgcp_msg_gen(mgcp_ctx->mgcp, &mgcp_msg);
- OSMO_ASSERT(msg);
-
+ if (!msg) {
+ osmo_fsm_inst_term(fi, OSMO_FSM_TERM_ERROR, NULL);
+ return;
+ }
mgcp_ctx->mgw_pending_trans = mgcp_msg_trans_id(msg);
mgcp_ctx->mgw_trans_pending = true;
rc = mgcp_client_tx(mgcp, msg, mgw_crcx_resp_cb, fi);

To view, visit change 39179. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: Ib9b02b7e6b37472c8e38b3380bc990a2bbac0657
Gerrit-Change-Number: 39179
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>