Compare commits
9 Commits
release-1.
...
release-1.
Author | SHA1 | Date | |
---|---|---|---|
![]() |
631259dcfc | ||
![]() |
98e4f938d6 | ||
![]() |
92c93a8010 | ||
![]() |
e40e6b49d4 | ||
![]() |
cec07d641a | ||
![]() |
6c6fb3707f | ||
![]() |
92ea719804 | ||
![]() |
fed316ff3e | ||
![]() |
8eb7d1c1a5 |
37
ChangeLog
37
ChangeLog
@@ -1,3 +1,40 @@
|
||||
*******************************************************************************
|
||||
Version 1.6.14
|
||||
*******************************************************************************
|
||||
|
||||
2011-10-31 Fabrice Fontaine <fabrice.fontaine(at)orange.com>
|
||||
|
||||
UPnP Low Power Support.
|
||||
|
||||
Adding two new functions (UpnpSendAdvertisementLowPower and
|
||||
UpnpUnRegisterRootDeviceLowPower) which can be used to specify values
|
||||
for the three SSDP headers defined by UPnP Low Power. Those headers are
|
||||
Powerstate, SleepPeriod and RegistrationState.
|
||||
|
||||
2011-10-24 Fabrice Fontaine <fabrice.fontaine(at)orange.com>
|
||||
|
||||
Bug fix in IN6_IS_ADDR_GLOBAL.
|
||||
|
||||
Changing IN6_IS_ADDR_GLOBAL to accept all IPv6 addresses which have a
|
||||
2000::/3 prefix.
|
||||
|
||||
2011-07-20 Marc Essayan <marc.essayan(at)orange-ftgroup.com>
|
||||
|
||||
Bug Fix on M-SEARCH.
|
||||
|
||||
Do not answer to M-SEARCH using HTTP version 1.0 as specified by the
|
||||
UPnP Device Architecture.
|
||||
|
||||
2011-03-18 Iain Denniston <iain.denniston(at)gmail.com>
|
||||
|
||||
Fixes for compilation under Windows (specifically MSVC). Also added
|
||||
MSVC supported "_inline", and fixed some WIN32 specific warnings.
|
||||
|
||||
2011-03-08 Iain Denniston <iain.denniston(at)gmail.com>
|
||||
|
||||
Several fixes to correctly use SOCKET (and related) types instead of
|
||||
non-portable variations.
|
||||
|
||||
*******************************************************************************
|
||||
Version 1.6.13
|
||||
*******************************************************************************
|
||||
|
2
Doxyfile
2
Doxyfile
@@ -31,7 +31,7 @@ PROJECT_NAME = libUPnP
|
||||
# This could be handy for archiving the generated documentation or
|
||||
# if some version control system is used.
|
||||
|
||||
PROJECT_NUMBER = 1.6.13
|
||||
PROJECT_NUMBER = 1.6.14
|
||||
|
||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
||||
# base path where the generated documentation will be put.
|
||||
|
@@ -105,13 +105,16 @@
|
||||
#define PACKAGE_NAME "libupnp"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "libupnp 1.6.13"
|
||||
#define PACKAGE_STRING "libupnp 1.6.14"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "libupnp"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "1.6.13"
|
||||
#define PACKAGE_VERSION "1.6.14"
|
||||
|
||||
/* Define to necessary symbol if this constant uses a non-standard name on
|
||||
your system. */
|
||||
@@ -154,13 +157,13 @@
|
||||
#define UPNP_VERSION_MINOR 6
|
||||
|
||||
/* see upnpconfig.h */
|
||||
#define UPNP_VERSION_PATCH 13
|
||||
#define UPNP_VERSION_PATCH 14
|
||||
|
||||
/* see upnpconfig.h */
|
||||
#define UPNP_VERSION_STRING "1.6.13"
|
||||
#define UPNP_VERSION_STRING "1.6.14"
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "1.6.13"
|
||||
#define VERSION "1.6.14"
|
||||
|
||||
/* File Offset size */
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
|
@@ -40,7 +40,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
/** The library version (string) e.g. "1.3.0" */
|
||||
#define UPNP_VERSION_STRING "1.6.13"
|
||||
#define UPNP_VERSION_STRING "1.6.14"
|
||||
|
||||
/** Major version of the library */
|
||||
#define UPNP_VERSION_MAJOR 1
|
||||
@@ -49,7 +49,7 @@
|
||||
#define UPNP_VERSION_MINOR 6
|
||||
|
||||
/** Patch version of the library */
|
||||
#define UPNP_VERSION_PATCH 13
|
||||
#define UPNP_VERSION_PATCH 14
|
||||
|
||||
/** The library version (numeric) e.g. 10300 means version 1.3.0 */
|
||||
#define UPNP_VERSION \
|
||||
|
19
configure.ac
19
configure.ac
@@ -9,7 +9,7 @@
|
||||
|
||||
AC_PREREQ(2.60)
|
||||
|
||||
AC_INIT([libupnp], [1.6.13], [mroberto@users.sourceforge.net])
|
||||
AC_INIT([libupnp], [1.6.14], [mroberto@users.sourceforge.net])
|
||||
dnl ############################################################################
|
||||
dnl # *Independently* of the above libupnp package version, the libtool version
|
||||
dnl # of the 3 libraries need to be updated whenever there is a change released:
|
||||
@@ -255,9 +255,24 @@ dnl #AC_SUBST([LT_VERSION_THREADUTIL], [6:0:0])
|
||||
dnl #AC_SUBST([LT_VERSION_UPNP], [7:0:1])
|
||||
dnl #
|
||||
dnl ############################################################################
|
||||
dnl # Release 1.6.14:
|
||||
dnl # "current:revision:age"
|
||||
dnl #
|
||||
dnl # - Code has changed in upnp
|
||||
dnl # revision: 0 -> 1
|
||||
dnl # - interface added in upnp
|
||||
dnl # current: 7 -> 8
|
||||
dnl # revision: 1 - > 0
|
||||
dnl # age: 1 -> 2
|
||||
dnl #
|
||||
dnl #AC_SUBST([LT_VERSION_IXML], [2:6:0])
|
||||
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [6:0:0])
|
||||
dnl #AC_SUBST([LT_VERSION_UPNP], [8:0:2])
|
||||
dnl #
|
||||
dnl ############################################################################
|
||||
AC_SUBST([LT_VERSION_IXML], [2:6:0])
|
||||
AC_SUBST([LT_VERSION_THREADUTIL], [6:0:0])
|
||||
AC_SUBST([LT_VERSION_UPNP], [7:0:1])
|
||||
AC_SUBST([LT_VERSION_UPNP], [8:0:2])
|
||||
dnl ############################################################################
|
||||
dnl # Repeating the algorithm to place it closer to the modificatin place:
|
||||
dnl # - library code modified: revision++
|
||||
|
@@ -1,4 +1,4 @@
|
||||
Version: 1.6.13
|
||||
Version: 1.6.14
|
||||
Summary: Universal Plug and Play (UPnP) SDK
|
||||
Name: libupnp
|
||||
Release: 1%{?dist}
|
||||
|
@@ -922,7 +922,8 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(PTHREAD_MUTEX_RECURSIVE) && !defined(__DragonFly__)
|
||||
#if !defined(PTHREAD_MUTEX_RECURSIVE) && !defined(__DragonFly__) && !defined(UPNP_USE_MSVCPP)
|
||||
/* !defined(UPNP_USE_MSVCPP) should probably also have pthreads version check - but it's not clear if that is possible */
|
||||
/* NK: Added for satisfying the gcc compiler */
|
||||
EXPORT_SPEC int pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind);
|
||||
#endif
|
||||
|
@@ -292,8 +292,8 @@ static int SetPriority(
|
||||
/*! . */
|
||||
ThreadPriority priority)
|
||||
{
|
||||
int retVal = 0;
|
||||
#if defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING > 0
|
||||
int retVal = 0;
|
||||
int currentPolicy;
|
||||
int minPriority = 0;
|
||||
int maxPriority = 0;
|
||||
@@ -325,11 +325,12 @@ static int SetPriority(
|
||||
|
||||
sched_result = pthread_setschedparam(ithread_self(), currentPolicy, &newPriority);
|
||||
retVal = (sched_result == 0 || errno == EPERM) ? 0 : sched_result;
|
||||
#else
|
||||
retVal = 0;
|
||||
#endif
|
||||
exit_function:
|
||||
return retVal;
|
||||
#else
|
||||
return 0;
|
||||
priority = priority;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@@ -40,7 +40,7 @@
|
||||
*/
|
||||
#ifdef UPNP_USE_MSVCPP
|
||||
/* define some things the M$ VC++ doesn't know */
|
||||
#define UPNP_INLINE
|
||||
#define UPNP_INLINE _inline
|
||||
typedef __int64 int64_t;
|
||||
#define PRId64 "I64d"
|
||||
#define PRIzd "ld"
|
||||
|
@@ -15,8 +15,11 @@
|
||||
|
||||
#ifdef WIN32
|
||||
#include <stdarg.h>
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
#ifndef UPNP_USE_MSVCPP
|
||||
/* Removed: not required (and cause compilation issues) */
|
||||
#include <winbase.h>
|
||||
#include <windef.h>
|
||||
#endif
|
||||
#include <winsock2.h>
|
||||
#include <iphlpapi.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
@@ -1,11 +1,11 @@
|
||||
#ifndef UPNPINTTYPES_H
|
||||
#define UPNPINTTYPES_H
|
||||
|
||||
#if !defined(UPNP_USE_BCBPP) && !defined(UPNP_USE_MSVCPP)
|
||||
#if !defined(UPNP_USE_BCBPP)
|
||||
|
||||
/* Printf format for integers. */
|
||||
#include <inttypes.h>
|
||||
|
||||
#endif /* !defined(UPNP_USE_BCBPP) && !defined(UPNP_USE_MSVCPP) */
|
||||
#endif /* !defined(UPNP_USE_BCBPP) */
|
||||
|
||||
#endif /* UPNPINTTYPES_H */
|
||||
|
@@ -1,11 +1,20 @@
|
||||
#ifndef UPNPSTDINT_H
|
||||
#define UPNPSTDINT_H
|
||||
|
||||
#if !defined(UPNP_USE_BCBPP) && !defined(UPNP_USE_MSVCPP)
|
||||
#if !defined(UPNP_USE_BCBPP)
|
||||
|
||||
/* Sized integer types. */
|
||||
#include <stdint.h>
|
||||
|
||||
#endif /* !defined(UPNP_USE_BCBPP) && !defined(UPNP_USE_MSVCPP) */
|
||||
#ifdef UPNP_USE_MSVCPP
|
||||
/* no ssize_t defined for VC */
|
||||
#ifdef _WIN64
|
||||
typedef int64_t ssize_t;
|
||||
#else
|
||||
typedef int32_t ssize_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* !defined(UPNP_USE_BCBPP) */
|
||||
|
||||
#endif /* UPNPSTDINT_H */
|
||||
|
@@ -5,6 +5,7 @@
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
* Copyright (C) 2011 France Telecom All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -51,6 +52,9 @@
|
||||
*/
|
||||
#ifdef WIN32
|
||||
#include <time.h>
|
||||
#ifdef UPNP_USE_MSVCPP
|
||||
#include <sys/types.h> /* needed for off_t */
|
||||
#endif
|
||||
#elif (defined(BSD) && BSD >= 199306)
|
||||
#include <time.h>
|
||||
#else
|
||||
@@ -1284,6 +1288,35 @@ EXPORT_SPEC int UpnpUnRegisterRootDevice(
|
||||
/*! [in] The handle of the root device instance to unregister. */
|
||||
UpnpDevice_Handle Hnd);
|
||||
|
||||
/*!
|
||||
* \brief Unregisters a root device registered with \b UpnpRegisterRootDevice,
|
||||
* \b UpnpRegisterRootDevice2, \b UpnpRegisterRootDevice3 or
|
||||
* \b UpnpRegisterRootDevice4.
|
||||
*
|
||||
* After this call, the \b UpnpDevice_Handle is no longer valid. For all
|
||||
* advertisements that have not yet expired, the SDK sends a device unavailable
|
||||
* message automatically.
|
||||
*
|
||||
* This is a synchronous call and generates no callbacks. Once this call
|
||||
* returns, the SDK will no longer generate callbacks to the application.
|
||||
*
|
||||
* This function allow a device to specify the SSDP extensions defined by UPnP
|
||||
* Low Power.
|
||||
*
|
||||
* \return An integer representing one of the following:
|
||||
* \li \c UPNP_E_SUCCESS: The operation completed successfully.
|
||||
* \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid device handle.
|
||||
*/
|
||||
EXPORT_SPEC int UpnpUnRegisterRootDeviceLowPower(
|
||||
/*! [in] The handle of the root device instance to unregister. */
|
||||
UpnpDevice_Handle Hnd,
|
||||
/*! PowerState as defined by UPnP Low Power. */
|
||||
int PowerState,
|
||||
/*! SleepPeriod as defined by UPnP Low Power. */
|
||||
int SleepPeriod,
|
||||
/*! RegistrationState as defined by UPnP Low Power. */
|
||||
int RegistrationState);
|
||||
|
||||
/*!
|
||||
* \brief Registers a control point application with the UPnP Library.
|
||||
*
|
||||
@@ -1438,6 +1471,36 @@ EXPORT_SPEC int UpnpSendAdvertisement(
|
||||
/*! The expiration age, in seconds, of the announcements. */
|
||||
int Exp);
|
||||
|
||||
/*!
|
||||
* \brief Sends out the discovery announcements for all devices and services
|
||||
* for a device.
|
||||
*
|
||||
* Each announcement is made with the same expiration time.
|
||||
*
|
||||
* This is a synchronous call.
|
||||
*
|
||||
* This function allow a device to specify the SSDP extensions defined by UPnP
|
||||
* Low Power.
|
||||
*
|
||||
* \return An integer representing one of the following:
|
||||
* \li \c UPNP_E_SUCCESS: The operation completed successfully.
|
||||
* \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid
|
||||
* device handle.
|
||||
* \li \c UPNP_E_OUTOF_MEMORY: There are insufficient resources to
|
||||
* send future advertisements.
|
||||
*/
|
||||
EXPORT_SPEC int UpnpSendAdvertisementLowPower(
|
||||
/*! The device handle for which to send out the announcements. */
|
||||
UpnpDevice_Handle Hnd,
|
||||
/*! The expiration age, in seconds, of the announcements. */
|
||||
int Exp,
|
||||
/*! PowerState as defined by UPnP Low Power. */
|
||||
int PowerState,
|
||||
/*! SleepPeriod as defined by UPnP Low Power. */
|
||||
int SleepPeriod,
|
||||
/*! RegistrationState as defined by UPnP Low Power. */
|
||||
int RegistrationState);
|
||||
|
||||
/* @} Discovery */
|
||||
|
||||
/******************************************************************************
|
||||
|
@@ -50,6 +50,7 @@
|
||||
|
||||
|
||||
#include "ixml.h" /* for IXML_Document */
|
||||
#include "upnpconfig.h" /* for UPNP_HAVE_TOOLS */
|
||||
|
||||
|
||||
/* Function declarations only if tools compiled into the library */
|
||||
|
@@ -28,16 +28,19 @@
|
||||
/* Other systems have strncasecmp */
|
||||
#endif
|
||||
|
||||
/* strnlen() is a GNU extension. */
|
||||
#if HAVE_STRNLEN
|
||||
extern size_t strnlen(const char *s, size_t maxlen);
|
||||
#else /* HAVE_STRNLEN */
|
||||
static size_t strnlen(const char *s, size_t n)
|
||||
{
|
||||
const char *p = (const char *)memchr(s, 0, n);
|
||||
return p ? p - s : n;
|
||||
}
|
||||
#endif /* HAVE_STRNLEN */
|
||||
#ifndef UPNP_USE_MSVCPP
|
||||
/* VC has strnlen which is already included but with (potentially) different linkage */
|
||||
/* strnlen() is a GNU extension. */
|
||||
#if HAVE_STRNLEN
|
||||
extern size_t strnlen(const char *s, size_t maxlen);
|
||||
#else /* HAVE_STRNLEN */
|
||||
static size_t strnlen(const char *s, size_t n)
|
||||
{
|
||||
const char *p = (const char *)memchr(s, 0, n);
|
||||
return p ? p - s : n;
|
||||
}
|
||||
#endif /* HAVE_STRNLEN */
|
||||
#endif /* WIN32 */
|
||||
|
||||
/* strndup() is a GNU extension. */
|
||||
#if HAVE_STRNDUP && !defined(WIN32)
|
||||
|
@@ -2,6 +2,7 @@
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
* Copyright (C) 2011 France Telecom All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -79,8 +80,8 @@
|
||||
|
||||
#ifndef IN6_IS_ADDR_GLOBAL
|
||||
#define IN6_IS_ADDR_GLOBAL(a) \
|
||||
(((((__const uint8_t *) (a))[0] & htonl(0xff000000)) <= htonl(0x3f000000) \
|
||||
&& (((__const uint8_t *) (a))[0] & htonl(0xff000000)) >= htonl(0x20000000)))
|
||||
((((__const uint32_t *) (a))[0] & htonl(0x70000000)) \
|
||||
== htonl (0x20000000))
|
||||
#endif /* IS ADDR GLOBAL */
|
||||
|
||||
#ifndef IN6_IS_ADDR_ULA
|
||||
@@ -1205,6 +1206,14 @@ exit_function:
|
||||
|
||||
#ifdef INCLUDE_DEVICE_APIS
|
||||
int UpnpUnRegisterRootDevice(UpnpDevice_Handle Hnd)
|
||||
{
|
||||
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"Inside UpnpUnRegisterRootDevice\n");
|
||||
return UpnpUnRegisterRootDeviceLowPower(Hnd, -1, -1, -1);
|
||||
}
|
||||
|
||||
int UpnpUnRegisterRootDeviceLowPower(UpnpDevice_Handle Hnd, int PowerState,
|
||||
int SleepPeriod, int RegistrationState)
|
||||
{
|
||||
int retVal = 0;
|
||||
struct Handle_Info *HInfo = NULL;
|
||||
@@ -1212,7 +1221,7 @@ int UpnpUnRegisterRootDevice(UpnpDevice_Handle Hnd)
|
||||
if (UpnpSdkInit != 1)
|
||||
return UPNP_E_FINISH;
|
||||
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"Inside UpnpUnRegisterRootDevice\n");
|
||||
"Inside UpnpUnRegisterRootDeviceLowPower\n");
|
||||
#if EXCLUDE_GENA == 0
|
||||
if (genaUnregisterDevice(Hnd) != UPNP_E_SUCCESS)
|
||||
return UPNP_E_INVALID_HANDLE;
|
||||
@@ -1223,6 +1232,11 @@ int UpnpUnRegisterRootDevice(UpnpDevice_Handle Hnd)
|
||||
HandleUnlock();
|
||||
return UPNP_E_INVALID_HANDLE;
|
||||
}
|
||||
HInfo->PowerState = PowerState;
|
||||
if( SleepPeriod < 0 )
|
||||
SleepPeriod = -1;
|
||||
HInfo->SleepPeriod = SleepPeriod;
|
||||
HInfo->RegistrationState = RegistrationState;
|
||||
HandleUnlock();
|
||||
|
||||
#if EXCLUDE_SSDP == 0
|
||||
@@ -1254,7 +1268,7 @@ int UpnpUnRegisterRootDevice(UpnpDevice_Handle Hnd)
|
||||
HandleUnlock();
|
||||
|
||||
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"Exiting UpnpUnRegisterRootDevice\n");
|
||||
"Exiting UpnpUnRegisterRootDeviceLowPower\n");
|
||||
|
||||
return retVal;
|
||||
}
|
||||
@@ -1583,6 +1597,14 @@ static int GetDescDocumentAndURL(
|
||||
#ifdef INCLUDE_DEVICE_APIS
|
||||
#if EXCLUDE_SSDP == 0
|
||||
int UpnpSendAdvertisement(UpnpDevice_Handle Hnd, int Exp)
|
||||
{
|
||||
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Inside UpnpSendAdvertisement \n");
|
||||
return UpnpSendAdvertisementLowPower (Hnd, Exp, -1, -1, -1);
|
||||
}
|
||||
|
||||
int UpnpSendAdvertisementLowPower(UpnpDevice_Handle Hnd, int Exp,
|
||||
int PowerState, int SleepPeriod, int RegistrationState)
|
||||
{
|
||||
struct Handle_Info *SInfo = NULL;
|
||||
int retVal = 0,
|
||||
@@ -1595,7 +1617,7 @@ int UpnpSendAdvertisement(UpnpDevice_Handle Hnd, int Exp)
|
||||
}
|
||||
|
||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Inside UpnpSendAdvertisement \n" );
|
||||
"Inside UpnpSendAdvertisementLowPower \n" );
|
||||
|
||||
HandleLock();
|
||||
if( GetHandleInfo( Hnd, &SInfo ) != HND_DEVICE ) {
|
||||
@@ -1605,6 +1627,11 @@ int UpnpSendAdvertisement(UpnpDevice_Handle Hnd, int Exp)
|
||||
if( Exp < 1 )
|
||||
Exp = DEFAULT_MAXAGE;
|
||||
SInfo->MaxAge = Exp;
|
||||
SInfo->PowerState = PowerState;
|
||||
if( SleepPeriod < 0 )
|
||||
SleepPeriod = -1;
|
||||
SInfo->SleepPeriod = SleepPeriod;
|
||||
SInfo->RegistrationState = RegistrationState;
|
||||
HandleUnlock();
|
||||
retVal = AdvertiseAndReply( 1, Hnd, 0, ( struct sockaddr * )NULL,
|
||||
( char * )NULL, ( char * )NULL,
|
||||
@@ -1665,7 +1692,7 @@ int UpnpSendAdvertisement(UpnpDevice_Handle Hnd, int Exp)
|
||||
|
||||
HandleUnlock();
|
||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Exiting UpnpSendAdvertisement \n" );
|
||||
"Exiting UpnpSendAdvertisementLowPower \n" );
|
||||
|
||||
return retVal;
|
||||
|
||||
@@ -3242,7 +3269,7 @@ int UpnpGetIfInfo(const char *IfName)
|
||||
ifname_found = 1;
|
||||
}
|
||||
/* Create an unbound datagram socket to do the SIOCGIFADDR ioctl on. */
|
||||
if ((LocalSock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
|
||||
if ((LocalSock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
|
||||
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Can't create addrlist socket\n");
|
||||
return UPNP_E_INIT;
|
||||
@@ -3660,7 +3687,7 @@ int getlocalhostname(char *out, size_t out_len)
|
||||
|
||||
/* Create an unbound datagram socket to do the SIOCGIFADDR ioctl on. */
|
||||
LocalSock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if (LocalSock < 0) {
|
||||
if (LocalSock == INVALID_SOCKET) {
|
||||
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Can't create addrlist socket\n");
|
||||
return UPNP_E_INIT;
|
||||
|
@@ -118,6 +118,7 @@ int DebugAtThisLevel(Upnp_LogLevel DLevel, Dbg_Module Module)
|
||||
(Module == DOM && DEBUG_DOM) || (Module == HTTP && DEBUG_HTTP);
|
||||
|
||||
return ret;
|
||||
Module = Module; /* VC complains about this being unreferenced */
|
||||
}
|
||||
|
||||
void UpnpPrintf(Upnp_LogLevel DLevel,
|
||||
|
@@ -1310,7 +1310,12 @@ parser_parse_requestline( INOUT http_parser_t * parser )
|
||||
&hmsg->major_version, &hmsg->minor_version );
|
||||
version_str.buf[version_str.length] = save_char; /* restore */
|
||||
if( num_scanned != 2 ||
|
||||
hmsg->major_version < 0 || hmsg->minor_version < 0 ) {
|
||||
/* HTTP version equals to 1.0 should fail for MSEARCH as required by the
|
||||
* UPnP certification tool */
|
||||
hmsg->major_version < 0 || ( ( hmsg->major_version == 1 )
|
||||
&& ( hmsg->minor_version < 1 )
|
||||
&& ( Http_Method_Table[index].id == HTTPMETHOD_MSEARCH ) ) ) {
|
||||
parser->http_error_code = HTTP_HTTP_VERSION_NOT_SUPPORTED;
|
||||
/* error; bad http version */
|
||||
return PARSE_FAILURE;
|
||||
}
|
||||
|
@@ -222,8 +222,8 @@ SOCKET http_Connect(
|
||||
http_FixUrl(destination_url, url);
|
||||
|
||||
connfd = socket(url->hostport.IPaddress.ss_family, SOCK_STREAM, 0);
|
||||
if (connfd == -1) {
|
||||
return UPNP_E_OUTOF_SOCKET;
|
||||
if (connfd == INVALID_SOCKET) {
|
||||
return (SOCKET)(UPNP_E_OUTOF_SOCKET);
|
||||
}
|
||||
sockaddr_len = (socklen_t)(url->hostport.IPaddress.ss_family == AF_INET6 ?
|
||||
sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in));
|
||||
@@ -236,7 +236,7 @@ SOCKET http_Connect(
|
||||
#endif
|
||||
shutdown(connfd, SD_BOTH);
|
||||
UpnpCloseSocket(connfd);
|
||||
return UPNP_E_SOCKET_CONNECT;
|
||||
return (SOCKET)(UPNP_E_SOCKET_CONNECT);
|
||||
}
|
||||
|
||||
return connfd;
|
||||
@@ -493,7 +493,8 @@ Cleanup_File:
|
||||
num_written = (size_t)nw;
|
||||
UpnpPrintf(UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||
">>> (SENT) >>>\n"
|
||||
"%.*s\nbuf_length=%zd, num_written=%zd\n""------------\n",
|
||||
"%.*s\nbuf_length=%" PRIzd ", num_written=%" PRIzd "\n"
|
||||
"------------\n",
|
||||
(int)buf_length, buf, buf_length, num_written);
|
||||
if (num_written != buf_length) {
|
||||
RetVal = 0;
|
||||
@@ -548,7 +549,7 @@ int http_RequestAndResponse(
|
||||
|
||||
tcp_connection = socket(
|
||||
destination->hostport.IPaddress.ss_family, SOCK_STREAM, 0);
|
||||
if (tcp_connection == -1) {
|
||||
if (tcp_connection == INVALID_SOCKET) {
|
||||
parser_response_init(response, req_method);
|
||||
return UPNP_E_SOCKET_ERROR;
|
||||
}
|
||||
@@ -969,7 +970,7 @@ int http_OpenHttpPost(
|
||||
handle->contentLength = contentLength;
|
||||
tcp_connection = socket(url.hostport.IPaddress.ss_family,
|
||||
SOCK_STREAM, 0);
|
||||
if (tcp_connection == -1) {
|
||||
if (tcp_connection == INVALID_SOCKET) {
|
||||
ret_code = UPNP_E_SOCKET_ERROR;
|
||||
goto errorHandler;
|
||||
}
|
||||
@@ -1446,7 +1447,7 @@ int http_OpenHttpGetProxy(const char *url_str, const char *proxy_str,
|
||||
parser_response_init(&handle->response, HTTPMETHOD_GET);
|
||||
tcp_connection =
|
||||
socket(peer->hostport.IPaddress.ss_family, SOCK_STREAM, 0);
|
||||
if (tcp_connection == -1) {
|
||||
if (tcp_connection == INVALID_SOCKET) {
|
||||
ret_code = UPNP_E_SOCKET_ERROR;
|
||||
goto errorHandler;
|
||||
}
|
||||
@@ -1965,7 +1966,7 @@ int http_OpenHttpGetEx(
|
||||
memset(handle, 0, sizeof(*handle));
|
||||
parser_response_init(&handle->response, HTTPMETHOD_GET);
|
||||
tcp_connection = socket(url.hostport.IPaddress.ss_family, SOCK_STREAM, 0);
|
||||
if (tcp_connection == -1) {
|
||||
if (tcp_connection == INVALID_SOCKET) {
|
||||
errCode = UPNP_E_SOCKET_ERROR;
|
||||
free(handle);
|
||||
break;
|
||||
|
@@ -86,12 +86,12 @@ int sock_destroy(SOCKINFO *info, int ShutdownMethod)
|
||||
{
|
||||
int ret = UPNP_E_SUCCESS;
|
||||
|
||||
if (info->socket != -1) {
|
||||
if (info->socket != INVALID_SOCKET) {
|
||||
shutdown(info->socket, ShutdownMethod);
|
||||
if (sock_close(info->socket) == -1) {
|
||||
ret = UPNP_E_SOCKET_ERROR;
|
||||
}
|
||||
info->socket = -1;
|
||||
info->socket = INVALID_SOCKET;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@@ -74,7 +74,7 @@ static UPNP_INLINE int sock_close(
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (sock != -1)
|
||||
if (sock != INVALID_SOCKET)
|
||||
ret = UpnpCloseSocket(sock);
|
||||
|
||||
return ret;
|
||||
|
@@ -5,6 +5,7 @@
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
* Copyright (C) 2011 France Telecom All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -353,7 +354,13 @@ int DeviceAdvertisement(
|
||||
/* [in] Service duration in sec. */
|
||||
int Duration,
|
||||
/* [in] Device address family. */
|
||||
int AddressFamily);
|
||||
int AddressFamily,
|
||||
/* [in] PowerState as defined by UPnP Low Power. */
|
||||
int PowerState,
|
||||
/* [in] SleepPeriod as defined by UPnP Low Power. */
|
||||
int SleepPeriod,
|
||||
/* [in] RegistrationState as defined by UPnP Low Power. */
|
||||
int RegistrationState);
|
||||
|
||||
/*!
|
||||
* \brief Creates the reply packet based on the input parameter, and send it
|
||||
@@ -375,7 +382,13 @@ int SendReply(
|
||||
/* [in] Life time of this device. */
|
||||
int Duration,
|
||||
/* [in] . */
|
||||
int ByType );
|
||||
int ByType,
|
||||
/* [in] PowerState as defined by UPnP Low Power. */
|
||||
int PowerState,
|
||||
/* [in] SleepPeriod as defined by UPnP Low Power. */
|
||||
int SleepPeriod,
|
||||
/* [in] RegistrationState as defined by UPnP Low Power. */
|
||||
int RegistrationState);
|
||||
|
||||
/*!
|
||||
* \brief Creates the reply packet based on the input parameter, and send it
|
||||
@@ -395,7 +408,13 @@ int DeviceReply(
|
||||
/* [in] Location of Device description document. */
|
||||
char *Location,
|
||||
/* [in] Life time of this device. */
|
||||
int Duration);
|
||||
int Duration,
|
||||
/* [in] PowerState as defined by UPnP Low Power. */
|
||||
int PowerState,
|
||||
/* [in] SleepPeriod as defined by UPnP Low Power. */
|
||||
int SleepPeriod,
|
||||
/* [in] RegistrationState as defined by UPnP Low Power. */
|
||||
int RegistrationState);
|
||||
|
||||
/*!
|
||||
* \brief Creates the advertisement packet based on the input parameter,
|
||||
@@ -413,7 +432,13 @@ int ServiceAdvertisement(
|
||||
/* [in] Life time of this device. */
|
||||
int Duration,
|
||||
/* [in] Device address family. */
|
||||
int AddressFamily);
|
||||
int AddressFamily,
|
||||
/* [in] PowerState as defined by UPnP Low Power. */
|
||||
int PowerState,
|
||||
/* [in] SleepPeriod as defined by UPnP Low Power. */
|
||||
int SleepPeriod,
|
||||
/* [in] RegistrationState as defined by UPnP Low Power. */
|
||||
int RegistrationState);
|
||||
|
||||
/*!
|
||||
* \brief Creates the advertisement packet based on the input parameter,
|
||||
@@ -431,7 +456,13 @@ int ServiceReply(
|
||||
/* [in] Location of Device description document. */
|
||||
char *Location,
|
||||
/* [in] Life time of this device. */
|
||||
int Duration);
|
||||
int Duration,
|
||||
/* [in] PowerState as defined by UPnP Low Power. */
|
||||
int PowerState,
|
||||
/* [in] SleepPeriod as defined by UPnP Low Power. */
|
||||
int SleepPeriod,
|
||||
/* [in] RegistrationState as defined by UPnP Low Power. */
|
||||
int RegistrationState);
|
||||
|
||||
/*!
|
||||
* \brief Creates a HTTP service shutdown request packet and sends it to the
|
||||
@@ -449,7 +480,13 @@ int ServiceShutdown(
|
||||
/* [in] Service duration in sec. */
|
||||
int Duration,
|
||||
/* [in] Device address family. */
|
||||
int AddressFamily);
|
||||
int AddressFamily,
|
||||
/* [in] PowerState as defined by UPnP Low Power. */
|
||||
int PowerState,
|
||||
/* [in] SleepPeriod as defined by UPnP Low Power. */
|
||||
int SleepPeriod,
|
||||
/* [in] RegistrationState as defined by UPnP Low Power. */
|
||||
int RegistrationState);
|
||||
|
||||
/*!
|
||||
* \brief Creates a HTTP device shutdown request packet and send it to the
|
||||
@@ -471,7 +508,13 @@ int DeviceShutdown(
|
||||
/* [in] Device duration in sec. */
|
||||
int Duration,
|
||||
/* [in] Device address family. */
|
||||
int AddressFamily);
|
||||
int AddressFamily,
|
||||
/* [in] PowerState as defined by UPnP Low Power. */
|
||||
int PowerState,
|
||||
/* [in] SleepPeriod as defined by UPnP Low Power. */
|
||||
int SleepPeriod,
|
||||
/* [in] RegistrationState as defined by UPnP Low Power. */
|
||||
int RegistrationState);
|
||||
|
||||
/* @} SSDP Device Functions */
|
||||
|
||||
|
@@ -2,6 +2,7 @@
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
* Copyright (C) 2011 France Telecom All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -87,6 +88,12 @@ struct Handle_Info
|
||||
char DescXML[LINE_SIZE];
|
||||
/* Advertisement timeout */
|
||||
int MaxAge;
|
||||
/* Power State as defined by UPnP Low Power. */
|
||||
int PowerState;
|
||||
/* Sleep Period as defined by UPnP Low Power. */
|
||||
int SleepPeriod;
|
||||
/* Registration State as defined by UPnP Low Power. */
|
||||
int RegistrationState;
|
||||
/*! Description parsed in terms of DOM document. */
|
||||
IXML_Document *DescDocument;
|
||||
/*! List of devices in the description document. */
|
||||
|
@@ -112,7 +112,8 @@ void linecopylen(
|
||||
#define ERROR_BUFFER_LEN 256
|
||||
|
||||
/* C specific */
|
||||
#ifndef __cplusplus
|
||||
/* VC needs these in C++ mode too (do other compilers?) */
|
||||
#if !defined(__cplusplus) || defined(UPNP_USE_MSVCPP)
|
||||
#ifdef WIN32
|
||||
#ifndef S_ISREG
|
||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
@@ -130,7 +131,7 @@ void linecopylen(
|
||||
#define max(a, b) (((a)>(b))? (a):(b))
|
||||
#define min(a, b) (((a)<(b))? (a):(b))
|
||||
#endif /* WIN32 */
|
||||
#endif /* __cplusplus */
|
||||
#endif /* !defined(__cplusplus) || defined(UPNP_USE_MSVCPP) */
|
||||
|
||||
#endif /* UTIL_H */
|
||||
|
||||
|
@@ -52,7 +52,10 @@
|
||||
#include <time.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include "inet_pton.h"
|
||||
#ifndef UPNP_USE_MSVCPP
|
||||
/* VC Winsocks2 includes these functions */
|
||||
#include "inet_pton.h"
|
||||
#endif
|
||||
#else
|
||||
#include <netdb.h> /* for struct addrinfo */
|
||||
#endif
|
||||
|
@@ -379,7 +379,7 @@ get_response_value( IN http_message_t * hmsg,
|
||||
char *node_str = NULL;
|
||||
const char *temp_str = NULL;
|
||||
DOMString error_node_str = NULL;
|
||||
int err_code = UPNP_E_BAD_RESPONSE; /* default error */ ;
|
||||
int err_code = UPNP_E_BAD_RESPONSE; /* default error */
|
||||
int done = FALSE;
|
||||
const char *names[5];
|
||||
const DOMString nodeValue;
|
||||
|
@@ -441,7 +441,7 @@ int SearchByTarget(int Mx, char *St, void *Cookie)
|
||||
struct Handle_Info *ctrlpt_info = NULL;
|
||||
enum SsdpSearchType requestType;
|
||||
unsigned long addrv4 = inet_addr(gIF_IPV4);
|
||||
int max_fd = 0;
|
||||
SOCKET max_fd = 0;
|
||||
|
||||
/*ThreadData *ThData; */
|
||||
ThreadPoolJob job;
|
||||
|
@@ -2,6 +2,7 @@
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
* Copyright (C) 2011 France Telecom All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -181,7 +182,7 @@ static int NewRequestHandler(
|
||||
int ret = UPNP_E_SUCCESS;
|
||||
|
||||
ReplySock = socket(DestAddr->sa_family, SOCK_DGRAM, 0);
|
||||
if (ReplySock == -1) {
|
||||
if (ReplySock == INVALID_SOCKET) {
|
||||
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
||||
UpnpPrintf(UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"SSDP_LIB: New Request Handler:"
|
||||
@@ -313,7 +314,13 @@ static void CreateServicePacket(
|
||||
/*! [out] Output buffer filled with HTTP statement. */
|
||||
char **packet,
|
||||
/*! [in] Address family of the HTTP request. */
|
||||
int AddressFamily)
|
||||
int AddressFamily,
|
||||
/*! [in] PowerState as defined by UPnP Low Power. */
|
||||
int PowerState,
|
||||
/*! [in] SleepPeriod as defined by UPnP Low Power. */
|
||||
int SleepPeriod,
|
||||
/*! [in] RegistrationState as defined by UPnP Low Power. */
|
||||
int RegistrationState)
|
||||
{
|
||||
int ret_code;
|
||||
const char *nts;
|
||||
@@ -326,7 +333,23 @@ static void CreateServicePacket(
|
||||
buf.size_inc = 30;
|
||||
*packet = NULL;
|
||||
if (msg_type == MSGTYPE_REPLY) {
|
||||
ret_code = http_MakeMessage(&buf, 1, 1,
|
||||
if (PowerState > 0) {
|
||||
ret_code = http_MakeMessage(&buf, 1, 1,
|
||||
"R" "sdc" "D" "sc" "ssc" "ssc" "ssc"
|
||||
"S" "Xc" "ssc" "ssc"
|
||||
"sdc" "sdc" "sdcc", HTTP_OK,
|
||||
"CACHE-CONTROL: max-age=", duration,
|
||||
"EXT:", "LOCATION: ", location,
|
||||
"OPT: ",
|
||||
"\"http://schemas.upnp.org/upnp/1/0/\"; ns=01",
|
||||
"01-NLS: ", gUpnpSdkNLSuuid,
|
||||
X_USER_AGENT, "ST: ", nt, "USN: ",
|
||||
usn, "Powerstate: ", PowerState,
|
||||
"SleepPeriod: ", SleepPeriod,
|
||||
"RegistrationState: ",
|
||||
RegistrationState);
|
||||
} else {
|
||||
ret_code = http_MakeMessage(&buf, 1, 1,
|
||||
"R" "sdc" "D" "sc" "ssc" "ssc" "ssc"
|
||||
"S" "Xc" "ssc" "sscc", HTTP_OK,
|
||||
"CACHE-CONTROL: max-age=", duration,
|
||||
@@ -336,6 +359,7 @@ static void CreateServicePacket(
|
||||
"01-NLS: ", gUpnpSdkNLSuuid,
|
||||
X_USER_AGENT, "ST: ", nt, "USN: ",
|
||||
usn);
|
||||
}
|
||||
if (ret_code != 0) {
|
||||
return;
|
||||
}
|
||||
@@ -358,7 +382,24 @@ static void CreateServicePacket(
|
||||
else
|
||||
host = "[" SSDP_IPV6_LINKLOCAL "]";
|
||||
}
|
||||
ret_code = http_MakeMessage(&buf, 1, 1,
|
||||
if (PowerState > 0) {
|
||||
ret_code = http_MakeMessage(&buf, 1, 1,
|
||||
"Q" "sssdc" "sdc" "ssc" "ssc" "ssc"
|
||||
"ssc" "ssc" "S" "Xc" "ssc"
|
||||
"sdc" "sdc" "sdcc",
|
||||
HTTPMETHOD_NOTIFY, "*", (size_t) 1,
|
||||
"HOST: ", host, ":", SSDP_PORT,
|
||||
"CACHE-CONTROL: max-age=", duration,
|
||||
"LOCATION: ", location, "OPT: ",
|
||||
"\"http://schemas.upnp.org/upnp/1/0/\"; ns=01",
|
||||
"01-NLS: ", gUpnpSdkNLSuuid, "NT: ",
|
||||
nt, "NTS: ", nts, X_USER_AGENT,
|
||||
"USN: ", usn, "Powerstate: ",
|
||||
PowerState, "SleepPeriod: ",
|
||||
SleepPeriod, "RegistrationState: ",
|
||||
RegistrationState);
|
||||
} else {
|
||||
ret_code = http_MakeMessage(&buf, 1, 1,
|
||||
"Q" "sssdc" "sdc" "ssc" "ssc" "ssc"
|
||||
"ssc" "ssc" "S" "Xc" "sscc",
|
||||
HTTPMETHOD_NOTIFY, "*", (size_t) 1,
|
||||
@@ -369,6 +410,7 @@ static void CreateServicePacket(
|
||||
"01-NLS: ", gUpnpSdkNLSuuid, "NT: ",
|
||||
nt, "NTS: ", nts, X_USER_AGENT,
|
||||
"USN: ", usn);
|
||||
}
|
||||
if (ret_code)
|
||||
return;
|
||||
} else
|
||||
@@ -382,7 +424,8 @@ static void CreateServicePacket(
|
||||
}
|
||||
|
||||
int DeviceAdvertisement(char *DevType, int RootDev, char *Udn, char *Location,
|
||||
int Duration, int AddressFamily)
|
||||
int Duration, int AddressFamily, int PowerState,
|
||||
int SleepPeriod, int RegistrationState)
|
||||
{
|
||||
struct sockaddr_storage __ss;
|
||||
struct sockaddr_in *DestAddr4 = (struct sockaddr_in *)&__ss;
|
||||
@@ -419,14 +462,17 @@ int DeviceAdvertisement(char *DevType, int RootDev, char *Udn, char *Location,
|
||||
sprintf(Mil_Usn, "%s::upnp:rootdevice", Udn);
|
||||
CreateServicePacket(MSGTYPE_ADVERTISEMENT, "upnp:rootdevice",
|
||||
Mil_Usn, Location, Duration, &msgs[0],
|
||||
AddressFamily);
|
||||
AddressFamily, PowerState, SleepPeriod,
|
||||
RegistrationState);
|
||||
}
|
||||
/* both root and sub-devices need to send these two messages */
|
||||
CreateServicePacket(MSGTYPE_ADVERTISEMENT, Udn, Udn,
|
||||
Location, Duration, &msgs[1], AddressFamily);
|
||||
Location, Duration, &msgs[1], AddressFamily,
|
||||
PowerState, SleepPeriod, RegistrationState);
|
||||
sprintf(Mil_Usn, "%s::%s", Udn, DevType);
|
||||
CreateServicePacket(MSGTYPE_ADVERTISEMENT, DevType, Mil_Usn,
|
||||
Location, Duration, &msgs[2], AddressFamily);
|
||||
Location, Duration, &msgs[2], AddressFamily,
|
||||
PowerState, SleepPeriod, RegistrationState);
|
||||
/* check error */
|
||||
if ((RootDev && msgs[0] == NULL) || msgs[1] == NULL || msgs[2] == NULL) {
|
||||
free(msgs[0]);
|
||||
@@ -454,7 +500,8 @@ int DeviceAdvertisement(char *DevType, int RootDev, char *Udn, char *Location,
|
||||
}
|
||||
|
||||
int SendReply(struct sockaddr *DestAddr, char *DevType, int RootDev,
|
||||
char *Udn, char *Location, int Duration, int ByType)
|
||||
char *Udn, char *Location, int Duration, int ByType,
|
||||
int PowerState, int SleepPeriod, int RegistrationState)
|
||||
{
|
||||
int ret_code;
|
||||
char *msgs[2];
|
||||
@@ -471,7 +518,8 @@ int SendReply(struct sockaddr *DestAddr, char *DevType, int RootDev,
|
||||
sprintf(Mil_Usn, "%s::upnp:rootdevice", Udn);
|
||||
CreateServicePacket(MSGTYPE_REPLY, "upnp:rootdevice",
|
||||
Mil_Usn, Location, Duration, &msgs[0],
|
||||
DestAddr->sa_family);
|
||||
DestAddr->sa_family, PowerState,
|
||||
SleepPeriod, RegistrationState);
|
||||
} else {
|
||||
/* two msgs for embedded devices */
|
||||
num_msgs = 1;
|
||||
@@ -480,12 +528,14 @@ int SendReply(struct sockaddr *DestAddr, char *DevType, int RootDev,
|
||||
if (!ByType) {
|
||||
CreateServicePacket(MSGTYPE_REPLY, Udn, Udn, Location,
|
||||
Duration, &msgs[0],
|
||||
DestAddr->sa_family);
|
||||
DestAddr->sa_family, PowerState,
|
||||
SleepPeriod, RegistrationState);
|
||||
} else {
|
||||
sprintf(Mil_Usn, "%s::%s", Udn, DevType);
|
||||
CreateServicePacket(MSGTYPE_REPLY, DevType, Mil_Usn,
|
||||
Location, Duration, &msgs[0],
|
||||
DestAddr->sa_family);
|
||||
DestAddr->sa_family, PowerState,
|
||||
SleepPeriod, RegistrationState);
|
||||
}
|
||||
}
|
||||
/* check error */
|
||||
@@ -506,7 +556,8 @@ int SendReply(struct sockaddr *DestAddr, char *DevType, int RootDev,
|
||||
}
|
||||
|
||||
int DeviceReply(struct sockaddr *DestAddr, char *DevType, int RootDev,
|
||||
char *Udn, char *Location, int Duration)
|
||||
char *Udn, char *Location, int Duration, int PowerState,
|
||||
int SleepPeriod, int RegistrationState)
|
||||
{
|
||||
char *szReq[3], Mil_Nt[LINE_SIZE], Mil_Usn[LINE_SIZE];
|
||||
int RetVal;
|
||||
@@ -521,16 +572,19 @@ int DeviceReply(struct sockaddr *DestAddr, char *DevType, int RootDev,
|
||||
sprintf(Mil_Usn, "%s::upnp:rootdevice", Udn);
|
||||
CreateServicePacket(MSGTYPE_REPLY, Mil_Nt, Mil_Usn,
|
||||
Location, Duration, &szReq[0],
|
||||
DestAddr->sa_family);
|
||||
DestAddr->sa_family, PowerState,
|
||||
SleepPeriod, RegistrationState);
|
||||
}
|
||||
sprintf(Mil_Nt, "%s", Udn);
|
||||
sprintf(Mil_Usn, "%s", Udn);
|
||||
CreateServicePacket(MSGTYPE_REPLY, Mil_Nt, Mil_Usn,
|
||||
Location, Duration, &szReq[1], DestAddr->sa_family);
|
||||
Location, Duration, &szReq[1], DestAddr->sa_family,
|
||||
PowerState, SleepPeriod, RegistrationState);
|
||||
sprintf(Mil_Nt, "%s", DevType);
|
||||
sprintf(Mil_Usn, "%s::%s", Udn, DevType);
|
||||
CreateServicePacket(MSGTYPE_REPLY, Mil_Nt, Mil_Usn,
|
||||
Location, Duration, &szReq[2], DestAddr->sa_family);
|
||||
Location, Duration, &szReq[2], DestAddr->sa_family,
|
||||
PowerState, SleepPeriod, RegistrationState);
|
||||
/* check error */
|
||||
if ((RootDev && szReq[0] == NULL) ||
|
||||
szReq[1] == NULL || szReq[2] == NULL) {
|
||||
@@ -554,7 +608,8 @@ int DeviceReply(struct sockaddr *DestAddr, char *DevType, int RootDev,
|
||||
}
|
||||
|
||||
int ServiceAdvertisement(char *Udn, char *ServType, char *Location,
|
||||
int Duration, int AddressFamily)
|
||||
int Duration, int AddressFamily, int PowerState,
|
||||
int SleepPeriod, int RegistrationState)
|
||||
{
|
||||
char Mil_Usn[LINE_SIZE];
|
||||
char *szReq[1];
|
||||
@@ -583,7 +638,8 @@ int ServiceAdvertisement(char *Udn, char *ServType, char *Location,
|
||||
/* CreateServiceRequestPacket(1,szReq[0],Mil_Nt,Mil_Usn,
|
||||
* Server,Location,Duration); */
|
||||
CreateServicePacket(MSGTYPE_ADVERTISEMENT, ServType, Mil_Usn,
|
||||
Location, Duration, &szReq[0], AddressFamily);
|
||||
Location, Duration, &szReq[0], AddressFamily,
|
||||
PowerState, SleepPeriod, RegistrationState);
|
||||
if (szReq[0] == NULL) {
|
||||
return UPNP_E_OUTOF_MEMORY;
|
||||
}
|
||||
@@ -594,7 +650,8 @@ int ServiceAdvertisement(char *Udn, char *ServType, char *Location,
|
||||
}
|
||||
|
||||
int ServiceReply(struct sockaddr *DestAddr, char *ServType, char *Udn,
|
||||
char *Location, int Duration)
|
||||
char *Location, int Duration, int PowerState, int SleepPeriod,
|
||||
int RegistrationState)
|
||||
{
|
||||
char Mil_Usn[LINE_SIZE];
|
||||
char *szReq[1];
|
||||
@@ -603,7 +660,8 @@ int ServiceReply(struct sockaddr *DestAddr, char *ServType, char *Udn,
|
||||
szReq[0] = NULL;
|
||||
sprintf(Mil_Usn, "%s::%s", Udn, ServType);
|
||||
CreateServicePacket(MSGTYPE_REPLY, ServType, Mil_Usn,
|
||||
Location, Duration, &szReq[0], DestAddr->sa_family);
|
||||
Location, Duration, &szReq[0], DestAddr->sa_family,
|
||||
PowerState, SleepPeriod, RegistrationState);
|
||||
if (szReq[0] == NULL)
|
||||
return UPNP_E_OUTOF_MEMORY;
|
||||
RetVal = NewRequestHandler(DestAddr, 1, szReq);
|
||||
@@ -613,7 +671,8 @@ int ServiceReply(struct sockaddr *DestAddr, char *ServType, char *Udn,
|
||||
}
|
||||
|
||||
int ServiceShutdown(char *Udn, char *ServType, char *Location, int Duration,
|
||||
int AddressFamily)
|
||||
int AddressFamily, int PowerState, int SleepPeriod,
|
||||
int RegistrationState)
|
||||
{
|
||||
char Mil_Usn[LINE_SIZE];
|
||||
char *szReq[1];
|
||||
@@ -643,7 +702,8 @@ int ServiceShutdown(char *Udn, char *ServType, char *Location, int Duration,
|
||||
/* CreateServiceRequestPacket(0,szReq[0],Mil_Nt,Mil_Usn,
|
||||
* Server,Location,Duration); */
|
||||
CreateServicePacket(MSGTYPE_SHUTDOWN, ServType, Mil_Usn,
|
||||
Location, Duration, &szReq[0], AddressFamily);
|
||||
Location, Duration, &szReq[0], AddressFamily,
|
||||
PowerState, SleepPeriod, RegistrationState);
|
||||
if (szReq[0] == NULL)
|
||||
return UPNP_E_OUTOF_MEMORY;
|
||||
RetVal = NewRequestHandler((struct sockaddr *)&__ss, 1, szReq);
|
||||
@@ -653,7 +713,8 @@ int ServiceShutdown(char *Udn, char *ServType, char *Location, int Duration,
|
||||
}
|
||||
|
||||
int DeviceShutdown(char *DevType, int RootDev, char *Udn, char *_Server,
|
||||
char *Location, int Duration, int AddressFamily)
|
||||
char *Location, int Duration, int AddressFamily,
|
||||
int PowerState, int SleepPeriod, int RegistrationState)
|
||||
{
|
||||
struct sockaddr_storage __ss;
|
||||
struct sockaddr_in *DestAddr4 = (struct sockaddr_in *)&__ss;
|
||||
@@ -686,16 +747,19 @@ int DeviceShutdown(char *DevType, int RootDev, char *Udn, char *_Server,
|
||||
sprintf(Mil_Usn, "%s::upnp:rootdevice", Udn);
|
||||
CreateServicePacket(MSGTYPE_SHUTDOWN, "upnp:rootdevice",
|
||||
Mil_Usn, Location, Duration, &msgs[0],
|
||||
AddressFamily);
|
||||
AddressFamily, PowerState, SleepPeriod,
|
||||
RegistrationState);
|
||||
}
|
||||
UpnpPrintf(UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"In function DeviceShutdown\n");
|
||||
/* both root and sub-devices need to send these two messages */
|
||||
CreateServicePacket(MSGTYPE_SHUTDOWN, Udn, Udn,
|
||||
Location, Duration, &msgs[1], AddressFamily);
|
||||
Location, Duration, &msgs[1], AddressFamily,
|
||||
PowerState, SleepPeriod, RegistrationState);
|
||||
sprintf(Mil_Usn, "%s::%s", Udn, DevType);
|
||||
CreateServicePacket(MSGTYPE_SHUTDOWN, DevType, Mil_Usn,
|
||||
Location, Duration, &msgs[2], AddressFamily);
|
||||
Location, Duration, &msgs[2], AddressFamily,
|
||||
PowerState, SleepPeriod, RegistrationState);
|
||||
/* check error */
|
||||
if ((RootDev && msgs[0] == NULL) || msgs[1] == NULL || msgs[2] == NULL) {
|
||||
free(msgs[0]);
|
||||
|
@@ -2,6 +2,7 @@
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
* Copyright (C) 2011 France Telecom All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -205,26 +206,37 @@ int AdvertiseAndReply(int AdFlag, UpnpDevice_Handle Hnd,
|
||||
DeviceAdvertisement(devType, i == 0,
|
||||
UDNstr,
|
||||
SInfo->DescURL, Exp,
|
||||
SInfo->DeviceAf);
|
||||
SInfo->DeviceAf,
|
||||
SInfo->PowerState,
|
||||
SInfo->SleepPeriod,
|
||||
SInfo->RegistrationState);
|
||||
} else {
|
||||
/* AdFlag == -1 */
|
||||
DeviceShutdown(devType, i == 0, UDNstr,
|
||||
SERVER, SInfo->DescURL,
|
||||
Exp, SInfo->DeviceAf);
|
||||
Exp, SInfo->DeviceAf,
|
||||
SInfo->PowerState,
|
||||
SInfo->SleepPeriod,
|
||||
SInfo->RegistrationState);
|
||||
}
|
||||
} else {
|
||||
switch (SearchType) {
|
||||
case SSDP_ALL:
|
||||
DeviceReply(DestAddr, devType, i == 0,
|
||||
UDNstr, SInfo->DescURL,
|
||||
defaultExp);
|
||||
defaultExp, SInfo->PowerState,
|
||||
SInfo->SleepPeriod,
|
||||
SInfo->RegistrationState);
|
||||
break;
|
||||
case SSDP_ROOTDEVICE:
|
||||
if (i == 0) {
|
||||
SendReply(DestAddr, devType, 1,
|
||||
UDNstr,
|
||||
SInfo->DescURL,
|
||||
defaultExp, 0);
|
||||
defaultExp, 0,
|
||||
SInfo->PowerState,
|
||||
SInfo->SleepPeriod,
|
||||
SInfo->RegistrationState);
|
||||
}
|
||||
break;
|
||||
case SSDP_DEVICEUDN: {
|
||||
@@ -238,7 +250,10 @@ int AdvertiseAndReply(int AdFlag, UpnpDevice_Handle Hnd,
|
||||
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"DeviceUDN=%s and search UDN=%s MATCH\n",
|
||||
UDNstr, DeviceUDN);
|
||||
SendReply(DestAddr, devType, 0, UDNstr, SInfo->DescURL, defaultExp, 0);
|
||||
SendReply(DestAddr, devType, 0, UDNstr, SInfo->DescURL, defaultExp, 0,
|
||||
SInfo->PowerState,
|
||||
SInfo->SleepPeriod,
|
||||
SInfo->RegistrationState);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -254,14 +269,20 @@ int AdvertiseAndReply(int AdFlag, UpnpDevice_Handle Hnd,
|
||||
"DeviceType=%s and search devType=%s MATCH\n",
|
||||
devType, DeviceType);
|
||||
SendReply(DestAddr, DeviceType, 0, UDNstr, SInfo->LowerDescURL,
|
||||
defaultExp, 1);
|
||||
defaultExp, 1,
|
||||
SInfo->PowerState,
|
||||
SInfo->SleepPeriod,
|
||||
SInfo->RegistrationState);
|
||||
} else if (atoi(strrchr(DeviceType, ':') + 1)
|
||||
== atoi(&devType[strlen(devType) - 1])) {
|
||||
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"DeviceType=%s and search devType=%s MATCH\n",
|
||||
devType, DeviceType);
|
||||
SendReply(DestAddr, DeviceType, 0, UDNstr, SInfo->DescURL,
|
||||
defaultExp, 1);
|
||||
defaultExp, 1,
|
||||
SInfo->PowerState,
|
||||
SInfo->SleepPeriod,
|
||||
SInfo->RegistrationState);
|
||||
} else {
|
||||
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"DeviceType=%s and search devType=%s DID NOT MATCH\n",
|
||||
@@ -337,12 +358,18 @@ int AdvertiseAndReply(int AdFlag, UpnpDevice_Handle Hnd,
|
||||
if (AdFlag == 1) {
|
||||
ServiceAdvertisement(UDNstr,
|
||||
servType, SInfo->DescURL,
|
||||
Exp, SInfo->DeviceAf);
|
||||
Exp, SInfo->DeviceAf,
|
||||
SInfo->PowerState,
|
||||
SInfo->SleepPeriod,
|
||||
SInfo->RegistrationState);
|
||||
} else {
|
||||
/* AdFlag == -1 */
|
||||
ServiceShutdown(UDNstr,
|
||||
servType, SInfo->DescURL,
|
||||
Exp, SInfo->DeviceAf);
|
||||
Exp, SInfo->DeviceAf,
|
||||
SInfo->PowerState,
|
||||
SInfo->SleepPeriod,
|
||||
SInfo->RegistrationState);
|
||||
}
|
||||
} else {
|
||||
switch (SearchType) {
|
||||
@@ -350,7 +377,10 @@ int AdvertiseAndReply(int AdFlag, UpnpDevice_Handle Hnd,
|
||||
ServiceReply(DestAddr, servType,
|
||||
UDNstr,
|
||||
SInfo->DescURL,
|
||||
defaultExp);
|
||||
defaultExp,
|
||||
SInfo->PowerState,
|
||||
SInfo->SleepPeriod,
|
||||
SInfo->RegistrationState);
|
||||
break;
|
||||
case SSDP_SERVICE:
|
||||
if (ServiceType) {
|
||||
@@ -364,14 +394,20 @@ int AdvertiseAndReply(int AdFlag, UpnpDevice_Handle Hnd,
|
||||
"ServiceType=%s and search servType=%s MATCH\n",
|
||||
ServiceType, servType);
|
||||
SendReply(DestAddr, ServiceType, 0, UDNstr, SInfo->LowerDescURL,
|
||||
defaultExp, 1);
|
||||
defaultExp, 1,
|
||||
SInfo->PowerState,
|
||||
SInfo->SleepPeriod,
|
||||
SInfo->RegistrationState);
|
||||
} else if (atoi(strrchr (ServiceType, ':') + 1) ==
|
||||
atoi(&servType[strlen(servType) - 1])) {
|
||||
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"ServiceType=%s and search servType=%s MATCH\n",
|
||||
ServiceType, servType);
|
||||
SendReply(DestAddr, ServiceType, 0, UDNstr, SInfo->DescURL,
|
||||
defaultExp, 1);
|
||||
defaultExp, 1,
|
||||
SInfo->PowerState,
|
||||
SInfo->SleepPeriod,
|
||||
SInfo->RegistrationState);
|
||||
} else {
|
||||
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"ServiceType=%s and search servType=%s DID NOT MATCH\n",
|
||||
@@ -736,7 +772,7 @@ static int create_ssdp_sock_v4(
|
||||
struct in_addr addr;
|
||||
|
||||
*ssdpSock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (*ssdpSock == -1) {
|
||||
if (*ssdpSock == INVALID_SOCKET) {
|
||||
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
||||
UpnpPrintf(UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
||||
"Error in socket(): %s\n", errorBuffer);
|
||||
@@ -847,7 +883,7 @@ static int create_ssdp_sock_reqv4(
|
||||
u_char ttl = 4;
|
||||
|
||||
*ssdpReqSock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (*ssdpReqSock == -1) {
|
||||
if (*ssdpReqSock == INVALID_SOCKET) {
|
||||
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
||||
UpnpPrintf(UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
||||
"Error in socket(): %s\n", errorBuffer);
|
||||
@@ -877,7 +913,7 @@ static int create_ssdp_sock_v6(
|
||||
int ret = 0;
|
||||
|
||||
*ssdpSock = socket(AF_INET6, SOCK_DGRAM, 0);
|
||||
if (*ssdpSock == -1) {
|
||||
if (*ssdpSock == INVALID_SOCKET) {
|
||||
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
||||
UpnpPrintf(UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
||||
"Error in socket(): %s\n", errorBuffer);
|
||||
@@ -978,7 +1014,7 @@ static int create_ssdp_sock_v6_ula_gua(
|
||||
int ret = 0;
|
||||
|
||||
*ssdpSock = socket(AF_INET6, SOCK_DGRAM, 0);
|
||||
if (*ssdpSock == -1) {
|
||||
if (*ssdpSock == INVALID_SOCKET) {
|
||||
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
||||
UpnpPrintf(UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
||||
"Error in socket(): %s\n", errorBuffer);
|
||||
@@ -1076,7 +1112,7 @@ static int create_ssdp_sock_reqv6(
|
||||
char hops = 1;
|
||||
|
||||
*ssdpReqSock = socket(AF_INET6, SOCK_DGRAM, 0);
|
||||
if (*ssdpReqSock == -1) {
|
||||
if (*ssdpReqSock == INVALID_SOCKET) {
|
||||
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
||||
UpnpPrintf(UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
||||
"Error in socket(): %s\n", errorBuffer);
|
||||
|
@@ -106,7 +106,7 @@ void get_random_info(unsigned char seed[16])
|
||||
GetComputerName( r.hostname, &r.l );
|
||||
/* MD5 it */
|
||||
MD5Init(&c);
|
||||
MD5Update(&c, &r, sizeof r);
|
||||
MD5Update(&c, (unsigned char *)(&r), sizeof r);
|
||||
MD5Final(seed, &c);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user