- Fixed a bug in UpnpPrintf, function could call va_start() and return
befor calling va_end(). - Removed all uses of the DBGONLY(x) macro. A static inline empty function now is used and the compiler takes care of optimizing it out. git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@185 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
parent
4ceb6c67d1
commit
2c1dba2942
44
ChangeLog
44
ChangeLog
@ -1,6 +1,14 @@
|
|||||||
*************************************************************************
|
*******************************************************************************
|
||||||
Version 1.4.7
|
Version 1.4.7
|
||||||
*************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
|
2007-05-17 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Removed all uses of the DBGONLY(x) macro. A static inline empty
|
||||||
|
function now is used and the compiler takes care of optimizing it out.
|
||||||
|
|
||||||
|
2007-05-17 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Fixed a bug in UpnpPrintf, function could call va_start() and return
|
||||||
|
befor calling va_end().
|
||||||
|
|
||||||
2007-05-15 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
2007-05-15 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
* EXPORT_SPEC missing on some declarations in ixml/inc/ixml.h.
|
* EXPORT_SPEC missing on some declarations in ixml/inc/ixml.h.
|
||||||
@ -31,16 +39,16 @@ Version 1.4.7
|
|||||||
tarball and executes upnp_tv_device from its creation directory,
|
tarball and executes upnp_tv_device from its creation directory,
|
||||||
there will be no error -108 for not finding directory web.
|
there will be no error -108 for not finding directory web.
|
||||||
|
|
||||||
*************************************************************************
|
*******************************************************************************
|
||||||
Version 1.4.6
|
Version 1.4.6
|
||||||
*************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
2007-04-19 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
2007-04-19 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
* Fix for freebsd host_os in configure.ac.
|
* Fix for freebsd host_os in configure.ac.
|
||||||
|
|
||||||
*************************************************************************
|
*******************************************************************************
|
||||||
Version 1.4.5
|
Version 1.4.5
|
||||||
*************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
2007-04-19 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
2007-04-19 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
* Case insensitive comparison in raw_find_str() (httpparser.c) as
|
* Case insensitive comparison in raw_find_str() (httpparser.c) as
|
||||||
@ -66,9 +74,9 @@ Version 1.4.5
|
|||||||
(int instead of size_t) in combination with format "b" and "Q".
|
(int instead of size_t) in combination with format "b" and "Q".
|
||||||
The attached patch should fix this.
|
The attached patch should fix this.
|
||||||
|
|
||||||
*************************************************************************
|
*******************************************************************************
|
||||||
Version 1.4.4
|
Version 1.4.4
|
||||||
*************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
2007-04-06 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
2007-04-06 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
* SF Tracker [ 1695399 ] Typo in util.h
|
* SF Tracker [ 1695399 ] Typo in util.h
|
||||||
@ -103,9 +111,9 @@ Version 1.4.4
|
|||||||
Please note, that I enabled some extra debugging lines that were commented,
|
Please note, that I enabled some extra debugging lines that were commented,
|
||||||
in order to get more information. See attached files.
|
in order to get more information. See attached files.
|
||||||
|
|
||||||
*************************************************************************
|
*******************************************************************************
|
||||||
Version 1.4.3
|
Version 1.4.3
|
||||||
*************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
2007-03-13 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
2007-03-13 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
* SF Tracker [ 1663004 ] Compile on Cygwin
|
* SF Tracker [ 1663004 ] Compile on Cygwin
|
||||||
@ -140,9 +148,9 @@ Version 1.4.3
|
|||||||
|
|
||||||
* Fixed nasty segmentation fault bug on membuffer.c.
|
* Fixed nasty segmentation fault bug on membuffer.c.
|
||||||
|
|
||||||
*************************************************************************
|
*******************************************************************************
|
||||||
Version 1.4.2
|
Version 1.4.2
|
||||||
*************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
2007-02-09 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
2007-02-09 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
|
||||||
@ -244,9 +252,9 @@ Version 1.4.2
|
|||||||
* support for large files (>2 GBytes) added
|
* support for large files (>2 GBytes) added
|
||||||
|
|
||||||
|
|
||||||
*************************************************************************
|
*******************************************************************************
|
||||||
Version 1.4.1
|
Version 1.4.1
|
||||||
*************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
2006-07-07 Oxy <virtual_worlds(at)gmx.de>
|
2006-07-07 Oxy <virtual_worlds(at)gmx.de>
|
||||||
|
|
||||||
@ -277,9 +285,9 @@ Version 1.4.1
|
|||||||
* Patch to fix memory leaks and reasons for crashes added (thanks
|
* Patch to fix memory leaks and reasons for crashes added (thanks
|
||||||
to loigu)
|
to loigu)
|
||||||
|
|
||||||
*************************************************************************
|
*******************************************************************************
|
||||||
Version 1.4.0
|
Version 1.4.0
|
||||||
*************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
2006-05-26 Oxy <virtual_worlds(at)gmx.de>
|
2006-05-26 Oxy <virtual_worlds(at)gmx.de>
|
||||||
|
|
||||||
@ -305,9 +313,9 @@ Version 1.4.0
|
|||||||
|
|
||||||
* Bugfix for M-Search packet
|
* Bugfix for M-Search packet
|
||||||
|
|
||||||
*************************************************************************
|
*******************************************************************************
|
||||||
FORK FROM DEAD libupnp
|
FORK FROM DEAD libupnp
|
||||||
*************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
2006-04-29 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
2006-04-29 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* autoconfig.h. Generated by configure. */
|
/* autoconfig.h. Generated from autoconfig.h.in by configure. */
|
||||||
/* autoconfig.h.in. Generated from configure.ac by autoheader. */
|
/* autoconfig.h.in. Generated from configure.ac by autoheader. */
|
||||||
|
|
||||||
/* Define to 1 to compile debug code */
|
/* Define to 1 to compile debug code */
|
||||||
@ -19,15 +19,18 @@
|
|||||||
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
|
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
|
||||||
#define HAVE_FSEEKO 1
|
#define HAVE_FSEEKO 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `ftime' function. */
|
||||||
|
#define HAVE_FTIME 1
|
||||||
|
|
||||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
#define HAVE_INTTYPES_H 1
|
#define HAVE_INTTYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `compat' library (-lcompat). */
|
||||||
|
/* #undef HAVE_LIBCOMPAT */
|
||||||
|
|
||||||
/* Define to 1 if you have the <limits.h> header file. */
|
/* Define to 1 if you have the <limits.h> header file. */
|
||||||
#define HAVE_LIMITS_H 1
|
#define HAVE_LIMITS_H 1
|
||||||
|
|
||||||
/* Define to 1 if you have the <malloc.h> header file. */
|
|
||||||
#define HAVE_MALLOC_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <memory.h> header file. */
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
#define HAVE_MEMORY_H 1
|
#define HAVE_MEMORY_H 1
|
||||||
|
|
||||||
@ -92,19 +95,19 @@
|
|||||||
#define PACKAGE "libupnp"
|
#define PACKAGE "libupnp"
|
||||||
|
|
||||||
/* Define to the address where bug reports for this package should be sent. */
|
/* Define to the address where bug reports for this package should be sent. */
|
||||||
#define PACKAGE_BUGREPORT "virtual_worlds@gmx.de"
|
#define PACKAGE_BUGREPORT "mroberto@users.sourceforge.net"
|
||||||
|
|
||||||
/* Define to the full name of this package. */
|
/* Define to the full name of this package. */
|
||||||
#define PACKAGE_NAME "libupnp"
|
#define PACKAGE_NAME "libupnp"
|
||||||
|
|
||||||
/* Define to the full name and version of this package. */
|
/* Define to the full name and version of this package. */
|
||||||
#define PACKAGE_STRING "libupnp 1.4.0"
|
#define PACKAGE_STRING "libupnp 1.4.7"
|
||||||
|
|
||||||
/* Define to the one symbol short name of this package. */
|
/* Define to the one symbol short name of this package. */
|
||||||
#define PACKAGE_TARNAME "libupnp"
|
#define PACKAGE_TARNAME "libupnp"
|
||||||
|
|
||||||
/* Define to the version of this package. */
|
/* Define to the version of this package. */
|
||||||
#define PACKAGE_VERSION "1.4.0"
|
#define PACKAGE_VERSION "1.4.7"
|
||||||
|
|
||||||
/* Define to necessary symbol if this constant uses a non-standard name on
|
/* Define to necessary symbol if this constant uses a non-standard name on
|
||||||
your system. */
|
your system. */
|
||||||
@ -135,27 +138,30 @@
|
|||||||
#define UPNP_VERSION_MINOR 4
|
#define UPNP_VERSION_MINOR 4
|
||||||
|
|
||||||
/* see upnpconfig.h */
|
/* see upnpconfig.h */
|
||||||
#define UPNP_VERSION_PATCH 0
|
#define UPNP_VERSION_PATCH 7
|
||||||
|
|
||||||
/* see upnpconfig.h */
|
/* see upnpconfig.h */
|
||||||
#define UPNP_VERSION_STRING "1.4.0"
|
#define UPNP_VERSION_STRING "1.4.7"
|
||||||
|
|
||||||
/* Version number of package */
|
/* Version number of package */
|
||||||
#define VERSION "1.4.0"
|
#define VERSION "1.4.7"
|
||||||
|
|
||||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
/* File Offset size */
|
||||||
#define _FILE_OFFSET_BITS 64
|
#define _FILE_OFFSET_BITS 64
|
||||||
|
|
||||||
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
|
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
|
||||||
/* #undef _LARGEFILE_SOURCE */
|
/* #undef _LARGEFILE_SOURCE */
|
||||||
|
|
||||||
/* Define for large files, on AIX-style hosts. */
|
/* Large files support */
|
||||||
/* #undef _LARGE_FILES */
|
#define _LARGE_FILE_SOURCE
|
||||||
|
|
||||||
/* Define to empty if `const' does not conform to ANSI C. */
|
/* Define to empty if `const' does not conform to ANSI C. */
|
||||||
/* #undef const */
|
/* #undef const */
|
||||||
|
|
||||||
/* Define to `unsigned' if <sys/types.h> does not define. */
|
/* Define to `long int' if <sys/types.h> does not define. */
|
||||||
|
/* #undef off_t */
|
||||||
|
|
||||||
|
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||||
/* #undef size_t */
|
/* #undef size_t */
|
||||||
|
|
||||||
/* Substitute for socklen_t */
|
/* Substitute for socklen_t */
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
|
|
||||||
#include "autoconfig.h"
|
#include "autoconfig.h"
|
||||||
|
|
||||||
#define MAX_JOBS_TOTAL 10
|
|
||||||
|
|
||||||
/** @name Compile time configuration options
|
/** @name Compile time configuration options
|
||||||
* The Linux SDK for UPnP Devices contains some compile-time parameters
|
* The Linux SDK for UPnP Devices contains some compile-time parameters
|
||||||
@ -96,6 +95,17 @@
|
|||||||
#define MAX_THREADS 12
|
#define MAX_THREADS 12
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
/** @name MAX_JOBS_TOTAL
|
||||||
|
* The {\tt MAX_JOBS_TOTAL} constant determines the maximum number of jobs
|
||||||
|
* that can be queued. If this limit is reached further jobs will be thrown
|
||||||
|
* to avoid memory exhaustion. The default value 100.
|
||||||
|
* (Added by Axis.)
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@{
|
||||||
|
#define MAX_JOBS_TOTAL 100
|
||||||
|
//@}
|
||||||
|
|
||||||
/** @name DEFAULT_SOAP_CONTENT_LENGTH
|
/** @name DEFAULT_SOAP_CONTENT_LENGTH
|
||||||
* SOAP messages will read at most {\tt DEFAULT_SOAP_CONTENT_LENGTH} bytes.
|
* SOAP messages will read at most {\tt DEFAULT_SOAP_CONTENT_LENGTH} bytes.
|
||||||
* This prevents devices that have a misbehaving web server to send
|
* This prevents devices that have a misbehaving web server to send
|
||||||
@ -294,68 +304,46 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** @name DBGONLY
|
|
||||||
The {\bf DBGONLY} macro allows code to be marked so that it
|
|
||||||
is only included in the DEBUG build and not the release. To
|
|
||||||
use this macro, put the code inside of the parentheses:
|
|
||||||
|
|
||||||
{\tt DBGONLY(int i;)}
|
|
||||||
|
|
||||||
This will cause a declaration of the integer {\tt i} only
|
|
||||||
in the debug build.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//@{
|
|
||||||
#ifdef DEBUG
|
|
||||||
#define DBGONLY(x) x
|
|
||||||
#else
|
|
||||||
#define DBGONLY(x)
|
|
||||||
#endif
|
|
||||||
//@}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#undef EXCLUDE_WEB_SERVER
|
#undef EXCLUDE_WEB_SERVER
|
||||||
#undef EXCLUDE_MINISERVER
|
#undef EXCLUDE_MINISERVER
|
||||||
#ifdef INTERNAL_WEB_SERVER
|
#ifdef INTERNAL_WEB_SERVER
|
||||||
#define EXCLUDE_WEB_SERVER 0
|
# define EXCLUDE_WEB_SERVER 0
|
||||||
#define EXCLUDE_MINISERVER 0
|
# define EXCLUDE_MINISERVER 0
|
||||||
#else
|
#else
|
||||||
#define EXCLUDE_WEB_SERVER 1
|
# define EXCLUDE_WEB_SERVER 1
|
||||||
#define EXCLUDE_MINISERVER 1
|
# define EXCLUDE_MINISERVER 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if EXCLUDE_GENA == 1 && EXCLUDE_SOAP == 1 && EXCLUDE_WEB_SERVER == 1
|
#if EXCLUDE_GENA == 1 && EXCLUDE_SOAP == 1 && EXCLUDE_WEB_SERVER == 1
|
||||||
#undef EXCLUDE_MINISERVER
|
# undef EXCLUDE_MINISERVER
|
||||||
#define EXCLUDE_MINISERVER 1
|
# define EXCLUDE_MINISERVER 1
|
||||||
#if INTERNAL_WEB_SERVER
|
# if INTERNAL_WEB_SERVER
|
||||||
# error "conflicting settings: use configure --disable-webserver"
|
# error "conflicting settings: use configure --disable-webserver"
|
||||||
#endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if EXCLUDE_GENA == 0 || EXCLUDE_SOAP == 0 || EXCLUDE_WEB_SERVER == 0
|
#if EXCLUDE_GENA == 0 || EXCLUDE_SOAP == 0 || EXCLUDE_WEB_SERVER == 0
|
||||||
#undef EXCLUDE_MINISERVER
|
# undef EXCLUDE_MINISERVER
|
||||||
#define EXCLUDE_MINISERVER 0
|
# define EXCLUDE_MINISERVER 0
|
||||||
#if EXCLUDE_WEB_SERVER == 0 && !defined INTERNAL_WEB_SERVER
|
# if EXCLUDE_WEB_SERVER == 0 && !defined INTERNAL_WEB_SERVER
|
||||||
#error "conflicting settings : use configure --enable-webserver"
|
# error "conflicting settings : use configure --enable-webserver"
|
||||||
#endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef INCLUDE_CLIENT_APIS
|
#ifdef INCLUDE_CLIENT_APIS
|
||||||
#define CLIENTONLY(x) x
|
# define CLIENTONLY(x) x
|
||||||
#else
|
#else
|
||||||
#define CLIENTONLY(x)
|
# define CLIENTONLY(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef INCLUDE_DEVICE_APIS
|
#ifdef INCLUDE_DEVICE_APIS
|
||||||
#define DEVICEONLY(x) x
|
# define DEVICEONLY(x) x
|
||||||
#else
|
#else
|
||||||
#define DEVICEONLY(x)
|
# define DEVICEONLY(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* upnp/inc/upnpconfig.h. Generated by configure. */
|
/* upnp/inc/upnpconfig.h. Generated from upnpconfig.h.in by configure. */
|
||||||
// -*- C -*-
|
// -*- C -*-
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@ -40,7 +40,7 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
/** The library version (string) e.g. "1.3.0" */
|
/** The library version (string) e.g. "1.3.0" */
|
||||||
#define UPNP_VERSION_STRING "1.4.0"
|
#define UPNP_VERSION_STRING "1.4.7"
|
||||||
|
|
||||||
/** Major version of the library */
|
/** Major version of the library */
|
||||||
#define UPNP_VERSION_MAJOR 1
|
#define UPNP_VERSION_MAJOR 1
|
||||||
@ -49,7 +49,7 @@
|
|||||||
#define UPNP_VERSION_MINOR 4
|
#define UPNP_VERSION_MINOR 4
|
||||||
|
|
||||||
/** Patch version of the library */
|
/** Patch version of the library */
|
||||||
#define UPNP_VERSION_PATCH 0
|
#define UPNP_VERSION_PATCH 7
|
||||||
|
|
||||||
/** The library version (numeric) e.g. 10300 means version 1.3.0 */
|
/** The library version (numeric) e.g. 10300 means version 1.3.0 */
|
||||||
#define UPNP_VERSION \
|
#define UPNP_VERSION \
|
||||||
@ -69,7 +69,7 @@
|
|||||||
|
|
||||||
/** Defined to 1 if the library has been compiled with DEBUG enabled
|
/** Defined to 1 if the library has been compiled with DEBUG enabled
|
||||||
* (i.e. configure --enable-debug) : <upnp/upnpdebug.h> file is available */
|
* (i.e. configure --enable-debug) : <upnp/upnpdebug.h> file is available */
|
||||||
#undef UPNP_HAVE_DEBUG
|
/* #undef UPNP_HAVE_DEBUG */
|
||||||
|
|
||||||
|
|
||||||
/** Defined to 1 if the library has been compiled with client API enabled
|
/** Defined to 1 if the library has been compiled with client API enabled
|
||||||
|
@ -82,15 +82,6 @@ typedef enum priority {LOW_PRIORITY,
|
|||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//DEBUGGING
|
|
||||||
#ifndef WIN32
|
|
||||||
#ifdef DEBUG
|
|
||||||
#define DBGONLY(x) x
|
|
||||||
#else
|
|
||||||
#define DBGONLY(x)
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "LinkedList.h"
|
#include "LinkedList.h"
|
||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
#include "FreeList.h"
|
#include "FreeList.h"
|
||||||
|
@ -52,9 +52,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "ixml.h"
|
#include "ixml.h"
|
||||||
#include "upnpconfig.h"
|
#include "upnpconfig.h"
|
||||||
#if UPNP_HAVE_DEBUG
|
|
||||||
#include "upnpdebug.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@ -489,6 +486,8 @@
|
|||||||
#define INOUT
|
#define INOUT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "upnpdebug.h"
|
||||||
|
|
||||||
enum UpnpOpenFileMode{UPNP_READ, UPNP_WRITE};
|
enum UpnpOpenFileMode{UPNP_READ, UPNP_WRITE};
|
||||||
|
|
||||||
/// @name Constants, Structures, and Types
|
/// @name Constants, Structures, and Types
|
||||||
|
@ -33,11 +33,9 @@
|
|||||||
#ifndef UPNP_DEBUG_H
|
#ifndef UPNP_DEBUG_H
|
||||||
#define UPNP_DEBUG_H
|
#define UPNP_DEBUG_H
|
||||||
|
|
||||||
|
#include "upnp.h"
|
||||||
#include "upnpconfig.h"
|
#include "upnpconfig.h"
|
||||||
|
|
||||||
// Function declarations only if debug compiled into the library
|
|
||||||
#if UPNP_HAVE_DEBUG
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -70,7 +68,17 @@ extern "C" {
|
|||||||
* \end{itemize}
|
* \end{itemize}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef enum Upnp_Module {SSDP,SOAP,GENA,TPOOL,MSERV,DOM,API, HTTP} Dbg_Module;
|
typedef enum Upnp_Module {
|
||||||
|
SSDP,
|
||||||
|
SOAP,
|
||||||
|
GENA,
|
||||||
|
TPOOL,
|
||||||
|
MSERV,
|
||||||
|
DOM,
|
||||||
|
API,
|
||||||
|
HTTP
|
||||||
|
} Dbg_Module;
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
typedef enum Upnp_LogLevel_e {
|
typedef enum Upnp_LogLevel_e {
|
||||||
UPNP_CRITICAL,
|
UPNP_CRITICAL,
|
||||||
@ -102,7 +110,11 @@ typedef enum Upnp_LogLevel_e {
|
|||||||
* -1 : If fails
|
* -1 : If fails
|
||||||
* UPNP_E_SUCCESS : if success
|
* UPNP_E_SUCCESS : if success
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
#ifdef DEBUG
|
||||||
int UpnpInitLog();
|
int UpnpInitLog();
|
||||||
|
#else
|
||||||
|
static inline int UpnpInitLog() { return UPNP_E_SUCCESS; }
|
||||||
|
#endif
|
||||||
|
|
||||||
// for backward compatibility
|
// for backward compatibility
|
||||||
#define InitLog UpnpInitLog
|
#define InitLog UpnpInitLog
|
||||||
@ -111,13 +123,17 @@ int UpnpInitLog();
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Function : UpnpSetLogLevel
|
* Function : UpnpSetLogLevel
|
||||||
*
|
*
|
||||||
* Parameters: void
|
* Parameters: Upnp_LogLevel log_level
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* This functions set the log level (see {\tt Upnp_LogLevel}
|
* This functions set the log level (see {\tt Upnp_LogLevel}
|
||||||
* Returns: void
|
* Returns: void
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
void UpnpSetLogLevel (Upnp_LogLevel);
|
#ifdef DEBUG
|
||||||
|
void UpnpSetLogLevel(Upnp_LogLevel log_level);
|
||||||
|
#else
|
||||||
|
static inline void UpnpSetLogLevel(Upnp_LogLevel log_level) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
@ -129,7 +145,11 @@ void UpnpSetLogLevel (Upnp_LogLevel);
|
|||||||
* This functions closes the log files
|
* This functions closes the log files
|
||||||
* Returns: void
|
* Returns: void
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
#ifdef DEBUG
|
||||||
void UpnpCloseLog();
|
void UpnpCloseLog();
|
||||||
|
#else
|
||||||
|
static inline void UpnpCloseLog() {}
|
||||||
|
#endif
|
||||||
|
|
||||||
// for backward compatibility
|
// for backward compatibility
|
||||||
#define CloseLog UpnpCloseLog
|
#define CloseLog UpnpCloseLog
|
||||||
@ -149,7 +169,15 @@ void UpnpCloseLog();
|
|||||||
* per the requested banner
|
* per the requested banner
|
||||||
* Returns: void
|
* Returns: void
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
void UpnpSetLogFileNames (const char* ErrFileName, const char* InfoFileName);
|
#ifdef DEBUG
|
||||||
|
void UpnpSetLogFileNames(
|
||||||
|
const char *ErrFileName,
|
||||||
|
const char *InfoFileName);
|
||||||
|
#else
|
||||||
|
static inline void UpnpSetLogFileNames(
|
||||||
|
const char *ErrFileName,
|
||||||
|
const char *InfoFileName) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
// for backward compatibility
|
// for backward compatibility
|
||||||
#define SetLogFileNames UpnpSetLogFileNames
|
#define SetLogFileNames UpnpSetLogFileNames
|
||||||
@ -171,12 +199,45 @@ void UpnpSetLogFileNames (const char* ErrFileName, const char* InfoFileName);
|
|||||||
* NULL : if the module is turn off for debug
|
* NULL : if the module is turn off for debug
|
||||||
* else returns the right file descriptor
|
* else returns the right file descriptor
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
FILE* UpnpGetDebugFile (Upnp_LogLevel level, Dbg_Module module);
|
#ifdef DEBUG
|
||||||
|
FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module);
|
||||||
|
#else
|
||||||
|
static inline FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// for backward compatibility
|
// for backward compatibility
|
||||||
#define GetDebugFile UpnpGetDebugFile
|
#define GetDebugFile UpnpGetDebugFile
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* Function : DebugAtThisLevel
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* IN Dbg_Level DLevel: The level of the debug logging. It will decide
|
||||||
|
* whether debug statement will go to standard output,
|
||||||
|
* or any of the log files.
|
||||||
|
* IN Dbg_Module Module: debug will go in the name of this module
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This functions returns true if debug output should be done in this
|
||||||
|
* module.
|
||||||
|
*
|
||||||
|
* Returns: int
|
||||||
|
***************************************************************************/
|
||||||
|
#ifdef DEBUG
|
||||||
|
int DebugAtThisLevel(
|
||||||
|
IN Upnp_LogLevel DLevel,
|
||||||
|
IN Dbg_Module Module);
|
||||||
|
#else
|
||||||
|
static inline int DebugAtThisLevel(
|
||||||
|
IN Upnp_LogLevel DLevel,
|
||||||
|
IN Dbg_Module Module) { return 0; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Function : UpnpPrintf
|
* Function : UpnpPrintf
|
||||||
*
|
*
|
||||||
@ -198,6 +259,7 @@ FILE* UpnpGetDebugFile (Upnp_LogLevel level, Dbg_Module module);
|
|||||||
* debug statement is coming
|
* debug statement is coming
|
||||||
* Returns: void
|
* Returns: void
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
#ifdef DEBUG
|
||||||
void UpnpPrintf (Upnp_LogLevel DLevel, Dbg_Module Module,
|
void UpnpPrintf (Upnp_LogLevel DLevel, Dbg_Module Module,
|
||||||
const char* DbgFileName, int DbgLineNo,
|
const char* DbgFileName, int DbgLineNo,
|
||||||
const char* FmtStr,
|
const char* FmtStr,
|
||||||
@ -206,6 +268,15 @@ void UpnpPrintf (Upnp_LogLevel DLevel, Dbg_Module Module,
|
|||||||
__attribute__((format (__printf__, 5, 6)))
|
__attribute__((format (__printf__, 5, 6)))
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
#else
|
||||||
|
static inline void UpnpPrintf(
|
||||||
|
Upnp_LogLevel DLevel,
|
||||||
|
Dbg_Module Module,
|
||||||
|
const char* DbgFileName,
|
||||||
|
int DbgLineNo,
|
||||||
|
const char* FmtStr,
|
||||||
|
...) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
@ -222,8 +293,19 @@ void UpnpPrintf (Upnp_LogLevel DLevel, Dbg_Module Module,
|
|||||||
* per the requested banner
|
* per the requested banner
|
||||||
* Returns: void
|
* Returns: void
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
void UpnpDisplayBanner (FILE *fd,
|
#ifdef DEBUG
|
||||||
const char** lines, size_t size, int starlength);
|
void UpnpDisplayBanner(
|
||||||
|
FILE *fd,
|
||||||
|
const char **lines,
|
||||||
|
size_t size,
|
||||||
|
int starlength);
|
||||||
|
#else
|
||||||
|
static inline void UpnpDisplayBanner(
|
||||||
|
FILE *fd,
|
||||||
|
const char **lines,
|
||||||
|
size_t size,
|
||||||
|
int starlength) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
@ -240,19 +322,23 @@ void UpnpDisplayBanner (FILE *fd,
|
|||||||
* debug statement is coming to the log file
|
* debug statement is coming to the log file
|
||||||
* Returns: void
|
* Returns: void
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
void UpnpDisplayFileAndLine (FILE *fd, const char *DbgFileName, int DbgLineNo);
|
#ifdef DEBUG
|
||||||
|
void UpnpDisplayFileAndLine(
|
||||||
|
FILE *fd,
|
||||||
|
const char *DbgFileName,
|
||||||
|
int DbgLineNo);
|
||||||
|
#else
|
||||||
|
static inline void UpnpDisplayFileAndLine(
|
||||||
|
FILE *fd,
|
||||||
|
const char *DbgFileName,
|
||||||
|
int DbgLineNo) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // UPNP_HAVE_DEBUG
|
|
||||||
|
|
||||||
#endif // UPNP_DEBUG_H
|
#endif // UPNP_DEBUG_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -116,7 +116,7 @@ UpnpInitLog( )
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Function : UpnpSetLogLevel
|
* Function : UpnpSetLogLevel
|
||||||
*
|
*
|
||||||
* Parameters: void
|
* Parameters: Upnp_LogLevel log_level
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* This functions set the log level (see {\tt Upnp_LogLevel}
|
* This functions set the log level (see {\tt Upnp_LogLevel}
|
||||||
@ -152,6 +152,42 @@ UpnpCloseLog( )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* Function : DebugAtThisLevel
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* IN Dbg_Level DLevel: The level of the debug logging. It will decide
|
||||||
|
* whether debug statement will go to standard output,
|
||||||
|
* or any of the log files.
|
||||||
|
* IN Dbg_Module Module: debug will go in the name of this module
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This functions returns true if debug output should be done in this
|
||||||
|
* module.
|
||||||
|
*
|
||||||
|
* Returns: int
|
||||||
|
***************************************************************************/
|
||||||
|
#ifdef DEBUG
|
||||||
|
int DebugAtThisLevel(
|
||||||
|
IN Upnp_LogLevel DLevel,
|
||||||
|
IN Dbg_Module Module)
|
||||||
|
{
|
||||||
|
int ret = g_log_level >= DLevel;
|
||||||
|
ret &=
|
||||||
|
DEBUG_ALL ||
|
||||||
|
(Module == SSDP && DEBUG_SSDP ) ||
|
||||||
|
(Module == SOAP && DEBUG_SOAP ) ||
|
||||||
|
(Module == GENA && DEBUG_GENA ) ||
|
||||||
|
(Module == TPOOL && DEBUG_TPOOL) ||
|
||||||
|
(Module == MSERV && DEBUG_MSERV) ||
|
||||||
|
(Module == DOM && DEBUG_DOM ) ||
|
||||||
|
(Module == HTTP && DEBUG_HTTP );
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Function : UpnpPrintf
|
* Function : UpnpPrintf
|
||||||
*
|
*
|
||||||
@ -173,64 +209,46 @@ UpnpCloseLog( )
|
|||||||
* statement is coming
|
* statement is coming
|
||||||
* Returns: void
|
* Returns: void
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
DBGONLY( void UpnpPrintf( IN Upnp_LogLevel DLevel,
|
#ifdef DEBUG
|
||||||
|
void UpnpPrintf(
|
||||||
|
IN Upnp_LogLevel DLevel,
|
||||||
IN Dbg_Module Module,
|
IN Dbg_Module Module,
|
||||||
IN const char *DbgFileName,
|
IN const char *DbgFileName,
|
||||||
IN int DbgLineNo,
|
IN int DbgLineNo,
|
||||||
IN const char *FmtStr,
|
IN const char *FmtStr,
|
||||||
... ) {
|
... )
|
||||||
|
{
|
||||||
va_list ArgList;
|
va_list ArgList;
|
||||||
va_start( ArgList, FmtStr );
|
|
||||||
if( g_log_level < DLevel ) return; if( DEBUG_ALL == 0 ) {
|
if (!DebugAtThisLevel(DLevel, Module)) {
|
||||||
switch ( Module ) {
|
return;
|
||||||
case SSDP:
|
|
||||||
if( DEBUG_SSDP == 1 ) break;
|
|
||||||
else
|
|
||||||
return; case SOAP:
|
|
||||||
if( DEBUG_SOAP == 1 ) break;
|
|
||||||
else
|
|
||||||
return; case GENA:
|
|
||||||
if( DEBUG_GENA == 1 ) break;
|
|
||||||
else
|
|
||||||
return; case TPOOL:
|
|
||||||
if( DEBUG_TPOOL == 1 ) break;
|
|
||||||
else
|
|
||||||
return; case MSERV:
|
|
||||||
if( DEBUG_MSERV == 1 ) break;
|
|
||||||
else
|
|
||||||
return; case DOM:
|
|
||||||
if( DEBUG_DOM == 1 ) break;
|
|
||||||
else
|
|
||||||
return; case HTTP:
|
|
||||||
if( DEBUG_HTTP == 1 ) break;
|
|
||||||
else
|
|
||||||
return; case API:
|
|
||||||
if( DEBUG_API == 1 ) break;
|
|
||||||
else
|
|
||||||
return; default:
|
|
||||||
return;}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ithread_mutex_lock( &GlobalDebugMutex ); if( DEBUG_TARGET == 0 ) {
|
ithread_mutex_lock(&GlobalDebugMutex);
|
||||||
|
va_start(ArgList, FmtStr);
|
||||||
|
if (!DEBUG_TARGET) {
|
||||||
if( DbgFileName ) {
|
if( DbgFileName ) {
|
||||||
UpnpDisplayFileAndLine( stdout, DbgFileName, DbgLineNo );}
|
UpnpDisplayFileAndLine(stdout, DbgFileName, DbgLineNo);
|
||||||
vfprintf( stdout, FmtStr, ArgList ); fflush( stdout );}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( DLevel == 0 ) {
|
|
||||||
if( DbgFileName ) {
|
|
||||||
UpnpDisplayFileAndLine( ErrFileHnd, DbgFileName, DbgLineNo );}
|
|
||||||
vfprintf( ErrFileHnd, FmtStr, ArgList ); fflush( ErrFileHnd );}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( DbgFileName ) {
|
|
||||||
UpnpDisplayFileAndLine( InfoFileHnd, DbgFileName, DbgLineNo );}
|
|
||||||
vfprintf( InfoFileHnd, FmtStr, ArgList ); fflush( InfoFileHnd );}
|
|
||||||
}
|
}
|
||||||
va_end( ArgList ); ithread_mutex_unlock( &GlobalDebugMutex );}
|
vfprintf(stdout, FmtStr, ArgList);
|
||||||
|
fflush(stdout);
|
||||||
)
|
} else if (DLevel == 0) {
|
||||||
|
if (DbgFileName) {
|
||||||
|
UpnpDisplayFileAndLine(ErrFileHnd, DbgFileName, DbgLineNo);
|
||||||
|
}
|
||||||
|
vfprintf(ErrFileHnd, FmtStr, ArgList);
|
||||||
|
fflush(ErrFileHnd);
|
||||||
|
} else {
|
||||||
|
if (DbgFileName) {
|
||||||
|
UpnpDisplayFileAndLine(InfoFileHnd, DbgFileName, DbgLineNo);
|
||||||
|
}
|
||||||
|
vfprintf(InfoFileHnd, FmtStr, ArgList);
|
||||||
|
fflush(InfoFileHnd);
|
||||||
|
}
|
||||||
|
va_end(ArgList);
|
||||||
|
ithread_mutex_unlock(&GlobalDebugMutex);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
@ -249,46 +267,26 @@ return; default:
|
|||||||
* NULL : if the module is turn off for debug
|
* NULL : if the module is turn off for debug
|
||||||
* else returns the right file descriptor
|
* else returns the right file descriptor
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
DBGONLY( FILE * GetDebugFile( Upnp_LogLevel DLevel, Dbg_Module Module ) {
|
#ifdef DEBUG
|
||||||
if( g_log_level < DLevel ) return NULL; if( DEBUG_ALL == 0 ) {
|
FILE *GetDebugFile( Upnp_LogLevel DLevel, Dbg_Module Module )
|
||||||
switch ( Module ) {
|
{
|
||||||
case SSDP:
|
FILE *ret;
|
||||||
if( DEBUG_SSDP == 1 ) break;
|
|
||||||
else
|
if (!DebugAtThisLevel(DLevel, Module)) {
|
||||||
return NULL; case SOAP:
|
ret = NULL;
|
||||||
if( DEBUG_SOAP == 1 ) break;
|
|
||||||
else
|
|
||||||
return NULL; case GENA:
|
|
||||||
if( DEBUG_GENA == 1 ) break;
|
|
||||||
else
|
|
||||||
return NULL; case TPOOL:
|
|
||||||
if( DEBUG_TPOOL == 1 ) break;
|
|
||||||
else
|
|
||||||
return NULL; case MSERV:
|
|
||||||
if( DEBUG_MSERV == 1 ) break;
|
|
||||||
else
|
|
||||||
return NULL; case DOM:
|
|
||||||
if( DEBUG_DOM == 1 ) break;
|
|
||||||
else
|
|
||||||
return NULL; case API:
|
|
||||||
if( DEBUG_API == 1 ) break;
|
|
||||||
else
|
|
||||||
return NULL; default:
|
|
||||||
return NULL;}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( DEBUG_TARGET == 0 ) {
|
if (!DEBUG_TARGET) {
|
||||||
return stdout;}
|
ret = stdout;
|
||||||
else
|
} else if (DLevel == 0) {
|
||||||
{
|
ret = ErrFileHnd;
|
||||||
if( DLevel == 0 ) {
|
} else {
|
||||||
return ErrFileHnd;}
|
ret = InfoFileHnd;
|
||||||
else
|
|
||||||
{
|
|
||||||
return InfoFileHnd;}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
)
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
@ -305,17 +303,26 @@ return NULL; default:
|
|||||||
* debug statement is coming to the log file
|
* debug statement is coming to the log file
|
||||||
* Returns: void
|
* Returns: void
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
DBGONLY( void UpnpDisplayFileAndLine( IN FILE * fd,
|
#ifdef DEBUG
|
||||||
|
void UpnpDisplayFileAndLine(
|
||||||
|
IN FILE * fd,
|
||||||
IN const char *DbgFileName,
|
IN const char *DbgFileName,
|
||||||
IN int DbgLineNo ) {
|
IN int DbgLineNo)
|
||||||
|
{
|
||||||
int starlength = 66;
|
int starlength = 66;
|
||||||
const char *lines[2];
|
const char *lines[2];
|
||||||
char FileAndLine[500]; lines[0] = "DEBUG"; if( DbgFileName ) {
|
char FileAndLine[500];
|
||||||
sprintf( FileAndLine, "FILE: %s, LINE: %d", DbgFileName,
|
lines[0] = "DEBUG";
|
||||||
DbgLineNo ); lines[1] = FileAndLine;}
|
if (DbgFileName) {
|
||||||
|
sprintf(FileAndLine,
|
||||||
UpnpDisplayBanner( fd, lines, 2, starlength ); fflush( fd );}
|
"FILE: %s, LINE: %d",
|
||||||
)
|
DbgFileName, DbgLineNo);
|
||||||
|
lines[1] = FileAndLine;
|
||||||
|
}
|
||||||
|
UpnpDisplayBanner(fd, lines, 2, starlength);
|
||||||
|
fflush(fd);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
@ -332,47 +339,58 @@ return NULL; default:
|
|||||||
* per the requested banner
|
* per the requested banner
|
||||||
* Returns: void
|
* Returns: void
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
DBGONLY( void UpnpDisplayBanner( IN FILE * fd,
|
#ifdef DEBUG
|
||||||
|
void UpnpDisplayBanner(
|
||||||
|
IN FILE * fd,
|
||||||
IN const char **lines,
|
IN const char **lines,
|
||||||
IN size_t size,
|
IN size_t size,
|
||||||
IN int starLength ) {
|
IN int starLength)
|
||||||
char *stars = ( char * )malloc( starLength + 1 );
|
{
|
||||||
const char *line = NULL;
|
|
||||||
int leftMarginLength = starLength / 2 + 1;
|
int leftMarginLength = starLength / 2 + 1;
|
||||||
int rightMarginLength = starLength / 2 + 1;
|
int rightMarginLength = starLength / 2 + 1;
|
||||||
char *leftMargin = ( char * )malloc( leftMarginLength );
|
|
||||||
char *rightMargin = ( char * )malloc( rightMarginLength );
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int LineSize = 0;
|
int LineSize = 0;
|
||||||
|
int starLengthMinus2 = starLength - 2;
|
||||||
|
|
||||||
|
char *leftMargin = ( char * )malloc( leftMarginLength );
|
||||||
|
char *rightMargin = ( char * )malloc( rightMarginLength );
|
||||||
|
char *stars = ( char * )malloc( starLength + 1 );
|
||||||
char *currentLine = ( char * )malloc( starLength + 1 );
|
char *currentLine = ( char * )malloc( starLength + 1 );
|
||||||
|
const char *line = NULL;
|
||||||
|
|
||||||
memset( stars, '*', starLength );
|
memset( stars, '*', starLength );
|
||||||
stars[starLength] = 0;
|
stars[starLength] = 0;
|
||||||
memset( leftMargin, 0, leftMarginLength );
|
memset( leftMargin, 0, leftMarginLength );
|
||||||
memset( rightMargin, 0, rightMarginLength );
|
memset( rightMargin, 0, rightMarginLength );
|
||||||
fprintf( fd, "\n%s\n", stars ); for( i = 0; i < size; i++ ) {
|
fprintf( fd, "\n%s\n", stars );
|
||||||
|
for( i = 0; i < size; i++ ) {
|
||||||
LineSize = strlen( lines[i] );
|
LineSize = strlen( lines[i] );
|
||||||
line = lines[i]; while( LineSize > ( starLength - 2 ) ) {
|
line = lines[i];
|
||||||
memcpy( currentLine, line, ( starLength - 2 ) );
|
while( LineSize > starLengthMinus2 ) {
|
||||||
currentLine[( starLength - 2 )] = 0;
|
memcpy( currentLine, line, starLengthMinus2 );
|
||||||
|
currentLine[starLengthMinus2] = 0;
|
||||||
fprintf( fd, "*%s*\n", currentLine );
|
fprintf( fd, "*%s*\n", currentLine );
|
||||||
LineSize -= ( starLength - 2 ); line += ( starLength - 2 );}
|
LineSize -= starLengthMinus2;
|
||||||
|
line += starLengthMinus2;
|
||||||
|
}
|
||||||
|
leftMarginLength = (starLengthMinus2 - LineSize)/2;
|
||||||
if( LineSize % 2 == 0 ) {
|
if( LineSize % 2 == 0 ) {
|
||||||
leftMarginLength = rightMarginLength =
|
rightMarginLength = leftMarginLength;
|
||||||
( ( starLength - 2 ) - LineSize ) / 2;}
|
} else {
|
||||||
else
|
rightMarginLength = leftMarginLength + 1;
|
||||||
{
|
}
|
||||||
leftMarginLength = ( ( starLength - 2 ) - LineSize ) / 2;
|
|
||||||
rightMarginLength =
|
|
||||||
( ( starLength - 2 ) - LineSize ) / 2 + 1;}
|
|
||||||
|
|
||||||
memset( leftMargin, ' ', leftMarginLength );
|
memset( leftMargin, ' ', leftMarginLength );
|
||||||
memset( rightMargin, ' ', rightMarginLength );
|
memset( rightMargin, ' ', rightMarginLength );
|
||||||
leftMargin[leftMarginLength] = 0;
|
leftMargin[leftMarginLength] = 0;
|
||||||
rightMargin[rightMarginLength] = 0;
|
rightMargin[rightMarginLength] = 0;
|
||||||
fprintf( fd, "*%s%s%s*\n", leftMargin, line, rightMargin );}
|
fprintf( fd, "*%s%s%s*\n", leftMargin, line, rightMargin );
|
||||||
|
}
|
||||||
fprintf( fd, "%s\n\n", stars );
|
fprintf( fd, "%s\n\n", stars );
|
||||||
|
|
||||||
|
free( currentLine );
|
||||||
|
free( stars );
|
||||||
|
free( rightMargin );
|
||||||
free( leftMargin );
|
free( leftMargin );
|
||||||
free( rightMargin ); free( stars ); free( currentLine );}
|
}
|
||||||
)
|
#endif
|
||||||
|
|
||||||
|
@ -104,9 +104,8 @@ genaCallback( IN http_parser_t * parser,
|
|||||||
// subscribe
|
// subscribe
|
||||||
gena_process_subscription_request( info, request );}
|
gena_process_subscription_request( info, request );}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_ALL, GENA, __FILE__, __LINE__,
|
||||||
( UPNP_ALL, GENA, __FILE__, __LINE__,
|
"got subscription request\n" );
|
||||||
"got subscription request\n" ); )
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -72,14 +72,14 @@ GenaAutoRenewSubscription( IN void *input )
|
|||||||
int eventType = 0;
|
int eventType = 0;
|
||||||
|
|
||||||
if( AUTO_RENEW_TIME == 0 ) {
|
if( AUTO_RENEW_TIME == 0 ) {
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||||
"GENA SUB EXPIRED" ) );
|
"GENA SUB EXPIRED" );
|
||||||
sub_struct->ErrCode = UPNP_E_SUCCESS;
|
sub_struct->ErrCode = UPNP_E_SUCCESS;
|
||||||
send_callback = 1;
|
send_callback = 1;
|
||||||
eventType = UPNP_EVENT_SUBSCRIPTION_EXPIRED;
|
eventType = UPNP_EVENT_SUBSCRIPTION_EXPIRED;
|
||||||
} else {
|
} else {
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||||
"GENA AUTO RENEW" ) );
|
"GENA AUTO RENEW" );
|
||||||
if( ( ( sub_struct->ErrCode = genaRenewSubscription( event->handle,
|
if( ( ( sub_struct->ErrCode = genaRenewSubscription( event->handle,
|
||||||
sub_struct->
|
sub_struct->
|
||||||
Sid,
|
Sid,
|
||||||
@ -93,17 +93,17 @@ GenaAutoRenewSubscription( IN void *input )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( send_callback ) {
|
if( send_callback ) {
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
if( GetHandleInfo( event->handle, &handle_info ) != HND_CLIENT ) {
|
if( GetHandleInfo( event->handle, &handle_info ) != HND_CLIENT ) {
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
free_upnp_timeout( event );
|
free_upnp_timeout( event );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||||
"HANDLE IS VALID" ) );
|
"HANDLE IS VALID" );
|
||||||
callback_fun = handle_info->Callback;
|
callback_fun = handle_info->Callback;
|
||||||
cookie = handle_info->Cookie;
|
cookie = handle_info->Cookie;
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
//make callback
|
//make callback
|
||||||
|
|
||||||
callback_fun( eventType, event->Event, cookie );
|
callback_fun( eventType, event->Event, cookie );
|
||||||
@ -397,9 +397,9 @@ genaUnregisterClient( IN UpnpClient_Handle client_handle )
|
|||||||
http_parser_t response;
|
http_parser_t response;
|
||||||
|
|
||||||
while( TRUE ) {
|
while( TRUE ) {
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) {
|
if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) {
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return GENA_E_BAD_HANDLE;
|
return GENA_E_BAD_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,7 +417,7 @@ genaUnregisterClient( IN UpnpClient_Handle client_handle )
|
|||||||
RemoveClientSubClientSID( &handle_info->ClientSubList,
|
RemoveClientSubClientSID( &handle_info->ClientSubList,
|
||||||
sub_copy.sid );
|
sub_copy.sid );
|
||||||
|
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
|
|
||||||
return_code = gena_unsubscribe( sub_copy.EventURL,
|
return_code = gena_unsubscribe( sub_copy.EventURL,
|
||||||
sub_copy.ActualSID, &response );
|
sub_copy.ActualSID, &response );
|
||||||
@ -429,7 +429,7 @@ genaUnregisterClient( IN UpnpClient_Handle client_handle )
|
|||||||
}
|
}
|
||||||
|
|
||||||
freeClientSubList( handle_info->ClientSubList );
|
freeClientSubList( handle_info->ClientSubList );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,25 +459,25 @@ genaUnSubscribe( IN UpnpClient_Handle client_handle,
|
|||||||
client_subscription sub_copy;
|
client_subscription sub_copy;
|
||||||
http_parser_t response;
|
http_parser_t response;
|
||||||
|
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
|
|
||||||
// validate handle and sid
|
// validate handle and sid
|
||||||
|
|
||||||
if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) {
|
if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) {
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return GENA_E_BAD_HANDLE;
|
return GENA_E_BAD_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ( sub =
|
if( ( sub =
|
||||||
GetClientSubClientSID( handle_info->ClientSubList, in_sid ) )
|
GetClientSubClientSID( handle_info->ClientSubList, in_sid ) )
|
||||||
== NULL ) {
|
== NULL ) {
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return GENA_E_BAD_SID;
|
return GENA_E_BAD_SID;
|
||||||
}
|
}
|
||||||
|
|
||||||
return_code = copy_client_subscription( sub, &sub_copy );
|
return_code = copy_client_subscription( sub, &sub_copy );
|
||||||
|
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
|
|
||||||
return_code = gena_unsubscribe( sub_copy.EventURL, sub_copy.ActualSID,
|
return_code = gena_unsubscribe( sub_copy.EventURL, sub_copy.ActualSID,
|
||||||
&response );
|
&response );
|
||||||
@ -488,16 +488,16 @@ genaUnSubscribe( IN UpnpClient_Handle client_handle,
|
|||||||
|
|
||||||
free_client_subscription( &sub_copy );
|
free_client_subscription( &sub_copy );
|
||||||
|
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
|
|
||||||
if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) {
|
if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) {
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return GENA_E_BAD_HANDLE;
|
return GENA_E_BAD_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveClientSubClientSID( &handle_info->ClientSubList, in_sid );
|
RemoveClientSubClientSID( &handle_info->ClientSubList, in_sid );
|
||||||
|
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
|
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
@ -538,28 +538,28 @@ genaSubscribe( IN UpnpClient_Handle client_handle,
|
|||||||
struct Handle_Info *handle_info;
|
struct Handle_Info *handle_info;
|
||||||
char *EventURL = NULL;
|
char *EventURL = NULL;
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||||
"GENA SUBSCRIBE BEGIN" ) );
|
"GENA SUBSCRIBE BEGIN" );
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
|
|
||||||
memset( out_sid, 0, sizeof( Upnp_SID ) );
|
memset( out_sid, 0, sizeof( Upnp_SID ) );
|
||||||
|
|
||||||
// validate handle
|
// validate handle
|
||||||
if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) {
|
if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) {
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return GENA_E_BAD_HANDLE;
|
return GENA_E_BAD_HANDLE;
|
||||||
}
|
}
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
|
|
||||||
// subscribe
|
// subscribe
|
||||||
SubscribeLock( );
|
SubscribeLock();
|
||||||
return_code =
|
return_code =
|
||||||
gena_subscribe( PublisherURL, TimeOut, NULL, &ActualSID );
|
gena_subscribe( PublisherURL, TimeOut, NULL, &ActualSID );
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
if( return_code != UPNP_E_SUCCESS ) {
|
if( return_code != UPNP_E_SUCCESS ) {
|
||||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL, GENA, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_CRITICAL, GENA, __FILE__, __LINE__,
|
||||||
"SUBSCRIBE FAILED in transfer error code: %d returned\n",
|
"SUBSCRIBE FAILED in transfer error code: %d returned\n",
|
||||||
return_code ) );
|
return_code );
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -605,8 +605,8 @@ genaSubscribe( IN UpnpClient_Handle client_handle,
|
|||||||
free( EventURL );
|
free( EventURL );
|
||||||
free( newSubscription );
|
free( newSubscription );
|
||||||
}
|
}
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
SubscribeUnlock( );
|
SubscribeUnlock();
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -643,17 +643,17 @@ genaRenewSubscription( IN UpnpClient_Handle client_handle,
|
|||||||
char *ActualSID;
|
char *ActualSID;
|
||||||
ThreadPoolJob tempJob;
|
ThreadPoolJob tempJob;
|
||||||
|
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
|
|
||||||
// validate handle and sid
|
// validate handle and sid
|
||||||
if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) {
|
if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) {
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return GENA_E_BAD_HANDLE;
|
return GENA_E_BAD_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ( sub = GetClientSubClientSID( handle_info->ClientSubList,
|
if( ( sub = GetClientSubClientSID( handle_info->ClientSubList,
|
||||||
in_sid ) ) == NULL ) {
|
in_sid ) ) == NULL ) {
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return GENA_E_BAD_SID;
|
return GENA_E_BAD_SID;
|
||||||
}
|
}
|
||||||
// remove old events
|
// remove old events
|
||||||
@ -663,13 +663,13 @@ genaRenewSubscription( IN UpnpClient_Handle client_handle,
|
|||||||
free_upnp_timeout( ( upnp_timeout * ) tempJob.arg );
|
free_upnp_timeout( ( upnp_timeout * ) tempJob.arg );
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||||
"REMOVED AUTO RENEW EVENT" ) );
|
"REMOVED AUTO RENEW EVENT" );
|
||||||
|
|
||||||
sub->RenewEventId = -1;
|
sub->RenewEventId = -1;
|
||||||
return_code = copy_client_subscription( sub, &sub_copy );
|
return_code = copy_client_subscription( sub, &sub_copy );
|
||||||
|
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
|
|
||||||
if( return_code != HTTP_SUCCESS ) {
|
if( return_code != HTTP_SUCCESS ) {
|
||||||
return return_code;
|
return return_code;
|
||||||
@ -677,10 +677,10 @@ genaRenewSubscription( IN UpnpClient_Handle client_handle,
|
|||||||
|
|
||||||
return_code = gena_subscribe( sub_copy.EventURL, TimeOut,
|
return_code = gena_subscribe( sub_copy.EventURL, TimeOut,
|
||||||
sub_copy.ActualSID, &ActualSID );
|
sub_copy.ActualSID, &ActualSID );
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
|
|
||||||
if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) {
|
if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) {
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
if( return_code == UPNP_E_SUCCESS ) {
|
if( return_code == UPNP_E_SUCCESS ) {
|
||||||
free( ActualSID );
|
free( ActualSID );
|
||||||
}
|
}
|
||||||
@ -693,7 +693,7 @@ genaRenewSubscription( IN UpnpClient_Handle client_handle,
|
|||||||
// network failure (remove client sub)
|
// network failure (remove client sub)
|
||||||
RemoveClientSubClientSID( &handle_info->ClientSubList, in_sid );
|
RemoveClientSubClientSID( &handle_info->ClientSubList, in_sid );
|
||||||
free_client_subscription( &sub_copy );
|
free_client_subscription( &sub_copy );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
// get subscription
|
// get subscription
|
||||||
@ -701,7 +701,7 @@ genaRenewSubscription( IN UpnpClient_Handle client_handle,
|
|||||||
in_sid ) ) == NULL ) {
|
in_sid ) ) == NULL ) {
|
||||||
free( ActualSID );
|
free( ActualSID );
|
||||||
free_client_subscription( &sub_copy );
|
free_client_subscription( &sub_copy );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return GENA_E_BAD_SID;
|
return GENA_E_BAD_SID;
|
||||||
}
|
}
|
||||||
// store actual sid
|
// store actual sid
|
||||||
@ -714,7 +714,7 @@ genaRenewSubscription( IN UpnpClient_Handle client_handle,
|
|||||||
RemoveClientSubClientSID( &handle_info->ClientSubList, sub->sid );
|
RemoveClientSubClientSID( &handle_info->ClientSubList, sub->sid );
|
||||||
}
|
}
|
||||||
free_client_subscription( &sub_copy );
|
free_client_subscription( &sub_copy );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -795,12 +795,12 @@ gena_process_notification_event( IN SOCKINFO * info,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
|
|
||||||
// get client info
|
// get client info
|
||||||
if( GetClientHandleInfo( &client_handle, &handle_info ) != HND_CLIENT ) {
|
if( GetClientHandleInfo( &client_handle, &handle_info ) != HND_CLIENT ) {
|
||||||
error_respond( info, HTTP_PRECONDITION_FAILED, event );
|
error_respond( info, HTTP_PRECONDITION_FAILED, event );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
ixmlDocument_free( ChangedVars );
|
ixmlDocument_free( ChangedVars );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -813,20 +813,20 @@ gena_process_notification_event( IN SOCKINFO * info,
|
|||||||
// (if we are in the middle)
|
// (if we are in the middle)
|
||||||
// this is to avoid mistakenly rejecting the first event if we
|
// this is to avoid mistakenly rejecting the first event if we
|
||||||
// receive it before the subscription response
|
// receive it before the subscription response
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
|
|
||||||
// try and get Subscription Lock
|
// try and get Subscription Lock
|
||||||
// (in case we are in the process of subscribing)
|
// (in case we are in the process of subscribing)
|
||||||
SubscribeLock( );
|
SubscribeLock();
|
||||||
|
|
||||||
// get HandleLock again
|
// get HandleLock again
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
|
|
||||||
if( GetClientHandleInfo( &client_handle, &handle_info )
|
if( GetClientHandleInfo( &client_handle, &handle_info )
|
||||||
!= HND_CLIENT ) {
|
!= HND_CLIENT ) {
|
||||||
error_respond( info, HTTP_PRECONDITION_FAILED, event );
|
error_respond( info, HTTP_PRECONDITION_FAILED, event );
|
||||||
SubscribeUnlock( );
|
SubscribeUnlock();
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
ixmlDocument_free( ChangedVars );
|
ixmlDocument_free( ChangedVars );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -836,17 +836,17 @@ gena_process_notification_event( IN SOCKINFO * info,
|
|||||||
GetClientSubActualSID( handle_info->ClientSubList,
|
GetClientSubActualSID( handle_info->ClientSubList,
|
||||||
&sid ) ) == NULL ) {
|
&sid ) ) == NULL ) {
|
||||||
error_respond( info, HTTP_PRECONDITION_FAILED, event );
|
error_respond( info, HTTP_PRECONDITION_FAILED, event );
|
||||||
SubscribeUnlock( );
|
SubscribeUnlock();
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
ixmlDocument_free( ChangedVars );
|
ixmlDocument_free( ChangedVars );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SubscribeUnlock( );
|
SubscribeUnlock();
|
||||||
} else {
|
} else {
|
||||||
error_respond( info, HTTP_PRECONDITION_FAILED, event );
|
error_respond( info, HTTP_PRECONDITION_FAILED, event );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
ixmlDocument_free( ChangedVars );
|
ixmlDocument_free( ChangedVars );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -864,7 +864,7 @@ gena_process_notification_event( IN SOCKINFO * info,
|
|||||||
callback = handle_info->Callback;
|
callback = handle_info->Callback;
|
||||||
cookie = handle_info->Cookie;
|
cookie = handle_info->Cookie;
|
||||||
|
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
|
|
||||||
// make callback with event struct
|
// make callback with event struct
|
||||||
// In future, should find a way of mainting
|
// In future, should find a way of mainting
|
||||||
|
@ -62,19 +62,19 @@ genaUnregisterDevice( IN UpnpDevice_Handle device_handle )
|
|||||||
{
|
{
|
||||||
struct Handle_Info *handle_info;
|
struct Handle_Info *handle_info;
|
||||||
|
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) {
|
if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) {
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL, GENA, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_CRITICAL, GENA, __FILE__, __LINE__,
|
||||||
"genaUnregisterDevice : BAD Handle : %d\n",
|
"genaUnregisterDevice : BAD Handle : %d\n",
|
||||||
device_handle ) );
|
device_handle );
|
||||||
|
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return GENA_E_BAD_HANDLE;
|
return GENA_E_BAD_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
freeServiceTable( &handle_info->ServiceTable );
|
freeServiceTable( &handle_info->ServiceTable );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
|
|
||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -203,10 +203,10 @@ notify_send_and_recv( IN uri_type * destination_url,
|
|||||||
SOCKINFO info;
|
SOCKINFO info;
|
||||||
|
|
||||||
// connect
|
// connect
|
||||||
DBGONLY( UpnpPrintf( UPNP_ALL, GENA, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_ALL, GENA, __FILE__, __LINE__,
|
||||||
"gena notify to: %.*s\n",
|
"gena notify to: %.*s\n",
|
||||||
(int)destination_url->hostport.text.size,
|
(int)destination_url->hostport.text.size,
|
||||||
destination_url->hostport.text.buff ); )
|
destination_url->hostport.text.buff );
|
||||||
|
|
||||||
conn_fd = http_Connect( destination_url, &url );
|
conn_fd = http_Connect( destination_url, &url );
|
||||||
if( conn_fd < 0 ) {
|
if( conn_fd < 0 ) {
|
||||||
@ -365,12 +365,12 @@ genaNotifyThread( IN void *input )
|
|||||||
struct Handle_Info *handle_info;
|
struct Handle_Info *handle_info;
|
||||||
ThreadPoolJob job;
|
ThreadPoolJob job;
|
||||||
|
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
//validate context
|
//validate context
|
||||||
|
|
||||||
if( GetHandleInfo( in->device_handle, &handle_info ) != HND_DEVICE ) {
|
if( GetHandleInfo( in->device_handle, &handle_info ) != HND_DEVICE ) {
|
||||||
free_notify_struct( in );
|
free_notify_struct( in );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,7 +380,7 @@ genaNotifyThread( IN void *input )
|
|||||||
|| ( ( sub = GetSubscriptionSID( in->sid, service ) ) == NULL )
|
|| ( ( sub = GetSubscriptionSID( in->sid, service ) ) == NULL )
|
||||||
|| ( ( copy_subscription( sub, &sub_copy ) != HTTP_SUCCESS ) ) ) {
|
|| ( ( copy_subscription( sub, &sub_copy ) != HTTP_SUCCESS ) ) ) {
|
||||||
free_notify_struct( in );
|
free_notify_struct( in );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//If the event is out of order push it back to the job queue
|
//If the event is out of order push it back to the job queue
|
||||||
@ -392,22 +392,22 @@ genaNotifyThread( IN void *input )
|
|||||||
ThreadPoolAdd( &gSendThreadPool, &job, NULL );
|
ThreadPoolAdd( &gSendThreadPool, &job, NULL );
|
||||||
|
|
||||||
freeSubscription( &sub_copy );
|
freeSubscription( &sub_copy );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
|
|
||||||
//send the notify
|
//send the notify
|
||||||
return_code = genaNotify( in->headers, in->propertySet, &sub_copy );
|
return_code = genaNotify( in->headers, in->propertySet, &sub_copy );
|
||||||
|
|
||||||
freeSubscription( &sub_copy );
|
freeSubscription( &sub_copy );
|
||||||
|
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
|
|
||||||
if( GetHandleInfo( in->device_handle, &handle_info ) != HND_DEVICE ) {
|
if( GetHandleInfo( in->device_handle, &handle_info ) != HND_DEVICE ) {
|
||||||
free_notify_struct( in );
|
free_notify_struct( in );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//validate context
|
//validate context
|
||||||
@ -416,7 +416,7 @@ genaNotifyThread( IN void *input )
|
|||||||
|| ( !service->active )
|
|| ( !service->active )
|
||||||
|| ( ( sub = GetSubscriptionSID( in->sid, service ) ) == NULL ) ) {
|
|| ( ( sub = GetSubscriptionSID( in->sid, service ) ) == NULL ) ) {
|
||||||
free_notify_struct( in );
|
free_notify_struct( in );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,7 +430,7 @@ genaNotifyThread( IN void *input )
|
|||||||
}
|
}
|
||||||
|
|
||||||
free_notify_struct( in );
|
free_notify_struct( in );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -477,8 +477,8 @@ genaInitNotify( IN UpnpDevice_Handle device_handle,
|
|||||||
|
|
||||||
notify_thread_struct *thread_struct = NULL;
|
notify_thread_struct *thread_struct = NULL;
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||||
"GENA BEGIN INITIAL NOTIFY " ) );
|
"GENA BEGIN INITIAL NOTIFY " );
|
||||||
|
|
||||||
reference_count = ( int * )malloc( sizeof( int ) );
|
reference_count = ( int * )malloc( sizeof( int ) );
|
||||||
|
|
||||||
@ -504,13 +504,13 @@ genaInitNotify( IN UpnpDevice_Handle device_handle,
|
|||||||
strcpy( UDN_copy, UDN );
|
strcpy( UDN_copy, UDN );
|
||||||
strcpy( servId_copy, servId );
|
strcpy( servId_copy, servId );
|
||||||
|
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
|
|
||||||
if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) {
|
if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) {
|
||||||
free( UDN_copy );
|
free( UDN_copy );
|
||||||
free( reference_count );
|
free( reference_count );
|
||||||
free( servId_copy );
|
free( servId_copy );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return GENA_E_BAD_HANDLE;
|
return GENA_E_BAD_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,26 +519,25 @@ genaInitNotify( IN UpnpDevice_Handle device_handle,
|
|||||||
free( UDN_copy );
|
free( UDN_copy );
|
||||||
free( reference_count );
|
free( reference_count );
|
||||||
free( servId_copy );
|
free( servId_copy );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return GENA_E_BAD_SERVICE;
|
return GENA_E_BAD_SERVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||||
"FOUND SERVICE IN INIT NOTFY: UDN %s, ServID: %s ",
|
"FOUND SERVICE IN INIT NOTFY: UDN %s, ServID: %s ",
|
||||||
UDN, servId ) );
|
UDN, servId );
|
||||||
|
|
||||||
if( ( ( sub = GetSubscriptionSID( sid, service ) ) == NULL ) ||
|
if( ( ( sub = GetSubscriptionSID( sid, service ) ) == NULL ) ||
|
||||||
( sub->active ) ) {
|
( sub->active ) ) {
|
||||||
free( UDN_copy );
|
free( UDN_copy );
|
||||||
free( reference_count );
|
free( reference_count );
|
||||||
free( servId_copy );
|
free( servId_copy );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return GENA_E_BAD_SID;
|
return GENA_E_BAD_SID;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||||
"FOUND SUBSCRIPTION IN INIT NOTIFY: SID %s ",
|
"FOUND SUBSCRIPTION IN INIT NOTIFY: SID %s ", sid );
|
||||||
sid ) );
|
|
||||||
|
|
||||||
sub->active = 1;
|
sub->active = 1;
|
||||||
|
|
||||||
@ -549,13 +548,13 @@ genaInitNotify( IN UpnpDevice_Handle device_handle,
|
|||||||
free( UDN_copy );
|
free( UDN_copy );
|
||||||
free( reference_count );
|
free( reference_count );
|
||||||
free( servId_copy );
|
free( servId_copy );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||||
"GENERATED PROPERY SET IN INIT NOTIFY: \n'%s'\n",
|
"GENERATED PROPERY SET IN INIT NOTIFY: \n'%s'\n",
|
||||||
propertySet ) );
|
propertySet );
|
||||||
|
|
||||||
headers_size = strlen( "CONTENT-TYPE text/xml\r\n" ) +
|
headers_size = strlen( "CONTENT-TYPE text/xml\r\n" ) +
|
||||||
strlen( "CONTENT-LENGTH: \r\n" ) + MAX_CONTENT_LENGTH +
|
strlen( "CONTENT-LENGTH: \r\n" ) + MAX_CONTENT_LENGTH +
|
||||||
@ -569,7 +568,7 @@ genaInitNotify( IN UpnpDevice_Handle device_handle,
|
|||||||
free( UDN_copy );
|
free( UDN_copy );
|
||||||
free( servId_copy );
|
free( servId_copy );
|
||||||
free( reference_count );
|
free( reference_count );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return UPNP_E_OUTOF_MEMORY;
|
return UPNP_E_OUTOF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -621,7 +620,7 @@ genaInitNotify( IN UpnpDevice_Handle device_handle,
|
|||||||
free( headers );
|
free( headers );
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
|
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
@ -668,8 +667,8 @@ genaInitNotifyExt( IN UpnpDevice_Handle device_handle,
|
|||||||
|
|
||||||
notify_thread_struct *thread_struct = NULL;
|
notify_thread_struct *thread_struct = NULL;
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||||
"GENA BEGIN INITIAL NOTIFY EXT" ) );
|
"GENA BEGIN INITIAL NOTIFY EXT" );
|
||||||
reference_count = ( int * )malloc( sizeof( int ) );
|
reference_count = ( int * )malloc( sizeof( int ) );
|
||||||
|
|
||||||
if( reference_count == NULL ) {
|
if( reference_count == NULL ) {
|
||||||
@ -694,13 +693,13 @@ genaInitNotifyExt( IN UpnpDevice_Handle device_handle,
|
|||||||
strcpy( UDN_copy, UDN );
|
strcpy( UDN_copy, UDN );
|
||||||
strcpy( servId_copy, servId );
|
strcpy( servId_copy, servId );
|
||||||
|
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
|
|
||||||
if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) {
|
if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) {
|
||||||
free( UDN_copy );
|
free( UDN_copy );
|
||||||
free( reference_count );
|
free( reference_count );
|
||||||
free( servId_copy );
|
free( servId_copy );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return GENA_E_BAD_HANDLE;
|
return GENA_E_BAD_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -709,24 +708,23 @@ genaInitNotifyExt( IN UpnpDevice_Handle device_handle,
|
|||||||
free( UDN_copy );
|
free( UDN_copy );
|
||||||
free( reference_count );
|
free( reference_count );
|
||||||
free( servId_copy );
|
free( servId_copy );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return GENA_E_BAD_SERVICE;
|
return GENA_E_BAD_SERVICE;
|
||||||
}
|
}
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||||
"FOUND SERVICE IN INIT NOTFY EXT: UDN %s, ServID: %s\n",
|
"FOUND SERVICE IN INIT NOTFY EXT: UDN %s, ServID: %s\n",
|
||||||
UDN, servId ) );
|
UDN, servId );
|
||||||
|
|
||||||
if( ( ( sub = GetSubscriptionSID( sid, service ) ) == NULL ) ||
|
if( ( ( sub = GetSubscriptionSID( sid, service ) ) == NULL ) ||
|
||||||
( sub->active ) ) {
|
( sub->active ) ) {
|
||||||
free( UDN_copy );
|
free( UDN_copy );
|
||||||
free( reference_count );
|
free( reference_count );
|
||||||
free( servId_copy );
|
free( servId_copy );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return GENA_E_BAD_SID;
|
return GENA_E_BAD_SID;
|
||||||
}
|
}
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||||
"FOUND SUBSCRIPTION IN INIT NOTIFY EXT: SID %s",
|
"FOUND SUBSCRIPTION IN INIT NOTIFY EXT: SID %s", sid );
|
||||||
sid ) );
|
|
||||||
|
|
||||||
sub->active = 1;
|
sub->active = 1;
|
||||||
|
|
||||||
@ -735,13 +733,13 @@ genaInitNotifyExt( IN UpnpDevice_Handle device_handle,
|
|||||||
free( UDN_copy );
|
free( UDN_copy );
|
||||||
free( reference_count );
|
free( reference_count );
|
||||||
free( servId_copy );
|
free( servId_copy );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||||
"GENERATED PROPERY SET IN INIT EXT NOTIFY: %s",
|
"GENERATED PROPERY SET IN INIT EXT NOTIFY: %s",
|
||||||
propertySet ) );
|
propertySet );
|
||||||
|
|
||||||
headers_size = strlen( "CONTENT-TYPE text/xml\r\n" ) +
|
headers_size = strlen( "CONTENT-TYPE text/xml\r\n" ) +
|
||||||
strlen( "CONTENT-LENGTH: \r\n" ) + MAX_CONTENT_LENGTH +
|
strlen( "CONTENT-LENGTH: \r\n" ) + MAX_CONTENT_LENGTH +
|
||||||
@ -754,7 +752,7 @@ genaInitNotifyExt( IN UpnpDevice_Handle device_handle,
|
|||||||
free( servId_copy );
|
free( servId_copy );
|
||||||
free( reference_count );
|
free( reference_count );
|
||||||
ixmlFreeDOMString( propertySet );
|
ixmlFreeDOMString( propertySet );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return UPNP_E_OUTOF_MEMORY;
|
return UPNP_E_OUTOF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -804,7 +802,7 @@ genaInitNotifyExt( IN UpnpDevice_Handle device_handle,
|
|||||||
free( thread_struct );
|
free( thread_struct );
|
||||||
free( headers );
|
free( headers );
|
||||||
}
|
}
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
|
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
@ -899,7 +897,7 @@ genaNotifyAllExt( IN UpnpDevice_Handle device_handle,
|
|||||||
"%ld\r\nNT: upnp:event\r\nNTS: upnp:propchange\r\n",
|
"%ld\r\nNT: upnp:event\r\nNTS: upnp:propchange\r\n",
|
||||||
(long) strlen( propertySet ) + 1 );
|
(long) strlen( propertySet ) + 1 );
|
||||||
|
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
|
|
||||||
if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE )
|
if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE )
|
||||||
return_code = GENA_E_BAD_HANDLE;
|
return_code = GENA_E_BAD_HANDLE;
|
||||||
@ -959,7 +957,7 @@ genaNotifyAllExt( IN UpnpDevice_Handle device_handle,
|
|||||||
free( servId_copy );
|
free( servId_copy );
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
|
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
@ -1061,7 +1059,7 @@ genaNotifyAll( IN UpnpDevice_Handle device_handle,
|
|||||||
" upnp:event\r\nNTS: upnp:propchange\r\n",
|
" upnp:event\r\nNTS: upnp:propchange\r\n",
|
||||||
(long) strlen( propertySet ) + 1 );
|
(long) strlen( propertySet ) + 1 );
|
||||||
|
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
|
|
||||||
if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) {
|
if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) {
|
||||||
return_code = GENA_E_BAD_HANDLE;
|
return_code = GENA_E_BAD_HANDLE;
|
||||||
@ -1123,7 +1121,7 @@ genaNotifyAll( IN UpnpDevice_Handle device_handle,
|
|||||||
free( UDN_copy );
|
free( UDN_copy );
|
||||||
free( servId_copy );
|
free( servId_copy );
|
||||||
}
|
}
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
|
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
@ -1317,8 +1315,8 @@ gena_process_subscription_request( IN SOCKINFO * info,
|
|||||||
memptr callback_hdr;
|
memptr callback_hdr;
|
||||||
memptr timeout_hdr;
|
memptr timeout_hdr;
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||||
"Subscription Request Received:\n" ) );
|
"Subscription Request Received:\n" );
|
||||||
|
|
||||||
if( httpmsg_find_hdr( request, HDR_NT, &nt_hdr ) == NULL ) {
|
if( httpmsg_find_hdr( request, HDR_NT, &nt_hdr ) == NULL ) {
|
||||||
error_respond( info, HTTP_BAD_REQUEST, request );
|
error_respond( info, HTTP_BAD_REQUEST, request );
|
||||||
@ -1347,18 +1345,17 @@ gena_process_subscription_request( IN SOCKINFO * info,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||||
"SubscriptionRequest for event URL path: %s\n",
|
"SubscriptionRequest for event URL path: %s\n",
|
||||||
event_url_path );
|
event_url_path );
|
||||||
)
|
|
||||||
|
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
|
|
||||||
// CURRENTLY, ONLY ONE DEVICE
|
// CURRENTLY, ONLY ONE DEVICE
|
||||||
if( GetDeviceHandleInfo( &device_handle, &handle_info ) != HND_DEVICE ) {
|
if( GetDeviceHandleInfo( &device_handle, &handle_info ) != HND_DEVICE ) {
|
||||||
free( event_url_path );
|
free( event_url_path );
|
||||||
error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
|
error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
service = FindServiceEventURLPath( &handle_info->ServiceTable,
|
service = FindServiceEventURLPath( &handle_info->ServiceTable,
|
||||||
@ -1367,28 +1364,28 @@ gena_process_subscription_request( IN SOCKINFO * info,
|
|||||||
|
|
||||||
if( service == NULL || !service->active ) {
|
if( service == NULL || !service->active ) {
|
||||||
error_respond( info, HTTP_NOT_FOUND, request );
|
error_respond( info, HTTP_NOT_FOUND, request );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||||
"Subscription Request: Number of Subscriptions already %d\n "
|
"Subscription Request: Number of Subscriptions already %d\n "
|
||||||
"Max Subscriptions allowed: %d\n",
|
"Max Subscriptions allowed: %d\n",
|
||||||
service->TotalSubscriptions,
|
service->TotalSubscriptions,
|
||||||
handle_info->MaxSubscriptions ) );
|
handle_info->MaxSubscriptions );
|
||||||
|
|
||||||
// too many subscriptions
|
// too many subscriptions
|
||||||
if( handle_info->MaxSubscriptions != -1 &&
|
if( handle_info->MaxSubscriptions != -1 &&
|
||||||
service->TotalSubscriptions >= handle_info->MaxSubscriptions ) {
|
service->TotalSubscriptions >= handle_info->MaxSubscriptions ) {
|
||||||
error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
|
error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// generate new subscription
|
// generate new subscription
|
||||||
sub = ( subscription * ) malloc( sizeof( subscription ) );
|
sub = ( subscription * ) malloc( sizeof( subscription ) );
|
||||||
if( sub == NULL ) {
|
if( sub == NULL ) {
|
||||||
error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
|
error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sub->eventKey = 0;
|
sub->eventKey = 0;
|
||||||
@ -1405,13 +1402,13 @@ gena_process_subscription_request( IN SOCKINFO * info,
|
|||||||
&sub->DeliveryURLs ) ) == 0 ) {
|
&sub->DeliveryURLs ) ) == 0 ) {
|
||||||
error_respond( info, HTTP_PRECONDITION_FAILED, request );
|
error_respond( info, HTTP_PRECONDITION_FAILED, request );
|
||||||
freeSubscriptionList( sub );
|
freeSubscriptionList( sub );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if( return_code == UPNP_E_OUTOF_MEMORY ) {
|
if( return_code == UPNP_E_OUTOF_MEMORY ) {
|
||||||
error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
|
error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
|
||||||
freeSubscriptionList( sub );
|
freeSubscriptionList( sub );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// set the timeout
|
// set the timeout
|
||||||
@ -1447,7 +1444,7 @@ gena_process_subscription_request( IN SOCKINFO * info,
|
|||||||
// respond OK
|
// respond OK
|
||||||
if( respond_ok( info, time_out, sub, request ) != UPNP_E_SUCCESS ) {
|
if( respond_ok( info, time_out, sub, request ) != UPNP_E_SUCCESS ) {
|
||||||
freeSubscriptionList( sub );
|
freeSubscriptionList( sub );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//add to subscription list
|
//add to subscription list
|
||||||
@ -1464,7 +1461,7 @@ gena_process_subscription_request( IN SOCKINFO * info,
|
|||||||
callback_fun = handle_info->Callback;
|
callback_fun = handle_info->Callback;
|
||||||
cookie = handle_info->Cookie;
|
cookie = handle_info->Cookie;
|
||||||
|
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
|
|
||||||
//make call back with request struct
|
//make call back with request struct
|
||||||
//in the future should find a way of mainting
|
//in the future should find a way of mainting
|
||||||
@ -1527,7 +1524,7 @@ gena_process_subscription_renewal_request( IN SOCKINFO * info,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
|
|
||||||
// CURRENTLY, ONLY SUPPORT ONE DEVICE
|
// CURRENTLY, ONLY SUPPORT ONE DEVICE
|
||||||
if( GetDeviceHandleInfo( &device_handle, &handle_info ) != HND_DEVICE ) {
|
if( GetDeviceHandleInfo( &device_handle, &handle_info ) != HND_DEVICE ) {
|
||||||
@ -1544,22 +1541,21 @@ gena_process_subscription_renewal_request( IN SOCKINFO * info,
|
|||||||
!service->active ||
|
!service->active ||
|
||||||
( ( sub = GetSubscriptionSID( sid, service ) ) == NULL ) ) {
|
( ( sub = GetSubscriptionSID( sid, service ) ) == NULL ) ) {
|
||||||
error_respond( info, HTTP_PRECONDITION_FAILED, request );
|
error_respond( info, HTTP_PRECONDITION_FAILED, request );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||||
"Renew request: Number of subscriptions already: %d\n "
|
"Renew request: Number of subscriptions already: %d\n "
|
||||||
"Max Subscriptions allowed:%d\n",
|
"Max Subscriptions allowed:%d\n",
|
||||||
service->TotalSubscriptions,
|
service->TotalSubscriptions,
|
||||||
handle_info->MaxSubscriptions );
|
handle_info->MaxSubscriptions );
|
||||||
)
|
|
||||||
// too many subscriptions
|
// too many subscriptions
|
||||||
if( handle_info->MaxSubscriptions != -1 &&
|
if( handle_info->MaxSubscriptions != -1 &&
|
||||||
service->TotalSubscriptions > handle_info->MaxSubscriptions ) {
|
service->TotalSubscriptions > handle_info->MaxSubscriptions ) {
|
||||||
error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
|
error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
|
||||||
RemoveSubscriptionSID( sub->sid, service );
|
RemoveSubscriptionSID( sub->sid, service );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// set the timeout
|
// set the timeout
|
||||||
@ -1598,7 +1594,7 @@ gena_process_subscription_renewal_request( IN SOCKINFO * info,
|
|||||||
RemoveSubscriptionSID( sub->sid, service );
|
RemoveSubscriptionSID( sub->sid, service );
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -1651,13 +1647,13 @@ gena_process_unsubscribe_request( IN SOCKINFO * info,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
|
|
||||||
// CURRENTLY, ONLY SUPPORT ONE DEVICE
|
// CURRENTLY, ONLY SUPPORT ONE DEVICE
|
||||||
if( GetDeviceHandleInfo( &device_handle, &handle_info ) != HND_DEVICE ) {
|
if( GetDeviceHandleInfo( &device_handle, &handle_info ) != HND_DEVICE ) {
|
||||||
error_respond( info, HTTP_PRECONDITION_FAILED, request );
|
error_respond( info, HTTP_PRECONDITION_FAILED, request );
|
||||||
membuffer_destroy( &event_url_path );
|
membuffer_destroy( &event_url_path );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
service = FindServiceEventURLPath( &handle_info->ServiceTable,
|
service = FindServiceEventURLPath( &handle_info->ServiceTable,
|
||||||
@ -1670,14 +1666,14 @@ gena_process_unsubscribe_request( IN SOCKINFO * info,
|
|||||||
//CheckSubscriptionSID(sid, service) == NULL )
|
//CheckSubscriptionSID(sid, service) == NULL )
|
||||||
{
|
{
|
||||||
error_respond( info, HTTP_PRECONDITION_FAILED, request );
|
error_respond( info, HTTP_PRECONDITION_FAILED, request );
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveSubscriptionSID( sid, service );
|
RemoveSubscriptionSID( sid, service );
|
||||||
error_respond( info, HTTP_OK, request ); // success
|
error_respond( info, HTTP_OK, request ); // success
|
||||||
|
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // INCLUDE_DEVICE_APIS
|
#endif // INCLUDE_DEVICE_APIS
|
||||||
|
@ -174,10 +174,8 @@ dispatch_request( IN SOCKINFO * info,
|
|||||||
case HTTPMETHOD_NOTIFY:
|
case HTTPMETHOD_NOTIFY:
|
||||||
case HTTPMETHOD_SUBSCRIBE:
|
case HTTPMETHOD_SUBSCRIBE:
|
||||||
case HTTPMETHOD_UNSUBSCRIBE:
|
case HTTPMETHOD_UNSUBSCRIBE:
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
|
||||||
"miniserver %d: got GENA msg\n", info->socket );
|
"miniserver %d: got GENA msg\n", info->socket );
|
||||||
)
|
|
||||||
callback = gGenaCallback;
|
callback = gGenaCallback;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -275,10 +273,8 @@ handle_request( void *args )
|
|||||||
struct mserv_request_t *request = ( struct mserv_request_t * )args;
|
struct mserv_request_t *request = ( struct mserv_request_t * )args;
|
||||||
int connfd = request->connfd;
|
int connfd = request->connfd;
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
|
||||||
"miniserver %d: READING\n", connfd );
|
"miniserver %d: READING\n", connfd );
|
||||||
)
|
|
||||||
//parser_request_init( &parser ); ////LEAK_FIX_MK
|
//parser_request_init( &parser ); ////LEAK_FIX_MK
|
||||||
hmsg = &parser.msg;
|
hmsg = &parser.msg;
|
||||||
|
|
||||||
@ -295,10 +291,8 @@ handle_request( void *args )
|
|||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
|
||||||
"miniserver %d: PROCESSING...\n", connfd );
|
"miniserver %d: PROCESSING...\n", connfd );
|
||||||
)
|
|
||||||
// dispatch
|
// dispatch
|
||||||
http_error_code = dispatch_request( &info, &parser );
|
http_error_code = dispatch_request( &info, &parser );
|
||||||
if( http_error_code != 0 ) {
|
if( http_error_code != 0 ) {
|
||||||
@ -316,10 +310,8 @@ handle_request( void *args )
|
|||||||
handle_error( &info, http_error_code, major, minor );
|
handle_error( &info, http_error_code, major, minor );
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
|
||||||
"miniserver %d: COMPLETE\n", connfd );
|
"miniserver %d: COMPLETE\n", connfd );
|
||||||
)
|
|
||||||
sock_destroy( &info, SD_BOTH ); //should shutdown completely
|
sock_destroy( &info, SD_BOTH ); //should shutdown completely
|
||||||
|
|
||||||
httpmsg_destroy( hmsg );
|
httpmsg_destroy( hmsg );
|
||||||
@ -352,10 +344,8 @@ schedule_request_job( IN int connfd,
|
|||||||
( struct mserv_request_t * )
|
( struct mserv_request_t * )
|
||||||
malloc( sizeof( struct mserv_request_t ) );
|
malloc( sizeof( struct mserv_request_t ) );
|
||||||
if( request == NULL ) {
|
if( request == NULL ) {
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
|
||||||
"mserv %d: out of memory\n", connfd );
|
"mserv %d: out of memory\n", connfd );
|
||||||
)
|
|
||||||
shutdown( request->connfd, SD_BOTH );
|
shutdown( request->connfd, SD_BOTH );
|
||||||
UpnpCloseSocket( connfd );
|
UpnpCloseSocket( connfd );
|
||||||
return;
|
return;
|
||||||
@ -370,10 +360,8 @@ schedule_request_job( IN int connfd,
|
|||||||
TPJobSetPriority( &job, MED_PRIORITY );
|
TPJobSetPriority( &job, MED_PRIORITY );
|
||||||
|
|
||||||
if( ThreadPoolAdd( &gRecvThreadPool, &job, NULL ) != 0 ) {
|
if( ThreadPoolAdd( &gRecvThreadPool, &job, NULL ) != 0 ) {
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
|
||||||
"mserv %d: cannot schedule request\n", connfd );
|
"mserv %d: cannot schedule request\n", connfd );
|
||||||
)
|
|
||||||
free( request );
|
free( request );
|
||||||
shutdown( connfd, SD_BOTH );
|
shutdown( connfd, SD_BOTH );
|
||||||
UpnpCloseSocket( connfd );
|
UpnpCloseSocket( connfd );
|
||||||
@ -446,10 +434,8 @@ RunMiniServer( MiniServerSockArray * miniSock )
|
|||||||
|
|
||||||
if( select( maxMiniSock, &rdSet, NULL, &expSet, NULL ) ==
|
if( select( maxMiniSock, &rdSet, NULL, &expSet, NULL ) ==
|
||||||
UPNP_SOCKETERROR ) {
|
UPNP_SOCKETERROR ) {
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
||||||
( UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
|
||||||
"Error in select call !!!\n" );
|
"Error in select call !!!\n" );
|
||||||
)
|
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -459,11 +445,9 @@ RunMiniServer( MiniServerSockArray * miniSock )
|
|||||||
( struct sockaddr * )&clientAddr,
|
( struct sockaddr * )&clientAddr,
|
||||||
&clientLen );
|
&clientLen );
|
||||||
if( connectHnd == UPNP_INVALID_SOCKET ) {
|
if( connectHnd == UPNP_INVALID_SOCKET ) {
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
|
||||||
"miniserver: Error"
|
"miniserver: Error"
|
||||||
" in accepting connection\n" );
|
" in accepting connection\n" );
|
||||||
)
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
schedule_request_job( connectHnd, &clientAddr );
|
schedule_request_job( connectHnd, &clientAddr );
|
||||||
@ -489,24 +473,19 @@ RunMiniServer( MiniServerSockArray * miniSock )
|
|||||||
&clientLen );
|
&clientLen );
|
||||||
if( byteReceived > 0 ) {
|
if( byteReceived > 0 ) {
|
||||||
requestBuf[byteReceived] = '\0';
|
requestBuf[byteReceived] = '\0';
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
|
||||||
"Received response !!! %s From host %s \n",
|
"Received response !!! %s From host %s \n",
|
||||||
requestBuf,
|
requestBuf, inet_ntoa( clientAddr.sin_addr ) );
|
||||||
inet_ntoa( clientAddr.sin_addr ) );
|
UpnpPrintf( UPNP_PACKET, MSERV, __FILE__, __LINE__,
|
||||||
)
|
|
||||||
DBGONLY( UpnpPrintf
|
|
||||||
( UPNP_PACKET, MSERV, __FILE__, __LINE__,
|
|
||||||
"Received multicast packet: \n %s\n",
|
"Received multicast packet: \n %s\n",
|
||||||
requestBuf );
|
requestBuf );
|
||||||
)
|
|
||||||
|
|
||||||
if( NULL != strstr( requestBuf, "ShutDown" ) )
|
if( NULL != strstr( requestBuf, "ShutDown" ) ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shutdown( miniServSock, SD_BOTH );
|
shutdown( miniServSock, SD_BOTH );
|
||||||
@ -555,10 +534,8 @@ get_port( int sockfd )
|
|||||||
}
|
}
|
||||||
|
|
||||||
port = ntohs( sockinfo.sin_port );
|
port = ntohs( sockinfo.sin_port );
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
|
||||||
"sockfd = %d, .... port = %d\n", sockfd, port );
|
"sockfd = %d, .... port = %d\n", sockfd, port );
|
||||||
)
|
|
||||||
|
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
@ -623,16 +600,10 @@ get_miniserver_sockets( MiniServerSockArray * out,
|
|||||||
//THIS MAY CAUSE TCP TO BECOME LESS RELIABLE
|
//THIS MAY CAUSE TCP TO BECOME LESS RELIABLE
|
||||||
//HOWEVER IT HAS BEEN SUGESTED FOR TCP SERVERS
|
//HOWEVER IT HAS BEEN SUGESTED FOR TCP SERVERS
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||||
"mserv start: resuseaddr set\n" );
|
"mserv start: resuseaddr set\n" );
|
||||||
)
|
sockError = setsockopt( listenfd, SOL_SOCKET, SO_REUSEADDR,
|
||||||
|
( const char * )&reuseaddr_on, sizeof( int ));
|
||||||
sockError = setsockopt( listenfd,
|
|
||||||
SOL_SOCKET,
|
|
||||||
SO_REUSEADDR,
|
|
||||||
( const char * )&reuseaddr_on,
|
|
||||||
sizeof( int )
|
|
||||||
);
|
|
||||||
if( sockError == UPNP_SOCKETERROR ) {
|
if( sockError == UPNP_SOCKETERROR ) {
|
||||||
shutdown( listenfd, SD_BOTH );
|
shutdown( listenfd, SD_BOTH );
|
||||||
UpnpCloseSocket( listenfd );
|
UpnpCloseSocket( listenfd );
|
||||||
@ -665,16 +636,14 @@ get_miniserver_sockets( MiniServerSockArray * out,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( sockError == UPNP_SOCKETERROR ) {
|
if( sockError == UPNP_SOCKETERROR ) {
|
||||||
DBGONLY( perror( "mserv start: bind failed" );
|
perror( "mserv start: bind failed" );
|
||||||
)
|
|
||||||
shutdown( listenfd, SD_BOTH );
|
shutdown( listenfd, SD_BOTH );
|
||||||
UpnpCloseSocket( listenfd );
|
UpnpCloseSocket( listenfd );
|
||||||
return UPNP_E_SOCKET_BIND; // bind failed
|
return UPNP_E_SOCKET_BIND; // bind failed
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||||
"mserv start: bind success\n" );
|
"mserv start: bind success\n" );
|
||||||
)
|
|
||||||
|
|
||||||
success = listen( listenfd, SOMAXCONN );
|
success = listen( listenfd, SOMAXCONN );
|
||||||
if( success == UPNP_SOCKETERROR ) {
|
if( success == UPNP_SOCKETERROR ) {
|
||||||
@ -694,10 +663,9 @@ get_miniserver_sockets( MiniServerSockArray * out,
|
|||||||
|
|
||||||
if( ( miniServerStopSock = socket( AF_INET, SOCK_DGRAM, 0 ) ) ==
|
if( ( miniServerStopSock = socket( AF_INET, SOCK_DGRAM, 0 ) ) ==
|
||||||
UPNP_INVALID_SOCKET ) {
|
UPNP_INVALID_SOCKET ) {
|
||||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL,
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
MSERV, __FILE__, __LINE__,
|
MSERV, __FILE__, __LINE__,
|
||||||
"Error in socket operation !!!\n" );
|
"Error in socket operation !!!\n" );
|
||||||
)
|
|
||||||
shutdown( listenfd, SD_BOTH );
|
shutdown( listenfd, SD_BOTH );
|
||||||
UpnpCloseSocket( listenfd );
|
UpnpCloseSocket( listenfd );
|
||||||
return UPNP_E_OUTOF_SOCKET;
|
return UPNP_E_OUTOF_SOCKET;
|
||||||
@ -711,10 +679,9 @@ get_miniserver_sockets( MiniServerSockArray * out,
|
|||||||
if( bind( miniServerStopSock, ( struct sockaddr * )&serverAddr,
|
if( bind( miniServerStopSock, ( struct sockaddr * )&serverAddr,
|
||||||
sizeof( serverAddr ) ) == UPNP_SOCKETERROR ) {
|
sizeof( serverAddr ) ) == UPNP_SOCKETERROR ) {
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL,
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
MSERV, __FILE__, __LINE__,
|
MSERV, __FILE__, __LINE__,
|
||||||
"Error in binding localhost!!!\n" );
|
"Error in binding localhost!!!\n" );
|
||||||
)
|
|
||||||
shutdown( listenfd, SD_BOTH );
|
shutdown( listenfd, SD_BOTH );
|
||||||
UpnpCloseSocket( listenfd );
|
UpnpCloseSocket( listenfd );
|
||||||
shutdown( miniServerStopSock, SD_BOTH );
|
shutdown( miniServerStopSock, SD_BOTH );
|
||||||
@ -877,10 +844,8 @@ StopMiniServer( void )
|
|||||||
|
|
||||||
sock = socket( AF_INET, SOCK_DGRAM, 0 );
|
sock = socket( AF_INET, SOCK_DGRAM, 0 );
|
||||||
if( sock == UPNP_INVALID_SOCKET ) {
|
if( sock == UPNP_INVALID_SOCKET ) {
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
|
||||||
"SSDP_SERVER:StopSSDPServer: Error in socket operation !!!\n" );
|
"SSDP_SERVER:StopSSDPServer: Error in socket operation !!!\n" );
|
||||||
)
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ str_int_entry Http_Header_Names[NUM_HTTP_HEADER_NAMES] = {
|
|||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
/************* scanner **************/
|
/************* scanner *************/
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
@ -562,7 +562,7 @@ httpmsg_find_hdr_str( IN http_message_t * msg,
|
|||||||
*
|
*
|
||||||
* Description : Finds header from a list, with the given 'name_id'.
|
* Description : Finds header from a list, with the given 'name_id'.
|
||||||
*
|
*
|
||||||
* Return : http_header_t* - Pointer to a header on success; *
|
* Return : http_header_t* - Pointer to a header on success;
|
||||||
* NULL on failure
|
* NULL on failure
|
||||||
*
|
*
|
||||||
* Note :
|
* Note :
|
||||||
@ -910,7 +910,7 @@ match_int( INOUT scanner_t * scanner,
|
|||||||
* Function: read_until_crlf
|
* Function: read_until_crlf
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* INOUT scanner_t* scanner ; Scanner Object
|
* INOUT scanner_t* scanner ;Scanner Object
|
||||||
* OUT memptr* str ; Buffer to copy scanner buffer contents to
|
* OUT memptr* str ; Buffer to copy scanner buffer contents to
|
||||||
*
|
*
|
||||||
* Description: Reads data until end of line; the crlf at the end of
|
* Description: Reads data until end of line; the crlf at the end of
|
||||||
@ -979,8 +979,8 @@ skip_to_end_of_header( INOUT scanner_t * scanner )
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* INOUT scanner_t* scanner ; Scanner Object
|
* INOUT scanner_t* scanner ; Scanner Object
|
||||||
* IN char c ; Character to be compared with
|
* IN char c ; Character to be compared with
|
||||||
* IN xboolean case_sensitive; Flag indicating whether comparison should
|
* IN xboolean case_sensitive; Flag indicating whether
|
||||||
* be case sensitive
|
* comparison should be case sensitive
|
||||||
*
|
*
|
||||||
* Description: Compares a character to the next char in the scanner;
|
* Description: Compares a character to the next char in the scanner;
|
||||||
* on error, scanner chars are not restored
|
* on error, scanner chars are not restored
|
||||||
@ -2020,9 +2020,8 @@ parser_parse_chunky_entity( INOUT http_parser_t * parser )
|
|||||||
status = match( scanner, "%x%L%c", &parser->chunk_size, &dummy );
|
status = match( scanner, "%x%L%c", &parser->chunk_size, &dummy );
|
||||||
if( status != PARSE_OK ) {
|
if( status != PARSE_OK ) {
|
||||||
scanner->cursor = save_pos;
|
scanner->cursor = save_pos;
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
"CHUNK COULD NOT BE PARSED\n" );
|
||||||
"CHUNK COULD NOT BE PARSED\n" ); )
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
// remove chunk info just matched; just retain data
|
// remove chunk info just matched; just retain data
|
||||||
@ -2149,9 +2148,8 @@ parser_get_entity_read_method( INOUT http_parser_t * parser )
|
|||||||
if( raw_find_str( &hdr_value, "chunked" ) >= 0 ) {
|
if( raw_find_str( &hdr_value, "chunked" ) >= 0 ) {
|
||||||
// read method to use chunked transfer encoding
|
// read method to use chunked transfer encoding
|
||||||
parser->ent_position = ENTREAD_USING_CHUNKED;
|
parser->ent_position = ENTREAD_USING_CHUNKED;
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
"Found Chunked Encoding ....\n" );
|
||||||
"Found Chunked Encoding ....\n" ); )
|
|
||||||
|
|
||||||
return PARSE_CONTINUE_1;
|
return PARSE_CONTINUE_1;
|
||||||
}
|
}
|
||||||
@ -2470,7 +2468,7 @@ raw_find_str( IN memptr *raw_value,
|
|||||||
* nameConverts a http_method id stored in the HTTP Method
|
* nameConverts a http_method id stored in the HTTP Method
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* const char* ptr - Ptr to the HTTP Method *
|
* const char* ptr - Ptr to the HTTP Method
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
const char *
|
const char *
|
||||||
method_to_str( IN http_method_t method )
|
method_to_str( IN http_method_t method )
|
||||||
@ -2495,40 +2493,38 @@ method_to_str( IN http_method_t method )
|
|||||||
* Returns:
|
* Returns:
|
||||||
* void
|
* void
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
#ifdef DEBUG
|
||||||
void
|
void
|
||||||
print_http_headers( http_message_t * hmsg )
|
print_http_headers( http_message_t * hmsg )
|
||||||
{
|
{
|
||||||
|
|
||||||
ListNode *node;
|
ListNode *node;
|
||||||
|
// NNS: dlist_node *node;
|
||||||
//NNS: dlist_node *node;
|
|
||||||
http_header_t *header;
|
http_header_t *header;
|
||||||
|
|
||||||
// print start line
|
// print start line
|
||||||
if( hmsg->is_request ) {
|
if( hmsg->is_request ) {
|
||||||
//printf( "method = %d, version = %d.%d, url = %.*s\n",
|
printf( "method = %d, version = %d.%d, url = %.*s\n",
|
||||||
// hmsg->method, hmsg->major_version, hmsg->minor_version,
|
hmsg->method, hmsg->major_version, hmsg->minor_version,
|
||||||
// hmsg->uri.pathquery.size, hmsg->uri.pathquery.buff);
|
hmsg->uri.pathquery.size, hmsg->uri.pathquery.buff);
|
||||||
} else {
|
} else {
|
||||||
// printf( "resp status = %d, version = %d.%d, status msg = %.*s\n",
|
printf( "resp status = %d, version = %d.%d, status msg = %.*s\n",
|
||||||
// hmsg->status_code, hmsg->major_version, hmsg->minor_version,
|
hmsg->status_code, hmsg->major_version, hmsg->minor_version,
|
||||||
// (int)hmsg->status_msg.length, hmsg->status_msg.buf);
|
(int)hmsg->status_msg.length, hmsg->status_msg.buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// print headers
|
// print headers
|
||||||
|
|
||||||
node = ListHead( &hmsg->headers );
|
node = ListHead( &hmsg->headers );
|
||||||
//NNS: node = dlist_first_node( &hmsg->headers );
|
// NNS: node = dlist_first_node( &hmsg->headers );
|
||||||
while( node != NULL ) {
|
while( node != NULL ) {
|
||||||
|
|
||||||
header = ( http_header_t * ) node->item;
|
header = ( http_header_t * ) node->item;
|
||||||
//NNS: header = (http_header_t *)node->data;
|
// NNS: header = (http_header_t *)node->data;
|
||||||
//printf( "hdr name: %.*s, value: %.*s\n",
|
printf( "hdr name: %.*s, value: %.*s\n",
|
||||||
// (int)header->name.length, header->name.buf,
|
(int)header->name.length, header->name.buf,
|
||||||
// (int)header->value.length, header->value.buf );
|
(int)header->value.length, header->value.buf );
|
||||||
|
|
||||||
node = ListNext( &hmsg->headers, node );
|
node = ListNext( &hmsg->headers, node );
|
||||||
|
// NNS: node = dlist_next( &hmsg->headers, node );
|
||||||
//NNS: node = dlist_next( &hmsg->headers, node );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@ -40,10 +40,10 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#ifndef UPNP_USE_BCBPP
|
#ifndef UPNP_USE_BCBPP
|
||||||
#ifndef UPNP_USE_MSVCPP
|
#ifndef UPNP_USE_MSVCPP
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
@ -169,10 +169,8 @@ http_Connect( IN uri_type * destination_url,
|
|||||||
if( connect( connfd, ( struct sockaddr * )&url->hostport.IPv4address,
|
if( connect( connfd, ( struct sockaddr * )&url->hostport.IPv4address,
|
||||||
sizeof( struct sockaddr_in ) ) == -1 ) {
|
sizeof( struct sockaddr_in ) ) == -1 ) {
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
DBGONLY(
|
|
||||||
UpnpPrintf(UPNP_CRITICAL, HTTP, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_CRITICAL, HTTP, __FILE__, __LINE__,
|
||||||
"connect error: %d\n", WSAGetLastError());
|
"connect error: %d\n", WSAGetLastError());
|
||||||
)
|
|
||||||
#endif
|
#endif
|
||||||
shutdown( connfd, SD_BOTH );
|
shutdown( connfd, SD_BOTH );
|
||||||
UpnpCloseSocket( connfd );
|
UpnpCloseSocket( connfd );
|
||||||
@ -226,12 +224,10 @@ http_RecvMessage( IN SOCKINFO * info,
|
|||||||
status = parser_append( parser, buf, num_read );
|
status = parser_append( parser, buf, num_read );
|
||||||
|
|
||||||
if( status == PARSE_SUCCESS ) {
|
if( status == PARSE_SUCCESS ) {
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
|
||||||
"<<< (RECVD) <<<\n%s\n-----------------\n",
|
"<<< (RECVD) <<<\n%s\n-----------------\n",
|
||||||
parser->msg.msg.buf );
|
parser->msg.msg.buf );
|
||||||
//print_http_headers( &parser->msg );
|
print_http_headers( &parser->msg );
|
||||||
)
|
|
||||||
|
|
||||||
if( parser->content_length >
|
if( parser->content_length >
|
||||||
( unsigned int )g_maxContentLength ) {
|
( unsigned int )g_maxContentLength ) {
|
||||||
@ -252,12 +248,10 @@ http_RecvMessage( IN SOCKINFO * info,
|
|||||||
}
|
}
|
||||||
} else if( num_read == 0 ) {
|
} else if( num_read == 0 ) {
|
||||||
if( ok_on_close ) {
|
if( ok_on_close ) {
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
|
||||||
"<<< (RECVD) <<<\n%s\n-----------------\n",
|
"<<< (RECVD) <<<\n%s\n-----------------\n",
|
||||||
parser->msg.msg.buf );
|
parser->msg.msg.buf );
|
||||||
//print_http_headers( &parser->msg );
|
print_http_headers( &parser->msg );
|
||||||
)
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
@ -455,11 +449,9 @@ http_SendMessage( IN SOCKINFO * info,
|
|||||||
num_written = sock_write( info, file_buf, num_read,
|
num_written = sock_write( info, file_buf, num_read,
|
||||||
TimeOut );
|
TimeOut );
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
|
||||||
">>> (SENT) >>>\n%.*s\n------------\n",
|
">>> (SENT) >>>\n%.*s\n------------\n",
|
||||||
( int )num_written, file_buf );
|
( int )num_written, file_buf );
|
||||||
)
|
|
||||||
|
|
||||||
//Send error nothing we can do
|
//Send error nothing we can do
|
||||||
if( num_written != num_read ) {
|
if( num_written != num_read ) {
|
||||||
@ -485,10 +477,9 @@ http_SendMessage( IN SOCKINFO * info,
|
|||||||
num_written = sock_write( info, buf, buf_length, TimeOut );
|
num_written = sock_write( info, buf, buf_length, TimeOut );
|
||||||
if( ( size_t ) num_written != buf_length )
|
if( ( size_t ) num_written != buf_length )
|
||||||
goto end;
|
goto end;
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
">>> (SENT) >>>\n%.*s\n------------\n",
|
">>> (SENT) >>>\n%.*s\n------------\n",
|
||||||
( int )buf_length, buf );
|
( int )buf_length, buf );
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -509,7 +500,7 @@ http_SendMessage( IN SOCKINFO * info,
|
|||||||
* IN size_t request_length ; Length of the request
|
* IN size_t request_length ; Length of the request
|
||||||
* IN http_method_t req_method ; HTTP Request method
|
* IN http_method_t req_method ; HTTP Request method
|
||||||
* IN int timeout_secs ; time out value
|
* IN int timeout_secs ; time out value
|
||||||
* OUT http_parser_t* response ; Parser object to receive the repsonse
|
* OUT http_parser_t* response; Parser object to receive the repsonse
|
||||||
*
|
*
|
||||||
* Description: Initiates socket, connects to the destination, sends a
|
* Description: Initiates socket, connects to the destination, sends a
|
||||||
* request and waits for the response from the remote end
|
* request and waits for the response from the remote end
|
||||||
@ -575,12 +566,12 @@ http_RequestAndResponse( IN uri_type * destination,
|
|||||||
* Function : http_Download
|
* Function : http_Download
|
||||||
*
|
*
|
||||||
* Parameters :
|
* Parameters :
|
||||||
* IN const char* url_str : String as a URL
|
* IN const char* url_str: String as a URL
|
||||||
* IN int timeout_secs : time out value
|
* IN int timeout_secs: time out value
|
||||||
* OUT char** document : buffer to store the document extracted
|
* OUT char** document: buffer to store the document extracted
|
||||||
* from the donloaded message.
|
* from the donloaded message.
|
||||||
* OUT int* doc_length : length of the extracted document
|
* OUT int* doc_length: length of the extracted document
|
||||||
* OUT char* content_type : Type of content
|
* OUT char* content_type: Type of content
|
||||||
*
|
*
|
||||||
* Description : Download the document message and extract the document
|
* Description : Download the document message and extract the document
|
||||||
* from the message.
|
* from the message.
|
||||||
@ -589,7 +580,6 @@ http_RequestAndResponse( IN uri_type * destination,
|
|||||||
* UPNP_E_SUCCESS;
|
* UPNP_E_SUCCESS;
|
||||||
* UPNP_E_INVALID_URL;
|
* UPNP_E_INVALID_URL;
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* Note :
|
* Note :
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
@ -601,10 +591,10 @@ http_Download( IN const char *url_str,
|
|||||||
{
|
{
|
||||||
int ret_code;
|
int ret_code;
|
||||||
uri_type url;
|
uri_type url;
|
||||||
char *msg_start,
|
char *msg_start;
|
||||||
*entity_start,
|
char *entity_start;
|
||||||
*hoststr,
|
char *hoststr;
|
||||||
*temp;
|
char *temp;
|
||||||
http_parser_t response;
|
http_parser_t response;
|
||||||
size_t msg_length;
|
size_t msg_length;
|
||||||
size_t hostlen;
|
size_t hostlen;
|
||||||
@ -614,10 +604,8 @@ http_Download( IN const char *url_str,
|
|||||||
char *urlPath = alloca( strlen( url_str ) + 1 );
|
char *urlPath = alloca( strlen( url_str ) + 1 );
|
||||||
|
|
||||||
//ret_code = parse_uri( (char*)url_str, strlen(url_str), &url );
|
//ret_code = parse_uri( (char*)url_str, strlen(url_str), &url );
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, "DOWNLOAD URL : %s\n",
|
||||||
( UPNP_INFO, HTTP, __FILE__, __LINE__, "DOWNLOAD URL : %s\n",
|
|
||||||
url_str );
|
url_str );
|
||||||
)
|
|
||||||
ret_code =
|
ret_code =
|
||||||
http_FixStrUrl( ( char * )url_str, strlen( url_str ), &url );
|
http_FixStrUrl( ( char * )url_str, strlen( url_str ), &url );
|
||||||
if( ret_code != UPNP_E_SUCCESS ) {
|
if( ret_code != UPNP_E_SUCCESS ) {
|
||||||
@ -641,10 +629,8 @@ http_Download( IN const char *url_str,
|
|||||||
*temp = '\0';
|
*temp = '\0';
|
||||||
hostlen = strlen( hoststr );
|
hostlen = strlen( hoststr );
|
||||||
*temp = '/';
|
*temp = '/';
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
|
||||||
"HOSTNAME : %s Length : %"PRIzu"\n", hoststr, hostlen );
|
"HOSTNAME : %s Length : %"PRIzu"\n", hoststr, hostlen );
|
||||||
)
|
|
||||||
|
|
||||||
ret_code = http_MakeMessage(
|
ret_code = http_MakeMessage(
|
||||||
&request, 1, 1,
|
&request, 1, 1,
|
||||||
@ -653,18 +639,14 @@ http_Download( IN const char *url_str,
|
|||||||
"HOST: ",
|
"HOST: ",
|
||||||
hoststr, hostlen );
|
hoststr, hostlen );
|
||||||
if( ret_code != 0 ) {
|
if( ret_code != 0 ) {
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
|
||||||
"HTTP Makemessage failed\n" );
|
"HTTP Makemessage failed\n" );
|
||||||
)
|
|
||||||
membuffer_destroy( &request );
|
membuffer_destroy( &request );
|
||||||
return ret_code;
|
return ret_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
|
||||||
"HTTP Buffer:\n %s\n----------END--------\n", request.buf );
|
"HTTP Buffer:\n %s\n----------END--------\n", request.buf );
|
||||||
)
|
|
||||||
// get doc msg
|
// get doc msg
|
||||||
ret_code =
|
ret_code =
|
||||||
http_RequestAndResponse( &url, request.buf, request.length,
|
http_RequestAndResponse( &url, request.buf, request.length,
|
||||||
@ -676,11 +658,8 @@ http_Download( IN const char *url_str,
|
|||||||
return ret_code;
|
return ret_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, "Response\n" );
|
||||||
( UPNP_INFO, HTTP, __FILE__, __LINE__, "Response\n" );
|
print_http_headers( &response.msg );
|
||||||
)
|
|
||||||
DBGONLY( print_http_headers( &response.msg );
|
|
||||||
)
|
|
||||||
|
|
||||||
// optional content-type
|
// optional content-type
|
||||||
if( content_type ) {
|
if( content_type ) {
|
||||||
@ -771,13 +750,10 @@ MakePostMessage( const char *url_str,
|
|||||||
char *hoststr,
|
char *hoststr,
|
||||||
*temp;
|
*temp;
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
"DOWNLOAD URL : %s\n", url_str );
|
"DOWNLOAD URL : %s\n", url_str );
|
||||||
)
|
|
||||||
|
|
||||||
ret_code =
|
ret_code =
|
||||||
http_FixStrUrl( ( char * )url_str, strlen( url_str ), url );
|
http_FixStrUrl( ( char * )url_str, strlen( url_str ), url );
|
||||||
|
|
||||||
if( ret_code != UPNP_E_SUCCESS ) {
|
if( ret_code != UPNP_E_SUCCESS ) {
|
||||||
return ret_code;
|
return ret_code;
|
||||||
}
|
}
|
||||||
@ -799,9 +775,8 @@ MakePostMessage( const char *url_str,
|
|||||||
*temp = '\0';
|
*temp = '\0';
|
||||||
hostlen = strlen( hoststr );
|
hostlen = strlen( hoststr );
|
||||||
*temp = '/';
|
*temp = '/';
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
"HOSTNAME : %s Length : %"PRIzu"\n", hoststr, hostlen );
|
"HOSTNAME : %s Length : %"PRIzu"\n", hoststr, hostlen );
|
||||||
)
|
|
||||||
|
|
||||||
if( contentLength >= 0 ) {
|
if( contentLength >= 0 ) {
|
||||||
ret_code = http_MakeMessage(
|
ret_code = http_MakeMessage(
|
||||||
@ -833,17 +808,16 @@ MakePostMessage( const char *url_str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( ret_code != 0 ) {
|
if( ret_code != 0 ) {
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
"HTTP Makemessage failed\n" );
|
"HTTP Makemessage failed\n" );
|
||||||
)
|
|
||||||
membuffer_destroy( request );
|
membuffer_destroy( request );
|
||||||
|
|
||||||
return ret_code;
|
return ret_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
"HTTP Buffer:\n %s\n" "----------END--------\n",
|
"HTTP Buffer:\n %s\n" "----------END--------\n",
|
||||||
request->buf );
|
request->buf );
|
||||||
)
|
|
||||||
|
|
||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -1108,9 +1082,8 @@ MakeGetMessage( const char *url_str,
|
|||||||
char *hoststr,
|
char *hoststr,
|
||||||
*temp;
|
*temp;
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
"DOWNLOAD URL : %s\n", url_str );
|
"DOWNLOAD URL : %s\n", url_str );
|
||||||
)
|
|
||||||
|
|
||||||
ret_code =
|
ret_code =
|
||||||
http_FixStrUrl( ( char * )url_str, strlen( url_str ), url );
|
http_FixStrUrl( ( char * )url_str, strlen( url_str ), url );
|
||||||
@ -1136,9 +1109,8 @@ MakeGetMessage( const char *url_str,
|
|||||||
*temp = '\0';
|
*temp = '\0';
|
||||||
hostlen = strlen( hoststr );
|
hostlen = strlen( hoststr );
|
||||||
*temp = '/';
|
*temp = '/';
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
"HOSTNAME : %s Length : %"PRIzu"\n", hoststr, hostlen );
|
"HOSTNAME : %s Length : %"PRIzu"\n", hoststr, hostlen );
|
||||||
)
|
|
||||||
|
|
||||||
if( proxy_str ) {
|
if( proxy_str ) {
|
||||||
querystr = url_str;
|
querystr = url_str;
|
||||||
@ -1156,17 +1128,16 @@ MakeGetMessage( const char *url_str,
|
|||||||
hoststr, hostlen );
|
hoststr, hostlen );
|
||||||
|
|
||||||
if( ret_code != 0 ) {
|
if( ret_code != 0 ) {
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
"HTTP Makemessage failed\n" );
|
"HTTP Makemessage failed\n" );
|
||||||
)
|
|
||||||
membuffer_destroy( request );
|
membuffer_destroy( request );
|
||||||
|
|
||||||
return ret_code;
|
return ret_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
"HTTP Buffer:\n %s\n" "----------END--------\n",
|
"HTTP Buffer:\n %s\n" "----------END--------\n",
|
||||||
request->buf );
|
request->buf );
|
||||||
)
|
|
||||||
|
|
||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -1386,11 +1357,9 @@ http_ReadHttpGet( IN void *Handle,
|
|||||||
}
|
}
|
||||||
} else if( num_read == 0 ) {
|
} else if( num_read == 0 ) {
|
||||||
if( ok_on_close ) {
|
if( ok_on_close ) {
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
"<<< (RECVD) <<<\n%s\n-----------------\n",
|
"<<< (RECVD) <<<\n%s\n-----------------\n",
|
||||||
handle->response.msg.msg.buf );
|
handle->response.msg.msg.buf );
|
||||||
//print_http_headers( &parser->msg );
|
|
||||||
)
|
|
||||||
handle->response.position = POS_COMPLETE;
|
handle->response.position = POS_COMPLETE;
|
||||||
} else {
|
} else {
|
||||||
// partial msg
|
// partial msg
|
||||||
@ -1850,31 +1819,26 @@ http_MakeMessage( INOUT membuffer * buf,
|
|||||||
va_start( argp, fmt );
|
va_start( argp, fmt );
|
||||||
|
|
||||||
while( ( c = *fmt++ ) != 0 ) {
|
while( ( c = *fmt++ ) != 0 ) {
|
||||||
|
if( c == 's' ) {
|
||||||
if( c == 's' ) // C string
|
// C string
|
||||||
{
|
|
||||||
s = ( char * )va_arg( argp, char * );
|
s = ( char * )va_arg( argp, char * );
|
||||||
|
|
||||||
assert( s );
|
assert( s );
|
||||||
|
UpnpPrintf(UPNP_ALL,HTTP,__FILE__,__LINE__,"Adding a string : %s\n", s);
|
||||||
//DBGONLY(UpnpPrintf(UPNP_ALL,HTTP,__FILE__,__LINE__,"Adding a string : %s\n", s);)
|
|
||||||
if( membuffer_append( buf, s, strlen( s ) ) != 0 ) {
|
if( membuffer_append( buf, s, strlen( s ) ) != 0 ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
} else if( c == 'K' ) // Add Chunky header
|
} else if( c == 'K' ) {
|
||||||
{
|
// Add Chunky header
|
||||||
if( membuffer_append
|
if( membuffer_append
|
||||||
( buf, "TRANSFER-ENCODING: chunked\r\n",
|
( buf, "TRANSFER-ENCODING: chunked\r\n",
|
||||||
strlen( "Transfer-Encoding: chunked\r\n" ) ) != 0 ) {
|
strlen( "Transfer-Encoding: chunked\r\n" ) ) != 0 ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
} else if( c == 'G' ) // Add Range header
|
} else if( c == 'G' ) {
|
||||||
{
|
// Add Range header
|
||||||
struct SendInstruction *RespInstr;
|
struct SendInstruction *RespInstr;
|
||||||
RespInstr =
|
RespInstr = (struct SendInstruction *)
|
||||||
( struct SendInstruction * )va_arg( argp,
|
va_arg( argp, struct SendInstruction *);
|
||||||
struct SendInstruction
|
|
||||||
* );
|
|
||||||
assert( RespInstr );
|
assert( RespInstr );
|
||||||
// connection header
|
// connection header
|
||||||
if( membuffer_append
|
if( membuffer_append
|
||||||
@ -1882,38 +1846,34 @@ http_MakeMessage( INOUT membuffer * buf,
|
|||||||
strlen( RespInstr->RangeHeader ) ) != 0 ) {
|
strlen( RespInstr->RangeHeader ) ) != 0 ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
|
} else if( c == 'b' ) {
|
||||||
} else if( c == 'b' ) // mem buffer
|
// mem buffer
|
||||||
{
|
|
||||||
s = ( char * )va_arg( argp, char * );
|
s = ( char * )va_arg( argp, char * );
|
||||||
|
|
||||||
//DBGONLY(UpnpPrintf(UPNP_ALL,HTTP,__FILE__,__LINE__,"Adding a char Buffer starting with: %c\n", s[0]);)
|
UpnpPrintf(UPNP_ALL,HTTP,__FILE__,__LINE__,
|
||||||
|
"Adding a char Buffer starting with: %c\n", s[0]);
|
||||||
assert( s );
|
assert( s );
|
||||||
length = ( size_t ) va_arg( argp, size_t );
|
length = ( size_t ) va_arg( argp, size_t );
|
||||||
if( membuffer_append( buf, s, length ) != 0 ) {
|
if( membuffer_append( buf, s, length ) != 0 ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if( c == 'c' ) {
|
||||||
else if( c == 'c' ) // crlf
|
// crlf
|
||||||
{
|
|
||||||
if( membuffer_append( buf, "\r\n", 2 ) != 0 ) {
|
if( membuffer_append( buf, "\r\n", 2 ) != 0 ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if( c == 'd' ) {
|
||||||
else if( c == 'd' ) // integer
|
// integer
|
||||||
{
|
|
||||||
num = ( int )va_arg( argp, int );
|
num = ( int )va_arg( argp, int );
|
||||||
|
|
||||||
sprintf( tempbuf, "%"PRIzu, num );
|
sprintf( tempbuf, "%"PRIzu, num );
|
||||||
if( membuffer_append( buf, tempbuf, strlen( tempbuf ) ) != 0 ) {
|
if( membuffer_append( buf, tempbuf, strlen( tempbuf ) ) != 0 ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if( c == 'h' ) {
|
||||||
else if( c == 'h' ) // off_t
|
// off_t
|
||||||
{
|
|
||||||
bignum = ( off_t )va_arg( argp, off_t );
|
bignum = ( off_t )va_arg( argp, off_t );
|
||||||
|
|
||||||
sprintf( tempbuf, "%"PRId64, (int64_t)bignum );
|
sprintf( tempbuf, "%"PRId64, (int64_t)bignum );
|
||||||
@ -1921,9 +1881,8 @@ http_MakeMessage( INOUT membuffer * buf,
|
|||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if( c == 't' || c == 'D' ) {
|
||||||
else if( c == 't' || c == 'D' ) // date
|
// date
|
||||||
{
|
|
||||||
if( c == 'D' ) {
|
if( c == 'D' ) {
|
||||||
// header
|
// header
|
||||||
start_str = "DATE: ";
|
start_str = "DATE: ";
|
||||||
@ -1947,9 +1906,7 @@ http_MakeMessage( INOUT membuffer * buf,
|
|||||||
if( membuffer_append( buf, tempbuf, strlen( tempbuf ) ) != 0 ) {
|
if( membuffer_append( buf, tempbuf, strlen( tempbuf ) ) != 0 ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
}
|
} else if( c == 'C' ) {
|
||||||
|
|
||||||
else if( c == 'C' ) {
|
|
||||||
if( ( http_major_version > 1 ) ||
|
if( ( http_major_version > 1 ) ||
|
||||||
( http_major_version == 1 && http_minor_version == 1 )
|
( http_major_version == 1 && http_minor_version == 1 )
|
||||||
) {
|
) {
|
||||||
@ -1959,9 +1916,7 @@ http_MakeMessage( INOUT membuffer * buf,
|
|||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if( c == 'N' ) {
|
||||||
|
|
||||||
else if( c == 'N' ) {
|
|
||||||
// content-length header
|
// content-length header
|
||||||
bignum = ( off_t )va_arg( argp, off_t );
|
bignum = ( off_t )va_arg( argp, off_t );
|
||||||
|
|
||||||
@ -1972,11 +1927,8 @@ http_MakeMessage( INOUT membuffer * buf,
|
|||||||
"CONTENT-LENGTH: ", bignum ) != 0 ) {
|
"CONTENT-LENGTH: ", bignum ) != 0 ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
}
|
} else if( c == 'S' || c == 'U' ) {
|
||||||
|
|
||||||
else if( c == 'S' || c == 'U' ) {
|
|
||||||
// SERVER or USER-AGENT header
|
// SERVER or USER-AGENT header
|
||||||
|
|
||||||
temp_str = ( c == 'S' ) ? "SERVER: " : "USER-AGENT: ";
|
temp_str = ( c == 'S' ) ? "SERVER: " : "USER-AGENT: ";
|
||||||
get_sdk_info( tempbuf );
|
get_sdk_info( tempbuf );
|
||||||
if (http_MakeMessage(
|
if (http_MakeMessage(
|
||||||
@ -1985,34 +1937,25 @@ http_MakeMessage( INOUT membuffer * buf,
|
|||||||
temp_str, tempbuf ) != 0 ) {
|
temp_str, tempbuf ) != 0 ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
}
|
} else if( c == 'X' ) {
|
||||||
|
// C string
|
||||||
else if( c == 'X' ) // C string
|
|
||||||
{
|
|
||||||
s = ( char * )va_arg( argp, char * );
|
s = ( char * )va_arg( argp, char * );
|
||||||
|
|
||||||
assert( s );
|
assert( s );
|
||||||
|
|
||||||
if( membuffer_append_str( buf, "X-User-Agent: ") != 0 ) {
|
if( membuffer_append_str( buf, "X-User-Agent: ") != 0 ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
if( membuffer_append( buf, s, strlen( s ) ) != 0 ) {
|
if( membuffer_append( buf, s, strlen( s ) ) != 0 ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
}
|
} else if( c == 'R' ) {
|
||||||
|
|
||||||
else if( c == 'R' ) {
|
|
||||||
// response start line
|
// response start line
|
||||||
// e.g.: 'HTTP/1.1 200 OK'
|
// e.g.: 'HTTP/1.1 200 OK'
|
||||||
//
|
//
|
||||||
|
|
||||||
// code
|
// code
|
||||||
status_code = ( int )va_arg( argp, int );
|
status_code = ( int )va_arg( argp, int );
|
||||||
|
|
||||||
assert( status_code > 0 );
|
assert( status_code > 0 );
|
||||||
sprintf( tempbuf, "HTTP/%d.%d %d ",
|
sprintf( tempbuf, "HTTP/%d.%d %d ",
|
||||||
http_major_version, http_minor_version, status_code );
|
http_major_version, http_minor_version, status_code );
|
||||||
|
|
||||||
// str
|
// str
|
||||||
status_msg = http_get_code_text( status_code );
|
status_msg = http_get_code_text( status_code );
|
||||||
if (http_MakeMessage(
|
if (http_MakeMessage(
|
||||||
@ -2022,40 +1965,31 @@ http_MakeMessage( INOUT membuffer * buf,
|
|||||||
status_msg ) != 0 ) {
|
status_msg ) != 0 ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
}
|
} else if( c == 'B' ) {
|
||||||
|
|
||||||
else if( c == 'B' ) {
|
|
||||||
// body of a simple reply
|
// body of a simple reply
|
||||||
//
|
//
|
||||||
|
|
||||||
status_code = ( int )va_arg( argp, int );
|
status_code = ( int )va_arg( argp, int );
|
||||||
|
|
||||||
sprintf( tempbuf, "%s%d %s%s",
|
sprintf( tempbuf, "%s%d %s%s",
|
||||||
"<html><body><h1>",
|
"<html><body><h1>",
|
||||||
status_code, http_get_code_text( status_code ),
|
status_code, http_get_code_text( status_code ),
|
||||||
"</h1></body></html>" );
|
"</h1></body></html>" );
|
||||||
bignum = strlen( tempbuf );
|
bignum = strlen( tempbuf );
|
||||||
|
|
||||||
if (http_MakeMessage(
|
if (http_MakeMessage(
|
||||||
buf, http_major_version, http_minor_version,
|
buf, http_major_version, http_minor_version,
|
||||||
"NTcs",
|
"NTcs",
|
||||||
bignum, // content-length
|
bignum, // content-length
|
||||||
"text/html", // content-type
|
"text/html", // content-type
|
||||||
tempbuf ) != 0 ) // body
|
tempbuf ) != 0 // body
|
||||||
{
|
) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
}
|
} else if( c == 'Q' ) {
|
||||||
|
|
||||||
else if( c == 'Q' ) {
|
|
||||||
// request start line
|
// request start line
|
||||||
// GET /foo/bar.html HTTP/1.1\r\n
|
// GET /foo/bar.html HTTP/1.1\r\n
|
||||||
|
|
||||||
method = ( http_method_t ) va_arg( argp, http_method_t );
|
method = ( http_method_t ) va_arg( argp, http_method_t );
|
||||||
method_str = method_to_str( method );
|
method_str = method_to_str( method );
|
||||||
url_str = ( const char * )va_arg( argp, const char * );
|
url_str = ( const char * )va_arg( argp, const char * );
|
||||||
num = ( size_t )va_arg( argp, size_t ); // length of url_str
|
num = ( size_t )va_arg( argp, size_t ); // length of url_str
|
||||||
|
|
||||||
if (http_MakeMessage(
|
if (http_MakeMessage(
|
||||||
buf, http_major_version, http_minor_version,
|
buf, http_major_version, http_minor_version,
|
||||||
"ssbsdsdc",
|
"ssbsdsdc",
|
||||||
@ -2064,20 +1998,15 @@ http_MakeMessage( INOUT membuffer * buf,
|
|||||||
" HTTP/", http_major_version, ".", http_minor_version ) != 0 ) {
|
" HTTP/", http_major_version, ".", http_minor_version ) != 0 ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
}
|
} else if( c == 'q' ) {
|
||||||
|
|
||||||
else if( c == 'q' ) {
|
|
||||||
// request start line and HOST header
|
// request start line and HOST header
|
||||||
|
|
||||||
method = ( http_method_t ) va_arg( argp, http_method_t );
|
method = ( http_method_t ) va_arg( argp, http_method_t );
|
||||||
|
|
||||||
uri_ptr = ( uri_type * ) va_arg( argp, uri_type * );
|
uri_ptr = ( uri_type * ) va_arg( argp, uri_type * );
|
||||||
assert( uri_ptr );
|
assert( uri_ptr );
|
||||||
if( http_FixUrl( uri_ptr, &url ) != 0 ) {
|
if( http_FixUrl( uri_ptr, &url ) != 0 ) {
|
||||||
error_code = UPNP_E_INVALID_URL;
|
error_code = UPNP_E_INVALID_URL;
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (http_MakeMessage(
|
if (http_MakeMessage(
|
||||||
buf, http_major_version, http_minor_version,
|
buf, http_major_version, http_minor_version,
|
||||||
"Q" "sbc",
|
"Q" "sbc",
|
||||||
@ -2085,28 +2014,23 @@ http_MakeMessage( INOUT membuffer * buf,
|
|||||||
"HOST: ", url.hostport.text.buff, url.hostport.text.size ) != 0 ) {
|
"HOST: ", url.hostport.text.buff, url.hostport.text.size ) != 0 ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
}
|
} else if( c == 'T' ) {
|
||||||
|
|
||||||
else if( c == 'T' ) {
|
|
||||||
// content type header
|
// content type header
|
||||||
temp_str = ( const char * )va_arg( argp, const char * ); // type/subtype format
|
temp_str = ( const char * )va_arg( argp, const char * ); // type/subtype format
|
||||||
|
|
||||||
if (http_MakeMessage(
|
if (http_MakeMessage(
|
||||||
buf, http_major_version, http_minor_version,
|
buf, http_major_version, http_minor_version,
|
||||||
"ssc",
|
"ssc",
|
||||||
"CONTENT-TYPE: ", temp_str ) != 0 ) {
|
"CONTENT-TYPE: ", temp_str ) != 0 ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else {
|
|
||||||
assert( 0 );
|
assert( 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_handler:
|
error_handler:
|
||||||
va_end( argp );
|
va_end( argp );
|
||||||
membuffer_destroy( buf );
|
membuffer_destroy( buf );
|
||||||
return error_code;
|
return error_code;
|
||||||
@ -2174,18 +2098,15 @@ MakeGetMessageEx( const char *url_str,
|
|||||||
*temp;
|
*temp;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
"DOWNLOAD URL : %s\n", url_str );
|
"DOWNLOAD URL : %s\n", url_str );
|
||||||
)
|
|
||||||
|
|
||||||
if( ( errCode = http_FixStrUrl( ( char * )url_str,
|
if( ( errCode = http_FixStrUrl( ( char * )url_str,
|
||||||
strlen( url_str ),
|
strlen( url_str ), url ) ) != UPNP_E_SUCCESS ) {
|
||||||
url ) ) != UPNP_E_SUCCESS ) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// make msg
|
// make msg
|
||||||
membuffer_init( request );
|
membuffer_init( request );
|
||||||
|
|
||||||
urlPath = alloca( strlen( url_str ) + 1 );
|
urlPath = alloca( strlen( url_str ) + 1 );
|
||||||
if( !urlPath ) {
|
if( !urlPath ) {
|
||||||
errCode = UPNP_E_OUTOF_MEMORY;
|
errCode = UPNP_E_OUTOF_MEMORY;
|
||||||
@ -2193,9 +2114,7 @@ MakeGetMessageEx( const char *url_str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
memset( urlPath, 0, strlen( url_str ) + 1 );
|
memset( urlPath, 0, strlen( url_str ) + 1 );
|
||||||
|
|
||||||
strcpy( urlPath, url_str );
|
strcpy( urlPath, url_str );
|
||||||
|
|
||||||
hoststr = strstr( urlPath, "//" );
|
hoststr = strstr( urlPath, "//" );
|
||||||
if( hoststr == NULL ) {
|
if( hoststr == NULL ) {
|
||||||
errCode = UPNP_E_INVALID_URL;
|
errCode = UPNP_E_INVALID_URL;
|
||||||
@ -2212,11 +2131,9 @@ MakeGetMessageEx( const char *url_str,
|
|||||||
*temp = '\0';
|
*temp = '\0';
|
||||||
hostlen = strlen( hoststr );
|
hostlen = strlen( hoststr );
|
||||||
*temp = '/';
|
*temp = '/';
|
||||||
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
|
||||||
"HOSTNAME : %s Length : %"PRIzu"\n",
|
"HOSTNAME : %s Length : %"PRIzu"\n",
|
||||||
hoststr, hostlen );
|
hoststr, hostlen );
|
||||||
)
|
|
||||||
|
|
||||||
errCode = http_MakeMessage(
|
errCode = http_MakeMessage(
|
||||||
request, 1, 1,
|
request, 1, 1,
|
||||||
@ -2227,18 +2144,17 @@ MakeGetMessageEx( const char *url_str,
|
|||||||
pRangeSpecifier );
|
pRangeSpecifier );
|
||||||
|
|
||||||
if( errCode != 0 ) {
|
if( errCode != 0 ) {
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
"HTTP Makemessage failed\n" );
|
"HTTP Makemessage failed\n" );
|
||||||
)
|
|
||||||
membuffer_destroy( request );
|
membuffer_destroy( request );
|
||||||
|
|
||||||
return errCode;
|
return errCode;
|
||||||
}
|
}
|
||||||
} while( 0 );
|
} while( 0 );
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
"HTTP Buffer:\n %s\n" "----------END--------\n",
|
"HTTP Buffer:\n %s\n" "----------END--------\n",
|
||||||
request->buf );
|
request->buf );
|
||||||
)
|
|
||||||
|
|
||||||
return errCode;
|
return errCode;
|
||||||
}
|
}
|
||||||
|
@ -637,11 +637,11 @@ get_file_info( IN const char *filename,
|
|||||||
|
|
||||||
rc = get_content_type( filename, &info->content_type );
|
rc = get_content_type( filename, &info->content_type );
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
"file info: %s, length: %lld, last_mod=%s readable=%d\n",
|
"file info: %s, length: %lld, last_mod=%s readable=%d\n",
|
||||||
filename, (long long)info->file_length,
|
filename, (long long)info->file_length,
|
||||||
asctime( gmtime( &info->last_modified ) ),
|
asctime( gmtime( &info->last_modified ) ),
|
||||||
info->is_readable ); )
|
info->is_readable );
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -1586,13 +1586,10 @@ http_RecvPostMessage( http_parser_t * parser,
|
|||||||
}
|
}
|
||||||
} else if( num_read == 0 ) {
|
} else if( num_read == 0 ) {
|
||||||
if( ok_on_close ) {
|
if( ok_on_close ) {
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
|
||||||
"<<< (RECVD) <<<\n%s\n-----------------\n",
|
"<<< (RECVD) <<<\n%s\n-----------------\n",
|
||||||
parser->msg.msg.buf );
|
parser->msg.msg.buf );
|
||||||
//print_http_headers( &parser->msg );
|
print_http_headers( &parser->msg );
|
||||||
)
|
|
||||||
|
|
||||||
parser->position = POS_COMPLETE;
|
parser->position = POS_COMPLETE;
|
||||||
} else {
|
} else {
|
||||||
// partial msg
|
// partial msg
|
||||||
@ -1760,9 +1757,8 @@ web_server_callback( IN http_parser_t * parser,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
"webserver: request processed...\n" );
|
"webserver: request processed...\n" );
|
||||||
)
|
|
||||||
|
|
||||||
membuffer_destroy( &headers );
|
membuffer_destroy( &headers );
|
||||||
membuffer_destroy( &filename );
|
membuffer_destroy( &filename );
|
||||||
|
@ -367,16 +367,20 @@ free_URL_list( URL_list * list )
|
|||||||
* uri_type *in ; URI object
|
* uri_type *in ; URI object
|
||||||
*
|
*
|
||||||
* Description : Function useful in debugging for printing a parsed uri.
|
* Description : Function useful in debugging for printing a parsed uri.
|
||||||
* Compiled out with DBGONLY macro.
|
|
||||||
*
|
*
|
||||||
* Return : void ;
|
* Return : void ;
|
||||||
*
|
*
|
||||||
* Note :
|
* Note :
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
DBGONLY( void print_uri( uri_type * in ) {
|
#ifdef DEBUG
|
||||||
|
void print_uri( uri_type *in )
|
||||||
|
{
|
||||||
print_token( &in->scheme );
|
print_token( &in->scheme );
|
||||||
print_token( &in->hostport.text );
|
print_token( &in->hostport.text );
|
||||||
print_token( &in->pathquery ); print_token( &in->fragment );} )
|
print_token( &in->pathquery );
|
||||||
|
print_token( &in->fragment );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function : print_token
|
* Function : print_token
|
||||||
@ -385,20 +389,23 @@ DBGONLY( void print_uri( uri_type * in ) {
|
|||||||
* token * in ; token
|
* token * in ; token
|
||||||
*
|
*
|
||||||
* Description : Function useful in debugging for printing a token.
|
* Description : Function useful in debugging for printing a token.
|
||||||
* Compiled out with DBGONLY macro.
|
|
||||||
*
|
*
|
||||||
* Return : void ;
|
* Return : void ;
|
||||||
*
|
*
|
||||||
* Note :
|
* Note :
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
DBGONLY( void print_token( token * in ) {
|
#ifdef DEBUG
|
||||||
|
void print_token(token * in)
|
||||||
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
printf( "Token Size : %"PRIzu"\n\'", in->size );
|
printf( "Token Size : %"PRIzu"\n\'", in->size );
|
||||||
for( i = 0; i < in->size; i++ ) {
|
for( i = 0; i < in->size; i++ ) {
|
||||||
putchar( in->buff[i] );}
|
putchar( in->buff[i] );
|
||||||
putchar( '\'' ); putchar( '\n' );}
|
}
|
||||||
|
putchar( '\'' );
|
||||||
)
|
putchar( '\n' );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function : token_string_casecmp
|
* Function : token_string_casecmp
|
||||||
@ -417,8 +424,10 @@ DBGONLY( void print_token( token * in ) {
|
|||||||
*
|
*
|
||||||
* Note :
|
* Note :
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int token_string_casecmp( token * in1,
|
int token_string_casecmp(
|
||||||
char *in2 ) {
|
token * in1,
|
||||||
|
char *in2 )
|
||||||
|
{
|
||||||
int in2_length = strlen( in2 );
|
int in2_length = strlen( in2 );
|
||||||
|
|
||||||
if( in1->size != in2_length )
|
if( in1->size != in2_length )
|
||||||
@ -790,9 +799,8 @@ remove_dots( char *in,
|
|||||||
return UPNP_E_OUTOF_MEMORY;
|
return UPNP_E_OUTOF_MEMORY;
|
||||||
|
|
||||||
Segments[0] = NULL;
|
Segments[0] = NULL;
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
( UPNP_ALL, API, __FILE__, __LINE__,
|
"REMOVE_DOTS: before: %s\n", in );
|
||||||
"REMOVE_DOTS: before: %s\n", in ) );
|
|
||||||
while( ( copyFrom < max ) && ( *copyFrom != '?' )
|
while( ( copyFrom < max ) && ( *copyFrom != '?' )
|
||||||
&& ( *copyFrom != '#' ) ) {
|
&& ( *copyFrom != '#' ) ) {
|
||||||
|
|
||||||
@ -837,9 +845,8 @@ remove_dots( char *in,
|
|||||||
}
|
}
|
||||||
( *copyTo ) = 0;
|
( *copyTo ) = 0;
|
||||||
free( Segments );
|
free( Segments );
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
( UPNP_ALL, API, __FILE__, __LINE__,
|
"REMOVE_DOTS: after: %s\n", in );
|
||||||
"REMOVE_DOTS: after: %s\n", in ) );
|
|
||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,31 +443,47 @@ FindServiceControlURLPath( service_table * table,
|
|||||||
*
|
*
|
||||||
* Note :
|
* Note :
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
DBGONLY( void printService( service_info * service, Dbg_Level level,
|
#ifdef DEBUG
|
||||||
Dbg_Module module ) {
|
void printService(
|
||||||
|
service_info *service,
|
||||||
|
Dbg_Level level,
|
||||||
|
Dbg_Module module )
|
||||||
|
{
|
||||||
if( service ) {
|
if( service ) {
|
||||||
if( service->serviceType )
|
if( service->serviceType ) {
|
||||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||||
"serviceType: %s\n", service->serviceType );
|
"serviceType: %s\n", service->serviceType );
|
||||||
if( service->serviceId )
|
}
|
||||||
UpnpPrintf( level, module, __FILE__, __LINE__, "serviceId: %s\n",
|
if( service->serviceId ) {
|
||||||
service->serviceId ); if( service->SCPDURL )
|
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||||
UpnpPrintf( level, module, __FILE__, __LINE__, "SCPDURL: %s\n",
|
"serviceId: %s\n", service->serviceId );
|
||||||
service->SCPDURL ); if( service->controlURL )
|
}
|
||||||
UpnpPrintf( level, module, __FILE__, __LINE__, "controlURL: %s\n",
|
if( service->SCPDURL ) {
|
||||||
service->controlURL ); if( service->eventURL )
|
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||||
UpnpPrintf( level, module, __FILE__, __LINE__, "eventURL: %s\n",
|
"SCPDURL: %s\n", service->SCPDURL );
|
||||||
service->eventURL ); if( service->UDN )
|
}
|
||||||
UpnpPrintf( level, module, __FILE__, __LINE__, "UDN: %s\n\n",
|
if( service->controlURL ) {
|
||||||
service->UDN ); if( service->active )
|
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||||
|
"controlURL: %s\n", service->controlURL );
|
||||||
|
}
|
||||||
|
if( service->eventURL ) {
|
||||||
|
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||||
|
"eventURL: %s\n", service->eventURL );
|
||||||
|
}
|
||||||
|
if( service->UDN ) {
|
||||||
|
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||||
|
"UDN: %s\n\n", service->UDN );
|
||||||
|
}
|
||||||
|
if( service->active ) {
|
||||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||||
"Service is active\n" );
|
"Service is active\n" );
|
||||||
else
|
} else {
|
||||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||||
"Service is inactive\n" );}
|
"Service is inactive\n" );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
)
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function : printServiceList
|
* Function : printServiceList
|
||||||
@ -484,36 +500,48 @@ DBGONLY( void printService( service_info * service, Dbg_Level level,
|
|||||||
*
|
*
|
||||||
* Note :
|
* Note :
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
DBGONLY( void printServiceList( service_info * service,
|
#ifdef DEBUG
|
||||||
|
void printServiceList(
|
||||||
|
service_info * service,
|
||||||
Dbg_Level level,
|
Dbg_Level level,
|
||||||
Dbg_Module module ) {
|
Dbg_Module module )
|
||||||
|
{
|
||||||
while( service ) {
|
while( service ) {
|
||||||
if( service->serviceType )
|
if( service->serviceType ) {
|
||||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||||
"serviceType: %s\n", service->serviceType );
|
"serviceType: %s\n", service->serviceType );
|
||||||
if( service->serviceId )
|
}
|
||||||
|
if( service->serviceId ) {
|
||||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||||
"serviceId: %s\n", service->serviceId );
|
"serviceId: %s\n", service->serviceId );
|
||||||
if( service->SCPDURL )
|
}
|
||||||
|
if( service->SCPDURL ) {
|
||||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||||
"SCPDURL: %s\n", service->SCPDURL );
|
"SCPDURL: %s\n", service->SCPDURL );
|
||||||
if( service->controlURL )
|
}
|
||||||
|
if( service->controlURL ) {
|
||||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||||
"controlURL: %s\n", service->controlURL );
|
"controlURL: %s\n", service->controlURL );
|
||||||
if( service->eventURL )
|
}
|
||||||
|
if( service->eventURL ) {
|
||||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||||
"eventURL: %s\n", service->eventURL );
|
"eventURL: %s\n", service->eventURL );
|
||||||
if( service->UDN )
|
}
|
||||||
UpnpPrintf( level, module, __FILE__, __LINE__, "UDN: %s\n\n",
|
if( service->UDN ) {
|
||||||
service->UDN ); if( service->active )
|
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||||
|
"UDN: %s\n\n", service->UDN );
|
||||||
|
}
|
||||||
|
if( service->active ) {
|
||||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||||
"Service is active\n" );
|
"Service is active\n" );
|
||||||
else
|
} else {
|
||||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||||
"Service is inactive\n" );
|
"Service is inactive\n" );
|
||||||
service = service->next;}
|
|
||||||
}
|
}
|
||||||
)
|
service = service->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function : printServiceTable
|
* Function : printServiceTable
|
||||||
@ -531,15 +559,18 @@ DBGONLY( void printService( service_info * service, Dbg_Level level,
|
|||||||
*
|
*
|
||||||
* Note :
|
* Note :
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
DBGONLY( void printServiceTable( service_table * table,
|
#ifdef DEBUG
|
||||||
|
void printServiceTable(
|
||||||
|
service_table * table,
|
||||||
Dbg_Level level,
|
Dbg_Level level,
|
||||||
Dbg_Module module ) {
|
Dbg_Module module )
|
||||||
|
{
|
||||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||||
"URL_BASE: %s\n", table->URLBase );
|
"URL_BASE: %s\n", table->URLBase );
|
||||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||||
"Services: \n" );
|
"Services: \n" );
|
||||||
printServiceList( table->serviceList, level, module );}
|
printServiceList( table->serviceList, level, module );}
|
||||||
)
|
#endif
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function : freeService
|
* Function : freeService
|
||||||
@ -554,7 +585,7 @@ DBGONLY( void printService( service_info * service, Dbg_Level level,
|
|||||||
*
|
*
|
||||||
* Note :
|
* Note :
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
void freeService( service_info * in )
|
void freeService( service_info * in )
|
||||||
{
|
{
|
||||||
if( in ) {
|
if( in ) {
|
||||||
if( in->serviceType )
|
if( in->serviceType )
|
||||||
@ -849,12 +880,10 @@ getServiceList( IXML_Node * node,
|
|||||||
( !
|
( !
|
||||||
( current->controlURL =
|
( current->controlURL =
|
||||||
resolve_rel_url( URLBase, tempDOMString ) ) ) ) {
|
resolve_rel_url( URLBase, tempDOMString ) ) ) ) {
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, GENA, __FILE__, __LINE__,
|
"BAD OR MISSING CONTROL URL" );
|
||||||
"BAD OR MISSING CONTROL URL" ) );
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||||
DBGONLY( UpnpPrintf
|
"CONTROL URL SET TO NULL IN SERVICE INFO" );
|
||||||
( UPNP_INFO, GENA, __FILE__, __LINE__,
|
|
||||||
"CONTROL URL SET TO NULL IN SERVICE INFO" ) );
|
|
||||||
current->controlURL = NULL;
|
current->controlURL = NULL;
|
||||||
fail = 0;
|
fail = 0;
|
||||||
}
|
}
|
||||||
@ -870,12 +899,10 @@ getServiceList( IXML_Node * node,
|
|||||||
( !
|
( !
|
||||||
( current->eventURL =
|
( current->eventURL =
|
||||||
resolve_rel_url( URLBase, tempDOMString ) ) ) ) {
|
resolve_rel_url( URLBase, tempDOMString ) ) ) ) {
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, GENA, __FILE__, __LINE__,
|
"BAD OR MISSING EVENT URL" );
|
||||||
"BAD OR MISSING EVENT URL" ) );
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||||
DBGONLY( UpnpPrintf
|
"EVENT URL SET TO NULL IN SERVICE INFO" );
|
||||||
( UPNP_INFO, GENA, __FILE__, __LINE__,
|
|
||||||
"EVENT URL SET TO NULL IN SERVICE INFO" ) );
|
|
||||||
current->eventURL = NULL;
|
current->eventURL = NULL;
|
||||||
fail = 0;
|
fail = 0;
|
||||||
}
|
}
|
||||||
|
@ -304,27 +304,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** @name DBGONLY
|
|
||||||
The {\bf DBGONLY} macro allows code to be marked so that it
|
|
||||||
is only included in the DEBUG build and not the release. To
|
|
||||||
use this macro, put the code inside of the parentheses:
|
|
||||||
|
|
||||||
{\tt DBGONLY(int i;)}
|
|
||||||
|
|
||||||
This will cause a declaration of the integer {\tt i} only
|
|
||||||
in the debug build.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//@{
|
|
||||||
#ifdef DEBUG
|
|
||||||
# define DBGONLY(x) x
|
|
||||||
#else
|
|
||||||
# define DBGONLY(x)
|
|
||||||
#endif
|
|
||||||
//@}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#undef EXCLUDE_WEB_SERVER
|
#undef EXCLUDE_WEB_SERVER
|
||||||
#undef EXCLUDE_MINISERVER
|
#undef EXCLUDE_MINISERVER
|
||||||
#ifdef INTERNAL_WEB_SERVER
|
#ifdef INTERNAL_WEB_SERVER
|
||||||
@ -368,4 +347,3 @@
|
|||||||
//@}
|
//@}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,25 +89,26 @@
|
|||||||
#define DEFAULT_TIMEOUT 1801
|
#define DEFAULT_TIMEOUT 1801
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern ithread_mutex_t GlobalClientSubscribeMutex;
|
extern ithread_mutex_t GlobalClientSubscribeMutex;
|
||||||
|
|
||||||
//Lock the subscription
|
// Lock the subscription
|
||||||
#define SubscribeLock() \
|
#define SubscribeLock() \
|
||||||
DBGONLY(UpnpPrintf(UPNP_INFO,GENA,__FILE__,__LINE__, \
|
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \
|
||||||
"Trying Subscribe Lock")); \
|
"Trying Subscribe Lock"); \
|
||||||
ithread_mutex_lock(&GlobalClientSubscribeMutex); \
|
ithread_mutex_lock(&GlobalClientSubscribeMutex); \
|
||||||
DBGONLY(UpnpPrintf(UPNP_INFO,GENA,__FILE__,__LINE__,"Subscribe Lock");)
|
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \
|
||||||
|
"Subscribe Lock");
|
||||||
|
|
||||||
//Unlock the subscription
|
// Unlock the subscription
|
||||||
#define SubscribeUnlock() \
|
#define SubscribeUnlock() \
|
||||||
DBGONLY(UpnpPrintf(UPNP_INFO,GENA,__FILE__,__LINE__, \
|
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \
|
||||||
"Trying Subscribe UnLock")); \
|
"Trying Subscribe UnLock"); \
|
||||||
ithread_mutex_unlock(&GlobalClientSubscribeMutex); \
|
ithread_mutex_unlock(&GlobalClientSubscribeMutex); \
|
||||||
DBGONLY(UpnpPrintf(UPNP_INFO,GENA,__FILE__,__LINE__,"Subscribe UnLock");)
|
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \
|
||||||
|
"Subscribe UnLock");
|
||||||
|
|
||||||
|
|
||||||
//Structure to send NOTIFY message to all subscribed control points
|
// Structure to send NOTIFY message to all subscribed control points
|
||||||
typedef struct NOTIFY_THREAD_STRUCT {
|
typedef struct NOTIFY_THREAD_STRUCT {
|
||||||
char * headers;
|
char * headers;
|
||||||
DOMString propertySet;
|
DOMString propertySet;
|
||||||
|
@ -214,37 +214,101 @@ EXTERN_C ssize_t readLine(int fd, char *out, int max, int *timeout);
|
|||||||
EXTERN_C int remove_dots(char * in, int size);
|
EXTERN_C int remove_dots(char * in, int size);
|
||||||
|
|
||||||
|
|
||||||
DBGONLY(EXTERN_C void print_http_request(http_message
|
#ifdef DEBUG
|
||||||
*message,Dbg_Level DLevel,
|
EXTERN_C void print_http_request(
|
||||||
Dbg_Module Module,char *DbgFileName,
|
http_message *message,
|
||||||
int DbgLineNo););
|
|
||||||
|
|
||||||
DBGONLY(EXTERN_C void print_http_response(http_message *message,
|
|
||||||
Dbg_Level DLevel,
|
|
||||||
Dbg_Module Module,char *DbgFileName,
|
|
||||||
int DbgLineNo););
|
|
||||||
|
|
||||||
DBGONLY(EXTERN_C void print_token( token * in,
|
|
||||||
Dbg_Level DLevel,
|
Dbg_Level DLevel,
|
||||||
Dbg_Module Module,
|
Dbg_Module Module,
|
||||||
char *DbgFileName,
|
char *DbgFileName,
|
||||||
int DbgLineNo););
|
int DbgLineNo);
|
||||||
|
#else
|
||||||
DBGONLY(EXTERN_C void print_status_line(http_status *in,
|
static inline void print_http_request(
|
||||||
|
http_message *message,
|
||||||
Dbg_Level DLevel,
|
Dbg_Level DLevel,
|
||||||
Dbg_Module Module,
|
Dbg_Module Module,
|
||||||
char *DbgFileName,
|
char *DbgFileName,
|
||||||
int DbgLineNo););
|
int DbgLineNo) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
DBGONLY(EXTERN_C void print_request_line(http_request *in,
|
#ifdef DEBUG
|
||||||
Dbg_Level DLevel,
|
EXTERN_C void print_http_response(
|
||||||
Dbg_Module Module,
|
http_message *message,
|
||||||
char *DbgFileName,int DbgLineNo));
|
|
||||||
|
|
||||||
DBGONLY(EXTERN_C void print_uri( uri_type *in,
|
|
||||||
Dbg_Level DLevel,
|
Dbg_Level DLevel,
|
||||||
Dbg_Module Module,
|
Dbg_Module Module,
|
||||||
char *DbgFileName,
|
char *DbgFileName,
|
||||||
int DbgLineNo););
|
int DbgLineNo);
|
||||||
|
#else
|
||||||
|
static inline void print_http_response(
|
||||||
|
http_message *message,
|
||||||
|
Dbg_Level DLevel,
|
||||||
|
Dbg_Module Module,
|
||||||
|
char *DbgFileName,
|
||||||
|
int DbgLineNo) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
EXTERN_C void print_token(
|
||||||
|
token *in,
|
||||||
|
Dbg_Level DLevel,
|
||||||
|
Dbg_Module Module,
|
||||||
|
char *DbgFileName,
|
||||||
|
int DbgLineNo);
|
||||||
|
#else
|
||||||
|
static inline void print_token(
|
||||||
|
token *in,
|
||||||
|
Dbg_Level DLevel,
|
||||||
|
Dbg_Module Module,
|
||||||
|
char *DbgFileName,
|
||||||
|
int DbgLineNo) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
EXTERN_C void print_status_line(
|
||||||
|
http_status *in,
|
||||||
|
Dbg_Level DLevel,
|
||||||
|
Dbg_Module Module,
|
||||||
|
char *DbgFileName,
|
||||||
|
int DbgLineNo);
|
||||||
|
#else
|
||||||
|
static inline void print_status_line(
|
||||||
|
http_status *in,
|
||||||
|
Dbg_Level DLevel,
|
||||||
|
Dbg_Module Module,
|
||||||
|
char *DbgFileName,
|
||||||
|
int DbgLineNo) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
EXTERN_C void print_request_line(
|
||||||
|
http_request *in,
|
||||||
|
Dbg_Level DLevel,
|
||||||
|
Dbg_Module Module,
|
||||||
|
char *DbgFileName,
|
||||||
|
int DbgLineNo);
|
||||||
|
#else
|
||||||
|
static inline void print_request_line(
|
||||||
|
http_request *in,
|
||||||
|
Dbg_Level DLevel,
|
||||||
|
Dbg_Module Module,
|
||||||
|
char *DbgFileName,
|
||||||
|
int DbgLineNo) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
EXTERN_C void print_uri(
|
||||||
|
uri_type *in,
|
||||||
|
Dbg_Level DLevel,
|
||||||
|
Dbg_Module Module,
|
||||||
|
char *DbgFileName,
|
||||||
|
int DbgLineNo);
|
||||||
|
#else
|
||||||
|
static inline void print_uri(
|
||||||
|
uri_type *in,
|
||||||
|
Dbg_Level DLevel,
|
||||||
|
Dbg_Module Module,
|
||||||
|
char *DbgFileName,
|
||||||
|
int DbgLineNo) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -488,7 +488,11 @@ const char* method_to_str( IN http_method_t method );
|
|||||||
* Returns:
|
* Returns:
|
||||||
* void
|
* void
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
void print_http_headers( IN http_message_t* hmsg );
|
#ifdef DEBUG
|
||||||
|
void print_http_headers( IN http_message_t *hmsg );
|
||||||
|
#else
|
||||||
|
static inline void print_http_headers( IN http_message_t *hmsg ) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
@ -496,3 +500,4 @@ void print_http_headers( IN http_message_t* hmsg );
|
|||||||
|
|
||||||
|
|
||||||
#endif // GENLIB_NET_HTTP_HTTPPARSER_H
|
#endif // GENLIB_NET_HTTP_HTTPPARSER_H
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ extern "C" {
|
|||||||
|
|
||||||
#define SID_SIZE 41
|
#define SID_SIZE 41
|
||||||
|
|
||||||
DEVICEONLY(
|
#ifdef INCLUDE_DEVICE_APIS
|
||||||
|
|
||||||
typedef struct SUBSCRIPTION {
|
typedef struct SUBSCRIPTION {
|
||||||
Upnp_SID sid;
|
Upnp_SID sid;
|
||||||
@ -263,9 +263,17 @@ service_info * FindServiceControlURLPath( service_table *table,
|
|||||||
*
|
*
|
||||||
* Note :
|
* Note :
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
DBGONLY(void printService(service_info *service,Dbg_Level
|
#ifdef DEBUG
|
||||||
level,
|
void printService(
|
||||||
Dbg_Module module));
|
service_info *service,
|
||||||
|
Dbg_Level level,
|
||||||
|
Dbg_Module module);
|
||||||
|
#else
|
||||||
|
static inline void printService(
|
||||||
|
service_info *service,
|
||||||
|
Dbg_Level level,
|
||||||
|
Dbg_Module module) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function : printServiceList
|
* Function : printServiceList
|
||||||
@ -282,8 +290,17 @@ DBGONLY(void printService(service_info *service,Dbg_Level
|
|||||||
*
|
*
|
||||||
* Note :
|
* Note :
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
DBGONLY(void printServiceList(service_info *service,
|
#ifdef DEBUG
|
||||||
Dbg_Level level, Dbg_Module module));
|
void printServiceList(
|
||||||
|
service_info *service,
|
||||||
|
Dbg_Level level,
|
||||||
|
Dbg_Module module);
|
||||||
|
#else
|
||||||
|
static inline void printServiceList(
|
||||||
|
service_info *service,
|
||||||
|
Dbg_Level level,
|
||||||
|
Dbg_Module module) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function : printServiceTable
|
* Function : printServiceTable
|
||||||
@ -301,9 +318,17 @@ DBGONLY(void printServiceList(service_info *service,
|
|||||||
*
|
*
|
||||||
* Note :
|
* Note :
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
DBGONLY(void printServiceTable(service_table *
|
#ifdef DEBUG
|
||||||
table,Dbg_Level
|
void printServiceTable(
|
||||||
level,Dbg_Module module));
|
service_table *table,
|
||||||
|
Dbg_Level level,
|
||||||
|
Dbg_Module module);
|
||||||
|
#else
|
||||||
|
static inline void printServiceTable(
|
||||||
|
service_table *table,
|
||||||
|
Dbg_Level level,
|
||||||
|
Dbg_Module module) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function : freeService
|
* Function : freeService
|
||||||
@ -451,10 +476,11 @@ int getSubElement(const char *element_name, IXML_Node *node,
|
|||||||
IXML_Node **out);
|
IXML_Node **out);
|
||||||
|
|
||||||
|
|
||||||
) /* DEVICEONLY */
|
#endif /* INCLUDE_DEVICE_APIS */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _SERVICE_TABLE */
|
#endif /* _SERVICE_TABLE */
|
||||||
|
|
||||||
|
@ -96,8 +96,16 @@ struct Handle_Info
|
|||||||
extern ithread_mutex_t GlobalHndMutex;
|
extern ithread_mutex_t GlobalHndMutex;
|
||||||
Upnp_Handle_Type GetHandleInfo(int Hnd, struct Handle_Info **HndInfo);
|
Upnp_Handle_Type GetHandleInfo(int Hnd, struct Handle_Info **HndInfo);
|
||||||
|
|
||||||
#define HandleLock() DBGONLY(UpnpPrintf(UPNP_INFO,API,__FILE__,__LINE__,"Trying Lock")); ithread_mutex_lock(&GlobalHndMutex); DBGONLY(UpnpPrintf(UPNP_INFO,API,__FILE__,__LINE__,"LOCK"));
|
#define HandleLock() \
|
||||||
#define HandleUnlock() DBGONLY(UpnpPrintf(UPNP_INFO,API,__FILE__,__LINE__,"Trying Unlock")); ithread_mutex_unlock(&GlobalHndMutex); DBGONLY(UpnpPrintf(UPNP_INFO,API,__FILE__,__LINE__,"Unlock"));
|
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Trying Lock"); \
|
||||||
|
ithread_mutex_lock(&GlobalHndMutex); \
|
||||||
|
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "LOCK");
|
||||||
|
|
||||||
|
#define HandleUnlock() \
|
||||||
|
UpnpPrintf(UPNP_INFO, API,__FILE__, __LINE__, "Trying Unlock"); \
|
||||||
|
ithread_mutex_unlock(&GlobalHndMutex); \
|
||||||
|
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Unlock");
|
||||||
|
|
||||||
Upnp_Handle_Type GetClientHandleInfo(int *client_handle_out,
|
Upnp_Handle_Type GetClientHandleInfo(int *client_handle_out,
|
||||||
struct Handle_Info **HndInfo);
|
struct Handle_Info **HndInfo);
|
||||||
Upnp_Handle_Type GetDeviceHandleInfo(int *device_handle_out,
|
Upnp_Handle_Type GetDeviceHandleInfo(int *device_handle_out,
|
||||||
|
@ -182,13 +182,16 @@ void free_URL_list(URL_list * list);
|
|||||||
* uri_type *in ; URI object
|
* uri_type *in ; URI object
|
||||||
*
|
*
|
||||||
* Description : Function useful in debugging for printing a parsed uri.
|
* Description : Function useful in debugging for printing a parsed uri.
|
||||||
* Compiled out with DBGONLY macro.
|
|
||||||
*
|
*
|
||||||
* Return : void ;
|
* Return : void ;
|
||||||
*
|
*
|
||||||
* Note :
|
* Note :
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
DBGONLY(void print_uri( uri_type *in);)
|
#ifdef DEBUG
|
||||||
|
void print_uri(uri_type *in);
|
||||||
|
#else
|
||||||
|
static inline void print_uri(uri_type *in) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function : print_token
|
* Function : print_token
|
||||||
@ -197,13 +200,16 @@ DBGONLY(void print_uri( uri_type *in);)
|
|||||||
* token * in ;
|
* token * in ;
|
||||||
*
|
*
|
||||||
* Description : Function useful in debugging for printing a token.
|
* Description : Function useful in debugging for printing a token.
|
||||||
* Compiled out with DBGONLY macro.
|
|
||||||
*
|
*
|
||||||
* Return : void ;
|
* Return : void ;
|
||||||
*
|
*
|
||||||
* Note :
|
* Note :
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
void print_token( token * in);
|
#ifdef DEBUG
|
||||||
|
void print_token(token *in);
|
||||||
|
#else
|
||||||
|
static inline void print_token(token * in) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function : token_string_casecmp
|
* Function : token_string_casecmp
|
||||||
|
@ -619,9 +619,8 @@ SoapSendAction( IN char *action_url,
|
|||||||
|
|
||||||
err_code = UPNP_E_OUTOF_MEMORY; // default error
|
err_code = UPNP_E_OUTOF_MEMORY; // default error
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||||
"Inside SoapSendAction():" );
|
"Inside SoapSendAction():" );
|
||||||
)
|
|
||||||
// init
|
// init
|
||||||
membuffer_init( &request );
|
membuffer_init( &request );
|
||||||
membuffer_init( &responsename );
|
membuffer_init( &responsename );
|
||||||
@ -642,12 +641,12 @@ SoapSendAction( IN char *action_url,
|
|||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||||
"path=%.*s, hostport=%.*s\n",
|
"path=%.*s, hostport=%.*s\n",
|
||||||
(int)url.pathquery.size,
|
(int)url.pathquery.size,
|
||||||
url.pathquery.buff,
|
url.pathquery.buff,
|
||||||
(int)url.hostport.text.size,
|
(int)url.hostport.text.size,
|
||||||
url.hostport.text.buff ); )
|
url.hostport.text.buff );
|
||||||
|
|
||||||
xml_start_len = strlen( xml_start );
|
xml_start_len = strlen( xml_start );
|
||||||
xml_end_len = strlen( xml_end );
|
xml_end_len = strlen( xml_end );
|
||||||
@ -771,9 +770,8 @@ SoapSendActionEx( IN char *action_url,
|
|||||||
|
|
||||||
err_code = UPNP_E_OUTOF_MEMORY; // default error
|
err_code = UPNP_E_OUTOF_MEMORY; // default error
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||||
"Inside SoapSendActionEx():" );
|
"Inside SoapSendActionEx():" );
|
||||||
)
|
|
||||||
// init
|
// init
|
||||||
membuffer_init( &request );
|
membuffer_init( &request );
|
||||||
membuffer_init( &responsename );
|
membuffer_init( &responsename );
|
||||||
@ -799,12 +797,12 @@ SoapSendActionEx( IN char *action_url,
|
|||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||||
"path=%.*s, hostport=%.*s\n",
|
"path=%.*s, hostport=%.*s\n",
|
||||||
(int)url.pathquery.size,
|
(int)url.pathquery.size,
|
||||||
url.pathquery.buff,
|
url.pathquery.buff,
|
||||||
(int)url.hostport.text.size,
|
(int)url.hostport.text.size,
|
||||||
url.hostport.text.buff ); )
|
url.hostport.text.buff );
|
||||||
|
|
||||||
xml_start_len = strlen( xml_start );
|
xml_start_len = strlen( xml_start );
|
||||||
xml_body_start_len = strlen( xml_body_start );
|
xml_body_start_len = strlen( xml_body_start );
|
||||||
|
@ -344,11 +344,10 @@ get_action_node( IN IXML_Document * TempDoc,
|
|||||||
int ret_code = -1; // error, by default
|
int ret_code = -1; // error, by default
|
||||||
IXML_NodeList *nl = NULL;
|
IXML_NodeList *nl = NULL;
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||||
"get_action_node(): node name =%s\n ", NodeName );
|
"get_action_node(): node name =%s\n ", NodeName );
|
||||||
)
|
|
||||||
|
|
||||||
* RespNode = NULL;
|
*RespNode = NULL;
|
||||||
|
|
||||||
// Got the Envelope node here
|
// Got the Envelope node here
|
||||||
EnvpNode = ixmlNode_getFirstChild( ( IXML_Node * ) TempDoc );
|
EnvpNode = ixmlNode_getFirstChild( ( IXML_Node * ) TempDoc );
|
||||||
@ -738,15 +737,15 @@ send_action_response( IN SOCKINFO * info,
|
|||||||
xml_response, strlen( xml_response ),
|
xml_response, strlen( xml_response ),
|
||||||
end_body, strlen( end_body ) );
|
end_body, strlen( end_body ) );
|
||||||
|
|
||||||
DBGONLY( if( ret_code != 0 ) {
|
if( ret_code != 0 ) {
|
||||||
UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||||
"Failed to send response: err code = %d\n",
|
"Failed to send response: err code = %d\n",
|
||||||
ret_code );}
|
ret_code );
|
||||||
)
|
}
|
||||||
|
|
||||||
err_code = 0;
|
err_code = 0;
|
||||||
|
|
||||||
error_handler:
|
error_handler:
|
||||||
ixmlFreeDOMString( xml_response );
|
ixmlFreeDOMString( xml_response );
|
||||||
membuffer_destroy( &headers );
|
membuffer_destroy( &headers );
|
||||||
if( err_code != 0 ) {
|
if( err_code != 0 ) {
|
||||||
@ -814,14 +813,13 @@ get_var_name( IN IXML_Document * TempDoc,
|
|||||||
Temp = ixmlNode_getNodeValue( VarNode );
|
Temp = ixmlNode_getNodeValue( VarNode );
|
||||||
linecopy( VarName, Temp );
|
linecopy( VarName, Temp );
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||||
"Received query for variable name %s\n",
|
"Received query for variable name %s\n",
|
||||||
VarName );
|
VarName );
|
||||||
)
|
|
||||||
|
|
||||||
ret_val = 0; // success
|
ret_val = 0; // success
|
||||||
|
|
||||||
error_handler:
|
error_handler:
|
||||||
return ret_val;
|
return ret_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -878,8 +876,8 @@ handle_query_variable( IN SOCKINFO * info,
|
|||||||
// send event
|
// send event
|
||||||
soap_event_callback( UPNP_CONTROL_GET_VAR_REQUEST, &variable, cookie );
|
soap_event_callback( UPNP_CONTROL_GET_VAR_REQUEST, &variable, cookie );
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||||
"Return from callback for var request\n" ) );
|
"Return from callback for var request\n" );
|
||||||
|
|
||||||
// validate, and handle result
|
// validate, and handle result
|
||||||
if( variable.CurrentVal == NULL ) {
|
if( variable.CurrentVal == NULL ) {
|
||||||
@ -968,8 +966,8 @@ handle_invoke_action( IN SOCKINFO * info,
|
|||||||
action.ErrCode = UPNP_E_SUCCESS;
|
action.ErrCode = UPNP_E_SUCCESS;
|
||||||
action.CtrlPtIPAddr = info->foreign_ip_addr;
|
action.CtrlPtIPAddr = info->foreign_ip_addr;
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||||
"Calling Callback\n" ) );
|
"Calling Callback\n" );
|
||||||
|
|
||||||
soap_event_callback( UPNP_CONTROL_ACTION_REQUEST, &action, cookie );
|
soap_event_callback( UPNP_CONTROL_ACTION_REQUEST, &action, cookie );
|
||||||
|
|
||||||
|
@ -536,9 +536,8 @@ SearchByTarget( IN int Mx,
|
|||||||
if( ReqBuf == NULL )
|
if( ReqBuf == NULL )
|
||||||
return UPNP_E_OUTOF_MEMORY;
|
return UPNP_E_OUTOF_MEMORY;
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||||
">>> SSDP SEND >>>\n%s\n", ReqBuf );
|
">>> SSDP SEND >>>\n%s\n", ReqBuf );
|
||||||
)
|
|
||||||
|
|
||||||
timeTillRead = Mx;
|
timeTillRead = Mx;
|
||||||
|
|
||||||
@ -589,26 +588,23 @@ SearchByTarget( IN int Mx,
|
|||||||
|
|
||||||
if( select( gSsdpReqSocket + 1, NULL, &wrSet, NULL, NULL )
|
if( select( gSsdpReqSocket + 1, NULL, &wrSet, NULL, NULL )
|
||||||
== UPNP_SOCKETERROR ) {
|
== UPNP_SOCKETERROR ) {
|
||||||
DBGONLY( if( errno == EBADF ) {
|
if( errno == EBADF ) {
|
||||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||||
"SSDP_LIB :RequestHandler:An invalid file descriptor"
|
"SSDP_LIB :RequestHandler:An invalid file descriptor"
|
||||||
" was givenin one of the sets. \n" );}
|
" was givenin one of the sets. \n" );
|
||||||
else
|
} else if( errno == EINTR ) {
|
||||||
if( errno == EINTR ) {
|
|
||||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||||
"SSDP_LIB :RequestHandler: A non blocked "
|
"SSDP_LIB :RequestHandler: A non blocked "
|
||||||
"signal was caught. \n" );}
|
"signal was caught. \n" );
|
||||||
else
|
} else if( errno == EINVAL ) {
|
||||||
if( errno == EINVAL ) {
|
|
||||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||||
"SSDP_LIB :RequestHandler: n is negative. \n" );}
|
"SSDP_LIB :RequestHandler: n is negative. \n" );
|
||||||
else
|
} else if( errno == ENOMEM ) {
|
||||||
if( errno == ENOMEM ) {
|
|
||||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||||
"SSDP_LIB : RequestHandler:select was unable to "
|
"SSDP_LIB : RequestHandler:select was unable to "
|
||||||
"allocate memory for internal tables.\n" );}
|
"allocate memory for internal tables.\n" );
|
||||||
)
|
}
|
||||||
shutdown( gSsdpReqSocket, SD_BOTH );
|
shutdown( gSsdpReqSocket, SD_BOTH );
|
||||||
UpnpCloseSocket( gSsdpReqSocket );
|
UpnpCloseSocket( gSsdpReqSocket );
|
||||||
free( ReqBuf );
|
free( ReqBuf );
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
|
@ -135,16 +135,16 @@ ssdp_handle_device_request( IN http_message_t * hmsg,
|
|||||||
return; // bad ST header
|
return; // bad ST header
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
// device info
|
// device info
|
||||||
if( GetDeviceHandleInfo( &handle, &dev_info ) != HND_DEVICE ) {
|
if( GetDeviceHandleInfo( &handle, &dev_info ) != HND_DEVICE ) {
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return; // no info found
|
return; // no info found
|
||||||
}
|
}
|
||||||
maxAge = dev_info->MaxAge;
|
maxAge = dev_info->MaxAge;
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__,
|
||||||
"ssdp_handle_device_request with Cmd %d SEARCH\n",
|
"ssdp_handle_device_request with Cmd %d SEARCH\n",
|
||||||
event.Cmd );
|
event.Cmd );
|
||||||
UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__,
|
||||||
@ -156,7 +156,7 @@ ssdp_handle_device_request( IN http_message_t * hmsg,
|
|||||||
UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__,
|
||||||
"DeviceUuid = %s\n", event.UDN );
|
"DeviceUuid = %s\n", event.UDN );
|
||||||
UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__,
|
||||||
"ServiceType = %s\n", event.ServiceType ); )
|
"ServiceType = %s\n", event.ServiceType );
|
||||||
|
|
||||||
threadArg =
|
threadArg =
|
||||||
( SsdpSearchReply * ) malloc( sizeof( SsdpSearchReply ) );
|
( SsdpSearchReply * ) malloc( sizeof( SsdpSearchReply ) );
|
||||||
@ -185,7 +185,7 @@ ssdp_handle_device_request( IN http_message_t * hmsg,
|
|||||||
mx = 1;
|
mx = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
replyTime = rand( ) % mx;
|
replyTime = rand() % mx;
|
||||||
|
|
||||||
TimerThreadSchedule( &gTimerThread, replyTime, REL_SEC, &job,
|
TimerThreadSchedule( &gTimerThread, replyTime, REL_SEC, &job,
|
||||||
SHORT_TERM, NULL );
|
SHORT_TERM, NULL );
|
||||||
@ -220,9 +220,9 @@ NewRequestHandler( IN struct sockaddr_in *DestAddr,
|
|||||||
|
|
||||||
ReplySock = socket( AF_INET, SOCK_DGRAM, 0 );
|
ReplySock = socket( AF_INET, SOCK_DGRAM, 0 );
|
||||||
if( ReplySock == UPNP_INVALID_SOCKET ) {
|
if( ReplySock == UPNP_INVALID_SOCKET ) {
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||||
"SSDP_LIB: New Request Handler:"
|
"SSDP_LIB: New Request Handler:"
|
||||||
"Error in socket operation !!!\n" ) );
|
"Error in socket operation !!!\n" );
|
||||||
|
|
||||||
return UPNP_E_OUTOF_SOCKET;
|
return UPNP_E_OUTOF_SOCKET;
|
||||||
}
|
}
|
||||||
@ -247,10 +247,9 @@ NewRequestHandler( IN struct sockaddr_in *DestAddr,
|
|||||||
// So, NUM_COPY has been changed from 2 to 1.
|
// So, NUM_COPY has been changed from 2 to 1.
|
||||||
NumCopy = 0;
|
NumCopy = 0;
|
||||||
while( NumCopy < NUM_COPY ) {
|
while( NumCopy < NUM_COPY ) {
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||||
">>> SSDP SEND >>>\n%s\n",
|
">>> SSDP SEND >>>\n%s\n",
|
||||||
*( RqPacket + Index ) );
|
*( RqPacket + Index ) );
|
||||||
)
|
|
||||||
rc = sendto( ReplySock, *( RqPacket + Index ),
|
rc = sendto( ReplySock, *( RqPacket + Index ),
|
||||||
strlen( *( RqPacket + Index ) ),
|
strlen( *( RqPacket + Index ) ),
|
||||||
0, ( struct sockaddr * )DestAddr, socklen );
|
0, ( struct sockaddr * )DestAddr, socklen );
|
||||||
@ -388,9 +387,8 @@ DeviceAdvertisement( IN char *DevType,
|
|||||||
char *msgs[3];
|
char *msgs[3];
|
||||||
int ret_code;
|
int ret_code;
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||||
"In function SendDeviceAdvertisemenrt\n" );
|
"In function SendDeviceAdvertisemenrt\n" );
|
||||||
)
|
|
||||||
|
|
||||||
DestAddr.sin_family = AF_INET;
|
DestAddr.sin_family = AF_INET;
|
||||||
DestAddr.sin_addr.s_addr = inet_addr( SSDP_IP );
|
DestAddr.sin_addr.s_addr = inet_addr( SSDP_IP );
|
||||||
@ -783,8 +781,8 @@ DeviceShutdown( IN char *DevType,
|
|||||||
Mil_Usn, Location, Duration, &msgs[0] );
|
Mil_Usn, Location, Duration, &msgs[0] );
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||||
"In function DeviceShutdown\n" ); )
|
"In function DeviceShutdown\n" );
|
||||||
// both root and sub-devices need to send these two messages
|
// both root and sub-devices need to send these two messages
|
||||||
CreateServicePacket( MSGTYPE_SHUTDOWN, Udn, Udn,
|
CreateServicePacket( MSGTYPE_SHUTDOWN, Udn, Udn,
|
||||||
Location, Duration, &msgs[1] );
|
Location, Duration, &msgs[1] );
|
||||||
|
@ -91,7 +91,7 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
|||||||
* Returns: int
|
* Returns: int
|
||||||
* UPNP_E_SUCCESS if successful else appropriate error
|
* UPNP_E_SUCCESS if successful else appropriate error
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
int AdvertiseAndReply( IN int AdFlag,
|
int AdvertiseAndReply( IN int AdFlag,
|
||||||
IN UpnpDevice_Handle Hnd,
|
IN UpnpDevice_Handle Hnd,
|
||||||
IN enum SsdpSearchType SearchType,
|
IN enum SsdpSearchType SearchType,
|
||||||
IN struct sockaddr_in *DestAddr,
|
IN struct sockaddr_in *DestAddr,
|
||||||
@ -115,14 +115,14 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
|||||||
const DOMString tmpStr;
|
const DOMString tmpStr;
|
||||||
char SERVER[200];
|
char SERVER[200];
|
||||||
|
|
||||||
DBGONLY( const DOMString dbgStr;
|
const DOMString dbgStr;
|
||||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
"Inside AdvertiseAndReply with AdFlag = %d\n",
|
"Inside AdvertiseAndReply with AdFlag = %d\n",
|
||||||
AdFlag ); )
|
AdFlag );
|
||||||
|
|
||||||
HandleLock( );
|
HandleLock();
|
||||||
if( GetHandleInfo( Hnd, &SInfo ) != HND_DEVICE ) {
|
if( GetHandleInfo( Hnd, &SInfo ) != HND_DEVICE ) {
|
||||||
HandleUnlock( );
|
HandleUnlock();
|
||||||
return UPNP_E_INVALID_HANDLE;
|
return UPNP_E_INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
defaultExp = SInfo->MaxAge;
|
defaultExp = SInfo->MaxAge;
|
||||||
@ -139,24 +139,20 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
|||||||
// parse the device list and send advertisements/replies
|
// parse the device list and send advertisements/replies
|
||||||
for( i = 0;; i++ ) {
|
for( i = 0;; i++ ) {
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
"Entering new device list with i = %d\n\n",
|
"Entering new device list with i = %d\n\n", i );
|
||||||
i );
|
|
||||||
)
|
|
||||||
|
|
||||||
tmpNode = ixmlNodeList_item( SInfo->DeviceList, i );
|
tmpNode = ixmlNodeList_item( SInfo->DeviceList, i );
|
||||||
if( tmpNode == NULL ) {
|
if( tmpNode == NULL ) {
|
||||||
DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
"Exiting new device list with i = %d\n\n",
|
"Exiting new device list with i = %d\n\n", i );
|
||||||
i );
|
|
||||||
)
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( dbgStr = ixmlNode_getNodeName( tmpNode );
|
dbgStr = ixmlNode_getNodeName( tmpNode );
|
||||||
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||||
"Extracting device type once for %s\n",
|
"Extracting device type once for %s\n",
|
||||||
dbgStr ); )
|
dbgStr );
|
||||||
// extract device type
|
// extract device type
|
||||||
ixmlNodeList_free( nodeList );
|
ixmlNodeList_free( nodeList );
|
||||||
nodeList = NULL;
|
nodeList = NULL;
|
||||||
@ -167,13 +163,12 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( dbgStr = ixmlNode_getNodeName( tmpNode );
|
dbgStr = ixmlNode_getNodeName( tmpNode );
|
||||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
"Extracting UDN for %s\n", dbgStr ); )
|
"Extracting UDN for %s\n", dbgStr );
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
"Extracting device type\n" );
|
"Extracting device type\n" );
|
||||||
)
|
|
||||||
|
|
||||||
tmpNode2 = ixmlNodeList_item( nodeList, 0 );
|
tmpNode2 = ixmlNodeList_item( nodeList, 0 );
|
||||||
if( tmpNode2 == NULL ) {
|
if( tmpNode2 == NULL ) {
|
||||||
@ -184,9 +179,8 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
"Extracting device type \n" );
|
"Extracting device type \n" );
|
||||||
)
|
|
||||||
|
|
||||||
tmpStr = ixmlNode_getNodeValue( textNode );
|
tmpStr = ixmlNode_getNodeValue( textNode );
|
||||||
if( tmpStr == NULL ) {
|
if( tmpStr == NULL ) {
|
||||||
@ -198,47 +192,41 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
"Extracting device type = %s\n", devType );
|
"Extracting device type = %s\n", devType );
|
||||||
if( tmpNode == NULL ) {
|
if( tmpNode == NULL ) {
|
||||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
"TempNode is NULL\n" );}
|
"TempNode is NULL\n" );
|
||||||
|
}
|
||||||
dbgStr = ixmlNode_getNodeName( tmpNode );
|
dbgStr = ixmlNode_getNodeName( tmpNode );
|
||||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
"Extracting UDN for %s\n", dbgStr ); )
|
"Extracting UDN for %s\n", dbgStr );
|
||||||
// extract UDN
|
// extract UDN
|
||||||
ixmlNodeList_free( nodeList );
|
ixmlNodeList_free( nodeList );
|
||||||
nodeList = NULL;
|
nodeList = NULL;
|
||||||
nodeList = ixmlElement_getElementsByTagName( ( IXML_Element * )
|
nodeList = ixmlElement_getElementsByTagName( ( IXML_Element * )
|
||||||
tmpNode, "UDN" );
|
tmpNode, "UDN" );
|
||||||
if( nodeList == NULL ) {
|
if( nodeList == NULL ) {
|
||||||
|
UpnpPrintf( UPNP_CRITICAL, API, __FILE__,
|
||||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL, API, __FILE__,
|
|
||||||
__LINE__, "UDN not found!!!\n" );
|
__LINE__, "UDN not found!!!\n" );
|
||||||
)
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
tmpNode2 = ixmlNodeList_item( nodeList, 0 );
|
tmpNode2 = ixmlNodeList_item( nodeList, 0 );
|
||||||
if( tmpNode2 == NULL ) {
|
if( tmpNode2 == NULL ) {
|
||||||
|
UpnpPrintf( UPNP_CRITICAL, API, __FILE__,
|
||||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL, API, __FILE__,
|
|
||||||
__LINE__, "UDN not found!!!\n" );
|
__LINE__, "UDN not found!!!\n" );
|
||||||
)
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
textNode = ixmlNode_getFirstChild( tmpNode2 );
|
textNode = ixmlNode_getFirstChild( tmpNode2 );
|
||||||
if( textNode == NULL ) {
|
if( textNode == NULL ) {
|
||||||
|
UpnpPrintf( UPNP_CRITICAL, API, __FILE__,
|
||||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL, API, __FILE__,
|
|
||||||
__LINE__, "UDN not found!!!\n" );
|
__LINE__, "UDN not found!!!\n" );
|
||||||
)
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
tmpStr = ixmlNode_getNodeValue( textNode );
|
tmpStr = ixmlNode_getNodeValue( textNode );
|
||||||
if( tmpStr == NULL ) {
|
if( tmpStr == NULL ) {
|
||||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__,
|
||||||
"UDN not found!!!!\n" );
|
"UDN not found!!!!\n" );
|
||||||
)
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
strcpy( UDNstr, tmpStr );
|
strcpy( UDNstr, tmpStr );
|
||||||
@ -246,9 +234,8 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||||
"Sending UDNStr = %s \n", UDNstr );
|
"Sending UDNStr = %s \n", UDNstr );
|
||||||
)
|
|
||||||
if( AdFlag ) {
|
if( AdFlag ) {
|
||||||
// send the device advertisement
|
// send the device advertisement
|
||||||
if( AdFlag == 1 ) {
|
if( AdFlag == 1 ) {
|
||||||
@ -278,22 +265,16 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
|||||||
{
|
{
|
||||||
if( DeviceUDN != NULL && strlen( DeviceUDN ) != 0 ) {
|
if( DeviceUDN != NULL && strlen( DeviceUDN ) != 0 ) {
|
||||||
if( strcasecmp( DeviceUDN, UDNstr ) ) {
|
if( strcasecmp( DeviceUDN, UDNstr ) ) {
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, API, __FILE__,
|
|
||||||
__LINE__,
|
|
||||||
"DeviceUDN=%s and search "
|
"DeviceUDN=%s and search "
|
||||||
"UDN=%s did not match\n",
|
"UDN=%s did not match\n",
|
||||||
UDNstr, DeviceUDN );
|
UDNstr, DeviceUDN );
|
||||||
)
|
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, API, __FILE__,
|
|
||||||
__LINE__,
|
|
||||||
"DeviceUDN=%s and search "
|
"DeviceUDN=%s and search "
|
||||||
"UDN=%s MATCH\n", UDNstr,
|
"UDN=%s MATCH\n", UDNstr,
|
||||||
DeviceUDN );
|
DeviceUDN );
|
||||||
)
|
|
||||||
SendReply( DestAddr, devType, 0,
|
SendReply( DestAddr, devType, 0,
|
||||||
UDNstr, SInfo->DescURL,
|
UDNstr, SInfo->DescURL,
|
||||||
defaultExp, 0 );
|
defaultExp, 0 );
|
||||||
@ -306,24 +287,17 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
|||||||
if( !strncasecmp
|
if( !strncasecmp
|
||||||
( DeviceType, devType,
|
( DeviceType, devType,
|
||||||
strlen( DeviceType ) ) ) {
|
strlen( DeviceType ) ) ) {
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||||
( UPNP_INFO, API, __FILE__, __LINE__,
|
|
||||||
"DeviceType=%s and search devType=%s MATCH\n",
|
"DeviceType=%s and search devType=%s MATCH\n",
|
||||||
devType, DeviceType );
|
devType, DeviceType );
|
||||||
)
|
|
||||||
SendReply( DestAddr, devType, 0, UDNstr,
|
SendReply( DestAddr, devType, 0, UDNstr,
|
||||||
SInfo->DescURL, defaultExp, 1 );
|
SInfo->DescURL, defaultExp, 1 );
|
||||||
}
|
} else {
|
||||||
|
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||||
DBGONLY(
|
|
||||||
else
|
|
||||||
UpnpPrintf( UPNP_INFO, API, __FILE__,
|
|
||||||
__LINE__,
|
|
||||||
"DeviceType=%s and search devType=%s"
|
"DeviceType=%s and search devType=%s"
|
||||||
" DID NOT MATCH\n",
|
" DID NOT MATCH\n",
|
||||||
devType, DeviceType );
|
devType, DeviceType );
|
||||||
)
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -332,9 +306,8 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
|||||||
}
|
}
|
||||||
// send service advertisements for services corresponding
|
// send service advertisements for services corresponding
|
||||||
// to the same device
|
// to the same device
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||||
"Sending service Advertisement\n" );
|
"Sending service Advertisement\n" );
|
||||||
)
|
|
||||||
|
|
||||||
tmpNode = ixmlNodeList_item( SInfo->ServiceList, i );
|
tmpNode = ixmlNodeList_item( SInfo->ServiceList, i );
|
||||||
if( tmpNode == NULL ) {
|
if( tmpNode == NULL ) {
|
||||||
@ -345,9 +318,8 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
|||||||
nodeList = ixmlElement_getElementsByTagName( ( IXML_Element * )
|
nodeList = ixmlElement_getElementsByTagName( ( IXML_Element * )
|
||||||
tmpNode, "service" );
|
tmpNode, "service" );
|
||||||
if( nodeList == NULL ) {
|
if( nodeList == NULL ) {
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||||
"Service not found 3\n" );
|
"Service not found 3\n" );
|
||||||
)
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for( j = 0;; j++ ) {
|
for( j = 0;; j++ ) {
|
||||||
@ -357,15 +329,11 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
|||||||
|
|
||||||
ixmlNodeList_free( tmpNodeList );
|
ixmlNodeList_free( tmpNodeList );
|
||||||
tmpNodeList = NULL;
|
tmpNodeList = NULL;
|
||||||
tmpNodeList = ixmlElement_getElementsByTagName( ( IXML_Element
|
tmpNodeList = ixmlElement_getElementsByTagName(
|
||||||
* ) tmpNode,
|
( IXML_Element *)tmpNode, "serviceType" );
|
||||||
"serviceType" );
|
|
||||||
|
|
||||||
if( tmpNodeList == NULL ) {
|
if( tmpNodeList == NULL ) {
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__,
|
||||||
( UPNP_CRITICAL, API, __FILE__, __LINE__,
|
|
||||||
"ServiceType not found \n" );
|
"ServiceType not found \n" );
|
||||||
)
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
tmpNode2 = ixmlNodeList_item( tmpNodeList, 0 );
|
tmpNode2 = ixmlNodeList_item( tmpNodeList, 0 );
|
||||||
@ -386,19 +354,16 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||||
"ServiceType = %s\n", servType );
|
"ServiceType = %s\n", servType );
|
||||||
)
|
|
||||||
if( AdFlag ) {
|
if( AdFlag ) {
|
||||||
if( AdFlag == 1 ) {
|
if( AdFlag == 1 ) {
|
||||||
ServiceAdvertisement( UDNstr, servType,
|
ServiceAdvertisement( UDNstr, servType,
|
||||||
SInfo->DescURL, Exp );
|
SInfo->DescURL, Exp );
|
||||||
} else // AdFlag == -1
|
} else { // AdFlag == -1
|
||||||
{
|
|
||||||
ServiceShutdown( UDNstr, servType,
|
ServiceShutdown( UDNstr, servType,
|
||||||
SInfo->DescURL, Exp );
|
SInfo->DescURL, Exp );
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
switch ( SearchType ) {
|
switch ( SearchType ) {
|
||||||
case SSDP_ALL:
|
case SSDP_ALL:
|
||||||
@ -433,9 +398,8 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
|||||||
ixmlNodeList_free( nodeList );
|
ixmlNodeList_free( nodeList );
|
||||||
nodeList = NULL;
|
nodeList = NULL;
|
||||||
}
|
}
|
||||||
DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
"Exiting AdvertiseAndReply : \n" );
|
"Exiting AdvertiseAndReply : \n" );
|
||||||
)
|
|
||||||
|
|
||||||
HandleUnlock( );
|
HandleUnlock( );
|
||||||
|
|
||||||
@ -733,18 +697,16 @@ start_event_handler( void *Data )
|
|||||||
if( status == PARSE_FAILURE ) {
|
if( status == PARSE_FAILURE ) {
|
||||||
if( parser->msg.method != HTTPMETHOD_NOTIFY ||
|
if( parser->msg.method != HTTPMETHOD_NOTIFY ||
|
||||||
!parser->valid_ssdp_notify_hack ) {
|
!parser->valid_ssdp_notify_hack ) {
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||||
"SSDP recvd bad msg code = %d\n",
|
"SSDP recvd bad msg code = %d\n",
|
||||||
status );
|
status );
|
||||||
)
|
|
||||||
// ignore bad msg, or not enuf mem
|
// ignore bad msg, or not enuf mem
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
// valid notify msg
|
// valid notify msg
|
||||||
} else if( status != PARSE_SUCCESS ) {
|
} else if( status != PARSE_SUCCESS ) {
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||||
"SSDP recvd bad msg code = %d\n", status );
|
"SSDP recvd bad msg code = %d\n", status );
|
||||||
)
|
|
||||||
|
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
@ -863,19 +825,16 @@ readFromSSDPSocket( SOCKET socket )
|
|||||||
if( byteReceived > 0 ) {
|
if( byteReceived > 0 ) {
|
||||||
|
|
||||||
requestBuf[byteReceived] = '\0';
|
requestBuf[byteReceived] = '\0';
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, SSDP,
|
UpnpPrintf( UPNP_INFO, SSDP,
|
||||||
__FILE__, __LINE__,
|
__FILE__, __LINE__,
|
||||||
"Received response !!! "
|
"Received response !!! "
|
||||||
"%s From host %s \n",
|
"%s From host %s \n",
|
||||||
requestBuf,
|
requestBuf,
|
||||||
inet_ntoa( clientAddr.sin_addr ) );
|
inet_ntoa( clientAddr.sin_addr ) );
|
||||||
)
|
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_PACKET, SSDP,
|
UpnpPrintf( UPNP_PACKET, SSDP, __FILE__, __LINE__,
|
||||||
__FILE__, __LINE__,
|
|
||||||
"Received multicast packet:"
|
"Received multicast packet:"
|
||||||
"\n %s\n", requestBuf );
|
"\n %s\n", requestBuf );
|
||||||
)
|
|
||||||
//add thread pool job to handle request
|
//add thread pool job to handle request
|
||||||
if( data != NULL ) {
|
if( data != NULL ) {
|
||||||
data->parser.msg.msg.length += byteReceived;
|
data->parser.msg.msg.length += byteReceived;
|
||||||
@ -891,7 +850,6 @@ readFromSSDPSocket( SOCKET socket )
|
|||||||
free_ssdp_event_handler_data( data );
|
free_ssdp_event_handler_data( data );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
free_ssdp_event_handler_data( data );
|
free_ssdp_event_handler_data( data );
|
||||||
}
|
}
|
||||||
@ -926,9 +884,9 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
|||||||
|
|
||||||
CLIENTONLY( if( ( ssdpReqSock = socket( AF_INET, SOCK_DGRAM, 0 ) )
|
CLIENTONLY( if( ( ssdpReqSock = socket( AF_INET, SOCK_DGRAM, 0 ) )
|
||||||
== UPNP_INVALID_SOCKET ) {
|
== UPNP_INVALID_SOCKET ) {
|
||||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL,
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in socket operation !!!\n" ); )
|
"Error in socket operation !!!\n" );
|
||||||
return UPNP_E_OUTOF_SOCKET;}
|
return UPNP_E_OUTOF_SOCKET;}
|
||||||
setsockopt( ssdpReqSock,
|
setsockopt( ssdpReqSock,
|
||||||
IPPROTO_IP,
|
IPPROTO_IP,
|
||||||
@ -938,10 +896,9 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
|||||||
|
|
||||||
if( ( ssdpSock = socket( AF_INET, SOCK_DGRAM, 0 ) )
|
if( ( ssdpSock = socket( AF_INET, SOCK_DGRAM, 0 ) )
|
||||||
== UPNP_INVALID_SOCKET ) {
|
== UPNP_INVALID_SOCKET ) {
|
||||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL,
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in socket operation !!!\n" );
|
"Error in socket operation !!!\n" );
|
||||||
)
|
|
||||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
||||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
||||||
return UPNP_E_OUTOF_SOCKET;
|
return UPNP_E_OUTOF_SOCKET;
|
||||||
@ -951,10 +908,9 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
|||||||
if( setsockopt( ssdpSock, SOL_SOCKET, SO_REUSEADDR,
|
if( setsockopt( ssdpSock, SOL_SOCKET, SO_REUSEADDR,
|
||||||
( char * )&onOff, sizeof( onOff ) ) != 0 ) {
|
( char * )&onOff, sizeof( onOff ) ) != 0 ) {
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL,
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in set reuse addr !!!\n" );
|
"Error in set reuse addr !!!\n" );
|
||||||
)
|
|
||||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
||||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
||||||
shutdown( ssdpSock, SD_BOTH );
|
shutdown( ssdpSock, SD_BOTH );
|
||||||
@ -966,10 +922,9 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
|||||||
if( setsockopt( ssdpSock, SOL_SOCKET, SO_REUSEPORT,
|
if( setsockopt( ssdpSock, SOL_SOCKET, SO_REUSEPORT,
|
||||||
( char * )&onOff, sizeof( onOff ) ) != 0 ) {
|
( char * )&onOff, sizeof( onOff ) ) != 0 ) {
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL,
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in set reuse port !!!\n" );
|
"Error in set reuse port !!!\n" );
|
||||||
)
|
|
||||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
||||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
||||||
shutdown( ssdpSock, SD_BOTH );
|
shutdown( ssdpSock, SD_BOTH );
|
||||||
@ -986,10 +941,9 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
|||||||
if( bind
|
if( bind
|
||||||
( ssdpSock, ( struct sockaddr * )&ssdpAddr,
|
( ssdpSock, ( struct sockaddr * )&ssdpAddr,
|
||||||
sizeof( ssdpAddr ) ) != 0 ) {
|
sizeof( ssdpAddr ) ) != 0 ) {
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
( UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in binding !!!\n" );
|
"Error in binding !!!\n" );
|
||||||
)
|
|
||||||
shutdown( ssdpSock, SD_BOTH );
|
shutdown( ssdpSock, SD_BOTH );
|
||||||
UpnpCloseSocket( ssdpSock );
|
UpnpCloseSocket( ssdpSock );
|
||||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
||||||
@ -1003,10 +957,9 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
|||||||
if( setsockopt( ssdpSock, IPPROTO_IP, IP_ADD_MEMBERSHIP,
|
if( setsockopt( ssdpSock, IPPROTO_IP, IP_ADD_MEMBERSHIP,
|
||||||
( char * )&ssdpMcastAddr,
|
( char * )&ssdpMcastAddr,
|
||||||
sizeof( struct ip_mreq ) ) != 0 ) {
|
sizeof( struct ip_mreq ) ) != 0 ) {
|
||||||
DBGONLY( UpnpPrintf
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
( UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in joining" " multicast group !!!\n" );
|
"Error in joining" " multicast group !!!\n" );
|
||||||
)
|
|
||||||
shutdown( ssdpSock, SD_BOTH );
|
shutdown( ssdpSock, SD_BOTH );
|
||||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
||||||
UpnpCloseSocket( ssdpSock );
|
UpnpCloseSocket( ssdpSock );
|
||||||
@ -1019,8 +972,8 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
|||||||
addr.s_addr = inet_addr(LOCAL_HOST);
|
addr.s_addr = inet_addr(LOCAL_HOST);
|
||||||
if (setsockopt(ssdpSock, IPPROTO_IP, IP_MULTICAST_IF,
|
if (setsockopt(ssdpSock, IPPROTO_IP, IP_MULTICAST_IF,
|
||||||
(char *)&addr, sizeof addr) != 0) {
|
(char *)&addr, sizeof addr) != 0) {
|
||||||
DBGONLY(UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||||
"Couldn't set multicast interface.\n" ));
|
"Couldn't set multicast interface.\n" );
|
||||||
/* This is probably not a critical error, so let's continue. */
|
/* This is probably not a critical error, so let's continue. */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1029,10 +982,9 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
|||||||
IP_MULTICAST_TTL, &ttl, sizeof( ttl ) );
|
IP_MULTICAST_TTL, &ttl, sizeof( ttl ) );
|
||||||
if( setsockopt( ssdpSock, SOL_SOCKET, SO_BROADCAST,
|
if( setsockopt( ssdpSock, SOL_SOCKET, SO_BROADCAST,
|
||||||
( char * )&option, sizeof( option ) ) != 0 ) {
|
( char * )&option, sizeof( option ) ) != 0 ) {
|
||||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL,
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in setting broadcast !!!\n" );
|
"Error in setting broadcast !!!\n" );
|
||||||
)
|
|
||||||
shutdown( ssdpSock, SD_BOTH );
|
shutdown( ssdpSock, SD_BOTH );
|
||||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
||||||
UpnpCloseSocket( ssdpSock );
|
UpnpCloseSocket( ssdpSock );
|
||||||
|
@ -168,9 +168,8 @@ calc_descURL( IN const char *ipPortStr,
|
|||||||
strcat( descURL, ipPortStr );
|
strcat( descURL, ipPortStr );
|
||||||
strcat( descURL, alias );
|
strcat( descURL, alias );
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||||
"desc url: %s\n", descURL );
|
"desc url: %s\n", descURL );
|
||||||
)
|
|
||||||
|
|
||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -408,18 +407,16 @@ configure_urlbase( INOUT IXML_Document * doc,
|
|||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||||
"desc url: %s\n", docURL );
|
"desc url: %s\n", docURL );
|
||||||
)
|
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||||
DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
|
||||||
"doc = %s\n", xml_str );
|
"doc = %s\n", xml_str );
|
||||||
)
|
|
||||||
// store in web server
|
// store in web server
|
||||||
err_code =
|
err_code =
|
||||||
web_server_set_alias( new_alias, xml_str, strlen( xml_str ),
|
web_server_set_alias( new_alias, xml_str, strlen( xml_str ),
|
||||||
last_modified );
|
last_modified );
|
||||||
|
|
||||||
error_handler:
|
error_handler:
|
||||||
free( root_path );
|
free( root_path );
|
||||||
free( new_alias );
|
free( new_alias );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user