Use struct gtp_addr for ms_addr and sgsn_addr

Prepare for IPv6 support by using a new struct for MS and SGSN
addresses, in which either an IPv4 or IPv6 can be stored.

Related: OS#6096
Change-Id: Ifc7e3b03a723fb544d1c7b789101102b2c27b60e
diff --git a/src/gtp-genl.c b/src/gtp-genl.c
index 9c9e8d3..82ef8ab 100644
--- a/src/gtp-genl.c
+++ b/src/gtp-genl.c
@@ -48,10 +48,10 @@
 	if (t->ifns >= 0)
 		mnl_attr_put_u32(nlh, GTPA_NET_NS_FD, t->ifns);
 	mnl_attr_put_u32(nlh, GTPA_LINK, t->ifidx);
-	if (t->sgsn_addr.s_addr)
-		mnl_attr_put_u32(nlh, GTPA_PEER_ADDRESS, t->sgsn_addr.s_addr);
-	if (t->ms_addr.s_addr)
-		mnl_attr_put_u32(nlh, GTPA_MS_ADDRESS, t->ms_addr.s_addr);
+	if (t->sgsn_addr.ip4.s_addr)
+		mnl_attr_put_u32(nlh, GTPA_PEER_ADDRESS, t->sgsn_addr.ip4.s_addr);
+	if (t->ms_addr.ip4.s_addr)
+		mnl_attr_put_u32(nlh, GTPA_MS_ADDRESS, t->ms_addr.ip4.s_addr);
 	if (t->gtp_version == GTP_V0) {
 		mnl_attr_put_u64(nlh, GTPA_TID, t->u.v0.tid);
 		mnl_attr_put_u16(nlh, GTPA_FLOW, t->u.v0.flowid);
@@ -116,8 +116,8 @@
 			uint32_t o_tei;
 		} v1;
 	} u;
-	struct in_addr	sgsn_addr;
-	struct in_addr	ms_addr;
+	struct gtp_addr sgsn_addr;
+	struct gtp_addr ms_addr;
 };
 
 static int genl_gtp_validate_cb(const struct nlattr *attr, void *data)
@@ -167,11 +167,13 @@
 	if (tb[GTPA_O_TEI])
 		pdp.u.v1.o_tei = mnl_attr_get_u32(tb[GTPA_O_TEI]);
 	if (tb[GTPA_PEER_ADDRESS]) {
-		pdp.sgsn_addr.s_addr =
+		pdp.sgsn_addr.family = AF_INET;
+		pdp.sgsn_addr.ip4.s_addr =
 			mnl_attr_get_u32(tb[GTPA_PEER_ADDRESS]);
 	}
 	if (tb[GTPA_MS_ADDRESS]) {
-		pdp.ms_addr.s_addr = mnl_attr_get_u32(tb[GTPA_MS_ADDRESS]);
+		pdp.ms_addr.family = AF_INET;
+		pdp.ms_addr.ip4.s_addr = mnl_attr_get_u32(tb[GTPA_MS_ADDRESS]);
 	}
 	if (tb[GTPA_VERSION]) {
 		pdp.version = mnl_attr_get_u32(tb[GTPA_VERSION]);
@@ -179,15 +181,15 @@
 
 	printf("version %u ", pdp.version);
 	if (pdp.version == GTP_V0) {
-		inet_ntop(AF_INET, &pdp.ms_addr, buf, sizeof(buf));
+		inet_ntop(AF_INET, &pdp.ms_addr.ip4, buf, sizeof(buf));
 		printf("tid %"PRIu64" ms_addr %s ",
 		       pdp.u.v0.tid, buf);
 	} else if (pdp.version == GTP_V1) {
-		inet_ntop(AF_INET, &pdp.ms_addr, buf, sizeof(buf));
+		inet_ntop(AF_INET, &pdp.ms_addr.ip4, buf, sizeof(buf));
 		printf("tei %u/%u ms_addr %s ", pdp.u.v1.i_tei,
 		       pdp.u.v1.o_tei, buf);
 	}
-	inet_ntop(AF_INET, &pdp.sgsn_addr, buf, sizeof(buf));
+	inet_ntop(AF_INET, &pdp.sgsn_addr.ip4, buf, sizeof(buf));
 	printf("sgsn_addr %s\n", buf);
 
 	return MNL_CB_OK;