diff --git a/miniupnpd/Changelog.txt b/miniupnpd/Changelog.txt index 201caef..c3072dd 100644 --- a/miniupnpd/Changelog.txt +++ b/miniupnpd/Changelog.txt @@ -1,4 +1,7 @@ -$Id: Changelog.txt,v 1.344 2013/06/06 21:39:58 nanard Exp $ +$Id: Changelog.txt,v 1.345 2013/06/13 13:21:28 nanard Exp $ + +2013/06/13: + Have 3 UUID for the 3 devices (IGD, WAN Device, WAN Connection Device) 2013/06/06: update upnpreplyparse to allow larger values (128 chars instead of 64) diff --git a/miniupnpd/minissdp.c b/miniupnpd/minissdp.c index f99372a..ad9952f 100644 --- a/miniupnpd/minissdp.c +++ b/miniupnpd/minissdp.c @@ -1,4 +1,4 @@ -/* $Id: minissdp.c,v 1.51 2013/06/11 18:02:18 nanard Exp $ */ +/* $Id: minissdp.c,v 1.52 2013/06/13 13:21:29 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * (c) 2006-2013 Thomas Bernard @@ -323,7 +323,7 @@ EXT: static void SendSSDPResponse(int s, const struct sockaddr * addr, const char * st, int st_len, const char * suffix, - const char * host, unsigned short port) + const char * host, unsigned short port, const char * uuidvalue) { int l, n; char buf[512]; @@ -412,27 +412,28 @@ SendSSDPResponse(int s, const struct sockaddr * addr, static struct { const char * s; const int version; + const char * uuid; } const known_service_types[] = { - {"upnp:rootdevice", 0}, - {"urn:schemas-upnp-org:device:InternetGatewayDevice:", IGD_VER}, - {"urn:schemas-upnp-org:device:WANConnectionDevice:", 1}, - {"urn:schemas-upnp-org:device:WANDevice:", 1}, - {"urn:schemas-upnp-org:service:WANCommonInterfaceConfig:", 1}, - {"urn:schemas-upnp-org:service:WANIPConnection:", WANIPC_VER}, + {"upnp:rootdevice", 0, uuidvalue_igd}, + {"urn:schemas-upnp-org:device:InternetGatewayDevice:", IGD_VER, uuidvalue_igd}, + {"urn:schemas-upnp-org:device:WANConnectionDevice:", 1, uuidvalue_wcd}, + {"urn:schemas-upnp-org:device:WANDevice:", 1, uuidvalue_wan}, + {"urn:schemas-upnp-org:service:WANCommonInterfaceConfig:", 1, uuidvalue_wan}, + {"urn:schemas-upnp-org:service:WANIPConnection:", WANIPC_VER, uuidvalue_wcd}, #ifndef UPNP_STRICT /* We use WAN IP Connection, not PPP connection, * but buggy control points may try to use WanPPPConnection * anyway */ - {"urn:schemas-upnp-org:service:WANPPPConnection:", 1}, + {"urn:schemas-upnp-org:service:WANPPPConnection:", 1, uuidvalue_wcd}, #endif #ifdef ENABLE_L3F_SERVICE - {"urn:schemas-upnp-org:service:Layer3Forwarding:", 1}, + {"urn:schemas-upnp-org:service:Layer3Forwarding:", 1, uuidvalue_igd}, #endif #ifdef ENABLE_6FC_SERVICE - {"url:schemas-upnp-org:service:WANIPv6FirewallControl:", 1}, + {"url:schemas-upnp-org:service:WANIPv6FirewallControl:", 1, uuidvalue_wcd}, #endif - {0, 0} + {0, 0, 0} }; static void @@ -533,12 +534,13 @@ SendSSDPNotifies(int s, const char * host, unsigned short port, snprintf(ver_str, sizeof(ver_str), "%d", known_service_types[i].version); SendSSDPNotify(s, (struct sockaddr *)&sockname, host, port, known_service_types[i].s, ver_str, /* NT: */ - uuidvalue, "::", known_service_types[i].s, /* ver_str, USN: */ + known_service_types[i].uuid, "::", + known_service_types[i].s, /* ver_str, USN: */ lifetime, ipv6); if(i==0) /* rootdevice */ SendSSDPNotify(s, (struct sockaddr *)&sockname, host, port, - uuidvalue, "", /* NT: */ - uuidvalue, "", "", /* ver_str, USN: */ + uuidvalue_igd, "", /* NT: */ + uuidvalue_igd, "", "", /* ver_str, USN: */ lifetime, ipv6); i++; } @@ -751,7 +753,8 @@ ProcessSSDPData(int s, const char *bufr, int n, syslog(LOG_INFO, "Single search found"); SendSSDPResponse(s, sender, st, st_len, "", - announced_host, port); + announced_host, port, + known_service_types[i].uuid); break; } } @@ -769,19 +772,39 @@ ProcessSSDPData(int s, const char *bufr, int n, l = (int)strlen(known_service_types[i].s); SendSSDPResponse(s, sender, known_service_types[i].s, l, ver_str, - announced_host, port); + announced_host, port, + known_service_types[i].uuid); } /* also answer for uuid */ - SendSSDPResponse(s, sender, uuidvalue, strlen(uuidvalue), "", - announced_host, port); + SendSSDPResponse(s, sender, uuidvalue_igd, strlen(uuidvalue_igd), "", + announced_host, port, uuidvalue_igd); + SendSSDPResponse(s, sender, uuidvalue_wan, strlen(uuidvalue_wan), "", + announced_host, port, uuidvalue_wan); + SendSSDPResponse(s, sender, uuidvalue_wcd, strlen(uuidvalue_wcd), "", + announced_host, port, uuidvalue_wcd); } /* responds to request by UUID value */ - l = (int)strlen(uuidvalue); - if(l==st_len && (0 == memcmp(st, uuidvalue, l))) + l = (int)strlen(uuidvalue_igd); + if(l==st_len) { - syslog(LOG_INFO, "ssdp:uuid found"); - SendSSDPResponse(s, sender, st, st_len, "", - announced_host, port); + if(0 == memcmp(st, uuidvalue_igd, l)) + { + syslog(LOG_INFO, "ssdp:uuid (IGD) found"); + SendSSDPResponse(s, sender, st, st_len, "", + announced_host, port, uuidvalue_igd); + } + else if(0 == memcmp(st, uuidvalue_wan, l)) + { + syslog(LOG_INFO, "ssdp:uuid (WAN) found"); + SendSSDPResponse(s, sender, st, st_len, "", + announced_host, port, uuidvalue_wan); + } + else if(0 == memcmp(st, uuidvalue_wcd, l)) + { + syslog(LOG_INFO, "ssdp:uuid (WCD) found"); + SendSSDPResponse(s, sender, st, st_len, "", + announced_host, port, uuidvalue_wcd); + } } } else @@ -893,7 +916,8 @@ SendSSDPGoodbye(int * sockets, int n_sockets) (struct sockaddr *)&sockname, #endif known_service_types[i].s, ver_str, /* NT: */ - uuidvalue, "::", known_service_types[i].s, /* ver_str, USN: */ + known_service_types[i].uuid, "::", + known_service_types[i].s, /* ver_str, USN: */ ipv6); if(i==0) /* root device */ { @@ -903,8 +927,8 @@ SendSSDPGoodbye(int * sockets, int n_sockets) #else (struct sockaddr *)&sockname, #endif - uuidvalue, "", /* NT: */ - uuidvalue, "", "", /* ver_str, USN: */ + uuidvalue_igd, "", /* NT: */ + uuidvalue_igd, "", "", /* ver_str, USN: */ ipv6); } } @@ -954,7 +978,7 @@ SubmitServicesToMiniSSDPD(const char * host, unsigned short port) { else snprintf(ver_str, sizeof(ver_str), "%d", known_service_types[i].version); l = snprintf(strbuf, sizeof(strbuf), "%s::%s%s", - uuidvalue, known_service_types[i].s, ver_str); + known_service_types[i].uuid, known_service_types[i].s, ver_str); if(l<0) { syslog(LOG_WARNING, "SubmitServicesToMiniSSDPD: snprintf %m"); continue; diff --git a/miniupnpd/miniupnpd.c b/miniupnpd/miniupnpd.c index 1dd3ff3..c1fe908 100644 --- a/miniupnpd/miniupnpd.c +++ b/miniupnpd/miniupnpd.c @@ -1,4 +1,4 @@ -/* $Id: miniupnpd.c,v 1.175 2013/04/29 09:34:14 nanard Exp $ */ +/* $Id: miniupnpd.c,v 1.176 2013/06/13 13:21:29 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * (c) 2006-2013 Thomas Bernard @@ -643,6 +643,35 @@ parselan_error: return -1; } +/* fill uuidvalue_wan and uuidvalue_wcd based on uuidvalue_igd */ +void complete_uuidvalues(void) +{ + size_t len; + len = strlen(uuidvalue_igd); + memcpy(uuidvalue_wan, uuidvalue_igd, len+1); + switch(uuidvalue_wan[len-1]) { + case '9': + uuidvalue_wan[len-1] = 'a'; + break; + case 'f': + uuidvalue_wan[len-1] = '0'; + break; + default: + uuidvalue_wan[len-1]++; + } + memcpy(uuidvalue_wcd, uuidvalue_wan, len+1); + switch(uuidvalue_wcd[len-1]) { + case '9': + uuidvalue_wcd[len-1] = 'a'; + break; + case 'f': + uuidvalue_wcd[len-1] = '0'; + break; + default: + uuidvalue_wcd[len-1]++; + } +} + /* init phase : * 1) read configuration file * 2) read command line arguments @@ -770,8 +799,9 @@ init(int argc, char * * argv, struct runtime_vars * v) break; #endif case UPNPUUID: - strncpy(uuidvalue+5, ary_options[i].value, - strlen(uuidvalue+5) + 1); + strncpy(uuidvalue_igd+5, ary_options[i].value, + strlen(uuidvalue_igd+5) + 1); + complete_uuidvalues(); break; case UPNPSERIAL: strncpy(serialnumber, ary_options[i].value, SERIALNUMBER_MAX_LEN); @@ -866,9 +896,10 @@ init(int argc, char * * argv, struct runtime_vars * v) fprintf(stderr, "Option -%c takes one argument.\n", argv[i][1]); break; case 'u': - if(i+1 < argc) - strncpy(uuidvalue+5, argv[++i], strlen(uuidvalue+5) + 1); - else + if(i+1 < argc) { + strncpy(uuidvalue_igd+5, argv[++i], strlen(uuidvalue_igd+5) + 1); + complete_uuidvalues(); + } else fprintf(stderr, "Option -%c takes one argument.\n", argv[i][1]); break; case 'z': diff --git a/miniupnpd/testupnpdescgen.c b/miniupnpd/testupnpdescgen.c index ab068da..cb5aa23 100644 --- a/miniupnpd/testupnpdescgen.c +++ b/miniupnpd/testupnpdescgen.c @@ -1,7 +1,7 @@ -/* $Id: testupnpdescgen.c,v 1.29 2012/04/30 21:08:00 nanard Exp $ */ +/* $Id: testupnpdescgen.c,v 1.30 2013/06/13 13:21:30 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2006-2012 Thomas Bernard + * (c) 2006-2013 Thomas Bernard * This software is subject to the conditions detailed * in the LICENCE file provided within the distribution */ @@ -17,7 +17,9 @@ #include "config.h" #include "upnpdescgen.h" -char uuidvalue[] = "uuid:12345678-0000-0000-0000-00000000abcd"; +char uuidvalue_igd[] = "uuid:12345678-0000-0000-0000-000000abcd01"; +char uuidvalue_wan[] = "uuid:12345678-0000-0000-0000-000000abcd02"; +char uuidvalue_wcd[] = "uuid:12345678-0000-0000-0000-000000abcd03"; char serialnumber[] = "12345678"; char modelnumber[] = "1"; char presentationurl[] = "http://192.168.0.1:8080/"; diff --git a/miniupnpd/upnpdescgen.c b/miniupnpd/upnpdescgen.c index 83445da..a7fe907 100644 --- a/miniupnpd/upnpdescgen.c +++ b/miniupnpd/upnpdescgen.c @@ -1,4 +1,4 @@ -/* $Id: upnpdescgen.c,v 1.73 2013/05/29 21:27:22 nanard Exp $ */ +/* $Id: upnpdescgen.c,v 1.74 2013/06/13 13:21:30 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * (c) 2006-2013 Thomas Bernard @@ -154,7 +154,7 @@ static const struct XMLElt rootDesc[] = {"/modelNumber", modelnumber}, {"/modelURL", ROOTDEV_MODELURL}, {"/serialNumber", serialnumber}, - {"/UDN", uuidvalue}, /* required */ + {"/UDN", uuidvalue_igd}, /* required */ /* see if /UPC is needed. */ #ifdef ENABLE_6FC_SERVICE #define SERVICES_OFFSET 63 @@ -201,7 +201,7 @@ static const struct XMLElt rootDesc[] = {"/modelNumber", WANDEV_MODELNUMBER}, {"/modelURL", WANDEV_MODELURL}, {"/serialNumber", serialnumber}, - {"/UDN", uuidvalue}, + {"/UDN", uuidvalue_wan}, {"/UPC", WANDEV_UPC}, /* UPC (=12 digit barcode) is optional */ /* 30 */ {"serviceList", INITHELPER(32,1)}, @@ -229,7 +229,7 @@ static const struct XMLElt rootDesc[] = {"/modelNumber", WANCDEV_MODELNUMBER}, {"/modelURL", WANCDEV_MODELURL}, {"/serialNumber", serialnumber}, - {"/UDN", uuidvalue}, + {"/UDN", uuidvalue_wcd}, {"/UPC", WANCDEV_UPC}, /* UPC (=12 digit Barcode) is optional */ #ifdef ENABLE_6FC_SERVICE {"serviceList", INITHELPER(51,2)}, @@ -1205,7 +1205,7 @@ genEventVars(int * len, const struct serviceDesc * s) break; case DEFAULTCONNECTIONSERVICE_MAGICALVALUE: /* DefaultConnectionService magical value */ - str = strcat_str(str, len, &tmplen, uuidvalue); + str = strcat_str(str, len, &tmplen, uuidvalue_wcd); #ifdef IGD_V2 str = strcat_str(str, len, &tmplen, ":WANConnectionDevice:2,urn:upnp-org:serviceId:WANIPConn1"); #else diff --git a/miniupnpd/upnpevents.c b/miniupnpd/upnpevents.c index 0027d99..660ccc0 100644 --- a/miniupnpd/upnpevents.c +++ b/miniupnpd/upnpevents.c @@ -1,7 +1,7 @@ -/* $Id: upnpevents.c,v 1.26 2012/10/04 22:11:56 nanard Exp $ */ +/* $Id: upnpevents.c,v 1.27 2013/06/13 13:21:30 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2008-2012 Thomas Bernard + * (c) 2008-2013 Thomas Bernard * This software is subject to the conditions detailed * in the LICENCE file provided within the distribution */ @@ -110,7 +110,7 @@ newSubscriber(const char * eventurl, const char * callback, int callbacklen) tmp->callback[callbacklen] = '\0'; /* make a dummy uuid */ /* TODO: improve that */ - strncpy(tmp->uuid, uuidvalue, sizeof(tmp->uuid)); + strncpy(tmp->uuid, uuidvalue_igd, sizeof(tmp->uuid)); tmp->uuid[sizeof(tmp->uuid)-1] = '\0'; snprintf(tmp->uuid+37, 5, "%04lx", random() & 0xffff); return tmp; diff --git a/miniupnpd/upnpglobalvars.c b/miniupnpd/upnpglobalvars.c index 18efbee..b339183 100644 --- a/miniupnpd/upnpglobalvars.c +++ b/miniupnpd/upnpglobalvars.c @@ -1,4 +1,4 @@ -/* $Id: upnpglobalvars.c,v 1.29 2012/04/26 14:01:16 nanard Exp $ */ +/* $Id: upnpglobalvars.c,v 1.30 2013/06/13 13:21:30 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * (c) 2006-2012 Thomas Bernard @@ -36,7 +36,9 @@ int runtime_flags = 0; const char * pidfilename = "/var/run/miniupnpd.pid"; -char uuidvalue[] = "uuid:00000000-0000-0000-0000-000000000000"; +char uuidvalue_igd[] = "uuid:00000000-0000-0000-0000-000000000000"; +char uuidvalue_wan[] = "uuid:00000000-0000-0000-0000-000000000000"; +char uuidvalue_wcd[] = "uuid:00000000-0000-0000-0000-000000000000"; char serialnumber[SERIALNUMBER_MAX_LEN] = "00000000"; char modelnumber[MODELNUMBER_MAX_LEN] = "1"; diff --git a/miniupnpd/upnpglobalvars.h b/miniupnpd/upnpglobalvars.h index 686e6af..ad9b4e0 100644 --- a/miniupnpd/upnpglobalvars.h +++ b/miniupnpd/upnpglobalvars.h @@ -1,4 +1,4 @@ -/* $Id: upnpglobalvars.h,v 1.33 2012/04/26 14:01:16 nanard Exp $ */ +/* $Id: upnpglobalvars.h,v 1.35 2013/06/13 13:21:30 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * (c) 2006-2012 Thomas Bernard @@ -54,7 +54,9 @@ extern int runtime_flags; extern const char * pidfilename; -extern char uuidvalue[]; +extern char uuidvalue_igd[]; /* uuid of root device (IGD) */ +extern char uuidvalue_wan[]; /* uuid of WAN Device */ +extern char uuidvalue_wcd[]; /* uuid of WAN Connection Device */ #define SERIALNUMBER_MAX_LEN (10) extern char serialnumber[]; diff --git a/miniupnpd/upnpsoap.c b/miniupnpd/upnpsoap.c index cb7d8f6..b954a35 100644 --- a/miniupnpd/upnpsoap.c +++ b/miniupnpd/upnpsoap.c @@ -1,4 +1,4 @@ -/* $Id: upnpsoap.c,v 1.117 2013/06/05 09:10:47 nanard Exp $ */ +/* $Id: upnpsoap.c,v 1.118 2013/06/13 13:21:30 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * (c) 2006-2013 Thomas Bernard @@ -1040,7 +1040,7 @@ SetDefaultConnectionService(struct upnphttp * h, const char * action) #ifdef UPNP_STRICT char * service; service = strchr(p, ','); - if(0 != memcmp(uuidvalue, p, sizeof("uuid:00000000-0000-0000-0000-000000000000") - 1)) { + if(0 != memcmp(uuidvalue_wcd, p, sizeof("uuid:00000000-0000-0000-0000-000000000000") - 1)) { SoapError(h, 720, "InvalidDeviceUUID"); } else if(service == NULL || 0 != strcmp(service+1, SERVICE_ID_WANIPC)) { SoapError(h, 721, "InvalidServiceID"); @@ -1073,7 +1073,7 @@ GetDefaultConnectionService(struct upnphttp * h, const char * action) int bodylen; bodylen = snprintf(body, sizeof(body), resp, - action, uuidvalue, action); + action, uuidvalue_wcd, action); BuildSendAndCloseSoapResp(h, body, bodylen); } #endif