* [PATCH][iproute2] ip: xfrm: report nat-t/encapsulation portmapping updates
@ 2012-03-13 22:35 Florian Westphal
2012-03-15 21:50 ` Stephen Hemminger
0 siblings, 1 reply; 2+ messages in thread
From: Florian Westphal @ 2012-03-13 22:35 UTC (permalink / raw)
To: netdev; +Cc: Florian Westphal
Signed-off-by: Florian Westphal <fw@strlen.de>
---
ip/xfrm_monitor.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 49 insertions(+), 7 deletions(-)
diff --git a/ip/xfrm_monitor.c b/ip/xfrm_monitor.c
index 6a5b331..ea17987 100644
--- a/ip/xfrm_monitor.c
+++ b/ip/xfrm_monitor.c
@@ -221,6 +221,20 @@ void xfrm_ae_flags_print(__u32 flags, void *arg)
}
+static void xfrm_usersa_print(const struct xfrm_usersa_id *sa_id, __u32 reqid, FILE *fp)
+{
+ char buf[256];
+
+ buf[0] = 0;
+ fprintf(fp, "dst %s ", rt_addr_n2a(sa_id->family,
+ sizeof(sa_id->daddr), &sa_id->daddr, buf, sizeof(buf)));
+
+ fprintf(fp, " reqid 0x%x", reqid);
+
+ fprintf(fp, " protocol %s ", strxf_proto(sa_id->proto));
+ fprintf(fp, " SPI 0x%x", ntohl(sa_id->spi));
+}
+
static int xfrm_ae_print(const struct sockaddr_nl *who,
struct nlmsghdr *n, void *arg)
{
@@ -235,13 +249,8 @@ static int xfrm_ae_print(const struct sockaddr_nl *who,
fprintf(fp, "src %s ", rt_addr_n2a(id->sa_id.family,
sizeof(id->saddr), &id->saddr,
abuf, sizeof(abuf)));
- memset(abuf, '\0', sizeof(abuf));
- fprintf(fp, "dst %s ", rt_addr_n2a(id->sa_id.family,
- sizeof(id->sa_id.daddr), &id->sa_id.daddr,
- abuf, sizeof(abuf)));
- fprintf(fp, " reqid 0x%x", id->reqid);
- fprintf(fp, " protocol %s ", strxf_proto(id->sa_id.proto));
- fprintf(fp, " SPI 0x%x", ntohl(id->sa_id.spi));
+
+ xfrm_usersa_print(&id->sa_id, id->reqid, fp);
fprintf(fp, "\n");
fflush(fp);
@@ -249,6 +258,36 @@ static int xfrm_ae_print(const struct sockaddr_nl *who,
return 0;
}
+static void xfrm_print_addr(FILE *fp, int family, xfrm_address_t *a, size_t s)
+{
+ char buf[256];
+
+ buf[0] = 0;
+ fprintf(fp, "%s", rt_addr_n2a(family, s, a, buf, sizeof(buf)));
+}
+
+static int xfrm_mapping_print(const struct sockaddr_nl *who,
+ struct nlmsghdr *n, void *arg)
+{
+ FILE *fp = (FILE*)arg;
+ struct xfrm_user_mapping *map = NLMSG_DATA(n);
+
+ fprintf(fp, "Mapping change ");
+ xfrm_print_addr(fp, map->id.family, &map->old_saddr,
+ sizeof(map->old_saddr));
+
+ fprintf(fp, ":%d -> ", ntohs(map->old_sport));
+ xfrm_print_addr(fp, map->id.family, &map->new_saddr,
+ sizeof(map->new_saddr));
+ fprintf(fp, ":%d\n\t", ntohs(map->new_sport));
+
+ xfrm_usersa_print(&map->id, map->reqid, fp);
+
+ fprintf(fp, "\n");
+ fflush(fp);
+ return 0;
+}
+
static int xfrm_accept_msg(const struct sockaddr_nl *who,
struct nlmsghdr *n, void *arg)
{
@@ -285,6 +324,9 @@ static int xfrm_accept_msg(const struct sockaddr_nl *who,
case XFRM_MSG_NEWAE:
xfrm_ae_print(who, n, arg);
return 0;
+ case XFRM_MSG_MAPPING:
+ xfrm_mapping_print(who, n, arg);
+ return 0;
default:
break;
}
--
1.7.3.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][iproute2] ip: xfrm: report nat-t/encapsulation portmapping updates
2012-03-13 22:35 [PATCH][iproute2] ip: xfrm: report nat-t/encapsulation portmapping updates Florian Westphal
@ 2012-03-15 21:50 ` Stephen Hemminger
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2012-03-15 21:50 UTC (permalink / raw)
To: Florian Westphal; +Cc: netdev
On Tue, 13 Mar 2012 23:35:25 +0100
Florian Westphal <fw@strlen.de> wrote:
> Signed-off-by: Florian Westphal <fw@strlen.de>
Applied
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-03-15 21:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-13 22:35 [PATCH][iproute2] ip: xfrm: report nat-t/encapsulation portmapping updates Florian Westphal
2012-03-15 21:50 ` Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).