Change in osmo-mgw[master]: mgcp-client: Support IPv6 in osmo_mgcpc_ep_ci_get_crcx_info_to_sockad...

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
Fri Aug 28 17:28:49 UTC 2020


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


Change subject: mgcp-client: Support IPv6 in osmo_mgcpc_ep_ci_get_crcx_info_to_sockaddr() implementation
......................................................................

mgcp-client: Support IPv6 in osmo_mgcpc_ep_ci_get_crcx_info_to_sockaddr() implementation

Change-Id: Ibbfc1c2485636502dc0f3aef3922432cc7fd6170
---
M src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c
1 file changed, 22 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/83/19883/1

diff --git a/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c b/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c
index ef4da17..c68d8b3 100644
--- a/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c
+++ b/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c
@@ -27,6 +27,7 @@
 #include <osmocom/core/fsm.h>
 #include <osmocom/core/byteswap.h>
 #include <osmocom/core/tdef.h>
+#include <osmocom/core/sockaddr_str.h>
 
 #include <osmocom/mgcp_client/mgcp_client_endpoint_fsm.h>
 
@@ -517,17 +518,33 @@
 bool osmo_mgcpc_ep_ci_get_crcx_info_to_sockaddr(const struct osmo_mgcpc_ep_ci *ci, struct sockaddr_storage *dest)
 {
 	const struct mgcp_conn_peer *rtp_info;
+	int family;
 	struct sockaddr_in *sin;
+	struct sockaddr_in6 *sin6;
 
 	rtp_info = osmo_mgcpc_ep_ci_get_rtp_info(ci);
 	if (!rtp_info)
 		return false;
 
-        sin = (struct sockaddr_in *)dest;
-
-        sin->sin_family = AF_INET;
-        sin->sin_addr.s_addr = inet_addr(rtp_info->addr);
-        sin->sin_port = osmo_ntohs(rtp_info->port);
+	family = osmo_ip_str_type(rtp_info->addr);
+	switch (family) {
+	case AF_INET:
+		sin = (struct sockaddr_in *)dest;
+		sin->sin_family = AF_INET;
+		sin->sin_port = osmo_ntohs(rtp_info->port);
+		if (inet_pton(AF_INET, rtp_info->addr, &sin->sin_addr) != 1)
+			return false;
+		break;
+	case AF_INET6:
+		sin6 = (struct sockaddr_in6 *)dest;
+		sin6->sin6_family = AF_INET6;
+		sin6->sin6_port = osmo_ntohs(rtp_info->port);
+		if (inet_pton(AF_INET6, rtp_info->addr, &sin6->sin6_addr) != 1)
+			return false;
+		break;
+	default:
+		return false;
+	}
 	return true;
 }
 

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

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: Ibbfc1c2485636502dc0f3aef3922432cc7fd6170
Gerrit-Change-Number: 19883
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/20200828/9c86a418/attachment.htm>


More information about the gerrit-log mailing list