2019-05-21 08:42:40 +00:00
|
|
|
/* $Id: upnpglobalvars.c,v 1.44 2019/05/21 08:39:45 nanard Exp $ */
|
2017-05-27 08:25:53 +00:00
|
|
|
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
|
|
|
* MiniUPnP project
|
2011-09-28 19:13:20 +00:00
|
|
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
2018-07-06 12:16:49 +00:00
|
|
|
* (c) 2006-2018 Thomas Bernard
|
2011-09-28 19:13:20 +00:00
|
|
|
* This software is subject to the conditions detailed
|
|
|
|
* in the LICENCE file provided within the distribution */
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "upnpglobalvars.h"
|
2013-10-20 21:02:19 +00:00
|
|
|
#include "upnpdescstrings.h"
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
/* network interface for internet */
|
|
|
|
const char * ext_if_name = 0;
|
|
|
|
|
2019-05-21 08:42:40 +00:00
|
|
|
#ifdef ENABLE_IPV6
|
|
|
|
/* network interface for internet - IPv6 */
|
|
|
|
const char * ext_if_name6 = 0;
|
|
|
|
#endif
|
|
|
|
|
2018-05-19 11:32:42 +00:00
|
|
|
/* stun host/port configuration */
|
|
|
|
const char * ext_stun_host = 0;
|
|
|
|
uint16_t ext_stun_port = 0;
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
/* file to store leases */
|
|
|
|
#ifdef ENABLE_LEASEFILE
|
|
|
|
const char* lease_file = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* forced ip address to use for this interface
|
|
|
|
* when NULL, getifaddr() is used */
|
|
|
|
const char * use_ext_ip_addr = 0;
|
|
|
|
|
2018-05-19 11:32:04 +00:00
|
|
|
/* disallow all port forwarding requests when
|
|
|
|
* we are behind restrictive nat */
|
|
|
|
int disable_port_forwarding = 0;
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
unsigned long downstream_bitrate = 0;
|
|
|
|
unsigned long upstream_bitrate = 0;
|
|
|
|
|
|
|
|
/* startup time */
|
|
|
|
time_t startup_time = 0;
|
|
|
|
|
2017-11-27 20:47:35 +00:00
|
|
|
#if defined(ENABLE_NATPMP) || defined(ENABLE_PCP)
|
|
|
|
/* origin for "epoch time" sent into NATPMP and PCP responses */
|
|
|
|
time_t epoch_origin = 0;
|
|
|
|
#endif /* defined(ENABLE_NATPMP) || defined(ENABLE_PCP) */
|
|
|
|
|
2014-02-03 09:47:47 +00:00
|
|
|
#ifdef ENABLE_PCP
|
|
|
|
/* for PCP */
|
2013-07-09 13:36:53 +00:00
|
|
|
unsigned long int min_lifetime = 120;
|
|
|
|
unsigned long int max_lifetime = 86400;
|
2014-02-03 09:47:47 +00:00
|
|
|
#endif
|
2013-07-09 13:36:53 +00:00
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
int runtime_flags = 0;
|
|
|
|
|
|
|
|
const char * pidfilename = "/var/run/miniupnpd.pid";
|
|
|
|
|
2013-06-13 14:03:36 +00:00
|
|
|
char uuidvalue_igd[] = "uuid:00000000-0000-0000-0000-000000000000";
|
|
|
|
char uuidvalue_wan[] = "uuid:00000000-0000-0000-0000-000000000000";
|
|
|
|
char uuidvalue_wcd[] = "uuid:00000000-0000-0000-0000-000000000000";
|
2011-09-28 19:13:20 +00:00
|
|
|
char serialnumber[SERIALNUMBER_MAX_LEN] = "00000000";
|
|
|
|
|
|
|
|
char modelnumber[MODELNUMBER_MAX_LEN] = "1";
|
|
|
|
|
|
|
|
/* presentation url :
|
|
|
|
* http://nnn.nnn.nnn.nnn:ppppp/ => max 30 bytes including terminating 0 */
|
2012-03-01 01:44:38 +00:00
|
|
|
char presentationurl[PRESENTATIONURL_MAX_LEN];
|
2012-02-04 23:24:13 +00:00
|
|
|
|
2013-12-13 11:03:28 +00:00
|
|
|
#ifdef ENABLE_MANUFACTURER_INFO_CONFIGURATION
|
2012-02-04 23:24:13 +00:00
|
|
|
/* friendly name for root devices in XML description */
|
|
|
|
char friendly_name[FRIENDLY_NAME_MAX_LEN] = OS_NAME " router";
|
2011-09-28 19:13:20 +00:00
|
|
|
|
2013-10-20 21:02:19 +00:00
|
|
|
/* manufacturer name for root devices in XML description */
|
|
|
|
char manufacturer_name[MANUFACTURER_NAME_MAX_LEN] = ROOTDEV_MANUFACTURER;
|
|
|
|
|
|
|
|
/* manufacturer url for root devices in XML description */
|
|
|
|
char manufacturer_url[MANUFACTURER_URL_MAX_LEN] = ROOTDEV_MANUFACTURERURL;
|
|
|
|
|
|
|
|
/* model name for root devices in XML description */
|
|
|
|
char model_name[MODEL_NAME_MAX_LEN] = ROOTDEV_MODELNAME;
|
|
|
|
|
|
|
|
/* model description for root devices in XML description */
|
|
|
|
char model_description[MODEL_DESCRIPTION_MAX_LEN] = ROOTDEV_MODELDESCRIPTION;
|
|
|
|
|
|
|
|
/* model url for root devices in XML description */
|
|
|
|
char model_url[MODEL_URL_MAX_LEN] = ROOTDEV_MODELURL;
|
2013-12-13 11:03:28 +00:00
|
|
|
#endif
|
2013-10-20 21:02:19 +00:00
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
/* UPnP permission rules : */
|
|
|
|
struct upnpperm * upnppermlist = 0;
|
|
|
|
unsigned int num_upnpperm = 0;
|
|
|
|
|
2013-07-09 13:36:53 +00:00
|
|
|
#ifdef PCP_SADSCP
|
|
|
|
struct dscp_values* dscp_values_list = 0;
|
|
|
|
unsigned int num_dscp_values = 0;
|
2013-12-13 16:01:41 +00:00
|
|
|
#endif /*PCP_SADSCP*/
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
/* For automatic removal of expired rules (with LeaseDuration) */
|
|
|
|
unsigned int nextruletoclean_timestamp = 0;
|
|
|
|
|
|
|
|
#ifdef USE_PF
|
2016-01-26 18:51:07 +00:00
|
|
|
/* "rdr-anchor miniupnpd" or/and "anchor miniupnpd" in pf.conf */
|
2012-02-03 12:14:10 +00:00
|
|
|
const char * anchor_name = "miniupnpd";
|
2011-09-28 19:13:20 +00:00
|
|
|
const char * queue = 0;
|
|
|
|
const char * tag = 0;
|
|
|
|
#endif
|
|
|
|
|
2019-09-30 07:12:08 +00:00
|
|
|
#ifdef USE_IPTABLES
|
2016-01-26 18:51:07 +00:00
|
|
|
/* 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 */
|
2011-09-28 19:13:20 +00:00
|
|
|
const char * miniupnpd_nat_chain = "MINIUPNPD";
|
2016-01-26 18:51:07 +00:00
|
|
|
|
|
|
|
/* iptables -t nat -N MINIUPNPD-POSTROUTING
|
|
|
|
* iptables -t nat -A POSTROUTING -o <ext_if_name> -j MINIUPNPD-POSTROUTING */
|
2016-01-26 15:50:48 +00:00
|
|
|
const char * miniupnpd_nat_postrouting_chain = "MINIUPNPD-POSTROUTING";
|
2016-01-26 18:51:07 +00:00
|
|
|
|
|
|
|
/* iptables -t filter -N MINIUPNPD
|
|
|
|
* iptables -t filter -A FORWARD -i <ext_if_name> ! -o <ext_if_name> -j MINIUPNPD */
|
2011-09-28 19:13:20 +00:00
|
|
|
const char * miniupnpd_forward_chain = "MINIUPNPD";
|
2016-01-26 18:51:07 +00:00
|
|
|
|
2014-05-10 11:09:48 +00:00
|
|
|
#ifdef ENABLE_UPNPPINHOLE
|
2016-01-26 18:51:07 +00:00
|
|
|
/* ip6tables -t filter -N MINIUPNPD
|
|
|
|
* ip6tables -t filter -A FORWARD -i <ext_if_name> ! -o <ext_if_name> -j MINIUPNPD */
|
2012-04-26 14:08:39 +00:00
|
|
|
const char * miniupnpd_v6_filter_chain = "MINIUPNPD";
|
2016-01-26 18:51:07 +00:00
|
|
|
#endif /* ENABLE_UPNPPINHOLE */
|
|
|
|
|
|
|
|
#endif /* USE_NETFILTER */
|
2012-04-26 14:08:39 +00:00
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
#ifdef ENABLE_NFQUEUE
|
|
|
|
int nfqueue = -1;
|
|
|
|
int n_nfqix = 0;
|
|
|
|
unsigned nfqix[MAX_LAN_ADDR];
|
2016-01-26 18:51:07 +00:00
|
|
|
#endif /* ENABLE_NFQUEUE */
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
struct lan_addr_list lan_addrs;
|
|
|
|
|
|
|
|
#ifdef ENABLE_IPV6
|
|
|
|
/* ipv6 address used for HTTP */
|
|
|
|
char ipv6_addr_for_http_with_brackets[64];
|
2014-05-20 12:43:47 +00:00
|
|
|
|
|
|
|
/* address used to bind local services */
|
|
|
|
struct in6_addr ipv6_bind_addr;
|
2011-09-28 19:13:20 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Path of the Unix socket used to communicate with MiniSSDPd */
|
|
|
|
const char * minissdpdsocketpath = "/var/run/minissdpd.sock";
|
|
|
|
|
|
|
|
/* BOOTID.UPNP.ORG and CONFIGID.UPNP.ORG */
|
2014-12-10 09:03:13 +00:00
|
|
|
/* See UPnP Device Architecture v1.1 section 1.2 Advertisement :
|
|
|
|
* The field value of the BOOTID.UPNP.ORG header field MUST be increased
|
|
|
|
* each time a device (re)joins the network and sends an initial announce
|
|
|
|
* (a "reboot" in UPnP terms), or adds a UPnP-enabled interface.
|
|
|
|
* Unless the device explicitly announces a change in the BOOTID.UPNP.ORG
|
|
|
|
* field value using an SSDP message, as long as the device remains
|
|
|
|
* continuously available in the network, the same BOOTID.UPNP.ORG field
|
|
|
|
* value MUST be used in all repeat announcements, search responses,
|
|
|
|
* update messages and eventually bye-bye messages. */
|
|
|
|
unsigned int upnp_bootid = 1; /* BOOTID.UPNP.ORG */
|
|
|
|
/* The field value of the CONFIGID.UPNP.ORG header field identifies the
|
|
|
|
* current set of device and service descriptions; control points can
|
|
|
|
* parse this header field to detect whether they need to send new
|
|
|
|
* description query messages. */
|
2014-12-15 11:02:42 +00:00
|
|
|
/* UPnP 1.1 devices MAY freely assign configid numbers from 0 to
|
|
|
|
* 16777215 (2^24-1). Higher numbers are reserved for future use, and
|
|
|
|
* can be assigned by the Technical Committee. The configuration of a
|
|
|
|
* root device consists of the following information: the DDD of the
|
|
|
|
* root device and all its embedded devices, and the SCPDs of all the
|
|
|
|
* contained services. If any part of the configuration changes, the
|
|
|
|
* CONFIGID.UPNP.ORG field value MUST be changed.
|
|
|
|
* DDD = Device Description Document
|
|
|
|
* SCPD = Service Control Protocol Description */
|
2014-12-10 09:03:13 +00:00
|
|
|
unsigned int upnp_configid = 1337; /* CONFIGID.UPNP.ORG */
|
2011-09-28 19:13:20 +00:00
|
|
|
|
2015-09-14 10:10:15 +00:00
|
|
|
#ifdef RANDOMIZE_URLS
|
|
|
|
char random_url[RANDOM_URL_MAX_LEN] = "random";
|
|
|
|
#endif /* RANDOMIZE_URLS */
|