From 39a1d85f7a3f7a0f2ebf213619c8343985c1d387 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Thu, 7 Feb 2013 10:59:31 +0100 Subject: [PATCH] minissdp.c: Fix SSDP packets sent with uuid as ST: header to conform to UDA --- miniupnpd/Changelog.txt | 1 + miniupnpd/minissdp.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/miniupnpd/Changelog.txt b/miniupnpd/Changelog.txt index e76ab3f..e2bf08d 100644 --- a/miniupnpd/Changelog.txt +++ b/miniupnpd/Changelog.txt @@ -2,6 +2,7 @@ $Id: Changelog.txt,v 1.328 2013/02/06 23:37:27 nanard Exp $ 2013/02/07: Add DATE: header in SSDP packets + Fix SSDP packets sent with uuid as ST: header to conform to UDA VERSION 1.8 : released on 2013/02/06 diff --git a/miniupnpd/minissdp.c b/miniupnpd/minissdp.c index 3b0007c..58ea9e9 100644 --- a/miniupnpd/minissdp.c +++ b/miniupnpd/minissdp.c @@ -324,6 +324,7 @@ SendSSDPAnnounce2(int s, const struct sockaddr * addr, char buf[512]; char addr_str[64]; socklen_t addrlen; + int st_is_uuid; #ifdef ENABLE_HTTP_DATE char http_date[64]; time_t t; @@ -335,6 +336,8 @@ SendSSDPAnnounce2(int s, const struct sockaddr * addr, "%a, %d %b %Y %H:%M:%S GMT", &tm); #endif + st_is_uuid = (st_len == (int)strlen(uuidvalue)) && + (memcmp(uuidvalue, st, st_len) == 0); /* * follow guideline from document "UPnP Device Architecture 1.0" * uppercase is recommended. @@ -349,7 +352,7 @@ SendSSDPAnnounce2(int s, const struct sockaddr * addr, "DATE: %s\r\n" #endif "ST: %.*s%s\r\n" - "USN: %s::%.*s%s\r\n" + "USN: %s%s%.*s%s\r\n" "EXT:\r\n" "SERVER: " MINIUPNPD_SERVER_STRING "\r\n" "LOCATION: http://%s:%u" ROOTDESC_PATH "\r\n" @@ -362,7 +365,8 @@ SendSSDPAnnounce2(int s, const struct sockaddr * addr, http_date, #endif st_len, st, suffix, - uuidvalue, st_len, st, suffix, + uuidvalue, st_is_uuid ? "" : "::", + st_is_uuid ? 0 : st_len, st, suffix, host, (unsigned int)port, upnp_bootid, upnp_bootid, upnp_configid); addrlen = (addr->sa_family == AF_INET6)