diff options
author | Thomas Graf <tgr@lsx.localdomain> | 2008-05-23 21:45:14 (GMT) |
---|---|---|
committer | Thomas Graf <tgr@lsx.localdomain> | 2008-05-23 21:45:14 (GMT) |
commit | d84430702496f617c01c5e2d27d0e82e02390bb7 (patch) | |
tree | df85d57f3a57c76fa375b57dacc8379e32efe0fe /lib/netfilter | |
parent | 10cf5a586c149fdb7e2639000dbfae5e6f8522a5 (diff) | |
download | libnl-d84430702496f617c01c5e2d27d0e82e02390bb7.zip libnl-d84430702496f617c01c5e2d27d0e82e02390bb7.tar.gz libnl-d84430702496f617c01c5e2d27d0e82e02390bb7.tar.bz2 |
Remove old line counting while dumping
Diffstat (limited to 'lib/netfilter')
-rw-r--r-- | lib/netfilter/ct_obj.c | 33 | ||||
-rw-r--r-- | lib/netfilter/log_msg_obj.c | 60 | ||||
-rw-r--r-- | lib/netfilter/log_obj.c | 30 | ||||
-rw-r--r-- | lib/netfilter/queue_msg_obj.c | 54 | ||||
-rw-r--r-- | lib/netfilter/queue_obj.c | 24 |
5 files changed, 104 insertions, 97 deletions
diff --git a/lib/netfilter/ct_obj.c b/lib/netfilter/ct_obj.c index 7944138..ae14c0d 100644 --- a/lib/netfilter/ct_obj.c +++ b/lib/netfilter/ct_obj.c @@ -171,11 +171,13 @@ static void ct_dump_tuples(struct nfnl_ct *ct, struct nl_dump_params *p) } /* Compatible with /proc/net/nf_conntrack */ -static int ct_dump(struct nl_object *a, struct nl_dump_params *p) +static void ct_dump_line(struct nl_object *a, struct nl_dump_params *p) { struct nfnl_ct *ct = (struct nfnl_ct *) a; char buf[64]; + nl_new_line(p); + if (nfnl_ct_test_proto(ct)) nl_dump(p, "%s ", nl_ip_proto2str(nfnl_ct_get_proto(ct), buf, sizeof(buf))); @@ -191,17 +193,15 @@ static int ct_dump(struct nl_object *a, struct nl_dump_params *p) nl_dump(p, "mark %u ", nfnl_ct_get_mark(ct)); nl_dump(p, "\n"); - - return 1; } -static int ct_dump_details(struct nl_object *a, struct nl_dump_params *p) +static void ct_dump_details(struct nl_object *a, struct nl_dump_params *p) { struct nfnl_ct *ct = (struct nfnl_ct *) a; char buf[64]; int fp = 0; - ct_dump(a, p); + ct_dump_line(a, p); nl_dump(p, " id 0x%x ", ct->ct_id); nl_dump_line(p, "family %s ", @@ -249,28 +249,25 @@ static int ct_dump_details(struct nl_object *a, struct nl_dump_params *p) if (ct->ct_status) nl_dump(p, ">"); nl_dump(p, "\n"); - - return 0; } -static int ct_dump_stats(struct nl_object *a, struct nl_dump_params *p) +static void ct_dump_stats(struct nl_object *a, struct nl_dump_params *p) { struct nfnl_ct *ct = (struct nfnl_ct *) a; - int line = ct_dump_details(a, p); double res; char *unit; - dp_dump_line(p, line++, " # packets volume\n"); + ct_dump_details(a, p); + + nl_dump_line(p, " # packets volume\n"); res = nl_cancel_down_bytes(nfnl_ct_get_bytes(ct, 1), &unit); - dp_dump_line(p, line++, " rx %10llu %7.2f %s\n", + nl_dump_line(p, " rx %10llu %7.2f %s\n", nfnl_ct_get_packets(ct, 1), res, unit); res = nl_cancel_down_bytes(nfnl_ct_get_bytes(ct, 0), &unit); - dp_dump_line(p, line++, " tx %10llu %7.2f %s\n", + nl_dump_line(p, " tx %10llu %7.2f %s\n", nfnl_ct_get_packets(ct, 0), res, unit); - - return line; } static int ct_compare(struct nl_object *_a, struct nl_object *_b, @@ -776,9 +773,11 @@ struct nl_object_ops ct_obj_ops = { .oo_size = sizeof(struct nfnl_ct), .oo_free_data = ct_free_data, .oo_clone = ct_clone, - .oo_dump[NL_DUMP_BRIEF] = ct_dump, - .oo_dump[NL_DUMP_FULL] = ct_dump_details, - .oo_dump[NL_DUMP_STATS] = ct_dump_stats, + .oo_dump = { + [NL_DUMP_LINE] = ct_dump_line, + [NL_DUMP_DETAILS] = ct_dump_details, + [NL_DUMP_STATS] = ct_dump_stats, + }, .oo_compare = ct_compare, .oo_attrs2str = ct_attrs2str, }; diff --git a/lib/netfilter/log_msg_obj.c b/lib/netfilter/log_msg_obj.c index b2cd9ef..d2cde4e 100644 --- a/lib/netfilter/log_msg_obj.c +++ b/lib/netfilter/log_msg_obj.c @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> * Copyright (c) 2007 Philip Craig <philipc@snapgear.com> * Copyright (c) 2007 Secure Computing Corporation */ @@ -70,7 +70,7 @@ errout: return err; } -static int log_msg_dump(struct nl_object *a, struct nl_dump_params *p) +static void log_msg_dump(struct nl_object *a, struct nl_dump_params *p) { struct nfnl_log_msg *msg = (struct nfnl_log_msg *) a; struct nl_cache *link_cache; @@ -78,95 +78,95 @@ static int log_msg_dump(struct nl_object *a, struct nl_dump_params *p) link_cache = nl_cache_mngt_require("route/link"); + nl_new_line(p); + if (msg->ce_mask & LOG_MSG_ATTR_PREFIX) - dp_dump(p, "%s", msg->log_msg_prefix); + nl_dump(p, "%s", msg->log_msg_prefix); if (msg->ce_mask & LOG_MSG_ATTR_INDEV) { if (link_cache) - dp_dump(p, "IN=%s ", + nl_dump(p, "IN=%s ", rtnl_link_i2name(link_cache, msg->log_msg_indev, buf, sizeof(buf))); else - dp_dump(p, "IN=%d ", msg->log_msg_indev); + nl_dump(p, "IN=%d ", msg->log_msg_indev); } if (msg->ce_mask & LOG_MSG_ATTR_PHYSINDEV) { if (link_cache) - dp_dump(p, "PHYSIN=%s ", + nl_dump(p, "PHYSIN=%s ", rtnl_link_i2name(link_cache, msg->log_msg_physindev, buf, sizeof(buf))); else - dp_dump(p, "IN=%d ", msg->log_msg_physindev); + nl_dump(p, "IN=%d ", msg->log_msg_physindev); } if (msg->ce_mask & LOG_MSG_ATTR_OUTDEV) { if (link_cache) - dp_dump(p, "OUT=%s ", + nl_dump(p, "OUT=%s ", rtnl_link_i2name(link_cache, msg->log_msg_outdev, buf, sizeof(buf))); else - dp_dump(p, "OUT=%d ", msg->log_msg_outdev); + nl_dump(p, "OUT=%d ", msg->log_msg_outdev); } if (msg->ce_mask & LOG_MSG_ATTR_PHYSOUTDEV) { if (link_cache) - dp_dump(p, "PHYSOUT=%s ", + nl_dump(p, "PHYSOUT=%s ", rtnl_link_i2name(link_cache, msg->log_msg_physoutdev, buf, sizeof(buf))); else - dp_dump(p, "PHYSOUT=%d ", msg->log_msg_physoutdev); + nl_dump(p, "PHYSOUT=%d ", msg->log_msg_physoutdev); } if (msg->ce_mask & LOG_MSG_ATTR_HWADDR) { int i; - dp_dump(p, "MAC"); + nl_dump(p, "MAC"); for (i = 0; i < msg->log_msg_hwaddr_len; i++) - dp_dump(p, "%c%02x", i?':':'=', msg->log_msg_hwaddr[i]); - dp_dump(p, " "); + nl_dump(p, "%c%02x", i?':':'=', msg->log_msg_hwaddr[i]); + nl_dump(p, " "); } /* FIXME: parse the payload to get iptables LOG compatible format */ if (msg->ce_mask & LOG_MSG_ATTR_FAMILY) - dp_dump(p, "FAMILY=%s ", + nl_dump(p, "FAMILY=%s ", nl_af2str(msg->log_msg_family, buf, sizeof(buf))); if (msg->ce_mask & LOG_MSG_ATTR_HWPROTO) - dp_dump(p, "HWPROTO=%s ", + nl_dump(p, "HWPROTO=%s ", nl_ether_proto2str(ntohs(msg->log_msg_hwproto), buf, sizeof(buf))); if (msg->ce_mask & LOG_MSG_ATTR_HOOK) - dp_dump(p, "HOOK=%s ", + nl_dump(p, "HOOK=%s ", nfnl_inet_hook2str(msg->log_msg_hook, buf, sizeof(buf))); if (msg->ce_mask & LOG_MSG_ATTR_MARK) - dp_dump(p, "MARK=%u ", msg->log_msg_mark); + nl_dump(p, "MARK=%u ", msg->log_msg_mark); if (msg->ce_mask & LOG_MSG_ATTR_PAYLOAD) - dp_dump(p, "PAYLOADLEN=%d ", msg->log_msg_payload_len); + nl_dump(p, "PAYLOADLEN=%d ", msg->log_msg_payload_len); if (msg->ce_mask & LOG_MSG_ATTR_UID) - dp_dump(p, "UID=%u ", msg->log_msg_uid); + nl_dump(p, "UID=%u ", msg->log_msg_uid); if (msg->ce_mask & LOG_MSG_ATTR_GID) - dp_dump(p, "GID=%u ", msg->log_msg_gid); + nl_dump(p, "GID=%u ", msg->log_msg_gid); if (msg->ce_mask & LOG_MSG_ATTR_SEQ) - dp_dump(p, "SEQ=%d ", msg->log_msg_seq); + nl_dump(p, "SEQ=%d ", msg->log_msg_seq); if (msg->ce_mask & LOG_MSG_ATTR_SEQ_GLOBAL) - dp_dump(p, "SEQGLOBAL=%d ", msg->log_msg_seq_global); - - dp_dump(p, "\n"); + nl_dump(p, "SEQGLOBAL=%d ", msg->log_msg_seq_global); - return 1; + nl_dump(p, "\n"); } /** @@ -448,9 +448,11 @@ struct nl_object_ops log_msg_obj_ops = { .oo_size = sizeof(struct nfnl_log_msg), .oo_free_data = log_msg_free_data, .oo_clone = log_msg_clone, - .oo_dump[NL_DUMP_BRIEF] = log_msg_dump, - .oo_dump[NL_DUMP_FULL] = log_msg_dump, - .oo_dump[NL_DUMP_STATS] = log_msg_dump, + .oo_dump = { + [NL_DUMP_LINE] = log_msg_dump, + [NL_DUMP_DETAILS] = log_msg_dump, + [NL_DUMP_STATS] = log_msg_dump, + }, }; /** @} */ diff --git a/lib/netfilter/log_obj.c b/lib/netfilter/log_obj.c index ce65443..ff2b63a 100644 --- a/lib/netfilter/log_obj.c +++ b/lib/netfilter/log_obj.c @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> * Copyright (c) 2007 Philip Craig <philipc@snapgear.com> * Copyright (c) 2007 Secure Computing Corporation * Copyright (c) 2008 Patrick McHardy <kaber@trash.net> @@ -26,34 +26,34 @@ /** @endcond */ -static int nfnl_log_dump(struct nl_object *a, struct nl_dump_params *p) +static void nfnl_log_dump(struct nl_object *a, struct nl_dump_params *p) { struct nfnl_log *log = (struct nfnl_log *) a; char buf[64]; + nl_new_line(p); + if (log->ce_mask & LOG_ATTR_GROUP) - dp_dump(p, "group=%u ", log->log_group); + nl_dump(p, "group=%u ", log->log_group); if (log->ce_mask & LOG_ATTR_COPY_MODE) - dp_dump(p, "copy_mode=%s ", + nl_dump(p, "copy_mode=%s ", nfnl_log_copy_mode2str(log->log_copy_mode, buf, sizeof(buf))); if (log->ce_mask & LOG_ATTR_COPY_RANGE) - dp_dump(p, "copy_range=%u ", log->log_copy_range); + nl_dump(p, "copy_range=%u ", log->log_copy_range); if (log->ce_mask & LOG_ATTR_FLUSH_TIMEOUT) - dp_dump(p, "flush_timeout=%u ", log->log_flush_timeout); + nl_dump(p, "flush_timeout=%u ", log->log_flush_timeout); if (log->ce_mask & LOG_ATTR_ALLOC_SIZE) - dp_dump(p, "alloc_size=%u ", log->log_alloc_size); + nl_dump(p, "alloc_size=%u ", log->log_alloc_size); if (log->ce_mask & LOG_ATTR_QUEUE_THRESHOLD) - dp_dump(p, "queue_threshold=%u ", log->log_queue_threshold); - - dp_dump(p, "\n"); + nl_dump(p, "queue_threshold=%u ", log->log_queue_threshold); - return 1; + nl_dump(p, "\n"); } static struct trans_tbl copy_modes[] = { @@ -274,9 +274,11 @@ static char *nfnl_log_attrs2str(int attrs, char *buf, size_t len) struct nl_object_ops log_obj_ops = { .oo_name = "netfilter/log", .oo_size = sizeof(struct nfnl_log), - .oo_dump[NL_DUMP_BRIEF] = nfnl_log_dump, - .oo_dump[NL_DUMP_FULL] = nfnl_log_dump, - .oo_dump[NL_DUMP_STATS] = nfnl_log_dump, + .oo_dump = { + [NL_DUMP_LINE] = nfnl_log_dump, + [NL_DUMP_DETAILS] = nfnl_log_dump, + [NL_DUMP_STATS] = nfnl_log_dump, + }, .oo_compare = nfnl_log_compare, .oo_attrs2str = nfnl_log_attrs2str, .oo_id_attrs = LOG_ATTR_GROUP, diff --git a/lib/netfilter/queue_msg_obj.c b/lib/netfilter/queue_msg_obj.c index 5796c34..aa03b15 100644 --- a/lib/netfilter/queue_msg_obj.c +++ b/lib/netfilter/queue_msg_obj.c @@ -60,7 +60,7 @@ errout: return err; } -static int nfnl_queue_msg_dump(struct nl_object *a, struct nl_dump_params *p) +static void nfnl_queue_msg_dump(struct nl_object *a, struct nl_dump_params *p) { struct nfnl_queue_msg *msg = (struct nfnl_queue_msg *) a; struct nl_cache *link_cache; @@ -68,90 +68,90 @@ static int nfnl_queue_msg_dump(struct nl_object *a, struct nl_dump_params *p) link_cache = nl_cache_mngt_require("route/link"); + nl_new_line(p); + if (msg->ce_mask & QUEUE_MSG_ATTR_GROUP) - dp_dump(p, "GROUP=%u ", msg->queue_msg_group); + nl_dump(p, "GROUP=%u ", msg->queue_msg_group); if (msg->ce_mask & QUEUE_MSG_ATTR_INDEV) { if (link_cache) - dp_dump(p, "IN=%s ", + nl_dump(p, "IN=%s ", rtnl_link_i2name(link_cache, msg->queue_msg_indev, buf, sizeof(buf))); else - dp_dump(p, "IN=%d ", msg->queue_msg_indev); + nl_dump(p, "IN=%d ", msg->queue_msg_indev); } if (msg->ce_mask & QUEUE_MSG_ATTR_PHYSINDEV) { if (link_cache) - dp_dump(p, "PHYSIN=%s ", + nl_dump(p, "PHYSIN=%s ", rtnl_link_i2name(link_cache, msg->queue_msg_physindev, buf, sizeof(buf))); else - dp_dump(p, "IN=%d ", msg->queue_msg_physindev); + nl_dump(p, "IN=%d ", msg->queue_msg_physindev); } if (msg->ce_mask & QUEUE_MSG_ATTR_OUTDEV) { if (link_cache) - dp_dump(p, "OUT=%s ", + nl_dump(p, "OUT=%s ", rtnl_link_i2name(link_cache, msg->queue_msg_outdev, buf, sizeof(buf))); else - dp_dump(p, "OUT=%d ", msg->queue_msg_outdev); + nl_dump(p, "OUT=%d ", msg->queue_msg_outdev); } if (msg->ce_mask & QUEUE_MSG_ATTR_PHYSOUTDEV) { if (link_cache) - dp_dump(p, "PHYSOUT=%s ", + nl_dump(p, "PHYSOUT=%s ", rtnl_link_i2name(link_cache, msg->queue_msg_physoutdev, buf, sizeof(buf))); else - dp_dump(p, "PHYSOUT=%d ", msg->queue_msg_physoutdev); + nl_dump(p, "PHYSOUT=%d ", msg->queue_msg_physoutdev); } if (msg->ce_mask & QUEUE_MSG_ATTR_HWADDR) { int i; - dp_dump(p, "MAC"); + nl_dump(p, "MAC"); for (i = 0; i < msg->queue_msg_hwaddr_len; i++) - dp_dump(p, "%c%02x", i?':':'=', + nl_dump(p, "%c%02x", i?':':'=', msg->queue_msg_hwaddr[i]); - dp_dump(p, " "); + nl_dump(p, " "); } if (msg->ce_mask & QUEUE_MSG_ATTR_FAMILY) - dp_dump(p, "FAMILY=%s ", + nl_dump(p, "FAMILY=%s ", nl_af2str(msg->queue_msg_family, buf, sizeof(buf))); if (msg->ce_mask & QUEUE_MSG_ATTR_HWPROTO) - dp_dump(p, "HWPROTO=%s ", + nl_dump(p, "HWPROTO=%s ", nl_ether_proto2str(ntohs(msg->queue_msg_hwproto), buf, sizeof(buf))); if (msg->ce_mask & QUEUE_MSG_ATTR_HOOK) - dp_dump(p, "HOOK=%s ", + nl_dump(p, "HOOK=%s ", nfnl_inet_hook2str(msg->queue_msg_hook, buf, sizeof(buf))); if (msg->ce_mask & QUEUE_MSG_ATTR_MARK) - dp_dump(p, "MARK=%d ", msg->queue_msg_mark); + nl_dump(p, "MARK=%d ", msg->queue_msg_mark); if (msg->ce_mask & QUEUE_MSG_ATTR_PAYLOAD) - dp_dump(p, "PAYLOADLEN=%d ", msg->queue_msg_payload_len); + nl_dump(p, "PAYLOADLEN=%d ", msg->queue_msg_payload_len); if (msg->ce_mask & QUEUE_MSG_ATTR_PACKETID) - dp_dump(p, "PACKETID=%u ", msg->queue_msg_packetid); + nl_dump(p, "PACKETID=%u ", msg->queue_msg_packetid); if (msg->ce_mask & QUEUE_MSG_ATTR_VERDICT) - dp_dump(p, "VERDICT=%s ", + nl_dump(p, "VERDICT=%s ", nfnl_verdict2str(msg->queue_msg_verdict, buf, sizeof(buf))); - dp_dump(p, "\n"); - - return 1; + nl_dump(p, "\n"); } /** @@ -471,9 +471,11 @@ struct nl_object_ops queue_msg_obj_ops = { .oo_size = sizeof(struct nfnl_queue_msg), .oo_free_data = nfnl_queue_msg_free_data, .oo_clone = nfnl_queue_msg_clone, - .oo_dump[NL_DUMP_BRIEF] = nfnl_queue_msg_dump, - .oo_dump[NL_DUMP_FULL] = nfnl_queue_msg_dump, - .oo_dump[NL_DUMP_STATS] = nfnl_queue_msg_dump, + .oo_dump = { + [NL_DUMP_LINE] = nfnl_queue_msg_dump, + [NL_DUMP_DETAILS] = nfnl_queue_msg_dump, + [NL_DUMP_STATS] = nfnl_queue_msg_dump, + }, .oo_attrs2str = nfnl_queue_msg_attrs2str, }; diff --git a/lib/netfilter/queue_obj.c b/lib/netfilter/queue_obj.c index 68e1e5a..ee03836 100644 --- a/lib/netfilter/queue_obj.c +++ b/lib/netfilter/queue_obj.c @@ -28,28 +28,28 @@ /** @endcond */ -static int nfnl_queue_dump(struct nl_object *a, struct nl_dump_params *p) +static void nfnl_queue_dump(struct nl_object *a, struct nl_dump_params *p) { struct nfnl_queue *queue = (struct nfnl_queue *) a; char buf[64]; + nl_new_line(p); + if (queue->ce_mask & QUEUE_ATTR_GROUP) - dp_dump(p, "group=%u ", queue->queue_group); + nl_dump(p, "group=%u ", queue->queue_group); if (queue->ce_mask & QUEUE_ATTR_MAXLEN) - dp_dump(p, "maxlen=%u ", queue->queue_maxlen); + nl_dump(p, "maxlen=%u ", queue->queue_maxlen); if (queue->ce_mask & QUEUE_ATTR_COPY_MODE) - dp_dump(p, "copy_mode=%s ", + nl_dump(p, "copy_mode=%s ", nfnl_queue_copy_mode2str(queue->queue_copy_mode, buf, sizeof(buf))); if (queue->ce_mask & QUEUE_ATTR_COPY_RANGE) - dp_dump(p, "copy_range=%u ", queue->queue_copy_range); - - dp_dump(p, "\n"); + nl_dump(p, "copy_range=%u ", queue->queue_copy_range); - return 1; + nl_dump(p, "\n"); } static struct trans_tbl copy_modes[] = { @@ -202,9 +202,11 @@ static char *nfnl_queue_attrs2str(int attrs, char *buf, size_t len) struct nl_object_ops queue_obj_ops = { .oo_name = "netfilter/queue", .oo_size = sizeof(struct nfnl_queue), - .oo_dump[NL_DUMP_BRIEF] = nfnl_queue_dump, - .oo_dump[NL_DUMP_FULL] = nfnl_queue_dump, - .oo_dump[NL_DUMP_STATS] = nfnl_queue_dump, + .oo_dump = { + [NL_DUMP_LINE] = nfnl_queue_dump, + [NL_DUMP_DETAILS] = nfnl_queue_dump, + [NL_DUMP_STATS] = nfnl_queue_dump, + }, .oo_compare = nfnl_queue_compare, .oo_attrs2str = nfnl_queue_attrs2str, .oo_id_attrs = QUEUE_ATTR_GROUP, |