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 https://miniupnp.tuxfamily.org/ 5 * (c) 2006-2020 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 ENABLE_NFQUEUE 113 int nfqueue = -1; 114 int n_nfqix = 0; 115 unsigned nfqix[MAX_LAN_ADDR]; 116 #endif /* ENABLE_NFQUEUE */ 117 118 struct lan_addr_list lan_addrs; 119 120 #ifdef ENABLE_IPV6 121 /* ipv6 address used for HTTP */ 122 char ipv6_addr_for_http_with_brackets[64]; 123 124 /* address used to bind local services */ 125 struct in6_addr ipv6_bind_addr; 126 #endif 127 128 /* Path of the Unix socket used to communicate with MiniSSDPd */ 129 const char * minissdpdsocketpath = "/var/run/minissdpd.sock"; 130 131 /* BOOTID.UPNP.ORG and CONFIGID.UPNP.ORG */ 132 /* See UPnP Device Architecture v1.1 section 1.2 Advertisement : 133 * The field value of the BOOTID.UPNP.ORG header field MUST be increased 134 * each time a device (re)joins the network and sends an initial announce 135 * (a "reboot" in UPnP terms), or adds a UPnP-enabled interface. 136 * Unless the device explicitly announces a change in the BOOTID.UPNP.ORG 137 * field value using an SSDP message, as long as the device remains 138 * continuously available in the network, the same BOOTID.UPNP.ORG field 139 * value MUST be used in all repeat announcements, search responses, 140 * update messages and eventually bye-bye messages. */ 141 unsigned int upnp_bootid = 1; /* BOOTID.UPNP.ORG */ 142 /* The field value of the CONFIGID.UPNP.ORG header field identifies the 143 * current set of device and service descriptions; control points can 144 * parse this header field to detect whether they need to send new 145 * description query messages. */ 146 /* UPnP 1.1 devices MAY freely assign configid numbers from 0 to 147 * 16777215 (2^24-1). Higher numbers are reserved for future use, and 148 * can be assigned by the Technical Committee. The configuration of a 149 * root device consists of the following information: the DDD of the 150 * root device and all its embedded devices, and the SCPDs of all the 151 * contained services. If any part of the configuration changes, the 152 * CONFIGID.UPNP.ORG field value MUST be changed. 153 * DDD = Device Description Document 154 * SCPD = Service Control Protocol Description */ 155 unsigned int upnp_configid = 1337; /* CONFIGID.UPNP.ORG */ 156 157 #ifdef RANDOMIZE_URLS 158 char random_url[RANDOM_URL_MAX_LEN] = "random"; 159 #endif /* RANDOMIZE_URLS */ 160