From 8dbd12018152683d253ff59ca22f646a410c1a82 Mon Sep 17 00:00:00 2001 From: "/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=pablo/emailAddress=pablo@netfilter.org" Date: Sun, 30 Oct 2005 14:58:23 +0000 Subject: o make static protocol handler functions o move build_tuple_proto and build_protoinfo to the extensions where it really belongs to. o Reworked the conntrack and expect netlink handlers o Fix expectation table output, now it's similar to the /proc output o Bumped version to 0.2.1 --- extensions/libnetfilter_conntrack_icmp.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'extensions/libnetfilter_conntrack_icmp.c') diff --git a/extensions/libnetfilter_conntrack_icmp.c b/extensions/libnetfilter_conntrack_icmp.c index 747fedf..07997d1 100644 --- a/extensions/libnetfilter_conntrack_icmp.c +++ b/extensions/libnetfilter_conntrack_icmp.c @@ -16,7 +16,7 @@ #include #include -void parse_proto(struct nfattr *cda[], struct nfct_tuple *tuple) +static void parse_proto(struct nfattr *cda[], struct nfct_tuple *tuple) { if (cda[CTA_PROTO_ICMP_TYPE-1]) tuple->l4dst.icmp.type = @@ -31,7 +31,20 @@ void parse_proto(struct nfattr *cda[], struct nfct_tuple *tuple) *(u_int16_t *)NFA_DATA(cda[CTA_PROTO_ICMP_ID-1]); } -int print_proto(char *buf, struct nfct_tuple *t) +static void build_tuple_proto(struct nfnlhdr *req, int size, + struct nfct_tuple *t) +{ + nfnl_addattr_l(&req->nlh, size, CTA_PROTO_ICMP_CODE, + &t->l4dst.icmp.code, sizeof(u_int8_t)); + nfnl_addattr_l(&req->nlh, size, CTA_PROTO_ICMP_TYPE, + &t->l4dst.icmp.type, sizeof(u_int8_t)); + /* This is an ICMP echo */ + if (t->l4dst.icmp.type == 8) + nfnl_addattr_l(&req->nlh, size, CTA_PROTO_ICMP_ID, + &t->l4src.icmp.id, sizeof(u_int16_t)); +} + +static int print_proto(char *buf, struct nfct_tuple *t) { int size = 0; @@ -48,13 +61,14 @@ static struct nfct_proto icmp = { .name = "icmp", .protonum = IPPROTO_ICMP, .parse_proto = parse_proto, + .build_tuple_proto = build_tuple_proto, .print_proto = print_proto, .version = LIBNETFILTER_CONNTRACK_VERSION }; -void __attribute__ ((constructor)) init(void); +static void __attribute__ ((constructor)) init(void); -void init(void) +static void init(void) { nfct_register_proto(&icmp); } -- cgit v1.2.3