miniupnpd/miniupnpd.c: commenting #endif + minor cleaning
This commit is contained in:
parent
ec0707d559
commit
df85522c73
|
@ -49,7 +49,9 @@
|
|||
#include <sys/un.h>
|
||||
#endif
|
||||
|
||||
#ifdef TOMATO
|
||||
#include <sys/stat.h>
|
||||
#endif /* TOMATO */
|
||||
#include "macros.h"
|
||||
#include "upnpglobalvars.h"
|
||||
#include "upnphttp.h"
|
||||
|
@ -93,7 +95,7 @@ struct ctlelem {
|
|||
int socket;
|
||||
LIST_ENTRY(ctlelem) entries;
|
||||
};
|
||||
#endif
|
||||
#endif /* USE_MINIUPNPDCTL */
|
||||
|
||||
#ifdef ENABLE_NFQUEUE
|
||||
/* globals */
|
||||
|
@ -104,7 +106,7 @@ static struct sockaddr_in ssdp;
|
|||
static int nfqueue_cb( struct nfq_q_handle *qh, struct nfgenmsg *nfmsg, struct nfq_data *nfa, void *data) ;
|
||||
int identify_ip_protocol (char *payload);
|
||||
int get_udp_dst_port (char *payload);
|
||||
#endif
|
||||
#endif /* ENABLE_NFQUEUE */
|
||||
|
||||
/* variables used by signals */
|
||||
static volatile sig_atomic_t quitting = 0;
|
||||
|
@ -113,7 +115,7 @@ volatile sig_atomic_t should_send_public_address_change_notif = 0;
|
|||
#ifdef TOMATO
|
||||
#if 1
|
||||
/* Tomato specific code */
|
||||
static volatile int gotusr2 = 0;
|
||||
static volatile sig_atomic_t gotusr2 = 0;
|
||||
|
||||
static void
|
||||
sigusr2(int sig)
|
||||
|
@ -136,14 +138,14 @@ tomato_save(const char *fname)
|
|||
FILE *f;
|
||||
int t;
|
||||
char tmp[128];
|
||||
|
||||
|
||||
strcpy(tmp, "/etc/upnp/saveXXXXXX");
|
||||
if ((t = mkstemp(tmp)) != -1)
|
||||
if ((t = mkstemp(tmp)) != -1)
|
||||
{
|
||||
if ((f = fdopen(t, "w")) != NULL)
|
||||
if ((f = fdopen(t, "w")) != NULL)
|
||||
{
|
||||
n = 0;
|
||||
while (upnp_get_redirection_infos_by_index(n, &eport, proto, &iport, iaddr, sizeof(iaddr), desc, sizeof(desc), rhost, sizeof(rhost), &leaseduration) == 0)
|
||||
while (upnp_get_redirection_infos_by_index(n, &eport, proto, &iport, iaddr, sizeof(iaddr), desc, sizeof(desc), rhost, sizeof(rhost), &leaseduration) == 0)
|
||||
{
|
||||
timestamp = (leaseduration > 0) ? time(NULL) + leaseduration : 0;
|
||||
fprintf(f, "%s %u %s %u [%s] %u\n", proto, eport, iaddr, iport, desc, timestamp);
|
||||
|
@ -207,7 +209,7 @@ tomato_load(void)
|
|||
#if 0
|
||||
ScanNATPMPforExpiration();
|
||||
#endif
|
||||
#endif
|
||||
#endif /* ENABLE_NATPMP */
|
||||
unlink("/etc/upnp/load");
|
||||
}
|
||||
|
||||
|
@ -1167,7 +1169,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
|
|||
strncpy(model_url, ary_options[i].value, MODEL_URL_MAX_LEN);
|
||||
model_url[MODEL_URL_MAX_LEN-1] = '\0';
|
||||
break;
|
||||
#endif
|
||||
#endif /* ENABLE_MANUFACTURER_INFO_CONFIGURATION */
|
||||
#ifdef USE_NETFILTER
|
||||
case UPNPFORWARDCHAIN:
|
||||
miniupnpd_forward_chain = ary_options[i].value;
|
||||
|
@ -1175,7 +1177,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
|
|||
case UPNPNATCHAIN:
|
||||
miniupnpd_nat_chain = ary_options[i].value;
|
||||
break;
|
||||
#endif
|
||||
#endif /* USE_NETFILTER */
|
||||
case UPNPNOTIFY_INTERVAL:
|
||||
v->notify_interval = atoi(ary_options[i].value);
|
||||
break;
|
||||
|
@ -1188,7 +1190,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
|
|||
if(strcmp(ary_options[i].value, "yes") == 0)
|
||||
SETFLAG(LOGPACKETSMASK); /*logpackets = 1;*/
|
||||
break;
|
||||
#endif
|
||||
#endif /* defined(USE_PF) || defined(USE_IPF) */
|
||||
case UPNPUUID:
|
||||
strncpy(uuidvalue_igd+5, ary_options[i].value,
|
||||
strlen(uuidvalue_igd+5) + 1);
|
||||
|
@ -1218,7 +1220,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
|
|||
case UPNPTAG:
|
||||
tag = ary_options[i].value;
|
||||
break;
|
||||
#endif
|
||||
#endif /* USE_PF */
|
||||
#ifdef ENABLE_NATPMP
|
||||
case UPNPENABLENATPMP:
|
||||
if(strcmp(ary_options[i].value, "yes") == 0)
|
||||
|
@ -1228,7 +1230,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
|
|||
SETFLAG(ENABLENATPMPMASK);
|
||||
/*enablenatpmp = atoi(ary_options[i].value);*/
|
||||
break;
|
||||
#endif
|
||||
#endif /* ENABLE_NATPMP */
|
||||
#ifdef ENABLE_PCP
|
||||
case UPNPPCPMINLIFETIME:
|
||||
min_lifetime = atoi(ary_options[i].value);
|
||||
|
@ -1246,13 +1248,13 @@ init(int argc, char * * argv, struct runtime_vars * v)
|
|||
if(strcmp(ary_options[i].value, "yes") == 0)
|
||||
SETFLAG(PCP_ALLOWTHIRDPARTYMASK);
|
||||
break;
|
||||
#endif
|
||||
#endif /* ENABLE_PCP */
|
||||
#ifdef PF_ENABLE_FILTER_RULES
|
||||
case UPNPQUICKRULES:
|
||||
if(strcmp(ary_options[i].value, "no") == 0)
|
||||
SETFLAG(PFNOQUICKRULESMASK);
|
||||
break;
|
||||
#endif
|
||||
#endif /* PF_ENABLE_FILTER_RULES */
|
||||
case UPNPENABLE:
|
||||
if(strcmp(ary_options[i].value, "yes") != 0)
|
||||
CLEARFLAG(ENABLEUPNPMASK);
|
||||
|
@ -1265,7 +1267,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
|
|||
case UPNPLEASEFILE:
|
||||
lease_file = ary_options[i].value;
|
||||
break;
|
||||
#endif
|
||||
#endif /* ENABLE_LEASEFILE */
|
||||
case UPNPMINISSDPDSOCKET:
|
||||
minissdpdsocketpath = ary_options[i].value;
|
||||
break;
|
||||
|
@ -1281,7 +1283,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
|
|||
fprintf(stderr, "Check your configuration file.\n");
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
#endif /* ENABLE_PCP */
|
||||
}
|
||||
#endif /* DISABLE_CONFIG_FILE */
|
||||
|
||||
|
@ -1333,7 +1335,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
|
|||
fprintf(stderr, "Option -%c takes one argument.\n", argv[i][1]);
|
||||
friendly_name[FRIENDLY_NAME_MAX_LEN-1] = '\0';
|
||||
break;
|
||||
#endif
|
||||
#endif /* ENABLE_MANUFACTURER_INFO_CONFIGURATION */
|
||||
case 's':
|
||||
if(i+1 < argc)
|
||||
strncpy(serialnumber, argv[++i], SERIALNUMBER_MAX_LEN);
|
||||
|
@ -1353,7 +1355,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
|
|||
/*enablenatpmp = 1;*/
|
||||
SETFLAG(ENABLENATPMPMASK);
|
||||
break;
|
||||
#endif
|
||||
#endif /* ENABLE_NATPMP */
|
||||
case 'U':
|
||||
/*sysuptime = 1;*/
|
||||
SETFLAG(SYSUPTIMEMASK);
|
||||
|
@ -1366,7 +1368,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
|
|||
/*logpackets = 1;*/
|
||||
SETFLAG(LOGPACKETSMASK);
|
||||
break;
|
||||
#endif
|
||||
#endif /* defined(USE_PF) || defined(USE_IPF) */
|
||||
case 'S':
|
||||
SETFLAG(SECUREMODEMASK);
|
||||
break;
|
||||
|
@ -1389,7 +1391,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
|
|||
else
|
||||
fprintf(stderr, "Option -%c takes one argument.\n", argv[i][1]);
|
||||
break;
|
||||
#endif
|
||||
#endif /* USE_PF */
|
||||
case 'p':
|
||||
if(i+1 < argc)
|
||||
v->port = atoi(argv[++i]);
|
||||
|
@ -1403,7 +1405,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
|
|||
else
|
||||
fprintf(stderr, "Option -%c takes one argument.\n", argv[i][1]);
|
||||
break;
|
||||
#endif
|
||||
#endif /* ENABLE_HTTPS */
|
||||
#ifdef ENABLE_NFQUEUE
|
||||
case 'Q':
|
||||
if(i+1<argc)
|
||||
|
@ -1425,7 +1427,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
|
|||
fprintf(stderr, "Option -%c takes one argument.\n", argv[i][1]);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#endif /* ENABLE_NFQUEUE */
|
||||
case 'P':
|
||||
if(i+1 < argc)
|
||||
pidfilename = argv[++i];
|
||||
|
@ -1466,7 +1468,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
|
|||
fprintf(stderr, "can't parse \"%s\" as a valid "
|
||||
#ifndef ENABLE_IPV6
|
||||
"LAN address or "
|
||||
#endif
|
||||
#endif /* #ifndef ENABLE_IPV6 */
|
||||
"interface name\n", argv[i]);
|
||||
free(lan_addr);
|
||||
break;
|
||||
|
@ -1482,7 +1484,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
|
|||
}
|
||||
else
|
||||
fprintf(stderr, "Option -%c takes one argument.\n", argv[i][1]);
|
||||
#else
|
||||
#else /* #ifndef MULTIPLE_EXTERNAL_IP */
|
||||
if(i+2 < argc)
|
||||
{
|
||||
char *val=calloc((strlen(argv[i+1]) + strlen(argv[i+2]) + 1), sizeof(char));
|
||||
|
@ -1521,7 +1523,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
|
|||
}
|
||||
else
|
||||
fprintf(stderr, "Option -%c takes two arguments.\n", argv[i][1]);
|
||||
#endif
|
||||
#endif /* #ifndef MULTIPLE_EXTERNAL_IP */
|
||||
break;
|
||||
case 'A':
|
||||
if(i+1 < argc) {
|
||||
|
@ -1591,7 +1593,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
|
|||
|
||||
#ifdef TOMATO
|
||||
syslog(LOG_NOTICE, "version " MINIUPNPD_VERSION " started");
|
||||
#endif
|
||||
#endif /* TOMATO */
|
||||
|
||||
set_startup_time(GETFLAG(SYSUPTIMEMASK));
|
||||
|
||||
|
@ -1626,10 +1628,10 @@ init(int argc, char * * argv, struct runtime_vars * v)
|
|||
sa.sa_handler = sigusr2;
|
||||
sigaction(SIGUSR2, &sa, NULL);
|
||||
if(signal(SIGPIPE, SIG_IGN) == SIG_ERR)
|
||||
#else
|
||||
#else /* TOMATO */
|
||||
sa.sa_handler = SIG_IGN;
|
||||
if(sigaction(SIGPIPE, &sa, NULL) < 0)
|
||||
#endif
|
||||
#endif /* TOMATO */
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to ignore SIGPIPE signals");
|
||||
}
|
||||
|
@ -1665,7 +1667,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
|
|||
|
||||
#ifdef TOMATO
|
||||
tomato_load();
|
||||
#endif
|
||||
#endif /* TOMATO */
|
||||
|
||||
return 0;
|
||||
print_usage:
|
||||
|
@ -2265,7 +2267,7 @@ main(int argc, char * * argv)
|
|||
tomato_helper();
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
#endif /* TOMATO */
|
||||
if(errno == EINTR) continue; /* interrupted by a signal, start again */
|
||||
syslog(LOG_ERR, "select(all): %m");
|
||||
syslog(LOG_ERR, "Failed to select open sockets. EXITING");
|
||||
|
@ -2553,7 +2555,7 @@ shutdown:
|
|||
|
||||
#ifdef TOMATO
|
||||
tomato_save("/etc/upnp/data");
|
||||
#endif
|
||||
#endif /* TOMATO */
|
||||
/* close out open sockets */
|
||||
while(upnphttphead.lh_first != NULL)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue