make rdr_name_type enum values more unique

This commit is contained in:
Paul Chambers 2019-10-02 13:29:29 -07:00 committed by Thomas Bernard
parent b36a6e94f8
commit 7ea314412c
3 changed files with 20 additions and 14 deletions

View File

@ -65,17 +65,23 @@ update_portmapping_desc_timestamp(const char * ifname,
const char * desc, unsigned int timestamp); const char * desc, unsigned int timestamp);
#ifdef USE_NFTABLES #ifdef USE_NFTABLES
/* only provided by nftables implementation at the moment */ /*
* only provided by nftables implementation at the moment.
* Should be implemented for iptables too, for consistency
*/
typedef enum { typedef enum {
TABLE_NAME, RDR_TABLE_NAME,
TABLE4_NAME, RDR_NAT_PREROUTING_CHAIN_NAME,
TABLE6_NAME, RDR_NAT_POSTROUTING_CHAIN_NAME,
NAT_CHAIN_NAME, RDR_FORWARD_CHAIN_NAME,
NAT_POSTROUTING_CHAIN_NAME,
FORWARD_CHAIN_NAME,
} rdr_name_type; } rdr_name_type;
/*
* used by the config file parsing in the core
* to set
*/
int set_rdr_name( rdr_name_type param, const char * string ); int set_rdr_name( rdr_name_type param, const char * string );
#endif #endif

View File

@ -1269,13 +1269,13 @@ init(int argc, char * * argv, struct runtime_vars * v)
#ifdef USE_NETFILTER #ifdef USE_NETFILTER
#ifdef USE_NFTABLES #ifdef USE_NFTABLES
case UPNPFORWARDCHAIN: case UPNPFORWARDCHAIN:
set_rdr_name(FORWARD_CHAIN_NAME, ary_options[i].value); set_rdr_name(RDR_FORWARD_CHAIN_NAME, ary_options[i].value);
break; break;
case UPNPNATCHAIN: case UPNPNATCHAIN:
set_rdr_name(NAT_CHAIN_NAME, ary_options[i].value); set_rdr_name(RDR_NAT_PREROUTING_CHAIN_NAME, ary_options[i].value);
break; break;
case UPNPNATPOSTCHAIN: case UPNPNATPOSTCHAIN:
set_rdr_name(NAT_POSTROUTING_CHAIN_NAME, ary_options[i].value); set_rdr_name(RDR_NAT_POSTROUTING_CHAIN_NAME, ary_options[i].value);
break; break;
#else #else
case UPNPFORWARDCHAIN: case UPNPFORWARDCHAIN:

View File

@ -155,16 +155,16 @@ set_rdr_name(rdr_name_type param, const char *string) {
return -1; return -1;
} }
switch (param) { switch (param) {
case TABLE_NAME: case RDR_TABLE_NAME:
nft_table = string; nft_table = string;
break; break;
case NAT_CHAIN_NAME: case RDR_NAT_PREROUTING_CHAIN_NAME:
nft_prerouting_chain = string; nft_prerouting_chain = string;
break; break;
case NAT_POSTROUTING_CHAIN_NAME: case RDR_NAT_POSTROUTING_CHAIN_NAME:
nft_postrouting_chain = string; nft_postrouting_chain = string;
break; break;
case FORWARD_CHAIN_NAME: case RDR_FORWARD_CHAIN_NAME:
nft_forward_chain = string; nft_forward_chain = string;
break; break;
default: default: