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