From 7a791562b143c0ff8634fbf28020558e666bb04c Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Sat, 8 Sep 2012 22:55:04 +0200 Subject: Help prints list type revision and terse description In order to catch kernel/userspace revision mismatch, better print all available data. --- include/libipset/types.h | 1 + lib/ipset_bitmap_ip.c | 1 + lib/ipset_bitmap_ipmac.c | 1 + lib/ipset_bitmap_port.c | 1 + lib/ipset_hash_ip.c | 1 + lib/ipset_hash_ipport.c | 1 + lib/ipset_hash_ipportip.c | 1 + lib/ipset_hash_ipportnet.c | 3 +++ lib/ipset_hash_net.c | 3 +++ lib/ipset_hash_netiface.c | 3 +++ lib/ipset_hash_netport.c | 3 +++ lib/ipset_list_set.c | 1 + src/ipset.c | 10 +++++----- 13 files changed, 25 insertions(+), 5 deletions(-) diff --git a/include/libipset/types.h b/include/libipset/types.h index 1fd3f92..333b432 100644 --- a/include/libipset/types.h +++ b/include/libipset/types.h @@ -81,6 +81,7 @@ struct ipset_type { uint64_t full[IPSET_CADT_MAX]; /* full args flags */ const char *usage; /* terse usage */ void (*usagefn)(void); /* additional usage */ + const char *description; /* short revision description */ struct ipset_type *next; const char *alias[]; /* name alias(es) */ diff --git a/lib/ipset_bitmap_ip.c b/lib/ipset_bitmap_ip.c index fae3d81..212c93e 100644 --- a/lib/ipset_bitmap_ip.c +++ b/lib/ipset_bitmap_ip.c @@ -94,6 +94,7 @@ static struct ipset_type ipset_bitmap_ip0 = { }, .usage = bitmap_ip_usage, + .description = "Initial revision", }; void _init(void); diff --git a/lib/ipset_bitmap_ipmac.c b/lib/ipset_bitmap_ipmac.c index 9f591cd..da69ceb 100644 --- a/lib/ipset_bitmap_ipmac.c +++ b/lib/ipset_bitmap_ipmac.c @@ -97,6 +97,7 @@ static struct ipset_type ipset_bitmap_ipmac0 = { }, .usage = bitmap_ipmac_usage, + .description = "Initial revision", }; void _init(void); diff --git a/lib/ipset_bitmap_port.c b/lib/ipset_bitmap_port.c index 7b1f839..9a37e35 100644 --- a/lib/ipset_bitmap_port.c +++ b/lib/ipset_bitmap_port.c @@ -84,6 +84,7 @@ static struct ipset_type ipset_bitmap_port0 = { }, .usage = bitmap_port_usage, + .description = "Initial revision", }; void _init(void); diff --git a/lib/ipset_hash_ip.c b/lib/ipset_hash_ip.c index 6a03d38..6c2b049 100644 --- a/lib/ipset_hash_ip.c +++ b/lib/ipset_hash_ip.c @@ -116,6 +116,7 @@ static struct ipset_type ipset_hash_ip0 = { }, .usage = hash_ip_usage, + .description = "Initial revision", }; void _init(void); diff --git a/lib/ipset_hash_ipport.c b/lib/ipset_hash_ipport.c index 5e80084..65197d9 100644 --- a/lib/ipset_hash_ipport.c +++ b/lib/ipset_hash_ipport.c @@ -141,6 +141,7 @@ static struct ipset_type ipset_hash_ipport1 = { .usage = hash_ipport1_usage, .usagefn = ipset_port_usage, + .description = "SCTP and UDPLITE support", }; void _init(void); diff --git a/lib/ipset_hash_ipportip.c b/lib/ipset_hash_ipportip.c index f99d85f..58be660 100644 --- a/lib/ipset_hash_ipportip.c +++ b/lib/ipset_hash_ipportip.c @@ -152,6 +152,7 @@ static struct ipset_type ipset_hash_ipportip1 = { .usage = hash_ipportip1_usage, .usagefn = ipset_port_usage, + .description = "SCTP and UDPLITE support", }; void _init(void); diff --git a/lib/ipset_hash_ipportnet.c b/lib/ipset_hash_ipportnet.c index 5a2d97c..c867e90 100644 --- a/lib/ipset_hash_ipportnet.c +++ b/lib/ipset_hash_ipportnet.c @@ -158,6 +158,7 @@ static struct ipset_type ipset_hash_ipportnet1 = { .usage = hash_ipportnet1_usage, .usagefn = ipset_port_usage, + .description = "SCTP and UDPLITE support", }; static const char hash_ipportnet2_usage[] = @@ -250,6 +251,7 @@ static struct ipset_type ipset_hash_ipportnet2 = { .usage = hash_ipportnet2_usage, .usagefn = ipset_port_usage, + .description = "Add/del range support", }; static const struct ipset_arg hash_ipportnet3_add_args[] = { @@ -355,6 +357,7 @@ static struct ipset_type ipset_hash_ipportnet3 = { .usage = hash_ipportnet3_usage, .usagefn = ipset_port_usage, + .description = "nomatch flag support", }; void _init(void); diff --git a/lib/ipset_hash_net.c b/lib/ipset_hash_net.c index 789bcd2..4846412 100644 --- a/lib/ipset_hash_net.c +++ b/lib/ipset_hash_net.c @@ -106,6 +106,7 @@ static struct ipset_type ipset_hash_net0 = { }, .usage = hash_net0_usage, + .description = "Initial revision", }; static const char hash_net1_usage[] = @@ -160,6 +161,7 @@ static struct ipset_type ipset_hash_net1 = { }, .usage = hash_net1_usage, + .description = "Add/del range support", }; static const struct ipset_arg hash_net2_add_args[] = { @@ -227,6 +229,7 @@ static struct ipset_type ipset_hash_net2 = { }, .usage = hash_net2_usage, + .description = "nomatch flag support", }; void _init(void); diff --git a/lib/ipset_hash_netiface.c b/lib/ipset_hash_netiface.c index 298ce2a..c14d4f2 100644 --- a/lib/ipset_hash_netiface.c +++ b/lib/ipset_hash_netiface.c @@ -116,6 +116,7 @@ static struct ipset_type ipset_hash_netiface0 = { }, .usage = hash_netiface_usage, + .description = "Initial revision", }; static const struct ipset_arg hash_netiface1_add_args[] = { @@ -198,6 +199,7 @@ static struct ipset_type ipset_hash_netiface1 = { }, .usage = hash_netiface1_usage, + .description = "nomatch flag support", }; static struct ipset_type ipset_hash_netiface2 = { @@ -255,6 +257,7 @@ static struct ipset_type ipset_hash_netiface2 = { }, .usage = hash_netiface1_usage, + .description = "/0 network support", }; void _init(void); diff --git a/lib/ipset_hash_netport.c b/lib/ipset_hash_netport.c index e638756..2319738 100644 --- a/lib/ipset_hash_netport.c +++ b/lib/ipset_hash_netport.c @@ -120,6 +120,7 @@ static struct ipset_type ipset_hash_netport1 = { .usage = hash_netport1_usage, .usagefn = ipset_port_usage, + .description = "SCTP and UDPLITE support", }; static const char hash_netport2_usage[] = @@ -196,6 +197,7 @@ static struct ipset_type ipset_hash_netport2 = { .usage = hash_netport2_usage, .usagefn = ipset_port_usage, + .description = "Add/del range support", }; static const struct ipset_arg hash_netport3_add_args[] = { @@ -285,6 +287,7 @@ static struct ipset_type ipset_hash_netport3 = { .usage = hash_netport3_usage, .usagefn = ipset_port_usage, + .description = "nomatch flag support", }; void _init(void); diff --git a/lib/ipset_list_set.c b/lib/ipset_list_set.c index 69a1379..b54c42e 100644 --- a/lib/ipset_list_set.c +++ b/lib/ipset_list_set.c @@ -88,6 +88,7 @@ static struct ipset_type ipset_list_set0 = { }, .usage = list_set_usage, + .description = "Initial revision", }; void _init(void); diff --git a/src/ipset.c b/src/ipset.c index 2709d7b..1e69e3e 100644 --- a/src/ipset.c +++ b/src/ipset.c @@ -624,14 +624,14 @@ parse_commandline(int argc, char *argv[]) type->family == NFPROTO_IPV4 ? "INET" : "INET6"); } else { - const char *name = NULL; - printf("\nSupported set types:\n"); type = ipset_types(); while (type) { - if (!(name && STREQ(name, type->name))) - printf(" %s\n", type->name); - name = type->name; + printf(" %s\t%s%u\t%s\n", + type->name, + strlen(type->name) < 12 ? "\t" : "", + type->revision, + type->description); type = type->next; } } -- cgit v1.2.3