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
changes/52/15852/2
Neels Hofmeyr 3 years ago
parent 523b92f3aa
commit 84ce206ae3
  1. 4
      src/libmsc/call_leg.c
  2. 4
      src/libmsc/mncc_call.c
  3. 6
      src/libmsc/msc_ho.c
  4. 2
      src/libmsc/msc_t.c
  5. 6
      src/libmsc/ran_msg_a.c
  6. 16
      src/libmsc/rtp_stream.c

@ -301,7 +301,7 @@ struct osmo_sockaddr_str *call_leg_local_ip(struct call_leg *cl, enum rtp_direct
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 @@ int call_leg_ensure_ci(struct call_leg *cl, enum rtp_direction dir, uint32_t cal
}
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);
}

@ -256,7 +256,7 @@ static bool mncc_call_rx_rtp_create(struct mncc_call *mncc_call)
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 @@ uint32_t mgcp_codec_to_mncc_payload_msg_type(enum mgcp_codecs codec)
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;
}

@ -661,7 +661,7 @@ static void msc_ho_rx_request_ack(struct msc_a *msc_a, struct msc_a_ran_dec_data
}
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 @@ static void msc_ho_rtp_switch_to_new_cell(struct msc_a *msc_a)
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 @@ static void msc_ho_rtp_rollback_to_old_cell(struct msc_a *msc_a)
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;
}

@ -444,7 +444,7 @@ static int msc_t_patch_and_send_ho_request_ack(struct msc_t *msc_t, const struct
/* 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);

@ -942,7 +942,7 @@ static struct msgb *ran_a_make_assignment_command(struct osmo_fsm_inst *log_fi,
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 @@ struct msgb *ran_a_make_handover_request(struct osmo_fsm_inst *log_fi, const str
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 @@ static struct msgb *ran_a_make_handover_request_ack(struct osmo_fsm_inst *caller
.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;
}

@ -74,7 +74,7 @@ void rtp_stream_update_id(struct rtp_stream *rtps)
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 @@ void rtp_stream_update_id(struct rtp_stream *rtps)
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 @@ struct rtp_stream *rtp_stream_alloc(struct call_leg *parent_call_leg, enum rtp_d
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 @@ static void rtp_stream_fsm_establishing_established(struct osmo_fsm_inst *fi, ui
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 @@ static int rtp_stream_do_mgcp_verb(struct rtp_stream *rtps, enum mgcp_verb verb,
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 @@ int rtp_stream_commit(struct rtp_stream *rtps)
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;
}

Loading…
Cancel
Save