Change in osmo-ttcn3-hacks[master]: WIP: mncc: Support IPv6 addresses (new version mncc 7)

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

pespin gerrit-no-reply at lists.osmocom.org
Wed Sep 9 18:58:03 UTC 2020


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/20056 )


Change subject: WIP: mncc: Support IPv6 addresses (new version mncc 7)
......................................................................

WIP: mncc: Support IPv6 addresses (new version mncc 7)

Apparently commit 06b859ca314f53a902329ed95848dbafef1d4f87 forgot to
bump the MNCC_SOCK_VERSION field from 5  to 6 in

TODO: check what about MNCC_Emulation.mp_mncc_version

TODO: Add IPv6 tests for sip/SIP_Tests

Change-Id: I5448ff931ec33f24f4837a51376f1703fe97683b
---
M library/MNCC_Emulation.ttcn
M library/MNCC_EncDec.cc
M library/MNCC_Types.ttcn
M library/mncc.h
4 files changed, 47 insertions(+), 14 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/56/20056/1

diff --git a/library/MNCC_Emulation.ttcn b/library/MNCC_Emulation.ttcn
index be087ec..13a842b 100644
--- a/library/MNCC_Emulation.ttcn
+++ b/library/MNCC_Emulation.ttcn
@@ -38,7 +38,7 @@
 import from UD_Types all;
 
 modulepar {
-	int mp_mncc_version := 6;
+	int mp_mncc_version := 7;
 }
 
 /* General "base class" component definition, of which specific implementations
diff --git a/library/MNCC_EncDec.cc b/library/MNCC_EncDec.cc
index f2692d7..d9529ee 100644
--- a/library/MNCC_EncDec.cc
+++ b/library/MNCC_EncDec.cc
@@ -188,8 +188,20 @@
 		memset(&rtp, 0, sizeof(rtp));
 		rtp.msg_type = in.msg__type();
 		rtp.callref = in.u().rtp().callref();
-		rtp.ip = in.u().rtp().ip();
-		rtp.port = in.u().rtp().rtp__port();
+		if (in.u().rtp().is__ipv6()) {
+			rtp.addr.ss_family = AF_INET6;
+			((struct sockaddr_in6*)&rtp.addr)->sin6_port = in.u().rtp().rtp__port();
+			//TODO: verify octetstring len
+			memcpy(((struct sockaddr_in6*)&rtp.addr)->sin6_addr, in.u().rtp().ip().data(),
+			       sizeof(struct in6_addr));
+		} else {
+			rtp.addr.ss_family = AF_INET;
+			((struct sockaddr_in*)&rtp.addr)->sin_port = in.u().rtp().rtp__port();
+			//TODO: verify octetstring len
+			memcpy(((struct sockaddr_in*)&rtp.addr)->sin_addr, in.u().rtp().ip().data(),
+			       sizeof(struct in_addr));
+			//rtp.ip = in.u().rtp().ip();
+		}
 		rtp.payload_type = in.u().rtp().payload__type();
 		rtp.payload_msg_type = in.u().rtp().payload__msg__type();
 		ret_val = OCTETSTRING(sizeof(rtp), (uint8_t *) &rtp);
@@ -224,6 +236,9 @@
 	const struct gsm_mncc_rtp *in_rtp;
 	MNCC__PDU__Rtp rtp;
 	MNCC__MsgUnion u;
+	bool is_ipv6;
+	OCTETSTRING ip;
+	uint16_t port;
 
 	in_mncc = (struct gsm_mncc *) ttcn_buffer.get_read_data();
 
@@ -258,7 +273,20 @@
 	case MNCC_RTP_CONNECT:
 	case MNCC_RTP_FREE:
 		in_rtp = (const struct gsm_mncc_rtp *) in_mncc;
-		rtp = MNCC__PDU__Rtp(in_rtp->callref, in_rtp->ip, in_rtp->port, in_rtp->payload_type,
+		switch (in_rtp->addr.ss_family) {
+		case AF_INET:
+			is_ipv6 = false;
+			port = ((struct sockaddr_in*)&in_rtp->addr)->sin_port;
+			ip = OCTETSTRING(sizeof(struct in_addr), &(struct sockaddr_in*)&in_rtp->addr)->sin_addr);
+		break;
+		case AF_INET6:
+			is_ipv6 = true;
+			port = ((struct sockaddr_in6*)&in_rtp->addr)->sin6_port;
+			ip = OCTETSTRING(sizeof(struct in6_addr), &(struct sockaddr_in6*)&in_rtp->addr)->sin6_addr);
+
+		break;
+		}
+		rtp = MNCC__PDU__Rtp(in_rtp->callref, is_ipv6, ip, port, in_rtp->payload_type,
 				     in_rtp->payload_msg_type, in_rtp->sdp);
 		u.rtp() = rtp;
 		break;
diff --git a/library/MNCC_Types.ttcn b/library/MNCC_Types.ttcn
index 0a8e7d9..fa4fc3e 100644
--- a/library/MNCC_Types.ttcn
+++ b/library/MNCC_Types.ttcn
@@ -373,7 +373,8 @@
 
 type record MNCC_PDU_Rtp {
 	uint32_t	callref,
-	uint32_t	ip,
+	boolean		is_ipv6,
+	octetstring	ip, //TODO: define size of octetstring based on is_ipv6 using CROSSTAGS?
 	uint16_t	rtp_port,
 	uint32_t	payload_type,
 	uint32_t	payload_msg_type,
@@ -1921,7 +1922,8 @@
 	u := {
 		rtp := {
 			callref := call_id,
-			ip := 0,
+			is_ipv6 := false,
+			ip := '00000000'O,
 			rtp_port := 0,
 			payload_type := 0,
 			payload_msg_type := 0,
@@ -1935,13 +1937,14 @@
 
 /* MSC -> MNCC: RTP_CREATE.rsp; acknowledge creation of RTP (stating MSC side IP/Port) */
 template MNCC_PDU tr_MNCC_RTP_CREATE(template uint32_t call_id := ?,
-				     template uint32_t ip := ?,
-				     template uint32_t rtp_port := ?,
+				     template octetstring ip := ?,
+				     template uint16_t rtp_port := ?,
 				     template uint32_t payload_type := ?) := {
 	msg_type := MNCC_RTP_CREATE,
 	u := {
 		rtp := {
 			callref := call_id,
+			is_ipv6 := false,
 			ip := ip,
 			rtp_port := rtp_port,
 			payload_type := payload_type,
@@ -1952,11 +1955,12 @@
 }
 
 /* MSC <- MNCC: RTP_CONNECT.req; request connect of RTP */
-template MNCC_PDU ts_MNCC_RTP_CONNECT(uint32_t call_id, uint32_t ip, uint32_t rtp_port, uint32_t pt) := {
+template MNCC_PDU ts_MNCC_RTP_CONNECT(uint32_t call_id, octetstring ip, uint16_t rtp_port, uint32_t pt) := {
 	msg_type := MNCC_RTP_CONNECT,
 	u := {
 		rtp := {
 			callref := call_id,
+			is_ipv6 := false,
 			ip := ip,
 			rtp_port := rtp_port,
 			payload_type := pt,
@@ -1966,13 +1970,14 @@
 	}
 }
 template MNCC_PDU tr_MNCC_RTP_CONNECT(template uint32_t call_id,
-				      template uint32_t ip := ?,
-				      template uint32_t rtp_port := ?,
+				      template octetstring ip := ?,
+				      template uint16_t rtp_port := ?,
 				      template uint32_t pt := ?) := {
 	msg_type := MNCC_RTP_CONNECT,
 	u := {
 		rtp := {
 			callref := call_id,
+			is_ipv6 := false,
 			ip := ip,
 			rtp_port := rtp_port,
 			payload_type := pt,
diff --git a/library/mncc.h b/library/mncc.h
index 9aff948..1e45c37 100644
--- a/library/mncc.h
+++ b/library/mncc.h
@@ -5,6 +5,7 @@
  */
 
 #include <stdint.h>
+#include <netinet/in.h>
 
 /* GSM 04.08 Bearer Capability: Rate Adaption */
 enum gsm48_bcap_ra {
@@ -275,7 +276,7 @@
 	unsigned char	data[0];
 };
 
-#define MNCC_SOCK_VERSION	5
+#define MNCC_SOCK_VERSION	7
 struct gsm_mncc_hello {
 	uint32_t	msg_type;
 	uint32_t	version;
@@ -294,8 +295,7 @@
 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;
 

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

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I5448ff931ec33f24f4837a51376f1703fe97683b
Gerrit-Change-Number: 20056
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200909/0136fa63/attachment.htm>


More information about the gerrit-log mailing list