Change in osmo-msc[master]: use osmo_sockaddr_str_is_nonzero()

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/.

laforge gerrit-no-reply at lists.osmocom.org
Mon Nov 4 10:12:30 UTC 2019


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-msc/+/15852 )

Change subject: use osmo_sockaddr_str_is_nonzero()
......................................................................

use osmo_sockaddr_str_is_nonzero()

Also regard an RTP port as invalid if the IP address is 0.0.0.0.
Achieve this by using osmo_sockaddr_str_is_nonzero() instead of
osmo_sockaddr_str_is_set().

Depends: I73cbcab90cffcdc9a5f8d5281c57c1f87b2c3550 (libosmocore)
Change-Id: I53ddb19a70fda3deb906464e1b89c12d9b4c7cbd
---
M src/libmsc/call_leg.c
M src/libmsc/mncc_call.c
M src/libmsc/msc_ho.c
M src/libmsc/msc_t.c
M src/libmsc/ran_msg_a.c
M src/libmsc/rtp_stream.c
6 files changed, 19 insertions(+), 19 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/src/libmsc/call_leg.c b/src/libmsc/call_leg.c
index 794eda2..b1d0b1e 100644
--- a/src/libmsc/call_leg.c
+++ b/src/libmsc/call_leg.c
@@ -301,7 +301,7 @@
 	rtps = cl->rtp[dir];
 	if (!rtps)
 		return NULL;
-	if (!osmo_sockaddr_str_is_set(&rtps->local))
+	if (!osmo_sockaddr_str_is_nonzero(&rtps->local))
 		return NULL;
 	return &rtps->local;
 }
@@ -327,7 +327,7 @@
 	}
 	if (codec_if_known)
 		rtp_stream_set_codec(cl->rtp[dir], *codec_if_known);
-	if (remote_addr_if_known && osmo_sockaddr_str_is_set(remote_addr_if_known))
+	if (remote_addr_if_known && osmo_sockaddr_str_is_nonzero(remote_addr_if_known))
 		rtp_stream_set_remote_addr(cl->rtp[dir], remote_addr_if_known);
 	return rtp_stream_ensure_ci(cl->rtp[dir], cl->mgw_endpoint);
 }
diff --git a/src/libmsc/mncc_call.c b/src/libmsc/mncc_call.c
index 5ca91d0..34c7299 100644
--- a/src/libmsc/mncc_call.c
+++ b/src/libmsc/mncc_call.c
@@ -256,7 +256,7 @@
 		return true;
 	}
 
-	if (!osmo_sockaddr_str_is_set(&mncc_call->rtps->local)) {
+	if (!osmo_sockaddr_str_is_nonzero(&mncc_call->rtps->local)) {
 		LOG_MNCC_CALL(mncc_call, LOGL_DEBUG, "Got RTP_CREATE, but RTP stream has no local address\n");
 		return true;
 	}
@@ -294,7 +294,7 @@
 
 static bool mncc_call_tx_rtp_create(struct mncc_call *mncc_call)
 {
-	if (!mncc_call->rtps || !osmo_sockaddr_str_is_set(&mncc_call->rtps->local)) {
+	if (!mncc_call->rtps || !osmo_sockaddr_str_is_nonzero(&mncc_call->rtps->local)) {
 		mncc_call_error(mncc_call, "Cannot send RTP_CREATE, no local RTP address set up\n");
 		return false;
 	}
diff --git a/src/libmsc/msc_ho.c b/src/libmsc/msc_ho.c
index 615b8cd..99f37b6 100644
--- a/src/libmsc/msc_ho.c
+++ b/src/libmsc/msc_ho.c
@@ -661,7 +661,7 @@
 	}
 
 	msc_a->ho.new_cell.ran_remote_rtp = hra->ran_dec->handover_request_ack.remote_rtp;
-	if (osmo_sockaddr_str_is_set(&msc_a->ho.new_cell.ran_remote_rtp)) {
+	if (osmo_sockaddr_str_is_nonzero(&msc_a->ho.new_cell.ran_remote_rtp)) {
 		LOG_HO(msc_a, LOGL_DEBUG, "Request Ack contains cell's RTP address " OSMO_SOCKADDR_STR_FMT "\n",
 		       OSMO_SOCKADDR_STR_FMT_ARGS(&msc_a->ho.new_cell.ran_remote_rtp));
 	}
@@ -684,7 +684,7 @@
 		return;
 	}
 
-	if (!osmo_sockaddr_str_is_set(&msc_a->ho.new_cell.ran_remote_rtp)) {
+	if (!osmo_sockaddr_str_is_nonzero(&msc_a->ho.new_cell.ran_remote_rtp)) {
 		LOG_HO(msc_a, LOGL_DEBUG, "New cell's RTP IP:port not yet known, not switching RTP stream\n");
 		return;
 	}
@@ -738,7 +738,7 @@
 		return;
 	}
 
-	if (!osmo_sockaddr_str_is_set(&msc_a->ho.old_cell.ran_remote_rtp)) {
+	if (!osmo_sockaddr_str_is_nonzero(&msc_a->ho.old_cell.ran_remote_rtp)) {
 		LOG_HO(msc_a, LOGL_DEBUG, "Have no RTP IP:port for the old cell, not switching back to\n");
 		return;
 	}
diff --git a/src/libmsc/msc_t.c b/src/libmsc/msc_t.c
index 6b96c26..af0ddaa 100644
--- a/src/libmsc/msc_t.c
+++ b/src/libmsc/msc_t.c
@@ -444,7 +444,7 @@
 
 	/* Also need to fetch the RTP IP:port from AoIP Transport Address IE to tell the MGW about it */
 	if (rtp_ran) {
-		if (osmo_sockaddr_str_is_set(&r->remote_rtp)) {
+		if (osmo_sockaddr_str_is_nonzero(&r->remote_rtp)) {
 			LOG_MSC_T(msc_t, LOGL_DEBUG, "From Handover Request Ack, got " OSMO_SOCKADDR_STR_FMT "\n",
 				  OSMO_SOCKADDR_STR_FMT_ARGS(&r->remote_rtp));
 			rtp_stream_set_remote_addr(rtp_ran, &r->remote_rtp);
diff --git a/src/libmsc/ran_msg_a.c b/src/libmsc/ran_msg_a.c
index fa0335c..fc9a9d7 100644
--- a/src/libmsc/ran_msg_a.c
+++ b/src/libmsc/ran_msg_a.c
@@ -942,7 +942,7 @@
 		use_scl = &scl;
 
 		/* Package RTP-Address data */
-		if (osmo_sockaddr_str_is_set(ac->cn_rtp)) {
+		if (osmo_sockaddr_str_is_nonzero(ac->cn_rtp)) {
 			struct sockaddr_in rtp_addr_in;
 
 			memset(&rtp_addr_in, 0, sizeof(rtp_addr_in));
@@ -1114,7 +1114,7 @@
 	if (n->classmark)
 		r.classmark_information = *n->classmark;
 
-	if (osmo_sockaddr_str_is_set(n->rtp_ran_local)) {
+	if (osmo_sockaddr_str_is_nonzero(n->rtp_ran_local)) {
 		if (osmo_sockaddr_str_to_sockaddr(n->rtp_ran_local, &ss)) {
 			LOG_RAN_A_ENC(log_fi, LOGL_ERROR,
 				       "Handover Request: invalid AoIP Transport Layer address/port: "
@@ -1139,7 +1139,7 @@
 		.chosen_speech_version = r->chosen_speech_version,
 	};
 
-	if (osmo_sockaddr_str_is_set(&r->remote_rtp)) {
+	if (osmo_sockaddr_str_is_nonzero(&r->remote_rtp)) {
 		osmo_sockaddr_str_to_sockaddr(&r->remote_rtp, &ss);
 		params.aoip_transport_layer = &ss;
 	}
diff --git a/src/libmsc/rtp_stream.c b/src/libmsc/rtp_stream.c
index d78743e..2902520 100644
--- a/src/libmsc/rtp_stream.c
+++ b/src/libmsc/rtp_stream.c
@@ -74,7 +74,7 @@
 		OSMO_STRBUF_PRINTF(sb, ":no-CI");
 	} else {
 		OSMO_STRBUF_PRINTF(sb, ":CI-%s", osmo_mgcpc_ep_ci_id(rtps->ci));
-		if (!osmo_sockaddr_str_is_set(&rtps->remote))
+		if (!osmo_sockaddr_str_is_nonzero(&rtps->remote))
 			OSMO_STRBUF_PRINTF(sb, ":no-remote-port");
 		else if (!rtps->remote_sent_to_mgw)
 			OSMO_STRBUF_PRINTF(sb, ":remote-port-not-sent");
@@ -89,9 +89,9 @@
 				OSMO_STRBUF_PRINTF(sb, ":remote-osmux-cid-not-sent");
 		}
 	}
-	if (osmo_sockaddr_str_is_set(&rtps->local))
+	if (osmo_sockaddr_str_is_nonzero(&rtps->local))
 		OSMO_STRBUF_PRINTF(sb, ":local-%s-%u", rtps->local.ip, rtps->local.port);
-	if (osmo_sockaddr_str_is_set(&rtps->remote))
+	if (osmo_sockaddr_str_is_nonzero(&rtps->remote))
 		OSMO_STRBUF_PRINTF(sb, ":remote-%s-%u", rtps->remote.ip, rtps->remote.port);
 	if (rtps->use_osmux)
 		OSMO_STRBUF_PRINTF(sb, ":osmux-%d-%d", rtps->local_osmux_cid, rtps->remote_osmux_cid);
@@ -137,8 +137,8 @@
 static void check_established(struct rtp_stream *rtps)
 {
 	if (rtps->fi->state != RTP_STREAM_ST_ESTABLISHED
-	    && osmo_sockaddr_str_is_set(&rtps->local)
-	    && osmo_sockaddr_str_is_set(&rtps->remote)
+	    && osmo_sockaddr_str_is_nonzero(&rtps->local)
+	    && osmo_sockaddr_str_is_nonzero(&rtps->remote)
 	    && rtps->remote_sent_to_mgw
 	    && (!rtps->use_osmux || rtps->remote_osmux_cid_sent_to_mgw)
 	    && rtps->codec_known)
@@ -172,7 +172,7 @@
 		check_established(rtps);
 
 		if ((!rtps->remote_sent_to_mgw || !rtps->codec_sent_to_mgw)
-		    && osmo_sockaddr_str_is_set(&rtps->remote)
+		    && osmo_sockaddr_str_is_nonzero(&rtps->remote)
 		    && (!rtps->use_osmux || rtps->remote_osmux_cid_sent_to_mgw)
 		    && rtps->codec_known) {
 			LOG_RTPS(rtps, LOGL_DEBUG,
@@ -315,7 +315,7 @@
 		verb_info.codecs_len = 1;
 		rtps->codec_sent_to_mgw = true;
 	}
-	if (osmo_sockaddr_str_is_set(&rtps->remote)) {
+	if (osmo_sockaddr_str_is_nonzero(&rtps->remote)) {
 		int rc = osmo_strlcpy(verb_info.addr, rtps->remote.ip, sizeof(verb_info.addr));
 		if (rc <= 0 || rc >= sizeof(verb_info.addr)) {
 			LOG_RTPS(rtps, LOGL_ERROR, "Failure to write IP address to MGCP message (rc=%d)\n", rc);
@@ -365,7 +365,7 @@
 		LOG_RTPS(rtps, LOGL_DEBUG, "Not committing: no MGW endpoint CI set up\n");
 		return -1;
 	}
-	if (!osmo_sockaddr_str_is_set(&rtps->remote)) {
+	if (!osmo_sockaddr_str_is_nonzero(&rtps->remote)) {
 		LOG_RTPS(rtps, LOGL_DEBUG, "Not committing: no remote RTP address known\n");
 		return -1;
 	}

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/15852
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Change-Id: I53ddb19a70fda3deb906464e1b89c12d9b4c7cbd
Gerrit-Change-Number: 15852
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191104/7be4ecf4/attachment.htm>


More information about the gerrit-log mailing list