diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2011-12-06 18:29:53 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2011-12-06 18:37:51 +0100 |
commit | b3c288427f1906e2b7c7f6e8c5747db8ccc5f62a (patch) | |
tree | 827f577bd17c9c5fe36539b83d5087c08853998f /src/conntrack | |
parent | c0ec781ec258779941346187ccc143876be9978b (diff) |
expect: nfexp_snprintf displays mask and master tuple information
This patch adds mask and master tuple information regarding one
expectation. This information has been not shown so far. I consider
that it is interesting because you can use this information to
troubleshoot expectation issues. Moreover, you can know which is
the master conntrack that this expectation is attached to.
This extends the text-based output for `conntrack -L exp'. This
can be considered a backward compatibily issue since existing
tools that are parsing this interface may break. But this is not
our fault, we provide an API to the conntrack table via
libnetfilter_conntrack. People should use those.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/conntrack')
-rw-r--r-- | src/conntrack/snprintf_default.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/conntrack/snprintf_default.c b/src/conntrack/snprintf_default.c index 8523bd1..beb1991 100644 --- a/src/conntrack/snprintf_default.c +++ b/src/conntrack/snprintf_default.c @@ -66,16 +66,18 @@ static int __snprintf_protoinfo_dccp(char *buf, static int __snprintf_address_ipv4(char *buf, unsigned int len, - const struct __nfct_tuple *tuple) + const struct __nfct_tuple *tuple, + const char *src_tag, + const char *dst_tag) { int ret, size = 0, offset = 0; struct in_addr src = { .s_addr = tuple->src.v4 }; struct in_addr dst = { .s_addr = tuple->dst.v4 }; - ret = snprintf(buf, len, "src=%s ", inet_ntoa(src)); + ret = snprintf(buf, len, "%s=%s ", src_tag, inet_ntoa(src)); BUFFER_SIZE(ret, size, len, offset); - ret = snprintf(buf+offset, len, "dst=%s ", inet_ntoa(dst)); + ret = snprintf(buf+offset, len, "%s=%s ", dst_tag, inet_ntoa(dst)); BUFFER_SIZE(ret, size, len, offset); return size; @@ -83,7 +85,9 @@ static int __snprintf_address_ipv4(char *buf, static int __snprintf_address_ipv6(char *buf, unsigned int len, - const struct __nfct_tuple *tuple) + const struct __nfct_tuple *tuple, + const char *src_tag, + const char *dst_tag) { int ret, size = 0, offset = 0; struct in6_addr src; @@ -96,13 +100,13 @@ static int __snprintf_address_ipv6(char *buf, if (!inet_ntop(AF_INET6, &src, tmp, sizeof(tmp))) return -1; - ret = snprintf(buf, len, "src=%s ", tmp); + ret = snprintf(buf, len, "%s=%s ", src_tag, tmp); BUFFER_SIZE(ret, size, len, offset); if (!inet_ntop(AF_INET6, &dst, tmp, sizeof(tmp))) return -1; - ret = snprintf(buf+offset, len-size, "dst=%s ", tmp); + ret = snprintf(buf+offset, len-size, "%s=%s ", dst_tag, tmp); BUFFER_SIZE(ret, size, len, offset); return size; @@ -110,16 +114,20 @@ static int __snprintf_address_ipv6(char *buf, int __snprintf_address(char *buf, unsigned int len, - const struct __nfct_tuple *tuple) + const struct __nfct_tuple *tuple, + const char *src_tag, + const char *dst_tag) { int size = 0; switch (tuple->l3protonum) { case AF_INET: - size = __snprintf_address_ipv4(buf, len, tuple); + size = __snprintf_address_ipv4(buf, len, tuple, + src_tag, dst_tag); break; case AF_INET6: - size = __snprintf_address_ipv6(buf, len, tuple); + size = __snprintf_address_ipv6(buf, len, tuple, + src_tag, dst_tag); break; } @@ -324,7 +332,8 @@ int __snprintf_conntrack_default(char *buf, BUFFER_SIZE(ret, size, len, offset); } - ret = __snprintf_address(buf+offset, len, &ct->tuple[__DIR_ORIG]); + ret = __snprintf_address(buf+offset, len, &ct->tuple[__DIR_ORIG], + "src", "dst"); BUFFER_SIZE(ret, size, len, offset); ret = __snprintf_proto(buf+offset, len, &ct->tuple[__DIR_ORIG]); @@ -341,7 +350,8 @@ int __snprintf_conntrack_default(char *buf, BUFFER_SIZE(ret, size, len, offset); } - ret = __snprintf_address(buf+offset, len, &ct->tuple[__DIR_REPL]); + ret = __snprintf_address(buf+offset, len, &ct->tuple[__DIR_REPL], + "src", "dst"); BUFFER_SIZE(ret, size, len, offset); ret = __snprintf_proto(buf+offset, len, &ct->tuple[__DIR_REPL]); |