mgw: Initial IPv6 support
This commit contains the bulky work of moving all address parsing to
support IPv6 together with IPv4.
Some specific patches required for full IPv6+IPv4 support requiring
behavioral changes come after this one.
Full Osmux IPv6 support is left out of the scope of this patch.
Depends: libosmocore.git Ie07a38b05b7888885dba4ae795e9f3d9a561543d (> 1.4.0)
Depends: libosmocore.git I59bf4b4b3ed14766a5a5285923d1ffa9fc8b2294 (> 1.4.0)
Change-Id: I504ca776d88fd852bbaef07060c125980db3fdd7
diff --git a/src/libosmo-mgcp/mgcp_vty.c b/src/libosmo-mgcp/mgcp_vty.c
index 22863c7..8ea1cdd 100644
--- a/src/libosmo-mgcp/mgcp_vty.c
+++ b/src/libosmo-mgcp/mgcp_vty.c
@@ -22,6 +22,7 @@
*/
#include <osmocom/core/talloc.h>
+#include <osmocom/core/sockaddr_str.h>
#include <osmocom/vty/misc.h>
#include <osmocom/mgcp/mgcp.h>
#include <osmocom/mgcp/mgcp_common.h>
@@ -407,9 +408,11 @@
DEFUN(cfg_mgcp_local_ip,
cfg_mgcp_local_ip_cmd,
- "local ip A.B.C.D",
+ "local ip " VTY_IPV46_CMD,
"Local options for the SDP record\n"
- IP_STR "IPv4 Address to use in SDP record\n")
+ IP_STR
+ "IPv4 Address to use in SDP record\n"
+ "IPv6 Address to use in SDP record\n")
{
osmo_talloc_replace_string(g_cfg, &g_cfg->local_ip, argv[0]);
return CMD_SUCCESS;
@@ -418,7 +421,10 @@
#define BIND_STR "Listen/Bind related socket option\n"
DEFUN(cfg_mgcp_bind_ip,
cfg_mgcp_bind_ip_cmd,
- "bind ip A.B.C.D", BIND_STR IP_STR "IPv4 Address to bind to\n")
+ "bind ip " VTY_IPV46_CMD,
+ BIND_STR IP_STR
+ "IPv4 Address to bind to\n"
+ "IPv6 Address to bind to\n")
{
osmo_talloc_replace_string(g_cfg, &g_cfg->source_addr, argv[0]);
return CMD_SUCCESS;
@@ -494,8 +500,10 @@
DEFUN(cfg_mgcp_rtp_bind_ip,
cfg_mgcp_rtp_bind_ip_cmd,
- "rtp bind-ip A.B.C.D",
- RTP_STR "Bind endpoints facing the Network\n" "Address to bind to\n")
+ "rtp bind-ip " VTY_IPV46_CMD,
+ RTP_STR "Bind endpoints facing the Network\n"
+ "IPv4 Address to bind to\n"
+ "IPv6 Address to bind to\n")
{
osmo_talloc_replace_string(g_cfg, &g_cfg->net_ports.bind_addr, argv[0]);
return CMD_SUCCESS;
@@ -850,11 +858,13 @@
return CMD_SUCCESS;
}
-#define CALL_AGENT_STR "Callagent information\n"
+#define CALL_AGENT_STR "Call agent information\n"
DEFUN(cfg_mgcp_agent_addr,
cfg_mgcp_agent_addr_cmd,
- "call-agent ip A.B.C.D",
- CALL_AGENT_STR IP_STR "IPv4 Address of the callagent\n")
+ "call-agent ip " VTY_IPV46_CMD,
+ CALL_AGENT_STR IP_STR
+ "IPv4 Address of the call agent\n"
+ "IPv6 Address of the call agent\n")
{
osmo_talloc_replace_string(g_cfg, &g_cfg->call_agent_addr, argv[0]);
return CMD_SUCCESS;
@@ -1236,13 +1246,15 @@
DEFUN(tap_rtp,
tap_rtp_cmd,
- "tap-rtp <0-64> ENDPOINT CONN (in|out) A.B.C.D <0-65534>",
+ "tap-rtp <0-64> ENDPOINT CONN (in|out) " VTY_IPV46_CMD " <0-65534>",
"Forward data on endpoint to a different system\n" "Trunk number\n"
"The endpoint in hex\n"
"The connection id in hex\n"
"Forward incoming data\n"
"Forward leaving data\n"
- "destination IP of the data\n" "destination port\n")
+ "Destination IPv4 of the data\n"
+ "Destination IPv6 of the data\n"
+ "Destination port\n")
{
struct mgcp_rtp_tap *tap;
struct mgcp_trunk *trunk;
@@ -1290,8 +1302,22 @@
}
memset(&tap->forward, 0, sizeof(tap->forward));
- inet_aton(argv[4], &tap->forward.sin_addr);
- tap->forward.sin_port = htons(atoi(argv[5]));
+
+ tap->forward.u.sa.sa_family = osmo_ip_str_type(argv[4]);
+ switch (tap->forward.u.sa.sa_family) {
+ case AF_INET:
+ if (inet_pton(AF_INET, argv[4], &tap->forward.u.sin.sin_addr) != 1)
+ return CMD_WARNING;
+ tap->forward.u.sin.sin_port = htons(atoi(argv[5]));
+ break;
+ case AF_INET6:
+ if (inet_pton(AF_INET6, argv[4], &tap->forward.u.sin6.sin6_addr) != 1)
+ return CMD_WARNING;
+ tap->forward.u.sin6.sin6_port = htons(atoi(argv[5]));
+ break;
+ default:
+ return CMD_WARNING;
+ }
tap->enabled = 1;
return CMD_SUCCESS;
}
@@ -1407,7 +1433,10 @@
DEFUN(cfg_mgcp_osmux_ip,
cfg_mgcp_osmux_ip_cmd,
- "osmux bind-ip A.B.C.D", OSMUX_STR IP_STR "IPv4 Address to bind to\n")
+ "osmux bind-ip " VTY_IPV46_CMD,
+ OSMUX_STR IP_STR
+ "IPv4 Address to bind to\n"
+ "IPv6 Address to bind to\n")
{
osmo_talloc_replace_string(g_cfg, &g_cfg->osmux_addr, argv[0]);
return CMD_SUCCESS;