pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-msc/+/43259?usp=email )


Change subject: iu: Fix encoding of IPv6 RTP address in RAB Ass Req
......................................................................

iu: Fix encoding of IPv6 RTP address in RAB Ass Req

Use the newly added ranap_new_msg_rab_assign_voice2() API from osmo-iuh,
which allows passing a struct osmo_sockaddr hence supporting IPv6.
This way we get rid of the use of deprecated inet_addr() API.

Also make sure to avoid crashing if the function fails (return NULL).

Depends: osmo-iuh.git I3a8800afd03b94349c8acec778ab7003819e80af
Change-Id: I23298235f4457bd556d2291d81c4aed3f009af0f
---
M TODO-RELEASE
M src/libmsc/ran_msg_iu.c
2 files changed, 16 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/59/43259/1

diff --git a/TODO-RELEASE b/TODO-RELEASE
index c8858d8..9734dd0 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -9,3 +9,4 @@
 #library       what                    description / commit summary line
 libosmovty     >=1.12.1                working optional-multi-choice
 libosmocore >1.12.0     log_get_context(), log_{get,set}_filter(_data)()
+osmo-iuh        >1.8.0                  ranap_new_msg_rab_assign_voice2()
diff --git a/src/libmsc/ran_msg_iu.c b/src/libmsc/ran_msg_iu.c
index 37cdf10..823c91b 100644
--- a/src/libmsc/ran_msg_iu.c
+++ b/src/libmsc/ran_msg_iu.c
@@ -348,7 +348,7 @@
 {
        struct msgb *msg;
        bool use_x213_nsap;
-       uint32_t cn_rtp_ip;
+       struct osmo_sockaddr cn_rtp_addr = {};
        static uint8_t next_rab_id = 1;
        uint8_t rab_id = next_rab_id;

@@ -356,22 +356,29 @@
        if (!next_rab_id)
                next_rab_id = 1;

-       cn_rtp_ip = osmo_htonl(inet_addr(ac->cn_rtp->ip));
-
-       if (cn_rtp_ip == INADDR_NONE) {
-               LOG_RAN_IU_ENC(caller_fi, LOGL_ERROR, "Error during RAB 
Assignment: invalid RTP IP-Address\n");
-               return NULL;
-       }
+       OSMO_ASSERT(ac->cn_rtp);
        if (ac->cn_rtp->port == 0) {
                LOG_RAN_IU_ENC(caller_fi, LOGL_ERROR, "Error during RAB 
Assignment: invalid RTP port\n");
                return NULL;
        }

+       if (osmo_sockaddr_str_to_osa(ac->cn_rtp, &cn_rtp_addr) < 0) {
+               LOG_RAN_IU_ENC(caller_fi, LOGL_ERROR, "Error during RAB 
Assignment: invalid RTP IP-Address\n");
+               return NULL;
+       }
+
        use_x213_nsap = (ac->rab_assign_addr_enc == NSAP_ADDR_ENC_X213);
        LOG_RAN_IU_ENC(caller_fi, LOGL_DEBUG, "RAB Assignment: rab_id=%d, rtp=" 
OSMO_SOCKADDR_STR_FMT ", use_x213_nsap=%d\n",
                        rab_id, OSMO_SOCKADDR_STR_FMT_ARGS(ac->cn_rtp), 
use_x213_nsap);

-       msg = ranap_new_msg_rab_assign_voice(rab_id, cn_rtp_ip, 
ac->cn_rtp->port, use_x213_nsap);
+       msg = ranap_new_msg_rab_assign_voice2(rab_id, &cn_rtp_addr, 
use_x213_nsap);
+       if (!msg) {
+               LOG_RAN_IU_ENC(caller_fi, LOGL_ERROR,
+                              "Error during RAB Assignment: Encoding failed 
rab_id=%d, rtp="
+                              OSMO_SOCKADDR_STR_FMT ", use_x213_nsap=%d\n",
+                              rab_id, OSMO_SOCKADDR_STR_FMT_ARGS(ac->cn_rtp), 
use_x213_nsap);
+               return NULL;
+       }
        msg->l2h = msg->data;

        return msg;

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

Gerrit-MessageType: newchange
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Change-Id: I23298235f4457bd556d2291d81c4aed3f009af0f
Gerrit-Change-Number: 43259
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>

Reply via email to