Move chain name variables to netfilter/*

This commit is contained in:
Thomas Bernard 2020-09-28 22:44:24 +02:00 committed by BERNARD Thomas
parent 61d4aecb6e
commit f9908a788b
7 changed files with 50 additions and 54 deletions

View File

@ -69,7 +69,7 @@ update_portmapping_desc_timestamp(const char * ifname,
unsigned short eport, int proto, unsigned short eport, int proto,
const char * desc, unsigned int timestamp); const char * desc, unsigned int timestamp);
#ifdef USE_NFTABLES #if defined(USE_NETFILTER)
/* /*
* only provided by nftables implementation at the moment. * only provided by nftables implementation at the moment.
* Should be implemented for iptables too, for consistency * Should be implemented for iptables too, for consistency

View File

@ -1310,7 +1310,6 @@ init(int argc, char * * argv, struct runtime_vars * v)
break; break;
#endif /* ENABLE_MANUFACTURER_INFO_CONFIGURATION */ #endif /* ENABLE_MANUFACTURER_INFO_CONFIGURATION */
#ifdef USE_NETFILTER #ifdef USE_NETFILTER
#ifdef USE_NFTABLES
case UPNPFORWARDCHAIN: case UPNPFORWARDCHAIN:
set_rdr_name(RDR_FORWARD_CHAIN_NAME, ary_options[i].value); set_rdr_name(RDR_FORWARD_CHAIN_NAME, ary_options[i].value);
break; break;
@ -1320,17 +1319,6 @@ init(int argc, char * * argv, struct runtime_vars * v)
case UPNPNATPOSTCHAIN: case UPNPNATPOSTCHAIN:
set_rdr_name(RDR_NAT_POSTROUTING_CHAIN_NAME, ary_options[i].value); set_rdr_name(RDR_NAT_POSTROUTING_CHAIN_NAME, ary_options[i].value);
break; break;
#else
case UPNPFORWARDCHAIN:
miniupnpd_forward_chain = ary_options[i].value;
break;
case UPNPNATCHAIN:
miniupnpd_nat_chain = ary_options[i].value;
break;
case UPNPNATPOSTCHAIN:
miniupnpd_nat_postrouting_chain = ary_options[i].value;
break;
#endif /* else USE_NFTABLES */
#endif /* USE_NETFILTER */ #endif /* USE_NETFILTER */
case UPNPNOTIFY_INTERVAL: case UPNPNOTIFY_INTERVAL:
v->notify_interval = atoi(ary_options[i].value); v->notify_interval = atoi(ary_options[i].value);

View File

@ -64,6 +64,50 @@
#include "iptcrdr.h" #include "iptcrdr.h"
#include "../upnpglobalvars.h" #include "../upnpglobalvars.h"
/* chain names to use in the nat and filter tables. */
/* iptables -t nat -N MINIUPNPD
* iptables -t nat -A PREROUTING -i <ext_if_name> -j MINIUPNPD */
static const char * miniupnpd_nat_chain = "MINIUPNPD";
/* iptables -t nat -N MINIUPNPD-POSTROUTING
* iptables -t nat -A POSTROUTING -o <ext_if_name> -j MINIUPNPD-POSTROUTING */
static const char * miniupnpd_nat_postrouting_chain = "MINIUPNPD-POSTROUTING";
/* iptables -t filter -N MINIUPNPD
* iptables -t filter -A FORWARD -i <ext_if_name> ! -o <ext_if_name> -j MINIUPNPD */
static const char * miniupnpd_forward_chain = "MINIUPNPD";
/**
* used by the core to override default chain names if specified in config file
* @param param which string to set
* @param string the new name to use. Do not dispose after setting (i.e. use strdup if not static).
* @return 0 if successful
*/
int
set_rdr_name(rdr_name_type param, const char *string)
{
if (string == NULL || strlen(string) > 30 || string[0] == '\0') {
syslog(LOG_ERR, "%s(): invalid string argument '%s'", "set_rdr_name", string);
return -1;
}
switch (param) {
case RDR_NAT_PREROUTING_CHAIN_NAME:
miniupnpd_nat_chain = string;
break;
case RDR_NAT_POSTROUTING_CHAIN_NAME:
miniupnpd_nat_postrouting_chain = string;
break;
case RDR_FORWARD_CHAIN_NAME:
miniupnpd_forward_chain = string;
break;
default:
syslog(LOG_ERR, "%s(): tried to set invalid string parameter: %d", "set_rdr_name", param);
return -2;
}
return 0;
}
/* local functions declarations */ /* local functions declarations */
static int static int
addnatrule(int proto, unsigned short eport, addnatrule(int proto, unsigned short eport,

View File

@ -28,6 +28,8 @@
static int next_uid = 1; static int next_uid = 1;
static const char * miniupnpd_v6_filter_chain = "MINIUPNPD";
static LIST_HEAD(pinhole_list_t, pinhole_t) pinhole_list; static LIST_HEAD(pinhole_list_t, pinhole_t) pinhole_list;
static struct pinhole_t * static struct pinhole_t *

View File

@ -14,12 +14,6 @@
#include "config.h" #include "config.h"
#include "portinuse.h" #include "portinuse.h"
#ifdef USE_NETFILTER
const char * miniupnpd_nat_chain = "MINIUPNPD";
const char * miniupnpd_nat_postrouting_chain = "MINIUPNPD-POSTROUTING";
const char * miniupnpd_forward_chain = "MINIUPNPD";
#endif /* USE_NETFILTER */
int main(int argc, char * * argv) int main(int argc, char * * argv)
{ {
#ifndef CHECK_PORTINUSE #ifndef CHECK_PORTINUSE

View File

@ -1,8 +1,8 @@
/* $Id: upnpglobalvars.c,v 1.45 2019/10/02 22:02:58 nanard Exp $ */ /* $Id: upnpglobalvars.c,v 1.45 2019/10/02 22:02:58 nanard Exp $ */
/* vim: tabstop=4 shiftwidth=4 noexpandtab /* vim: tabstop=4 shiftwidth=4 noexpandtab
* MiniUPnP project * MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
* (c) 2006-2019 Thomas Bernard * (c) 2006-2020 Thomas Bernard
* This software is subject to the conditions detailed * This software is subject to the conditions detailed
* in the LICENCE file provided within the distribution */ * in the LICENCE file provided within the distribution */
@ -109,29 +109,6 @@ const char * queue = 0;
const char * tag = 0; const char * tag = 0;
#endif #endif
#ifdef USE_IPTABLES
/* chain names to use in the nat and filter tables. */
/* iptables -t nat -N MINIUPNPD
* iptables -t nat -A PREROUTING -i <ext_if_name> -j MINIUPNPD */
const char * miniupnpd_nat_chain = "MINIUPNPD";
/* iptables -t nat -N MINIUPNPD-POSTROUTING
* iptables -t nat -A POSTROUTING -o <ext_if_name> -j MINIUPNPD-POSTROUTING */
const char * miniupnpd_nat_postrouting_chain = "MINIUPNPD-POSTROUTING";
/* iptables -t filter -N MINIUPNPD
* iptables -t filter -A FORWARD -i <ext_if_name> ! -o <ext_if_name> -j MINIUPNPD */
const char * miniupnpd_forward_chain = "MINIUPNPD";
#ifdef ENABLE_UPNPPINHOLE
/* ip6tables -t filter -N MINIUPNPD
* ip6tables -t filter -A FORWARD -i <ext_if_name> ! -o <ext_if_name> -j MINIUPNPD */
const char * miniupnpd_v6_filter_chain = "MINIUPNPD";
#endif /* ENABLE_UPNPPINHOLE */
#endif /* USE_NETFILTER */
#ifdef ENABLE_NFQUEUE #ifdef ENABLE_NFQUEUE
int nfqueue = -1; int nfqueue = -1;
int n_nfqix = 0; int n_nfqix = 0;

View File

@ -2,7 +2,7 @@
/* vim: tabstop=4 shiftwidth=4 noexpandtab /* vim: tabstop=4 shiftwidth=4 noexpandtab
* MiniUPnP project * MiniUPnP project
* http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/ * http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
* (c) 2006-2019 Thomas Bernard * (c) 2006-2020 Thomas Bernard
* This software is subject to the conditions detailed * This software is subject to the conditions detailed
* in the LICENCE file provided within the distribution */ * in the LICENCE file provided within the distribution */
@ -142,15 +142,6 @@ extern const char * queue;
extern const char * tag; extern const char * tag;
#endif #endif
#ifdef USE_IPTABLES
extern const char * miniupnpd_nat_chain;
extern const char * miniupnpd_nat_postrouting_chain;
extern const char * miniupnpd_forward_chain;
#ifdef ENABLE_UPNPPINHOLE
extern const char * miniupnpd_v6_filter_chain;
#endif
#endif
#ifdef ENABLE_NFQUEUE #ifdef ENABLE_NFQUEUE
extern int nfqueue; extern int nfqueue;
extern int n_nfqix; extern int n_nfqix;