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/include/osmocom/mgcp/mgcp.h b/include/osmocom/mgcp/mgcp.h
index 33bfe71..75e531b 100644
--- a/include/osmocom/mgcp/mgcp.h
+++ b/include/osmocom/mgcp/mgcp.h
@@ -23,6 +23,7 @@
 #pragma once
 
 #include <osmocom/core/msgb.h>
+#include <osmocom/core/socket.h>
 #include <osmocom/core/write_queue.h>
 #include <osmocom/core/timer.h>
 #include <osmocom/core/logging.h>
@@ -207,4 +208,4 @@
 
 
 int mgcp_create_bind(const char *source_addr, struct osmo_fd *fd, int port);
-int mgcp_udp_send(int fd, struct in_addr *addr, int port, char *buf, int len);
+int mgcp_udp_send(int fd, struct osmo_sockaddr *addr, int port, char *buf, int len);
diff --git a/include/osmocom/mgcp/mgcp_endp.h b/include/osmocom/mgcp/mgcp_endp.h
index 065494f..14cae25 100644
--- a/include/osmocom/mgcp/mgcp_endp.h
+++ b/include/osmocom/mgcp/mgcp_endp.h
@@ -26,7 +26,7 @@
 #include <osmocom/core/msgb.h>
 #include <osmocom/gsm/i460_mux.h>
 
-struct sockaddr_in;
+struct sockaddr;
 struct mgcp_conn;
 struct mgcp_conn_rtp;
 struct mgcp_endpoint;
@@ -42,7 +42,7 @@
 struct osmo_rtp_msg_ctx {
 	int proto;
 	struct mgcp_conn_rtp *conn_src;
-	struct sockaddr_in *from_addr;
+	struct osmo_sockaddr *from_addr;
 };
 
 #define OSMO_RTP_MSG_CTX(MSGB) ((struct osmo_rtp_msg_ctx*)(MSGB)->cb)
diff --git a/include/osmocom/mgcp/mgcp_network.h b/include/osmocom/mgcp/mgcp_network.h
index c4967eb..9674445 100644
--- a/include/osmocom/mgcp/mgcp_network.h
+++ b/include/osmocom/mgcp/mgcp_network.h
@@ -2,6 +2,9 @@
 
 #include <inttypes.h>
 #include <stdbool.h>
+
+#include <osmocom/core/socket.h>
+
 #include <osmocom/mgcp/mgcp.h>
 
 #define MGCP_DUMMY_LOAD 0x23
@@ -79,7 +82,7 @@
 /* 'mgcp_rtp_end': basically a wrapper around the RTP+RTCP ports */
 struct mgcp_rtp_end {
 	/* remote IP address of the RTP socket */
-	struct in_addr addr;
+	struct osmo_sockaddr addr;
 
 	/* in network byte order */
 	int rtp_port, rtcp_port;
@@ -121,12 +124,12 @@
 	/* is this tap active (1) or not (0) */
 	int enabled;
 	/* IP/port to which we're forwarding the tapped data */
-	struct sockaddr_in forward;
+	struct osmo_sockaddr forward;
 };
 
 struct mgcp_conn;
 
-int mgcp_send(struct mgcp_endpoint *endp, int is_rtp, struct sockaddr_in *addr,
+int mgcp_send(struct mgcp_endpoint *endp, int is_rtp, struct osmo_sockaddr *addr,
 	      struct msgb *msg, struct mgcp_conn_rtp *conn_src,
 	      struct mgcp_conn_rtp *conn_dst);
 int mgcp_send_dummy(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn);
@@ -140,7 +143,7 @@
 void mgcp_patch_and_count(struct mgcp_endpoint *endp,
 			  struct mgcp_rtp_state *state,
 			  struct mgcp_rtp_end *rtp_end,
-			  struct sockaddr_in *addr, struct msgb *msg);
+			  struct osmo_sockaddr *addr, struct msgb *msg);
 void mgcp_get_local_addr(char *addr, struct mgcp_conn_rtp *conn);
 int mgcp_set_ip_tos(int fd, int tos);
 
diff --git a/include/osmocom/mgcp/osmux.h b/include/osmocom/mgcp/osmux.h
index 69ba3d0..99b44d1 100644
--- a/include/osmocom/mgcp/osmux.h
+++ b/include/osmocom/mgcp/osmux.h
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <osmocom/core/socket.h>
 
 #include <osmocom/netif/osmux.h>
 struct mgcp_conn_rtp;
@@ -13,7 +14,7 @@
 
 int osmux_init(int role, struct mgcp_config *cfg);
 int osmux_enable_conn(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn,
-		      struct in_addr *addr, uint16_t port);
+		      struct osmo_sockaddr *addr, uint16_t port);
 void conn_osmux_disable(struct mgcp_conn_rtp *conn);
 int conn_osmux_allocate_cid(struct mgcp_conn_rtp *conn, int osmux_cid);
 void conn_osmux_release_cid(struct mgcp_conn_rtp *conn);