diff --git a/miniupnpd/miniupnpd.c b/miniupnpd/miniupnpd.c index 6cf6d51..54d3903 100644 --- a/miniupnpd/miniupnpd.c +++ b/miniupnpd/miniupnpd.c @@ -49,7 +49,9 @@ #include #endif +#ifdef TOMATO #include +#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