diff --git a/ChangeLog b/ChangeLog index 467d7ff..26da6e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -318,6 +318,15 @@ Version 1.8.0 Version 1.6.16 ******************************************************************************* +2012-03-15 Fabrice Fontaine + + Add --disable-optssdp option + + Modify configure.ac to add --disable-optssdp option. This option will + remove OPT, 01-NLS and X_USER_AGENT headers from SSDP messages as those + headers are optional. If --disable-gena and disable-optssdp are both + used, uuid part will not be compiled anymore. + 2012-03-15 Fabrice Fontaine Bug fix in ixmlNode_allowChildren diff --git a/build/inc/autoconfig.h b/build/inc/autoconfig.h index 2a8437c..a4e3216 100644 --- a/build/inc/autoconfig.h +++ b/build/inc/autoconfig.h @@ -153,6 +153,9 @@ /* see upnpconfig.h */ #define UPNP_HAVE_SSDP 1 +/* see upnpconfig.h */ +#define UPNP_HAVE_OPTSSDP 1 + /* see upnpconfig.h */ #define UPNP_HAVE_TOOLS 1 diff --git a/build/inc/upnpconfig.h b/build/inc/upnpconfig.h index 8eba8bd..21c56f7 100644 --- a/build/inc/upnpconfig.h +++ b/build/inc/upnpconfig.h @@ -105,6 +105,11 @@ #define UPNP_HAVE_SSDP 1 +/** Defined to 1 if the library has been compiled with optional SSDP headers + * support (i.e. configure --enable-optssdp) */ +#define UPNP_HAVE_OPTSSDP 1 + + /** Defined to 1 if the library has been compiled with the SOAP part enabled * (i.e. configure --enable-soap) */ #define UPNP_HAVE_SOAP 1 diff --git a/configure.ac b/configure.ac index bd125a9..fe93927 100644 --- a/configure.ac +++ b/configure.ac @@ -403,6 +403,12 @@ if test "x$enable_ssdp" = xyes ; then AC_DEFINE(UPNP_HAVE_SSDP, 1, [see upnpconfig.h]) fi +RT_BOOL_ARG_ENABLE([optssdp], [yes], [optionnal SSDP headers support)]) +if test "x$enable_optssdp" = xyes ; then + AC_DEFINE(UPNP_HAVE_OPTSSDP, 1, [see upnpconfig.h]) + enable_uuid=yes +fi + RT_BOOL_ARG_ENABLE([soap], [yes], [SOAP part]) if test "x$enable_soap" = xyes ; then AC_DEFINE(UPNP_HAVE_SOAP, 1, [see upnpconfig.h]) @@ -411,8 +417,11 @@ fi RT_BOOL_ARG_ENABLE([gena], [yes], [GENA part]) if test "x$enable_gena" = xyes ; then AC_DEFINE(UPNP_HAVE_GENA, 1, [see upnpconfig.h]) + enable_uuid=yes fi +AM_CONDITIONAL(ENABLE_UUID, test x"$enable_uuid" = xyes) + RT_BOOL_ARG_ENABLE([tools], [yes], [helper APIs in upnptools.h]) if test "x$enable_tools" = xyes ; then AC_DEFINE(UPNP_HAVE_TOOLS, 1, [see upnpconfig.h]) diff --git a/upnp/Makefile.am b/upnp/Makefile.am index 81f5948..96080fd 100644 --- a/upnp/Makefile.am +++ b/upnp/Makefile.am @@ -162,10 +162,12 @@ endif # uuid +if ENABLE_UUID libupnp_la_SOURCES += \ src/uuid/md5.c \ src/uuid/sysdep.c \ src/uuid/uuid.c +endif # urlconfig diff --git a/upnp/inc/upnpconfig.h.in b/upnp/inc/upnpconfig.h.in index e040c8f..d19ee87 100644 --- a/upnp/inc/upnpconfig.h.in +++ b/upnp/inc/upnpconfig.h.in @@ -104,6 +104,11 @@ #undef UPNP_HAVE_SSDP +/** Defined to 1 if the library has been compiled with optional SSDP headers + * support (i.e. configure --enable-optssdp) */ +#undef UPNP_HAVE_OPTSSDP + + /** Defined to 1 if the library has been compiled with the SOAP part enabled * (i.e. configure --enable-soap) */ #undef UPNP_HAVE_SOAP diff --git a/upnp/src/api/upnpapi.c b/upnp/src/api/upnpapi.c index 0c0d0c3..68e6c96 100644 --- a/upnp/src/api/upnpapi.c +++ b/upnp/src/api/upnpapi.c @@ -179,8 +179,10 @@ int UpnpSdkDeviceRegisteredV4 = 0; * == 0 if unregistered, == 1 if registered. */ int UpnpSdkDeviceregisteredV6 = 0; +#ifdef HAVE_UPNP_OPTSSDP /*! Global variable used in discovery notifications. */ Upnp_SID gUpnpSdkNLSuuid; +#endif /* HAVE_UPNP_OPTSSDP */ /*! Global variable used as to store the OpenSSL context object * to be used for all SSL/TLS connections @@ -320,7 +322,9 @@ static int UpnpInitPreamble(void) { int retVal = UPNP_E_SUCCESS; int i; +#ifdef UPNP_HAVE_OPTSSDP uuid_upnp nls_uuid; +#endif /* UPNP_HAVE_OPTSSDP */ retVal = WinsockInit(); if (retVal != UPNP_E_SUCCESS) { @@ -345,9 +349,11 @@ static int UpnpInitPreamble(void) return retVal; } +#ifdef UPNP_HAVE_OPTSSDP /* Create the NLS uuid. */ uuid_create(&nls_uuid); uuid_unpack(&nls_uuid, gUpnpSdkNLSuuid); +#endif /* UPNP_HAVE_OPTSSDP */ /* Initializes the handle list. */ HandleLock(); diff --git a/upnp/src/ssdp/ssdp_device.c b/upnp/src/ssdp/ssdp_device.c index 3274328..9560af3 100644 --- a/upnp/src/ssdp/ssdp_device.c +++ b/upnp/src/ssdp/ssdp_device.c @@ -343,6 +343,7 @@ static void CreateServicePacket( *packet = NULL; if (msg_type == MSGTYPE_REPLY) { if (PowerState > 0) { +#ifdef UPNP_HAVE_OPTSSDP ret_code = http_MakeMessage(&buf, 1, 1, "R" "sdc" "D" "sc" "ssc" "ssc" "ssc" "S" "Xc" "ssc" "ssc" @@ -357,7 +358,21 @@ static void CreateServicePacket( "SleepPeriod: ", SleepPeriod, "RegistrationState: ", RegistrationState); +#else + ret_code = http_MakeMessage(&buf, 1, 1, + "R" "sdc" "D" "sc" "ssc" + "S" "ssc" "ssc" + "sdc" "sdc" "sdcc", HTTP_OK, + "CACHE-CONTROL: max-age=", duration, + "EXT:", "LOCATION: ", location, + "ST: ", nt, "USN: ", + usn, "Powerstate: ", PowerState, + "SleepPeriod: ", SleepPeriod, + "RegistrationState: ", + RegistrationState); +#endif /* UPNP_HAVE_OPTSSDP */ } else { +#ifdef UPNP_HAVE_OPTSSDP ret_code = http_MakeMessage(&buf, 1, 1, "R" "sdc" "D" "sc" "ssc" "ssc" "ssc" "S" "Xc" "ssc" "sscc", HTTP_OK, @@ -368,6 +383,14 @@ static void CreateServicePacket( "01-NLS: ", gUpnpSdkNLSuuid, X_USER_AGENT, "ST: ", nt, "USN: ", usn); +#else + ret_code = http_MakeMessage(&buf, 1, 1, + "R" "sdc" "D" "sc" "ssc" + "S" "ssc" "sscc", HTTP_OK, + "CACHE-CONTROL: max-age=", duration, + "EXT:", "LOCATION: ", location, + "ST: ", nt, "USN: ", usn); +#endif /* UPNP_HAVE_OPTSSDP */ } if (ret_code != 0) { return; @@ -394,6 +417,7 @@ static void CreateServicePacket( host = "[" SSDP_IPV6_LINKLOCAL "]"; } if (PowerState > 0) { +#ifdef UPNP_HAVE_OPTSSDP ret_code = http_MakeMessage(&buf, 1, 1, "Q" "sssdc" "sdc" "ssc" "ssc" "ssc" "ssc" "ssc" "S" "Xc" "ssc" @@ -409,7 +433,23 @@ static void CreateServicePacket( PowerState, "SleepPeriod: ", SleepPeriod, "RegistrationState: ", RegistrationState); +#else + ret_code = http_MakeMessage(&buf, 1, 1, + "Q" "sssdc" "sdc" "ssc" + "ssc" "ssc" "S" "ssc" + "sdc" "sdc" "sdcc", + HTTPMETHOD_NOTIFY, "*", (size_t) 1, + "HOST: ", host, ":", SSDP_PORT, + "CACHE-CONTROL: max-age=", duration, + "LOCATION: ", location, "NT: ", nt, + "NTS: ", nts, + "USN: ", usn, "Powerstate: ", + PowerState, "SleepPeriod: ", + SleepPeriod, "RegistrationState: ", + RegistrationState); +#endif /* UPNP_HAVE_OPTSSDP */ } else { +#ifdef UPNP_HAVE_OPTSSDP ret_code = http_MakeMessage(&buf, 1, 1, "Q" "sssdc" "sdc" "ssc" "ssc" "ssc" "ssc" "ssc" "S" "Xc" "sscc", @@ -421,6 +461,16 @@ static void CreateServicePacket( "01-NLS: ", gUpnpSdkNLSuuid, "NT: ", nt, "NTS: ", nts, X_USER_AGENT, "USN: ", usn); +#else + ret_code = http_MakeMessage(&buf, 1, 1, + "Q" "sssdc" "sdc" "ssc" + "ssc" "ssc" "S" "sscc", + HTTPMETHOD_NOTIFY, "*", (size_t) 1, + "HOST: ", host, ":", SSDP_PORT, + "CACHE-CONTROL: max-age=", duration, + "LOCATION: ", location, "NT: ", nt, + "NTS: ", nts, "USN: ", usn); +#endif /* UPNP_HAVE_OPTSSDP */ } if (ret_code) return;