Compare commits

..

41 Commits

Author SHA1 Message Date
Marcelo Roberto Jimenez
6ac867bbb1 Fix the library numbers for release. 2010-11-07 01:33:18 -02:00
Marcelo Roberto Jimenez
9052ca95be Fix broken Makefile.am and remove unused file utilall.h. 2010-11-06 19:41:47 -02:00
Marcelo Roberto Jimenez
ef7edf6cf8 Fix for "SampleUtil_Initialize was called multiple times!" bug.
Fix for bug introduced in samples code in svn revision 502, commit
git:25c908c558c8e60eb386c155a6b93add447ffec0

Sample device and combo were aborting with the message:
"***** SampleUtil_Initialize was called multiple times!"
2010-11-06 00:45:24 -02:00
Fabrice Fontaine
c65ec8a720 Make multiple SSDP advertisements faster.
Put the loop to send multiple copies of each SSDP advertisements in
ssdp_server.c instead of ssdp_device.c so we have only one call to
imillisleep ( SSDP_PAUSE ) to speed up advertisements.
2010-11-05 23:52:17 -02:00
Fabrice Fontaine
2d22e997e1 Removing unused NUM_COPY variable.
Previously, NUM_COPY was used in ssdp_device.c to send multiple copies
of each advertisements but also multiple replies to each M-SEARCH
request. As sending multiple replies is not compliant with HTTPU/MU
spec, NUM_COPY has been set to 1 in an older patch. However, as this
variable is not needed and has been replaced with SSDP_COPY, it has
been removed.
2010-11-05 23:52:11 -02:00
Fabrice Fontaine
96dc968f18 Use SSDP_COPY to send multiple SSDP advertisements.
Currently, SSDP_COPY is used only to send multiple M-SEARCH requests (in
ssdp_ctrlpt.c). With this patch, SSDP_COPY is also used to send multiple
copies of each advertisements packets (in ssdp_device.c).
2010-11-05 13:25:40 -02:00
Carl Benson
8e846368e0 patch for taking notice of UPNP_USE_RWLOCK flag in threadutil
By "Carl Benson" <carl.benson@windriver.com>:

I had to do some modifications myself though, because the Android
build system insists on having a file named "util.h" taking precedence
in its include path, libupnp gets confused because of the same filename
in upnp/src/inc/util.h
2010-11-01 01:06:11 -02:00
Marcelo Roberto Jimenez
d6671c464f Bump config to 1.6.9. 2010-11-01 01:03:40 -02:00
Marcelo Roberto Jimenez
699dd3c82e Missed this line in configure.ac in the homekeeping commit. 2010-10-21 09:55:54 -02:00
Marcelo Roberto Jimenez
9be360bcd1 Homekeeping for the next release. 2010-10-20 11:15:23 -02:00
Marcelo Roberto Jimenez
593b8d0a2b Fixes in configure.ac for release. 2010-10-20 11:11:45 -02:00
Marcelo Roberto Jimenez
890c1b6ef8 Disable debug for release. 2010-10-20 10:36:11 -02:00
Marcelo Roberto Jimenez
c127a3a87e Add docs/doxygen to .gitignore. 2010-10-20 10:35:15 -02:00
Marcelo Roberto Jimenez
bd5758186c White spaces. 2010-10-20 10:29:45 -02:00
Marcelo Roberto Jimenez
cc472bc2cd Doxygen and indentation for sock. 2010-10-20 09:05:42 -02:00
Marcelo Roberto Jimenez
6128296e5f Doxygen and indentation for miniserver. 2010-10-20 08:56:06 -02:00
Marcelo Roberto Jimenez
d84c6a7e9f Indent plus Doxygen in webserver. 2010-10-20 01:28:37 -02:00
Marcelo Roberto Jimenez
113ebd1f91 Slightly better implementation for ToUpperCase(). 2010-10-20 00:36:47 -02:00
Marcelo Roberto Jimenez
bf1450bf81 Fix a long date memory leak in webserver.c:StrStr(). 2010-10-20 00:29:08 -02:00
Marcelo Roberto Jimenez
56b9c75056 Changelog fix. 2010-10-19 16:11:39 -02:00
Marcelo Roberto Jimenez
2bdc9e075e Bug fix in select of miniserver.c
Fix a bug in miniserver.c, in which maxMiniSock was wrongly declared as
unsigned int and as a result it was beeng set to ((unsigned int)(-1)).
As a result, after beeing incremented, it became zero, and this value
was beeing used in the select() call.

Thanks to Fabrice Fontaine for helping and testing with this issue.
2010-10-19 15:49:36 -02:00
Marcelo Roberto Jimenez
923eee2393 Don't ask, UTF-8 mess? 2010-10-15 12:54:00 -03:00
Marcelo Roberto Jimenez
f74746ff3f Fix for 100% CPU issue in select() in miniserv.c. I have also removed
the sleep() call, it was just a workaround.

SF Bug Tracker [ 3086852 ] 99% CPU loop in miniserver.c on a non ipv6
system.

Submitted by: Jin ( jin_eld ) - 2010-10-13 19:29:13 UTC

I cross compiled libupnp 1.6.7 for ARM9 using the --disable-ipv6
option, my system is an ipv4 only setup.

I do not know why this problem only appears when running the app in the
background (for instance using nohup &), but then it starts using 99%
CPU.

I traced the problem down to the select() call in miniserver.c in the
RunMiniServer() function. Select returns code 1, but errno is set to
"Socket operation on non-socket", I also see this when running my app
under strace.

I set all ...Sock6 variables to INVALID_SOCKET to make sure that they
do not get added to the FD_SET and the problem is gone.
2010-10-15 12:41:36 -03:00
Marcelo Roberto Jimenez
8401a59ed5 New function, sock_close(). 2010-10-15 12:25:35 -03:00
Marcelo Roberto Jimenez
5b40cfa272 Misplaced declaration of UpnpCloseSocket. 2010-10-15 12:17:15 -03:00
Marcelo Roberto Jimenez
fcda28ba75 Remove of unused file. 2010-10-15 11:53:25 -03:00
Marcelo Roberto Jimenez
7cd434225f White spaces and comments. 2010-10-04 17:05:43 -03:00
Marcelo Roberto Jimenez
78e5ba89fa Merge of similar files. 2010-10-04 15:48:45 -03:00
Marcelo Roberto Jimenez
ebb8f209b0 Merge of similar files. 2010-10-04 15:36:11 -03:00
Marcelo Roberto Jimenez
73afd667e1 Fix for bug introduced in the last commit. 2010-10-04 13:24:38 -03:00
Marcelo Roberto Jimenez
cc294a6cf1 Merge similar code. 2010-10-04 13:03:20 -03:00
Marcelo Roberto Jimenez
458a9416c6 Merge of work from 1.8.x. 2010-10-04 12:04:38 -03:00
Marcelo Roberto Jimenez
b9eeb89250 Bumped Doxyfile version. 2010-10-04 11:44:06 -03:00
Marcelo Roberto Jimenez
a6e68b481d Updated THANKS. 2010-10-04 11:33:37 -03:00
Marcelo Roberto Jimenez
a19a896e88 Updated TODO list. 2010-10-04 11:28:37 -03:00
Marcelo Roberto Jimenez
cdee5b7cde UTF-8. 2010-10-04 11:11:33 -03:00
Marcelo Roberto Jimenez
dec78c8ef1 Echo the copy on configure output. 2010-10-04 11:01:28 -03:00
Marcelo Roberto Jimenez
fb62a5d42a Update files for windows compilation. 2010-10-04 10:51:30 -03:00
Marcelo Roberto Jimenez
a9b5081a08 Update build/inc/autoconfig.h and build/inc/upnpconfig.h at configure
time.
2010-10-04 10:47:39 -03:00
Marcelo Roberto Jimenez
3886a697b5 Remove build/inc/config.h. The right file is upnp/src/inc/config.h. 2010-10-04 10:42:32 -03:00
Marcelo Roberto Jimenez
3dab2bd00a Homekeeping for the next release. 2010-10-04 09:58:15 -03:00
73 changed files with 3939 additions and 4931 deletions

1
.gitignore vendored
View File

@@ -101,4 +101,5 @@ upnp/inc/upnpconfig.h
upnp/sample/upnp_tv_combo
upnp/sample/upnp_tv_ctrlpt
upnp/sample/upnp_tv_device
docs/doxygen

View File

@@ -1,3 +1,95 @@
*******************************************************************************
Version 1.6.9
*******************************************************************************
2010-10-20 Marcelo Roberto Jimenez <mroberto(at)users.sourceforge.net>
Fix for bug introduced in samples code in svn revision 502, commit
git:25c908c558c8e60eb386c155a6b93add447ffec0
Sample device and combo were aborting with the message:
"***** SampleUtil_Initialize was called multiple times!"
2010-11-08 Fabrice Fontaine <fabrice.fontaine(at)orange-ftgroup.com>
Make multiple SSDP advertisements faster.
Put the loop to send multiple copies of each SSDP advertisements in
ssdp_server.c instead of ssdp_device.c so we have only one call to
imillisleep ( SSDP_PAUSE ) to speed up advertisements.
2010-11-05 Fabrice Fontaine <fabrice.fontaine(at)orange-ftgroup.com>
Removing unused NUM_COPY variable.
Previously, NUM_COPY was used in ssdp_device.c to send multiple copies
of each advertisements but also multiple replies to each M-SEARCH
request. As sending multiple replies is not compliant with HTTPU/MU
spec, NUM_COPY has been set to 1 in an older patch. However, as this
variable is not needed and has been replaced with SSDP_COPY, it has
been removed.
2010-11-05 Fabrice Fontaine <fabrice.fontaine(at)orange-ftgroup.com>
Use SSDP_COPY to send multiple SSDP advertisements.
Currently, SSDP_COPY is used only to send multiple M-SEARCH requests (in
ssdp_ctrlpt.c). With this patch, SSDP_COPY is also used to send multiple
copies of each advertisements packets (in ssdp_device.c).
2010-11-01 Carl Benson <carl.benson(at)windriver.com>
Fix for Android build.
I had to do some modifications myself though, because the Android
build system insists on having a file named "util.h" taking precedence
in its include path, libupnp gets confused because of the same filename
in upnp/src/inc/util.h
*******************************************************************************
Version 1.6.8
*******************************************************************************
2010-10-20 Marcelo Roberto Jimenez <mroberto(at)users.sourceforge.net>
Fix a long date memory leak in webserver.c:StrStr().
2010-10-19 Marcelo Roberto Jimenez <mroberto(at)users.sourceforge.net>
Bug fix in select of miniserver.c
Fix a bug in miniserver.c, in which maxMiniSock was wrongly declared as
unsigned int and as a result it was beeng set to ((unsigned int)(-1)).
As a result, after beeing incremented, it became zero, and this value
was beeing used in the select() call.
Thanks to Fabrice Fontaine for helping and testing with this issue.
2010-10-15 Marcelo Roberto Jimenez <mroberto(at)users.sourceforge.net>
Fix for 100% CPU issue in select() in miniserv.c. I have also removed
the sleep() call, it was just a workaround.
SF Bug Tracker [ 3086852 ] 99% CPU loop in miniserver.c on a non ipv6
system.
Submitted by: Jin ( jin_eld ) - 2010-10-13 19:29:13 UTC
I cross compiled libupnp 1.6.7 for ARM9 using the --disable-ipv6
option, my system is an ipv4 only setup.
I do not know why this problem only appears when running the app in the
background (for instance using nohup &), but then it starts using 99%
CPU.
I traced the problem down to the select() call in miniserver.c in the
RunMiniServer() function. Select returns code 1, but errno is set to
"Socket operation on non-socket", I also see this when running my app
under strace.
I set all ...Sock6 variables to INVALID_SOCKET to make sure that they
do not get added to the FD_SET and the problem is gone.
*******************************************************************************
Version 1.6.7
*******************************************************************************

View File

@@ -31,7 +31,7 @@ PROJECT_NAME = libUPnP
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 1.6.7
PROJECT_NUMBER = 1.6.9
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.

View File

@@ -26,7 +26,6 @@ EXTRA_DIST = \
build/libupnp.dsp \
build/libupnp.dsw \
build/inc/autoconfig.h \
build/inc/config.h \
build/inc/upnpconfig.h \
build/msvc/inttypes.h \
build/msvc/stdint.h \

2
THANKS
View File

@@ -13,12 +13,14 @@ exempt of errors.
- Arno Willig
- Bob Ciora
- Carlo Parata
- Carl Benson
- Chandra (inactiveneurons)
- Chaos
- Charles Nepveu (cnepveu)
- Chris Pickel
- Chuck Thomason (cyt4)
- Craig Nelson
- David Blanchet
- David Maass
- Emil Ljungdahl
- Erik Johansson

23
TODO
View File

@@ -2,28 +2,5 @@
To Be Done
==========
- add FreeBSD patches
( http://sf.net/tracker/index.php?func=detail&aid=1332618&group_id=7189&atid=307189 ?)
- non-regression testing
- replace doc++ by Doxygen for documentation generation
- incorporate public patches and fix reported bugs :
http://sourceforge.net/tracker/?group_id=7189&atid=107189 and
http://sourceforge.net/tracker/?group_id=7189&atid=307189
- RPM packaging (a preliminary one here :
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=176617 )
- make API clean for large files and 64 bits
To Be Decided
=============
- IPV6 support ?

View File

@@ -67,9 +67,6 @@
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/timeb.h> header file. */
#define HAVE_SYS_TIMEB_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
@@ -82,6 +79,13 @@
/* Define to 1 if you have the `vprintf' function. */
#define HAVE_VPRINTF 1
/* Define to 1 if you have the <ws2tcpip.h> header file. */
/* #undef HAVE_WS2TCPIP_H */
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Define to 1 to prevent compilation of assert() */
#define NDEBUG 1
@@ -101,13 +105,13 @@
#define PACKAGE_NAME "libupnp"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "libupnp 1.4.7"
#define PACKAGE_STRING "libupnp 1.6.9"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libupnp"
/* Define to the version of this package. */
#define PACKAGE_VERSION "1.4.7"
#define PACKAGE_VERSION "1.6.9"
/* Define to necessary symbol if this constant uses a non-standard name on
your system. */
@@ -116,6 +120,12 @@
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* see upnpconfig.h */
/* #undef UPNP_ENABLE_IPV6 */
/* see upnpconfig.h */
#define UPNP_ENABLE_NOTIFICATION_REORDERING 1
/* see upnpconfig.h */
#define UPNP_HAVE_CLIENT 1
@@ -131,20 +141,23 @@
/* see upnpconfig.h */
#define UPNP_HAVE_WEBSERVER 1
/* Do not use pthread_rwlock_t */
#define UPNP_USE_RWLOCK 1
/* see upnpconfig.h */
#define UPNP_VERSION_MAJOR 1
/* see upnpconfig.h */
#define UPNP_VERSION_MINOR 4
#define UPNP_VERSION_MINOR 6
/* see upnpconfig.h */
#define UPNP_VERSION_PATCH 7
#define UPNP_VERSION_PATCH 9
/* see upnpconfig.h */
#define UPNP_VERSION_STRING "1.4.7"
#define UPNP_VERSION_STRING "1.6.9"
/* Version number of package */
#define VERSION "1.4.7"
#define VERSION "1.6.9"
/* File Offset size */
#define _FILE_OFFSET_BITS 64
@@ -153,7 +166,7 @@
/* #undef _LARGEFILE_SOURCE */
/* Large files support */
#define _LARGE_FILE_SOURCE
#define _LARGE_FILE_SOURCE /**/
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
@@ -164,5 +177,5 @@
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */
/* Substitute for socklen_t */
/* Type for storing the length of struct sockaddr */
/* #undef socklen_t */

View File

@@ -1,434 +0,0 @@
/**************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************/
#ifndef INTERNAL_CONFIG_H
#define INTERNAL_CONFIG_H
#include "autoconfig.h"
/*!
* \name Compile time configuration options
*
* The Linux SDK for UPnP Devices contains some compile-time parameters
* that effect the behavior of the SDK. All configuration options are
* located in {\tt src/inc/config.h}.
*
* @{
*/
/*!
* \name THREAD_IDLE_TIME
*
* The {\tt THREAD_IDLE_TIME} constant determines when a thread will be
* removed from the thread pool and returned to the operating system. When
* a thread in the thread pool has been idle for this number of milliseconds
* the thread will be released from the thread pool. The default value is
* 5000 milliseconds (5 seconds).
*
* @{
*/
#define THREAD_IDLE_TIME 5000
/* @} */
/*!
* \name JOBS_PER_THREAD
*
* The {\tt JOBS_PER_THREAD} constant determines when a new thread will be
* allocated to the thread pool inside the SDK. The thread pool will
* try and maintain this jobs/thread ratio. When the jobs/thread ratio
* becomes greater than this, then a new thread (up to the max) will be
* allocated to the thread pool. The default ratio is 10 jobs/thread.
*
* @{
*/
#define JOBS_PER_THREAD 10
/* @} */
/*!
* \name MIN_THREADS
*
* The {\tt MIN_THREADS} constant defines the minimum number of threads the
* thread pool inside the SDK will create. The thread pool will
* always have this number of threads. These threads are used
* for both callbacks into applications built on top of the SDK and also
* for making connections to other control points and devices. This number
* includes persistent threads. The default value is two threads.
*
* @{
*/
#define MIN_THREADS 2
/* @} */
/*!
* \name MAX_THREADS
*
* The {\tt MAX_THREADS} constant defines the maximum number of threads the
* thread pool inside the SDK will create. These threads are used
* for both callbacks into applications built on top of the library and also
* for making connections to other control points and devices. It is not
* recommended that this value be below 10, since the threads are
* necessary for correct operation. This value can be increased for greater
* performance in operation at the expense of greater memory overhead. The
* default value is 12.
*
* @{
*/
#define MAX_THREADS 12
/* @} */
/*!
* \name THREAD_STACK_SIZE
*
* The {\tt THREAD_STACK_SIZE} constant defines the minimum stack size (in
* bytes) allocated for the stack of each thread the thread pool inside the
* SDK will create. These threads are used for both callbacks into
* applications built on top of the library and also for making connections
* to other control points and devices. This value will not be used if it
* is lower than ITHREAD_STACK_MIN or greater than a system-imposed limit.
* This value can be used to lower memory overhead in embedded systems.
* The default value is 0 (so it is not used by default).
*
* @{
*/
#define THREAD_STACK_SIZE 0
/* @} */
/*! \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
*
* SOAP messages will read at most {\tt DEFAULT_SOAP_CONTENT_LENGTH} bytes.
* This prevents devices that have a misbehaving web server to send
* a large amount of data to the control point causing it to crash.
* This can be adjusted dynamically with {\tt UpnpSetMaxContentLength}.
*
* @{
*/
#define DEFAULT_SOAP_CONTENT_LENGTH 16000
/* @} */
/*!
* \name NUM_SSDP_COPY
*
* This configuration parameter determines how many copies of each SSDP
* advertisement and search packets will be sent. By default it will send two
* copies of every packet.
*
* @{
*/
#define NUM_SSDP_COPY 2
/* @} */
/*!
* \name SSDP_PAUSE
*
* This configuration parameter determines the pause between identical SSDP
* advertisement and search packets. The pause is measured in milliseconds
* and defaults to 100.
*
* @{
*/
#define SSDP_PAUSE 100
/* @} */
/*!
* \name WEB_SERVER_BUF_SIZE
*
* This configuration parameter sets the maximum buffer size for the
* webserver. The default value is 1MB.
*
* @{
*/
#define WEB_SERVER_BUF_SIZE (1024*1024)
/* @} */
/*!
* \name WEB_SERVER_CONTENT_LANGUAGE
*
* This configuration parameter sets the value of the Content-Language
* header for the webserver. Thanks to this parameter, the use can advertize
* the language used by the device in the description (friendlyName) and
* presentation steps of UPnP. The default value is empty string so no
* Content-Language header is added.
*
* @{
*/
#define WEB_SERVER_CONTENT_LANGUAGE ""
/* @} */
/*!
* \name AUTO_RENEW_TIME
*
* The {\tt AUTO_RENEW_TIME} is the time, in seconds, before a subscription
* expires that the SDK automatically resubscribes. The default
* value is 10 seconds. Setting this value too low can result in the
* subscription renewal not making it to the device in time, causing the
* subscription to timeout. In order to avoid continually resubscribing
* the minimum subscription time is five seconds more than the auto renew
* time.
*
* @{
*/
#define AUTO_RENEW_TIME 10
/* @} */
/*!
* \name CP_MINIMUM_SUBSCRIPTION_TIME
*
* The {\tt CP_MINIMUM_SUBSCRIPTION_TIME} is the minimum subscription time
* allowed for a control point using the SDK. Subscribing for less than
* this time automatically results in a subscription for this amount. The
* default value is 5 seconds more than the {\tt AUTO_RENEW_TIME}, or 15
* seconds.
*
* @{
*/
#define CP_MINIMUM_SUBSCRIPTION_TIME (AUTO_RENEW_TIME + 5)
/* @} */
/*!
* \name MAX_SEARCH_TIME
*
* The {\tt MAX_SEARCH_TIME} is the maximum time
* allowed for an SSDP search by a control point. Searching for greater than
* this time automatically results in a search for this amount. The default
* value is 80 seconds.
*
* @{
*/
#define MAX_SEARCH_TIME 80
/* @} */
/*!
* \name MIN_SEARCH_TIME
*
* The {\tt MIN_SEARCH_TIME} is the minimumm time
* allowed for an SSDP search by a control point. Searching for less than
* this time automatically results in a search for this amount. The default
* value is 2 seconds.
*
* @{
*/
#define MIN_SEARCH_TIME 2
/* @} */
/*!
* \name AUTO_ADVERTISEMENT_TIME
*
* The {\tt AUTO_ADVERTISEMENT_TIME} is the time, in seconds, before an
* device advertisements expires before a renewed advertisement is sent.
* The default time is 30 seconds.
*
* @{
*/
#define AUTO_ADVERTISEMENT_TIME 30
/* @} */
/*!
* \name SSDP_PACKET_DISTRIBUTE
*
* The {\tt SSDP_PACKET_DISTRIBUTE} enables the SSDP packets to be sent
* at an interval equal to half of the expiration time of SSDP packets
* minus the AUTO_ADVERTISEMENT_TIME. This is used to increase
* the probability of SSDP packets reaching to control points.
* It is recommended that this flag be turned on for embedded wireless
* devices.
*
* @{
*/
#define SSDP_PACKET_DISTRIBUTE 1
/* @} */
/*!
* \name Module Exclusion
*
* Depending on the requirements, the user can selectively discard any of
* the major modules like SOAP, GENA, SSDP or the Internal web server. By
* default everything is included inside the SDK. By setting any of
* the values below to 0, that component will not be included in the final
* SDK.
* \begin{itemize}
* \item {\tt EXCLUDE_SOAP[0,1]}
* \item {\tt EXCLUDE_GENA[0,1]}
* \item {\tt EXCLUDE_SSDP[0,1]}
* \item {\tt EXCLUDE_DOM [0,1]}
* \item {\tt EXCLUDE_MINISERVER[0,1]}
* \item {\tt EXCLUDE_WEB_SERVER[0,1]}
* \item {\tt EXCLUDE_JNI[0,1]}
* \end{itemize}
*
* @{
*/
#define EXCLUDE_SSDP 0
#define EXCLUDE_SOAP 0
#define EXCLUDE_GENA 0
#define EXCLUDE_DOM 0
#define EXCLUDE_MINISERVER 0
#define EXCLUDE_WEB_SERVER 0
#ifdef USE_JNI
# define EXCLUDE_JNI 0
#else
# define EXCLUDE_JNI 1
#endif
/* @} */
/*!
* \name DEBUG_TARGET
*
* The user has the option to redirect the library output debug messages
* to either the screen or to a log file. All the output messages with
* debug level 0 will go to {\tt upnp.err} and messages with debug level
* greater than zero will be redirected to {\tt upnp.out}.
*
* @{
*/
#define DEBUG_TARGET 1
/* @} */
/*!
* \name Other debugging features
*
* The UPnP SDK contains other features to aid in debugging:
* see <upnp/inc/upnpdebug.h>
*/
#define DEBUG_ALL 1
#define DEBUG_SSDP 0
#define DEBUG_SOAP 0
#define DEBUG_GENA 0
#define DEBUG_TPOOL 0
#define DEBUG_MSERV 0
#define DEBUG_DOM 0
#define DEBUG_HTTP 0
#define DEBUG_API 0
/*
* @} Compile time configuration options
*/
/***************************************************************************
* Do not change, Internal purpose only!!!
***************************************************************************/
/*!
* @{
*/
/*
* Set additional defines based on requested configuration
*/
/* configure --enable-client */
#if UPNP_HAVE_CLIENT
# define INCLUDE_CLIENT_APIS 1
#endif
/* configure --enable-device */
#if UPNP_HAVE_DEVICE
# define INCLUDE_DEVICE_APIS 1
#endif
/* configure --enable-webserver --enable-device */
#if UPNP_HAVE_WEBSERVER
# define INTERNAL_WEB_SERVER 1
#endif
#undef EXCLUDE_WEB_SERVER
#undef EXCLUDE_MINISERVER
#ifdef INTERNAL_WEB_SERVER
# define EXCLUDE_WEB_SERVER 0
# define EXCLUDE_MINISERVER 0
#else
# define EXCLUDE_WEB_SERVER 1
# define EXCLUDE_MINISERVER 1
#endif
#if EXCLUDE_GENA == 1 && EXCLUDE_SOAP == 1 && EXCLUDE_WEB_SERVER == 1
# undef EXCLUDE_MINISERVER
# define EXCLUDE_MINISERVER 1
# if INTERNAL_WEB_SERVER
# error "conflicting settings: use configure --disable-webserver"
# endif
#endif
#if EXCLUDE_GENA == 0 || EXCLUDE_SOAP == 0 || EXCLUDE_WEB_SERVER == 0
# undef EXCLUDE_MINISERVER
# define EXCLUDE_MINISERVER 0
# if EXCLUDE_WEB_SERVER == 0 && !defined INTERNAL_WEB_SERVER
# error "conflicting settings : use configure --enable-webserver"
# endif
#endif
/*
* @}
*/
#endif /* INTERNAL_CONFIG_H */

View File

@@ -1,35 +1,35 @@
/* upnp/inc/upnpconfig.h. Generated from upnpconfig.h.in by configure. */
// -*- C -*-
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2006 R<EFBFBD>mi Turboult <r3mi@users.sourceforge.net>
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither name of Intel Corporation nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
/* -*- C -*- */
/*******************************************************************************
*
* Copyright (c) 2006 Rémi Turboult <r3mi@users.sourceforge.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#ifndef UPNP_CONFIG_H
#define UPNP_CONFIG_H
@@ -40,20 +40,20 @@
***************************************************************************/
/** The library version (string) e.g. "1.3.0" */
#define UPNP_VERSION_STRING "1.4.7"
#define UPNP_VERSION_STRING "1.6.9"
/** Major version of the library */
#define UPNP_VERSION_MAJOR 1
/** Minor version of the library */
#define UPNP_VERSION_MINOR 4
#define UPNP_VERSION_MINOR 6
/** Patch version of the library */
#define UPNP_VERSION_PATCH 7
#define UPNP_VERSION_PATCH 9
/** The library version (numeric) e.g. 10300 means version 1.3.0 */
#define UPNP_VERSION \
((UPNP_VERSION_MAJOR*100 + UPNP_VERSION_MINOR)*100 + UPNP_VERSION_PATCH)
((UPNP_VERSION_MAJOR * 100 + UPNP_VERSION_MINOR) * 100 + UPNP_VERSION_PATCH)
@@ -91,7 +91,9 @@
* (i.e. configure --enable-tools) : <upnp/upnptools.h> file is available */
#define UPNP_HAVE_TOOLS 1
/** Defined to 1 if the library has been compiled with ipv6 support
* (i.e. configure --enable-ipv6) */
/* #undef UPNP_ENABLE_IPV6 */
#endif // UPNP_CONFIG_H
#endif /* UPNP_CONFIG_H */

View File

@@ -5,17 +5,17 @@
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=libupnp - Win32 Debug
!MESSAGE Dies ist kein g<EFBFBD>ltiges Makefile. Zum Erstellen dieses Projekts mit NMAKE
!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und f<EFBFBD>hren Sie den Befehl
!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE
!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl
!MESSAGE
!MESSAGE NMAKE /f "libupnp.mak".
!MESSAGE
!MESSAGE Sie k<EFBFBD>nnen beim Ausf<EFBFBD>hren von NMAKE eine Konfiguration angeben
!MESSAGE Sie können beim Ausf?hren von NMAKE eine Konfiguration angeben
!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel:
!MESSAGE
!MESSAGE NMAKE /f "libupnp.mak" CFG="libupnp - Win32 Debug"
!MESSAGE
!MESSAGE F<EFBFBD>r die Konfiguration stehen zur Auswahl:
!MESSAGE Für die Konfiguration stehen zur Auswahl:
!MESSAGE
!MESSAGE "libupnp - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library")
!MESSAGE "libupnp - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library")
@@ -389,10 +389,6 @@ SOURCE=..\upnp\src\inc\upnpapi.h
# End Source File
# Begin Source File
SOURCE=..\upnp\src\inc\upnpclosesocket.h
# End Source File
# Begin Source File
SOURCE=..\upnp\src\inc\uri.h
# End Source File
# Begin Source File

View File

@@ -603,10 +603,6 @@
RelativePath="..\..\upnp\src\inc\upnpapi.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\upnpclosesocket.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\upnpdebug.h"
>

View File

@@ -599,10 +599,6 @@
RelativePath="..\..\upnp\src\inc\upnpapi.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\upnpclosesocket.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\upnpdebug.h"
>

View File

@@ -9,7 +9,7 @@
AC_PREREQ(2.60)
AC_INIT([libupnp], [1.6.7], [mroberto@users.sourceforge.net])
AC_INIT([libupnp], [1.6.9], [mroberto@users.sourceforge.net])
dnl ############################################################################
dnl # *Independently* of the above libupnp package version, the libtool version
dnl # of the 3 libraries need to be updated whenever there is a change released:
@@ -147,22 +147,56 @@ dnl ############################################################################
dnl # Release 1.6.7:
dnl # "current:revision:age"
dnl #
dnl # - Code has changed in upnp
dnl # revision: 5 -> 6
dnl # - Code has changed in threadutil
dnl # revision: 3 -> 4
dnl # - Code has changed in upnp
dnl # revision: 5 -> 6
dnl # - Interfaces have been changed, added and removed in upnp
dnl # current: 4 -> 5
dnl # revision: 4 -> 0
dnl # current: 3 -> 4
dnl # revision: 6 -> 0
dnl # - Interfaces removed in upnp:
dnl # age: -> 0
dnl #
dnl #AC_SUBST([LT_VERSION_IXML], [2:4:0])
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [5:0:2])
dnl #AC_SUBST([LT_VERSION_UPNP], [3:5:0])
dnl #
dnl # Obs.: 1.6.7 was released with a version error, the correct nubers should
dnl # have been:
dnl #AC_SUBST([LT_VERSION_UPNP], [4:0:0])
dnl #
dnl ############################################################################
AC_SUBST([LT_VERSION_IXML], [2:4:0])
AC_SUBST([LT_VERSION_THREADUTIL], [5:0:2])
AC_SUBST([LT_VERSION_UPNP], [3:5:0])
dnl # Release 1.6.8:
dnl # "current:revision:age"
dnl #
dnl # - Code has changed in ixml
dnl # revision: 4 -> 5
dnl # - Code has changed in threadutil
dnl # revision: 0 -> 1
dnl # - Code has changed in upnp
dnl # revision: 0 -> 1
dnl #
dnl #AC_SUBST([LT_VERSION_IXML], [2:5:0])
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [5:1:2])
dnl #AC_SUBST([LT_VERSION_UPNP], [4:1:0])
dnl #
dnl ############################################################################
dnl # Release 1.6.9:
dnl # "current:revision:age"
dnl #
dnl # - Code has changed in threadutil
dnl # revision: 1 -> 2
dnl # - Code has changed in upnp
dnl # revision: 1 -> 2
dnl #
dnl #AC_SUBST([LT_VERSION_IXML], [2:5:0])
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [5:2:2])
dnl #AC_SUBST([LT_VERSION_UPNP], [4:2:0])
dnl #
############################################################################
AC_SUBST([LT_VERSION_IXML], [2:5:0])
AC_SUBST([LT_VERSION_THREADUTIL], [5:2:2])
AC_SUBST([LT_VERSION_UPNP], [4:2:0])
dnl ############################################################################
dnl # Repeating the algorithm to place it closer to the modificatin place:
dnl # - library code modified: revision++
@@ -492,3 +526,11 @@ AC_CONFIG_FILES([
AC_OUTPUT
#
# Files copied for windows compilation.
#
echo "configure: copying \"autoconfig.h\" to \"build/inc/autoconfig.h\""
cp autoconfig.h build/inc/autoconfig.h
echo "configure: copying \"upnp/inc/upnpconfig.h\" to \"build/inc/upnpconfig.h\""
cp upnp/inc/upnpconfig.h build/inc/upnpconfig.h

View File

@@ -2,7 +2,7 @@
#
# "Makefile.am" for "libupnp/ixml"
#
# (C) Copyright 2005 R<EFBFBD>mi Turboult <r3mi@users.sourceforge.net>
# (C) Copyright 2005 Rémi Turboult <r3mi@users.sourceforge.net>
#
SUBDIRS = doc

View File

@@ -5,6 +5,7 @@
#include "UpnpGlobal.h"
#include "ixml.h"
/*!
@@ -20,6 +21,13 @@
*/
#ifdef DEBUG
void IxmlPrintf(
/*! [in] The file name, usually __FILE__. */
const char *DbgFileName,
/*! [in] The line number, usually __LINE__ or a variable that got the
* __LINE__ at the appropriate place. */
int DbgLineNo,
/*! [in] The function name. */
const char *FunctionName,
/*! [in] Printf like format specification. */
const char* FmtStr,
/*! [in] Printf like Variable number of arguments that will go in the debug
@@ -27,7 +35,7 @@ void IxmlPrintf(
...)
#if (__GNUC__ >= 3)
/* This enables printf like format checking by the compiler */
__attribute__((format (__printf__, 1, 2)))
__attribute__((format (__printf__, 4, 5)))
#endif
;
#else /* DEBUG */
@@ -37,5 +45,23 @@ static UPNP_INLINE void IxmlPrintf(
#endif /* DEBUG */
/*!
* \brief Print the node names and values of a XML tree.
*/
#ifdef DEBUG
void printNodes(
/*! [in] The root of the tree to print. */
IXML_Node *tmpRoot,
/*! [in] The depth to print. */
int depth);
#else
static UPNP_INLINE void printNodes(
IXML_Node *tmpRoot,
int depth)
{
}
#endif
#endif /* IXMLDEBUG_H */

View File

@@ -444,17 +444,17 @@ int ixmlDocument_createElementNSEx(
IXML_Element **rtElement)
{
IXML_Element *newElement = NULL;
int errCode = IXML_SUCCESS;
int ret = IXML_SUCCESS;
int line = 0;
if (doc == NULL || namespaceURI == NULL || qualifiedName == NULL) {
line = __LINE__;
errCode = IXML_INVALID_PARAMETER;
ret = IXML_INVALID_PARAMETER;
goto ErrorHandler;
}
errCode = ixmlDocument_createElementEx(doc, qualifiedName, &newElement);
if (errCode != IXML_SUCCESS) {
ret = ixmlDocument_createElementEx(doc, qualifiedName, &newElement);
if (ret != IXML_SUCCESS) {
line = __LINE__;
goto ErrorHandler;
}
@@ -464,16 +464,16 @@ int ixmlDocument_createElementNSEx(
line = __LINE__;
ixmlElement_free(newElement);
newElement = NULL;
errCode = IXML_INSUFFICIENT_MEMORY;
ret = IXML_INSUFFICIENT_MEMORY;
goto ErrorHandler;
}
// set the localName and prefix
errCode = ixmlNode_setNodeName((IXML_Node *)newElement, qualifiedName);
if (errCode != IXML_SUCCESS) {
ret = ixmlNode_setNodeName((IXML_Node *)newElement, qualifiedName);
if (ret != IXML_SUCCESS) {
line = __LINE__;
ixmlElement_free(newElement);
newElement = NULL;
errCode = IXML_INSUFFICIENT_MEMORY;
ret = IXML_INSUFFICIENT_MEMORY;
goto ErrorHandler;
}
@@ -481,12 +481,11 @@ int ixmlDocument_createElementNSEx(
ErrorHandler:
*rtElement = newElement;
if (errCode != IXML_SUCCESS) {
IxmlPrintf("(%s::ixmlDocument_createElementNSEx): Error %d, line %d\n",
__FILE__, errCode, line);
if (ret != IXML_SUCCESS) {
IxmlPrintf(__FILE__, line, "ixmlDocument_createElementNSEx", "Error %d\n", ret);
}
return errCode;
return ret;
}

View File

@@ -181,9 +181,9 @@ static void ixmlPrintDomTreeRecursive(
break;
default:
IxmlPrintf("(%s::ixmlPrintDomTreeRecursive) line %d: "
IxmlPrintf(__FILE__, __LINE__, "ixmlPrintDomTreeRecursive",
"Warning, unknown node type %d\n",
__FILE__, __LINE__, ixmlNode_getNodeType(nodeptr));
ixmlNode_getNodeType(nodeptr));
break;
}
}
@@ -253,9 +253,9 @@ static void ixmlPrintDomTree(
break;
default:
IxmlPrintf("(%s::ixmlPrintDomTree) line %d: "
IxmlPrintf(__FILE__, __LINE__, "ixmlPrintDomTree",
"Warning, unknown node type %d\n",
__FILE__, __LINE__, ixmlNode_getNodeType(nodeptr));
ixmlNode_getNodeType(nodeptr));
break;
}
}
@@ -324,9 +324,9 @@ static void ixmlDomTreetoString(
break;
default:
IxmlPrintf("(%s::ixmlDomTreetoString) line %d: "
IxmlPrintf(__FILE__, __LINE__, "ixmlPrintDomTreeRecursive",
"Warning, unknown node type %d\n",
__FILE__, __LINE__, ixmlNode_getNodeType(nodeptr));
ixmlNode_getNodeType(nodeptr));
break;
}
}

View File

@@ -17,15 +17,54 @@
#ifdef DEBUG
void IxmlPrintf(
const char *DbgFileName,
int DbgLineNo,
const char *FunctionName,
const char *FmtStr,
...)
{
va_list ArgList;
va_start(ArgList, FmtStr);
vfprintf(stdout, FmtStr, ArgList);
fflush(stdout);
va_end(ArgList);
FILE *fp = stdout;
fprintf(fp, "(%s::%s), line %d", DbgFileName, FunctionName, DbgLineNo);
if (FmtStr) {
fprintf(fp, ": ");
va_start(ArgList, FmtStr);
vfprintf(fp, FmtStr, ArgList);
fflush(fp);
va_end(ArgList);
} else {
fprintf(fp, "\n");
}
}
void printNodes(IXML_Node *tmpRoot, int depth)
{
int i;
IXML_NodeList *NodeList1;
IXML_Node *ChildNode1;
unsigned short NodeType;
const DOMString NodeValue;
const DOMString NodeName;
NodeList1 = ixmlNode_getChildNodes(tmpRoot);
for (i = 0; i < 100; ++i) {
ChildNode1 = ixmlNodeList_item(NodeList1, i);
if (ChildNode1 == NULL) {
break;
}
printNodes(ChildNode1, depth+1);
NodeType = ixmlNode_getNodeType(ChildNode1);
NodeValue = ixmlNode_getNodeValue(ChildNode1);
NodeName = ixmlNode_getNodeName(ChildNode1);
IxmlPrintf(__FILE__, __LINE__, "printNodes",
"DEPTH-%2d-IXML_Node Type %d, "
"IXML_Node Name: %s, IXML_Node Value: %s\n",
depth, NodeType, NodeName, NodeValue);
}
}
#endif

View File

@@ -542,8 +542,7 @@ static int Parser_UTF8ToInt(
*len = 0;
ret = -1;
}
IxmlPrintf("(%s::Parser_UTF8ToInt): Error %d, line %d\n",
__FILE__, ret, line);
IxmlPrintf(__FILE__, line, "Parser_UTF8ToInt", "Error %d\n", ret);
return ret;
}
}
@@ -1305,8 +1304,7 @@ fail_entity:
ExitFunction:
if (ret == -1 || (g_error_char && ret == g_error_char)) {
IxmlPrintf("(%s::Parser_getChar): Error %d, line %d\n",
__FILE__, ret, line);
IxmlPrintf(__FILE__, line, "Parser_getChar", "Error %d\n", ret);
}
return ret;
@@ -1373,8 +1371,7 @@ static int Parser_copyToken(
ExitFunction:
if (ret != IXML_SUCCESS) {
IxmlPrintf("(%s::Parser_copyToken): Error %d, line %d\n",
__FILE__, ret, line);
IxmlPrintf(__FILE__, line, "Parser_copyToken", "Error %d\n", ret);
}
return ret;
@@ -1921,8 +1918,7 @@ static int Parser_xmlNamespace(
ExitFunction:
if (ret != IXML_SUCCESS && ret != IXML_FILE_DONE) {
IxmlPrintf("(%s::Parser_xmlNamespace): Error %d, line %d\n",
__FILE__, ret, line);
IxmlPrintf(__FILE__, line, "Parser_xmlNamespace", "Error %d\n", ret);
}
return ret;
@@ -2251,8 +2247,7 @@ static int Parser_processContent(
ExitFunction:
if (ret != IXML_SUCCESS) {
IxmlPrintf("(%s::Parser_processContent): Error %d, line %d\n",
__FILE__, ret, line);
IxmlPrintf(__FILE__, line, "Parser_processContent", "Error %d\n", ret);
}
return ret;
@@ -2324,8 +2319,7 @@ static int Parser_processETag(
ExitFunction:
if (ret != IXML_SUCCESS) {
IxmlPrintf("(%s::Parser_processETag): Error %d, line %d\n",
__FILE__, ret, line);
IxmlPrintf(__FILE__, line, "Parser_processETag", "Error %d\n", ret);
}
return ret;
@@ -2580,8 +2574,7 @@ static int Parser_processAttribute(
ExitFunction:
if (ret != IXML_SUCCESS && ret != IXML_FILE_DONE) {
IxmlPrintf("(%s::Parser_processAttribute): Error %d, line %d\n",
__FILE__, ret, line);
IxmlPrintf(__FILE__, line, "Parser_processAttribute", "Error %d\n", ret);
}
return ret;
@@ -2684,8 +2677,7 @@ static int Parser_getNextNode(
ExitFunction:
if (ret != IXML_SUCCESS && ret != IXML_FILE_DONE) {
IxmlPrintf("(%s::Parser_getNextNode): Error %d, line %d\n",
__FILE__, ret, line);
IxmlPrintf(__FILE__, line, "Parser_getNextNode", "Error %d\n", ret);
}
return ret;

View File

@@ -1,4 +1,4 @@
Version: 1.6.7
Version: 1.6.9
Summary: Universal Plug and Play (UPnP) SDK
Name: libupnp
Release: 1%{?dist}

View File

@@ -29,14 +29,24 @@
*
******************************************************************************/
#ifndef FREE_LIST_H
#define FREE_LIST_H
/*!
* \file
*/
#ifdef __cplusplus
extern "C" {
#endif
#include "ithread.h"
#include <errno.h>
/****************************************************************************

View File

@@ -29,21 +29,32 @@
*
******************************************************************************/
#ifndef LINKED_LIST_H
#define LINKED_LIST_H
/*!
* \file
*/
#include "FreeList.h"
#ifdef __cplusplus
extern "C" {
#endif
#define EOUTOFMEM (-7 & 1<<29)
#define FREELISTSIZE 100
#define LIST_SUCCESS 1
#define LIST_FAIL 0
/****************************************************************************
* Name: free_routine
*
@@ -52,6 +63,7 @@ extern "C" {
*****************************************************************************/
typedef void (*free_function)(void *arg);
/****************************************************************************
* Name: cmp_routine
*
@@ -61,6 +73,7 @@ typedef void (*free_function)(void *arg);
*****************************************************************************/
typedef int (*cmp_routine)(void *itemA,void *itemB);
/****************************************************************************
* Name: ListNode
*
@@ -75,6 +88,7 @@ typedef struct LISTNODE
void *item;
} ListNode;
/****************************************************************************
* Name: LinkedList
*
@@ -104,6 +118,7 @@ typedef struct LINKEDLIST
cmp_routine cmp_func; /* compare function to use */
} LinkedList;
/****************************************************************************
* Function: ListInit
*
@@ -119,6 +134,7 @@ typedef struct LINKEDLIST
*****************************************************************************/
int ListInit(LinkedList *list,cmp_routine cmp_func, free_function free_func);
/****************************************************************************
* Function: ListAddHead
*
@@ -135,6 +151,7 @@ int ListInit(LinkedList *list,cmp_routine cmp_func, free_function free_func);
*****************************************************************************/
ListNode *ListAddHead(LinkedList *list, void *item);
/****************************************************************************
* Function: ListAddTail
*
@@ -151,6 +168,7 @@ ListNode *ListAddHead(LinkedList *list, void *item);
*****************************************************************************/
ListNode *ListAddTail(LinkedList *list, void *item);
/****************************************************************************
* Function: ListAddAfter
*
@@ -205,6 +223,7 @@ ListNode *ListAddBefore(LinkedList *list,void *item, ListNode *anode);
*****************************************************************************/
void *ListDelNode(LinkedList *list,ListNode *dnode, int freeItem);
/****************************************************************************
* Function: ListDestroy
*
@@ -240,6 +259,7 @@ int ListDestroy(LinkedList *list, int freeItem);
*****************************************************************************/
ListNode* ListHead(LinkedList *list);
/****************************************************************************
* Function: ListTail
*
@@ -256,6 +276,7 @@ ListNode* ListHead(LinkedList *list);
*****************************************************************************/
ListNode* ListTail(LinkedList *list);
/****************************************************************************
* Function: ListNext
*
@@ -272,6 +293,7 @@ ListNode* ListTail(LinkedList *list);
*****************************************************************************/
ListNode* ListNext(LinkedList *list, ListNode * node);
/****************************************************************************
* Function: ListPrev
*
@@ -288,6 +310,7 @@ ListNode* ListNext(LinkedList *list, ListNode * node);
*****************************************************************************/
ListNode* ListPrev(LinkedList *list, ListNode * node);
/****************************************************************************
* Function: ListFind
*
@@ -307,6 +330,7 @@ ListNode* ListPrev(LinkedList *list, ListNode * node);
*****************************************************************************/
ListNode* ListFind(LinkedList *list, ListNode *start, void * item);
/****************************************************************************
* Function: ListSize
*

View File

@@ -29,160 +29,139 @@
*
******************************************************************************/
#ifndef TIMERTHREAD_H
#define TIMERTHREAD_H
/*!
* \file
*/
#include "FreeList.h"
#include "ithread.h"
#include "LinkedList.h"
#include "FreeList.h"
#include "ThreadPool.h"
#ifdef __cplusplus
extern "C" {
#endif
#define INVALID_EVENT_ID (-10 & 1<<29)
/* Timeout Types */
/* absolute means in seconds from Jan 1, 1970 */
/* relative means in seconds from current time */
typedef enum timeoutType {ABS_SEC,REL_SEC} TimeoutType;
/****************************************************************************
* Name: TimerThread
*
* Description:
* A timer thread similar to the one in the Upnp SDK that allows
* the scheduling of a job to run at a specified time in the future
* Because the timer thread uses the thread pool there is no
* gurantee of timing, only approximate timing.
* Uses ThreadPool, Mutex, Condition, Thread
*
*
*****************************************************************************/
/*!
* A timer thread similar to the one in the Upnp SDK that allows
* the scheduling of a job to run at a specified time in the future.
*
* Because the timer thread uses the thread pool there is no
* gurantee of timing, only approximate timing.
*
* Uses ThreadPool, Mutex, Condition, Thread.
*/
typedef struct TIMERTHREAD
{
ithread_mutex_t mutex;
ithread_cond_t condition;
int lastEventId;
LinkedList eventQ;
int shutdown;
FreeList freeEvents;
ThreadPool *tp;
ithread_mutex_t mutex;
ithread_cond_t condition;
int lastEventId;
LinkedList eventQ;
int shutdown;
FreeList freeEvents;
ThreadPool *tp;
} TimerThread;
/****************************************************************************
* Name: TimerEvent
*
* Description:
*
* Struct to contain information for a timer event.
* Internal to the TimerThread
*
*****************************************************************************/
/*!
* Struct to contain information for a timer event.
*
* Internal to the TimerThread.
*/
typedef struct TIMEREVENT
{
ThreadPoolJob job;
time_t eventTime; /* absolute time for event in seconds since Jan 1, 1970 */
Duration persistent; /* long term or short term job */
int id;
ThreadPoolJob job;
/*! [in] Absolute time for event in seconds since Jan 1, 1970. */
time_t eventTime;
/*! [in] Long term or short term job. */
Duration persistent;
int id;
} TimerEvent;
/************************************************************************
* Function: TimerThreadInit
*
* Description:
* Initializes and starts timer thread.
/*!
* \brief Initializes and starts timer thread.
*
* Parameters:
* timer - valid timer thread pointer.
* tp - valid thread pool to use. Must be
* started. Must be valid for lifetime
* of timer. Timer must be shutdown
* BEFORE thread pool.
* Return:
* 0 on success, nonzero on failure
* Returns error from ThreadPoolAddPersistent on failure.
*
************************************************************************/
int TimerThreadInit(TimerThread *timer,
ThreadPool *tp);
* \return 0 on success, nonzero on failure. Returns error from
* ThreadPoolAddPersistent on failure.
*/
int TimerThreadInit(
/*! [in] Valid timer thread pointer. */
TimerThread *timer,
/*! [in] Valid thread pool to use. Must be started. Must be valid for
* lifetime of timer. Timer must be shutdown BEFORE thread pool. */
ThreadPool *tp);
/************************************************************************
* Function: TimerThreadSchedule
*
* Description:
* Schedules an event to run at a specified time.
/*!
* \brief Schedules an event to run at a specified time.
*
* Parameters:
* timer - valid timer thread pointer.
* time_t - time of event.
* either in absolute seconds,
* or relative seconds in the future.
* timeoutType - either ABS_SEC, or REL_SEC.
* if REL_SEC, then the event
* will be scheduled at the
* current time + REL_SEC.
* job-> valid Thread pool job with following fields
* func - function to schedule
* arg - argument to function
* priority - priority of job.
*
* id - id of timer event. (out, can be null)
* Return:
* 0 on success, nonzero on failure
* EOUTOFMEM if not enough memory to schedule job.
*
************************************************************************/
int TimerThreadSchedule(TimerThread* timer,
time_t time,
TimeoutType type,
ThreadPoolJob *job,
Duration duration,
int *id);
* \return 0 on success, nonzero on failure, EOUTOFMEM if not enough memory
* to schedule job.
*/
int TimerThreadSchedule(
/*! [in] Valid timer thread pointer. */
TimerThread* timer,
/*! [in] time of event. Either in absolute seconds, or relative
* seconds in the future. */
time_t time,
/*! [in] either ABS_SEC, or REL_SEC. If REL_SEC, then the event
* will be scheduled at the current time + REL_SEC. */
TimeoutType type,
/*! [in] Valid Thread pool job with following fields. */
ThreadPoolJob *job,
/*! [in] . */
Duration duration,
/*! [in] Id of timer event. (out, can be null). */
int *id);
/************************************************************************
* Function: TimerThreadRemove
*
* Description:
* Removes an event from the timer Q.
* Events can only be removed
* before they have been placed in the
* thread pool.
*
* Parameters:
* timer - valid timer thread pointer.
* id - id of event to remove.
* ThreadPoolJob *out - space for thread pool job.
* Return:
* 0 on success,
* INVALID_EVENT_ID on failure
*
************************************************************************/
int TimerThreadRemove(TimerThread *timer,
int id,
ThreadPoolJob *out);
/************************************************************************
* Function: TimerThreadShutdown
*
* Description:
* Shutdown the timer thread
* Events scheduled in the future will NOT be run.
* Timer thread should be shutdown BEFORE it's associated
* thread pool.
* Returns:
* returns 0 if succesfull,
* nonzero otherwise.
* Always returns 0.
***********************************************************************/
int TimerThreadShutdown(TimerThread *timer);
/*!
* \brief Removes an event from the timer Q.
*
* Events can only be removed before they have been placed in the thread pool.
*
* \return 0 on success, INVALID_EVENT_ID on failure.
*/
int TimerThreadRemove(
/*! [in] Valid timer thread pointer. */
TimerThread *timer,
/*! [in] Id of event to remove. */
int id,
/*! [in] Space for thread pool job. */
ThreadPoolJob *out);
/*!
* \brief Shutdown the timer thread.
*
* Events scheduled in the future will NOT be run.
*
* Timer thread should be shutdown BEFORE it's associated thread pool.
*
* \return 0 if succesfull, nonzero otherwise. Always returns 0.
*/
int TimerThreadShutdown(
/*! [in] Valid timer thread pointer. */
TimerThread *timer);
#ifdef __cplusplus
}

View File

@@ -188,7 +188,10 @@ typedef pthread_rwlockattr_t ithread_rwlockattr_t;
* Internal Use Only
***************************************************************************/
#if UPNP_USE_RWLOCK
typedef pthread_rwlock_t ithread_rwlock_t;
typedef pthread_rwlock_t ithread_rwlock_t;
#else
/* Read-write locks aren't available: use mutex instead. */
typedef ithread_mutex_t ithread_rwlock_t;
#endif /* UPNP_USE_RWLOCK */
@@ -337,7 +340,7 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
#define ithread_mutexattr_setkind_np pthread_mutexattr_settype
#else
#define ithread_mutexattr_setkind_np pthread_mutexattr_setkind_np
#endif
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
* Function: ithread_mutexattr_getkind_np
@@ -362,7 +365,7 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
#define ithread_mutexattr_getkind_np pthread_mutexattr_gettype
#else
#define ithread_mutexattr_getkind_np pthread_mutexattr_getkind_np
#endif
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
@@ -536,8 +539,10 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
*****************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlock_init pthread_rwlock_init
#endif /* UPNP_USE_RWLOCK */
#else
/* Read-write locks aren't available: use mutex instead. */
#define ithread_rwlock_init ithread_mutex_init
#endif
/****************************************************************************
* Function: ithread_rwlock_rdlock
@@ -555,9 +560,11 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
*****************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlock_rdlock pthread_rwlock_rdlock
#else
/* Read-write locks aren't available: use mutex instead. */
#define ithread_rwlock_rdlock ithread_mutex_lock
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
* Function: ithread_rwlock_wrlock
*
@@ -574,6 +581,9 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
*****************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlock_wrlock pthread_rwlock_wrlock
#else
/* Read-write locks aren't available: use mutex instead. */
#define ithread_rwlock_wrlock ithread_mutex_lock
#endif /* UPNP_USE_RWLOCK */
@@ -594,6 +604,9 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
*****************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlock_unlock pthread_rwlock_unlock
#else
/* Read-write locks aren't available: use mutex instead. */
#define ithread_rwlock_unlock ithread_mutex_unlock
#endif /* UPNP_USE_RWLOCK */
@@ -615,6 +628,9 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
*****************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlock_destroy pthread_rwlock_destroy
#else
/* Read-write locks aren't available: use mutex instead. */
#define ithread_rwlock_destroy ithread_mutex_destroy
#endif /* UPNP_USE_RWLOCK */

View File

@@ -1,45 +1,55 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2003 Intel Corporation
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither name of Intel Corporation nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
/**************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************/
#include "LinkedList.h"
#ifndef WIN32
#ifdef WIN32
/* Do not #include <sys/param.h> */
#else
#include <sys/param.h>
#endif
#if (defined(BSD) && BSD >= 199306) || defined(__OSX__) || defined(__APPLE__)
#include <stdlib.h>
#else
#include <malloc.h>
#endif
#include <assert.h>
static int
freeListNode( ListNode * node,
LinkedList * list )

View File

@@ -1,68 +1,69 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2003 Intel Corporation
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither name of Intel Corporation nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
/*******************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
/*!
* \file
*/
#include "TimerThread.h"
#include <assert.h>
/****************************************************************************
* Function: FreeTimerEvent
*
* Description:
* Deallocates a dynamically allocated TimerEvent.
* Parameters:
* TimerEvent *event - must be allocated with CreateTimerEvent
*****************************************************************************/
static void
FreeTimerEvent( TimerThread * timer,
TimerEvent * event )
/*!
* \brief Deallocates a dynamically allocated TimerEvent.
*/
static void FreeTimerEvent(
/*! [in] Valid timer thread pointer. */
TimerThread *timer,
/*! [in] Must be allocated with CreateTimerEvent*/
TimerEvent *event)
{
assert(timer != NULL);
assert( timer != NULL );
FreeListFree( &timer->freeEvents, event );
FreeListFree(&timer->freeEvents, event);
}
/****************************************************************************
* Function: TimerThreadWorker
/*!
* \brief Implements timer thread.
*
* Description:
* Implements timer thread.
* Waits for next event to occur and schedules
* associated job into threadpool.
* Internal Only.
* Parameters:
* void * arg -> is cast to TimerThread *
*****************************************************************************/
static void *
TimerThreadWorker( void *arg )
* Waits for next event to occur and schedules associated job into threadpool.
*/
static void *TimerThreadWorker(
/*! [in] arg is cast to (TimerThread *). */
void *arg)
{
TimerThread *timer = ( TimerThread * ) arg;
ListNode *head = NULL;
@@ -81,19 +82,14 @@ TimerThreadWorker( void *arg )
while( 1 )
{
//mutex should always be locked at top of loop
//Check for shutdown
if( timer->shutdown )
{
timer->shutdown = 0;
ithread_cond_signal( &timer->condition );
ithread_mutex_unlock( &timer->mutex );
return NULL;
}
nextEvent = NULL;
@@ -102,7 +98,6 @@ TimerThreadWorker( void *arg )
if( timer->eventQ.size > 0 )
{
head = ListHead( &timer->eventQ );
nextEvent = ( TimerEvent * ) head->item;
nextEventTime = nextEvent->eventTime;
}
@@ -110,54 +105,42 @@ TimerThreadWorker( void *arg )
currentTime = time( NULL );
//If time has elapsed, schedule job
if( ( nextEvent != NULL ) && ( currentTime >= nextEventTime ) )
{
if( nextEvent->persistent ) {
ThreadPoolAddPersistent( timer->tp, &nextEvent->job,
&tempId );
} else {
ThreadPoolAdd( timer->tp, &nextEvent->job, &tempId );
}
ListDelNode( &timer->eventQ, head, 0 );
FreeTimerEvent( timer, nextEvent );
continue;
}
if( nextEvent != NULL ) {
timeToWait.tv_nsec = 0;
timeToWait.tv_sec = nextEvent->eventTime;
ithread_cond_timedwait( &timer->condition, &timer->mutex,
&timeToWait );
} else {
ithread_cond_wait( &timer->condition, &timer->mutex );
}
}
}
/****************************************************************************
* Function: CalculateEventTime
/*!
* \brief Calculates the appropriate timeout in absolute seconds
* since Jan 1, 1970.
*
* Description:
* Calculates the appropriate timeout in absolute seconds since
* Jan 1, 1970
* Internal Only.
* Parameters:
* time_t *timeout - timeout
*
*****************************************************************************/
static int
CalculateEventTime( time_t * timeout,
TimeoutType type )
* \return
*/
static int CalculateEventTime(
/*! [in] Timeout. */
time_t *timeout,
/*! [in] Timeout type. */
TimeoutType type)
{
time_t now;
@@ -175,29 +158,22 @@ CalculateEventTime( time_t * timeout,
}
/****************************************************************************
* Function: CreateTimerEvent
/*!
* \brief Creates a Timer Event. (Dynamically allocated).
*
* Description:
* Creates a Timer Event. (Dynamically allocated)
* Internal to timer thread.
* Parameters:
* func - thread function to run.
* arg - argument to function.
* priority - priority of job.
* eventTime - the absoule time of the event
* in seconds from Jan, 1970
* id - id of job
*
* Returns:
* TimerEvent * on success, NULL on failure.
****************************************************************************/
static TimerEvent *
CreateTimerEvent( TimerThread * timer,
ThreadPoolJob * job,
Duration persistent,
time_t eventTime,
int id )
* \return (TimerEvent *) on success, NULL on failure.
*/
static TimerEvent *CreateTimerEvent(
/*! [in] Valid timer thread pointer. */
TimerThread *timer,
/*! [in] . */
ThreadPoolJob *job,
/*! [in] . */
Duration persistent,
/*! [in] The absoule time of the event in seconds from Jan, 1970. */
time_t eventTime,
/*! [in] Id of job. */
int id)
{
TimerEvent *temp = NULL;
@@ -215,25 +191,8 @@ CreateTimerEvent( TimerThread * timer,
return temp;
}
/************************************************************************
* Function: TimerThreadInit
*
* Description:
* Initializes and starts timer thread.
*
* Parameters:
* timer - valid timer thread pointer.
* tp - valid thread pool to use. Must be
* started. Must be valid for lifetime
* of timer. Timer must be shutdown
* BEFORE thread pool.
* Return:
* 0 on success, nonzero on failure
* Returns error from ThreadPoolAddPersistent if failure.
************************************************************************/
int
TimerThreadInit( TimerThread * timer,
ThreadPool * tp )
int TimerThreadInit(TimerThread *timer, ThreadPool *tp)
{
int rc = 0;
@@ -290,37 +249,14 @@ TimerThreadInit( TimerThread * timer,
}
/************************************************************************
* Function: TimerThreadSchedule
*
* Description:
* Schedules an event to run at a specified time.
*
* Parameters:
* timer - valid timer thread pointer.
* time_t - time of event.
* either in absolute seconds,
* or relative seconds in the future.
* timeoutType - either ABS_SEC, or REL_SEC.
* if REL_SEC, then the event
* will be scheduled at the
* current time + REL_SEC.
*
* func - function to schedule
* arg - argument to function
* priority - priority of job.
* id - id of timer event. (out)
* Return:
* 0 on success, nonzero on failure
* EOUTOFMEM if not enough memory to schedule job
************************************************************************/
int
TimerThreadSchedule( TimerThread * timer,
time_t timeout,
TimeoutType type,
ThreadPoolJob * job,
Duration duration,
int *id )
int TimerThreadSchedule(
TimerThread *timer,
time_t timeout,
TimeoutType type,
ThreadPoolJob *job,
Duration duration,
int *id)
{
int rc = EOUTOFMEM;
@@ -394,28 +330,11 @@ TimerThreadSchedule( TimerThread * timer,
return rc;
}
/************************************************************************
* Function: TimerThreadRemove
*
* Description:
* Removes an event from the timer Q.
* Events can only be removed
* before they have been placed in the
* thread pool.
*
* Parameters:
* timer - valid timer thread pointer.
* id - id of event to remove.
* out - space for returned job (Can be NULL)
* Return:
* 0 on success.
* INVALID_EVENT_ID on error.
*
************************************************************************/
int
TimerThreadRemove( TimerThread * timer,
int id,
ThreadPoolJob * out )
int TimerThreadRemove(
TimerThread *timer,
int id,
ThreadPoolJob *out)
{
int rc = INVALID_EVENT_ID;
ListNode *tempNode = NULL;
@@ -450,21 +369,8 @@ TimerThreadRemove( TimerThread * timer,
return rc;
}
/************************************************************************
* Function: TimerThreadShutdown
*
* Description:
* Shutdown the timer thread
* Events scheduled in the future will NOT be run.
* Timer thread should be shutdown BEFORE it's associated
* thread pool.
* Returns:
* returns 0 if succesfull,
* nonzero otherwise.
* Always returns 0.
***********************************************************************/
int
TimerThreadShutdown( TimerThread * timer )
int TimerThreadShutdown(TimerThread *timer)
{
ListNode *tempNode2 = NULL;
ListNode *tempNode = NULL;
@@ -517,3 +423,4 @@ TimerThreadShutdown( TimerThread * timer )
return 0;
}

View File

@@ -67,12 +67,10 @@ libupnp_la_SOURCES = \
src/inc/sysdep.h \
src/inc/unixutil.h \
src/inc/upnpapi.h \
src/inc/upnpclosesocket.h \
src/inc/upnp_timeout.h \
src/inc/uri.h \
src/inc/urlconfig.h \
src/inc/util.h \
src/inc/utilall.h \
src/inc/upnputil.h \
src/inc/uuid.h \
src/inc/VirtualDir.h \
src/inc/webserver.h

View File

@@ -12,8 +12,11 @@
#ifdef WIN32
#include <iphlpapi.h>
#include <winsock2.h>
#include <Ws2tcpip.h>
#define UpnpCloseSocket closesocket
#else
#include <sys/param.h>
#if (defined(BSD) && BSD >= 199306) || defined (__FreeBSD_kernel__)
@@ -23,6 +26,11 @@
#include <sys/socket.h>
#endif
#include <netinet/in.h>
#include <unistd.h> /* for close(). Do not include in WIN32. */
#define SOCKET int
#define INVALID_SOCKET ((SOCKET)(-1))
#define UpnpCloseSocket close
#endif

View File

@@ -69,22 +69,6 @@
#endif
#ifdef WIN32
#include <iphlpapi.h>
#else
#define SOCKET int
#define INVALID_SOCKET (SOCKET)(~0)
#endif
#ifdef WIN32
#define UpnpCloseSocket closesocket
#define fseeko fseek
#else
#define UpnpCloseSocket close
#endif
#define LINE_SIZE 180
#define NAME_SIZE 256
#define MNFT_NAME_SIZE 64

View File

@@ -1,7 +1,7 @@
/* -*- C -*- */
/*******************************************************************************
*
* Copyright (c) 2006 R<EFBFBD>mi Turboult <r3mi@users.sourceforge.net>
* Copyright (c) 2006 Rémi Turboult <r3mi@users.sourceforge.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -52,7 +52,7 @@
/** The library version (numeric) e.g. 10300 means version 1.3.0 */
#define UPNP_VERSION \
((UPNP_VERSION_MAJOR*100 + UPNP_VERSION_MINOR)*100 + UPNP_VERSION_PATCH)
((UPNP_VERSION_MAJOR * 100 + UPNP_VERSION_MINOR) * 100 + UPNP_VERSION_PATCH)

View File

@@ -304,24 +304,6 @@ static UPNP_INLINE void PrintThreadPoolStats(
#endif
/*!
* \brief Print the node names and values of a XML tree.
*/
#ifdef DEBUG
void printNodes(
/*! [in] The root of the tree to print. */
IXML_Node *tmpRoot,
/*! [in] The depth to print. */
int depth);
#else
static UPNP_INLINE void printNodes(
IXML_Node *tmpRoot,
int depth)
{
}
#endif
/*@}*/
#ifdef __cplusplus

View File

@@ -29,201 +29,237 @@
*
******************************************************************************/
/** @name Optional Tool APIs
* The Linux SDK for UPnP Devices contains some additional, optional
* utility APIs that can be helpful in writing applications using the
* SDK. These additional APIs can be compiled out in order to save code
* size in the SDK. Refer to the README for details.
*/
/*! @{ */
#ifndef UPNP_TOOLS_H
#define UPNP_TOOLS_H
#include "upnp.h"
/*!
* \file
*
* \defgroup UPnPTools Optional Tool API
*
* \brief Additional, optional utility API that can be helpful in writing
* applications.
*
* This additional API can be compiled out in order to save code size in the
* library. Refer to the file README for details.
*
* @{
*/
#include "ixml.h" /* for IXML_Document */
/* Function declarations only if tools compiled into the library */
#if UPNP_HAVE_TOOLS
#ifdef __cplusplus
extern "C" {
#endif
/** {\bf UpnpResolveURL} combines a base URL and a relative URL into
* a single absolute URL. The memory for {\bf AbsURL} needs to be
* allocated by the caller and must be large enough to hold the
* {\bf BaseURL} and {\bf RelURL} combined.
/*!
* \brief Converts an SDK error code into a string error message suitable for
* display. The memory returned from this function should NOT be freed.
*
* @return [int] An integer representing one of the following:
* \begin{itemize}
* \item {\tt UPNP_E_SUCCESS}: The operation completed successfully.
* \item {\tt UPNP_E_INVALID_PARAM}: {\bf RelURL} is {\tt NULL}.
* \item {\tt UPNP_E_INVALID_URL}: The {\bf BaseURL} / {\bf RelURL}
* \return An ASCII text string representation of the error message associated
* with the error code or the string "Unknown error code"
*/
EXPORT_SPEC const char *UpnpGetErrorMessage(
/*! [in] The SDK error code to convert. */
int errorcode);
/*!
* \brief Combines a base URL and a relative URL into a single absolute URL.
*
* The memory for \b AbsURL needs to be allocated by the caller and must
* be large enough to hold the \b BaseURL and \b RelURL combined.
*
* \return An integer representing one of the following:
* \li <tt>UPNP_E_SUCCESS</tt>: The operation completed successfully.
* \li <tt>UPNP_E_INVALID_PARAM</tt>: \b RelURL is <tt>NULL</tt>.
* \li <tt>UPNP_E_INVALID_URL</tt>: The \b BaseURL / \b RelURL
* combination does not form a valid URL.
* \item {\tt UPNP_E_OUTOF_MEMORY}: Insufficient resources exist to
* \li <tt>UPNP_E_OUTOF_MEMORY</tt>: Insufficient resources exist to
* complete this operation.
* \end{itemize}
*/
EXPORT_SPEC int UpnpResolveURL(
IN const char * BaseURL, /** The base URL to combine. */
IN const char * RelURL, /** The relative URL to {\bf BaseURL}. */
OUT char * AbsURL /** A pointer to a buffer to store the
absolute URL. */
);
/*! [in] The base URL to combine. */
const char *BaseURL,
/*! [in] The relative URL to \b BaseURL. */
const char *RelURL,
/*! [out] A pointer to a buffer to store the absolute URL. */
char *AbsURL);
/** {\bf UpnpMakeAction} creates an action request packet based on its input
* parameters (status variable name and value pair). Any number of input
* parameters can be passed to this function but every input variable name
* should have a matching value argument.
*
* @return [IXML_Document*] The action node of {\bf Upnp_Document} type or
* {\tt NULL} if the operation failed.
*/
EXPORT_SPEC IXML_Document* UpnpMakeAction(
IN const char * ActionName, /** The action name. */
IN const char * ServType, /** The service type. */
IN int NumArg, /** Number of argument pairs to be passed. */
IN const char * Arg, /** Status variable name and value pair. */
IN ... /* Other status variable name and value pairs. */
);
/** {\bf UpnpAddToAction} creates an action request packet based on its input
* parameters (status variable name and value pair). This API is specially
* suitable inside a loop to add any number input parameters into an existing
* action. If no action document exists in the beginning then a
* {\bf Upnp_Document} variable initialized with {\tt NULL} should be passed
* as a parameter.
/*!
* \brief Creates an action request packet based on its input parameters
* (status variable name and value pair).
*
* @return [int] An integer representing one of the following:
* \begin{itemize}
* \item {\tt UPNP_E_SUCCESS}: The operation completed successfully.
* \item {\tt UPNP_E_INVALID_PARAM}: One or more of the parameters
* are invalid.
* \item {\tt UPNP_E_OUTOF_MEMORY}: Insufficient resources exist to
* complete this operation.
* \end{itemize}
* Any number of input parameters can be passed to this function but every
* input variable name should have a matching value argument.
*
* It is a wrapper function that calls makeAction() function to create the
* action request.
*
* \return The action node of \b Upnp_Document type or <tt>NULL</tt> if the
* operation failed.
*/
EXPORT_SPEC IXML_Document *UpnpMakeAction(
/*! [in] Name of the action request or response. */
const char *ActionName,
/*! [in] The service type. */
const char *ServType,
/*! [in] Number of argument pairs to be passed. */
int NumArg,
/*! [in] pointer to the first argument. */
const char *Arg,
/*! [in] Argument list. */
...);
/*!
* \brief Ceates an action response packet based on its output parameters
* (status variable name and value pair).
*
* Any number of input parameters can be passed to this function but every
* output variable name should have a matching value argument.
*
* It is a wrapper function that calls makeAction() function to create the
* action request.
*
* \return The action node of \b Upnp_Document type or <tt>NULL</tt> if the
* operation failed.
*/
EXPORT_SPEC IXML_Document *UpnpMakeActionResponse(
/*! [in] The action name. */
const char *ActionName,
/*! [in] The service type.. */
const char *ServType,
/*! [in] The number of argument pairs passed. */
int NumArg,
/*! [in] The status variable name and value pair. */
const char *Arg,
/*! [in] Other status variable name and value pairs. */
...);
/*!
* \brief Adds the argument in the action request.
*
* This API is specially suitable inside a loop to add any number input
* parameters into an existing action. If no action document exists in the
* beginning then a <b>Upnp_Document variable initialized with <tt>NULL</tt></b>
* should be passed as a parameter.
*
* It is a wrapper function that calls addToAction() function to add the
* argument in the action request.
*
* \return An integer representing one of the following:
* \li <tt>UPNP_E_SUCCESS</tt>: The operation completed successfully.
* \li <tt>UPNP_E_INVALID_PARAM</tt>: One or more of the parameters are invalid.
* \li <tt>UPNP_E_OUTOF_MEMORY</tt>: Insufficient resources exist to
* complete this operation.
*/
EXPORT_SPEC int UpnpAddToAction(
IN OUT IXML_Document ** ActionDoc,
/** A pointer to store the action
document node. */
IN const char * ActionName, /** The action name. */
IN const char * ServType, /** The service type. */
IN const char * ArgName, /** The status variable name. */
IN const char * ArgVal /** The status variable value. */
);
/*! [in,out] A pointer to store the action document node. */
IXML_Document **ActionDoc,
/*! [in] The action name. */
const char *ActionName,
/*! [in] The service type. */
const char *ServType,
/*! [in] The status variable name. */
const char *ArgName,
/*! [in] The status variable value. */
const char *ArgVal);
/** {\bf UpnpMakeActionResponse} creates an action response packet based
* on its output parameters (status variable name and value pair). Any
* number of input parameters can be passed to this function but every output
* variable name should have a matching value argument.
*
* @return [IXML_Document*] The action node of {\bf Upnp_Document} type or
* {\tt NULL} if the operation failed.
*/
EXPORT_SPEC IXML_Document* UpnpMakeActionResponse(
IN const char * ActionName, /** The action name. */
IN const char * ServType, /** The service type. */
IN int NumArg, /** The number of argument pairs passed. */
IN const char * Arg, /** The status variable name and value pair. */
IN ... /* Other status variable name and value pairs. */
);
/** {\bf UpnpAddToActionResponse} creates an action response
* packet based on its output parameters (status variable name
* and value pair). This API is especially suitable inside
* a loop to add any number of input parameters into an existing action
* response. If no action document exists in the beginning, a
* {\bf Upnp_Document} variable initialized with {\tt NULL} should be passed
* as a parameter.
/*!
* \brief Creates an action response packet based on its output parameters
* (status variable name and value pair).
*
* @return [int] An integer representing one of the following:
* \begin{itemize}
* \item {\tt UPNP_E_SUCCESS}: The operation completed successfully.
* \item {\tt UPNP_E_INVALID_PARAM}: One or more of the parameters
* are invalid.
* \item {\tt UPNP_E_OUTOF_MEMORY}: Insufficient resources exist to
* complete this operation.
* \end{itemize}
* This API is especially suitable inside a loop to add any number of input
* parameters into an existing action response. If no action document exists
* in the beginning, a \b Upnp_Document variable initialized with <tt>NULL</tt>
* should be passed as a parameter.
*
* It is a wrapper function that calls addToAction() function to add the
* argument in the action request.
*
* \return An integer representing one of the following:
* \li <tt>UPNP_E_SUCCESS</tt>: The operation completed successfully.
* \li <tt>UPNP_E_INVALID_PARAM</tt>: One or more of the parameters are invalid.
* \li <tt>UPNP_E_OUTOF_MEMORY</tt>: Insufficient resources exist to
* complete this operation.
*/
EXPORT_SPEC int UpnpAddToActionResponse(
IN OUT IXML_Document ** ActionResponse,
/** Pointer to a document to
store the action document
node. */
IN const char * ActionName, /** The action name. */
IN const char * ServType, /** The service type. */
IN const char * ArgName, /** The status variable name. */
IN const char * ArgVal /** The status variable value. */
);
/*! [in,out] Pointer to a document to store the action document node. */
IXML_Document **ActionResponse,
/*! [in] The action name. */
const char *ActionName,
/*! [in] The service type. */
const char *ServType,
/*! [in] The status variable name. */
const char *ArgName,
/*! [in] The status variable value. */
const char *ArgVal);
/** {\bf UpnpAddToPropertySet} can be used when an application needs to
* transfer the status of many variables at once. It can be used
* (inside a loop) to add some extra status variables into an existing
* property set. If the application does not already have a property
* set document, the application should create a variable initialized
* with {\tt NULL} and pass that as the first parameter.
*
* @return [int] An integer representing one of the following:
* \begin{itemize}
* \item {\tt UPNP_E_SUCCESS}: The operation completed successfully.
* \item {\tt UPNP_E_INVALID_PARAM}: One or more of the parameters
* are invalid.
* \item {\tt UPNP_E_OUTOF_MEMORY}: Insufficient resources exist to
* complete this operation.
* \end{itemize}
/*!
* \brief Creates a property set message packet.
*
* Any number of input parameters can be passed to this function but every
* input variable name should have a matching value input argument.
*
* \return <tt>NULL</tt> on failure, or the property-set document node.
*/
EXPORT_SPEC IXML_Document *UpnpCreatePropertySet(
/*! [in] The number of argument pairs passed. */
int NumArg,
/*! [in] The status variable name and value pair. */
const char *Arg,
/*! [in] Variable sized list with the rest of the parameters. */
...);
/*!
* \brief Can be used when an application needs to transfer the status of many
* variables at once.
*
* It can be used (inside a loop) to add some extra status variables into an
* existing property set. If the application does not already have a property
* set document, the application should create a variable initialized with
* <tt>NULL</tt> and pass that as the first parameter.
*
* \return An integer representing one of the following:
* \li <tt>UPNP_E_SUCCESS</tt>: The operation completed successfully.
* \li <tt>UPNP_E_INVALID_PARAM</tt>: One or more of the parameters are invalid.
* \li <tt>UPNP_E_OUTOF_MEMORY</tt>: Insufficient resources exist to
* complete this operation.
*/
EXPORT_SPEC int UpnpAddToPropertySet(
IN OUT IXML_Document **PropSet,
/** A pointer to the document containing
the property set document node. */
IN const char * ArgName, /** The status variable name. */
IN const char * ArgVal /** The status variable value. */
);
/*! [in,out] A pointer to the document containing the property set document node. */
IXML_Document **PropSet,
/*! [in] The status variable name. */
const char *ArgName,
/*! [in] The status variable value. */
const char *ArgVal);
/** {\bf UpnpCreatePropertySet} creates a property set
* message packet. Any number of input parameters can be passed
* to this function but every input variable name should have
* a matching value input argument.
*
* @return [IXML_Document*] {\tt NULL} on failure, or the property-set
* document node.
*
*/
EXPORT_SPEC IXML_Document* UpnpCreatePropertySet(
IN int NumArg, /** The number of argument pairs passed. */
IN const char* Arg, /** The status variable name and value pair. */
IN ...
);
/** {\bf UpnpGetErrorMessage} converts an SDK error code into a
* string error message suitable for display. The memory returned
* from this function should NOT be freed.
*
* @return [char*] An ASCII text string representation of the error message
* associated with the error code.
*/
EXPORT_SPEC const char * UpnpGetErrorMessage(
int errorcode /** The SDK error code to convert. */
);
/*! @} */
#ifdef __cplusplus
}
#endif
/*! @} */
#endif /* UPNP_HAVE_TOOLS */
#endif /* UPNP_TOOLS_H */

View File

@@ -82,9 +82,6 @@ int SampleUtil_Initialize(print_string print_function)
ithread_mutex_unlock(&display_mutex);
initialize_init = 0;
} else {
SampleUtil_Print("***** SampleUtil_Initialize was called multiple times!\n");
abort();
}
return UPNP_E_SUCCESS;
@@ -428,8 +425,9 @@ int SampleUtil_PrintEvent(IN Upnp_EventType EventType, IN void *Event)
{
ithread_mutex_lock(&display_mutex);
SampleUtil_Print("======================================================================\n");
SampleUtil_Print("----------------------------------------------------------------------\n");
SampleUtil_Print(
"======================================================================\n"
"----------------------------------------------------------------------\n");
SampleUtil_PrintEventType(EventType);
switch (EventType) {
/* SSDP */
@@ -467,7 +465,7 @@ int SampleUtil_PrintEvent(IN Upnp_EventType EventType, IN void *Event)
SampleUtil_Print("ServiceID = %s\n", a_event->ServiceID);
if (a_event->ActionRequest) {
xmlbuff = ixmlPrintNode((IXML_Node *)a_event->ActionRequest);
if ( xmlbuff ) {
if (xmlbuff) {
SampleUtil_Print("ActRequest = %s\n", xmlbuff);
ixmlFreeDOMString(xmlbuff);
}
@@ -541,6 +539,7 @@ int SampleUtil_PrintEvent(IN Upnp_EventType EventType, IN void *Event)
SampleUtil_Print("CurrentVal = %s\n", sv_event->CurrentVal);
break;
}
/* GENA */
case UPNP_EVENT_SUBSCRIPTION_REQUEST: {
struct Upnp_Subscription_Request *sr_event =
@@ -585,7 +584,6 @@ int SampleUtil_PrintEvent(IN Upnp_EventType EventType, IN void *Event)
SampleUtil_Print("TimeOut = %d\n", es_event->TimeOut);
break;
}
case UPNP_EVENT_AUTORENEWAL_FAILED:
case UPNP_EVENT_SUBSCRIPTION_EXPIRED: {
struct Upnp_Event_Subscribe *es_event =
@@ -599,8 +597,10 @@ int SampleUtil_PrintEvent(IN Upnp_EventType EventType, IN void *Event)
break;
}
}
SampleUtil_Print("----------------------------------------------------------------------\n");
SampleUtil_Print("======================================================================\n");
SampleUtil_Print(
"----------------------------------------------------------------------\n"
"======================================================================\n"
"\n\n\n");
ithread_mutex_unlock(&display_mutex);

View File

@@ -1,51 +1,55 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2003 Intel Corporation
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither name of Intel Corporation nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
/*******************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#ifndef SAMPLE_UTIL_H
#define SAMPLE_UTIL_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <stdlib.h>
#include <string.h>
#include "ithread.h"
#include "ixml.h"
#include "ixml.h" /* for IXML_Document, IXML_Element */
#include "upnp.h" /* for Upnp_EventType */
#include "upnptools.h"
// mutex to control displaying of events
#include <stdlib.h>
#include <string.h>
/* mutex to control displaying of events */
extern ithread_mutex_t display_mutex;
@@ -166,7 +170,7 @@ int SampleUtil_PrintEvent(IN Upnp_EventType EventType,
********************************************************************************/
int SampleUtil_FindAndParseService (
IN IXML_Document *DescDoc,
IN const char *location,
IN const char* location,
IN char *serviceType,
OUT char **serviceId,
OUT char **eventURL,

View File

@@ -29,9 +29,14 @@
*
******************************************************************************/
#include "upnp_tv_ctrlpt.h"
/*
#include "upnp.h"
/*!
Mutex for protecting the global device list
in a multi-threaded, asynchronous environment.
All functions should lock this mutex before reading
@@ -48,7 +53,7 @@ char *TvServiceType[] = {
};
char *TvServiceName[] = { "Control", "Picture" };
/*
/*!
Global arrays for storing variable names and counts for
TvControl and TvPicture services
*/
@@ -59,12 +64,12 @@ char *TvVarName[TV_SERVICE_SERVCOUNT][TV_MAXVARS] = {
char TvVarCount[TV_SERVICE_SERVCOUNT] =
{ TV_CONTROL_VARCOUNT, TV_PICTURE_VARCOUNT };
/*
/*!
Timeout to request during subscriptions
*/
int default_timeout = 1801;
/*
/*!
The first node in the global device list, or NULL if empty
*/
struct TvDeviceNode *GlobalDeviceList = NULL;
@@ -937,7 +942,7 @@ TvStateUpdate( char *UDN,
*
********************************************************************************/
void TvCtrlPointHandleEvent(
const Upnp_SID sid,
const char *sid,
int evntkey,
IXML_Document *changes)
{
@@ -949,11 +954,11 @@ void TvCtrlPointHandleEvent(
tmpdevnode = GlobalDeviceList;
while (tmpdevnode) {
for (service = 0; service < TV_SERVICE_SERVCOUNT; ++service) {
if(strcmp(tmpdevnode->device.TvService[service].SID, sid) == 0) {
if (strcmp(tmpdevnode->device.TvService[service].SID, sid) == 0) {
SampleUtil_Print("Received Tv %s Event: %d for SID %s",
TvServiceName[service],
evntkey,
sid );
sid);
TvStateUpdate(
tmpdevnode->device.UDN,
service,
@@ -1330,8 +1335,9 @@ int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionP
SampleUtil_Print(
"UPnP Initialized\n"
"\tipaddress= %s port = %u\n",
ip_address, port);
"\tipaddress = %s port = %u\n",
ip_address ? ip_address : "{NULL}",
port);
SampleUtil_Print("Registering Control Point");
rc = UpnpRegisterClient(TvCtrlPointCallbackEventHandler,

View File

@@ -1,4 +1,4 @@
/*******************************************************************************
/**************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
@@ -27,29 +27,40 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
**************************************************************************/
#ifndef UPNP_TV_CTRLPT_H
#define UPNP_TV_CTRLPT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include "sample_util.h"
#include "ithread.h"
#ifndef WIN32
#include <unistd.h>
#endif
#include <stdarg.h>
#include <stdlib.h>
#include "upnp.h"
#include "UpnpString.h"
#include "upnptools.h"
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "upnp.h"
#include "upnptools.h"
#include "sample_util.h"
#ifdef WIN32
/* Do not #include <unistd.h> */
#else
#include <unistd.h>
#endif
#define TV_SERVICE_SERVCOUNT 2
#define TV_SERVICE_CONTROL 0
@@ -68,12 +79,12 @@ extern "C" {
#define TV_MAX_VAL_LEN 5
#define TV_SUCCESS 0
#define TV_ERROR (-1)
#define TV_WARNING 1
#define TV_SUCCESS 0
#define TV_ERROR (-1)
#define TV_WARNING 1
/* This should be the maximum VARCOUNT from above */
#define TV_MAXVARS TV_PICTURE_VARCOUNT
#define TV_MAXVARS TV_PICTURE_VARCOUNT
extern char TvDeviceType[];
extern char *TvServiceType[];
@@ -110,11 +121,11 @@ extern ithread_mutex_t DeviceListMutex;
extern UpnpClient_Handle ctrlpt_handle;
void TvCtrlPointPrintHelp( void );
void TvCtrlPointPrintHelp(void);
int TvCtrlPointDeleteNode(struct TvDeviceNode *);
int TvCtrlPointRemoveDevice(const char *);
int TvCtrlPointRemoveAll( void );
int TvCtrlPointRefresh( void );
int TvCtrlPointRemoveAll(void);
int TvCtrlPointRefresh(void);
int TvCtrlPointSendAction(int, int, char *, char **, char **, int);
@@ -138,20 +149,20 @@ int TvCtrlPointGetContrast(int);
int TvCtrlPointGetBrightness(int);
int TvCtrlPointGetDevice(int, struct TvDeviceNode **);
int TvCtrlPointPrintList( void );
int TvCtrlPointPrintList(void);
int TvCtrlPointPrintDevice(int);
void TvCtrlPointAddDevice(IXML_Document *, const char *, int);
void TvCtrlPointHandleGetVar(const char *, const char *, const DOMString);
void TvStateUpdate(char*,int, IXML_Document * , char **);
void TvCtrlPointHandleEvent(const Upnp_SID, int, IXML_Document *);
void TvCtrlPointHandleEvent(const char *, int, IXML_Document *);
void TvCtrlPointHandleSubscribeUpdate(const char *, const Upnp_SID, int);
int TvCtrlPointCallbackEventHandler(Upnp_EventType, void *, void *);
void TvCtrlPointVerifyTimeouts(int);
void TvCtrlPointPrintCommands( void );
void* TvCtrlPointCommandLoop( void* );
int TvCtrlPointStart( print_string printFunctionPtr, state_update updateFunctionPtr );
int TvCtrlPointStop( void );
int TvCtrlPointProcessCommand( char *cmdline );
void TvCtrlPointPrintCommands(void);
void* TvCtrlPointCommandLoop(void *);
int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionPtr);
int TvCtrlPointStop(void);
int TvCtrlPointProcessCommand(char *cmdline);
#ifdef __cplusplus
};

View File

@@ -371,23 +371,26 @@ TvDeviceStateTableInit( IN char *DescDocURL )
* sr_event -- The subscription request event structure
*
*****************************************************************************/
int
TvDeviceHandleSubscriptionRequest( IN struct Upnp_Subscription_Request
*sr_event )
int TvDeviceHandleSubscriptionRequest(IN struct Upnp_Subscription_Request *sr_event)
{
unsigned int i = 0; //,j=0;
// IXML_Document *PropSet = NULL;
unsigned int i = 0;
int cmp1 = 0;
int cmp2 = 0;
const char *l_serviceId = NULL;
const char *l_udn = NULL;
const char *l_sid = NULL;
// lock state mutex
ithread_mutex_lock( &TVDevMutex );
ithread_mutex_lock(&TVDevMutex);
for( i = 0; i < TV_SERVICE_SERVCOUNT; i++ ) {
if( ( strcmp( sr_event->UDN, tv_service_table[i].UDN ) == 0 ) &&
( strcmp( sr_event->ServiceId, tv_service_table[i].ServiceId )
== 0 ) ) {
/*
l_serviceId = sr_event->ServiceId;
l_udn = sr_event->UDN;
l_sid = sr_event->Sid;
for (i = 0; i < TV_SERVICE_SERVCOUNT; ++i) {
cmp1 = strcmp(l_udn, tv_service_table[i].UDN);
cmp2 = strcmp(l_serviceId, tv_service_table[i].ServiceId);
if (cmp1 == 0 && cmp2 == 0) {
#if 0
PropSet = NULL;
for (j = 0; j< tv_service_table[i].VariableCount; ++j) {
@@ -402,29 +405,27 @@ TvDeviceHandleSubscriptionRequest( IN struct Upnp_Subscription_Request
// dump initial state
UpnpAcceptSubscriptionExt(
device_handle,
sr_event->UDN,
sr_event->ServiceId,
l_udn,
l_serviceId,
PropSet,
sr_event->Sid);
l_sid);
// free document
Document_free(PropSet);
*/
UpnpAcceptSubscription( device_handle,
sr_event->UDN,
sr_event->ServiceId,
#endif
UpnpAcceptSubscription(
device_handle,
l_udn,
l_serviceId,
(const char **)tv_service_table[i].
VariableName,
(const char **)tv_service_table[i].
VariableStrVal,
tv_service_table[i].VariableCount,
sr_event->Sid);
l_sid);
}
}
ithread_mutex_unlock( &TVDevMutex );
ithread_mutex_unlock(&TVDevMutex);
return 1;
}
@@ -442,52 +443,52 @@ TvDeviceHandleSubscriptionRequest( IN struct Upnp_Subscription_Request
* cgv_event -- The control get variable request event structure
*
*****************************************************************************/
int
TvDeviceHandleGetVarRequest( INOUT struct Upnp_State_Var_Request
*cgv_event )
int TvDeviceHandleGetVarRequest(INOUT struct Upnp_State_Var_Request *cgv_event)
{
unsigned int i = 0;
unsigned int j = 0;
int getvar_succeeded = 0;
unsigned int i = 0;
unsigned int j = 0;
int getvar_succeeded = 0;
cgv_event->CurrentVal = NULL;
cgv_event->CurrentVal = NULL;
ithread_mutex_lock( &TVDevMutex );
ithread_mutex_lock(&TVDevMutex);
for( i = 0; i < TV_SERVICE_SERVCOUNT; i++ ) {
// check udn and service id
if( ( strcmp( cgv_event->DevUDN, tv_service_table[i].UDN ) == 0 )
&&
( strcmp( cgv_event->ServiceID, tv_service_table[i].ServiceId )
== 0 ) ) {
// check variable name
for( j = 0; j < tv_service_table[i].VariableCount; j++ ) {
if( strcmp( cgv_event->StateVarName,
tv_service_table[i].VariableName[j] ) == 0 ) {
getvar_succeeded = 1;
cgv_event->CurrentVal =
ixmlCloneDOMString( tv_service_table[i].
VariableStrVal[j] );
break;
}
}
}
}
for (i = 0; i < TV_SERVICE_SERVCOUNT; i++) {
// check udn and service id
const char *devUDN =
cgv_event->DevUDN;
const char *serviceID =
cgv_event->ServiceID;
if (strcmp(devUDN, tv_service_table[i].UDN) == 0 &&
strcmp(serviceID, tv_service_table[i].ServiceId) == 0) {
// check variable name
for (j = 0; j < tv_service_table[i].VariableCount; j++) {
const char *stateVarName =
cgv_event->StateVarName;
if (strcmp(stateVarName,
tv_service_table[i].VariableName[j]) == 0) {
getvar_succeeded = 1;
cgv_event->CurrentVal = ixmlCloneDOMString(
tv_service_table[i].VariableStrVal[j]);
break;
}
}
}
}
if (getvar_succeeded) {
cgv_event->ErrCode = UPNP_E_SUCCESS;
} else {
SampleUtil_Print(
"Error in UPNP_CONTROL_GET_VAR_REQUEST callback:\n"
" Unknown variable name = %s\n",
cgv_event->StateVarName);
cgv_event->ErrCode = 404;
strcpy(cgv_event->ErrStr, "Invalid Variable");
}
if( getvar_succeeded ) {
cgv_event->ErrCode = UPNP_E_SUCCESS;
} else {
SampleUtil_Print
( "Error in UPNP_CONTROL_GET_VAR_REQUEST callback:\n" );
SampleUtil_Print( " Unknown variable name = %s\n",
cgv_event->StateVarName );
cgv_event->ErrCode = 404;
strcpy( cgv_event->ErrStr, "Invalid Variable" );
}
ithread_mutex_unlock(&TVDevMutex);
ithread_mutex_unlock( &TVDevMutex );
return ( cgv_event->ErrCode == UPNP_E_SUCCESS );
return cgv_event->ErrCode == UPNP_E_SUCCESS;
}
/******************************************************************************
@@ -502,99 +503,79 @@ TvDeviceHandleGetVarRequest( INOUT struct Upnp_State_Var_Request
* ca_event -- The control action request event structure
*
*****************************************************************************/
int
TvDeviceHandleActionRequest( INOUT struct Upnp_Action_Request *ca_event )
int TvDeviceHandleActionRequest(INOUT struct Upnp_Action_Request *ca_event)
{
/*
Defaults if action not found
*/
int action_found = 0;
int i = 0;
int service = -1;
int retCode = 0;
char *errorString = NULL;
/* Defaults if action not found. */
int action_found = 0;
int i = 0;
int service = -1;
int retCode = 0;
char *errorString = NULL;
const char *devUDN = NULL;
const char *serviceID = NULL;
const char *actionName = NULL;
ca_event->ErrCode = 0;
ca_event->ActionResult = NULL;
ca_event->ErrCode = 0;
ca_event->ActionResult = NULL;
if( ( strcmp( ca_event->DevUDN,
tv_service_table[TV_SERVICE_CONTROL].UDN ) == 0 ) &&
( strcmp
( ca_event->ServiceID,
tv_service_table[TV_SERVICE_CONTROL].ServiceId ) == 0 ) ) {
/*
Request for action in the TvDevice Control Service
*/
service = TV_SERVICE_CONTROL;
} else if( ( strcmp( ca_event->DevUDN,
tv_service_table[TV_SERVICE_PICTURE].UDN ) == 0 )
&&
( strcmp
( ca_event->ServiceID,
tv_service_table[TV_SERVICE_PICTURE].ServiceId ) ==
0 ) ) {
/*
Request for action in the TvDevice Picture Service
*/
service = TV_SERVICE_PICTURE;
}
//Find and call appropriate procedure based on action name
//Each action name has an associated procedure stored in the
//service table. These are set at initialization.
devUDN = ca_event->DevUDN;
serviceID = ca_event->ServiceID;
actionName = ca_event->ActionName;
if (strcmp(devUDN, tv_service_table[TV_SERVICE_CONTROL].UDN) == 0 &&
strcmp(serviceID, tv_service_table[TV_SERVICE_CONTROL].ServiceId) == 0) {
/* Request for action in the TvDevice Control Service. */
service = TV_SERVICE_CONTROL;
} else if (strcmp(devUDN, tv_service_table[TV_SERVICE_PICTURE].UDN) == 0 &&
strcmp(serviceID, tv_service_table[TV_SERVICE_PICTURE].ServiceId) == 0) {
/* Request for action in the TvDevice Picture Service. */
service = TV_SERVICE_PICTURE;
}
/* Find and call appropriate procedure based on action name.
* Each action name has an associated procedure stored in the
* service table. These are set at initialization. */
for (i = 0;
i < TV_MAXACTIONS && tv_service_table[service].ActionNames[i] != NULL;
i++) {
if (!strcmp(actionName, tv_service_table[service].ActionNames[i])) {
if (!strcmp(tv_service_table[TV_SERVICE_CONTROL].
VariableStrVal[TV_CONTROL_POWER], "1") ||
!strcmp(actionName, "PowerOn")) {
retCode = tv_service_table[service].actions[i](
ca_event->ActionRequest,
&ca_event->ActionResult,
&errorString);
} else {
errorString = "Power is Off";
retCode = UPNP_E_INTERNAL_ERROR;
}
action_found = 1;
break;
}
}
for( i = 0; ( ( i < TV_MAXACTIONS ) &&
( tv_service_table[service].ActionNames[i] != NULL ) );
i++ ) {
if (!action_found) {
ca_event->ActionResult = NULL;
strcpy(ca_event->ErrStr, "Invalid Action");
ca_event->ErrCode = 401;
} else {
if (retCode == UPNP_E_SUCCESS) {
ca_event->ErrCode = UPNP_E_SUCCESS;
} else {
// copy the error string
strcpy(ca_event->ErrStr, errorString);
switch (retCode) {
case UPNP_E_INVALID_PARAM:
ca_event->ErrCode = 402;
break;
case UPNP_E_INTERNAL_ERROR:
default:
ca_event->ErrCode = 501;
break;
}
}
}
if( !strcmp( ca_event->ActionName,
tv_service_table[service].ActionNames[i] ) ) {
if( ( !strcmp( tv_service_table[TV_SERVICE_CONTROL].
VariableStrVal[TV_CONTROL_POWER], "1" ) )
|| ( !strcmp( ca_event->ActionName, "PowerOn" ) ) ) {
retCode =
tv_service_table[service].actions[i] ( ca_event->
ActionRequest,
&ca_event->
ActionResult,
&errorString );
} else {
errorString = "Power is Off";
retCode = UPNP_E_INTERNAL_ERROR;
}
action_found = 1;
break;
}
}
if( !action_found ) {
ca_event->ActionResult = NULL;
strcpy( ca_event->ErrStr, "Invalid Action" );
ca_event->ErrCode = 401;
} else {
if( retCode == UPNP_E_SUCCESS ) {
ca_event->ErrCode = UPNP_E_SUCCESS;
} else {
// copy the error string
strcpy( ca_event->ErrStr, errorString );
switch ( retCode ) {
case UPNP_E_INVALID_PARAM:
{
ca_event->ErrCode = 402;
break;
}
case UPNP_E_INTERNAL_ERROR:
default:
{
ca_event->ErrCode = 501;
break;
}
}
}
}
return ( ca_event->ErrCode );
return ca_event->ErrCode;
}
/******************************************************************************
@@ -1770,48 +1751,43 @@ TvDeviceDecreaseBrightness( IN IXML_Document *in, OUT IXML_Document **out, OUT c
*****************************************************************************/
int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Cookie)
{
switch ( EventType ) {
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
switch (EventType) {
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
TvDeviceHandleSubscriptionRequest((struct Upnp_Subscription_Request *)Event);
break;
TvDeviceHandleSubscriptionRequest( ( struct
Upnp_Subscription_Request
* )Event );
break;
case UPNP_CONTROL_GET_VAR_REQUEST:
TvDeviceHandleGetVarRequest((struct Upnp_State_Var_Request *)Event);
break;
case UPNP_CONTROL_GET_VAR_REQUEST:
TvDeviceHandleGetVarRequest( ( struct Upnp_State_Var_Request
* )Event );
break;
case UPNP_CONTROL_ACTION_REQUEST:
TvDeviceHandleActionRequest((struct Upnp_Action_Request *)Event);
break;
case UPNP_CONTROL_ACTION_REQUEST:
TvDeviceHandleActionRequest( ( struct Upnp_Action_Request * )
Event );
break;
/*
ignore these cases, since this is not a control point
*/
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
case UPNP_DISCOVERY_SEARCH_RESULT:
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
case UPNP_CONTROL_ACTION_COMPLETE:
case UPNP_CONTROL_GET_VAR_COMPLETE:
case UPNP_EVENT_RECEIVED:
case UPNP_EVENT_RENEWAL_COMPLETE:
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
break;
/*
ignore these cases, since this is not a control point
*/
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
case UPNP_DISCOVERY_SEARCH_RESULT:
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
case UPNP_CONTROL_ACTION_COMPLETE:
case UPNP_CONTROL_GET_VAR_COMPLETE:
case UPNP_EVENT_RECEIVED:
case UPNP_EVENT_RENEWAL_COMPLETE:
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
break;
default:
SampleUtil_Print("Error in TvDeviceCallbackEventHandler: unknown event type %d\n",
EventType);
}
default:
SampleUtil_Print( "Error in TvDeviceCallbackEventHandler: unknown event type %d\n",
EventType );
}
/* Print a summary of the event received */
SampleUtil_PrintEvent(EventType, Event);
/* Print a summary of the event received */
SampleUtil_PrintEvent( EventType, Event );
return 0;
return 0;
}
/******************************************************************************
@@ -1823,8 +1799,7 @@ int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Co
* Parameters:
*
*****************************************************************************/
int
TvDeviceStop()
int TvDeviceStop(void)
{
UpnpUnRegisterRootDevice( device_handle );
UpnpFinish();

View File

@@ -1,53 +1,66 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2003 Intel Corporation
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither name of Intel Corporation nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
/**************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************/
#ifndef UPNP_TV_DEVICE_H
#define UPNP_TV_DEVICE_H
#include <stdio.h>
#include <signal.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "ithread.h"
#include <stdlib.h>
#ifndef WIN32
#include <unistd.h>
#endif
#include <string.h>
#include "upnp.h"
#include "sample_util.h"
#include "ithread.h"
#include "upnp.h"
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
/* Do not #include <unistd.h> */
#else
#include <unistd.h>
#endif
//Color constants
#define MAX_COLOR 10
#define MIN_COLOR 1
@@ -148,8 +161,7 @@ extern char *TvServiceType[];
*
*****************************************************************************/
typedef int (*upnp_action) (IXML_Document *request, IXML_Document **out,
char **errorString);
typedef int (*upnp_action) (IXML_Document *request, IXML_Document **out, char **errorString);
/* Structure for storing Tv Service
identifiers and state table */
@@ -193,7 +205,7 @@ extern ithread_mutex_t TVDevMutex;
* struct TvService *out - service containing action table to set.
*
*****************************************************************************/
int SetActionTable(int serviceType, struct TvService * out);
int SetActionTable(int serviceType, struct TvService *out);
/******************************************************************************
* TvDeviceStateTableInit
@@ -313,8 +325,7 @@ int TvDeviceSetServiceTableVar(unsigned int, unsigned int, char*);
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out,
OUT char **errorString);
int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDevicePowerOff
@@ -329,8 +340,7 @@ int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceSetChannel
@@ -347,8 +357,7 @@ int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceIncreaseChannel
@@ -363,8 +372,7 @@ int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceDecreaseChannel
*
@@ -378,8 +386,7 @@ int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceSetVolume
*
@@ -395,8 +402,7 @@ int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceIncreaseVolume
@@ -411,8 +417,7 @@ int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out,
* IXML_Document **out - action result document
* char **errorString - errorString (in case action was unsuccessful)
*****************************************************************************/
int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
OUT char **errorString);
int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
@@ -428,8 +433,7 @@ int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
OUT char **errorString);
int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
//Picture Service Actions
@@ -449,8 +453,7 @@ int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
@@ -465,8 +468,7 @@ int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out,
* IXML_Document **out - action result document
* char **errorString - errorString (in case action was unsuccessful)
*****************************************************************************/
int TvDeviceIncreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceIncreaseColor(IN IXML_Document * in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceDecreaseColor
@@ -480,8 +482,7 @@ int TvDeviceIncreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
* IXML_Document **out - action result document
* char **errorString - errorString (in case action was unsuccessful)
*****************************************************************************/
int TvDeviceDecreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceDecreaseColor(IN IXML_Document * in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceSetTint
@@ -498,8 +499,7 @@ int TvDeviceDecreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceIncreaseTint
@@ -514,8 +514,7 @@ int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceDecreaseTint
@@ -530,8 +529,7 @@ int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/*****************************************************************************
* TvDeviceSetContrast
@@ -548,8 +546,7 @@ int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
****************************************************************************/
int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceIncreaseContrast
@@ -565,8 +562,7 @@ int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceDecreaseContrast
*
@@ -580,8 +576,7 @@ int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceSetBrightness
@@ -595,8 +590,7 @@ int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
* brightness -- The brightness value to change to.
*
*****************************************************************************/
int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceIncreaseBrightness
@@ -611,8 +605,7 @@ int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceDecreaseBrightness
@@ -626,12 +619,11 @@ int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceDecreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceDecreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
int TvDeviceStart(char * ip_address, unsigned short port,char * desc_doc_name,
char *web_dir_path, print_string pfun);
int TvDeviceStop();
int TvDeviceStop(void);
#ifdef __cplusplus
}

View File

@@ -143,8 +143,7 @@ TvCtrlPointDeleteNode( struct TvDeviceNode *node )
* UDN -- The Unique Device Name for the device to remove
*
********************************************************************************/
int
TvCtrlPointRemoveDevice(const char *UDN)
int TvCtrlPointRemoveDevice(const char *UDN)
{
struct TvDeviceNode *curdevnode;
struct TvDeviceNode *prevdevnode;
@@ -943,7 +942,7 @@ TvStateUpdate( char *UDN,
*
********************************************************************************/
void TvCtrlPointHandleEvent(
const Upnp_SID sid,
const char *sid,
int evntkey,
IXML_Document *changes)
{
@@ -955,7 +954,7 @@ void TvCtrlPointHandleEvent(
tmpdevnode = GlobalDeviceList;
while (tmpdevnode) {
for (service = 0; service < TV_SERVICE_SERVCOUNT; ++service) {
if (strcmp(tmpdevnode->device.TvService[service].SID, sid) == 0) {
if (strcmp(tmpdevnode->device.TvService[service].SID, sid) == 0) {
SampleUtil_Print("Received Tv %s Event: %d for SID %s",
TvServiceName[service],
evntkey,
@@ -1019,10 +1018,10 @@ void TvCtrlPointHandleSubscribeUpdate(
ithread_mutex_unlock( &DeviceListMutex );
}
void
TvCtrlPointHandleGetVar( const char *controlURL,
const char *varName,
const DOMString varValue )
void TvCtrlPointHandleGetVar(
const char *controlURL,
const char *varName,
const DOMString varValue)
{
struct TvDeviceNode *tmpdevnode;
@@ -1033,9 +1032,9 @@ TvCtrlPointHandleGetVar( const char *controlURL,
tmpdevnode = GlobalDeviceList;
while (tmpdevnode) {
for (service = 0; service < TV_SERVICE_SERVCOUNT; service++) {
if (strcmp(tmpdevnode->device.TvService[service].ControlURL, controlURL ) == 0 ) {
if (strcmp(tmpdevnode->device.TvService[service].ControlURL, controlURL) == 0) {
SampleUtil_StateUpdate(
varName, varValue, tmpdevnode->device.UDN, GET_VAR_COMPLETE );
varName, varValue, tmpdevnode->device.UDN, GET_VAR_COMPLETE);
break;
}
}
@@ -1076,29 +1075,24 @@ int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void
SampleUtil_Print(
"Error in Discovery Callback -- %d", d_event->ErrCode);
}
ret = UpnpDownloadXmlDoc(d_event->Location, &DescDoc);
if (ret != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error obtaining device description from %s -- error = %d",
d_event->Location, ret );
d_event->Location, ret);
} else {
TvCtrlPointAddDevice(
DescDoc, d_event->Location, d_event->Expires);
}
if( DescDoc ) {
if (DescDoc) {
ixmlDocument_free(DescDoc);
}
TvCtrlPointPrintList();
break;
}
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
/* Nothing to do here... */
break;
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE: {
struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event;
@@ -1106,13 +1100,10 @@ int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void
SampleUtil_Print(
"Error in Discovery ByeBye Callback -- %d", d_event->ErrCode);
}
SampleUtil_Print("Received ByeBye for Device: %s", d_event->DeviceId);
TvCtrlPointRemoveDevice(d_event->DeviceId);
SampleUtil_Print("After byebye:");
TvCtrlPointPrintList();
break;
}
/* SOAP Stuff */
@@ -1121,13 +1112,10 @@ int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void
if (a_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Action Complete Callback -- %d",
a_event->ErrCode);
"Error in Action Complete Callback -- %d", a_event->ErrCode);
}
/* No need for any processing here, just print out results.
* Service state table updates are handled by events. */
break;
}
case UPNP_CONTROL_GET_VAR_COMPLETE: {
@@ -1135,8 +1123,7 @@ int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void
if (sv_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Get Var Complete Callback -- %d",
sv_event->ErrCode);
"Error in Get Var Complete Callback -- %d", sv_event->ErrCode);
} else {
TvCtrlPointHandleGetVar(
sv_event->CtrlUrl,
@@ -1162,15 +1149,13 @@ int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void
if (es_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Event Subscribe Callback -- %d",
es_event->ErrCode);
"Error in Event Subscribe Callback -- %d", es_event->ErrCode);
} else {
TvCtrlPointHandleSubscribeUpdate(
es_event->PublisherUrl,
es_event->Sid,
es_event->TimeOut);
}
break;
}
case UPNP_EVENT_AUTORENEWAL_FAILED:
@@ -1185,7 +1170,6 @@ int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void
es_event->PublisherUrl,
&TimeOut,
newSID);
if (ret == UPNP_E_SUCCESS) {
SampleUtil_Print("Subscribed to EventURL with SID=%s", newSID);
TvCtrlPointHandleSubscribeUpdate(

View File

@@ -44,6 +44,7 @@ extern "C" {
#include "ithread.h"
#include "upnp.h"
#include "UpnpString.h"
#include "upnptools.h"
@@ -120,8 +121,8 @@ extern ithread_mutex_t DeviceListMutex;
extern UpnpClient_Handle ctrlpt_handle;
void TvCtrlPointPrintHelp(void);
int TvCtrlPointDeleteNode(struct TvDeviceNode*);
void TvCtrlPointPrintHelp(void);
int TvCtrlPointDeleteNode(struct TvDeviceNode *);
int TvCtrlPointRemoveDevice(const char *);
int TvCtrlPointRemoveAll(void);
int TvCtrlPointRefresh(void);
@@ -148,20 +149,20 @@ int TvCtrlPointGetContrast(int);
int TvCtrlPointGetBrightness(int);
int TvCtrlPointGetDevice(int, struct TvDeviceNode **);
int TvCtrlPointPrintList( void );
int TvCtrlPointPrintList(void);
int TvCtrlPointPrintDevice(int);
void TvCtrlPointAddDevice(IXML_Document *, const char *, int);
void TvCtrlPointHandleGetVar(const char *, const char *, const DOMString);
void TvStateUpdate(char*,int, IXML_Document * , char **);
void TvCtrlPointHandleEvent(const Upnp_SID, int, IXML_Document *);
void TvCtrlPointHandleEvent(const char *, int, IXML_Document *);
void TvCtrlPointHandleSubscribeUpdate(const char *, const Upnp_SID, int);
int TvCtrlPointCallbackEventHandler(Upnp_EventType, void *, void *);
void TvCtrlPointVerifyTimeouts(int);
void TvCtrlPointPrintCommands( void );
void* TvCtrlPointCommandLoop( void* );
int TvCtrlPointStart( print_string printFunctionPtr, state_update updateFunctionPtr );
int TvCtrlPointStop( void );
int TvCtrlPointProcessCommand( char *cmdline );
void TvCtrlPointPrintCommands(void);
void* TvCtrlPointCommandLoop(void *);
int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionPtr);
int TvCtrlPointStop(void);
int TvCtrlPointProcessCommand(char *cmdline);
#ifdef __cplusplus
};

View File

@@ -373,23 +373,26 @@ TvDeviceStateTableInit( IN char *DescDocURL )
* sr_event -- The subscription request event structure
*
*****************************************************************************/
int
TvDeviceHandleSubscriptionRequest( IN struct Upnp_Subscription_Request
*sr_event )
int TvDeviceHandleSubscriptionRequest(IN struct Upnp_Subscription_Request *sr_event)
{
unsigned int i = 0; //,j=0;
// IXML_Document *PropSet = NULL;
unsigned int i = 0;
int cmp1 = 0;
int cmp2 = 0;
const char *l_serviceId = NULL;
const char *l_udn = NULL;
const char *l_sid = NULL;
// lock state mutex
ithread_mutex_lock( &TVDevMutex );
ithread_mutex_lock(&TVDevMutex);
for( i = 0; i < TV_SERVICE_SERVCOUNT; i++ ) {
if( ( strcmp( sr_event->UDN, tv_service_table[i].UDN ) == 0 ) &&
( strcmp( sr_event->ServiceId, tv_service_table[i].ServiceId )
== 0 ) ) {
/*
l_serviceId = sr_event->ServiceId;
l_udn = sr_event->UDN;
l_sid = sr_event->Sid;
for (i = 0; i < TV_SERVICE_SERVCOUNT; ++i) {
cmp1 = strcmp(l_udn, tv_service_table[i].UDN);
cmp2 = strcmp(l_serviceId, tv_service_table[i].ServiceId);
if (cmp1 == 0 && cmp2 == 0) {
#if 0
PropSet = NULL;
for (j = 0; j< tv_service_table[i].VariableCount; ++j) {
@@ -404,29 +407,27 @@ TvDeviceHandleSubscriptionRequest( IN struct Upnp_Subscription_Request
// dump initial state
UpnpAcceptSubscriptionExt(
device_handle,
sr_event->UDN,
sr_event->ServiceId,
l_udn,
l_serviceId,
PropSet,
sr_event->Sid);
l_sid);
// free document
Document_free(PropSet);
*/
UpnpAcceptSubscription( device_handle,
sr_event->UDN,
sr_event->ServiceId,
#endif
UpnpAcceptSubscription(
device_handle,
l_udn,
l_serviceId,
(const char **)tv_service_table[i].
VariableName,
(const char **)tv_service_table[i].
VariableStrVal,
tv_service_table[i].VariableCount,
sr_event->Sid);
l_sid);
}
}
ithread_mutex_unlock( &TVDevMutex );
ithread_mutex_unlock(&TVDevMutex);
return 1;
}
@@ -444,52 +445,52 @@ TvDeviceHandleSubscriptionRequest( IN struct Upnp_Subscription_Request
* cgv_event -- The control get variable request event structure
*
*****************************************************************************/
int
TvDeviceHandleGetVarRequest( INOUT struct Upnp_State_Var_Request
*cgv_event )
int TvDeviceHandleGetVarRequest(INOUT struct Upnp_State_Var_Request *cgv_event)
{
unsigned int i = 0;
unsigned int j = 0;
int getvar_succeeded = 0;
unsigned int i = 0;
unsigned int j = 0;
int getvar_succeeded = 0;
cgv_event->CurrentVal = NULL;
cgv_event->CurrentVal = NULL;
ithread_mutex_lock( &TVDevMutex );
ithread_mutex_lock(&TVDevMutex);
for( i = 0; i < TV_SERVICE_SERVCOUNT; i++ ) {
// check udn and service id
if( ( strcmp( cgv_event->DevUDN, tv_service_table[i].UDN ) == 0 )
&&
( strcmp( cgv_event->ServiceID, tv_service_table[i].ServiceId )
== 0 ) ) {
// check variable name
for( j = 0; j < tv_service_table[i].VariableCount; j++ ) {
if( strcmp( cgv_event->StateVarName,
tv_service_table[i].VariableName[j] ) == 0 ) {
getvar_succeeded = 1;
cgv_event->CurrentVal =
ixmlCloneDOMString( tv_service_table[i].
VariableStrVal[j] );
break;
}
}
}
}
for (i = 0; i < TV_SERVICE_SERVCOUNT; i++) {
// check udn and service id
const char *devUDN =
cgv_event->DevUDN;
const char *serviceID =
cgv_event->ServiceID;
if (strcmp(devUDN, tv_service_table[i].UDN) == 0 &&
strcmp(serviceID, tv_service_table[i].ServiceId) == 0) {
// check variable name
for (j = 0; j < tv_service_table[i].VariableCount; j++) {
const char *stateVarName =
cgv_event->StateVarName;
if (strcmp(stateVarName,
tv_service_table[i].VariableName[j]) == 0) {
getvar_succeeded = 1;
cgv_event->CurrentVal = ixmlCloneDOMString(
tv_service_table[i].VariableStrVal[j]);
break;
}
}
}
}
if (getvar_succeeded) {
cgv_event->ErrCode = UPNP_E_SUCCESS;
} else {
SampleUtil_Print(
"Error in UPNP_CONTROL_GET_VAR_REQUEST callback:\n"
" Unknown variable name = %s\n",
cgv_event->StateVarName);
cgv_event->ErrCode = 404;
strcpy(cgv_event->ErrStr, "Invalid Variable");
}
if( getvar_succeeded ) {
cgv_event->ErrCode = UPNP_E_SUCCESS;
} else {
SampleUtil_Print
( "Error in UPNP_CONTROL_GET_VAR_REQUEST callback:\n" );
SampleUtil_Print( " Unknown variable name = %s\n",
cgv_event->StateVarName );
cgv_event->ErrCode = 404;
strcpy( cgv_event->ErrStr, "Invalid Variable" );
}
ithread_mutex_unlock(&TVDevMutex);
ithread_mutex_unlock( &TVDevMutex );
return ( cgv_event->ErrCode == UPNP_E_SUCCESS );
return cgv_event->ErrCode == UPNP_E_SUCCESS;
}
/******************************************************************************
@@ -504,99 +505,79 @@ TvDeviceHandleGetVarRequest( INOUT struct Upnp_State_Var_Request
* ca_event -- The control action request event structure
*
*****************************************************************************/
int
TvDeviceHandleActionRequest( INOUT struct Upnp_Action_Request *ca_event )
int TvDeviceHandleActionRequest(INOUT struct Upnp_Action_Request *ca_event)
{
/*
Defaults if action not found
*/
int action_found = 0;
int i = 0;
int service = -1;
int retCode = 0;
char *errorString = NULL;
/* Defaults if action not found. */
int action_found = 0;
int i = 0;
int service = -1;
int retCode = 0;
char *errorString = NULL;
const char *devUDN = NULL;
const char *serviceID = NULL;
const char *actionName = NULL;
ca_event->ErrCode = 0;
ca_event->ActionResult = NULL;
ca_event->ErrCode = 0;
ca_event->ActionResult = NULL;
if( ( strcmp( ca_event->DevUDN,
tv_service_table[TV_SERVICE_CONTROL].UDN ) == 0 ) &&
( strcmp
( ca_event->ServiceID,
tv_service_table[TV_SERVICE_CONTROL].ServiceId ) == 0 ) ) {
/*
Request for action in the TvDevice Control Service
*/
service = TV_SERVICE_CONTROL;
} else if( ( strcmp( ca_event->DevUDN,
tv_service_table[TV_SERVICE_PICTURE].UDN ) == 0 )
&&
( strcmp
( ca_event->ServiceID,
tv_service_table[TV_SERVICE_PICTURE].ServiceId ) ==
0 ) ) {
/*
Request for action in the TvDevice Picture Service
*/
service = TV_SERVICE_PICTURE;
}
//Find and call appropriate procedure based on action name
//Each action name has an associated procedure stored in the
//service table. These are set at initialization.
devUDN = ca_event->DevUDN;
serviceID = ca_event->ServiceID;
actionName = ca_event->ActionName;
if (strcmp(devUDN, tv_service_table[TV_SERVICE_CONTROL].UDN) == 0 &&
strcmp(serviceID, tv_service_table[TV_SERVICE_CONTROL].ServiceId) == 0) {
/* Request for action in the TvDevice Control Service. */
service = TV_SERVICE_CONTROL;
} else if (strcmp(devUDN, tv_service_table[TV_SERVICE_PICTURE].UDN) == 0 &&
strcmp(serviceID, tv_service_table[TV_SERVICE_PICTURE].ServiceId) == 0) {
/* Request for action in the TvDevice Picture Service. */
service = TV_SERVICE_PICTURE;
}
/* Find and call appropriate procedure based on action name.
* Each action name has an associated procedure stored in the
* service table. These are set at initialization. */
for (i = 0;
i < TV_MAXACTIONS && tv_service_table[service].ActionNames[i] != NULL;
i++) {
if (!strcmp(actionName, tv_service_table[service].ActionNames[i])) {
if (!strcmp(tv_service_table[TV_SERVICE_CONTROL].
VariableStrVal[TV_CONTROL_POWER], "1") ||
!strcmp(actionName, "PowerOn")) {
retCode = tv_service_table[service].actions[i](
ca_event->ActionRequest,
&ca_event->ActionResult,
&errorString);
} else {
errorString = "Power is Off";
retCode = UPNP_E_INTERNAL_ERROR;
}
action_found = 1;
break;
}
}
for( i = 0; ( ( i < TV_MAXACTIONS ) &&
( tv_service_table[service].ActionNames[i] != NULL ) );
i++ ) {
if (!action_found) {
ca_event->ActionResult = NULL;
strcpy(ca_event->ErrStr, "Invalid Action");
ca_event->ErrCode = 401;
} else {
if (retCode == UPNP_E_SUCCESS) {
ca_event->ErrCode = UPNP_E_SUCCESS;
} else {
// copy the error string
strcpy(ca_event->ErrStr, errorString);
switch (retCode) {
case UPNP_E_INVALID_PARAM:
ca_event->ErrCode = 402;
break;
case UPNP_E_INTERNAL_ERROR:
default:
ca_event->ErrCode = 501;
break;
}
}
}
if( !strcmp( ca_event->ActionName,
tv_service_table[service].ActionNames[i] ) ) {
if( ( !strcmp( tv_service_table[TV_SERVICE_CONTROL].
VariableStrVal[TV_CONTROL_POWER], "1" ) )
|| ( !strcmp( ca_event->ActionName, "PowerOn" ) ) ) {
retCode =
tv_service_table[service].actions[i] ( ca_event->
ActionRequest,
&ca_event->
ActionResult,
&errorString );
} else {
errorString = "Power is Off";
retCode = UPNP_E_INTERNAL_ERROR;
}
action_found = 1;
break;
}
}
if( !action_found ) {
ca_event->ActionResult = NULL;
strcpy( ca_event->ErrStr, "Invalid Action" );
ca_event->ErrCode = 401;
} else {
if( retCode == UPNP_E_SUCCESS ) {
ca_event->ErrCode = UPNP_E_SUCCESS;
} else {
// copy the error string
strcpy( ca_event->ErrStr, errorString );
switch ( retCode ) {
case UPNP_E_INVALID_PARAM:
{
ca_event->ErrCode = 402;
break;
}
case UPNP_E_INTERNAL_ERROR:
default:
{
ca_event->ErrCode = 501;
break;
}
}
}
}
return ( ca_event->ErrCode );
return ca_event->ErrCode;
}
/******************************************************************************
@@ -1772,48 +1753,43 @@ TvDeviceDecreaseBrightness( IN IXML_Document *in, OUT IXML_Document **out, OUT c
*****************************************************************************/
int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Cookie)
{
switch ( EventType ) {
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
switch (EventType) {
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
TvDeviceHandleSubscriptionRequest((struct Upnp_Subscription_Request *)Event);
break;
TvDeviceHandleSubscriptionRequest( ( struct
Upnp_Subscription_Request
* )Event );
break;
case UPNP_CONTROL_GET_VAR_REQUEST:
TvDeviceHandleGetVarRequest((struct Upnp_State_Var_Request *)Event);
break;
case UPNP_CONTROL_GET_VAR_REQUEST:
TvDeviceHandleGetVarRequest( ( struct Upnp_State_Var_Request
* )Event );
break;
case UPNP_CONTROL_ACTION_REQUEST:
TvDeviceHandleActionRequest((struct Upnp_Action_Request *)Event);
break;
case UPNP_CONTROL_ACTION_REQUEST:
TvDeviceHandleActionRequest( ( struct Upnp_Action_Request * )
Event );
break;
/*
ignore these cases, since this is not a control point
*/
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
case UPNP_DISCOVERY_SEARCH_RESULT:
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
case UPNP_CONTROL_ACTION_COMPLETE:
case UPNP_CONTROL_GET_VAR_COMPLETE:
case UPNP_EVENT_RECEIVED:
case UPNP_EVENT_RENEWAL_COMPLETE:
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
break;
/*
ignore these cases, since this is not a control point
*/
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
case UPNP_DISCOVERY_SEARCH_RESULT:
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
case UPNP_CONTROL_ACTION_COMPLETE:
case UPNP_CONTROL_GET_VAR_COMPLETE:
case UPNP_EVENT_RECEIVED:
case UPNP_EVENT_RENEWAL_COMPLETE:
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
break;
default:
SampleUtil_Print("Error in TvDeviceCallbackEventHandler: unknown event type %d\n",
EventType);
}
default:
SampleUtil_Print( "Error in TvDeviceCallbackEventHandler: unknown event type %d\n",
EventType );
}
/* Print a summary of the event received */
SampleUtil_PrintEvent(EventType, Event);
/* Print a summary of the event received */
SampleUtil_PrintEvent( EventType, Event );
return 0;
return 0;
}
/******************************************************************************
@@ -1825,8 +1801,7 @@ int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Co
* Parameters:
*
*****************************************************************************/
int
TvDeviceStop(void)
int TvDeviceStop(void)
{
UpnpUnRegisterRootDevice( device_handle );
UpnpFinish();
@@ -1874,7 +1849,8 @@ TvDeviceStart( char *ip_address,
SampleUtil_Print(
"Initializing UPnP Sdk with\n"
"\tipaddress = %s port = %u\n",
ip_address, port );
ip_address ? ip_address : "{NULL}",
port);
ret = UpnpInit( ip_address, port );
if( ret != UPNP_E_SUCCESS ) {
@@ -1888,8 +1864,9 @@ TvDeviceStart( char *ip_address,
SampleUtil_Print(
"UPnP Initialized\n"
"\tipaddress= %s port = %u\n",
ip_address, port );
"\tipaddress = %s port = %u\n",
ip_address ? ip_address : "{NULL}",
port);
if( desc_doc_name == NULL ) {
desc_doc_name = "tvdevicedesc.xml";

View File

@@ -1,4 +1,4 @@
/*******************************************************************************
/**************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
@@ -27,28 +27,40 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
**************************************************************************/
#ifndef UPNP_TV_DEVICE_H
#define UPNP_TV_DEVICE_H
#include <stdio.h>
#include <signal.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "ithread.h"
#include <stdlib.h>
#ifndef WIN32
#include <unistd.h>
#endif
#include <string.h>
#include "upnp.h"
#include "sample_util.h"
#include "ithread.h"
#include "upnp.h"
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
/* Do not #include <unistd.h> */
#else
#include <unistd.h>
#endif
//Color constants
#define MAX_COLOR 10
#define MIN_COLOR 1
@@ -149,8 +161,7 @@ extern char *TvServiceType[];
*
*****************************************************************************/
typedef int (*upnp_action) (IXML_Document *request, IXML_Document **out,
char **errorString);
typedef int (*upnp_action) (IXML_Document *request, IXML_Document **out, char **errorString);
/* Structure for storing Tv Service
identifiers and state table */
@@ -194,7 +205,7 @@ extern ithread_mutex_t TVDevMutex;
* struct TvService *out - service containing action table to set.
*
*****************************************************************************/
int SetActionTable(int serviceType, struct TvService * out);
int SetActionTable(int serviceType, struct TvService *out);
/******************************************************************************
* TvDeviceStateTableInit
@@ -314,8 +325,7 @@ int TvDeviceSetServiceTableVar(unsigned int, unsigned int, char*);
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out,
OUT char **errorString);
int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDevicePowerOff
@@ -330,8 +340,7 @@ int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceSetChannel
@@ -348,8 +357,7 @@ int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceIncreaseChannel
@@ -364,8 +372,7 @@ int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceDecreaseChannel
*
@@ -379,8 +386,7 @@ int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceSetVolume
*
@@ -396,8 +402,7 @@ int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceIncreaseVolume
@@ -412,8 +417,7 @@ int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out,
* IXML_Document **out - action result document
* char **errorString - errorString (in case action was unsuccessful)
*****************************************************************************/
int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
OUT char **errorString);
int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
@@ -429,8 +433,7 @@ int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
OUT char **errorString);
int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
//Picture Service Actions
@@ -450,8 +453,7 @@ int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
@@ -466,8 +468,7 @@ int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out,
* IXML_Document **out - action result document
* char **errorString - errorString (in case action was unsuccessful)
*****************************************************************************/
int TvDeviceIncreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceIncreaseColor(IN IXML_Document * in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceDecreaseColor
@@ -481,8 +482,7 @@ int TvDeviceIncreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
* IXML_Document **out - action result document
* char **errorString - errorString (in case action was unsuccessful)
*****************************************************************************/
int TvDeviceDecreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceDecreaseColor(IN IXML_Document * in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceSetTint
@@ -499,8 +499,7 @@ int TvDeviceDecreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceIncreaseTint
@@ -515,8 +514,7 @@ int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceDecreaseTint
@@ -531,8 +529,7 @@ int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/*****************************************************************************
* TvDeviceSetContrast
@@ -549,8 +546,7 @@ int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
****************************************************************************/
int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceIncreaseContrast
@@ -566,8 +562,7 @@ int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceDecreaseContrast
*
@@ -581,8 +576,7 @@ int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceSetBrightness
@@ -596,8 +590,7 @@ int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
* brightness -- The brightness value to change to.
*
*****************************************************************************/
int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceIncreaseBrightness
@@ -612,8 +605,7 @@ int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceDecreaseBrightness
@@ -627,8 +619,7 @@ int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceDecreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceDecreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
int TvDeviceStart(char * ip_address, unsigned short port,char * desc_doc_name,
char *web_dir_path, print_string pfun);

View File

@@ -122,6 +122,7 @@ ithread_mutex_t GlobalClientSubscribeMutex;
/*! rwlock to synchronize handles (root device or control point handle). */
ithread_rwlock_t GlobalHndRWLock;
/*! Mutex to synchronize the uuid creation process. */
ithread_mutex_t gUUIDMutex;

View File

@@ -149,7 +149,7 @@ void UpnpPrintf(
ithread_mutex_lock(&GlobalDebugMutex);
va_start(ArgList, FmtStr);
if (!DEBUG_TARGET) {
if( DbgFileName ) {
if (DbgFileName) {
UpnpDisplayFileAndLine(stdout, DbgFileName, DbgLineNo);
}
vfprintf(stdout, FmtStr, ArgList);
@@ -324,32 +324,5 @@ void PrintThreadPoolStats(
}
void printNodes(IXML_Node *tmpRoot, int depth)
{
int i;
IXML_NodeList *NodeList1;
IXML_Node *ChildNode1;
unsigned short NodeType;
const DOMString NodeValue;
const DOMString NodeName;
NodeList1 = ixmlNode_getChildNodes(tmpRoot);
for (i = 0; i < 100; ++i) {
ChildNode1 = ixmlNodeList_item(NodeList1, i);
if (ChildNode1 == NULL) {
break;
}
printNodes(ChildNode1, depth+1);
NodeType = ixmlNode_getNodeType(ChildNode1);
NodeValue = ixmlNode_getNodeValue(ChildNode1);
NodeName = ixmlNode_getNodeName(ChildNode1);
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"DEPTH-%2d-IXML_Node Type %d, "
"IXML_Node Name: %s, IXML_Node Value: %s\n",
depth, NodeType, NodeName, NodeValue);
}
}
#endif /* DEBUG */

File diff suppressed because it is too large Load Diff

View File

@@ -68,6 +68,7 @@
#ifdef WIN32
#include <malloc.h>
#define fseeko fseek
#else
#include <arpa/inet.h>
#include <fcntl.h>

View File

@@ -36,7 +36,7 @@
#include "config.h"
#include <assert.h>
#include "util.h"
#include "upnputil.h"
#include "membuffer.h"
#include "httpparser.h"
#include "statcodes.h"

View File

@@ -37,7 +37,7 @@
#include "config.h"
#include <stdio.h>
#include <string.h>
#include "util.h"
#include "upnputil.h"
#include "statcodes.h"
#ifdef WIN32

File diff suppressed because it is too large Load Diff

View File

@@ -29,304 +29,186 @@
*
**************************************************************************/
/************************************************************************
* Purpose: This file implements the sockets functionality
************************************************************************/
/*!
* \file
*
* \brief Implements the sockets functionality.
*/
#include "config.h"
#include "sock.h"
#include "unixutil.h" /* for socklen_t, EAFNOSUPPORT */
#include "unixutil.h" /* for socklen_t, EAFNOSUPPORT */
#include "upnp.h"
#include <assert.h>
#include <errno.h>
#include <time.h>
#include <string.h>
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
#define MSG_NOSIGNAL 0
#endif
/************************************************************************
* Function : sock_init
*
* Parameters :
* OUT SOCKINFO* info ; Socket Information Object
* IN SOCKET sockfd ; Socket Descriptor
*
* Description : Assign the passed in socket descriptor to socket
* descriptor in the SOCKINFO structure.
*
* Return : int;
* UPNP_E_SUCCESS
* UPNP_E_OUTOF_MEMORY
* UPNP_E_SOCKET_ERROR
*
* Note :
************************************************************************/
int
sock_init( OUT SOCKINFO * info,
IN SOCKET sockfd )
int sock_init(OUT SOCKINFO *info, IN SOCKET sockfd)
{
assert( info );
assert(info);
memset( info, 0, sizeof( SOCKINFO ) );
memset(info, 0, sizeof(SOCKINFO));
info->socket = sockfd;
info->socket = sockfd;
return UPNP_E_SUCCESS;
return UPNP_E_SUCCESS;
}
/************************************************************************
* Function : sock_init_with_ip
*
* Parameters :
* OUT SOCKINFO* info ; Socket Information Object
* IN SOCKET sockfd ; Socket Descriptor
* IN struct sockaddr* foreign_sockaddr; remote socket address.
*
* Description : Calls the sock_init function and assigns the passed in
* IP address and port to the IP address and port in the SOCKINFO
* structure.
*
* Return : int;
* UPNP_E_SUCCESS
* UPNP_E_OUTOF_MEMORY
* UPNP_E_SOCKET_ERROR
*
* Note :
************************************************************************/
int
sock_init_with_ip( OUT SOCKINFO * info,
IN SOCKET sockfd,
IN struct sockaddr* foreign_sockaddr )
int sock_init_with_ip(OUT SOCKINFO *info, IN SOCKET sockfd,
IN struct sockaddr *foreign_sockaddr)
{
int ret;
int ret;
ret = sock_init( info, sockfd );
if( ret != UPNP_E_SUCCESS ) {
return ret;
}
ret = sock_init(info, sockfd);
if (ret != UPNP_E_SUCCESS) {
return ret;
}
memcpy( &info->foreign_sockaddr, foreign_sockaddr,
sizeof( info->foreign_sockaddr) );
memcpy(&info->foreign_sockaddr, foreign_sockaddr,
sizeof(info->foreign_sockaddr));
return UPNP_E_SUCCESS;
return UPNP_E_SUCCESS;
}
/************************************************************************
* Function : sock_destroy
*
* Parameters :
* INOUT SOCKINFO* info ; Socket Information Object
* int ShutdownMethod ; How to shutdown the socket. Used by
* sockets's shutdown()
*
* Description : Shutsdown the socket using the ShutdownMethod to
* indicate whether sends and receives on the socket will be
* dis-allowed. After shutting down the socket, closesocket is called
* to release system resources used by the socket calls.
*
* Return : int;
* UPNP_E_SOCKET_ERROR on failure
* UPNP_E_SUCCESS on success
*
* Note :
************************************************************************/
int
sock_destroy( INOUT SOCKINFO * info,
int ShutdownMethod )
int sock_destroy(INOUT SOCKINFO *info, int ShutdownMethod)
{
if( info->socket != INVALID_SOCKET ) {
shutdown( info->socket, ShutdownMethod );
if( UpnpCloseSocket( info->socket ) == -1 ) {
return UPNP_E_SOCKET_ERROR;
}
}
int ret = UPNP_E_SUCCESS;
return UPNP_E_SUCCESS;
if (info->socket != -1) {
shutdown(info->socket, ShutdownMethod);
if (sock_close(info->socket) == -1) {
ret = UPNP_E_SOCKET_ERROR;
}
info->socket = -1;
}
return ret;
}
/************************************************************************
* Function : sock_read_write
*
* Parameters :
* IN SOCKINFO *info ; Socket Information Object
* OUT char* buffer ; Buffer to get data to or send data from
* IN size_t bufsize ; Size of the buffer
* IN int *timeoutSecs ; timeout value
* IN xboolean bRead ; Boolean value specifying read or write option
*
* Description : Receives or sends data. Also returns the time taken
* to receive or send data.
*
* Return :int ;
* numBytes - On Success, no of bytes received or sent
* UPNP_E_TIMEDOUT - Timeout
* UPNP_E_SOCKET_ERROR - Error on socket calls
*
* Note :
************************************************************************/
static int
sock_read_write( IN SOCKINFO * info,
OUT char *buffer,
IN size_t bufsize,
IN int *timeoutSecs,
IN xboolean bRead )
/*!
* \brief Receives or sends data. Also returns the time taken to receive or
* send data.
*
* \return
* \li \c numBytes - On Success, no of bytes received or sent or
* \li \c UPNP_E_TIMEDOUT - Timeout
* \li \c UPNP_E_SOCKET_ERROR - Error on socket calls
*/
static int sock_read_write(
/*! Socket Information Object. */
IN SOCKINFO *info,
/*! Buffer to get data to or send data from. */
OUT char *buffer,
/*! Size of the buffer. */
IN size_t bufsize,
/*! timeout value. */
IN int *timeoutSecs,
/*! Boolean value specifying read or write option. */
IN xboolean bRead)
{
int retCode;
fd_set readSet;
fd_set writeSet;
struct timeval timeout;
int numBytes;
time_t start_time = time( NULL );
SOCKET sockfd = info->socket;
long bytes_sent = 0,
byte_left = 0,
num_written;
if( *timeoutSecs < 0 ) {
return UPNP_E_TIMEDOUT;
}
FD_ZERO( &readSet );
FD_ZERO( &writeSet );
if( bRead ) {
FD_SET( sockfd, &readSet );
} else {
FD_SET( sockfd, &writeSet );
}
timeout.tv_sec = *timeoutSecs;
timeout.tv_usec = 0;
while( TRUE ) {
if( *timeoutSecs == 0 ) {
retCode =
select( sockfd + 1, &readSet, &writeSet, NULL, NULL );
} else {
retCode =
select( sockfd + 1, &readSet, &writeSet, NULL, &timeout );
}
if( retCode == 0 ) {
return UPNP_E_TIMEDOUT;
}
if( retCode == -1 ) {
if( errno == EINTR )
continue;
return UPNP_E_SOCKET_ERROR; // error
} else {
break; // read or write
}
}
int retCode;
fd_set readSet;
fd_set writeSet;
struct timeval timeout;
int numBytes;
time_t start_time = time(NULL);
SOCKET sockfd = info->socket;
long bytes_sent = 0, byte_left = 0, num_written;
if (*timeoutSecs < 0) {
return UPNP_E_TIMEDOUT;
}
FD_ZERO(&readSet);
FD_ZERO(&writeSet);
if (bRead) {
FD_SET(sockfd, &readSet);
} else {
FD_SET(sockfd, &writeSet);
}
timeout.tv_sec = *timeoutSecs;
timeout.tv_usec = 0;
while (TRUE) {
if (*timeoutSecs == 0) {
retCode = select(sockfd + 1, &readSet, &writeSet,
NULL, NULL);
} else {
retCode = select(sockfd + 1, &readSet, &writeSet,
NULL, &timeout);
}
if (retCode == 0) {
return UPNP_E_TIMEDOUT;
}
if (retCode == -1) {
if (errno == EINTR)
continue;
return UPNP_E_SOCKET_ERROR;
} else {
/* read or write. */
break;
}
}
#ifdef SO_NOSIGPIPE
{
int old;
int set = 1;
socklen_t olen = sizeof(old);
getsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &old, &olen);
setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &set, sizeof(set));
{
int old;
int set = 1;
socklen_t olen = sizeof(old);
getsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &old, &olen);
setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &set, sizeof(set));
#endif
if( bRead ) {
// read data
numBytes = recv( sockfd, buffer, bufsize,MSG_NOSIGNAL);
} else {
byte_left = bufsize;
bytes_sent = 0;
while( byte_left > 0 ) {
// write data
num_written =
send( sockfd, buffer + bytes_sent, byte_left,
MSG_DONTROUTE|MSG_NOSIGNAL);
if( num_written == -1 ) {
if (bRead) {
/* read data. */
numBytes = recv(sockfd, buffer, bufsize, MSG_NOSIGNAL);
} else {
byte_left = bufsize;
bytes_sent = 0;
while (byte_left > 0) {
/* write data. */
num_written = send(sockfd,
buffer + bytes_sent, byte_left,
MSG_DONTROUTE | MSG_NOSIGNAL);
if (num_written == -1) {
#ifdef SO_NOSIGPIPE
setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &old, olen);
setsockopt(sockfd, SOL_SOCKET,
SO_NOSIGPIPE, &old, olen);
#endif
return num_written;
}
byte_left = byte_left - num_written;
bytes_sent += num_written;
}
numBytes = bytes_sent;
}
return num_written;
}
byte_left = byte_left - num_written;
bytes_sent += num_written;
}
numBytes = bytes_sent;
}
#ifdef SO_NOSIGPIPE
setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &old, olen);
}
setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &old, olen);
}
#endif
if (numBytes < 0) {
return UPNP_E_SOCKET_ERROR;
}
/* subtract time used for reading/writing. */
if (*timeoutSecs != 0) {
*timeoutSecs -= time(NULL) - start_time;
}
if( numBytes < 0 ) {
return UPNP_E_SOCKET_ERROR;
}
// subtract time used for reading/writing
if( *timeoutSecs != 0 ) {
*timeoutSecs -= time( NULL ) - start_time;
}
return numBytes;
return numBytes;
}
/************************************************************************
* Function : sock_read
*
* Parameters :
* IN SOCKINFO *info ; Socket Information Object
* OUT char* buffer ; Buffer to get data to
* IN size_t bufsize ; Size of the buffer
* IN int *timeoutSecs ; timeout value
*
* Description : Calls sock_read_write() for reading data on the
* socket
*
* Return : int;
* Values returned by sock_read_write()
*
* Note :
************************************************************************/
int
sock_read( IN SOCKINFO * info,
OUT char *buffer,
IN size_t bufsize,
INOUT int *timeoutSecs )
int sock_read(IN SOCKINFO *info, OUT char *buffer, IN size_t bufsize,
INOUT int *timeoutSecs)
{
return sock_read_write( info, buffer, bufsize, timeoutSecs, TRUE );
return sock_read_write(info, buffer, bufsize, timeoutSecs, TRUE);
}
/************************************************************************
* Function : sock_write
*
* Parameters :
* IN SOCKINFO *info ; Socket Information Object
* IN char* buffer ; Buffer to send data from
* IN size_t bufsize ; Size of the buffer
* IN int *timeoutSecs ; timeout value
*
* Description : Calls sock_read_write() for writing data on the
* socket
*
* Return : int;
* sock_read_write()
*
* Note :
************************************************************************/
int
sock_write( IN SOCKINFO * info,
IN char *buffer,
IN size_t bufsize,
INOUT int *timeoutSecs )
int sock_write(IN SOCKINFO *info, IN char *buffer, IN size_t bufsize,
INOUT int *timeoutSecs)
{
return sock_read_write( info, buffer, bufsize, timeoutSecs, FALSE );
return sock_read_write(info, buffer, bufsize, timeoutSecs, FALSE);
}

View File

@@ -153,31 +153,15 @@ subscription *GetSubscriptionSID(const Upnp_SID sid, service_info *service)
}
/************************************************************************
* Function : GetNextSubscription
*
* Parameters :
* service_info * service ; service object providing the list of
* subscriptions
* subscription *current ; current subscription object
*
* Description : Get current and valid subscription from the service
* table.
*
* Return : subscription * - Pointer to the next subscription node;
*
* Note :
************************************************************************/
subscription *
GetNextSubscription( service_info * service,
subscription * current )
subscription *GetNextSubscription(service_info *service, subscription *current)
{
time_t current_time;
subscription *next = NULL;
subscription *previous = NULL;
int notDone = 1;
//get the current_time
// get the current_time
time( &current_time );
while( ( notDone ) && ( current ) ) {
previous = current;
@@ -202,52 +186,26 @@ GetNextSubscription( service_info * service,
return next;
}
/************************************************************************
* Function : GetFirstSubscription
*
* Parameters :
* service_info *service ; service object providing the list of
* subscriptions
*
* Description : Gets pointer to the first subscription node in the
* service table.
*
* Return : subscription * - pointer to the first subscription node ;
*
* Note :
************************************************************************/
subscription *
GetFirstSubscription( service_info * service )
{
subscription temp;
subscription *next = NULL;
temp.next = service->subscriptionList;
next = GetNextSubscription( service, &temp );
service->subscriptionList = temp.next;
// service->subscriptionList=next;
return next;
subscription *GetFirstSubscription(service_info *service)
{
subscription temp;
subscription *next = NULL;
temp.next = service->subscriptionList;
next = GetNextSubscription(service, &temp);
service->subscriptionList = temp.next;
// service->subscriptionList = next;
return next;
}
/************************************************************************
* Function : freeSubscription
*
* Parameters :
* subscription * sub ; subscription to be freed
*
* Description : Free's the memory allocated for storing the URL of
* the subscription.
*
* Return : void ;
*
* Note :
************************************************************************/
void
freeSubscription( subscription * sub )
void freeSubscription(subscription *sub)
{
if( sub ) {
free_URL_list( &sub->DeliveryURLs );
}
if (sub) {
free_URL_list(&sub->DeliveryURLs);
}
}
/************************************************************************

View File

@@ -1,65 +1,59 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2003 Intel Corporation
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither name of Intel Corporation nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
/*******************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
/*!
* \file
*
* \brief Contains a function for freeing the memory associated with a upnp
* time out event.
*/
/************************************************************************
* Purpose: This file contains a function for freeing the memory associated
* wuth a upnp time out event.
************************************************************************/
#include "config.h"
#include "upnp_timeout.h"
#include <stdlib.h>
/************************************************************************
* Function : free_upnp_timeout
*
* Parameters :
* upnp_timeout *event ; Event which needs to be freed
*
* Description : Free memory associated with event and memory for any
* sub-elements
*
* Return : void ;
*
* Note :
************************************************************************/
void
free_upnp_timeout( upnp_timeout * event )
#include <stdlib.h> /* for free() */
void free_upnp_timeout(upnp_timeout *event)
{
if( event ) {
if( event->Event )
free( event->Event );
free( event );
}
if (event) {
if (event->Event) {
free(event->Event);
}
free(event);
}
}

View File

@@ -37,7 +37,7 @@
#include "config.h"
#include "upnp.h"
#include "util.h"
#include "upnputil.h"
#include <string.h>

View File

@@ -1,52 +1,64 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2003 Intel Corporation
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither name of Intel Corporation nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
/*******************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#ifndef GENA_CTRLPT_H
#define GENA_CTRLPT_H
/*!
* \file
*/
#include "sock.h"
/************************************************************************
* Function : gena_process_notification_event
*
* Parameters:
* IN SOCKINFO *info: Socket structure containing the device socket
* information
* IN http_message_t* event: The http message contains the GENA
* notification
*
* Description:
* This function processes NOTIFY events that are sent by devices.
* called by genacallback()
*
* Returns: void
*
* Note : called by genacallback()
****************************************************************************/
void gena_process_notification_event( INOUT SOCKINFO *info,
IN http_message_t* request );
/*!
* \brief This function processes NOTIFY events that are sent by devices.
*
* Parameters:
* IN SOCKINFO *info: Socket structure containing the device socket
* information
* IN http_message_t *event: The http message contains the GENA
* notification
*
* \note called by genacallback()
*/
void gena_process_notification_event(
/*! [in] Socket info of the device. */
SOCKINFO *info,
/*! [in] The http message contains the GENA notification. */
http_message_t *event);
#endif /* GENA_CTRLPT_H */

View File

@@ -1,88 +1,79 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2003 Intel Corporation
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither name of Intel Corporation nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
/*******************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#ifndef GENA_DEVICE_H
#define GENA_DEVICE_H
/*!
* \file
*/
#include "sock.h"
/****************************************************************************
* Function : gena_process_subscription_request
*
* Parameters :
* IN SOCKINFO *info : socket info of the device
* IN http_message_t* request : SUBSCRIPTION request from the control
* point
*
* Description : This function handles a subscription request from a
* ctrl point. The socket is not closed on return.
*
* Return : void
*
* Note :
****************************************************************************/
void gena_process_subscription_request( IN SOCKINFO *info,
IN http_message_t* request );
/*!
* \brief Handles a subscription request from a ctrl point. The socket is not
* closed on return.
*/
void gena_process_subscription_request(
/*! [in] Socket info of the device. */
SOCKINFO *info,
/*! [in] Subscription request from the control point. */
http_message_t *request);
/****************************************************************************
* Function : gena_process_subscription_renewal_request
*
* Parameters :
* IN SOCKINFO *info : socket info of the device
* IN http_message_t* request : subscription renewal request from the
* control point
*
* Description : This function handles a subscription renewal request
* from a ctrl point. The connection is not destroyed on return.
*
* Return : void
*
* Note :
****************************************************************************/
void gena_process_subscription_renewal_request( IN SOCKINFO *info,
IN http_message_t* request );
/*!
* \brief Handles a subscription renewal request from a ctrl point.
* The connection is not destroyed on return.
*/
void gena_process_subscription_renewal_request(
/*! [in] Socket info of the device. */
SOCKINFO *info,
/*! [in] Subscription renewal request from the control point. */
http_message_t *request);
/****************************************************************************
* Function : gena_process_unsubscribe_request
*
* Parameters :
* IN SOCKINFO *info : socket info of the device
* IN http_message_t* request : UNSUBSCRIBE request from the control
* point
*
* Description : This function Handles a subscription cancellation request
* from a ctrl point. The connection is not destroyed on return.
*
* Return : void
*
* Note :
****************************************************************************/
void gena_process_unsubscribe_request( IN SOCKINFO *info,
IN http_message_t* request );
/*!
* \brief Handles a subscription cancellation request from a ctrl point.
* The connection is not destroyed on return.
*/
void gena_process_unsubscribe_request(
/*! [in] Socket info of the device. */
SOCKINFO *info,
/*! [in] UNSUBSCRIBE request from the control point. */
http_message_t *request);
#endif /* GENA_DEVICE_H */

View File

@@ -1,42 +1,49 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2003 Intel Corporation
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither name of Intel Corporation nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
/*******************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#ifndef GENLIB_NET_HTTP_HTTPPARSER_H
#define GENLIB_NET_HTTP_HTTPPARSER_H
#include "util.h"
#include "membuffer.h"
#include "uri.h"
/*!
* \file
*/
#include "LinkedList.h"
#include "membuffer.h"
#include "uri.h"
#include "upnputil.h"
////// private types ////////////
@@ -478,27 +485,22 @@ int raw_find_str( IN memptr* raw_value, IN const char* str );
************************************************************************/
const char* method_to_str( IN http_method_t method );
/************************************************************************
* Function: print_http_headers
*
* Parameters:
* http_message_t* hmsg ; HTTP Message object
*
* Description:
*
* Returns:
* void
************************************************************************/
/*!
* \brief Print the HTTP headers.
*/
#ifdef DEBUG
void print_http_headers( IN http_message_t *hmsg );
void print_http_headers(
/*! [in] HTTP Message object. */
http_message_t *hmsg );
#else
static UPNP_INLINE void print_http_headers( IN http_message_t *hmsg ) {}
static UPNP_INLINE void print_http_headers(http_message_t *hmsg) {}
#endif
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
#endif // GENLIB_NET_HTTP_HTTPPARSER_H
#endif /* GENLIB_NET_HTTP_HTTPPARSER_H */

View File

@@ -33,7 +33,7 @@
#define GENLIB_NET_HTTP_HTTPREADWRITE_H
#include "config.h"
#include "util.h"
#include "upnputil.h"
#include "sock.h"
#include "httpparser.h"

View File

@@ -34,7 +34,7 @@
#include <stdlib.h>
#include "util.h"
#include "upnputil.h"
#define MINVAL( a, b ) ( (a) < (b) ? (a) : (b) )
#define MAXVAL( a, b ) ( (a) > (b) ? (a) : (b) )

View File

@@ -1,38 +1,43 @@
/************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
/**************************************************************************
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************/
**************************************************************************/
#ifndef MINISERVER_H
#define MINISERVER_H
/*!
* \file
*/
#include "sock.h"
#include "httpparser.h"
@@ -41,32 +46,43 @@ extern SOCKET gMiniServerStopSock;
typedef struct MServerSockArray {
/* socket for listening for miniserver requests */
/*! IPv4 socket for listening for miniserver requests. */
SOCKET miniServerSock4;
/*! IPv6 Socket for listening for miniserver requests. */
SOCKET miniServerSock6;
/* socket for stopping miniserver */
/*! Socket for stopping miniserver */
SOCKET miniServerStopSock;
/* socket for incoming advertisments and search requests */
/*! IPv4 SSDP Socket for incoming advertisments and search requests. */
SOCKET ssdpSock4;
/*! IPv6 SSDP Socket for incoming advertisments and search requests. */
SOCKET ssdpSock6;
/*! IPv6 SSDP Socket for incoming advertisments and search requests. */
SOCKET ssdpSock6UlaGua;
/* ! . */
SOCKET stopPort;
/* ! . */
SOCKET miniServerPort4;
/* ! . */
SOCKET miniServerPort6;
#ifdef INCLUDE_CLIENT_APIS
/* socket for sending search requests and receiving search replies */
/*! IPv4 SSDP socket for sending search requests and receiving search
* replies */
SOCKET ssdpReqSock4;
/*! IPv6 SSDP socket for sending search requests and receiving search
* replies */
SOCKET ssdpReqSock6;
#endif /* INCLUDE_CLIENT_APIS */
} MiniServerSockArray;
/*! . */
typedef void (*MiniServerCallback)(
/* ! . */
IN http_parser_t *parser,
/* ! . */
IN http_message_t* request,
IN SOCKINFO *info );
/* ! . */
IN SOCKINFO *info);
#ifdef __cplusplus
@@ -118,9 +134,11 @@ void SetGenaCallback(
* \li On error: UPNP_E_XXX.
*/
int StartMiniServer(
/*! [in,out] Port on which the server listens for incoming IPv4 connections. */
/*! [in,out] Port on which the server listens for incoming IPv4
* connections. */
unsigned short *listen_port4,
/*! [in,out] Port on which the server listens for incoming IPv6 connections. */
/*! [in,out] Port on which the server listens for incoming IPv6
* connections. */
unsigned short *listen_port6);

View File

@@ -32,7 +32,7 @@
#ifndef GENLIB_NET_HTTP_PARSETOOLS_H
#define GENLIB_NET_HTTP_PARSETOOLS_H
#include "util.h"
#include "upnputil.h"
#include "httpparser.h"

View File

@@ -29,13 +29,14 @@
*
**************************************************************************/
#ifndef GENLIB_NET_SOCK_H
#define GENLIB_NET_SOCK_H
/*!
* \file
*/
#include "util.h"
#include "upnputil.h"
#ifdef WIN32
/* Do not #include <netinet/in.h> */
@@ -43,135 +44,128 @@
#include <netinet/in.h>
#endif
/* Following variable is not defined under winsock.h */
/* The following are not defined under winsock.h */
#ifndef SD_RECEIVE
#define SD_RECEIVE 0x00
#define SD_SEND 0x01
#define SD_BOTH 0x02
#define SD_RECEIVE 0x00
#define SD_SEND 0x01
#define SD_BOTH 0x02
#endif
/*! */
typedef struct
{
/* handle/descriptor to a socket */
/*! Handle/descriptor to a socket. */
SOCKET socket;
/* the following two fields are filled only in incoming requests; */
/*! The following two fields are filled only in incoming requests. */
struct sockaddr_storage foreign_sockaddr;
} SOCKINFO;
#ifdef __cplusplus
#extern "C" {
#endif
/*!
* \brief Assign the passed in socket descriptor to socket descriptor in the
* SOCKINFO structure.
*
* \return Integer:
* \li \c UPNP_E_SUCCESS
* \li \c UPNP_E_OUTOF_MEMORY
* \li \c UPNP_E_SOCKET_ERROR
*/
int sock_init(
/*! Socket Information Object. */
OUT SOCKINFO *info,
/*! Socket Descriptor. */
IN SOCKET sockfd);
/************************************************************************
* Function : sock_init
*
* Parameters :
* OUT SOCKINFO* info ; Socket Information Object
* IN SOCKET sockfd ; Socket Descriptor
*
* Description : Assign the passed in socket descriptor to socket
* descriptor in the SOCKINFO structure.
*
* Return : int;
* UPNP_E_SUCCESS
* UPNP_E_OUTOF_MEMORY
* UPNP_E_SOCKET_ERROR
* Note :
************************************************************************/
int sock_init(OUT SOCKINFO* info, IN SOCKET sockfd);
/************************************************************************
* Function : sock_init_with_ip
*
* Parameters :
* OUT SOCKINFO* info ; Socket Information Object
* IN SOCKET sockfd ; Socket Descriptor
* IN struct sockaddr* foreign_sockaddr; Remote socket address
*
* Description : Calls the sock_init function and assigns the passed in
* IP address and port to the IP address and port in the SOCKINFO
* structure.
*
* Return : int;
* UPNP_E_SUCCESS
* UPNP_E_OUTOF_MEMORY
* UPNP_E_SOCKET_ERROR
*
* Note :
************************************************************************/
/*!
* \brief Calls the sock_init function and assigns the passed in IP address
* and port to the IP address and port in the SOCKINFO structure.
*
* \return Integer:
* \li \c UPNP_E_SUCCESS
* \li \c UPNP_E_OUTOF_MEMORY
* \li \c UPNP_E_SOCKET_ERROR
*/
int sock_init_with_ip(
/*! Socket Information Object. */
OUT SOCKINFO* info,
/*! Socket Descriptor. */
IN SOCKET sockfd,
/*! Remote socket address. */
IN struct sockaddr *foreign_sockaddr);
/************************************************************************
* Function : sock_read
*
* Parameters :
* IN SOCKINFO *info ; Socket Information Object
* OUT char* buffer ; Buffer to get data to
* IN size_t bufsize ; Size of the buffer
* IN int *timeoutSecs ; timeout value
*
* Description : Reads data on socket in sockinfo
*
* Return : int;
* numBytes - On Success, no of bytes received
* UPNP_E_TIMEDOUT - Timeout
* UPNP_E_SOCKET_ERROR - Error on socket calls
*
* Note :
************************************************************************/
int sock_read( IN SOCKINFO *info, OUT char* buffer, IN size_t bufsize,
INOUT int *timeoutSecs );
/*!
* \brief Reads data on socket in sockinfo.
*
* \return Integer:
* \li \c numBytes - On Success, no of bytes received.
* \li \c UPNP_E_TIMEDOUT - Timeout.
* \li \c UPNP_E_SOCKET_ERROR - Error on socket calls.
*/
int sock_read(
/*! Socket Information Object. */
IN SOCKINFO *info,
/*! Buffer to get data to. */
OUT char* buffer,
/*! Size of the buffer. */
IN size_t bufsize,
/*! timeout value. */
INOUT int *timeoutSecs);
/************************************************************************
* Function : sock_write
*
* Parameters :
* IN SOCKINFO *info ; Socket Information Object
* IN char* buffer ; Buffer to send data from
* IN size_t bufsize ; Size of the buffer
* IN int *timeoutSecs ; timeout value
*
* Description : Writes data on the socket in sockinfo
*
* Return : int;
* numBytes - On Success, no of bytes sent
* UPNP_E_TIMEDOUT - Timeout
* UPNP_E_SOCKET_ERROR - Error on socket calls
*
* Note :
************************************************************************/
int sock_write( IN SOCKINFO *info, IN char* buffer, IN size_t bufsize,
INOUT int *timeoutSecs );
/*!
* \brief Writes data on the socket in sockinfo.
*
* \return Integer:
* \li \c numBytes - On Success, no of bytes received.
* \li \c UPNP_E_TIMEDOUT - Timeout.
* \li \c UPNP_E_SOCKET_ERROR - Error on socket calls.
*/
int sock_write(
/*! Socket Information Object. */
IN SOCKINFO *info,
/*! Buffer to send data from. */
IN char* buffer,
/*! Size of the buffer. */
IN size_t bufsize,
/*! timeout value. */
INOUT int *timeoutSecs);
/************************************************************************
* Function : sock_destroy
*
* Parameters :
* INOUT SOCKINFO* info ; Socket Information Object
* int ShutdownMethod ; How to shutdown the socket. Used by
* sockets's shutdown()
*
* Description : Shutsdown the socket using the ShutdownMethod to
* indicate whether sends and receives on the socket will be
* dis-allowed. After shutting down the socket, closesocket is called
* to release system resources used by the socket calls.
*
* Return : int;
* UPNP_E_SOCKET_ERROR on failure
* UPNP_E_SUCCESS on success
*
* Note :
************************************************************************/
int sock_destroy(INOUT SOCKINFO* info, int);
/*!
* \brief Shutsdown the socket using the ShutdownMethod to indicate whether
* sends and receives on the socket will be dis-allowed.
*
* After shutting down the socket, closesocket is called to release system
* resources used by the socket calls.
*
* \return Integer:
* \li \c UPNP_E_SOCKET_ERROR on failure.
* \li \c UPNP_E_SUCCESS on success.
*/
int sock_destroy(
/*! Socket Information Object. */
INOUT SOCKINFO* info,
/*! How to shutdown the socket. Used by sockets's shutdown(). */
int ShutdownMethod);
/*!
* \brief Closes the socket if it is different from -1.
*
* \return -1 if an error occurred or if the socket is -1.
*/
static inline int sock_close(
/*! Socket descriptor. */
int sock)
{
int ret = -1;
if (sock != -1) {
ret = UpnpCloseSocket(sock);
}
return ret;
}
#ifdef __cplusplus
} /* #extern "C" */

View File

@@ -90,7 +90,6 @@ typedef enum SsdpCmdType{
#define SSDP_IPV6_SITELOCAL "FF05::C"
#define SSDP_PORT 1900
#define NUM_TRY 3
#define NUM_COPY 1
#define THREAD_LIMIT 50
#define COMMAND_LEN 300
@@ -140,12 +139,12 @@ typedef void (* SsdpFunPtr)(Event *);
typedef Event SsdpEvent ;
//Structure to contain Discovery response
// Structure to contain Discovery response
typedef struct resultData
{
struct Upnp_Discovery param;
void *cookie;
Upnp_FunPtr ctrlpt_callback;
struct Upnp_Discovery param;
void *cookie;
Upnp_FunPtr ctrlpt_callback;
}ResultData;
@@ -224,12 +223,12 @@ int Make_Socket_NoBlocking (int sock);
***************************************************************************/
#ifdef INCLUDE_DEVICE_APIS
void ssdp_handle_device_request(
IN http_message_t* hmsg,
IN struct sockaddr* dest_addr );
IN http_message_t *hmsg,
IN struct sockaddr *dest_addr);
#else
static inline void ssdp_handle_device_request(
IN http_message_t* hmsg,
IN struct sockaddr* dest_addr ) {}
IN http_message_t *hmsg,
IN struct sockaddr* dest_addr) {}
#endif
/************************************************************************
@@ -253,10 +252,10 @@ static inline void ssdp_handle_device_request(
*
***************************************************************************/
void ssdp_handle_ctrlpt_msg(
IN http_message_t* hmsg,
IN struct sockaddr* dest_addr,
IN http_message_t *hmsg,
IN struct sockaddr *dest_addr,
IN xboolean timeout,
IN void* cookie );
IN void *cookie);
/************************************************************************
* Function : unique_service_name

View File

@@ -33,7 +33,7 @@
#define GENLIB_UTIL_STRINTMAP_H
#include <stdlib.h>
#include "util.h"
#include "upnputil.h"
// Util to map from a string to an integer and vice versa

View File

@@ -1,58 +1,62 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2003 Intel Corporation
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither name of Intel Corporation nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
/*******************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#ifndef _UPNPTIMEOUTH_
#define _UPNPTIMEOUTH_
#ifndef UPNPTIMEOUT_H
#define UPNPTIMEOUT_H
/*!
* \file
*/
/*!
* The upnp_timeout structure definition.
*/
typedef struct UPNP_TIMEOUT {
int EventType;
int handle;
int eventId;
void *Event;
int EventType;
int handle;
int eventId;
void *Event;
} upnp_timeout;
/************************************************************************
* Function : free_upnp_timeout
*
* Parameters :
* upnp_timeout *event ; Event which needs to be freed
*
* Description : Free memory associated with event and memory for any
* sub-elements
*
* Return : void ;
*
* Note :
************************************************************************/
void free_upnp_timeout(upnp_timeout *event);
/*!
* \brief Free memory associated with event and memory for any sub-elements.
*/
void free_upnp_timeout(
/*! [in] Event which needs to be freed. */
upnp_timeout *event);
#endif /* UPNPTIMEOUT_H */
#endif

View File

@@ -109,10 +109,8 @@ struct Handle_Info
#endif
};
extern ithread_rwlock_t GlobalHndRWLock;
/*!
* \brief Get handle information.
*

View File

@@ -1,37 +0,0 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2003 Intel Corporation
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither name of Intel Corporation nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#ifndef UPNPCLOSESOCKET_H
#define UPNPCLOSESOCKET_H
#define UpnpCloseSocket close
#endif

View File

@@ -1,34 +0,0 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2003 Intel Corporation
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither name of Intel Corporation nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#include <genlib/util/util.h>
#include <genlib/util/xstring.h>

View File

@@ -1,33 +1,33 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2003 Intel Corporation
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither name of Intel Corporation nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
/**************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************/
#ifndef GENLIB_NET_HTTP_WEBSERVER_H
#define GENLIB_NET_HTTP_WEBSERVER_H
@@ -50,97 +50,83 @@ struct SendInstruction
char RangeHeader[200];
char AcceptLanguageHeader[200];
off_t RangeOffset;
off_t ReadSendSize; // Read from local source and send on the network.
long RecvWriteSize; // Recv from the network and write into local file.
//Later few more member could be added depending on the requirement.
/*! Read from local source and send on the network. */
off_t ReadSendSize;
/*! Recv from the network and write into local file. */
long RecvWriteSize;
/* Later few more member could be added depending
* on the requirement.*/
};
/************************************************************************
* Function: web_server_init
*
* Parameters:
* none
*
* Description: Initilialize the different documents. Initialize the
* memory for root directory for web server. Call to initialize global
* XML document. Sets bWebServerState to WEB_SERVER_ENABLED
*
* Returns:
* 0 - OK
* UPNP_E_OUTOF_MEMORY: note: alias_content is not freed here
************************************************************************/
int web_server_init( void );
/************************************************************************
* Function: web_server_destroy
*
* Parameters:
* none
*
* Description: Release memory allocated for the global web server root
* directory and the global XML document
* Resets the flag bWebServerState to WEB_SERVER_DISABLED
*
* Returns:
* void
************************************************************************/
void web_server_destroy( void );
/*!
* \brief Initilialize the different documents. Initialize the memory
* for root directory for web server. Call to initialize global XML
* document. Sets bWebServerState to WEB_SERVER_ENABLED.
*
* \note alias_content is not freed here
*
* \return
* \li \c 0 - OK
* \li \c UPNP_E_OUTOF_MEMORY
*/
int web_server_init(void);
/************************************************************************
* Function: web_server_set_alias
*
* Parameters:
* alias_name: webserver name of alias; created by caller and freed by
* caller (doesn't even have to be malloc()d .)
* alias_content: the xml doc; this is allocated by the caller; and
* freed by the web server
* alias_content_length: length of alias body in bytes
* last_modified: time when the contents of alias were last
* changed (local time)
*
* Description: Replaces current alias with the given alias. To remove
* the current alias, set alias_name to NULL.
*
* Returns:
* 0 - OK
* UPNP_E_OUTOF_MEMORY: note: alias_content is not freed here
************************************************************************/
int web_server_set_alias( IN const char* alias_name,
IN const char* alias_content, IN size_t alias_content_length,
IN time_t last_modified );
/************************************************************************
* Function: web_server_set_root_dir
*
* Parameters:
* IN const char* root_dir ; String having the root directory for the
* document
*
* Description: Assign the path specfied by the IN const char* root_dir
* parameter to the global Document root directory. Also check for
* path names ending in '/'
*
* Returns:
* int
************************************************************************/
int web_server_set_root_dir( IN const char* root_dir );
/*!
* \brief Release memory allocated for the global web server root
* directory and the global XML document. Resets the flag bWebServerState
* to WEB_SERVER_DISABLED.
*/
void web_server_destroy(void);
/************************************************************************
* Function: web_server_callback
*
* Parameters:
* IN http_parser_t *parser,
* INOUT http_message_t* req,
* IN SOCKINFO *info
*
* Description: main entry point into web server;
* handles HTTP GET and HEAD requests
*
* Returns:
* void
************************************************************************/
void web_server_callback( IN http_parser_t *parser, IN http_message_t* req, INOUT SOCKINFO *info );
/*!
* \brief Replaces current alias with the given alias. To remove the current
* alias, set alias_name to NULL.
*
* \note alias_content is not freed here
*
* \return
* \li \c 0 - OK
* \li \c UPNP_E_OUTOF_MEMORY
*/
int web_server_set_alias(
/*! [in] Webserver name of alias; created by caller and freed by caller
* (doesn't even have to be malloc()d. */
const char* alias_name,
/*! [in] The xml doc; this is allocated by the caller; and freed by
* the web server. */
const char* alias_content,
/*! [in] Length of alias body in bytes. */
size_t alias_content_length,
/*! [in] Time when the contents of alias were last changed (local time). */
time_t last_modified);
/*!
* \brief Assign the path specfied by the input const char* root_dir parameter
* to the global Document root directory. Also check for path names ending
* in '/'.
*
* \return Integer.
*/
int web_server_set_root_dir(
/*! [in] String having the root directory for the document. */
const char* root_dir);
/*!
* \brief Main entry point into web server; Handles HTTP GET and HEAD
* requests.
*/
void web_server_callback(
/*! [in] . */
http_parser_t *parser,
/*! [in] . */
http_message_t *req,
/*! [in,out] . */
SOCKINFO *info);
#ifdef __cplusplus

View File

@@ -33,7 +33,7 @@
#include "config.h"
#include "util.h"
#include "upnputil.h"
#ifdef INCLUDE_CLIENT_APIS
@@ -74,11 +74,10 @@
***************************************************************************/
void send_search_result(IN void *data)
{
ResultData *temp = ( ResultData * ) data;
ResultData *temp = ( ResultData * ) data;
temp->ctrlpt_callback( UPNP_DISCOVERY_SEARCH_RESULT,
&temp->param, temp->cookie );
free( temp );
temp->ctrlpt_callback(UPNP_DISCOVERY_SEARCH_RESULT, &temp->param, temp->cookie);
free(temp);
}
/************************************************************************
@@ -127,7 +126,7 @@ void ssdp_handle_ctrlpt_msg(
ListNode *node = NULL;
SsdpSearchArg *searchArg = NULL;
int matched = 0;
ResultData *threadData;
ResultData *threadData = NULL;
ThreadPoolJob job;
// we are assuming that there can be only one client supported at a time
@@ -136,7 +135,7 @@ void ssdp_handle_ctrlpt_msg(
if ( GetClientHandleInfo( &handle, &ctrlpt_info ) != HND_CLIENT ) {
HandleUnlock();
return;
return;
}
// copy
ctrlpt_callback = ctrlpt_info->Callback;
@@ -146,14 +145,15 @@ void ssdp_handle_ctrlpt_msg(
// search timeout
if ( timeout ) {
ctrlpt_callback( UPNP_DISCOVERY_SEARCH_TIMEOUT, NULL, cookie );
return;
return;
}
param.ErrCode = UPNP_E_SUCCESS;
// MAX-AGE
param.Expires = -1; // assume error
if( httpmsg_find_hdr( hmsg, HDR_CACHE_CONTROL, &hdr_value ) != NULL ) {
// assume error
param.Expires = -1;
if ( httpmsg_find_hdr( hmsg, HDR_CACHE_CONTROL, &hdr_value ) != NULL ) {
if( matchstr( hdr_value.buf, hdr_value.length,
"%imax-age = %d%0", &param.Expires ) != PARSE_OK )
return;
@@ -161,7 +161,7 @@ void ssdp_handle_ctrlpt_msg(
// DATE
param.Date[0] = '\0';
if( httpmsg_find_hdr( hmsg, HDR_DATE, &hdr_value ) != NULL ) {
if ( httpmsg_find_hdr( hmsg, HDR_DATE, &hdr_value ) != NULL ) {
linecopylen( param.Date, hdr_value.buf, hdr_value.length );
}
@@ -170,17 +170,17 @@ void ssdp_handle_ctrlpt_msg(
// EXT
param.Ext[0] = '\0';
if( httpmsg_find_hdr( hmsg, HDR_EXT, &hdr_value ) != NULL ) {
if ( httpmsg_find_hdr( hmsg, HDR_EXT, &hdr_value ) != NULL ) {
linecopylen( param.Ext, hdr_value.buf, hdr_value.length );
}
// LOCATION
param.Location[0] = '\0';
if( httpmsg_find_hdr( hmsg, HDR_LOCATION, &hdr_value ) != NULL ) {
if ( httpmsg_find_hdr( hmsg, HDR_LOCATION, &hdr_value ) != NULL ) {
linecopylen( param.Location, hdr_value.buf, hdr_value.length );
}
// SERVER / USER-AGENT
param.Os[0] = '\0';
if( httpmsg_find_hdr( hmsg, HDR_SERVER, &hdr_value ) != NULL ||
if ( httpmsg_find_hdr( hmsg, HDR_SERVER, &hdr_value ) != NULL ||
httpmsg_find_hdr( hmsg, HDR_USER_AGENT, &hdr_value ) != NULL ) {
linecopylen( param.Os, hdr_value.buf, hdr_value.length );
}
@@ -327,7 +327,7 @@ void ssdp_handle_ctrlpt_msg(
TPJobInit( &job, ( start_routine ) send_search_result,
threadData );
TPJobSetPriority(&job, MED_PRIORITY);
TPJobSetFreeFunction( &job, ( free_routine ) free );
TPJobSetFreeFunction(&job, (free_routine)free);
ThreadPoolAdd(&gRecvThreadPool, &job, NULL);
}
}

View File

@@ -102,9 +102,9 @@ advertiseAndReplyThread( IN void *data )
* 1 if successful else appropriate error
***************************************************************************/
#ifdef INCLUDE_DEVICE_APIS
void
ssdp_handle_device_request( IN http_message_t *hmsg,
IN struct sockaddr *dest_addr )
void ssdp_handle_device_request(
IN http_message_t *hmsg,
IN struct sockaddr *dest_addr)
{
#define MX_FUDGE_FACTOR 10
@@ -223,7 +223,6 @@ NewRequestHandler( IN struct sockaddr *DestAddr,
char errorBuffer[ERROR_BUFFER_LEN];
SOCKET ReplySock;
int socklen = sizeof( struct sockaddr_storage );
int NumCopy;
int Index;
unsigned long replyAddr = inet_addr( gIF_IPV4 );
int ttl = 4; // a/c to UPNP Spec
@@ -265,38 +264,20 @@ NewRequestHandler( IN struct sockaddr *DestAddr,
for( Index = 0; Index < NumPacket; Index++ ) {
int rc;
// The reason to keep this loop is purely historical/documentation,
// according to section 9.2 of HTTPU spec:
//
// "If a multicast resource would send a response(s) to any copy of the
// request, it SHOULD send its response(s) to each copy of the request
// it receives. It MUST NOT repeat its response(s) per copy of the
// request."
//
// http://www.upnp.org/download/draft-goland-http-udp-04.txt
//
// So, NUM_COPY has been changed from 2 to 1.
NumCopy = 0;
while( NumCopy < NUM_COPY ) {
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
">>> SSDP SEND to %s >>>\n%s\n",
buf_ntop, *( RqPacket + Index ) );
rc = sendto( ReplySock, *( RqPacket + Index ),
strlen( *( RqPacket + Index ) ),
0, DestAddr, socklen );
if (rc == -1) {
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
">>> SSDP SEND to %s >>>\n%s\n",
buf_ntop, *( RqPacket + Index ) );
rc = sendto( ReplySock, *( RqPacket + Index ),
strlen( *( RqPacket + Index ) ),
0, DestAddr, socklen );
if (rc == -1) {
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
"SSDP_LIB: New Request Handler:"
"Error in socket(): %s\n", errorBuffer );
ret = UPNP_E_SOCKET_WRITE;
goto end_NewRequestHandler;
}
imillisleep( SSDP_PAUSE );
++NumCopy;
"SSDP_LIB: New Request Handler:"
"Error in socket(): %s\n", errorBuffer );
ret = UPNP_E_SOCKET_WRITE;
goto end_NewRequestHandler;
}
}
@@ -502,7 +483,7 @@ DeviceAdvertisement( IN char *DevType,
//char Mil_Nt[LINE_SIZE]
char Mil_Usn[LINE_SIZE];
char *msgs[3];
int ret_code;
int ret_code = UPNP_E_SUCCESS;
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
"In function DeviceAdvertisement\n" );
@@ -751,7 +732,7 @@ ServiceAdvertisement( IN char *Udn,
{
char Mil_Usn[LINE_SIZE];
char *szReq[1];
int RetVal;
int RetVal = UPNP_E_SUCCESS;
struct sockaddr_storage __ss;
struct sockaddr_in* DestAddr4 = (struct sockaddr_in*)&__ss;
struct sockaddr_in6* DestAddr6 = (struct sockaddr_in6*)&__ss;
@@ -860,7 +841,7 @@ ServiceShutdown( IN char *Udn,
struct sockaddr_storage __ss;
struct sockaddr_in* DestAddr4 = (struct sockaddr_in*)&__ss;
struct sockaddr_in6* DestAddr6 = (struct sockaddr_in6*)&__ss;
int RetVal;
int RetVal = UPNP_E_SUCCESS;
memset( &__ss, 0, sizeof(__ss) );
if( AddressFamily == AF_INET ) {
@@ -926,7 +907,7 @@ DeviceShutdown( IN char *DevType,
struct sockaddr_in6* DestAddr6 = (struct sockaddr_in6*)&__ss;
char *msgs[3];
char Mil_Usn[LINE_SIZE];
int ret_code;
int ret_code = UPNP_E_SUCCESS;
msgs[0] = NULL;
msgs[1] = NULL;

View File

@@ -135,6 +135,7 @@ int AdvertiseAndReply(
const DOMString tmpStr;
char SERVER[200];
const DOMString dbgStr;
int NumCopy = 0;
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Inside AdvertiseAndReply with AdFlag = %d\n", AdFlag);
@@ -152,245 +153,251 @@ int AdvertiseAndReply(
get_sdk_info(SERVER);
/* parse the device list and send advertisements/replies */
for (i = 0;; i++) {
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Entering new device list with i = %d\n\n", i);
tmpNode = ixmlNodeList_item(SInfo->DeviceList, i);
if (!tmpNode) {
while (NumCopy == 0 || (AdFlag && NumCopy < NUM_SSDP_COPY)) {
if (NumCopy != 0)
imillisleep(SSDP_PAUSE);
NumCopy++;
for (i = 0;; i++) {
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Exiting new device list with i = %d\n\n", i);
break;
}
dbgStr = ixmlNode_getNodeName(tmpNode);
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"Extracting device type once for %s\n", dbgStr);
ixmlNodeList_free(nodeList);
nodeList = ixmlElement_getElementsByTagName(
(IXML_Element *)tmpNode, "deviceType");
if (!nodeList) continue;
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Extracting UDN for %s\n", dbgStr);
dbgStr = ixmlNode_getNodeName(tmpNode);
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Extracting device type\n");
tmpNode2 = ixmlNodeList_item(nodeList, 0);
if (!tmpNode2) continue;
textNode = ixmlNode_getFirstChild(tmpNode2);
if (!textNode) continue;
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Extracting device type \n");
tmpStr = ixmlNode_getNodeValue(textNode);
if (!tmpStr) continue;
strcpy(devType, tmpStr);
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"Extracting device type = %s\n", devType);
if (!tmpNode) {
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"TempNode is NULL\n");
}
dbgStr = ixmlNode_getNodeName(tmpNode);
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Extracting UDN for %s\n", dbgStr);
ixmlNodeList_free(nodeList);
nodeList = ixmlElement_getElementsByTagName(
(IXML_Element *)tmpNode, "UDN");
if (!nodeList) {
UpnpPrintf(UPNP_CRITICAL, API, __FILE__,
__LINE__, "UDN not found!\n");
continue;
}
tmpNode2 = ixmlNodeList_item(nodeList, 0);
if (!tmpNode2) {
UpnpPrintf(UPNP_CRITICAL, API, __FILE__,
__LINE__, "UDN not found!\n");
continue;
}
textNode = ixmlNode_getFirstChild(tmpNode2);
if (!textNode) {
UpnpPrintf(UPNP_CRITICAL, API, __FILE__,
__LINE__, "UDN not found!\n");
continue;
}
tmpStr = ixmlNode_getNodeValue(textNode);
if (!tmpStr) {
UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
"UDN not found!\n");
continue;
}
strcpy(UDNstr, tmpStr);
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"Sending UDNStr = %s \n", UDNstr);
if (AdFlag) {
/* send the device advertisement */
if (AdFlag == 1) {
DeviceAdvertisement(devType, i == 0,
UDNstr, SInfo->DescURL, Exp, SInfo->DeviceAf );
} else {
/* AdFlag == -1 */
DeviceShutdown(devType, i == 0, UDNstr,
SERVER, SInfo->DescURL, Exp, SInfo->DeviceAf );
"Entering new device list with i = %d\n\n", i);
tmpNode = ixmlNodeList_item(SInfo->DeviceList, i);
if (!tmpNode) {
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Exiting new device list with i = %d\n\n", i);
break;
}
} else {
switch (SearchType) {
case SSDP_ALL:
DeviceReply(DestAddr, devType, i == 0,
UDNstr, SInfo->DescURL, defaultExp);
break;
case SSDP_ROOTDEVICE:
if (i == 0) {
SendReply(DestAddr, devType, 1,
UDNstr, SInfo->DescURL, defaultExp, 0);
dbgStr = ixmlNode_getNodeName(tmpNode);
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"Extracting device type once for %s\n", dbgStr);
ixmlNodeList_free(nodeList);
nodeList = ixmlElement_getElementsByTagName(
(IXML_Element *)tmpNode, "deviceType");
if (!nodeList) continue;
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Extracting UDN for %s\n", dbgStr);
dbgStr = ixmlNode_getNodeName(tmpNode);
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Extracting device type\n");
tmpNode2 = ixmlNodeList_item(nodeList, 0);
if (!tmpNode2) continue;
textNode = ixmlNode_getFirstChild(tmpNode2);
if (!textNode) continue;
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Extracting device type \n");
tmpStr = ixmlNode_getNodeValue(textNode);
if (!tmpStr) continue;
strcpy(devType, tmpStr);
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"Extracting device type = %s\n", devType);
if (!tmpNode) {
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"TempNode is NULL\n");
}
dbgStr = ixmlNode_getNodeName(tmpNode);
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Extracting UDN for %s\n", dbgStr);
ixmlNodeList_free(nodeList);
nodeList = ixmlElement_getElementsByTagName(
(IXML_Element *)tmpNode, "UDN");
if (!nodeList) {
UpnpPrintf(UPNP_CRITICAL, API, __FILE__,
__LINE__, "UDN not found!\n");
continue;
}
tmpNode2 = ixmlNodeList_item(nodeList, 0);
if (!tmpNode2) {
UpnpPrintf(UPNP_CRITICAL, API, __FILE__,
__LINE__, "UDN not found!\n");
continue;
}
textNode = ixmlNode_getFirstChild(tmpNode2);
if (!textNode) {
UpnpPrintf(UPNP_CRITICAL, API, __FILE__,
__LINE__, "UDN not found!\n");
continue;
}
tmpStr = ixmlNode_getNodeValue(textNode);
if (!tmpStr) {
UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
"UDN not found!\n");
continue;
}
strcpy(UDNstr, tmpStr);
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"Sending UDNStr = %s \n", UDNstr);
if (AdFlag) {
/* send the device advertisement */
if (AdFlag == 1) {
DeviceAdvertisement(devType, i == 0,
UDNstr, SInfo->DescURL, Exp, SInfo->DeviceAf );
} else {
/* AdFlag == -1 */
DeviceShutdown(devType, i == 0, UDNstr,
SERVER, SInfo->DescURL, Exp, SInfo->DeviceAf );
}
break;
case SSDP_DEVICEUDN: {
if (DeviceUDN && strlen(DeviceUDN) != 0) {
if (strcasecmp(DeviceUDN, UDNstr)) {
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"DeviceUDN=%s and search UDN=%s DID NOT match\n",
UDNstr, DeviceUDN);
break;
} else {
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"DeviceUDN=%s and search UDN=%s MATCH\n",
UDNstr, DeviceUDN);
SendReply(DestAddr, devType, 0,
UDNstr, SInfo->DescURL,
defaultExp, 0);
break;
} else {
switch (SearchType) {
case SSDP_ALL:
DeviceReply(DestAddr, devType, i == 0,
UDNstr, SInfo->DescURL, defaultExp);
break;
case SSDP_ROOTDEVICE:
if (i == 0) {
SendReply(DestAddr, devType, 1,
UDNstr, SInfo->DescURL, defaultExp, 0);
}
break;
case SSDP_DEVICEUDN: {
if (DeviceUDN && strlen(DeviceUDN) != 0) {
if (strcasecmp(DeviceUDN, UDNstr)) {
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"DeviceUDN=%s and search UDN=%s DID NOT match\n",
UDNstr, DeviceUDN);
break;
} else {
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"DeviceUDN=%s and search UDN=%s MATCH\n",
UDNstr, DeviceUDN);
SendReply(DestAddr, devType, 0,
UDNstr, SInfo->DescURL,
defaultExp, 0);
break;
}
}
}
}
case SSDP_DEVICETYPE: {
if (!strncasecmp(DeviceType, devType, strlen(DeviceType)-2)) {
if (atoi(&DeviceType[strlen(DeviceType)-1]) <= atoi(&devType[strlen(devType)-1])) {
/* the requested version is lower than the device version
* must reply with the lower version number */
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"DeviceType=%s and search devType=%s MATCH\n",
devType, DeviceType);
SendReply(DestAddr, DeviceType, 0, UDNstr, SInfo->DescURL, defaultExp, 1);
case SSDP_DEVICETYPE: {
if (!strncasecmp(DeviceType, devType, strlen(DeviceType)-2)) {
if (atoi(&DeviceType[strlen(DeviceType)-1]) <= atoi(&devType[strlen(devType)-1])) {
/* the requested version is lower than the device version
* must reply with the lower version number */
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"DeviceType=%s and search devType=%s MATCH\n",
devType, DeviceType);
SendReply(DestAddr, DeviceType, 0, UDNstr, SInfo->DescURL, defaultExp, 1);
} else {
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"DeviceType=%s and search devType=%s DID NOT MATCH\n",
devType, DeviceType);
}
} else {
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"DeviceType=%s and search devType=%s DID NOT MATCH\n",
devType, DeviceType);
}
} else {
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"DeviceType=%s and search devType=%s DID NOT MATCH\n",
devType, DeviceType);
break;
}
default:
break;
}
break;
}
default:
break;
}
}
/* send service advertisements for services corresponding
* to the same device */
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"Sending service Advertisement\n");
/* send service advertisements for services corresponding
* to the same device */
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"Sending service Advertisement\n");
/* Correct service traversal such that each device's serviceList
* is directly traversed as a child of its parent device. This
* ensures that the service's alive message uses the UDN of
* the parent device. */
tmpNode = ixmlNode_getFirstChild(tmpNode);
while (tmpNode) {
dbgStr = ixmlNode_getNodeName(tmpNode);
if (!strncmp(dbgStr, SERVICELIST_STR, sizeof SERVICELIST_STR)) {
break;
/* Correct service traversal such that each device's serviceList
* is directly traversed as a child of its parent device. This
* ensures that the service's alive message uses the UDN of
* the parent device. */
tmpNode = ixmlNode_getFirstChild(tmpNode);
while (tmpNode) {
dbgStr = ixmlNode_getNodeName(tmpNode);
if (!strncmp(dbgStr, SERVICELIST_STR, sizeof SERVICELIST_STR)) {
break;
}
tmpNode = ixmlNode_getNextSibling(tmpNode);
}
tmpNode = ixmlNode_getNextSibling(tmpNode);
}
ixmlNodeList_free(nodeList);
if (!tmpNode) {
nodeList = NULL;
continue;
}
nodeList = ixmlElement_getElementsByTagName(
(IXML_Element *)tmpNode, "service");
if (!nodeList) {
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"Service not found 3\n" );
continue;
}
for (j = 0;; j++) {
tmpNode = ixmlNodeList_item(nodeList, j);
ixmlNodeList_free(nodeList);
if (!tmpNode) {
break;
}
ixmlNodeList_free(tmpNodeList);
tmpNodeList = ixmlElement_getElementsByTagName(
(IXML_Element *)tmpNode, "serviceType");
if (!tmpNodeList) {
UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
"ServiceType not found \n");
nodeList = NULL;
continue;
}
tmpNode2 = ixmlNodeList_item(tmpNodeList, 0);
if (!tmpNode2) continue;
textNode = ixmlNode_getFirstChild(tmpNode2);
if (!textNode) continue;
/* servType is of format Servicetype:ServiceVersion */
tmpStr = ixmlNode_getNodeValue(textNode);
if (!tmpStr) continue;
strcpy(servType, tmpStr);
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"ServiceType = %s\n", servType);
if (AdFlag) {
if (AdFlag == 1) {
ServiceAdvertisement(UDNstr, servType,
SInfo->DescURL, Exp, SInfo->DeviceAf );
} else {
/* AdFlag == -1 */
ServiceShutdown(UDNstr, servType,
SInfo->DescURL, Exp, SInfo->DeviceAf );
}
} else {
switch (SearchType) {
case SSDP_ALL:
ServiceReply(DestAddr, servType,
UDNstr, SInfo->DescURL,
defaultExp);
nodeList = ixmlElement_getElementsByTagName(
(IXML_Element *)tmpNode, "service");
if (!nodeList) {
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"Service not found 3\n" );
continue;
}
for (j = 0;; j++) {
tmpNode = ixmlNodeList_item(nodeList, j);
if (!tmpNode) {
break;
case SSDP_SERVICE:
if (ServiceType) {
if (!strncasecmp(ServiceType, servType, strlen(ServiceType) - 2)) {
if (atoi(&ServiceType[strlen(ServiceType)-1]) <= atoi(&servType[strlen(servType)-1])) {
/* the requested version is lower than the service version
* must reply with the lower version number */
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"ServiceType=%s and search servType=%s MATCH\n",
ServiceType, servType);
SendReply(DestAddr, ServiceType, 0, UDNstr, SInfo->DescURL, defaultExp, 1);
}
ixmlNodeList_free(tmpNodeList);
tmpNodeList = ixmlElement_getElementsByTagName(
(IXML_Element *)tmpNode, "serviceType");
if (!tmpNodeList) {
UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
"ServiceType not found \n");
continue;
}
tmpNode2 = ixmlNodeList_item(tmpNodeList, 0);
if (!tmpNode2) continue;
textNode = ixmlNode_getFirstChild(tmpNode2);
if (!textNode) continue;
/* servType is of format Servicetype:ServiceVersion */
tmpStr = ixmlNode_getNodeValue(textNode);
if (!tmpStr) continue;
strcpy(servType, tmpStr);
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"ServiceType = %s\n", servType);
if (AdFlag) {
if (AdFlag == 1) {
ServiceAdvertisement(UDNstr, servType,
SInfo->DescURL, Exp, SInfo->DeviceAf );
} else {
/* AdFlag == -1 */
ServiceShutdown(UDNstr, servType,
SInfo->DescURL, Exp, SInfo->DeviceAf );
}
} else {
switch (SearchType) {
case SSDP_ALL:
ServiceReply(DestAddr, servType,
UDNstr, SInfo->DescURL,
defaultExp);
break;
case SSDP_SERVICE:
if (ServiceType) {
if (!strncasecmp(ServiceType, servType, strlen(ServiceType) - 2)) {
if (atoi(&ServiceType[strlen(ServiceType)-1]) <= atoi(&servType[strlen(servType)-1])) {
/* the requested version is lower than the service version
* must reply with the lower version number */
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"ServiceType=%s and search servType=%s MATCH\n",
ServiceType, servType);
SendReply(DestAddr, ServiceType, 0, UDNstr, SInfo->DescURL, defaultExp, 1);
} else {
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"ServiceType=%s and search servType=%s DID NOT MATCH\n",
ServiceType, servType);
}
} else {
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"ServiceType=%s and search servType=%s DID NOT MATCH\n",
ServiceType, servType);
}
} else {
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"ServiceType=%s and search servType=%s DID NOT MATCH\n",
ServiceType, servType);
}
break;
default:
break;
}
break;
default:
break;
}
}
ixmlNodeList_free(tmpNodeList);
tmpNodeList = NULL;
ixmlNodeList_free(nodeList);
nodeList = NULL;
}
ixmlNodeList_free(tmpNodeList);
tmpNodeList = NULL;
ixmlNodeList_free(nodeList);
nodeList = NULL;
}
end_function:
@@ -743,7 +750,7 @@ start_event_handler( void *Data )
* Returns: void
*
***************************************************************************/
static void ssdp_event_handler_thread(void * the_data)
static void ssdp_event_handler_thread(void *the_data)
{
ssdp_thread_data *data = (ssdp_thread_data *)the_data;
http_message_t *hmsg = &data->parser.msg;
@@ -755,10 +762,10 @@ static void ssdp_event_handler_thread(void * the_data)
if (hmsg->method == HTTPMETHOD_NOTIFY ||
hmsg->request_method == HTTPMETHOD_MSEARCH) {
#ifdef INCLUDE_CLIENT_APIS
ssdp_handle_ctrlpt_msg(hmsg, (struct sockaddr*)&data->dest_addr, FALSE, NULL);
ssdp_handle_ctrlpt_msg(hmsg, (struct sockaddr *)&data->dest_addr, FALSE, NULL);
#endif /* INCLUDE_CLIENT_APIS */
} else {
ssdp_handle_device_request(hmsg, (struct sockaddr*)&data->dest_addr);
ssdp_handle_device_request(hmsg, (struct sockaddr *)&data->dest_addr);
}
/* free data */

View File

@@ -40,7 +40,7 @@
#include "UpnpInet.h"
#include "uri.h"
#include "urlconfig.h"
#include "util.h"
#include "upnputil.h"
#include "webserver.h"