[PATCH v2 2/3] conntrack: use C99 initializer syntax for opts map

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The old way of the commands_v_options initialization made it more
difficult and error-prone to add a map for a new command, because one
would have to calculate a proper "index" for the initializer and fill
the gap with zeros.

As a preparation step for adding the new "-A" command support,
switch to C99 initializer syntax for commands_v_options.

Signed-off-by: Mikhail Sennikovsky <mikhail.sennikovskii@xxxxxxxxx>
---
 extensions/libct_proto_dccp.c    |  32 +++++-----
 extensions/libct_proto_gre.c     |  32 +++++-----
 extensions/libct_proto_icmp.c    |  32 +++++-----
 extensions/libct_proto_icmpv6.c  |  32 +++++-----
 extensions/libct_proto_sctp.c    |  32 +++++-----
 extensions/libct_proto_tcp.c     |  32 +++++-----
 extensions/libct_proto_udp.c     |  32 +++++-----
 extensions/libct_proto_udplite.c |  32 +++++-----
 include/conntrack.h              |  65 +++++++++++++++++++-
 src/conntrack.c                  | 102 ++++++-------------------------
 10 files changed, 212 insertions(+), 211 deletions(-)

diff --git a/extensions/libct_proto_dccp.c b/extensions/libct_proto_dccp.c
index e9da474..6103117 100644
--- a/extensions/libct_proto_dccp.c
+++ b/extensions/libct_proto_dccp.c
@@ -67,22 +67,22 @@ static const char *dccp_optflags[DCCP_OPT_MAX] = {
 static char dccp_commands_v_options[NUMBER_OF_CMD][DCCP_OPT_MAX] =
 /* Well, it's better than "Re: Sevilla vs Betis" */
 {
-	    	/* 1 2 3 4 5 6 7 8 9 10*/
-/*CT_LIST*/   	  {2,2,2,2,0,0,2,0,0,0},
-/*CT_CREATE*/	  {3,3,3,3,0,0,1,0,0,1},
-/*CT_UPDATE*/	  {2,2,2,2,0,0,2,0,0,0},
-/*CT_DELETE*/	  {2,2,2,2,0,0,2,0,0,0},
-/*CT_GET*/	  {3,3,3,3,0,0,2,0,0,0},
-/*CT_FLUSH*/	  {0,0,0,0,0,0,0,0,0,0},
-/*CT_EVENT*/	  {2,2,2,2,0,0,2,0,0,0},
-/*CT_VERSION*/	  {0,0,0,0,0,0,0,0,0,0},
-/*CT_HELP*/	  {0,0,0,0,0,0,0,0,0,0},
-/*EXP_LIST*/	  {0,0,0,0,0,0,0,0,0,0},
-/*EXP_CREATE*/	  {1,1,0,0,1,1,0,1,1,1},
-/*EXP_DELETE*/	  {1,1,1,1,0,0,0,0,0,0},
-/*EXP_GET*/	  {1,1,1,1,0,0,0,0,0,0},
-/*EXP_FLUSH*/	  {0,0,0,0,0,0,0,0,0,0},
-/*EXP_EVENT*/	  {0,0,0,0,0,0,0,0,0,0},
+				/* 1 2 3 4 5 6 7 8 9 10 */
+	[CT_LIST_BIT]		= {2,2,2,2,0,0,2,0,0,0},
+	[CT_CREATE_BIT]		= {3,3,3,3,0,0,1,0,0,1},
+	[CT_UPDATE_BIT]		= {2,2,2,2,0,0,2,0,0,0},
+	[CT_DELETE_BIT]		= {2,2,2,2,0,0,2,0,0,0},
+	[CT_GET_BIT]		= {3,3,3,3,0,0,2,0,0,0},
+	[CT_FLUSH_BIT]		= {0,0,0,0,0,0,0,0,0,0},
+	[CT_EVENT_BIT]		= {2,2,2,2,0,0,2,0,0,0},
+	[CT_VERSION_BIT]	= {0,0,0,0,0,0,0,0,0,0},
+	[CT_HELP_BIT]		= {0,0,0,0,0,0,0,0,0,0},
+	[EXP_LIST_BIT]		= {0,0,0,0,0,0,0,0,0,0},
+	[EXP_CREATE_BIT]	= {1,1,0,0,1,1,0,1,1,1},
+	[EXP_DELETE_BIT]	= {1,1,1,1,0,0,0,0,0,0},
+	[EXP_GET_BIT]		= {1,1,1,1,0,0,0,0,0,0},
+	[EXP_FLUSH_BIT]		= {0,0,0,0,0,0,0,0,0,0},
+	[EXP_EVENT_BIT]		= {0,0,0,0,0,0,0,0,0,0},
 };
 
 static const char *dccp_states[DCCP_CONNTRACK_MAX] = {
diff --git a/extensions/libct_proto_gre.c b/extensions/libct_proto_gre.c
index a36d111..c619db3 100644
--- a/extensions/libct_proto_gre.c
+++ b/extensions/libct_proto_gre.c
@@ -66,22 +66,22 @@ static void help(void)
 
 static char gre_commands_v_options[NUMBER_OF_CMD][GRE_OPT_MAX] =
 {
-		/* 1 2 3 4 5 6 7 8 */
-/*CT_LIST*/	  {2,2,2,2,0,0,0,0},
-/*CT_CREATE*/	  {3,3,3,3,0,0,0,0},
-/*CT_UPDATE*/	  {2,2,2,2,0,0,0,0},
-/*CT_DELETE*/	  {2,2,2,2,0,0,0,0},
-/*CT_GET*/	  {3,3,3,3,0,0,0,0},
-/*CT_FLUSH*/	  {0,0,0,0,0,0,0,0},
-/*CT_EVENT*/	  {2,2,2,2,0,0,0,0},
-/*CT_VERSION*/	  {0,0,0,0,0,0,0,0},
-/*CT_HELP*/	  {0,0,0,0,0,0,0,0},
-/*EXP_LIST*/	  {0,0,0,0,0,0,0,0},
-/*EXP_CREATE*/	  {1,1,1,1,1,1,1,1},
-/*EXP_DELETE*/	  {1,1,1,1,0,0,0,0},
-/*EXP_GET*/	  {1,1,1,1,0,0,0,0},
-/*EXP_FLUSH*/	  {0,0,0,0,0,0,0,0},
-/*EXP_EVENT*/	  {0,0,0,0,0,0,0,0},
+				/* 1 2 3 4 5 6 7 8 */
+	[CT_LIST_BIT]		= {2,2,2,2,0,0,0,0},
+	[CT_CREATE_BIT]		= {3,3,3,3,0,0,0,0},
+	[CT_UPDATE_BIT]		= {2,2,2,2,0,0,0,0},
+	[CT_DELETE_BIT]		= {2,2,2,2,0,0,0,0},
+	[CT_GET_BIT]		= {3,3,3,3,0,0,0,0},
+	[CT_FLUSH_BIT]		= {0,0,0,0,0,0,0,0},
+	[CT_EVENT_BIT]		= {2,2,2,2,0,0,0,0},
+	[CT_VERSION_BIT]	= {0,0,0,0,0,0,0,0},
+	[CT_HELP_BIT]		= {0,0,0,0,0,0,0,0},
+	[EXP_LIST_BIT]		= {0,0,0,0,0,0,0,0},
+	[EXP_CREATE_BIT]	= {1,1,1,1,1,1,1,1},
+	[EXP_DELETE_BIT]	= {1,1,1,1,0,0,0,0},
+	[EXP_GET_BIT]		= {1,1,1,1,0,0,0,0},
+	[EXP_FLUSH_BIT]		= {0,0,0,0,0,0,0,0},
+	[EXP_EVENT_BIT]		= {0,0,0,0,0,0,0,0},
 };
 
 static int parse_options(char c,
diff --git a/extensions/libct_proto_icmp.c b/extensions/libct_proto_icmp.c
index ec52c39..304018f 100644
--- a/extensions/libct_proto_icmp.c
+++ b/extensions/libct_proto_icmp.c
@@ -40,22 +40,22 @@ static const char *icmp_optflags[ICMP_NUMBER_OF_OPT] = {
 static char icmp_commands_v_options[NUMBER_OF_CMD][ICMP_NUMBER_OF_OPT] =
 /* Well, it's better than "Re: Maradona vs Pele" */
 {
-		/* 1 2 3 */
-/*CT_LIST*/	  {2,2,2},
-/*CT_CREATE*/	  {1,1,2},
-/*CT_UPDATE*/	  {2,2,2},
-/*CT_DELETE*/	  {2,2,2},
-/*CT_GET*/	  {1,1,2},
-/*CT_FLUSH*/	  {0,0,0},
-/*CT_EVENT*/	  {2,2,2},
-/*CT_VERSION*/	  {0,0,0},
-/*CT_HELP*/	  {0,0,0},
-/*EXP_LIST*/	  {0,0,0},
-/*EXP_CREATE*/	  {0,0,0},
-/*EXP_DELETE*/	  {0,0,0},
-/*EXP_GET*/	  {0,0,0},
-/*EXP_FLUSH*/	  {0,0,0},
-/*EXP_EVENT*/	  {0,0,0},
+				/* 1 2 3 */
+	[CT_LIST_BIT]		= {2,2,2},
+	[CT_CREATE_BIT]		= {1,1,2},
+	[CT_UPDATE_BIT]		= {2,2,2},
+	[CT_DELETE_BIT]		= {2,2,2},
+	[CT_GET_BIT]		= {1,1,2},
+	[CT_FLUSH_BIT]		= {0,0,0},
+	[CT_EVENT_BIT]		= {2,2,2},
+	[CT_VERSION_BIT]	= {0,0,0},
+	[CT_HELP_BIT]		= {0,0,0},
+	[EXP_LIST_BIT]		= {0,0,0},
+	[EXP_CREATE_BIT]	= {0,0,0},
+	[EXP_DELETE_BIT]	= {0,0,0},
+	[EXP_GET_BIT]		= {0,0,0},
+	[EXP_FLUSH_BIT]		= {0,0,0},
+	[EXP_EVENT_BIT]		= {0,0,0},
 };
 
 static void help(void)
diff --git a/extensions/libct_proto_icmpv6.c b/extensions/libct_proto_icmpv6.c
index fe16a1d..114bcac 100644
--- a/extensions/libct_proto_icmpv6.c
+++ b/extensions/libct_proto_icmpv6.c
@@ -43,22 +43,22 @@ static const char *icmpv6_optflags[ICMPV6_NUMBER_OF_OPT] = {
 static char icmpv6_commands_v_options[NUMBER_OF_CMD][ICMPV6_NUMBER_OF_OPT] =
 /* Well, it's better than "Re: Maradona vs Pele" */
 {
-		/* 1 2 3 */
-/*CT_LIST*/	  {2,2,2},
-/*CT_CREATE*/	  {1,1,2},
-/*CT_UPDATE*/	  {2,2,2},
-/*CT_DELETE*/	  {2,2,2},
-/*CT_GET*/	  {1,1,2},
-/*CT_FLUSH*/	  {0,0,0},
-/*CT_EVENT*/	  {2,2,2},
-/*CT_VERSION*/	  {0,0,0},
-/*CT_HELP*/	  {0,0,0},
-/*EXP_LIST*/	  {0,0,0},
-/*EXP_CREATE*/	  {0,0,0},
-/*EXP_DELETE*/	  {0,0,0},
-/*EXP_GET*/	  {0,0,0},
-/*EXP_FLUSH*/	  {0,0,0},
-/*EXP_EVENT*/	  {0,0,0},
+				/* 1 2 3 */
+	[CT_LIST_BIT]		= {2,2,2},
+	[CT_CREATE_BIT]		= {1,1,2},
+	[CT_UPDATE_BIT]		= {2,2,2},
+	[CT_DELETE_BIT]		= {2,2,2},
+	[CT_GET_BIT]		= {1,1,2},
+	[CT_FLUSH_BIT]		= {0,0,0},
+	[CT_EVENT_BIT]		= {2,2,2},
+	[CT_VERSION_BIT]	= {0,0,0},
+	[CT_HELP_BIT]		= {0,0,0},
+	[EXP_LIST_BIT]		= {0,0,0},
+	[EXP_CREATE_BIT]	= {0,0,0},
+	[EXP_DELETE_BIT]	= {0,0,0},
+	[EXP_GET_BIT]		= {0,0,0},
+	[EXP_FLUSH_BIT]		= {0,0,0},
+	[EXP_EVENT_BIT]		= {0,0,0},
 };
 
 static void help(void)
diff --git a/extensions/libct_proto_sctp.c b/extensions/libct_proto_sctp.c
index a58ccde..723a2cd 100644
--- a/extensions/libct_proto_sctp.c
+++ b/extensions/libct_proto_sctp.c
@@ -70,22 +70,22 @@ static const char *sctp_optflags[SCTP_OPT_MAX] = {
 static char sctp_commands_v_options[NUMBER_OF_CMD][SCTP_OPT_MAX] =
 /* Well, it's better than "Re: Sevilla vs Betis" */
 {
-	    	/* 1 2 3 4 5 6 7 8 9 10 11*/
-/*CT_LIST*/   	  {2,2,2,2,0,0,2,0,0,0,0},
-/*CT_CREATE*/	  {3,3,3,3,0,0,1,0,0,1,1},
-/*CT_UPDATE*/	  {2,2,2,2,0,0,2,0,0,2,2},
-/*CT_DELETE*/	  {2,2,2,2,0,0,2,0,0,0,0},
-/*CT_GET*/	  {3,3,3,3,0,0,2,0,0,2,2},
-/*CT_FLUSH*/	  {0,0,0,0,0,0,0,0,0,0,0},
-/*CT_EVENT*/	  {2,2,2,2,0,0,2,0,0,0,0},
-/*CT_VERSION*/	  {0,0,0,0,0,0,0,0,0,0,0},
-/*CT_HELP*/	  {0,0,0,0,0,0,0,0,0,0,0},
-/*EXP_LIST*/	  {0,0,0,0,0,0,0,0,0,0,0},
-/*EXP_CREATE*/	  {1,1,0,0,1,1,0,1,1,1,1},
-/*EXP_DELETE*/	  {1,1,1,1,0,0,0,0,0,0,0},
-/*EXP_GET*/	  {1,1,1,1,0,0,0,0,0,0,0},
-/*EXP_FLUSH*/	  {0,0,0,0,0,0,0,0,0,0,0},
-/*EXP_EVENT*/	  {0,0,0,0,0,0,0,0,0,0,0},
+				/* 1 2 3 4 5 6 7 8 9 10 11 */
+	[CT_LIST_BIT]		= {2,2,2,2,0,0,2,0,0,0,0},
+	[CT_CREATE_BIT]		= {3,3,3,3,0,0,1,0,0,1,1},
+	[CT_UPDATE_BIT]		= {2,2,2,2,0,0,2,0,0,2,2},
+	[CT_DELETE_BIT]		= {2,2,2,2,0,0,2,0,0,0,0},
+	[CT_GET_BIT]		= {3,3,3,3,0,0,2,0,0,2,2},
+	[CT_FLUSH_BIT]		= {0,0,0,0,0,0,0,0,0,0,0},
+	[CT_EVENT_BIT]		= {2,2,2,2,0,0,2,0,0,0,0},
+	[CT_VERSION_BIT]	= {0,0,0,0,0,0,0,0,0,0,0},
+	[CT_HELP_BIT]		= {0,0,0,0,0,0,0,0,0,0,0},
+	[EXP_LIST_BIT]		= {0,0,0,0,0,0,0,0,0,0,0},
+	[EXP_CREATE_BIT]	= {1,1,0,0,1,1,0,1,1,1,1},
+	[EXP_DELETE_BIT]	= {1,1,1,1,0,0,0,0,0,0,0},
+	[EXP_GET_BIT]		= {1,1,1,1,0,0,0,0,0,0,0},
+	[EXP_FLUSH_BIT]		= {0,0,0,0,0,0,0,0,0,0,0},
+	[EXP_EVENT_BIT]		= {0,0,0,0,0,0,0,0,0,0,0},
 };
 
 static const char *sctp_states[SCTP_CONNTRACK_MAX] = {
diff --git a/extensions/libct_proto_tcp.c b/extensions/libct_proto_tcp.c
index 3da0dc6..7e4500c 100644
--- a/extensions/libct_proto_tcp.c
+++ b/extensions/libct_proto_tcp.c
@@ -54,22 +54,22 @@ static const char *tcp_optflags[TCP_NUMBER_OF_OPT] = {
 static char tcp_commands_v_options[NUMBER_OF_CMD][TCP_NUMBER_OF_OPT] =
 /* Well, it's better than "Re: Sevilla vs Betis" */
 {
-	    	/* 1 2 3 4 5 6 7 8 9 */
-/*CT_LIST*/   	  {2,2,2,2,0,0,2,0,0},
-/*CT_CREATE*/	  {3,3,3,3,0,0,1,0,0},
-/*CT_UPDATE*/	  {2,2,2,2,0,0,2,0,0},
-/*CT_DELETE*/	  {2,2,2,2,0,0,2,0,0},
-/*CT_GET*/	  {3,3,3,3,0,0,2,0,0},
-/*CT_FLUSH*/	  {0,0,0,0,0,0,0,0,0},
-/*CT_EVENT*/	  {2,2,2,2,0,0,2,0,0},
-/*CT_VERSION*/	  {0,0,0,0,0,0,0,0,0},
-/*CT_HELP*/	  {0,0,0,0,0,0,0,0,0},
-/*EXP_LIST*/	  {0,0,0,0,0,0,0,0,0},
-/*EXP_CREATE*/	  {1,1,0,0,1,1,0,1,1},
-/*EXP_DELETE*/	  {1,1,1,1,0,0,0,0,0},
-/*EXP_GET*/	  {1,1,1,1,0,0,0,0,0},
-/*EXP_FLUSH*/	  {0,0,0,0,0,0,0,0,0},
-/*EXP_EVENT*/	  {0,0,0,0,0,0,0,0,0},
+				/* 1 2 3 4 5 6 7 8 9 */
+	[CT_LIST_BIT]		= {2,2,2,2,0,0,2,0,0},
+	[CT_CREATE_BIT]		= {3,3,3,3,0,0,1,0,0},
+	[CT_UPDATE_BIT]		= {2,2,2,2,0,0,2,0,0},
+	[CT_DELETE_BIT]		= {2,2,2,2,0,0,2,0,0},
+	[CT_GET_BIT]		= {3,3,3,3,0,0,2,0,0},
+	[CT_FLUSH_BIT]		= {0,0,0,0,0,0,0,0,0},
+	[CT_EVENT_BIT]		= {2,2,2,2,0,0,2,0,0},
+	[CT_VERSION_BIT]	= {0,0,0,0,0,0,0,0,0},
+	[CT_HELP_BIT]		= {0,0,0,0,0,0,0,0,0},
+	[EXP_LIST_BIT]		= {0,0,0,0,0,0,0,0,0},
+	[EXP_CREATE_BIT]	= {1,1,0,0,1,1,0,1,1},
+	[EXP_DELETE_BIT]	= {1,1,1,1,0,0,0,0,0},
+	[EXP_GET_BIT]		= {1,1,1,1,0,0,0,0,0},
+	[EXP_FLUSH_BIT]		= {0,0,0,0,0,0,0,0,0},
+	[EXP_EVENT_BIT]		= {0,0,0,0,0,0,0,0,0},
 };
 
 static const char *tcp_states[TCP_CONNTRACK_MAX] = {
diff --git a/extensions/libct_proto_udp.c b/extensions/libct_proto_udp.c
index fe43548..fce489d 100644
--- a/extensions/libct_proto_udp.c
+++ b/extensions/libct_proto_udp.c
@@ -62,22 +62,22 @@ static void help(void)
 static char udp_commands_v_options[NUMBER_OF_CMD][UDP_NUMBER_OF_OPT] =
 /* Well, it's better than "Re: Galeano vs Vargas Llosa" */
 {
-		/* 1 2 3 4 5 6 7 8 */
-/*CT_LIST*/	  {2,2,2,2,0,0,0,0},
-/*CT_CREATE*/     {3,3,3,3,0,0,0,0},
-/*CT_UPDATE*/     {2,2,2,2,0,0,0,0},
-/*CT_DELETE*/     {2,2,2,2,0,0,0,0},
-/*CT_GET*/        {3,3,3,3,0,0,0,0},
-/*CT_FLUSH*/      {0,0,0,0,0,0,0,0},
-/*CT_EVENT*/      {2,2,2,2,0,0,0,0},
-/*CT_VERSION*/    {0,0,0,0,0,0,0,0},
-/*CT_HELP*/       {0,0,0,0,0,0,0,0},
-/*EXP_LIST*/      {0,0,0,0,0,0,0,0},
-/*EXP_CREATE*/    {1,1,0,0,1,1,1,1},
-/*EXP_DELETE*/    {1,1,1,1,0,0,0,0},
-/*EXP_GET*/       {1,1,1,1,0,0,0,0},
-/*EXP_FLUSH*/     {0,0,0,0,0,0,0,0},
-/*EXP_EVENT*/     {0,0,0,0,0,0,0,0},
+				/* 1 2 3 4 5 6 7 8 */
+	[CT_LIST_BIT]		= {2,2,2,2,0,0,0,0},
+	[CT_CREATE_BIT]		= {3,3,3,3,0,0,0,0},
+	[CT_UPDATE_BIT]		= {2,2,2,2,0,0,0,0},
+	[CT_DELETE_BIT]		= {2,2,2,2,0,0,0,0},
+	[CT_GET_BIT]		= {3,3,3,3,0,0,0,0},
+	[CT_FLUSH_BIT]		= {0,0,0,0,0,0,0,0},
+	[CT_EVENT_BIT]		= {2,2,2,2,0,0,0,0},
+	[CT_VERSION_BIT]	= {0,0,0,0,0,0,0,0},
+	[CT_HELP_BIT]		= {0,0,0,0,0,0,0,0},
+	[EXP_LIST_BIT]		= {0,0,0,0,0,0,0,0},
+	[EXP_CREATE_BIT]	= {1,1,0,0,1,1,1,1},
+	[EXP_DELETE_BIT]	= {1,1,1,1,0,0,0,0},
+	[EXP_GET_BIT]		= {1,1,1,1,0,0,0,0},
+	[EXP_FLUSH_BIT]		= {0,0,0,0,0,0,0,0},
+	[EXP_EVENT_BIT]		= {0,0,0,0,0,0,0,0},
 };
 
 static int parse_options(char c,
diff --git a/extensions/libct_proto_udplite.c b/extensions/libct_proto_udplite.c
index 2bece38..8d42d1a 100644
--- a/extensions/libct_proto_udplite.c
+++ b/extensions/libct_proto_udplite.c
@@ -70,22 +70,22 @@ static void help(void)
 
 static char udplite_commands_v_options[NUMBER_OF_CMD][UDP_OPT_MAX] =
 {
-		/* 1 2 3 4 5 6 7 8 */
-/*CT_LIST*/	  {2,2,2,2,0,0,0,0},
-/*CT_CREATE*/	  {3,3,3,3,0,0,0,0},
-/*CT_UPDATE*/	  {2,2,2,2,0,0,0,0},
-/*CT_DELETE*/	  {2,2,2,2,0,0,0,0},
-/*CT_GET*/	  {3,3,3,3,0,0,0,0},
-/*CT_FLUSH*/	  {0,0,0,0,0,0,0,0},
-/*CT_EVENT*/	  {2,2,2,2,0,0,0,0},
-/*CT_VERSION*/	  {0,0,0,0,0,0,0,0},
-/*CT_HELP*/	  {0,0,0,0,0,0,0,0},
-/*EXP_LIST*/	  {0,0,0,0,0,0,0,0},
-/*EXP_CREATE*/	  {1,1,0,0,1,1,1,1},
-/*EXP_DELETE*/	  {1,1,1,1,0,0,0,0},
-/*EXP_GET*/	  {1,1,1,1,0,0,0,0},
-/*EXP_FLUSH*/	  {0,0,0,0,0,0,0,0},
-/*EXP_EVENT*/	  {0,0,0,0,0,0,0,0},
+				/* 1 2 3 4 5 6 7 8 */
+	[CT_LIST_BIT]		= {2,2,2,2,0,0,0,0},
+	[CT_CREATE_BIT]		= {3,3,3,3,0,0,0,0},
+	[CT_UPDATE_BIT]		= {2,2,2,2,0,0,0,0},
+	[CT_DELETE_BIT]		= {2,2,2,2,0,0,0,0},
+	[CT_GET_BIT]		= {3,3,3,3,0,0,0,0},
+	[CT_FLUSH_BIT]		= {0,0,0,0,0,0,0,0},
+	[CT_EVENT_BIT]		= {2,2,2,2,0,0,0,0},
+	[CT_VERSION_BIT]	= {0,0,0,0,0,0,0,0},
+	[CT_HELP_BIT]		= {0,0,0,0,0,0,0,0},
+	[EXP_LIST_BIT]		= {0,0,0,0,0,0,0,0},
+	[EXP_CREATE_BIT]	= {1,1,0,0,1,1,1,1},
+	[EXP_DELETE_BIT]	= {1,1,1,1,0,0,0,0},
+	[EXP_GET_BIT]		= {1,1,1,1,0,0,0,0},
+	[EXP_FLUSH_BIT]		= {0,0,0,0,0,0,0,0},
+	[EXP_EVENT_BIT]		= {0,0,0,0,0,0,0,0},
 };
 
 static int parse_options(char c,
diff --git a/include/conntrack.h b/include/conntrack.h
index 1c1720e..bc17af0 100644
--- a/include/conntrack.h
+++ b/include/conntrack.h
@@ -11,7 +11,70 @@
 #include <linux/netfilter/nf_conntrack_common.h>
 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
 
-#define NUMBER_OF_CMD   19
+enum ct_command {
+	CT_NONE		= 0,
+
+	CT_LIST_BIT 	= 0,
+	CT_LIST 	= (1 << CT_LIST_BIT),
+
+	CT_CREATE_BIT	= 1,
+	CT_CREATE	= (1 << CT_CREATE_BIT),
+
+	CT_UPDATE_BIT	= 2,
+	CT_UPDATE	= (1 << CT_UPDATE_BIT),
+
+	CT_DELETE_BIT	= 3,
+	CT_DELETE	= (1 << CT_DELETE_BIT),
+
+	CT_GET_BIT	= 4,
+	CT_GET		= (1 << CT_GET_BIT),
+
+	CT_FLUSH_BIT	= 5,
+	CT_FLUSH	= (1 << CT_FLUSH_BIT),
+
+	CT_EVENT_BIT	= 6,
+	CT_EVENT	= (1 << CT_EVENT_BIT),
+
+	CT_VERSION_BIT	= 7,
+	CT_VERSION	= (1 << CT_VERSION_BIT),
+
+	CT_HELP_BIT	= 8,
+	CT_HELP		= (1 << CT_HELP_BIT),
+
+	EXP_LIST_BIT 	= 9,
+	EXP_LIST 	= (1 << EXP_LIST_BIT),
+
+	EXP_CREATE_BIT	= 10,
+	EXP_CREATE	= (1 << EXP_CREATE_BIT),
+
+	EXP_DELETE_BIT	= 11,
+	EXP_DELETE	= (1 << EXP_DELETE_BIT),
+
+	EXP_GET_BIT	= 12,
+	EXP_GET		= (1 << EXP_GET_BIT),
+
+	EXP_FLUSH_BIT	= 13,
+	EXP_FLUSH	= (1 << EXP_FLUSH_BIT),
+
+	EXP_EVENT_BIT	= 14,
+	EXP_EVENT	= (1 << EXP_EVENT_BIT),
+
+	CT_COUNT_BIT	= 15,
+	CT_COUNT	= (1 << CT_COUNT_BIT),
+
+	EXP_COUNT_BIT	= 16,
+	EXP_COUNT	= (1 << EXP_COUNT_BIT),
+
+	CT_STATS_BIT	= 17,
+	CT_STATS	= (1 << CT_STATS_BIT),
+
+	EXP_STATS_BIT	= 18,
+	EXP_STATS	= (1 << EXP_STATS_BIT),
+
+	_CT_BIT_MAX	= 19,
+};
+
+#define NUMBER_OF_CMD   _CT_BIT_MAX
 #define NUMBER_OF_OPT   29
 
 struct nf_conntrack;
diff --git a/src/conntrack.c b/src/conntrack.c
index 6c999f4..e96e42d 100644
--- a/src/conntrack.c
+++ b/src/conntrack.c
@@ -153,68 +153,6 @@ static void free_tmpl_objects(struct ct_tmpl *tmpl)
 		nfct_bitmask_destroy(tmpl->label_modify);
 }
 
-enum ct_command {
-	CT_NONE		= 0,
-
-	CT_LIST_BIT 	= 0,
-	CT_LIST 	= (1 << CT_LIST_BIT),
-
-	CT_CREATE_BIT	= 1,
-	CT_CREATE	= (1 << CT_CREATE_BIT),
-
-	CT_UPDATE_BIT	= 2,
-	CT_UPDATE	= (1 << CT_UPDATE_BIT),
-
-	CT_DELETE_BIT	= 3,
-	CT_DELETE	= (1 << CT_DELETE_BIT),
-
-	CT_GET_BIT	= 4,
-	CT_GET		= (1 << CT_GET_BIT),
-
-	CT_FLUSH_BIT	= 5,
-	CT_FLUSH	= (1 << CT_FLUSH_BIT),
-
-	CT_EVENT_BIT	= 6,
-	CT_EVENT	= (1 << CT_EVENT_BIT),
-
-	CT_VERSION_BIT	= 7,
-	CT_VERSION	= (1 << CT_VERSION_BIT),
-
-	CT_HELP_BIT	= 8,
-	CT_HELP		= (1 << CT_HELP_BIT),
-
-	EXP_LIST_BIT 	= 9,
-	EXP_LIST 	= (1 << EXP_LIST_BIT),
-
-	EXP_CREATE_BIT	= 10,
-	EXP_CREATE	= (1 << EXP_CREATE_BIT),
-
-	EXP_DELETE_BIT	= 11,
-	EXP_DELETE	= (1 << EXP_DELETE_BIT),
-
-	EXP_GET_BIT	= 12,
-	EXP_GET		= (1 << EXP_GET_BIT),
-
-	EXP_FLUSH_BIT	= 13,
-	EXP_FLUSH	= (1 << EXP_FLUSH_BIT),
-
-	EXP_EVENT_BIT	= 14,
-	EXP_EVENT	= (1 << EXP_EVENT_BIT),
-
-	CT_COUNT_BIT	= 15,
-	CT_COUNT	= (1 << CT_COUNT_BIT),
-
-	EXP_COUNT_BIT	= 16,
-	EXP_COUNT	= (1 << EXP_COUNT_BIT),
-
-	CT_STATS_BIT	= 17,
-	CT_STATS	= (1 << CT_STATS_BIT),
-
-	EXP_STATS_BIT	= 18,
-	EXP_STATS	= (1 << EXP_STATS_BIT),
-};
-/* If you add a new command, you have to update NUMBER_OF_CMD in conntrack.h */
-
 enum ct_options {
 	CT_OPT_ORIG_SRC_BIT	= 0,
 	CT_OPT_ORIG_SRC 	= (1 << CT_OPT_ORIG_SRC_BIT),
@@ -413,26 +351,26 @@ static const char *getopt_str = ":L::I::U::D::G::E::F::hVs:d:r:q:"
 static char commands_v_options[NUMBER_OF_CMD][NUMBER_OF_OPT] =
 /* Well, it's better than "Re: Linux vs FreeBSD" */
 {
-          /*   s d r q p t u z e [ ] { } a m i f n g o c b j w l < > ( ) */
-/*CT_LIST*/   {2,2,2,2,2,0,2,2,0,0,0,2,2,0,2,0,2,2,2,2,2,0,2,2,2,0,0,2,2},
-/*CT_CREATE*/ {3,3,3,3,1,1,2,0,0,0,0,0,0,2,2,0,0,2,2,0,0,0,0,2,0,2,0,2,2},
-/*CT_UPDATE*/ {2,2,2,2,2,2,2,0,0,0,0,2,2,0,2,2,2,2,2,2,0,0,0,0,2,2,2,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,0},
+	[EXP_DELETE_BIT]	= {1,1,2,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+	[EXP_GET_BIT]		= {1,1,2,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+	[EXP_FLUSH_BIT]		= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+	[EXP_EVENT_BIT]		= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0},
+	[CT_COUNT_BIT]		= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+	[EXP_COUNT_BIT]		= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+	[CT_STATS_BIT]		= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+	[EXP_STATS_BIT]		= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
 };
 
 static const int cmd2type[][2] = {
-- 
2.25.1




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux