miniupnpd: reduce number of global variables by using more runtime_flags
change ipv6_enabled/ipv6fc_inbound_pinhole_allowed/ipv6fc_firewall_enabled global vars to flags in runtime_flags
This commit is contained in:
parent
15682180a5
commit
7b13adafbd
|
@ -3,6 +3,8 @@ $Id: Changelog.txt,v 1.362 2014/03/13 10:20:57 nanard Exp $
|
|||
2014/03/10:
|
||||
Enable PCP by default.
|
||||
Work in IPv6 on system where PF_INET6 are restricted to IPv6 only
|
||||
change ipv6_enabled/ipv6fc_inbound_pinhole_allowed/ipv6fc_firewall_enabled
|
||||
global vars to flags in runtime_flags
|
||||
|
||||
2014/03/09:
|
||||
IPv6 support in testgetifaddr
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: minissdp.c,v 1.58 2014/02/24 18:41:24 nanard Exp $ */
|
||||
/* $Id: minissdp.c,v 1.61 2014/03/10 11:04:51 nanard Exp $ */
|
||||
/* MiniUPnP project
|
||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* (c) 2006-2014 Thomas Bernard
|
||||
|
@ -281,16 +281,16 @@ OpenAndConfSSDPNotifySockets(int * sockets)
|
|||
goto error;
|
||||
i++;
|
||||
#ifdef ENABLE_IPV6
|
||||
if(ipv6_enabled)
|
||||
if(GETFLAG(IPV6DISABLEDMASK))
|
||||
{
|
||||
sockets[i] = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
sockets[i] = OpenAndConfSSDPNotifySocketIPv6(lan_addr->index);
|
||||
if(sockets[i] < 0)
|
||||
goto error;
|
||||
}
|
||||
else
|
||||
{
|
||||
sockets[i] = -1;
|
||||
}
|
||||
i++;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: miniupnpd.c,v 1.185 2014/02/28 12:14:26 nanard Exp $ */
|
||||
/* $Id: miniupnpd.c,v 1.189 2014/03/10 11:04:52 nanard Exp $ */
|
||||
/* MiniUPnP project
|
||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* (c) 2006-2014 Thomas Bernard
|
||||
|
@ -1579,7 +1579,7 @@ main(int argc, char * * argv)
|
|||
} else {
|
||||
memcpy(ipv6_addr_for_http_with_brackets, "[::1]", 6);
|
||||
syslog(LOG_WARNING, "no HTTP IPv6 address, disabling IPv6");
|
||||
ipv6_enabled = 0;
|
||||
SETFLAG(IPV6DISABLEDMASK);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1594,7 +1594,7 @@ main(int argc, char * * argv)
|
|||
}
|
||||
}
|
||||
#ifdef ENABLE_IPV6
|
||||
if(ipv6_enabled)
|
||||
if(!GETFLAG(IPV6DISABLEDMASK))
|
||||
{
|
||||
sudpv6 = OpenAndConfSSDPReceiveSocket(1);
|
||||
if(sudpv6 < 0)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id: testupnpdescgen.c,v 1.30 2013/06/13 13:21:30 nanard Exp $ */
|
||||
/* $Id: testupnpdescgen.c,v 1.32 2014/03/10 11:04:52 nanard Exp $ */
|
||||
/* MiniUPnP project
|
||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* (c) 2006-2013 Thomas Bernard
|
||||
* (c) 2006-2014 Thomas Bernard
|
||||
* This software is subject to the conditions detailed
|
||||
* in the LICENCE file provided within the distribution */
|
||||
|
||||
|
@ -38,10 +38,7 @@ char model_url[] = ROOTDEV_MODELURL;
|
|||
char * use_ext_ip_addr = NULL;
|
||||
const char * ext_if_name = "eth0";
|
||||
|
||||
#ifdef ENABLE_6FC_SERVICE
|
||||
int ipv6fc_firewall_enabled = 1;
|
||||
int ipv6fc_inbound_pinhole_allowed = 1;
|
||||
#endif
|
||||
int runtime_flags = 0;
|
||||
|
||||
int getifaddr(const char * ifname, char * buf, int len, struct in_addr * addr, struct in_addr * mask)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id: upnpdescgen.c,v 1.74 2013/06/13 13:21:30 nanard Exp $ */
|
||||
/* $Id: upnpdescgen.c,v 1.77 2014/03/10 11:04:53 nanard Exp $ */
|
||||
/* MiniUPnP project
|
||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* (c) 2006-2013 Thomas Bernard
|
||||
* (c) 2006-2014 Thomas Bernard
|
||||
* This software is subject to the conditions detailed
|
||||
* in the LICENCE file provided within the distribution */
|
||||
|
||||
|
@ -1176,13 +1176,13 @@ genEventVars(int * len, const struct serviceDesc * s)
|
|||
case FIREWALLENABLED_MAGICALVALUE:
|
||||
/* see 2.4.2 of UPnP-gw-WANIPv6FirewallControl-v1-Service.pdf */
|
||||
snprintf(tmp, sizeof(tmp), "%d",
|
||||
ipv6fc_firewall_enabled);
|
||||
GETFLAG(IPV6FCFWDISABLEDMASK) ? 0 : 1);
|
||||
str = strcat_str(str, len, &tmplen, tmp);
|
||||
break;
|
||||
case INBOUNDPINHOLEALLOWED_MAGICALVALUE:
|
||||
/* see 2.4.3 of UPnP-gw-WANIPv6FirewallControl-v1-Service.pdf */
|
||||
snprintf(tmp, sizeof(tmp), "%d",
|
||||
ipv6fc_inbound_pinhole_allowed);
|
||||
GETFLAG(IPV6FCINBOUNDDISALLOWEDMASK) ? 0 : 1);
|
||||
str = strcat_str(str, len, &tmplen, tmp);
|
||||
break;
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: upnpglobalvars.c,v 1.34 2014/02/06 09:52:03 nanard Exp $ */
|
||||
/* $Id: upnpglobalvars.c,v 1.35 2014/03/10 11:04:53 nanard Exp $ */
|
||||
/* MiniUPnP project
|
||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* (c) 2006-2014 Thomas Bernard
|
||||
|
@ -24,9 +24,6 @@ const char* lease_file = 0;
|
|||
* when NULL, getifaddr() is used */
|
||||
const char * use_ext_ip_addr = 0;
|
||||
|
||||
/* LAN address */
|
||||
/*const char * listen_addr = 0;*/
|
||||
|
||||
unsigned long downstream_bitrate = 0;
|
||||
unsigned long upstream_bitrate = 0;
|
||||
|
||||
|
@ -78,18 +75,10 @@ char model_url[MODEL_URL_MAX_LEN] = ROOTDEV_MODELURL;
|
|||
struct upnpperm * upnppermlist = 0;
|
||||
unsigned int num_upnpperm = 0;
|
||||
|
||||
#ifdef ENABLE_NATPMP
|
||||
/* NAT-PMP */
|
||||
#if 0
|
||||
unsigned int nextnatpmptoclean_timestamp = 0;
|
||||
unsigned short nextnatpmptoclean_eport = 0;
|
||||
unsigned short nextnatpmptoclean_proto = 0;
|
||||
#endif
|
||||
#ifdef PCP_SADSCP
|
||||
struct dscp_values* dscp_values_list = 0;
|
||||
unsigned int num_dscp_values = 0;
|
||||
#endif /*PCP_SADSCP*/
|
||||
#endif
|
||||
|
||||
/* For automatic removal of expired rules (with LeaseDuration) */
|
||||
unsigned int nextruletoclean_timestamp = 0;
|
||||
|
@ -121,7 +110,6 @@ struct lan_addr_list lan_addrs;
|
|||
#ifdef ENABLE_IPV6
|
||||
/* ipv6 address used for HTTP */
|
||||
char ipv6_addr_for_http_with_brackets[64];
|
||||
int ipv6_enabled = 1;
|
||||
#endif
|
||||
|
||||
/* Path of the Unix socket used to communicate with MiniSSDPd */
|
||||
|
@ -131,8 +119,3 @@ const char * minissdpdsocketpath = "/var/run/minissdpd.sock";
|
|||
unsigned int upnp_bootid = 1;
|
||||
unsigned int upnp_configid = 1337;
|
||||
|
||||
#ifdef ENABLE_6FC_SERVICE
|
||||
int ipv6fc_firewall_enabled = 1;
|
||||
int ipv6fc_inbound_pinhole_allowed = 1;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: upnpglobalvars.h,v 1.37 2014/02/06 09:52:03 nanard Exp $ */
|
||||
/* $Id: upnpglobalvars.h,v 1.38 2014/03/10 11:04:53 nanard Exp $ */
|
||||
/* MiniUPnP project
|
||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* (c) 2006-2014 Thomas Bernard
|
||||
|
@ -51,6 +51,13 @@ extern int runtime_flags;
|
|||
#ifdef PF_ENABLE_FILTER_RULES
|
||||
#define PFNOQUICKRULESMASK 0x0040
|
||||
#endif
|
||||
#ifdef ENABLE_IPV6
|
||||
#define IPV6DISABLEDMASK 0x0080
|
||||
#endif
|
||||
#ifdef ENABLE_6FC_SERVICE
|
||||
#define IPV6FCFWDISABLEDMASK 0x0100
|
||||
#define IPV6FCINBOUNDDISALLOWEDMASK 0x0200
|
||||
#endif
|
||||
|
||||
#define SETFLAG(mask) runtime_flags |= mask
|
||||
#define GETFLAG(mask) (runtime_flags & mask)
|
||||
|
@ -95,18 +102,10 @@ extern char model_url[];
|
|||
extern struct upnpperm * upnppermlist;
|
||||
extern unsigned int num_upnpperm;
|
||||
|
||||
#ifdef ENABLE_NATPMP
|
||||
/* NAT-PMP */
|
||||
#if 0
|
||||
extern unsigned int nextnatpmptoclean_timestamp;
|
||||
extern unsigned short nextnatpmptoclean_eport;
|
||||
extern unsigned short nextnatpmptoclean_proto;
|
||||
#endif
|
||||
#ifdef PCP_SADSCP
|
||||
extern struct dscp_values* dscp_values_list;
|
||||
extern unsigned int num_dscp_values;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* For automatic removal of expired rules (with LeaseDuration) */
|
||||
extern unsigned int nextruletoclean_timestamp;
|
||||
|
@ -139,7 +138,6 @@ extern struct lan_addr_list lan_addrs;
|
|||
#ifdef ENABLE_IPV6
|
||||
/* ipv6 address used for HTTP */
|
||||
extern char ipv6_addr_for_http_with_brackets[64];
|
||||
extern int ipv6_enabled;
|
||||
#endif
|
||||
|
||||
extern const char * minissdpdsocketpath;
|
||||
|
@ -148,10 +146,5 @@ extern const char * minissdpdsocketpath;
|
|||
extern unsigned int upnp_bootid;
|
||||
extern unsigned int upnp_configid;
|
||||
|
||||
#ifdef ENABLE_6FC_SERVICE
|
||||
extern int ipv6fc_firewall_enabled;
|
||||
extern int ipv6fc_inbound_pinhole_allowed;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id: upnpsoap.c,v 1.121 2014/02/28 15:01:31 nanard Exp $ */
|
||||
/* $Id: upnpsoap.c,v 1.122 2014/03/10 11:04:53 nanard Exp $ */
|
||||
/* MiniUPnP project
|
||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* (c) 2006-2013 Thomas Bernard
|
||||
* (c) 2006-2014 Thomas Bernard
|
||||
* This software is subject to the conditions detailed
|
||||
* in the LICENCE file provided within the distribution */
|
||||
|
||||
|
@ -1220,19 +1220,21 @@ GetFirewallStatus(struct upnphttp * h, const char * action)
|
|||
|
||||
bodylen = snprintf(body, sizeof(body), resp,
|
||||
action, "urn:schemas-upnp-org:service:WANIPv6FirewallControl:1",
|
||||
ipv6fc_firewall_enabled, ipv6fc_inbound_pinhole_allowed, action);
|
||||
GETFLAG(IPV6FCFWDISABLEDMASK) ? 0 : 1,
|
||||
GETFLAG(IPV6FCINBOUNDDISALLOWEDMASK) ? 0 : 1,
|
||||
action);
|
||||
BuildSendAndCloseSoapResp(h, body, bodylen);
|
||||
}
|
||||
|
||||
static int
|
||||
CheckStatus(struct upnphttp * h)
|
||||
{
|
||||
if (!ipv6fc_firewall_enabled)
|
||||
if (GETFLAG(IPV6FCFWDISABLEDMASK))
|
||||
{
|
||||
SoapError(h, 702, "FirewallDisabled");
|
||||
return 0;
|
||||
}
|
||||
else if(!ipv6fc_inbound_pinhole_allowed)
|
||||
else if(GETFLAG(IPV6FCINBOUNDDISALLOWEDMASK))
|
||||
{
|
||||
SoapError(h, 703, "InboundPinholeNotAllowed");
|
||||
return 0;
|
||||
|
@ -1604,7 +1606,7 @@ GetOutboundPinholeTimeout(struct upnphttp * h, const char * action)
|
|||
int opt=0, proto=0;
|
||||
unsigned short iport, rport;
|
||||
|
||||
if (!ipv6fc_firewall_enabled)
|
||||
if (GETFLAG(IPV6FCFWDISABLEDMASK))
|
||||
{
|
||||
SoapError(h, 702, "FirewallDisabled");
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue