1 /* $Id: upnpglobalvars.c,v 1.45 2019/10/02 22:02:58 nanard Exp $ */ 2 /* vim: tabstop=4 shiftwidth=4 noexpandtab 3 * MiniUPnP project 4 * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ 5 * (c) 2006-2019 Thomas Bernard 6 * This software is subject to the conditions detailed 7 * in the LICENCE file provided within the distribution */ 8 9 #include <sys/types.h> 10 #include <netinet/in.h> 11 12 #include "config.h" 13 #include "upnpglobalvars.h" 14 #include "upnpdescstrings.h" 15 16 /* network interface for internet */ 17 const char * ext_if_name = 0; 18 19 #ifdef ENABLE_IPV6 20 /* network interface for internet - IPv6 */ 21 const char * ext_if_name6 = 0; 22 #endif 23 24 /* stun host/port configuration */ 25 const char * ext_stun_host = 0; 26 uint16_t ext_stun_port = 0; 27 28 /* file to store leases */ 29 #ifdef ENABLE_LEASEFILE 30 const char* lease_file = 0; 31 #endif 32 33 /* forced ip address to use for this interface 34 * when NULL, getifaddr() is used */ 35 const char * use_ext_ip_addr = 0; 36 37 /* disallow all port forwarding requests when 38 * we are behind restrictive nat */ 39 int disable_port_forwarding = 0; 40 41 unsigned long downstream_bitrate = 0; 42 unsigned long upstream_bitrate = 0; 43 44 /* startup time */ 45 time_t startup_time = 0; 46 47 #if defined(ENABLE_NATPMP) || defined(ENABLE_PCP) 48 /* origin for "epoch time" sent into NATPMP and PCP responses */ 49 time_t epoch_origin = 0; 50 #endif /* defined(ENABLE_NATPMP) || defined(ENABLE_PCP) */ 51 52 #ifdef ENABLE_PCP 53 /* for PCP */ 54 unsigned long int min_lifetime = 120; 55 unsigned long int max_lifetime = 86400; 56 #endif 57 58 int runtime_flags = 0; 59 60 const char * pidfilename = "/var/run/miniupnpd.pid"; 61 62 char uuidvalue_igd[] = "uuid:00000000-0000-0000-0000-000000000000"; 63 char uuidvalue_wan[] = "uuid:00000000-0000-0000-0000-000000000000"; 64 char uuidvalue_wcd[] = "uuid:00000000-0000-0000-0000-000000000000"; 65 char serialnumber[SERIALNUMBER_MAX_LEN] = "00000000"; 66 67 char modelnumber[MODELNUMBER_MAX_LEN] = "1"; 68 69 /* presentation url : 70 * http://nnn.nnn.nnn.nnn:ppppp/ => max 30 bytes including terminating 0 */ 71 char presentationurl[PRESENTATIONURL_MAX_LEN]; 72 73 #ifdef ENABLE_MANUFACTURER_INFO_CONFIGURATION 74 /* friendly name for root devices in XML description */ 75 char friendly_name[FRIENDLY_NAME_MAX_LEN] = OS_NAME " router"; 76 77 /* manufacturer name for root devices in XML description */ 78 char manufacturer_name[MANUFACTURER_NAME_MAX_LEN] = ROOTDEV_MANUFACTURER; 79 80 /* manufacturer url for root devices in XML description */ 81 char manufacturer_url[MANUFACTURER_URL_MAX_LEN] = ROOTDEV_MANUFACTURERURL; 82 83 /* model name for root devices in XML description */ 84 char model_name[MODEL_NAME_MAX_LEN] = ROOTDEV_MODELNAME; 85 86 /* model description for root devices in XML description */ 87 char model_description[MODEL_DESCRIPTION_MAX_LEN] = ROOTDEV_MODELDESCRIPTION; 88 89 /* model url for root devices in XML description */ 90 char model_url[MODEL_URL_MAX_LEN] = ROOTDEV_MODELURL; 91 #endif 92 93 /* UPnP permission rules : */ 94 struct upnpperm * upnppermlist = 0; 95 unsigned int num_upnpperm = 0; 96 97 #ifdef PCP_SADSCP 98 struct dscp_values* dscp_values_list = 0; 99 unsigned int num_dscp_values = 0; 100 #endif /*PCP_SADSCP*/ 101 102 /* For automatic removal of expired rules (with LeaseDuration) */ 103 unsigned int nextruletoclean_timestamp = 0; 104 105 #ifdef USE_PF 106 /* "rdr-anchor miniupnpd" or/and "anchor miniupnpd" in pf.conf */ 107 const char * anchor_name = "miniupnpd"; 108 const char * queue = 0; 109 const char * tag = 0; 110 #endif 111 112 #ifdef USE_IPTABLES 113 /* chain names to use in the nat and filter tables. */ 114 115 /* iptables -t nat -N MINIUPNPD 116 * iptables -t nat -A PREROUTING -i <ext_if_name> -j MINIUPNPD */ 117 const char * miniupnpd_nat_chain = "MINIUPNPD"; 118 119 /* iptables -t nat -N MINIUPNPD-POSTROUTING 120 * iptables -t nat -A POSTROUTING -o <ext_if_name> -j MINIUPNPD-POSTROUTING */ 121 const char * miniupnpd_nat_postrouting_chain = "MINIUPNPD-POSTROUTING"; 122 123 /* iptables -t filter -N MINIUPNPD 124 * iptables -t filter -A FORWARD -i <ext_if_name> ! -o <ext_if_name> -j MINIUPNPD */ 125 const char * miniupnpd_forward_chain = "MINIUPNPD"; 126 127 #ifdef ENABLE_UPNPPINHOLE 128 /* ip6tables -t filter -N MINIUPNPD 129 * ip6tables -t filter -A FORWARD -i <ext_if_name> ! -o <ext_if_name> -j MINIUPNPD */ 130 const char * miniupnpd_v6_filter_chain = "MINIUPNPD"; 131 #endif /* ENABLE_UPNPPINHOLE */ 132 133 #endif /* USE_NETFILTER */ 134 135 #ifdef ENABLE_NFQUEUE 136 int nfqueue = -1; 137 int n_nfqix = 0; 138 unsigned nfqix[MAX_LAN_ADDR]; 139 #endif /* ENABLE_NFQUEUE */ 140 141 struct lan_addr_list lan_addrs; 142 143 #ifdef ENABLE_IPV6 144 /* ipv6 address used for HTTP */ 145 char ipv6_addr_for_http_with_brackets[64]; 146 147 /* address used to bind local services */ 148 struct in6_addr ipv6_bind_addr; 149 #endif 150 151 /* Path of the Unix socket used to communicate with MiniSSDPd */ 152 const char * minissdpdsocketpath = "/var/run/minissdpd.sock"; 153 154 /* BOOTID.UPNP.ORG and CONFIGID.UPNP.ORG */ 155 /* See UPnP Device Architecture v1.1 section 1.2 Advertisement : 156 * The field value of the BOOTID.UPNP.ORG header field MUST be increased 157 * each time a device (re)joins the network and sends an initial announce 158 * (a "reboot" in UPnP terms), or adds a UPnP-enabled interface. 159 * Unless the device explicitly announces a change in the BOOTID.UPNP.ORG 160 * field value using an SSDP message, as long as the device remains 161 * continuously available in the network, the same BOOTID.UPNP.ORG field 162 * value MUST be used in all repeat announcements, search responses, 163 * update messages and eventually bye-bye messages. */ 164 unsigned int upnp_bootid = 1; /* BOOTID.UPNP.ORG */ 165 /* The field value of the CONFIGID.UPNP.ORG header field identifies the 166 * current set of device and service descriptions; control points can 167 * parse this header field to detect whether they need to send new 168 * description query messages. */ 169 /* UPnP 1.1 devices MAY freely assign configid numbers from 0 to 170 * 16777215 (2^24-1). Higher numbers are reserved for future use, and 171 * can be assigned by the Technical Committee. The configuration of a 172 * root device consists of the following information: the DDD of the 173 * root device and all its embedded devices, and the SCPDs of all the 174 * contained services. If any part of the configuration changes, the 175 * CONFIGID.UPNP.ORG field value MUST be changed. 176 * DDD = Device Description Document 177 * SCPD = Service Control Protocol Description */ 178 unsigned int upnp_configid = 1337; /* CONFIGID.UPNP.ORG */ 179 180 #ifdef RANDOMIZE_URLS 181 char random_url[RANDOM_URL_MAX_LEN] = "random"; 182 #endif /* RANDOMIZE_URLS */ 183