diff --git a/miniupnpd/linux/ifacewatcher.c b/miniupnpd/linux/ifacewatcher.c index 1a80633..7095a0f 100644 --- a/miniupnpd/linux/ifacewatcher.c +++ b/miniupnpd/linux/ifacewatcher.c @@ -1,7 +1,7 @@ -/* $Id: ifacewatcher.c,v 1.7 2012/05/27 22:16:10 nanard Exp $ */ +/* $Id: ifacewatcher.c,v 1.9 2018/02/03 22:05:42 nanard Exp $ */ /* MiniUPnP project - * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2006-2015 Thomas Bernard + * http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/ + * (c) 2006-2018 Thomas Bernard * * ifacewatcher.c * diff --git a/miniupnpd/miniupnpd.c b/miniupnpd/miniupnpd.c index e6a73d4..b291a31 100644 --- a/miniupnpd/miniupnpd.c +++ b/miniupnpd/miniupnpd.c @@ -2,7 +2,7 @@ /* vim: tabstop=4 shiftwidth=4 noexpandtab * MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2006-2017 Thomas Bernard + * (c) 2006-2018 Thomas Bernard * This software is subject to the conditions detailed * in the LICENCE file provided within the distribution */ @@ -1296,13 +1296,11 @@ init(int argc, char * * argv, struct runtime_vars * v) break; #ifdef IGD_V2 case UPNPFORCEIGDDESCV1: - if (strcmp(ary_options[i].value, "yes")!=0 && - strcmp(ary_options[i].value, "no")!=0 ) { + if (strcmp(ary_options[i].value, "yes") == 0) + SETFLAG(FORCEIGDDESCV1MASK); + else if (strcmp(ary_options[i].value, "no") != 0 ) { fprintf(stderr, "force_igd_desc_v1 can only be yes or no\n"); } - /* ary_options is processed by genRootDesc() to find - this because there is apperently no way to pass - options to the http server */ break; #endif default: diff --git a/miniupnpd/testupnpdescgen.c b/miniupnpd/testupnpdescgen.c index 1ae4bb9..5b88c2a 100644 --- a/miniupnpd/testupnpdescgen.c +++ b/miniupnpd/testupnpdescgen.c @@ -1,7 +1,7 @@ /* $Id: testupnpdescgen.c,v 1.34 2017/05/27 07:47:57 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2006-2017 Thomas Bernard + * (c) 2006-2018 Thomas Bernard * This software is subject to the conditions detailed * in the LICENCE file provided within the distribution */ @@ -15,6 +15,7 @@ #include "macros.h" #include "config.h" +#include "upnpglobalvars.h" #include "upnpdescgen.h" #include "upnpdescstrings.h" #include "getifaddr.h" @@ -39,16 +40,11 @@ char random_url[] = "RANDOM"; #endif /* RANDOMIZE_URLS */ unsigned int upnp_configid = 666; -char * use_ext_ip_addr = NULL; +const char * use_ext_ip_addr = NULL; const char * ext_if_name = "eth0"; int runtime_flags = 0; -#ifdef IGD_V2 -struct option * ary_options = NULL; -unsigned int num_options = 0; -#endif - int getifaddr(const char * ifname, char * buf, int len, struct in_addr * addr, struct in_addr * mask) { UNUSED(ifname); @@ -144,8 +140,25 @@ main(int argc, char * * argv) char * s; int l; FILE * f; - UNUSED(argc); - UNUSED(argv); + + for(l = 1; l < argc; l++) { + if(0 == strcmp(argv[l], "--help") || 0 == strcmp(argv[l], "-h")) { + printf("Usage:\t%s [options]\n", argv[0]); + printf("options:\n"); +#ifdef IGD_V2 + printf("\t--forceigdv1 Force versions of devices to be 1\n"); +#else + printf("\tNone\n"); +#endif + return 0; +#ifdef IGD_V2 + } else if(0 == strcmp(argv[l], "--forceigdv1")) { + SETFLAG(FORCEIGDDESCV1MASK); +#endif + } else { + fprintf(stderr, "unknown option %s\n", argv[l]); + } + } if(mkdir("testdescs", 0777) < 0) { if(errno != EEXIST) { diff --git a/miniupnpd/upnpdescgen.c b/miniupnpd/upnpdescgen.c index f74b05e..88e00c1 100644 --- a/miniupnpd/upnpdescgen.c +++ b/miniupnpd/upnpdescgen.c @@ -2,7 +2,7 @@ /* vim: tabstop=4 shiftwidth=4 noexpandtab * MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2006-2017 Thomas Bernard + * (c) 2006-2018 Thomas Bernard * This software is subject to the conditions detailed * in the LICENCE file provided within the distribution */ @@ -17,7 +17,6 @@ #endif #include "upnpdescgen.h" #include "miniupnpdpath.h" -#include "options.h" #include "upnpglobalvars.h" #include "upnpdescstrings.h" #include "upnpurns.h" @@ -879,31 +878,6 @@ strcat_int(char * str, int * len, int * tmplen, int i) return str; } -#ifdef IGD_V2 -int force_igd_desc_v1(void) -{ - /* keep a cache so we only do it once */ - static int force=-1; - int i; - - if (force!=-1) return force; - - force=0; - - for(i=0; i0) str[pos] = '1'; + str[*len - 1] = '1'; /* Change the version number to 1 */ } } #endif diff --git a/miniupnpd/upnpglobalvars.h b/miniupnpd/upnpglobalvars.h index 5e68932..80f7a02 100644 --- a/miniupnpd/upnpglobalvars.h +++ b/miniupnpd/upnpglobalvars.h @@ -65,6 +65,9 @@ extern int runtime_flags; #ifdef ENABLE_PCP #define PCP_ALLOWTHIRDPARTYMASK 0x0400 #endif +#ifdef IGD_V2 +#define FORCEIGDDESCV1MASK 0x0800 +#endif #define SETFLAG(mask) runtime_flags |= mask #define GETFLAG(mask) (runtime_flags & mask)