aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2016-05-08 18:52:45 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2016-05-10 18:16:52 +0200
commitf69f8c73625a9ffcdc54a190f062b2e1223588b9 (patch)
tree6d789d4fa152ee675dd484d3325424452c8ec9cb
parent9438f72cc420a7401633121de32b14467bff50ae (diff)
gtp-genl: fix wrong MS address
This displays the SGSN address where we should show the MS address instead. And use inet_pton instead.
-rw-r--r--src/gtp-genl.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/gtp-genl.c b/src/gtp-genl.c
index 2f33adb..52183bb 100644
--- a/src/gtp-genl.c
+++ b/src/gtp-genl.c
@@ -149,6 +149,7 @@ static int genl_gtp_validate_cb(const struct nlattr *attr, void *data)
static int genl_gtp_attr_cb(const struct nlmsghdr *nlh, void *data)
{
struct nlattr *tb[GTPA_MAX + 1] = {};
+ char buf[INET_ADDRSTRLEN];
struct gtp_pdp pdp = {};
struct genlmsghdr *genl;
@@ -171,13 +172,17 @@ static int genl_gtp_attr_cb(const struct nlmsghdr *nlh, void *data)
}
printf("version %u ", pdp.version);
- if (pdp.version == GTP_V0)
+ if (pdp.version == GTP_V0) {
+ inet_ntop(AF_INET, &pdp.ms_addr, buf, sizeof(buf));
printf("tid %"PRIu64" ms_addr %s ",
- pdp.u.v0.tid, inet_ntoa(pdp.sgsn_addr));
- else if (pdp.version == GTP_V1)
+ pdp.u.v0.tid, buf);
+ } else if (pdp.version == GTP_V1) {
+ inet_ntop(AF_INET, &pdp.ms_addr, buf, sizeof(buf));
printf("tei %u/%u ms_addr %s ", pdp.u.v1.i_tei,
- pdp.u.v1.o_tei, inet_ntoa(pdp.sgsn_addr));
- printf("sgsn_addr %s\n", inet_ntoa(pdp.ms_addr));
+ pdp.u.v1.o_tei, buf);
+ }
+ inet_ntop(AF_INET, &pdp.sgsn_addr, buf, sizeof(buf));
+ printf("sgsn_addr %s\n", buf);
return MNL_CB_OK;
}