From 41796b0c80876094f3db8af0efae16d162788793 Mon Sep 17 00:00:00 2001 From: "/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org" Date: Sat, 24 Sep 2005 18:42:39 +0000 Subject: major update (See ChangeLog) --- src/conntrack.c | 7 ++----- src/libct.c | 30 +++++++++++++++++------------- 2 files changed, 19 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/conntrack.c b/src/conntrack.c index 07d15f6..3731d0e 100644 --- a/src/conntrack.c +++ b/src/conntrack.c @@ -43,13 +43,12 @@ #include #include #include -#include #include #include "linux_list.h" #include "libct_proto.h" #define PROGNAME "conntrack" -#define VERSION "0.80" +#define VERSION "0.81" #if 0 #define DEBUGP printf @@ -651,8 +650,6 @@ fprintf(stdout, "--mask-dst ip Destination mask address for expectations\n"); fprintf(stdout, "-p proto Layer 4 Protocol\n"); fprintf(stdout, "-t timeout Set timeout\n"); fprintf(stdout, "-u status Set status\n"); -fprintf(stdout, "-m dumpmask Set dump mask\n"); -fprintf(stdout, "-g groupmask Set group mask\n"); fprintf(stdout, "-e eventmask Set event mask\n"); fprintf(stdout, "-a min_ip[-max_ip] NAT ip range\n"); fprintf(stdout, "-z Zero Counters\n"); @@ -670,7 +667,7 @@ int main(int argc, char *argv[]) unsigned long timeout = 0; unsigned int status = IPS_CONFIRMED; unsigned long id = 0; - unsigned int type = 0, dump_mask = 0, extra_flags = 0, event_mask = 0; + unsigned int type = 0, extra_flags = 0, event_mask = 0; int manip = -1; int res = 0, retry = 2; diff --git a/src/libct.c b/src/libct.c index 7c1160a..01307f2 100644 --- a/src/libct.c +++ b/src/libct.c @@ -17,9 +17,6 @@ /* From kernel.h */ #define INT_MAX ((int)(~0U>>1)) #define INT_MIN (-INT_MAX - 1) -#include -#include -#include #include #include "linux_list.h" #include "libct_proto.h" @@ -187,7 +184,7 @@ static int handler(struct sockaddr_nl *sock, struct nlmsghdr *nlh, void *arg) parse_tuple(attr, &ct.tuple[CTNL_DIR_REPLY]); break; case CTA_STATUS: - ct.status = *(unsigned int *)NFA_DATA(attr); + ct.status = ntohl(*(u_int32_t *)NFA_DATA(attr)); flags |= STATUS; break; case CTA_PROTOINFO: @@ -195,11 +192,11 @@ static int handler(struct sockaddr_nl *sock, struct nlmsghdr *nlh, void *arg) flags |= PROTOINFO; break; case CTA_TIMEOUT: - ct.timeout = ntohl(*(unsigned long *)NFA_DATA(attr)); + ct.timeout = ntohl(*(u_int32_t *)NFA_DATA(attr)); flags |= TIMEOUT; break; case CTA_MARK: - ct.mark = ntohl(*(unsigned long *)NFA_DATA(attr)); + ct.mark = ntohl(*(u_int32_t *)NFA_DATA(attr)); flags |= MARK; break; case CTA_COUNTERS_ORIG: @@ -208,7 +205,7 @@ static int handler(struct sockaddr_nl *sock, struct nlmsghdr *nlh, void *arg) flags |= COUNTERS; break; case CTA_USE: - ct.use = ntohl(*(unsigned int *)NFA_DATA(attr)); + ct.use = ntohl(*(u_int32_t *)NFA_DATA(attr)); flags |= USE; break; case CTA_ID: @@ -256,7 +253,8 @@ static int handler(struct sockaddr_nl *sock, struct nlmsghdr *nlh, void *arg) ct.counters[CTNL_DIR_REPLY].packets, ct.counters[CTNL_DIR_REPLY].bytes); - print_status(ct.status); + if (flags & STATUS) + print_status(ct.status); if (flags & MARK) fprintf(stdout, "mark=%lu ", ct.mark); @@ -272,15 +270,15 @@ static int handler(struct sockaddr_nl *sock, struct nlmsghdr *nlh, void *arg) static char *typemsg2str(type, flags) { - char *ret = "UNKNOWN"; + char *ret = "[UNKNOWN]"; if (type == IPCTNL_MSG_CT_NEW) { if (flags & NLM_F_CREATE) - ret = "NEW"; + ret = "[NEW]"; else - ret = "UPDATE"; + ret = "[UPDATE]"; } else if (type == IPCTNL_MSG_CT_DELETE) - ret = "DESTROY"; + ret = "[DESTROY]"; return ret; } @@ -289,7 +287,7 @@ static int event_handler(struct sockaddr_nl *sock, struct nlmsghdr *nlh, void *arg) { int type = NFNL_MSG_TYPE(nlh->nlmsg_type); - fprintf(stdout, "[%s] ", typemsg2str(type, nlh->nlmsg_flags)); + fprintf(stdout, "%9s ", typemsg2str(type, nlh->nlmsg_flags)); return handler(sock, nlh, arg); } @@ -465,6 +463,7 @@ static void event_sighandler(int s) { fprintf(stdout, "Now closing conntrack event dumping...\n"); ctnl_close(&cth); + exit(0); } int event_conntrack(unsigned int event_mask) @@ -527,6 +526,11 @@ struct ctproto_handler *findproto(char *name) void register_proto(struct ctproto_handler *h) { + if (strcmp(h->version, LIBCT_VERSION) != 0) { + fprintf(stderr, "plugin `%s': version %s (I'm %s)\n", + h->name, h->version, LIBCT_VERSION); + exit(1); + } list_add(&h->head, &proto_list); } -- cgit v1.2.3