mncc: Support IPv6 addresses (new version mncc 7)

Change-Id: I6002b648bcb2055dcbbdae3f688f6e2cb7282b7f
pespin/ipv6
Pau Espin 2 years ago
parent 0632717dc1
commit eeda9e123f
  1. 6
      include/osmocom/msc/mncc.h
  2. 15
      src/libmsc/gsm_04_08_cc.c
  3. 5
      src/libmsc/mncc_call.c
  4. 7
      src/libmsc/sdp_msg.c
  5. 18
      tests/mncc/mncc_test.ok

@ -28,6 +28,7 @@
#include <osmocom/gsm/mncc.h>
#include <stdint.h>
#include <netinet/in.h>
struct gsm_network;
struct msgb;
@ -170,7 +171,7 @@ struct gsm_data_frame {
unsigned char data[0];
};
#define MNCC_SOCK_VERSION 6
#define MNCC_SOCK_VERSION 7
struct gsm_mncc_hello {
uint32_t msg_type;
uint32_t version;
@ -189,8 +190,7 @@ struct gsm_mncc_hello {
struct gsm_mncc_rtp {
uint32_t msg_type;
uint32_t callref;
uint32_t ip;
uint16_t port;
struct sockaddr_storage addr;
uint32_t payload_type;
uint32_t payload_msg_type;
char sdp[1024];

@ -1623,8 +1623,8 @@ static int mncc_recv_rtp(struct gsm_network *net, struct gsm_trans *trans, uint3
rtp->callref = callref;
rtp->msg_type = cmd;
if (rtp_addr) {
rtp->ip = osmo_htonl(inet_addr(rtp_addr->ip));
rtp->port = rtp_addr->port;
if (osmo_sockaddr_str_to_sockaddr(rtp_addr, &rtp->addr) < 0)
return -EINVAL;
}
rtp->payload_type = payload_type;
rtp->payload_msg_type = payload_msg_type;
@ -1710,6 +1710,7 @@ static int tch_rtp_connect(struct gsm_network *net, const struct gsm_mncc_rtp *r
struct call_leg *cl;
struct rtp_stream *rtps;
struct osmo_sockaddr_str rtp_addr;
char ipbuf[INET6_ADDRSTRLEN];
/* FIXME: in *rtp we should get the codec information of the remote
* leg. We will have to populate trans->conn->rtp.codec_cn with a
@ -1735,7 +1736,9 @@ static int tch_rtp_connect(struct gsm_network *net, const struct gsm_mncc_rtp *r
return -EIO;
}
LOG_TRANS_CAT(trans, DMNCC, LOGL_DEBUG, "rx %s\n", get_mncc_name(MNCC_RTP_CONNECT));
LOG_TRANS_CAT(trans, DMNCC, LOGL_DEBUG, "rx %s %s:%u\n", get_mncc_name(MNCC_RTP_CONNECT),
osmo_sockaddr_ntop((const struct sockaddr*)&rtp->addr, ipbuf),
osmo_sockaddr_port((const struct sockaddr*)&rtp->addr));
cl = trans->msc_a->cc.call_leg;
rtps = cl ? cl->rtp[RTP_TO_CN] : NULL;
@ -1746,7 +1749,11 @@ static int tch_rtp_connect(struct gsm_network *net, const struct gsm_mncc_rtp *r
return -EINVAL;
}
osmo_sockaddr_str_from_32n(&rtp_addr, rtp->ip, rtp->port);
if (osmo_sockaddr_str_from_sockaddr(&rtp_addr, &rtp->addr) < 0) {
LOG_TRANS_CAT(trans, DMNCC, LOGL_ERROR, "RTP connect with invalid IP addr\n");
mncc_recv_rtp_err(net, trans, rtp->callref, MNCC_RTP_CONNECT);
return -EINVAL;
}
rtp_stream_set_remote_addr(rtps, &rtp_addr);
rtp_stream_commit(rtps);
return 0;

@ -303,11 +303,10 @@ static bool mncc_call_tx_rtp_create(struct mncc_call *mncc_call)
.rtp = {
.msg_type = MNCC_RTP_CREATE,
.callref = mncc_call->callref,
.port = rtp_local->port,
},
};
if (osmo_sockaddr_str_to_32n(rtp_local, &mncc_msg.rtp.ip)) {
if (osmo_sockaddr_str_to_sockaddr(rtp_local, &mncc_msg.rtp.addr)) {
mncc_call_error(mncc_call, "Failed to compose IP address " OSMO_SOCKADDR_STR_FMT "\n",
OSMO_SOCKADDR_STR_FMT_ARGS(rtp_local));
return false;
@ -332,7 +331,7 @@ static bool mncc_call_rx_rtp_connect(struct mncc_call *mncc_call, const struct g
return true;
}
if (osmo_sockaddr_str_from_32n(&rtp, mncc_msg->ip, mncc_msg->port)) {
if (osmo_sockaddr_str_from_sockaddr(&rtp, &mncc_msg->addr)) {
mncc_call_error(mncc_call, "Cannot RTP-CONNECT, invalid RTP IP:port in incoming MNCC message\n");
return false;
}

@ -168,15 +168,16 @@ int sdp_msg_to_str(char *dst, size_t dst_size, const struct sdp_msg *sdp)
const struct sdp_audio_codec *codec;
struct osmo_strbuf sb = { .buf = dst, .len = dst_size };
const char *ip = sdp->rtp.ip[0] ? sdp->rtp.ip : "0.0.0.0";
char ipv = osmo_ip_str_type(ip) == AF_INET6 ? '6' : '4';
OSMO_STRBUF_PRINTF(sb,
"v=0\r\n"
"o=OsmoMSC 0 0 IN IP4 %s\r\n"
"o=OsmoMSC 0 0 IN IP%c %s\r\n"
"s=GSM Call\r\n"
"c=IN IP4 %s\r\n"
"c=IN IP%c %s\r\n"
"t=0 0\r\n"
"m=audio %d RTP/AVP",
ip, ip,
ipv, ip, ipv, ip,
sdp->rtp.port);
/* Append all payload type numbers to 'm=audio <port> RTP/AVP 3 4 112' line */

@ -12,12 +12,12 @@ len way too short: len=10 sdplen=-824 sdp=- rc=-22
len zero: len=0 sdplen=-834 sdp=- rc=-22
struct gsm_mncc_rtp:
empty SDP: len=1048 sdplen=1024 sdp="\0" rc=0
empty SDP, shortest possible: len=25 sdplen=1 sdp="\0" rc=0
empty SDP, zero len: len=24 sdplen=0 sdp=- rc=-22
terminated SDP str: len=1048 sdplen=1024 sdp="Privacy is a desirable marketing option\0" rc=0
terminated SDP str, shortest possible: len=64 sdplen=40 sdp="Privacy is a desirable marketing option\0" rc=0
terminated SDP str, but len excludes nul: len=63 sdplen=39 sdp="Privacy is a desirable marketing option" rc=-22
terminated SDP str, but len too short: len=47 sdplen=23 sdp="Privacy is a desirable " rc=-22
len way too short: len=10 sdplen=-14 sdp=- rc=-22
len zero: len=0 sdplen=-24 sdp=- rc=-22
empty SDP: len=1168 sdplen=1024 sdp="\0" rc=0
empty SDP, shortest possible: len=145 sdplen=1 sdp="\0" rc=0
empty SDP, zero len: len=144 sdplen=0 sdp=- rc=-22
terminated SDP str: len=1168 sdplen=1024 sdp="Privacy is a desirable marketing option\0" rc=0
terminated SDP str, shortest possible: len=184 sdplen=40 sdp="Privacy is a desirable marketing option\0" rc=0
terminated SDP str, but len excludes nul: len=183 sdplen=39 sdp="Privacy is a desirable marketing option" rc=-22
terminated SDP str, but len too short: len=167 sdplen=23 sdp="Privacy is a desirable " rc=-22
len way too short: len=10 sdplen=-134 sdp=- rc=-22
len zero: len=0 sdplen=-144 sdp=- rc=-22

Loading…
Cancel
Save