[netfilter-cvslog] r7525 - trunk/iptables

kaber at trash.net kaber at trash.net
Tue May 13 13:10:38 CEST 2008


Author: kaber at trash.net
Date: 2008-05-13 13:10:38 +0200 (Tue, 13 May 2008)
New Revision: 7525

Modified:
   trunk/iptables/ip6tables.c
   trunk/iptables/iptables.c
Log:
[patch] Make --set-counters (-c) accept comma separated counters

Here is the --set-counters syntax patch requested earlier today making
--set-counters (-c) accept comma separated counts.

-c packets,bytes

I have not updated the manpage to reflect this alternate syntax for the
--set-counters (-c) option.

Henrik Nordstrom <henrik at henriknordstrom.net>


Modified: trunk/iptables/ip6tables.c
===================================================================
--- trunk/iptables/ip6tables.c	2008-05-13 11:09:23 UTC (rev 7524)
+++ trunk/iptables/ip6tables.c	2008-05-13 11:10:38 UTC (rev 7525)
@@ -1754,26 +1754,28 @@
 			set_option(&options, OPT_COUNTERS, &fw.ipv6.invflags,
 				   invert);
 			pcnt = optarg;
-			if (optind < argc && argv[optind][0] != '-'
+			bcnt = strchr(pcnt + 1, ',');
+			if (bcnt)
+			    bcnt++;
+			if (!bcnt && optind < argc && argv[optind][0] != '-'
 			    && argv[optind][0] != '!')
 				bcnt = argv[optind++];
-			else
+			if (!bcnt)
 				exit_error(PARAMETER_PROBLEM,
 					"-%c requires packet and byte counter",
 					opt2char(OPT_COUNTERS));
 
-			if (sscanf(pcnt, "%llu", (unsigned long long *)&cnt) != 1)
+			if (sscanf(pcnt, "%llu", &cnt) != 1)
 				exit_error(PARAMETER_PROBLEM,
 					"-%c packet counter not numeric",
 					opt2char(OPT_COUNTERS));
 			fw.counters.pcnt = cnt;
 
-			if (sscanf(bcnt, "%llu", (unsigned long long *)&cnt) != 1)
+			if (sscanf(bcnt, "%llu", &cnt) != 1)
 				exit_error(PARAMETER_PROBLEM,
 					"-%c byte counter not numeric",
 					opt2char(OPT_COUNTERS));
 			fw.counters.bcnt = cnt;
-
 			break;
 
 		case 1: /* non option */

Modified: trunk/iptables/iptables.c
===================================================================
--- trunk/iptables/iptables.c	2008-05-13 11:09:23 UTC (rev 7524)
+++ trunk/iptables/iptables.c	2008-05-13 11:10:38 UTC (rev 7525)
@@ -1794,21 +1794,24 @@
 			set_option(&options, OPT_COUNTERS, &fw.ip.invflags,
 				   invert);
 			pcnt = optarg;
-			if (optind < argc && argv[optind][0] != '-'
+			bcnt = strchr(pcnt + 1, ',');
+			if (bcnt)
+			    bcnt++;
+			if (!bcnt && optind < argc && argv[optind][0] != '-'
 			    && argv[optind][0] != '!')
 				bcnt = argv[optind++];
-			else
+			if (!bcnt)
 				exit_error(PARAMETER_PROBLEM,
 					"-%c requires packet and byte counter",
 					opt2char(OPT_COUNTERS));
 
-			if (sscanf(pcnt, "%llu", (unsigned long long *)&cnt) != 1)
+			if (sscanf(pcnt, "%llu", &cnt) != 1)
 				exit_error(PARAMETER_PROBLEM,
 					"-%c packet counter not numeric",
 					opt2char(OPT_COUNTERS));
 			fw.counters.pcnt = cnt;
 
-			if (sscanf(bcnt, "%llu", (unsigned long long *)&cnt) != 1)
+			if (sscanf(bcnt, "%llu", &cnt) != 1)
 				exit_error(PARAMETER_PROBLEM,
 					"-%c byte counter not numeric",
 					opt2char(OPT_COUNTERS));




More information about the netfilter-cvslog mailing list