Compare commits

..

114 Commits

Author SHA1 Message Date
Marcelo Roberto Jimenez
95f7a7eeef Whitespace fix on soaplib.h. 2010-10-02 18:57:35 -03:00
Marcelo Roberto Jimenez
ca50c2153e Remove extra soaplib.h. 2010-10-02 18:57:13 -03:00
Fabrice Fontaine
c73d870f46 Adding --disable-notification-reordering option
Adding a configure flag to disable GENA notification reordering as even
with an imillisleep(1), this mechanism consumes too much CPU on embedded
devices when there is a burst of notifications.
2010-10-02 13:44:52 -03:00
Fabrice Fontaine
ab54cb3dc5 Bug fix when there is no service in embedded devices
When a device with embedded devices (like IGD) when created and one of
the embedded devices did not have any service, there was a Segmentation
Fault (see SF Tracker [ 2688125 ]).
2010-09-30 11:51:06 -03:00
Fabrice Fontaine
c33b11d09f Bug fix on burst of GENA notification
When a lot of notifications were generated by a device in a short
period of time then 100% of the CPU was used to reorder those
notifications by pushing back the thread in the job queue. This
mechanism has been modified so now thread sleep 1 ms before being
pushed back into the job queue.

Removing DEFAULT_SCHED_PARAM parameter and use
sched_get_priority_min(DEFAULT_POLICY) instead.
2010-09-28 20:41:28 -03:00
Fabrice Fontaine
4966423d96 Bug fix on M-SEARCH response
Devices must respond to M-SEARCH requests for any supported version and the
response should specify the same version as was contained in the search target.
Previously, the device did not answer if the M-SEARCH request did not
contain the same version number than the version number of the device.
2010-09-22 15:34:45 -03:00
Marcelo Roberto Jimenez
2fb55d3874 White space fix. 2010-09-21 16:49:20 -03:00
Fabrice Fontaine
d2238615e3 Add Content-Language iff Accept-Language
Add Content-Language header in the response if and only if there is an Accept-Language header in the request.
2010-09-21 13:50:29 -03:00
Fabrice Fontaine
2fcbe6df52 Addition of WEB_SERVER_CONTENT_LANGUAGE parameter
This patch adds the WEB_SERVER_CONTENT_LANGUAGE parameter so the user can specify
the language used by the device during Description and Presentation steps of UPnP
through the HTTP CONTENT-LANGUAGE header.
By default, the WEB_SERVER_CONTENT_LANGUAGE is an empty string so no
CONTENT-LANGUAGE is added.
2010-09-21 08:48:40 -03:00
Fabrice Fontaine
467f9987a1 Customize the stack size of the threads used by pupnp through the new THREAD_STACK_SIZE variable
This patch allows a user to customize the stack size of the threads used by
pupnp through the new THREAD_STACK_SIZE variable. This is especially useful
on embedded systems with limited memory where the user can set THREAD_STACK_SIZE
to ITHREAD_STACK_MIN.

However, as this modification can have side effects, I set 0 as the default
value, so threads will continue to use the default stack size of the system
(which varies greatly as stated in
https://computing.llnl.gov/tutorials/pthreads/).
2010-09-18 06:45:56 -03:00
Marcelo Roberto Jimenez
8fbecaee5e Another fix for Changelog. 2010-09-16 08:42:14 -03:00
Fabrice Fontaine
55d581481f Broken IPv6.
IPv6 is currently broken in latest release of branch-1.6.x, so find
a patch attached that correct the issue (small fixes on define,
undef and retVal).
2010-09-16 08:21:41 -03:00
Marcelo Roberto Jimenez
a0b405f902 White spaces. 2010-09-15 06:07:42 -03:00
Marcelo Roberto Jimenez
b37f9ac64a Get rid of evil CLIENTONLY macro. 2010-09-15 05:46:07 -03:00
Marcelo Roberto Jimenez
2dad42679d White spaces. 2010-09-15 05:44:36 -03:00
Chandra Penke
ea00f0f222 Fix win32 compilation errors in visual studio 2010-09-15 05:23:53 -03:00
Marcelo Roberto Jimenez
f3ae1b4116 Added UpnpString_cmp() and UpnpString_casecmp() methods to UpnpString.
UpnpString_set_String() and UpnpString_set_StringN now return error values.
String lenghts are size_t.
(cherry picked from commit 81b28fbb90)
2010-09-12 00:35:31 -03:00
David Hoeung
67009170d1 Timeout for TCP connect
Hi,

I've made some modification to the libupnp v1.6.5
I've add a timeout for each TCP connect.

It is very useful when an UPnP device stop working and do not accept
connection for an UPnP action.

Modifications are only located in
upnp/src/genlib/net/http/httpreadwrite.c

For every TCP connection, I set the socket to non-blocking, perform
connect,
check result and wait during a timeout if necessary, then reset the
socket to blocking.

Please see this patch in attached file.

I hope it helps.

Regards,

David Hoeung
Consultant Extia
Orange Labs R&D

----
2010-09-11 00:17:55 -03:00
Warwick Harvey
2b399b1791 Take notice of UPNP_USE_RWLOCK flag.
Updated threadutil to use mutexes instead of read-write locks if
UPNP_USE_RWLOCK is false (0).
2010-09-10 22:43:30 -03:00
Marcelo Roberto Jimenez
0bec9ec1ae Remove some unused code plus some coding style in httpparser.c 2010-09-10 19:46:18 -03:00
Marcelo Roberto Jimenez
25a4bd6d25 2010-09-10 Jean Sigwald <jean.sigwald(at)orange-ftgroup.com>
I discovered a reliable denial-of-service issue on the last stable
release of libupnp (1.6.6) remotely triggerable by any
unauthenticated user. The issue is related with a bad parsing of
malformed XML.
2010-09-10 19:26:10 -03:00
Marcelo Roberto Jimenez
5755ac022f SF Patch Tracker [ 2854711 ] Patch for Solaris10 compilation and usage
Submitted By: zephyrus ( zephyrus00jp )

Patch for Solaris10 compilation and usage.
2010-09-10 19:02:31 -03:00
Marcelo Roberto Jimenez
0158f52ee2 One setp further to stop the CLIENTONLY() mess. 2010-09-10 18:56:36 -03:00
Marcelo Roberto Jimenez
0db4a6beac Fix an UTF-8 issue in README. 2010-09-10 00:47:53 -03:00
Chandra Penke
575e5fc196 SUMMARY: Minor change in comment for SetMaxContentLenght in upnp.h
This is a follow up from issue 6 in tracker id 3056713: calling UpnpSetMaxContentLength() by passing '0' disables the content length checking. This is useful for developing some prototype applications that deal with a lot of XML/SOAP data, and for debugging.

The corresponding c file change is already in the pupnp tree. Copy/pasting the relevant block of code here for clarity:

In upnp/src/genlib/net/http/httpreadwrite.c:

if (g_maxContentLength > 0 && parser->content_length > (unsigned int)g_maxContentLength) {
	*http_error_code = HTTP_REQ_ENTITY_TOO_LARGE;
	line = __LINE__;
	ret = UPNP_E_OUTOF_BOUNDS;
	goto ExitFunction;
}

This block of code checks only does the bounds check if g_maxContentLength > 0, and it's only place g_maxContentLength is checked.

Attached is a patch against the latest sources.
(cherry picked from commit 7f1e164a5a)
2010-09-10 00:42:27 -03:00
Marcelo Roberto Jimenez
0e45dd9b8f Fix for coding style and compiler warning message:
src/genlib/miniserver/miniserver.c: In function ‘get_miniserver_sockets’:
src/genlib/miniserver/miniserver.c:592: warning: unused variable ‘actual_port6’
src/genlib/miniserver/miniserver.c:582: warning: unused variable ‘__ss_v6’
2010-09-10 00:32:49 -03:00
Chandra Penke
ae516b6bd3 Add support for conditionally enabling ipv6
(cherry picked from commit 6b0d84fc95)
2010-09-10 00:32:49 -03:00
Chandra Penke
7137f6e261 Fix for compilation in debug builds.
Ensure internal methods are declared as static since debug builds don't inline.
2010-09-10 00:02:04 -03:00
Marcelo Roberto Jimenez
92b241b560 Fix for UpnpPrintf() in Chandra Penke's last commit.
src/ssdp/ssdp_ctrlpt.c: In function ‘SearchByTarget’:
src/ssdp/ssdp_ctrlpt.c:634: warning: format ‘%s’ expects type ‘char *’, but argument 6 has type ‘int’
2010-09-09 22:52:27 -03:00
Chandra Penke
2b3ab1799b Fix for regression in SSDP code to send/receive messages over UDP
Sending messages over UDP is broken in some Apple OSes
such as OS X and iOS. This might be broken in other OSes to but didn't
verify.

The fix is to modify the socket lenght argument of sendto to use the correct
sockaddr lenght dependng on whether the socket is IPV4 or IPV6.

Also added some error checks and debugging related to the issue
2010-09-09 22:52:26 -03:00
Marcelo Roberto Jimenez
4657e57766 Using UpnpReadHttpGet to download large files causes the application to
crash. This happens when the file being downloaded exceeds the device
memory - entirely possible when transferring video files.
The programmatic cause is that the logic implemented in the function
http_ReadHttpGet (which UpnpReadHttpGet calls) reads the entire file
into memory. The fix modifies the existing logic to discard data after
it's been read; there's no reason to keep it around since the caller
of UpnpReadHttpGet already has a copy of it.

This issue exists in 1.6.6 as well as the latest sources.

Patch submitted by Chandra (inactiveneurons).
2010-09-07 22:15:21 -03:00
Marcelo Roberto Jimenez
21660334e4 In the latest sources, http_RequestAndResponse and other methods that
use connect() are broken. More specifically, connect() in these methods
is returning with an EINVAL. The programatic cause is that the address_len
argument passed to connect() is different in IPV4 vs IPV6 (as described in:
http://www.opengroup.org/onlinepubs/009695399/functions/connect.html).
The current code always uses the IPV6 size. The fix modifies each use of
connect() to use the correct size based on the address family being used.

Patch submitted by Chandra (inactiveneurons).
2010-09-07 21:56:53 -03:00
Marcelo Roberto Jimenez
97af8b6fdb Fix compilation error in upnp/src/gena/gena_ctrlpt.c (this is most
likely an error on all platforms).

Patch submitted by Chandra (inactiveneurons).
2010-09-07 14:57:56 -03:00
Marcelo Roberto Jimenez
934bd2682f Fix compilation error in upnp/src/inc/ssdplib.h when compiling in OS X
(the netinet/* headers are not available).

Patch submitted by Chandra (inactiveneurons).
2010-09-07 14:51:38 -03:00
Marcelo Roberto Jimenez
b8e9628140 Fix compilation error in ixml/inc/ixml.h when compiling with an
Objective-C compiler (when cross-compiling for iPhone devices).

Patch submitted by Chandra (inactiveneurons).
2010-09-07 14:47:12 -03:00
Marcelo Roberto Jimenez
b3b7a91a64 White spaces. 2010-09-03 21:51:31 -03:00
Marcelo Roberto Jimenez
ebc941f265 Issue regarding the GENA notifications. A string termination indicator was added
at the end of the notification ("\r\n") in notify_send_and_recv() in
upnp/src/gena/gena_device.c.

Patch by Fabrice Fontaine.
2010-09-03 21:49:49 -03:00
Marcelo Roberto Jimenez
842a6ce5c8 Adding .gitignore. 2010-09-03 21:49:20 -03:00
Marcelo Roberto Jimenez
2d978c32b8 White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@581 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-22 02:10:50 +00:00
Marcelo Roberto Jimenez
e386dd0d68 The last part of Ronan Menard's patch.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@580 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-22 02:05:34 +00:00
Marcelo Roberto Jimenez
5a2cc884c1 * upnp/src/ssdp/ssdp_device.c: Fix for IPV6 ULA/GUA issues.
* upnp/src/ssdp/ssdp_ctrlpt.c: Fix for IPV6 ULA/GUA issues.
* upnp/src/ssdp/ssdp_server.c: Fix for IPV6 ULA/GUA issues.

Patch submitted by Ronan Menard.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@578 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-22 01:34:35 +00:00
Marcelo Roberto Jimenez
a362d06dff upnp/src/genlib/miniserver/miniserver.c: Fix for IPV6 ULA/GUA issues.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@576 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-21 22:13:26 +00:00
Marcelo Roberto Jimenez
0e73448ea8 * gena_subscribe(): Fix for IPV6 ULA/GUA issues.
Patch submitted by Ronan Menard.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@574 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-21 21:53:09 +00:00
Marcelo Roberto Jimenez
a7966b6597 * SOCKET ssdpSock6UlaGua: created variable for later use.
Patch submitted by Ronan Menard.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@572 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-21 21:40:00 +00:00
Marcelo Roberto Jimenez
2d5c6310a9 * SSDP_IPV6_SITELOCAL: new macro.
Patch submitted by Ronan Menard.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@569 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-21 21:31:55 +00:00
Marcelo Roberto Jimenez
c9bcee536e The scope of the macro NUM_HANDLE is now restricted to upnpapi.c.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@568 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-21 21:22:09 +00:00
Marcelo Roberto Jimenez
1605744278 * InitHandleList() has never been implemented, I guess no one has ever
called it, so remove it.
* GetFreeHandle() and FreeHandle() are now static as they should.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@566 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-21 21:10:50 +00:00
Marcelo Roberto Jimenez
ce0d2833a3 * New internal buffer added to store global/ula IPV6 address.
* Macros to test whether an IPV6 address is global or ula.
* UpnpGetServerUlaGuaIp6Address(): added interface.
* IN6_IS_ADDR_GLOBAL, IN6_IS_ADDR_ULA: new macros.
* gIF_IPV6_ULA_GUA: new buffer.
* UpnpRegisterRootDevice3(): Change to the test of already registered
devices for IPV6.
* UpnpGetIfInfo(): gua/ula issues.

Patch submitted by Ronan Menard.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@564 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-21 20:42:43 +00:00
Marcelo Roberto Jimenez
74db05ff1e English mispelling.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@562 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-19 13:54:44 +00:00
Marcelo Roberto Jimenez
9468e0224a libUPnP does support IPV6 now.
Patch submitted by Ronan Menard.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@560 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-19 13:48:17 +00:00
Marcelo Roberto Jimenez
cb89781a55 HTTP version equal to 1.0 should failed as required by the UPnP
certification tool. Patch submitted by Ronan Menard.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@558 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-19 13:27:50 +00:00
Marcelo Roberto Jimenez
3de0765893 Backport of svn rev 556:
SF Bug Tracker [ 3022490 ] String declaration fix for patch applied in 3007407
	Hello,

	When my patch for tracker ID 3007407 was accepted, the definition of the
	serviceList string was changed from

	#define SERVICELIST_STR "serviceList"

	to

	static const char *SERVICELIST_STR = "serviceList";

	During internal code review of the final patch, it was pointed out that 
	sizeof(SERVICELIST_STR) == 4 since SERVICELIST_STR is now declared as
	a pointer instead of an array.

	If you wish to use a variable instead of a define, I suggest the
	following instead:

	static const char SERVICELIST_STR[] = "serviceList";

	Thanks,
	Chuck Thomason



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@557 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-06-28 20:40:21 +00:00
Marcelo Roberto Jimenez
ce0e5b664f Backport of svn rev. 554:
Remove excessive 'dnl's from libupnp.m4.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@555 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-06-26 11:09:49 +00:00
Marcelo Roberto Jimenez
eec36896c3 2010-06-10 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
Backport of svn revision 552:
	SF Bug Tracker [ 3007407 ] Service traversal issue in AdvertiseAndReply()
	Submitted: Chuck Thomason ( cyt4 ) - 2010-05-26 15:07:39 UTC

	When the UPnP server is started, one alive message is broadcast for each
	service in each device. It appears that libupnp's implementation of the
	alive message generation does not correctly navigate the XML description
	document when locating the services. This can result in the wrong UDN
	being used in the alive message sent for a service.

	In my specific case (see attached XML), the root EchoSTB device contains
	no services, but its embedded MediaServer device contains 2 services.
	When the existing libupnp code traverses the EchoSTB device in the XML,
	it searches the global list of serviceLists within the document instead
	of searching for a serviceList that is its direct child node. The
	ContentDirectory and ConnectionManager services are then announced with
	the UDN of EchoSTB1 (the root device) instead of with the UDN of
	MediaServer, which is actually their parent device.

	I discovered this behavior using libupnp-1.6.6. I have generated a patch
	against branch-1.6.x that corrects the XML navigation such that all
	services are traversed from their parent device, which results in the
	correct UDN being sent in the alive message for each service. I built
	from branch-1.6.x without this patch, tested, and confirmed that the
	issue still exists as I observed it in libupnp-1.6.6. I then built
	from branch-1.6.x with this patch, tested, and confirmed that the
	issue was resolved.

	Thanks,
	Chuck Thomason



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@553 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-06-17 17:07:41 +00:00
Nick Leverton
00cf8052de Add PTHREAD_CFLAGS to Libs: in libupnp.pc, as assumed by acx_pthread.m4
(fixes binutils-gold link failure)


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@551 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-05-14 13:09:59 +00:00
Marcelo Roberto Jimenez
74b8730f0f SF Bug Tracker [ 2995758 ] libupnp 1.6.6, wrong bind when reuseaddr is 1.
Submitted: viallard anthony ( homer242 )
When trying to use reuseaddr option in miniserver/miniserver.c, there
isn't a affectation of the port chosen (serverAddr.sin_port isn't
receive listen_port variable value).




git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@548 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-05-07 11:07:26 +00:00
Marcelo Roberto Jimenez
1b45bec411 Backport of r544:
Define PROTOTYPES to be one by default in global.h. This affects the
RSA MD5 code.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@546 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-25 14:59:32 +00:00
Marcelo Roberto Jimenez
21163f491d Comment.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@541 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-25 12:04:48 +00:00
Marcelo Roberto Jimenez
a54e07bfb2 Code convergence for client_table (ClientSubscription).
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@539 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-25 08:47:37 +00:00
Marcelo Roberto Jimenez
0dea692199 Allow null pointer deletions in membuffer.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@538 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-25 00:47:37 +00:00
Marcelo Roberto Jimenez
dc457414d1 Adding UpnpString.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@537 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-25 00:44:34 +00:00
Nick Leverton
e1d09004eb Subscription auto-renewals copy the renewal time from old subscription.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@533 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-21 12:28:27 +00:00
Marcelo Roberto Jimenez
640fa8b1be Code base convergence.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@530 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-01 20:36:30 +00:00
Marcelo Roberto Jimenez
2bcbdffd89 1 - Ported some of IPV6 code to 1.6.7.
2 - Backport of svn revision 527:
* Added API to ithread, created the following functions:
- int ithread_initialize_library(void);
- int ithread_cleanup_library(void);
- int ithread_initialize_thread(void);
- int ithread_cleanup_thread(void);
* SF Bug Tracker [ 2876374 ] Access Violation when compiling with Visual Studio 2008
Submitted: Stulle ( stulleamgym ) - 2009-10-10 19:05

Hi,

I am one of the devs of the MorphXT project and I use this lib in some
other of my projects, too. When I tried to upgrade the lib earlier for one
of my projects I had to realise that something did not work at first and
while most of the things were reasonably ease to be fixed. Now, the last
thing I encountered was not so easy to fix and I am uncertain if my fix is
any good so I'll just post it here and wait for some comments.

The problem was that I got an Access Violation when calling "UpnpInit". It
would call "ithread_rwlock_init(&GlobalHndRWLock, NULL)" which eventually
led to calling "pthread_cond_init" and I got the error notice at
"EnterCriticalSection (&ptw32_cond_list_lock);". It appeared that
"ptw32_cond_list_lock" was NULL. Now, I found two ways to fix this. Firstly
moving the whole block after at least one of the "ThreadPoolInit" calls
will fix the issue. Secondly, you could add:
#ifdef WIN32
#ifdef PTW32_STATIC_LIB
// to get the following working we need this... is it a good patch or
not... I do not know!
pthread_win32_process_attach_np();
#endif
#endif
right before "ithread_rwlock_init(&GlobalHndRWLock, NULL)".

Just so you know, I am using libupnp 1.6.6 and libpthreads 2.8.0 and both
are linked static into the binaries. I am currently using Visual Studio
2008 for development with Windows being the target OS. Any comment at your
end?

Regards, Stulle



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@529 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-31 17:53:16 +00:00
Marcelo Roberto Jimenez
6c8a4dd361 SF Patch Tracker [ 2836704 ] Patch for Solaris10 compilation and usage.
Submitted By: zephyrus ( zephyrus00jp )
This second part covers the issue on linking with -lsocket -lnsl -lrt.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@525 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-27 14:45:47 +00:00
Marcelo Roberto Jimenez
e9941f7ac8 UTF-8 stuff.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@524 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-27 14:41:25 +00:00
Marcelo Roberto Jimenez
5a465a5cf2 White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@523 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-22 09:08:15 +00:00
Marcelo Roberto Jimenez
6aa2419cfd SF Bug Tracker [ 2392166 ] ithread_detach not called for finished worker thread
Submitted: Ulrik ( ulsv_enea ) - 2008-12-05 08:24

	Valgrind reports a memory leak due to that the function ithread_detach is
	not called for finished worker threads in ThreadPool.c.

	==21137== 2,176 bytes in 8 blocks are possibly lost in loss record 5 of 5
	==21137== at 0x4C20F3F: calloc (vg_replace_malloc.c:279)
	==21137== by 0x4010F58: _dl_allocate_tls (in /lib/ld-2.6.1.so)
	==21137== by 0x544BA92: pthread_create@@GLIBC_2.2.5 (in
	/lib/libpthread-2.6.1.so)
	==21137== by 0x5F94592: CreateWorker (ThreadPool.c:639)
	==21137== by 0x5F95079: ThreadPoolInit (ThreadPool.c:784)

	I'm using libupnp 1.6.6

	For more info on pthread_detach, see:
	http://gelorakan.wordpress.com/2007/11/26/pthead_create-valgrind-memory-lea
	k-solved/



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@520 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 22:41:49 +00:00
Marcelo Roberto Jimenez
712ed6d2ff SF Bug Tracker [ 2392304 ] Memory leak in SSDP AdvertiseAndReply
Submitted: Ulrik ( ulsv_enea ) - 2008-12-05 08:24

	Valgrind reports a memory leak function in AdvertiseAndReply
	(ssdp/ssdp_server.c) in libupnp 1.6.6

	There are continue statements in many places in AdvertiseAndReply. In some
	of those error handling cases the variable nodelist is not free'ed before
	continuing to the next iteration. The next iteration will take care of
	free'ing the nodelist from the previous iteration in most cases, but not
	when breaking out of the for loop after the last element.

	I belive this memory leak can be solved by makeing sure that the rows

	ixmlNodeList_free( nodeList );
	nodeList = NULL;

	are always executed, also in the beginning of the last iteration when we
	found out that there are not more elements.

	==29110== at 0x4C21C16: malloc (vg_replace_malloc.c:149)
	==29110== by 0x5D8DE0E: ixmlNodeList_addToNodeList (nodeList.c:106)
	==29110== by 0x5D8B7E2: ixmlNode_getElementsByTagNameRecursive
	(node.c:1438)
	==29110== by 0x5D8E587: ixmlElement_getElementsByTagName
	(element.c:491)
	==29110== by 0x5B6C0F1: AdvertiseAndReply (ssdp_server.c:201)
	==29110== by 0x5B7AB74: UpnpSendAdvertisement (upnpapi.c:1495)



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@518 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 21:19:13 +00:00
Marcelo Roberto Jimenez
53d5e61b33 Thanks update.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@517 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 19:53:20 +00:00
Marcelo Roberto Jimenez
324931ca8f Backport of svn revision 514:
libupnp and multi-flows scenario patch
	Submited by Carlo Parata from STMicroelectronics.
Hi Roberto and Nektarios,
after an analysis of the problem of libupnp with a multi-flows scenario, I
noticed that the only cause of the freezed system is the ThreadPool
management. There are not mutex problems. In practise, if all threads in the
thread pool are busy executing jobs, a new worker thread should be created if
a job is scheduled (I inspired to tombupnp library). So I solved the problem
with a little patch in threadutil library that you can find attached in this
e-mail. I hope to have helped you.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@515 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 19:51:18 +00:00
Marcelo Roberto Jimenez
edc0638640 Backport of svn revision 512:
Style compatibilization between two similar constructions addressed in two
separate recent patches.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@513 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 17:07:09 +00:00
Marcelo Roberto Jimenez
e1ea72a5fb Backport of svn revision 510:
SF Patch Tracker [ 2964973 ] install: will not overwrite just-created
	...blah... with...
	Submitted: Nick Leverton ( leveret ) - 2010-03-07 05:18

	Full error:
	/usr/bin/install: will not overwrite just-created
	`/tmp/buildd/libupnp-1.6.6/debian/tmp/usr/share/doc/libupnp3-dev/examples/s
	ample_util.c' with `common/sample_util.c'

	This seems to be from Automake 1.11 which doesn't like having duplicate
	files in a Makefile.am. Patch attached, kindly provided by Stefan Potyra
	for Debian (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=543068)

	This fix will be needed for both 1.6.x and 1.8.x branches.




git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@511 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 16:13:59 +00:00
Marcelo Roberto Jimenez
5eb55e0fb2 Backport of svn revision 504:
SF Patch Tracker [ 2969188 ] 1.8.0: patch for FreeBSD compilation
	Submitted By: Nick Leverton (leveret)
	Fix the order of header inclusion for FreeBSD.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@509 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 15:42:40 +00:00
Marcelo Roberto Jimenez
9226dd833b SF Patch Tracker [ 2836704 ] Patch for Solaris10 compilation and usage.
Submitted By: zephyrus ( zephyrus00jp )
	Obs by Marcelo: The issue with linking with -lsocket -lnsl -lrt is not
	covered in this changeset beacuse I don't have solaris to test. I will
	need some help from zephyrus in this regard. The issue will be addressed
	in a future changeset.

	Compilation for solaris

	I have used gcc3.x and gcc4.x under solaris 10 for x86 / 64 bits.

	A couple of Source file fixes were necessary for successful compilation
	and runtime behavior.

	threadutil/src/ThreadPool.c

	POSIX
	sched_setschduler() returns non-negative value for success.

	Without the fix, UpnpInit() fails immediately.

	upnpp/src/api/upnpai.c

	There is a typo of a macro name "__sun" in one of the
	CPP conditional.
	Without the fix, the compilation aborts due to unknown constant
	in socket ioctl call.

	A few structs and an array is not properly initialized.
	Well, I think it may be safe as is, but when I checked it
	using purify evaluation version, it was reported that
	uninitizlied iszBuffer may cause read of uninitialized memory.
	So play it safe.

	Configure issue.
	This has to be more of a configure magic.
	To link a program successfully using network, we need
	-lsocket and -lnsl library specifications on the link line.
	We also need -lrt for programs that use thread scheduling features.

	The sample program under upnp/sample requires
	-lsocket -lnsl -lrt
	for successful linking.
	I added -lsocket -lnsl -lrt to Makefile.in.
	configure probably needs to take care of these.

	I don't know much about configure, automake, etc., so
	I am just raising a flag here.

	TIA



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@505 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 11:47:17 +00:00
Marcelo Roberto Jimenez
25c908c558 SF Patch Tracker [ 2836704 ] Search for nested serviceList (not
stopping at the first lis
	Submitted By: zephyrus ( zephyrus00jp )
	
	Internet Gateway Device description contains nested serviceList (rootdevice
	-> servicelist, subdevice
	and subdevice has the lower-level serviceList, etc..)

	Unfrotunately, the sample code sample_util.c used by tv_device sample,
	etc.
	has a code that looks for only the first top-level serviceList.
	This results in the failure to read all the services of an IGD xml
	description.

	Attached patch modifies this behavior and looks for the service by
	visiting all the serviceList in xml document in turn.

	With the modified patch (ad additional modification), I could
	simulate an IGD device and created a modified control program for that.

	Patch against 1.6.6

	TIA.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@502 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-20 21:32:38 +00:00
Marcelo Roberto Jimenez
16e91b5dcc Backport of svn revision 497:
* SF Patch Tracker [ 2203721 ] timeb.h check obsolete



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@498 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-15 23:51:09 +00:00
Marcelo Roberto Jimenez
01d17e5c4b Backport of svn revision 495:
* SF Patch Tracker [ 2970872 ] Update ErrorMessages for latest return
	code list
	Submitted By: Nick Leverton ( leveret )
	
	ErrorMessage[] in upnptools.c has got a bit out of sync, the attached
	patch (generated from grep 'define UPNP_E_') should bring it up to date.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@496 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-15 23:39:48 +00:00
Marcelo Roberto Jimenez
a1d707ac81 Backport of svn revision 493: Declare a few functions to have proper
(void) argument list.

	* SF Patch Tracker [ 2857611 ] Declare a few functions to have proper
	(void) argument list.
	Submitted By: zephyrus ( zephyrus00jp )
	
	In a publicly installed headers, a few functions are declared without any
	arguments at all, a la "()".
	When I used gcc's -Wimplict and -Wstrict-prototypes to check for the
	mismatch of
	function prototype declarations and their usage in my own program,
	some headers from libupnp-1.6.6 produced warnings.

	They are not strictly bugs, but pretty much annoying. This is 2009, and
	almost all the important compilers
	understand ISO-C.

	So the offending functions are declared as "(void") to show that they have
	no arguments at all.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@494 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-15 15:34:54 +00:00
Marcelo Roberto Jimenez
4ad6ea3545 Backport of svn revision 484:
SF Patch Tracker [ 2546532 ] Missing carriage return between
    	SOAPACTION and User-Agent headers.
    
    	There is something going wrong in soap_ctrlpt.c at line 931 (based on
    	version 1.6.6 release).
    
    	The http_Makemessage call looks as follows:
    
    	if (http_MakeMessage(
    	&request, 1, 1,
    	"Q" "sbc" "N" "s" "s" "Ucc" "sss",
    	SOAPMETHOD_POST, path.buf, path.length,
    	"HOST: ", host.buf, host.length,
    	content_length,
    	ContentTypeHeader,
    	"SOAPACTION:
    	\"urn:schemas-upnp-org:control-1-0#QueryStateVariable\"",
    	xml_start, var_name, xml_end ) != 0 ) {
    	return UPNP_E_OUTOF_MEMORY;
    	}
    
    	This will result in the SOAPACTION header to be immediately followed by the
    	User-Agent header, while a cr-lf should separate the two. I propose to fix
    	this by changing the second "s" to "sc" to force the addition of a cr-lf
    	after the SOAPACTION. This looks consistent to the other Makemessage calls.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@487 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-14 18:53:12 +00:00
Marcelo Roberto Jimenez
70a0aff4e7 Backport of svn revision 482:
wrong order in parameters corrected


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@486 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-14 18:38:31 +00:00
Marcelo Roberto Jimenez
aaacf65f41 Do not use C++ like comments. Some compilers don't like it.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@481 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-08-14 12:06:22 +00:00
Marcelo Roberto Jimenez
cd8ce90e19 Backport of svn rev. 479: Fix for application compiler warning: "PRId64" redefined.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@480 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-08-14 12:02:20 +00:00
Marcelo Roberto Jimenez
812d019d12 Backport of ixml from 1.8.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@478 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-27 05:01:52 +00:00
Marcelo Roberto Jimenez
881b212690 Backport of svn 371: Removing the useless, unused and undocumented function UpnpFree().
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@477 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-27 03:31:07 +00:00
Marcelo Roberto Jimenez
223c0e8816 Backport of Doxyfile.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@476 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-27 03:11:28 +00:00
Marcelo Roberto Jimenez
ceca478180 Backport of most of upnp.h with documentation.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@475 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-27 03:06:21 +00:00
Marcelo Roberto Jimenez
7963e97469 Backport of svn 367: Removing dead code.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@471 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-26 12:24:24 +00:00
Marcelo Roberto Jimenez
0080c080cd Update of win32 files.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@470 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-25 04:21:11 +00:00
Marcelo Roberto Jimenez
405451e34c Backport of svn 468: Added upnp/m4/libupnp.m4 to the distribution tarball.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@469 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-25 04:11:17 +00:00
Marcelo Roberto Jimenez
a772b1a754 Backport of svn 403: Bob Ciora's patch for "UpnpCreatePropertySet can leak memory".
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@466 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-25 03:42:30 +00:00
Marcelo Roberto Jimenez
ffc4668e0b Backport of 406: Updating Makefile.am for missing files in the "make dist" tarball.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@465 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-25 03:35:12 +00:00
Marcelo Roberto Jimenez
56a7f038dc Changelog update for a fixed bug of a missing HandleUnlock() that went in
in one of the latest comitts.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@463 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-25 03:25:42 +00:00
Marcelo Roberto Jimenez
3ba4e34662 Added ixmldebug and UpnpGlobal.h to the 1.6.x branch.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@462 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-25 03:22:35 +00:00
Marcelo Roberto Jimenez
515233ca56 Backport of svn 395 and 434:
395: Bob Ciora's patch for lazy UpnpAcceptSubscription().
434: Fixed a buffer overflow due to a bug in the calculation of the
     CONTENT-TYPE header line size, the length was beeing calculated with
     the wrong string, there was a missing colon.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@461 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-25 02:56:04 +00:00
Marcelo Roberto Jimenez
423808a095 Backport of svn 453: Andre Sodermans (wienerschnitzel) patch for building
libupnp under windows systems with VC8/VC9.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@460 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-24 11:40:33 +00:00
Marcelo Roberto Jimenez
f22a69b487 Backport of 457: SF Bug Tracker [ 2026431 ] pupnp does not build on GNU/KfreeBSD.
Submitted By: Nick Leverton - leveret
	Gnu/KFreeBSD is one of the Debian architectures, it includes a FreeBSD
	kernel with GNU userspace (glibc etc). The Gnu/KfreeBSD developers
	provided the attached patch to test the appropriate #define and allow pupnp
	to build in their environment, and asked me to forward it to you.

	Since the test is a simple check for defined(__GLIBC__), this would
	presumably also help with other ports of GNU libc to non-Linux kernels.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@458 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-24 11:30:42 +00:00
Marcelo Roberto Jimenez
bcf5a5c5e0 Backport: Debug code for http_RecvMessage().
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@450 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-10 04:15:36 +00:00
Marcelo Roberto Jimenez
e0c9de0b1d Backport: Added an m4 macro to deal with finding libupnp in the users'
configure script.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@449 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-10 04:02:16 +00:00
Marcelo Roberto Jimenez
94e4a3bdda Fix in function SetSeed() in threadutil/src/ThreadPool.c for CYGWIN
compilation. Thanks to Gary Chan.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@355 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-04-29 15:42:18 +00:00
Marcelo Roberto Jimenez
b7b3bb7d05 Homekeeping for the next release.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@354 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-04-29 15:38:35 +00:00
Marcelo Roberto Jimenez
f0161c7274 Merge of trunk into branch 1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@351 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-04-26 00:49:39 +00:00
Marcelo Roberto Jimenez
4b40e94b03 Merge of trunk into branch 1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@339 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-03-25 10:21:08 +00:00
Marcelo Roberto Jimenez
1c9632dcc3 White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@329 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-03-05 03:55:33 +00:00
Marcelo Roberto Jimenez
cc0c2ffc50 Merge of trunk into branch-1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@327 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-02-22 04:48:10 +00:00
Marcelo Roberto Jimenez
f812b124d7 Merge of trunk into branch-1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@324 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-02-10 02:27:45 +00:00
Marcelo Roberto Jimenez
a785465222 Merge of trunk into branch-1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@322 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-02-08 02:29:26 +00:00
Marcelo Roberto Jimenez
078f3f8faf Merge of trunk into branch 1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@312 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-02-03 01:36:23 +00:00
Marcelo Roberto Jimenez
1eeaf99b83 Merge of trunk into branch-1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@306 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-01-27 02:13:08 +00:00
Marcelo Roberto Jimenez
f6dd5062fe Merge of trunk into branch-1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@284 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-27 02:14:02 +00:00
Marcelo Roberto Jimenez
7d4a610b93 Merge of head into branch-1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@265 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-10 23:18:38 +00:00
Marcelo Roberto Jimenez
0a074d1989 Merge of trunk into branch 1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@263 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-10 22:56:56 +00:00
Marcelo Roberto Jimenez
0475a46680 Merge of current trunk to branch 1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@251 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-19 14:15:45 +00:00
Marcelo Roberto Jimenez
2a76749682 Creating branch 1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@210 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-06-23 14:23:29 +00:00
93 changed files with 4290 additions and 6700 deletions

104
.gitignore vendored Normal file
View File

@@ -0,0 +1,104 @@
#
# NOTE! Don't add files that are generated in specific
# subdirectories here. Add them in the ".gitignore" file
# in that subdirectory instead.
#
# NOTE! Please use 'git ls-files -i --exclude-standard'
# command after changing this file, to see if there are
# any tracked files which get ignored after the change.
#
# Normal rules
#
.*
*.o
*.o.*
*.a
*.s
*.ko
*.so
*.so.dbg
*.mod.c
*.i
*.lst
*.symtypes
*.order
modules.builtin
*.elf
*.bin
*.gz
*.bz2
*.lzma
*.patch
*.gcno
#
# Top-level generic files
#
/tags
/TAGS
/linux
/vmlinux
/vmlinuz
/System.map
/Module.markers
/Module.symvers
#
# git files that we don't want to ignore even it they are dot-files
#
!.gitignore
!.mailmap
#
# Generated include files
#
include/config
include/linux/version.h
include/generated
# stgit generated dirs
patches-*
# quilt's files
patches
series
# cscope files
cscope.*
ncscope.*
# gnu global files
GPATH
GRTAGS
GSYMS
GTAGS
*.orig
*~
\#*#
*.lo
*.la
Makefile
Makefile.in
aclocal.m4
autoconfig.h
autoconfig.h.in
autom4te.cache/
build-aux/
config.log
config.status
configure
libtool
libupnp.pc
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
stamp-h1
upnp/inc/stamp-h2
upnp/inc/upnpconfig.h
upnp/sample/upnp_tv_combo
upnp/sample/upnp_tv_ctrlpt
upnp/sample/upnp_tv_device

402
ChangeLog
View File

@@ -1,221 +1,195 @@
*******************************************************************************
Version 1.8.0
*******************************************************************************
2010-08-22 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* upnp/src/api/Discovery.c: Fix a serious bug and memory leak in
UpnpDiscovery_strcpy_DeviceType(). Thanks to David Blanchet for the
patch.
2010-04-25 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
Separation of the ClientSubscription object.
2010-04-24 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
Protect the object destructors agains null pointers on deletion, which
should be something valid.
2010-03-27 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
SF Patch Tracker [ 2987390 ] upnp_debug vs. ixml_debug
Thanks for the load of updates, I'm still assimilating them ! Could I make
a suggestion though? The addition of printNodes(IXML_Node) to upnpdebug a
dds a new dependency on ixml.h for anything using upnpdebug.h. I'm making
quite a bit of use of upnpdebug in porting things to version 1.8.0, and I'd
prefer it if printNodes could be added to ixmldebug.h instead. I'm attach
ing a patch, what do you think ?
Nick
2010-03-27 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Forward port of svn revision 505:
SF Patch Tracker [ 2836704 ] Patch for Solaris10 compilation and usage.
Submitted By: zephyrus ( zephyrus00jp )
2010-03-20 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* SF Patch Tracker [ 2969188 ] 1.8.0: patch for FreeBSD compilation
Submitted By: Nick Leverton (leveret)
Fix the order of header inclusion for FreeBSD.
2010-03-20 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Forward port of svn revision 502:
SF Patch Tracker [ 2836704 ] Search for nested serviceList (not
stopping at the first lis
Submitted By: zephyrus ( zephyrus00jp )
Internet Gateway Device description contains nested serviceList (rootdevice
-> servicelist, subdevice
and subdevice has the lower-level serviceList, etc..)
Unfrotunately, the sample code sample_util.c used by tv_device sample,
etc.
has a code that looks for only the first top-level serviceList.
This results in the failure to read all the services of an IGD xml
description.
Attached patch modifies this behavior and looks for the service by
visiting all the serviceList in xml document in turn.
With the modified patch (ad additional modification), I could
simulate an IGD device and created a modified control program for that.
Patch against 1.6.6
TIA.
2010-03-20 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* SF Patch Tracker [ 2973319 ] Problem in commit 499
Submitted By: Nick Leverton (leveret)
Afraid that this doesn't compile, it seems retval should be retVal in two
places.
2010-03-16 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Fix for the ithread_mutex_unlock() logic in UpnpInit().
Thanks for Nicholas Kraft.
2010-03-15 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* SF Patch Tracker [ 2962606 ] Autorenewal errors: invalid SID,
too-short renewal interval
Submitted By: Nick Leverton (leveret)
Auto-renewals send an invalid SID due to a missing UpnpString_get_String
call. They also send a renewal interval of 0 instead of copying it from
the original subscription.
2010-03-15 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* SF Patch Tracker [ 2964685 ] patch for avoiding inet_ntoa (1.8.0)
Submitted By: Nick Leverton (leveret)
Seems like SF's tracker won't let me add a patch to someone else's issue ?!
This refers to https://sourceforge.net/support/tracker.php?aid=2724578
The calls to inet_ntoa are in getlocalhostname(), which is called from
UpnpInit when it is returning the bound IP address.
UpnpInit/getlocalhostname hasn't been updated to IPv6, I presume this is
deliberate so that it doesn't start returning IPv6 addresses and
overwriting the caller's IPv4-sized allocation.
The attached patch just updates getlocalhostname to use inet_ntop instead
of inet_ntoa, and also documents the fact that UpnpInit is IPv4 only whilst
UpnpInnit2 is both IPv4 and IPv6.
A fuller solution might be to change UpnpInit to use some variant on
UpnpGetIfInfo. UpnpInit could still be left as IPv4 only if desired -
perhaps UpnpGetIfInfo could take an option for the desired address family.
getlocalhostname and its own copy of the interface scanning code would then
be redundant. I don't have IPv6 capability here though so I'm reluctant to
change the IPv6 code, as I have no way to test it.
2010-03-15 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* SF Patch Tracker [ 2724578 ] patch for avoiding memory leaks when
add devices
each time a device been added, UpnpInit() is called, on exit, UpnpFinish()
is called, but the memories allocated by ThreadPoolInit() may lost because
there's no code to call ThreadPoolShutdown() to release the memories. And
inet_ntoa() is not thread safe, so in my patch, I substitute inet_ntoa()
with inet_ntop().
2010-03-14 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* SF Patch Tracker [ 2964687 ] Add new string based accessors to upnp
object API
As per email to pupnp-devel, this is the patch to add the _strget_
accessors for string-like objects in the interface.
Will add a further patch shortly to udpate the sample programs.
2008-06-27 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Nicholas Kraft's patch to fix some IPv6 copy/paste issues. He
reported to be getting infinite loops with the svn code.
2008-06-13 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* SF Bug Tracker [ 1984541 ]
ixmlDocumenttoString does not render the namespace tag.
Submitted By: Beliveau - belivo
Undoing the patch that fixed this problem. In fact, there was no
problem and the patch was wrong.
2008-06-11 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Ingo Hofmann's patch for "Content-Type in Subscription responses".
Adds charset="utf-8" attribute to the CONTENT-TYPE header line.
Hi,
I have found an inconsistency regarding the text/xml content-type
returned by libupnp. It looks like only subscription responses send
"text/xml" where all other messages contain "text/xml; charset="utf-8"".
Since I'm working on an DLNA device the latter behaviour is mandatory.
I changed the according lines in gena_device.c (see attached patch).
I'm not sure if it would be ok for other device to have the charset
field but it would help me a lot :)
Best regards,
Ingo
2008-06-04 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* SF Bug Tracker [ 1984541 ]
ixmlDocumenttoString does not render the namespace tag.
Submitted By: Beliveau - belivo
The problem occurs when converting a xml document using
ixmlDocumenttoString containing a namespace tag created with
ixmlDocument_createElementNS. The namespace tag doesn't get rendered.
example: The following code fragment prints:
<?xml version="1.0"?>
<root></root>
instead of:
<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0"></root>
Code:
#include <stdlib.h>
#include <upnp/ixml.h>
int main()
{
IXML_Document* wDoc = ixmlDocument_createDocument();
IXML_Element* wRoot = ixmlDocument_createElementNS(wDoc,
"urn:schemas-upnp-org:device-1-0", "root");
ixmlNode_appendChild((IXML_Node *)wDoc,(IXML_Node *)wRoot);
DOMString wString = ixmlDocumenttoString(wDoc);
printf(wString);
free(wString);
ixmlDocument_free(wDoc);
return 0;
}
The problem was in the printing routine, not in the library data
structure.
2008-05-31 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Charles Nepveu's suggestion of not allocating a thread for
MiniServer when it is not compiled.
2008-05-24 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Ported Peter Hartley's patch to compile with mingw.
2008-05-24 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Added some debug capability to ixml.
2008-05-02 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Merged Charles Nepveu's IPv6 work. libupnp now is IPv6 enabled.
2008-02-06 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Breaking API so that we now hide internal data structures.
2008-02-06 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Rewrote Peter Hartley's patch to include a new extra header field in
FileInfo.
*******************************************************************************
Version 1.6.7
*******************************************************************************
2010-10-01 Fabrice Fontaine <fabrice.fontaine(at)orange-ftgroup.com>
Adding --disable-notification-reordering option
Adding a configure flag to disable GENA notification reordering as even
with an imillisleep(1), this mechanism consumes too much CPU on embedded
devices when there is a burst of notifications.
2010-09-30 Fabrice Fontaine <fabrice.fontaine(at)orange-ftgroup.com>
Bug fix when there is no service in embedded devices
When a device with embedded devices (like IGD) when created and one of
the embedded devices did not have any service, there was a Segmentation
Fault (see SF Tracker [ 2688125 ]).
Original SF Tracker issue follows:
SF Tracker [ 2688125 ] v1.6.6 crashes on subdevices without services
Submitted by: Arno Willig ( akw ) - 2009-03-15 22:45:23 BRT
I discovered a bug, which will make libupnp (1.6.6) segfault, when you
create a upnp description document with multiple devices which have
subdevices, but no own services.
The crash occurs in genlib/service_table.c in line 977:
end->next =
getServiceList( currentDevice, &next_end, URLBase );
In this case "end" seems not to be defined, so end->next crashes.
Can anyone confirm this, please?
2010-09-28 Marc Essayan <marc.essayan(at)orange-ftgroup.com>
Bug fix on burst of GENA notification
When a lot of notifications were generated by a device in a short
period of time then 100% of the CPU was used to reorder those
notifications by pushing back the thread in the job queue. This
mechanism has been modified so now thread sleep 1 ms before being
pushed back into the job queue.
Removing DEFAULT_SCHED_PARAM parameter and use
sched_get_priority_min(DEFAULT_POLICY) instead.
2010-09-22 Fabrice Fontaine <fabrice.fontaine(at)orange-ftgroup.com>
Bug fix on M-SEARCH response
Devices must respond to M-SEARCH requests for any supported version and the
response should specify the same version as was contained in the search target.
Previously, the device did not answer if the M-SEARCH request did not
contain the same version number than the version number of the device.
2010-09-21 Fabrice Fontaine <fabrice.fontaine(at)orange-ftgroup.com>
Add Content-Language iff Accept-Language
Add Content-Language header in the response if and only if there is an
Accept-Language header in the request.
2010-09-21 Fabrice Fontaine <fabrice.fontaine(at)orange-ftgroup.com>
Addition of WEB_SERVER_CONTENT_LANGUAGE parameter
This patch adds the WEB_SERVER_CONTENT_LANGUAGE parameter so the user can specify
the language used by the device during Description and Presentation steps of UPnP
through the HTTP CONTENT-LANGUAGE header.
By default, the WEB_SERVER_CONTENT_LANGUAGE is an empty string so no
CONTENT-LANGUAGE is added.
2010-09-18 Fabrice Fontaine <fabrice.fontaine(at)orange-ftgroup.com>
Customize the stack size of the threads used by pupnp through the new
THREAD_STACK_SIZE variable.
This patch allows a user to customize the stack size of the threads used by
pupnp through the new THREAD_STACK_SIZE variable. This is especially useful
on embedded systems with limited memory where the user can set THREAD_STACK_SIZE
to ITHREAD_STACK_MIN.
However, as this modification can have side effects, I set 0 as the default
value, so threads will continue to use the default stack size of the system
(which varies greatly as stated in
https://computing.llnl.gov/tutorials/pthreads/).
2010-09-16 Fabrice Fontaine <fabrice.fontaine(at)orange-ftgroup.com>
Broken IPv6.
IPv6 is currently broken in latest release of branch-1.6.x, so find a
patch attached that correct the issue (small fixes on define, undef and
retVal).
2010-09-10 Warwick Harvey <warwick.harvey(at)tieto.com>
Patch to take notice of UPNP_USE_RWLOCK flag
The configure.ac file included with UPnP checks for the presence of the
pthread_rwlock_t type, and then sets the value of the UPNP_USE_RWLOCK
flag appropriately. However, this flag is not referenced at all in the
source code, and thus the code does not compile on systems that don't
have the pthread_rwlock_t type (such as Android).
Please find attached a patch (against the current 1.6.x head) that checks
the value of this flag and falls back on using mutexes if read-write
locks are not available.
2010-09-10 Jean Sigwald <jean.sigwald(at)orange-ftgroup.com>
I discovered a reliable denial-of-service issue on the last stable
release of libupnp (1.6.6) remotely triggerable by any
unauthenticated user. The issue is related with a bad parsing of
malformed XML.
2010-09-10 Chandra Penke <chandrapenke(at)mcntech.com>
* SF Patch Tracker [ 2854711 ] Patch for Solaris10 compilation and usage
Submitted By: zephyrus ( zephyrus00jp )
Patch for Solaris10 compilation and usage.
2010-09-10 Chandra Penke <chandrapenke(at)mcntech.com>
Add support for conditionally enabling ipv6.
2010-09-10 Chandra Penke <chandrapenke(at)mcntech.com>
Fix for compilation in debug builds.
Ensure internal methods are declared as static since debug builds don't inline.
2010-09-09 Chandra Penke <chandrapenke(at)mcntech.com>
Fix for regression in SSDP code to send/receive messages over UDP
Sending messages over UDP is broken in some Apple OSes
such as OS X and iOS. This might be broken in other OSes to but didn't
verify.
The fix is to modify the socket lenght argument of sendto to use the correct
sockaddr lenght dependng on whether the socket is IPV4 or IPV6.
Also added some error checks and debugging related to the issue
2010-09-07 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
Using UpnpReadHttpGet to download large files causes the application to
crash. This happens when the file being downloaded exceeds the device
memory - entirely possible when transferring video files.
The programmatic cause is that the logic implemented in the function
http_ReadHttpGet (which UpnpReadHttpGet calls) reads the entire file
into memory. The fix modifies the existing logic to discard data after
it's been read; there's no reason to keep it around since the caller
of UpnpReadHttpGet already has a copy of it.
This issue exists in 1.6.6 as well as the latest sources.
Patch submitted by Chandra (inactiveneurons).
2010-09-07 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
In the latest sources, http_RequestAndResponse and other methods that
use connect() are broken. More specifically, connect() in these methods
is returning with an EINVAL. The programatic cause is that the address_len
argument passed to connect() is different in IPV4 vs IPV6 (as described in:
http://www.opengroup.org/onlinepubs/009695399/functions/connect.html).
The current code always uses the IPV6 size. The fix modifies each use of
connect() to use the correct size based on the address family being used.
Patch submitted by Chandra (inactiveneurons).
2010-09-07 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
Fix compilation error in upnp/src/gena/gena_ctrlpt.c (this is most
likely an error on all platforms).
Patch submitted by Chandra (inactiveneurons).
2010-09-07 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
Fix compilation error in upnp/src/inc/ssdplib.h when compiling in OS X
(the netinet/* headers are not available).
Patch submitted by Chandra (inactiveneurons).
2010-09-07 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
Fix compilation error in ixml/inc/ixml.h when compiling with an
Objective-C compiler (when cross-compiling for iPhone devices).
Patch submitted by Chandra (inactiveneurons).
2010-08-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Issue regarding the GENA notifications. A string termination indicator
was added at the end of the notification ("\r\n") in
notify_send_and_recv() in upnp/src/gena/gena_device.c.
Patch by Fabrice Fontaine.
2010-08-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* The last part of Ronan Menard's patch.

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.8.0
PROJECT_NUMBER = 1.6.7
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.

View File

@@ -1,7 +1,7 @@
#
# Top-level "Makefile.am" for libupnp
#
# Copyright (C) 2005 R<EFBFBD>mi Turboult <r3mi@users.sourceforge.net>
# Copyright (C) 2005 Rémi Turboult <r3mi@users.sourceforge.net>
#
ACLOCAL_AMFLAGS = -I m4

2
README
View File

@@ -1,7 +1,7 @@
Portable SDK for UPnP* Devices (libupnp)
Copyright (c) 2000-2003 Intel Corporation - All Rights Reserved.
Copyright (c) 2005-2006 R<EFBFBD>mi Turboult <r3mi@users.sourceforge.net>
Copyright (c) 2005-2006 Rémi Turboult <r3mi@users.sourceforge.net>
Copyright (c) 2006 Michel Pfeiffer and others <virtual_worlds@gmx.de>
See LICENSE for details.

2
THANKS
View File

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

11
TODO
View File

@@ -18,13 +18,12 @@ http://sourceforge.net/tracker/?group_id=7189&atid=307189
- make API clean for large files and 64 bits
- Why is NUM_HANDLE defined to 200 when we can register only:
A) One client(1)
B) An IPv4 and IPv6 device (2)
NUM_HANDLE should be 3
- A sane way to implement the virtual directory callback initialization and checking
against NULL pointers.
To Be Decided
=============
- IPV6 support ?

View File

@@ -82,14 +82,11 @@
/* 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 1 to prevent compilation of assert() */
/* #undef NDEBUG */
#define NDEBUG 1
/* Define to 1 to prevent some debug code */
/* #undef NO_DEBUG */
#define NO_DEBUG 1
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
/* #undef NO_MINUS_C_MINUS_O */
@@ -104,13 +101,13 @@
#define PACKAGE_NAME "libupnp"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "libupnp 1.8.0"
#define PACKAGE_STRING "libupnp 1.4.7"
/* 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.8.0"
#define PACKAGE_VERSION "1.4.7"
/* Define to necessary symbol if this constant uses a non-standard name on
your system. */
@@ -123,7 +120,7 @@
#define UPNP_HAVE_CLIENT 1
/* see upnpconfig.h */
#define UPNP_HAVE_DEBUG 1
/* #undef UPNP_HAVE_DEBUG */
/* see upnpconfig.h */
#define UPNP_HAVE_DEVICE 1
@@ -134,23 +131,20 @@
/* 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 8
#define UPNP_VERSION_MINOR 4
/* see upnpconfig.h */
#define UPNP_VERSION_PATCH 0
#define UPNP_VERSION_PATCH 7
/* see upnpconfig.h */
#define UPNP_VERSION_STRING "1.8.0"
#define UPNP_VERSION_STRING "1.4.7"
/* Version number of package */
#define VERSION "1.8.0"
#define VERSION "1.4.7"
/* File Offset size */
#define _FILE_OFFSET_BITS 64
@@ -170,5 +164,5 @@
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */
/* Type for storing the length of struct sockaddr */
/* Substitute for socklen_t */
/* #undef socklen_t */

View File

@@ -29,7 +29,6 @@
*
**************************************************************************/
#ifndef INTERNAL_CONFIG_H
#define INTERNAL_CONFIG_H
@@ -112,6 +111,24 @@
/* @} */
/*!
* \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
@@ -175,6 +192,20 @@
#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
*
@@ -395,17 +426,9 @@
#endif
#ifdef INCLUDE_CLIENT_APIS
# define CLIENTONLY(x) x
#else /* INCLUDE_CLIENT_APIS */
# define CLIENTONLY(x)
#endif /* INCLUDE_CLIENT_APIS */
/*
* @}
*/
#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<>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,16 +40,16 @@
***************************************************************************/
/** The library version (string) e.g. "1.3.0" */
#define UPNP_VERSION_STRING "1.8.0"
#define UPNP_VERSION_STRING "1.4.7"
/** Major version of the library */
#define UPNP_VERSION_MAJOR 1
/** Minor version of the library */
#define UPNP_VERSION_MINOR 8
#define UPNP_VERSION_MINOR 4
/** Patch version of the library */
#define UPNP_VERSION_PATCH 0
#define UPNP_VERSION_PATCH 7
/** The library version (numeric) e.g. 10300 means version 1.3.0 */
#define UPNP_VERSION \
@@ -69,7 +69,7 @@
/** Defined to 1 if the library has been compiled with DEBUG enabled
* (i.e. configure --enable-debug) : <upnp/upnpdebug.h> file is available */
#define UPNP_HAVE_DEBUG 1
/* #undef UPNP_HAVE_DEBUG */
/** Defined to 1 if the library has been compiled with client API enabled
@@ -92,5 +92,6 @@
#define UPNP_HAVE_TOOLS 1
#endif /* UPNP_CONFIG_H */
#endif // UPNP_CONFIG_H

View File

@@ -9,7 +9,7 @@
AC_PREREQ(2.60)
AC_INIT([libupnp], [1.8.0], [mroberto@users.sourceforge.net])
AC_INIT([libupnp], [1.6.7], [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:
@@ -144,16 +144,11 @@ dnl #AC_SUBST([LT_VERSION_THREADUTIL], [4:3:2])
dnl #AC_SUBST([LT_VERSION_UPNP], [3:5:0])
dnl #
dnl ############################################################################
dnl # Release 1.8.0:
dnl # Release 1.6.7:
dnl # "current:revision:age"
dnl #
dnl # - Code has changed in upnp
dnl # revision: 5 -> 6
dnl # - Interfaces have been changed, added and removed in upnp
dnl # current: 3 -> 4
dnl # revision: 6 -> 0
dnl # - Interface has been removed in upnp
dnl # age = 0
dnl # - Code has changed in threadutil
dnl # revision: 3 -> 4
dnl # - Interfaces have been changed, added and removed in upnp
@@ -162,12 +157,12 @@ dnl # revision: 4 -> 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], [4:0:0])
dnl #AC_SUBST([LT_VERSION_UPNP], [3:5:0])
dnl #
dnl ############################################################################
AC_SUBST([LT_VERSION_IXML], [2:4:0])
AC_SUBST([LT_VERSION_THREADUTIL], [5:0:2])
AC_SUBST([LT_VERSION_UPNP], [4:0:0])
AC_SUBST([LT_VERSION_UPNP], [3:5:0])
dnl ############################################################################
dnl # Repeating the algorithm to place it closer to the modificatin place:
dnl # - library code modified: revision++
@@ -261,6 +256,16 @@ if test "x$enable_tools" = xyes ; then
AC_DEFINE(UPNP_HAVE_TOOLS, 1, [see upnpconfig.h])
fi
RT_BOOL_ARG_ENABLE([ipv6], [no], [ipv6 support])
if test "x$enable_ipv6" = xyes ; then
AC_DEFINE(UPNP_ENABLE_IPV6, 1, [see upnpconfig.h])
fi
RT_BOOL_ARG_ENABLE([notification_reordering], [yes], [GENA notification reordering in gena_device.c])
if test "x$enable_notification_reordering" = xyes ; then
AC_DEFINE(UPNP_ENABLE_NOTIFICATION_REORDERING, 1, [see upnpconfig.h])
fi
RT_BOOL_ARG_ENABLE([samples], [yes], [compilation of upnp/sample/ code])

View File

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

View File

@@ -45,9 +45,13 @@
#include "UpnpGlobal.h" /* For EXPORT_SPEC */
typedef int BOOL;
/* Define BOOL. */
#ifndef __OBJC__
typedef int BOOL;
#else
/* For Objective C compilers, include objc.h which defines BOOL. */
#include <objc/objc.h>
#endif
/*!
* \brief The type of DOM strings.

View File

@@ -5,7 +5,6 @@
#include "UpnpGlobal.h"
#include "ixml.h"
/*!
@@ -21,13 +20,6 @@
*/
#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
@@ -35,7 +27,7 @@ void IxmlPrintf(
...)
#if (__GNUC__ >= 3)
/* This enables printf like format checking by the compiler */
__attribute__((format (__printf__, 4, 5)))
__attribute__((format (__printf__, 1, 2)))
#endif
;
#else /* DEBUG */
@@ -45,23 +37,5 @@ 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 ret = IXML_SUCCESS;
int errCode = IXML_SUCCESS;
int line = 0;
if (doc == NULL || namespaceURI == NULL || qualifiedName == NULL) {
line = __LINE__;
ret = IXML_INVALID_PARAMETER;
errCode = IXML_INVALID_PARAMETER;
goto ErrorHandler;
}
ret = ixmlDocument_createElementEx(doc, qualifiedName, &newElement);
if (ret != IXML_SUCCESS) {
errCode = ixmlDocument_createElementEx(doc, qualifiedName, &newElement);
if (errCode != IXML_SUCCESS) {
line = __LINE__;
goto ErrorHandler;
}
@@ -464,16 +464,16 @@ int ixmlDocument_createElementNSEx(
line = __LINE__;
ixmlElement_free(newElement);
newElement = NULL;
ret = IXML_INSUFFICIENT_MEMORY;
errCode = IXML_INSUFFICIENT_MEMORY;
goto ErrorHandler;
}
// set the localName and prefix
ret = ixmlNode_setNodeName((IXML_Node *)newElement, qualifiedName);
if (ret != IXML_SUCCESS) {
errCode = ixmlNode_setNodeName((IXML_Node *)newElement, qualifiedName);
if (errCode != IXML_SUCCESS) {
line = __LINE__;
ixmlElement_free(newElement);
newElement = NULL;
ret = IXML_INSUFFICIENT_MEMORY;
errCode = IXML_INSUFFICIENT_MEMORY;
goto ErrorHandler;
}
@@ -481,11 +481,12 @@ int ixmlDocument_createElementNSEx(
ErrorHandler:
*rtElement = newElement;
if (ret != IXML_SUCCESS) {
IxmlPrintf(__FILE__, line, "ixmlDocument_createElementNSEx", "Error %d\n", ret);
if (errCode != IXML_SUCCESS) {
IxmlPrintf("(%s::ixmlDocument_createElementNSEx): Error %d, line %d\n",
__FILE__, errCode, line);
}
return ret;
return errCode;
}

View File

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

View File

@@ -17,54 +17,15 @@
#ifdef DEBUG
void IxmlPrintf(
const char *DbgFileName,
int DbgLineNo,
const char *FunctionName,
const char *FmtStr,
...)
{
va_list 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");
}
va_start(ArgList, FmtStr);
vfprintf(stdout, FmtStr, ArgList);
fflush(stdout);
va_end(ArgList);
}
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,7 +542,8 @@ static int Parser_UTF8ToInt(
*len = 0;
ret = -1;
}
IxmlPrintf(__FILE__, line, "Parser_UTF8ToInt", "Error %d\n", ret);
IxmlPrintf("(%s::Parser_UTF8ToInt): Error %d, line %d\n",
__FILE__, ret, line);
return ret;
}
}
@@ -582,11 +583,14 @@ static int Parser_isValidEndElement(
IXML_Node *newNode)
{
assert(xmlParser);
assert(xmlParser->pCurElement);
assert(xmlParser->pCurElement->element);
assert(newNode);
assert(newNode->nodeName);
if (xmlParser->pCurElement == NULL) {
return 0;
}
return strcmp(xmlParser->pCurElement->element, newNode->nodeName) == 0;
}
@@ -1301,7 +1305,8 @@ fail_entity:
ExitFunction:
if (ret == -1 || (g_error_char && ret == g_error_char)) {
IxmlPrintf(__FILE__, line, "Parser_getChar", "Error %d\n", ret);
IxmlPrintf("(%s::Parser_getChar): Error %d, line %d\n",
__FILE__, ret, line);
}
return ret;
@@ -1368,7 +1373,8 @@ static int Parser_copyToken(
ExitFunction:
if (ret != IXML_SUCCESS) {
IxmlPrintf(__FILE__, line, "Parser_copyToken", "Error %d\n", ret);
IxmlPrintf("(%s::Parser_copyToken): Error %d, line %d\n",
__FILE__, ret, line);
}
return ret;
@@ -1915,7 +1921,8 @@ static int Parser_xmlNamespace(
ExitFunction:
if (ret != IXML_SUCCESS && ret != IXML_FILE_DONE) {
IxmlPrintf(__FILE__, line, "Parser_xmlNamespace", "Error %d\n", ret);
IxmlPrintf("(%s::Parser_xmlNamespace): Error %d, line %d\n",
__FILE__, ret, line);
}
return ret;
@@ -2244,7 +2251,8 @@ static int Parser_processContent(
ExitFunction:
if (ret != IXML_SUCCESS) {
IxmlPrintf(__FILE__, line, "Parser_processContent", "Error %d\n", ret);
IxmlPrintf("(%s::Parser_processContent): Error %d, line %d\n",
__FILE__, ret, line);
}
return ret;
@@ -2316,7 +2324,8 @@ static int Parser_processETag(
ExitFunction:
if (ret != IXML_SUCCESS) {
IxmlPrintf(__FILE__, line, "Parser_processETag", "Error %d\n", ret);
IxmlPrintf("(%s::Parser_processETag): Error %d, line %d\n",
__FILE__, ret, line);
}
return ret;
@@ -2571,7 +2580,8 @@ static int Parser_processAttribute(
ExitFunction:
if (ret != IXML_SUCCESS && ret != IXML_FILE_DONE) {
IxmlPrintf(__FILE__, line, "Parser_processAttribute", "Error %d\n", ret);
IxmlPrintf("(%s::Parser_processAttribute): Error %d, line %d\n",
__FILE__, ret, line);
}
return ret;
@@ -2674,7 +2684,8 @@ static int Parser_getNextNode(
ExitFunction:
if (ret != IXML_SUCCESS && ret != IXML_FILE_DONE) {
IxmlPrintf(__FILE__, line, "Parser_getNextNode", "Error %d\n", ret);
IxmlPrintf("(%s::Parser_getNextNode): Error %d, line %d\n",
__FILE__, ret, line);
}
return ret;

View File

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

View File

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

View File

@@ -29,32 +29,21 @@
*
******************************************************************************/
#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
*
@@ -63,7 +52,6 @@ extern "C" {
*****************************************************************************/
typedef void (*free_function)(void *arg);
/****************************************************************************
* Name: cmp_routine
*
@@ -73,7 +61,6 @@ typedef void (*free_function)(void *arg);
*****************************************************************************/
typedef int (*cmp_routine)(void *itemA,void *itemB);
/****************************************************************************
* Name: ListNode
*
@@ -88,7 +75,6 @@ typedef struct LISTNODE
void *item;
} ListNode;
/****************************************************************************
* Name: LinkedList
*
@@ -118,7 +104,6 @@ typedef struct LINKEDLIST
cmp_routine cmp_func; /* compare function to use */
} LinkedList;
/****************************************************************************
* Function: ListInit
*
@@ -134,7 +119,6 @@ typedef struct LINKEDLIST
*****************************************************************************/
int ListInit(LinkedList *list,cmp_routine cmp_func, free_function free_func);
/****************************************************************************
* Function: ListAddHead
*
@@ -151,7 +135,6 @@ int ListInit(LinkedList *list,cmp_routine cmp_func, free_function free_func);
*****************************************************************************/
ListNode *ListAddHead(LinkedList *list, void *item);
/****************************************************************************
* Function: ListAddTail
*
@@ -168,7 +151,6 @@ ListNode *ListAddHead(LinkedList *list, void *item);
*****************************************************************************/
ListNode *ListAddTail(LinkedList *list, void *item);
/****************************************************************************
* Function: ListAddAfter
*
@@ -223,7 +205,6 @@ ListNode *ListAddBefore(LinkedList *list,void *item, ListNode *anode);
*****************************************************************************/
void *ListDelNode(LinkedList *list,ListNode *dnode, int freeItem);
/****************************************************************************
* Function: ListDestroy
*
@@ -259,7 +240,6 @@ int ListDestroy(LinkedList *list, int freeItem);
*****************************************************************************/
ListNode* ListHead(LinkedList *list);
/****************************************************************************
* Function: ListTail
*
@@ -276,7 +256,6 @@ ListNode* ListHead(LinkedList *list);
*****************************************************************************/
ListNode* ListTail(LinkedList *list);
/****************************************************************************
* Function: ListNext
*
@@ -293,7 +272,6 @@ ListNode* ListTail(LinkedList *list);
*****************************************************************************/
ListNode* ListNext(LinkedList *list, ListNode * node);
/****************************************************************************
* Function: ListPrev
*
@@ -310,7 +288,6 @@ ListNode* ListNext(LinkedList *list, ListNode * node);
*****************************************************************************/
ListNode* ListPrev(LinkedList *list, ListNode * node);
/****************************************************************************
* Function: ListFind
*
@@ -330,7 +307,6 @@ ListNode* ListPrev(LinkedList *list, ListNode * node);
*****************************************************************************/
ListNode* ListFind(LinkedList *list, ListNode *start, void * item);
/****************************************************************************
* Function: ListSize
*

View File

@@ -115,6 +115,10 @@ typedef enum priority {
#define DEFAULT_MAX_THREADS 10
/*! default stack size used by TPAttrInit */
#define DEFAULT_STACK_SIZE 0
/*! default jobs per thread used by TPAttrInit */
#define DEFAULT_JOBS_PER_THREAD 10
@@ -154,10 +158,6 @@ typedef int PolicyType;
#define DEFAULT_POLICY SCHED_OTHER
/*! Default priority */
#define DEFAULT_SCHED_PARAM 0
/****************************************************************************
* Name: free_routine
*
@@ -182,6 +182,10 @@ typedef struct THREADPOOLATTR
/* maxThreads, ThreadPool will never have more than this number of threads */
int maxThreads;
/* stackSize (in bytes), this is the minimum stack size allocated for each
* thread */
size_t stackSize;
/* maxIdleTime (in milliseconds) this is the maximum time a thread will
* remain idle before dying */
int maxIdleTime;
@@ -522,6 +526,20 @@ int TPAttrSetMaxThreads(ThreadPoolAttr *attr, int maxThreads);
int TPAttrSetMinThreads(ThreadPoolAttr *attr, int minThreads);
/****************************************************************************
* Function: TPAttrSetStackSize
*
* Description:
* Sets the stack size for the thread pool attributes.
* Parameters:
* attr - must be valid thread pool attributes.
* stackSize - value to set
* Returns:
* Always returns 0.
*****************************************************************************/
int TPAttrSetStackSize(ThreadPoolAttr *attr, size_t stackSize);
/****************************************************************************
* Function: TPAttrSetIdleTime
*

View File

@@ -29,139 +29,160 @@
*
******************************************************************************/
#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;
/*!
* 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.
/****************************************************************************
* Name: TimerThread
*
* Because the timer thread uses the thread pool there is no
* gurantee of timing, only approximate timing.
* 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
*
* 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;
/*!
* Struct to contain information for a timer event.
/****************************************************************************
* Name: TimerEvent
*
* Internal to the TimerThread.
*/
* Description:
*
* Struct to contain information for a timer event.
* Internal to the TimerThread
*
*****************************************************************************/
typedef struct TIMEREVENT
{
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;
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;
} TimerEvent;
/*!
* \brief Initializes and starts timer thread.
*
* \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);
/*!
* \brief Schedules an event to run at a specified time.
/************************************************************************
* Function: TimerThreadInit
*
* \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);
* 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 on failure.
*
************************************************************************/
int TimerThreadInit(TimerThread *timer,
ThreadPool *tp);
/*!
* \brief Removes an event from the timer Q.
/************************************************************************
* Function: TimerThreadSchedule
*
* Events can only be removed before they have been placed in the thread pool.
* Description:
* Schedules an event to run at a specified time.
*
* \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);
* 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);
/************************************************************************
* 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);
/*!
* \brief Shutdown the timer thread.
/************************************************************************
* Function: TimerThreadShutdown
*
* 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);
* 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);
#ifdef __cplusplus
}

View File

@@ -86,6 +86,9 @@ extern "C" {
#define ITHREAD_CANCELED PTHREAD_CANCELED
#define ITHREAD_STACK_MIN PTHREAD_STACK_MIN
/***************************************************************************
* Name: ithread_t
*
@@ -171,7 +174,9 @@ typedef pthread_condattr_t ithread_condattr_t;
* typedef to pthread_rwlockattr_t
* Internal Use Only
***************************************************************************/
#if UPNP_USE_RWLOCK
typedef pthread_rwlockattr_t ithread_rwlockattr_t;
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
@@ -182,7 +187,9 @@ typedef pthread_rwlockattr_t ithread_rwlockattr_t;
* typedef to pthread_rwlock_t
* Internal Use Only
***************************************************************************/
#if UPNP_USE_RWLOCK
typedef pthread_rwlock_t ithread_rwlock_t;
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
@@ -443,7 +450,9 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
* Always returns 0.
* See man page for pthread_rwlockattr_init
***************************************************************************/
#define ithread_rwlockattr_init pthread_rwlockattr_init
#if UPNP_USE_RWLOCK
#define ithread_rwlockattr_init pthread_rwlockattr_init
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
@@ -459,7 +468,9 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
* Always returns 0.
* See man page for pthread_rwlockattr_destroy
***************************************************************************/
#define ithread_rwlockattr_destroy pthread_rwlockattr_destroy
#if UPNP_USE_RWLOCK
#define ithread_rwlockattr_destroy pthread_rwlockattr_destroy
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
@@ -480,7 +491,9 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
* Returns EINVAL if the kind is not supported.
* See man page for pthread_rwlockattr_setkind_np
*****************************************************************************/
#define ithread_rwlockatttr_setpshared pthread_rwlockatttr_setpshared
#if UPNP_USE_RWLOCK
#define ithread_rwlockatttr_setpshared pthread_rwlockatttr_setpshared
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
@@ -501,7 +514,9 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
* Always returns 0.
* See man page for pthread_rwlockatttr_getpshared
*****************************************************************************/
#define ithread_rwlockatttr_getpshared pthread_rwlockatttr_getpshared
#if UPNP_USE_RWLOCK
#define ithread_rwlockatttr_getpshared pthread_rwlockatttr_getpshared
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
@@ -519,7 +534,9 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
* Always returns 0.
* See man page for pthread_rwlock_init
*****************************************************************************/
#define ithread_rwlock_init pthread_rwlock_init
#if UPNP_USE_RWLOCK
#define ithread_rwlock_init pthread_rwlock_init
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
@@ -536,7 +553,9 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
* Always returns 0.
* See man page for pthread_rwlock_rdlock
*****************************************************************************/
#define ithread_rwlock_rdlock pthread_rwlock_rdlock
#if UPNP_USE_RWLOCK
#define ithread_rwlock_rdlock pthread_rwlock_rdlock
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
@@ -553,7 +572,9 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
* Always returns 0.
* See man page for pthread_rwlock_wrlock
*****************************************************************************/
#define ithread_rwlock_wrlock pthread_rwlock_wrlock
#if UPNP_USE_RWLOCK
#define ithread_rwlock_wrlock pthread_rwlock_wrlock
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
@@ -571,7 +592,9 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
* Always returns 0.
* See man page for pthread_rwlock_unlock
*****************************************************************************/
#define ithread_rwlock_unlock pthread_rwlock_unlock
#if UPNP_USE_RWLOCK
#define ithread_rwlock_unlock pthread_rwlock_unlock
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
@@ -590,7 +613,9 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
* Always returns 0.
* See man page for pthread_rwlock_destroy
*****************************************************************************/
#define ithread_rwlock_destroy pthread_rwlock_destroy
#if UPNP_USE_RWLOCK
#define ithread_rwlock_destroy pthread_rwlock_destroy
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
@@ -704,6 +729,49 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
***************************************************************************/
#define ithread_cond_destroy pthread_cond_destroy
/****************************************************************************
* Function: ithread_attr_init
*
* Description:
* Initialises thread attribute object.
* Parameters:
* ithread_attr_t *attr (must be valid non NULL pointer to
* ithread_attr_t)
* Returns:
* 0 on success. Nonzero on failure.
* See man page for pthread_attr_init
***************************************************************************/
#define ithread_attr_init pthread_attr_init
/****************************************************************************
* Function: ithread_attr_destroy
*
* Description:
* Destroys thread attribute object.
* Parameters:
* ithread_attr_t *attr (must be valid non NULL pointer to
* ithread_attr_t)
* Returns:
* 0 on success. Nonzero on failure.
* See man page for pthread_attr_destroy
***************************************************************************/
#define ithread_attr_destroy pthread_attr_destroy
/****************************************************************************
* Function: ithread_attr_setstacksize
*
* Description:
* Sets stack size of a thread attribute object.
* Parameters:
* ithread_attr_t *attr (must be valid non NULL pointer to
* ithread_attr_t)
* size_t stacksize (value of stacksize must be greater than
* ITHREAD_STACK_MIN and lower than system-imposed limits
* Returns:
* 0 on success. Nonzero on failure.
* See man page for pthread_attr_setstacksize
***************************************************************************/
#define ithread_attr_setstacksize pthread_attr_setstacksize
/****************************************************************************
* Function: ithread_create
@@ -713,7 +781,7 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
* and argument.
* Parameters:
* ithread_t * thread (must be valid non NULL pointer to pthread_t)
* ithread_attr_t *attr, IGNORED
* ithread_attr_t *attr
* void * (start_routine) (void *arg) (start routine)
* void * arg - argument.
* Returns:

View File

@@ -1,55 +1,45 @@
/**************************************************************************
*
* 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"
#ifdef WIN32
/* Do not #include <sys/param.h> */
#else
#ifndef WIN32
#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

@@ -246,7 +246,7 @@ static int SetPolicyType(PolicyType in)
memset(&current, 0, sizeof(current));
sched_getparam(0, &current);
current.sched_priority = DEFAULT_SCHED_PARAM;
current.sched_priority = sched_get_priority_min(DEFAULT_POLICY);
sched_result = sched_setscheduler(0, in, &current);
retVal = (sched_result != -1 || errno == EPERM) ? 0 : errno;
#else
@@ -609,12 +609,16 @@ static int CreateWorker(ThreadPool *tp)
ithread_t temp;
int rc = 0;
int currentThreads = tp->totalThreads + 1;
ithread_attr_t attr;
if (tp->attr.maxThreads != INFINITE_THREADS &&
currentThreads > tp->attr.maxThreads) {
return EMAXTHREADS;
}
rc = ithread_create(&temp, NULL, WorkerThread, tp);
ithread_attr_init(&attr);
ithread_attr_setstacksize(&attr, tp->attr.stackSize);
rc = ithread_create(&temp, &attr, WorkerThread, tp);
ithread_attr_destroy(&attr);
if (rc == 0) {
rc = ithread_detach(temp);
while (tp->totalThreads < currentThreads) {
@@ -1174,6 +1178,7 @@ int TPAttrInit(ThreadPoolAttr *attr)
attr->maxIdleTime = DEFAULT_IDLE_TIME;
attr->maxThreads = DEFAULT_MAX_THREADS;
attr->minThreads = DEFAULT_MIN_THREADS;
attr->stackSize = DEFAULT_STACK_SIZE;
attr->schedPolicy = DEFAULT_POLICY;
attr->starvationTime = DEFAULT_STARVATION_TIME;
attr->maxJobsTotal = DEFAULT_MAX_JOBS_TOTAL;
@@ -1298,6 +1303,28 @@ int TPAttrSetMinThreads(ThreadPoolAttr *attr, int minThreads)
return 0;
}
/****************************************************************************
* Function: TPAttrSetStackSize
*
* Description:
* Sets the stack size for the thread pool attributes.
* Parameters:
* attr - must be valid thread pool attributes.
* stackSize - value to set
* Returns:
* Always returns 0.
*****************************************************************************/
int TPAttrSetStackSize(ThreadPoolAttr *attr, size_t stackSize)
{
if (!attr) {
return EINVAL;
}
attr->stackSize = stackSize;
return 0;
}
/****************************************************************************
* Function: TPAttrSetIdleTime
*

View File

@@ -1,69 +1,68 @@
/*******************************************************************************
*
* 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
*/
///////////////////////////////////////////////////////////////////////////
//
// 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 "TimerThread.h"
#include <assert.h>
/*!
* \brief Deallocates a dynamically allocated TimerEvent.
*/
static void FreeTimerEvent(
/*! [in] Valid timer thread pointer. */
TimerThread *timer,
/*! [in] Must be allocated with CreateTimerEvent*/
TimerEvent *event)
/****************************************************************************
* Function: FreeTimerEvent
*
* Description:
* Deallocates a dynamically allocated TimerEvent.
* Parameters:
* TimerEvent *event - must be allocated with CreateTimerEvent
*****************************************************************************/
static void
FreeTimerEvent( TimerThread * timer,
TimerEvent * event )
{
assert(timer != NULL);
FreeListFree(&timer->freeEvents, event);
assert( timer != NULL );
FreeListFree( &timer->freeEvents, event );
}
/*!
* \brief Implements timer thread.
/****************************************************************************
* Function: TimerThreadWorker
*
* Waits for next event to occur and schedules associated job into threadpool.
*/
static void *TimerThreadWorker(
/*! [in] arg is cast to (TimerThread *). */
void *arg)
* 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 )
{
TimerThread *timer = ( TimerThread * ) arg;
ListNode *head = NULL;
@@ -82,14 +81,19 @@ static void *TimerThreadWorker(
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;
@@ -98,6 +102,7 @@ static void *TimerThreadWorker(
if( timer->eventQ.size > 0 )
{
head = ListHead( &timer->eventQ );
nextEvent = ( TimerEvent * ) head->item;
nextEventTime = nextEvent->eventTime;
}
@@ -105,42 +110,54 @@ static void *TimerThreadWorker(
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 );
}
}
}
/*!
* \brief Calculates the appropriate timeout in absolute seconds
* since Jan 1, 1970.
/****************************************************************************
* Function: CalculateEventTime
*
* \return
*/
static int CalculateEventTime(
/*! [in] Timeout. */
time_t *timeout,
/*! [in] Timeout type. */
TimeoutType type)
* 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 )
{
time_t now;
@@ -158,22 +175,29 @@ static int CalculateEventTime(
}
/*!
* \brief Creates a Timer Event. (Dynamically allocated).
/****************************************************************************
* Function: CreateTimerEvent
*
* \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)
* 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 )
{
TimerEvent *temp = NULL;
@@ -191,8 +215,25 @@ static TimerEvent *CreateTimerEvent(
return temp;
}
int TimerThreadInit(TimerThread *timer, ThreadPool *tp)
/************************************************************************
* 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 rc = 0;
@@ -249,14 +290,37 @@ int TimerThreadInit(TimerThread *timer, ThreadPool *tp)
}
int TimerThreadSchedule(
TimerThread *timer,
time_t timeout,
TimeoutType type,
ThreadPoolJob *job,
Duration duration,
int *id)
/************************************************************************
* 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 rc = EOUTOFMEM;
@@ -330,11 +394,28 @@ int TimerThreadSchedule(
return rc;
}
int TimerThreadRemove(
TimerThread *timer,
int id,
ThreadPoolJob *out)
/************************************************************************
* 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 rc = INVALID_EVENT_ID;
ListNode *tempNode = NULL;
@@ -369,8 +450,21 @@ int TimerThreadRemove(
return rc;
}
int TimerThreadShutdown(TimerThread *timer)
/************************************************************************
* 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 )
{
ListNode *tempNode2 = NULL;
ListNode *tempNode = NULL;
@@ -423,4 +517,3 @@ int TimerThreadShutdown(TimerThread *timer)
return 0;
}

View File

@@ -19,15 +19,6 @@ LDADD = \
upnpincludedir = $(includedir)/upnp
upnpinclude_HEADERS = \
inc/ActionComplete.h \
inc/ActionRequest.h \
inc/Discovery.h \
inc/Event.h \
inc/EventSubscribe.h \
inc/FileInfo.h \
inc/StateVarComplete.h \
inc/StateVarRequest.h \
inc/SubscriptionRequest.h \
inc/UpnpString.h \
inc/upnp.h \
inc/upnpdebug.h \
@@ -53,7 +44,6 @@ libupnp_la_LDFLAGS = \
libupnp_la_SOURCES = \
src/inc/config.h \
src/inc/client_table.h \
src/inc/ClientSubscription.h \
src/inc/gena.h \
src/inc/gena_ctrlpt.h \
src/inc/gena_device.h \
@@ -89,8 +79,6 @@ libupnp_la_SOURCES = \
# ssdp
libupnp_la_SOURCES += \
src/ssdp/ssdp_ResultData.c \
src/ssdp/ssdp_ResultData.h \
src/ssdp/ssdp_device.c \
src/ssdp/ssdp_ctrlpt.c \
src/ssdp/ssdp_server.c
@@ -104,13 +92,12 @@ libupnp_la_SOURCES += \
# genlib
libupnp_la_SOURCES += \
src/genlib/miniserver/miniserver.c \
src/genlib/client_table/client_table.c \
src/genlib/client_table/ClientSubscription.c \
src/genlib/service_table/service_table.c \
src/genlib/util/membuffer.c \
src/genlib/util/strintmap.c \
src/genlib/util/upnp_timeout.c \
src/genlib/util/util.c \
src/genlib/client_table/client_table.c \
src/genlib/net/sock.c \
src/genlib/net/http/httpparser.c \
src/genlib/net/http/httpreadwrite.c \
@@ -127,15 +114,6 @@ libupnp_la_SOURCES += \
# api
libupnp_la_SOURCES += \
src/api/ActionComplete.c \
src/api/ActionRequest.c \
src/api/Discovery.c \
src/api/Event.c \
src/api/EventSubscribe.c \
src/api/FileInfo.c \
src/api/StateVarComplete.c \
src/api/StateVarRequest.c \
src/api/SubscriptionRequest.c \
src/api/UpnpString.c \
src/api/upnpapi.c

View File

@@ -1,173 +0,0 @@
#ifndef ACTIONCOMPLETE_H
#define ACTIONCOMPLETE_H
/*!
* \file
*
* \brief UpnpActionComplete object declararion.
*
* \author Marcelo Roberto Jimenez
*/
/*!
* \brief The type of an UpnpActionComplete object.
*/
typedef struct s_UpnpActionComplete UpnpActionComplete;
#include "ixml.h" /* for IXML_Document */
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
#include "UpnpString.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*!
* \brief Constructor.
*
* \return Pointer to the newly created object.
*/
EXPORT_SPEC UpnpActionComplete *UpnpActionComplete_new();
/*!
* \brief Destructor.
*/
EXPORT_SPEC void UpnpActionComplete_delete(
/*! [in] \b this pointer. */
UpnpActionComplete *p);
/*!
* \brief Copy Constructor.
*/
EXPORT_SPEC UpnpActionComplete *UpnpActionComplete_dup(
/*! [in] \b this pointer. */
const UpnpActionComplete *p);
/*!
* \brief Assignment operator.
*/
EXPORT_SPEC void UpnpActionComplete_assign(
/*! [in] \b this pointer. */
UpnpActionComplete *p,
/*! [in] \b that pointer. */
const UpnpActionComplete *q);
/*!
* \brief Error code getter.
*/
EXPORT_SPEC int UpnpActionComplete_get_ErrCode(
/*! [in] \b this pointer. */
const UpnpActionComplete *p);
/*!
* \brief Error code setter.
*/
EXPORT_SPEC void UpnpActionComplete_set_ErrCode(
/*! [in] \b this pointer. */
UpnpActionComplete *p,
/*! [in] The error code to set. */
int n);
/*!
* \brief Control URL getter.
*
* \return The control URL string.
*/
EXPORT_SPEC const UpnpString *UpnpActionComplete_get_CtrlUrl(
/*! [in] \b this pointer. */
const UpnpActionComplete *p);
/*!
* \brief Control URL getter as a C string
*
* \return The control URL string.
*/
EXPORT_SPEC const char *UpnpActionComplete_get_CtrlUrl_cstr(
/*! [in] \b this pointer. */
const UpnpActionComplete *p);
/*!
* \brief Control URL setter.
*/
EXPORT_SPEC void UpnpActionComplete_set_CtrlUrl(
/*! [in] \b this pointer. */
UpnpActionComplete *p,
/*! [in] The control URL string to copy. */
const UpnpString *s);
/*!
* \brief Set the control URL from a null terminated C string.
*/
EXPORT_SPEC void UpnpActionComplete_strcpy_CtrlUrl(
/*! [in] \b this pointer. */
UpnpActionComplete *p,
/*! [in] The null terminated control URL C string to copy. */
const char *s);
/*!
* \brief ActionRequest document getter.
*
* \return A pointer to the document object.
*/
EXPORT_SPEC IXML_Document *UpnpActionComplete_get_ActionRequest(
/*! [in] \b this pointer. */
const UpnpActionComplete *p);
/*!
* \brief ActionRequest document setter.
*
* \note The ActionComplete object takes ownership of the document parameter,
* i.e. it is responsible for deleting it upon destruction.
*/
EXPORT_SPEC void UpnpActionComplete_set_ActionRequest(
/*! [in] \b this pointer. */
UpnpActionComplete *p,
/*! [in] Document to copy. */
IXML_Document *d);
/*!
* \brief ActionResult document getter.
*/
EXPORT_SPEC IXML_Document *UpnpActionComplete_get_ActionResult(
/*! [in] \b this pointer. */
const UpnpActionComplete *p);
/*!
* \brief ActionResult document setter.
*
* \note The ActionComplete object takes ownership of the document parameter,
* i.e. it is responsible for deleting it upon destruction.
*/
EXPORT_SPEC void UpnpActionComplete_set_ActionResult(
/*! [in] \b this pointer. */
UpnpActionComplete *p,
/*! [in] Document to copy. */
IXML_Document *d);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* ACTIONCOMPLETE_H */

View File

@@ -1,96 +0,0 @@
#ifndef ACTIONREQUEST_H
#define ACTIONREQUEST_H
/*!
* \file
*
* \brief UpnpActionRequest object declaration.
*
* \author Marcelo Roberto Jimenez
*/
/*! Returned as part of a \b UPNP_CONTROL_ACTION_COMPLETE callback. */
typedef struct s_UpnpActionRequest UpnpActionRequest;
#include "ixml.h" /* for IXML_Document */
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
#include "UpnpInet.h" /* for sockaddr, sockaddr_storage */
#include "UpnpString.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*! Constructor */
EXPORT_SPEC UpnpActionRequest *UpnpActionRequest_new();
/*! Destructor */
EXPORT_SPEC void UpnpActionRequest_delete(UpnpActionRequest *p);
/*! Copy Constructor */
EXPORT_SPEC UpnpActionRequest *UpnpActionRequest_dup(const UpnpActionRequest *p);
/*! Assignment operator */
EXPORT_SPEC void UpnpActionRequest_assign(UpnpActionRequest *p, const UpnpActionRequest *q);
/*! The result of the operation */
EXPORT_SPEC int UpnpActionRequest_get_ErrCode(const UpnpActionRequest *p);
EXPORT_SPEC void UpnpActionRequest_set_ErrCode(UpnpActionRequest *p, int n);
/*! The socket number of the connection to the requestor */
EXPORT_SPEC int UpnpActionRequest_get_Socket(const UpnpActionRequest *p);
EXPORT_SPEC void UpnpActionRequest_set_Socket(UpnpActionRequest *p, int n);
/*! The error string in case of error */
EXPORT_SPEC const UpnpString *UpnpActionRequest_get_ErrStr(const UpnpActionRequest *p);
EXPORT_SPEC const char *UpnpActionRequest_get_ErrStr_cstr(const UpnpActionRequest *p);
EXPORT_SPEC void UpnpActionRequest_set_ErrStr(UpnpActionRequest *p, const UpnpString *s);
EXPORT_SPEC void UpnpActionRequest_strcpy_ErrStr(UpnpActionRequest *p, const char *s);
/*! The Action Name */
EXPORT_SPEC const UpnpString *UpnpActionRequest_get_ActionName(const UpnpActionRequest *p);
EXPORT_SPEC const char *UpnpActionRequest_get_ActionName_cstr(const UpnpActionRequest *p);
EXPORT_SPEC void UpnpActionRequest_set_ActionName(UpnpActionRequest *p, const UpnpString *s);
EXPORT_SPEC void UpnpActionRequest_strcpy_ActionName(UpnpActionRequest *p, const char *s);
/*! The unique device ID */
EXPORT_SPEC const UpnpString *UpnpActionRequest_get_DevUDN(const UpnpActionRequest *p);
EXPORT_SPEC const char *UpnpActionRequest_get_DevUDN_cstr(const UpnpActionRequest *p);
EXPORT_SPEC void UpnpActionRequest_set_DevUDN(UpnpActionRequest *p, const UpnpString *s);
/*! The service ID */
EXPORT_SPEC const UpnpString *UpnpActionRequest_get_ServiceID(const UpnpActionRequest *p);
EXPORT_SPEC const char *UpnpActionRequest_get_ServiceID_cstr(const UpnpActionRequest *p);
EXPORT_SPEC void UpnpActionRequest_set_ServiceID(UpnpActionRequest *p, const UpnpString *s);
/*! The DOM document describing the action */
EXPORT_SPEC IXML_Document *UpnpActionRequest_get_ActionRequest(const UpnpActionRequest *p);
EXPORT_SPEC void UpnpActionRequest_set_ActionRequest(UpnpActionRequest *p, IXML_Document *d);
/*! The DOM document describing the result of the action */
EXPORT_SPEC IXML_Document *UpnpActionRequest_get_ActionResult(const UpnpActionRequest *p);
EXPORT_SPEC void UpnpActionRequest_set_ActionResult(UpnpActionRequest *p, IXML_Document *d);
/*! The DOM document containing the information from the SOAP header */
EXPORT_SPEC IXML_Document *UpnpActionRequest_get_SoapHeader(const UpnpActionRequest *p);
EXPORT_SPEC void UpnpActionRequest_set_SoapHeader(UpnpActionRequest *p, IXML_Document *d);
/*! IP address of the control point requesting this action */
EXPORT_SPEC const struct sockaddr *UpnpActionRequest_get_CtrlPtIPAddr(const UpnpActionRequest *p);
EXPORT_SPEC void UpnpActionRequest_set_CtrlPtIPAddr(UpnpActionRequest *p, const struct sockaddr *sa);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* ACTIONREQUEST_H */

View File

@@ -1,112 +0,0 @@
#ifndef DISCOVERY_H
#define DISCOVERY_H
/*!
* \file
*
* \brief UpnpDiscovery object declararion.
*
* \author Marcelo Roberto Jimenez
*/
/*! Returned in a \b UPNP_DISCOVERY_RESULT callback. */
typedef struct s_UpnpDiscovery UpnpDiscovery;
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
#include "UpnpInet.h" /* for sockaddr, sockaddr_storage */
#include "UpnpString.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*! Constructor */
EXPORT_SPEC UpnpDiscovery *UpnpDiscovery_new();
/*! Destructor */
EXPORT_SPEC void UpnpDiscovery_delete(UpnpDiscovery *p);
/*! Copy Constructor */
EXPORT_SPEC UpnpDiscovery *UpnpDiscovery_dup(const UpnpDiscovery *p);
/*! Assignment operator */
EXPORT_SPEC void UpnpDiscovery_assign(UpnpDiscovery *p, const UpnpDiscovery *q);
/*! The result code of the \b UpnpSearchAsync call. */
EXPORT_SPEC int UpnpDiscovery_get_ErrCode(const UpnpDiscovery *p);
EXPORT_SPEC void UpnpDiscovery_set_ErrCode(UpnpDiscovery *p, int n);
/*! The expiration time of the advertisement. */
EXPORT_SPEC int UpnpDiscovery_get_Expires(const UpnpDiscovery *p);
EXPORT_SPEC void UpnpDiscovery_set_Expires(UpnpDiscovery *p, int n);
/*! The unique device identifier. */
EXPORT_SPEC const UpnpString *UpnpDiscovery_get_DeviceID(const UpnpDiscovery *p);
EXPORT_SPEC const char *UpnpDiscovery_get_DeviceID_cstr(const UpnpDiscovery *p);
EXPORT_SPEC void UpnpDiscovery_set_DeviceID(UpnpDiscovery *p, const UpnpString *s);
EXPORT_SPEC void UpnpDiscovery_strcpy_DeviceID(UpnpDiscovery *p, const char *s);
/*! The device type. */
EXPORT_SPEC const UpnpString *UpnpDiscovery_get_DeviceType(const UpnpDiscovery *p);
EXPORT_SPEC const char *UpnpDiscovery_get_DeviceType_cstr(const UpnpDiscovery *p);
EXPORT_SPEC void UpnpDiscovery_set_DeviceType(UpnpDiscovery *p, const UpnpString *s);
EXPORT_SPEC void UpnpDiscovery_strcpy_DeviceType(UpnpDiscovery *p, const char *s);
/*! The ServiceType. */
EXPORT_SPEC const UpnpString *UpnpDiscovery_get_ServiceType(const UpnpDiscovery *p);
EXPORT_SPEC const char *UpnpDiscovery_get_ServiceType_cstr(const UpnpDiscovery *p);
EXPORT_SPEC void UpnpDiscovery_set_ServiceType(UpnpDiscovery *p, const UpnpString *s);
EXPORT_SPEC void UpnpDiscovery_strcpy_ServiceType(UpnpDiscovery *p, const char *s);
/*! The service version. */
EXPORT_SPEC const UpnpString *UpnpDiscovery_get_ServiceVer(const UpnpDiscovery *p);
EXPORT_SPEC const char *UpnpDiscovery_get_ServiceVer_cstr(const UpnpDiscovery *p);
EXPORT_SPEC void UpnpDiscovery_set_ServiceVer(UpnpDiscovery *p, const UpnpString *s);
EXPORT_SPEC void UpnpDiscovery_strcpy_ServiceVer(UpnpDiscovery *p, const char *s);
/*! The URL to the UPnP description document for the device. */
EXPORT_SPEC const UpnpString *UpnpDiscovery_get_Location(const UpnpDiscovery *p);
EXPORT_SPEC const char *UpnpDiscovery_get_Location_cstr(const UpnpDiscovery *p);
EXPORT_SPEC void UpnpDiscovery_set_Location(UpnpDiscovery *p, const UpnpString *s);
EXPORT_SPEC void UpnpDiscovery_strcpy_Location(UpnpDiscovery *p, const char *s);
EXPORT_SPEC void UpnpDiscovery_strncpy_Location(UpnpDiscovery *p, const char *s, int n);
/*! The operating system the device is running. */
EXPORT_SPEC const UpnpString *UpnpDiscovery_get_Os(const UpnpDiscovery *p);
EXPORT_SPEC const char *UpnpDiscovery_get_Os_cstr(const UpnpDiscovery *p);
EXPORT_SPEC void UpnpDiscovery_set_Os(UpnpDiscovery *p, const UpnpString *s);
EXPORT_SPEC void UpnpDiscovery_strcpy_Os(UpnpDiscovery *p, const char *s);
EXPORT_SPEC void UpnpDiscovery_strncpy_Os(UpnpDiscovery *p, const char *s, int n);
/*! Date when the response was generated. */
EXPORT_SPEC const UpnpString *UpnpDiscovery_get_Date(const UpnpDiscovery *p);
EXPORT_SPEC const char *UpnpDiscovery_get_Date_cstr(const UpnpDiscovery *p);
EXPORT_SPEC void UpnpDiscovery_set_Date(UpnpDiscovery *p, const UpnpString *s);
EXPORT_SPEC void UpnpDiscovery_strcpy_Date(UpnpDiscovery *p, const char *s);
/*! Confirmation that the MAN header was understood by the device. */
EXPORT_SPEC const UpnpString *UpnpDiscovery_get_Ext(const UpnpDiscovery *p);
EXPORT_SPEC const char *UpnpDiscovery_get_Ext_cstr(const UpnpDiscovery *p);
EXPORT_SPEC void UpnpDiscovery_set_Ext(UpnpDiscovery *p, const UpnpString *s);
EXPORT_SPEC void UpnpDiscovery_strcpy_Ext(UpnpDiscovery *p, const char *s);
EXPORT_SPEC void UpnpDiscovery_strncpy_Ext(UpnpDiscovery *p, const char *s, int n);
/*! The host address of the device responding to the search. */
EXPORT_SPEC const struct sockaddr *UpnpDiscovery_get_DestAddr(const UpnpDiscovery *p);
EXPORT_SPEC void UpnpDiscovery_set_DestAddr(UpnpDiscovery *p, const struct sockaddr *sa);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* DISCOVERY_H */

View File

@@ -1,62 +0,0 @@
#ifndef EVENT_H
#define EVENT_H
/*!
* \file
*
* \brief UpnpEvent object declararion.
*
* \author Marcelo Roberto Jimenez
*/
/*! Returned along with a \b UPNP_EVENT_RECEIVED callback. */
typedef struct s_UpnpEvent UpnpEvent;
#include "ixml.h" /* for IXML_Document */
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
#include "UpnpString.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*! Constructor */
EXPORT_SPEC UpnpEvent *UpnpEvent_new();
/*! Destructor */
EXPORT_SPEC void UpnpEvent_delete(UpnpEvent *p);
/*! Copy Constructor */
EXPORT_SPEC UpnpEvent *UpnpEvent_dup(const UpnpEvent *p);
/*! Assignment operator */
EXPORT_SPEC void UpnpEvent_assign(UpnpEvent *p, const UpnpEvent *q);
/*! The event sequence number. */
EXPORT_SPEC int UpnpEvent_get_EventKey(const UpnpEvent *p);
EXPORT_SPEC void UpnpEvent_set_EventKey(UpnpEvent *p, int n);
/*! The DOM tree representing the changes generating the event. */
EXPORT_SPEC IXML_Document *UpnpEvent_get_ChangedVariables(const UpnpEvent *p);
EXPORT_SPEC void UpnpEvent_set_ChangedVariables(UpnpEvent *p, IXML_Document *d);
/*! The subscription ID for this subscription. */
EXPORT_SPEC const UpnpString *UpnpEvent_get_SID(const UpnpEvent *p);
EXPORT_SPEC const char *UpnpEvent_get_SID_cstr(const UpnpEvent *p);
EXPORT_SPEC void UpnpEvent_set_SID(UpnpEvent *p, const UpnpString *s);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* EVENT_H */

View File

@@ -1,74 +0,0 @@
#ifndef EVENTSUBSCRIBE_H
#define EVENTSUBSCRIBE_H
/*!
* \file
*
* \brief UpnpEventSubscribe object declararion.
*
* \author Marcelo Roberto Jimenez
*/
/*! Returned along with a \b UPNP_EVENT_SUBSCRIBE_COMPLETE or
* \b UPNP_EVENT_UNSUBSCRIBE_COMPLETE callback. */
typedef struct s_UpnpEventSubscribe UpnpEventSubscribe;
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
#include "UpnpString.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*! Constructor */
EXPORT_SPEC UpnpEventSubscribe *UpnpEventSubscribe_new();
/*! Destructor */
EXPORT_SPEC void UpnpEventSubscribe_delete(UpnpEventSubscribe *p);
/*! Copy Constructor */
EXPORT_SPEC UpnpEventSubscribe *UpnpEventSubscribe_dup(const UpnpEventSubscribe *p);
/*! Assignment operator */
EXPORT_SPEC void UpnpEventSubscribe_assign(UpnpEventSubscribe *p, const UpnpEventSubscribe *q);
/*! The result of the operation. */
EXPORT_SPEC int UpnpEventSubscribe_get_ErrCode(const UpnpEventSubscribe *p);
EXPORT_SPEC void UpnpEventSubscribe_set_ErrCode(UpnpEventSubscribe *p, int n);
/*! The actual subscription time (for subscriptions only). */
EXPORT_SPEC int UpnpEventSubscribe_get_TimeOut(const UpnpEventSubscribe *p);
EXPORT_SPEC void UpnpEventSubscribe_set_TimeOut(UpnpEventSubscribe *p, int n);
/*! The SID for this subscription. For subscriptions, this only
* contains a valid SID if the \b Upnp_EventSubscribe.result field
* contains a \b UPNP_E_SUCCESS result code. For unsubscriptions,
* this contains the SID from which the subscription is being
* unsubscribed. */
EXPORT_SPEC const UpnpString *UpnpEventSubscribe_get_SID(const UpnpEventSubscribe *p);
EXPORT_SPEC const char *UpnpEventSubscribe_get_SID_cstr(const UpnpEventSubscribe *p);
EXPORT_SPEC void UpnpEventSubscribe_set_SID(UpnpEventSubscribe *p, const UpnpString *s);
EXPORT_SPEC void UpnpEventSubscribe_strcpy_SID(UpnpEventSubscribe *p, const char *s);
/*! The event URL being subscribed to or removed from. */
EXPORT_SPEC const UpnpString *UpnpEventSubscribe_get_PublisherUrl(const UpnpEventSubscribe *p);
EXPORT_SPEC const char *UpnpEventSubscribe_get_PublisherUrl_cstr(const UpnpEventSubscribe *p);
EXPORT_SPEC void UpnpEventSubscribe_set_PublisherUrl(UpnpEventSubscribe *p, const UpnpString *s);
EXPORT_SPEC void UpnpEventSubscribe_strcpy_PublisherUrl(UpnpEventSubscribe *p, const char *s);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* EVENTSUBSCRIBE_H */

View File

@@ -1,84 +0,0 @@
#ifndef FILEINFO_H
#define FILEINFO_H
/*!
* \file
*
* \brief UpnpFileInfo object declararion.
*
* \author Marcelo Roberto Jimenez
*/
/*! Detailed description of this class should go here */
typedef struct s_UpnpFileInfo UpnpFileInfo;
#include "ixml.h" /* for DOMString */
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
#include <sys/types.h> /* for off_t */
#include <time.h> /* for time_t */
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*! Constructor */
EXPORT_SPEC UpnpFileInfo *UpnpFileInfo_new();
/*! Destructor */
EXPORT_SPEC void UpnpFileInfo_delete(UpnpFileInfo *p);
/*! Copy Constructor */
EXPORT_SPEC UpnpFileInfo *UpnpFileInfo_dup(const UpnpFileInfo *p);
/*! Assignment operator */
EXPORT_SPEC void UpnpFileInfo_assign(UpnpFileInfo *p, const UpnpFileInfo *q);
/*! The length of the file. A length less than 0 indicates the size
* is unknown, and data will be sent until 0 bytes are returned from
* a read call. */
EXPORT_SPEC off_t UpnpFileInfo_get_FileLength(const UpnpFileInfo *p);
EXPORT_SPEC void UpnpFileInfo_set_FileLength(UpnpFileInfo *p, off_t l);
/*! The time at which the contents of the file was modified;
* The time system is always local (not GMT). */
EXPORT_SPEC const time_t *UpnpFileInfo_get_LastModified(const UpnpFileInfo *p);
EXPORT_SPEC void UpnpFileInfo_set_LastModified(UpnpFileInfo *p, const time_t *t);
/*! If the file is a directory, \b is_directory contains
* a non-zero value. For a regular file, it should be 0. */
EXPORT_SPEC int UpnpFileInfo_get_IsDirectory(const UpnpFileInfo *p);
EXPORT_SPEC void UpnpFileInfo_set_IsDirectory(UpnpFileInfo *p, int b);
/*! If the file or directory is readable, this contains
* a non-zero value. If unreadable, it should be set to 0. */
EXPORT_SPEC int UpnpFileInfo_get_IsReadable(const UpnpFileInfo *p);
EXPORT_SPEC void UpnpFileInfo_set_IsReadable(UpnpFileInfo *p, int b);
/*! The content type of the file. */
EXPORT_SPEC const DOMString UpnpFileInfo_get_ContentType(const UpnpFileInfo *p);
EXPORT_SPEC const char *UpnpFileInfo_get_ContentType_cstr(const UpnpFileInfo *p);
EXPORT_SPEC void UpnpFileInfo_set_ContentType(UpnpFileInfo *p, const DOMString s);
/*! Additional HTTP headers to return. Each header line should be
* followed by "\r\n". */
EXPORT_SPEC const DOMString UpnpFileInfo_get_ExtraHeaders(const UpnpFileInfo *p);
EXPORT_SPEC const char *UpnpFileInfo_get_ExtraHeaders_cstr(const UpnpFileInfo *p);
EXPORT_SPEC void UpnpFileInfo_set_ExtraHeaders(UpnpFileInfo *p, const DOMString s);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* FILEINFO_H */

View File

@@ -1,72 +0,0 @@
#ifndef STATEVARCOMPLETE_H
#define STATEVARCOMPLETE_H
/*!
* \file
*
* \brief UpnpStateVarComplete object declararion.
*
* \author Marcelo Roberto Jimenez
*/
/*! Represents the reply for the current value of a state variable in an
* asynchronous call. */
typedef struct s_UpnpStateVarComplete UpnpStateVarComplete;
#include "ixml.h" /* for DOMString */
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
#include "UpnpString.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*! Constructor */
EXPORT_SPEC UpnpStateVarComplete *UpnpStateVarComplete_new();
/*! Destructor */
EXPORT_SPEC void UpnpStateVarComplete_delete(UpnpStateVarComplete *p);
/*! Copy Constructor */
EXPORT_SPEC UpnpStateVarComplete *UpnpStateVarComplete_dup(const UpnpStateVarComplete *p);
/*! Assignment operator */
EXPORT_SPEC void UpnpStateVarComplete_assign(UpnpStateVarComplete *p, const UpnpStateVarComplete *q);
/*! The result of the operation */
EXPORT_SPEC int UpnpStateVarComplete_get_ErrCode(const UpnpStateVarComplete *p);
EXPORT_SPEC void UpnpStateVarComplete_set_ErrCode(UpnpStateVarComplete *p, int n);
/*! The control URL for the service. */
EXPORT_SPEC const UpnpString *UpnpStateVarComplete_get_CtrlUrl(const UpnpStateVarComplete *p);
EXPORT_SPEC const char *UpnpStateVarComplete_get_CtrlUrl_cstr(const UpnpStateVarComplete *p);
EXPORT_SPEC void UpnpStateVarComplete_set_CtrlUrl(UpnpStateVarComplete *p, const UpnpString *s);
EXPORT_SPEC void UpnpStateVarComplete_strcpy_CtrlUrl(UpnpStateVarComplete *p, const char *s);
/*! The name of the variable. */
EXPORT_SPEC const UpnpString *UpnpStateVarComplete_get_StateVarName(const UpnpStateVarComplete *p);
EXPORT_SPEC const char *UpnpStateVarComplete_get_StateVarName_cstr(const UpnpStateVarComplete *p);
EXPORT_SPEC void UpnpStateVarComplete_set_StateVarName(UpnpStateVarComplete *p, const UpnpString *s);
EXPORT_SPEC void UpnpStateVarComplete_strcpy_StateVarName(UpnpStateVarComplete *p, const char *s);
/*! The current value of the variable. This needs to be allocated by
* the caller. When finished with it, the SDK frees this \b DOMString. */
EXPORT_SPEC const DOMString UpnpStateVarComplete_get_CurrentVal(const UpnpStateVarComplete *p);
EXPORT_SPEC const char *UpnpStateVarComplete_get_CurrentVal_cstr(const UpnpStateVarComplete *p);
EXPORT_SPEC void UpnpStateVarComplete_set_CurrentVal(UpnpStateVarComplete *p, const DOMString s);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* STATEVARCOMPLETE_H */

View File

@@ -1,91 +0,0 @@
#ifndef STATEVARREQUEST_H
#define STATEVARREQUEST_H
/*!
* \file
*
* \brief UpnpStateVarRequest object declararion.
*
* \author Marcelo Roberto Jimenez
*/
/*! Represents the request for current value of a state variable in a service
* state table. */
typedef struct s_UpnpStateVarRequest UpnpStateVarRequest;
#include "ixml.h" /* for DOMString */
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
#include "UpnpInet.h" /* for sockaddr, sockaddr_storage */
#include "UpnpString.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*! Constructor */
EXPORT_SPEC UpnpStateVarRequest *UpnpStateVarRequest_new();
/*! Destructor */
EXPORT_SPEC void UpnpStateVarRequest_delete(UpnpStateVarRequest *p);
/*! Copy Constructor */
EXPORT_SPEC UpnpStateVarRequest *UpnpStateVarRequest_dup(const UpnpStateVarRequest *p);
/*! Assignment operator */
EXPORT_SPEC void UpnpStateVarRequest_assign(UpnpStateVarRequest *p, const UpnpStateVarRequest *q);
/*! The result of the operation */
EXPORT_SPEC int UpnpStateVarRequest_get_ErrCode(const UpnpStateVarRequest *p);
EXPORT_SPEC void UpnpStateVarRequest_set_ErrCode(UpnpStateVarRequest *p, int n);
/*! The socket number of the connection to the requestor */
EXPORT_SPEC int UpnpStateVarRequest_get_Socket(const UpnpStateVarRequest *p);
EXPORT_SPEC void UpnpStateVarRequest_set_Socket(UpnpStateVarRequest *p, int n);
/*! The error string in case of error */
EXPORT_SPEC const UpnpString *UpnpStateVarRequest_get_ErrStr(const UpnpStateVarRequest *p);
EXPORT_SPEC const char *UpnpStateVarRequest_get_ErrStr_cstr(const UpnpStateVarRequest *p);
EXPORT_SPEC void UpnpStateVarRequest_set_ErrStr(UpnpStateVarRequest *p, const UpnpString *s);
EXPORT_SPEC void UpnpStateVarRequest_strcpy_ErrStr(UpnpStateVarRequest *p, const char *s);
/*! The unique device ID */
EXPORT_SPEC const UpnpString *UpnpStateVarRequest_get_DevUDN(const UpnpStateVarRequest *p);
EXPORT_SPEC const char *UpnpStateVarRequest_get_DevUDN_cstr(const UpnpStateVarRequest *p);
EXPORT_SPEC void UpnpStateVarRequest_set_DevUDN(UpnpStateVarRequest *p, const UpnpString *s);
/*! The service ID */
EXPORT_SPEC const UpnpString *UpnpStateVarRequest_get_ServiceID(const UpnpStateVarRequest *p);
EXPORT_SPEC const char *UpnpStateVarRequest_get_ServiceID_cstr(const UpnpStateVarRequest *p);
EXPORT_SPEC void UpnpStateVarRequest_set_ServiceID(UpnpStateVarRequest *p, const UpnpString *s);
/*! The name of the variable. */
EXPORT_SPEC const UpnpString *UpnpStateVarRequest_get_StateVarName(const UpnpStateVarRequest *p);
EXPORT_SPEC const char *UpnpStateVarRequest_get_StateVarName_cstr(const UpnpStateVarRequest *p);
EXPORT_SPEC void UpnpStateVarRequest_set_StateVarName(UpnpStateVarRequest *p, const UpnpString *s);
EXPORT_SPEC void UpnpStateVarRequest_strcpy_StateVarName(UpnpStateVarRequest *p, const char *s);
/*! IP address of sender requesting the state variable. */
EXPORT_SPEC const struct sockaddr *UpnpStateVarRequest_get_CtrlPtIPAddr(const UpnpStateVarRequest *p);
EXPORT_SPEC void UpnpStateVarRequest_set_CtrlPtIPAddr(UpnpStateVarRequest *p, const struct sockaddr *sa);
/*! The current value of the variable. This needs to be allocated by
* the caller. When finished with it, the SDK frees this \b DOMString. */
EXPORT_SPEC const DOMString UpnpStateVarRequest_get_CurrentVal(const UpnpStateVarRequest *p);
EXPORT_SPEC const char *UpnpStateVarRequest_get_CurrentVal_cstr(const UpnpStateVarRequest *p);
EXPORT_SPEC void UpnpStateVarRequest_set_CurrentVal(UpnpStateVarRequest *p, const DOMString s);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* STATEVARREQUEST_H */

View File

@@ -1,66 +0,0 @@
#ifndef SUBSCRIPTIONREQUEST_H
#define SUBSCRIPTIONREQUEST_H
/*!
* \file
*
* \brief UpnpSubscriptionRequest object declararion.
*
* \author Marcelo Roberto Jimenez
*/
/*! Returned along with a \b UPNP_EVENT_SUBSCRIPTION_REQUEST callback. */
typedef struct s_UpnpSubscriptionRequest UpnpSubscriptionRequest;
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
#include "UpnpString.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*! Constructor */
EXPORT_SPEC UpnpSubscriptionRequest *UpnpSubscriptionRequest_new();
/*! Destructor */
EXPORT_SPEC void UpnpSubscriptionRequest_delete(UpnpSubscriptionRequest *p);
/*! Copy Constructor */
EXPORT_SPEC UpnpSubscriptionRequest *UpnpSubscriptionRequest_dup(const UpnpSubscriptionRequest *p);
/*! Assignment operator */
EXPORT_SPEC void UpnpSubscriptionRequest_assign(UpnpSubscriptionRequest *p, const UpnpSubscriptionRequest *q);
/*! The identifier for the service being subscribed to. */
EXPORT_SPEC const UpnpString *UpnpSubscriptionRequest_get_ServiceId(const UpnpSubscriptionRequest *p);
EXPORT_SPEC const char *UpnpSubscriptionRequest_get_ServiceId_cstr(const UpnpSubscriptionRequest *p);
EXPORT_SPEC void UpnpSubscriptionRequest_set_ServiceId(UpnpSubscriptionRequest *p, const UpnpString *s);
EXPORT_SPEC void UpnpSubscriptionRequest_strcpy_ServiceId(UpnpSubscriptionRequest *p, const char *s);
/*! Universal device name. */
EXPORT_SPEC const UpnpString *UpnpSubscriptionRequest_get_UDN(const UpnpSubscriptionRequest *p);
EXPORT_SPEC const char *UpnpSubscriptionRequest_get_UDN_cstr(const UpnpSubscriptionRequest *p);
EXPORT_SPEC void UpnpSubscriptionRequest_set_UDN(UpnpSubscriptionRequest *p, const UpnpString *s);
EXPORT_SPEC void UpnpSubscriptionRequest_strcpy_UDN(UpnpSubscriptionRequest *p, const char *s);
/*! The assigned subscription ID for this subscription. */
EXPORT_SPEC const UpnpString *UpnpSubscriptionRequest_get_SID(const UpnpSubscriptionRequest *p);
EXPORT_SPEC const char *UpnpSubscriptionRequest_get_SID_cstr(const UpnpSubscriptionRequest *p);
EXPORT_SPEC void UpnpSubscriptionRequest_set_SID(UpnpSubscriptionRequest *p, const UpnpString *s);
EXPORT_SPEC void UpnpSubscriptionRequest_strcpy_SID(UpnpSubscriptionRequest *p, const char *s);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* SUBSCRIPTIONREQUEST_H */

View File

@@ -24,6 +24,9 @@
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
#include <stdlib.h> /* for size_t */
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@@ -76,11 +79,22 @@ EXPORT_SPEC void UpnpString_assign(
*
* \return The length of the string.
* */
EXPORT_SPEC int UpnpString_get_Length(
EXPORT_SPEC size_t UpnpString_get_Length(
/*! [in] The \em \b this pointer. */
const UpnpString *p);
/*!
* \brief Truncates the string to the specified lenght, or does nothing
* if the current lenght is less than or equal to the requested length.
* */
EXPORT_SPEC void UpnpString_set_Length(
/*! [in] The \em \b this pointer. */
UpnpString *p,
/*! [in] The requested length. */
size_t n);
/*!
* \brief Returns the pointer to char.
*
@@ -94,7 +108,7 @@ EXPORT_SPEC const char *UpnpString_get_String(
/*!
* \brief Sets the string from a pointer to char.
*/
EXPORT_SPEC void UpnpString_set_String(
EXPORT_SPEC int UpnpString_set_String(
/*! [in] The \em \b this pointer. */
UpnpString *p,
/*! [in] (char *) to copy from. */
@@ -104,13 +118,13 @@ EXPORT_SPEC void UpnpString_set_String(
/*!
* \brief Sets the string from a pointer to char using a maximum of N chars.
*/
EXPORT_SPEC void UpnpString_set_StringN(
EXPORT_SPEC int UpnpString_set_StringN(
/*! [in] The \em \b this pointer. */
UpnpString *p,
/*! [in] (char *) to copy from. */
const char *s,
/*! Maximum number of chars to copy.*/
int n);
size_t n);
/*!
@@ -121,6 +135,30 @@ EXPORT_SPEC void UpnpString_clear(
UpnpString *p);
/*!
* \brief Compares two strings for equality. Case matters.
*
* \return The result of strcmp().
*/
EXPORT_SPEC int UpnpString_cmp(
/*! [in] The \em \b the first string. */
UpnpString *p,
/*! [in] The \em \b the second string. */
UpnpString *q);
/*!
* \brief Compares two strings for equality. Case does not matter.
*
* \return The result of strcasecmp().
*/
EXPORT_SPEC int UpnpString_casecmp(
/*! [in] The \em \b the first string. */
UpnpString *p,
/*! [in] The \em \b the second string. */
UpnpString *q);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@@ -417,6 +417,7 @@
#endif
#if UPNP_VERSION >= 10800
/*
* Opaque data structures. The following includes are data structures that
* must be externally visible. Since version 1.8.0, only an opaque typedef
@@ -436,6 +437,7 @@
#include "StateVarComplete.h"
#include "StateVarRequest.h"
#include "SubscriptionRequest.h"
#endif /* UPNP_VERSION >= 10800 */
/*!
@@ -635,6 +637,234 @@ enum Upnp_DescType_e {
typedef enum Upnp_DescType_e Upnp_DescType;
#if UPNP_VERSION < 10800
/** Returned as part of a {\bf UPNP_CONTROL_ACTION_COMPLETE} callback. */
struct Upnp_Action_Request
{
/** The result of the operation. */
int ErrCode;
/** The socket number of the connection to the requestor. */
int Socket;
/** The error string in case of error. */
char ErrStr[LINE_SIZE];
/** The Action Name. */
char ActionName[NAME_SIZE];
/** The unique device ID. */
char DevUDN[NAME_SIZE];
/** The service ID. */
char ServiceID[NAME_SIZE];
/** The DOM document describing the action. */
IXML_Document *ActionRequest;
/** The DOM document describing the result of the action. */
IXML_Document *ActionResult;
/** IP address of the control point requesting this action. */
struct sockaddr_storage CtrlPtIPAddr;
/** The DOM document containing the information from the
the SOAP header. */
IXML_Document *SoapHeader;
};
struct Upnp_Action_Complete
{
/** The result of the operation. */
int ErrCode;
/** The control URL for service. */
char CtrlUrl[NAME_SIZE];
/** The DOM document describing the action. */
IXML_Document *ActionRequest;
/** The DOM document describing the result of the action. */
IXML_Document *ActionResult;
};
/** Represents the request for current value of a state variable in a service
* state table. */
struct Upnp_State_Var_Request
{
/** The result of the operation. */
int ErrCode;
/** The socket number of the connection to the requestor. */
int Socket;
/** The error string in case of error. */
char ErrStr[LINE_SIZE];
/** The unique device ID. */
char DevUDN[NAME_SIZE];
/** The service ID. */
char ServiceID[NAME_SIZE];
/** The name of the variable. */
char StateVarName[NAME_SIZE];
/** IP address of sender requesting the state variable. */
struct sockaddr_storage CtrlPtIPAddr;
/** The current value of the variable. This needs to be allocated by
* the caller. When finished with it, the SDK frees this {\bf DOMString}. */
DOMString CurrentVal;
};
/** Represents the reply for the current value of a state variable in an
asynchronous call. */
struct Upnp_State_Var_Complete
{
/** The result of the operation. */
int ErrCode;
/** The control URL for the service. */
char CtrlUrl[NAME_SIZE];
/** The name of the variable. */
char StateVarName[NAME_SIZE];
/** The current value of the variable or error string in case of error. */
DOMString CurrentVal;
};
/** Returned along with a {\bf UPNP_EVENT_RECEIVED} callback. */
struct Upnp_Event
{
/** The subscription ID for this subscription. */
Upnp_SID Sid;
/** The event sequence number. */
int EventKey;
/** The DOM tree representing the changes generating the event. */
IXML_Document *ChangedVariables;
};
/*
* This typedef is required by Doc++ to parse the last entry of the
* Upnp_Discovery structure correctly.
*/
/** Returned in a {\bf UPNP_DISCOVERY_RESULT} callback. */
struct Upnp_Discovery
{
/** The result code of the {\bf UpnpSearchAsync} call. */
int ErrCode;
/** The expiration time of the advertisement. */
int Expires;
/** The unique device identifier. */
char DeviceId[LINE_SIZE];
/** The device type. */
char DeviceType[LINE_SIZE];
/** The service type. */
char ServiceType[LINE_SIZE];
/** The service version. */
char ServiceVer[LINE_SIZE];
/** The URL to the UPnP description document for the device. */
char Location[LINE_SIZE];
/** The operating system the device is running. */
char Os[LINE_SIZE];
/** Date when the response was generated. */
char Date[LINE_SIZE];
/** Confirmation that the MAN header was understood by the device. */
char Ext[LINE_SIZE];
/** The host address of the device responding to the search. */
struct sockaddr_in DestAddr;
};
/** Returned along with a {\bf UPNP_EVENT_SUBSCRIBE_COMPLETE} or {\bf
* UPNP_EVENT_UNSUBSCRIBE_COMPLETE} callback. */
struct Upnp_Event_Subscribe {
/** The SID for this subscription. For subscriptions, this only
* contains a valid SID if the {\bf Upnp_EventSubscribe.result} field
* contains a {\tt UPNP_E_SUCCESS} result code. For unsubscriptions,
* this contains the SID from which the subscription is being
* unsubscribed. */
Upnp_SID Sid;
/** The result of the operation. */
int ErrCode;
/** The event URL being subscribed to or removed from. */
char PublisherUrl[NAME_SIZE];
/** The actual subscription time (for subscriptions only). */
int TimeOut;
};
/** Returned along with a {\bf UPNP_EVENT_SUBSCRIPTION_REQUEST}
* callback. */
struct Upnp_Subscription_Request
{
/** The identifier for the service being subscribed to. */
char *ServiceId;
/** Universal device name. */
char *UDN;
/** The assigned subscription ID for this subscription. */
Upnp_SID Sid;
};
struct File_Info
{
/** The length of the file. A length less than 0 indicates the size
* is unknown, and data will be sent until 0 bytes are returned from
* a read call. */
off_t file_length;
/** The time at which the contents of the file was modified;
* The time system is always local (not GMT). */
time_t last_modified;
/** If the file is a directory, {\bf is_directory} contains
* a non-zero value. For a regular file, it should be 0. */
int is_directory;
/** If the file or directory is readable, this contains
* a non-zero value. If unreadable, it should be set to 0. */
int is_readable;
/** The content type of the file. This string needs to be allocated
* by the caller using {\bf ixmlCloneDOMString}. When finished
* with it, the SDK frees the {\bf DOMString}. */
DOMString content_type;
};
#endif /* UPNP_VERSION < 10800 */
/*!
* All callback functions share the same prototype, documented below.
* Note that any memory passed to the callback function
@@ -757,6 +987,7 @@ EXPORT_SPEC int UpnpInit(
* \li \c UPNP_E_INVALID_INTERFACE: IfName is invalid or does not
* have a valid IPv4 or IPv6 addresss configured.
*/
#ifdef UPNP_ENABLE_IPV6
EXPORT_SPEC int UpnpInit2(
/*! The interface name to use by the UPnP SDK operations.
* Examples: "eth0", "xl0", "Local Area Connection", \c NULL to
@@ -765,6 +996,7 @@ EXPORT_SPEC int UpnpInit2(
/*! Local Port to listen for incoming connections.
* \c NULL will pick an arbitrary free port. */
unsigned short DestPort);
#endif
/*!
@@ -814,8 +1046,9 @@ EXPORT_SPEC unsigned short UpnpGetServerPort(void);
* related requests.
* \li On error: 0 is returned if \b UpnpInit has not succeeded.
*/
#ifdef UPNP_ENABLE_IPV6
EXPORT_SPEC unsigned short UpnpGetServerPort6(void);
#endif
/*!
* \brief Returns the local IPv4 listening ip address.
*
@@ -841,10 +1074,11 @@ EXPORT_SPEC char *UpnpGetServerIpAddress(void);
* listening for UPnP related requests.
* \li On error: \c NULL is returned if \b UpnpInit has not succeeded.
*/
#ifdef UPNP_ENABLE_IPV6
EXPORT_SPEC char *UpnpGetServerIp6Address(void);
EXPORT_SPEC char *UpnpGetServerUlaGuaIp6Address(void);
#endif
/*!
* \brief Registers a device application with the UPnP Library.
*
@@ -1121,6 +1355,8 @@ EXPORT_SPEC int UpnpSetContentLength(
* behaviour if the size of the incoming SOAP message exceeds the memory that
* device can allocate.
*
* If set to 0 then checking will be disabled.
*
* The default maximum content-length is \c DEFAULT_SOAP_CONTENT_LENGTH
* = 16K bytes.
*
@@ -2416,7 +2652,12 @@ typedef int (*VDCallback_GetInfo)(
/*! [in] The name of the file to query. */
const char *filename,
/*! [out] Pointer to a structure to store the information on the file. */
UpnpFileInfo *info);
#if UPNP_VERSION < 10800
struct File_Info *info
#else
UpnpFileInfo *info
#endif /* UPNP_VERSION < 10800 */
);
/*!

View File

@@ -90,6 +90,9 @@
* (i.e. configure --enable-tools) : <upnp/upnptools.h> file is available */
#undef UPNP_HAVE_TOOLS
/** 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 */

View File

@@ -304,6 +304,24 @@ 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,237 +29,201 @@
*
******************************************************************************/
/** @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
/*!
* \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 */
#include "upnp.h"
/* Function declarations only if tools compiled into the library */
#if UPNP_HAVE_TOOLS
#ifdef __cplusplus
extern "C" {
#endif
/*!
* \brief Converts an SDK error code into a string error message suitable for
* display. The memory returned from this function should NOT be freed.
/** {\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.
*
* \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
* @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}
* combination does not form a valid URL.
* \li <tt>UPNP_E_OUTOF_MEMORY</tt>: Insufficient resources exist to
* \item {\tt UPNP_E_OUTOF_MEMORY}: Insufficient resources exist to
* complete this operation.
* \end{itemize}
*/
EXPORT_SPEC int UpnpResolveURL(
/*! [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);
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. */
);
/*!
* \brief Creates an action request packet based on its input parameters
* (status variable name and value pair).
/** {\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.
*
* 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.
* @return [IXML_Document*] The action node of {\bf Upnp_Document} type or
* {\tt NULL} 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. */
...);
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. */
);
/*!
* \brief Ceates an action response packet based on its output parameters
* (status variable name and value pair).
/** {\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.
*
* 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.
* @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}
*/
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] 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);
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. */
);
/*!
* \brief Creates an action response packet based on its output parameters
* (status variable name and value pair).
/** {\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.
*
* 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.
* @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.
*
* @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}
*/
EXPORT_SPEC int UpnpAddToActionResponse(
/*! [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);
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. */
);
/*!
* \brief Creates a property set message packet.
/** {\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.
*
* Any number of input parameters can be passed to this function but every
* input variable name should have a matching value input argument.
* @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}
*
* \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] 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);
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. */
);
/** {\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

@@ -43,7 +43,8 @@
#endif
int initialize = 1;
static int initialize_init = 1;
static int initialize_register = 1;
/*! Function pointers to use for displaying formatted strings.
* Set on Initialization of device. */
@@ -67,7 +68,7 @@ ithread_mutex_t display_mutex;
******************************************************************************/
int SampleUtil_Initialize(print_string print_function)
{
if (initialize) {
if (initialize_init) {
ithread_mutexattr_t attr;
ithread_mutexattr_init(&attr);
@@ -80,7 +81,7 @@ int SampleUtil_Initialize(print_string print_function)
gPrintFun = print_function;
ithread_mutex_unlock(&display_mutex);
initialize = 0;
initialize_init = 0;
} else {
SampleUtil_Print("***** SampleUtil_Initialize was called multiple times!\n");
abort();
@@ -99,12 +100,9 @@ int SampleUtil_Initialize(print_string print_function)
******************************************************************************/
int SampleUtil_RegisterUpdateFunction(state_update update_function)
{
/* Intialize only once. */
static int initialize = 1;
if (initialize) {
if (initialize_register) {
gStateUpdateFun = update_function;
initialize = 0;
initialize_register = 0;
}
return UPNP_E_SUCCESS;
@@ -123,7 +121,9 @@ int SampleUtil_Finish()
{
ithread_mutex_destroy(&display_mutex);
gPrintFun = NULL;
initialize = 1;
gStateUpdateFun = NULL;
initialize_init = 1;
initialize_register = 1;
return UPNP_E_SUCCESS;
}
@@ -428,37 +428,26 @@ int SampleUtil_PrintEvent(IN Upnp_EventType EventType, IN void *Event)
{
ithread_mutex_lock(&display_mutex);
SampleUtil_Print(
"======================================================================\n"
"----------------------------------------------------------------------\n");
SampleUtil_Print("======================================================================\n");
SampleUtil_Print("----------------------------------------------------------------------\n");
SampleUtil_PrintEventType(EventType);
switch (EventType) {
/* SSDP */
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
case UPNP_DISCOVERY_SEARCH_RESULT: {
UpnpDiscovery *d_event = (UpnpDiscovery *)Event;
SampleUtil_Print(
"ErrCode = %d\n"
"Expires = %d\n"
"DeviceId = %s\n"
"DeviceType = %s\n"
"ServiceType = %s\n"
"ServiceVer = %s\n"
"Location = %s\n"
"OS = %s\n"
"Date = %s\n"
"Ext = %s\n",
UpnpDiscovery_get_ErrCode(d_event),
UpnpDiscovery_get_Expires(d_event),
UpnpString_get_String(UpnpDiscovery_get_DeviceID(d_event)),
UpnpString_get_String(UpnpDiscovery_get_DeviceType(d_event)),
UpnpString_get_String(UpnpDiscovery_get_ServiceType(d_event)),
UpnpString_get_String(UpnpDiscovery_get_ServiceVer(d_event)),
UpnpString_get_String(UpnpDiscovery_get_Location(d_event)),
UpnpString_get_String(UpnpDiscovery_get_Os(d_event)),
UpnpString_get_String(UpnpDiscovery_get_Date(d_event)),
UpnpString_get_String(UpnpDiscovery_get_Ext(d_event)));
struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event;
SampleUtil_Print("ErrCode = %s(%d)\n",
UpnpGetErrorMessage(d_event->ErrCode), d_event->ErrCode);
SampleUtil_Print("Expires = %d\n", d_event->Expires);
SampleUtil_Print("DeviceId = %s\n", d_event->DeviceId);
SampleUtil_Print("DeviceType = %s\n", d_event->DeviceType);
SampleUtil_Print("ServiceType = %s\n", d_event->ServiceType);
SampleUtil_Print("ServiceVer = %s\n", d_event->ServiceVer);
SampleUtil_Print("Location = %s\n", d_event->Location);
SampleUtil_Print("OS = %s\n", d_event->Os);
SampleUtil_Print("Ext = %s\n", d_event->Ext);
break;
}
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
@@ -466,26 +455,19 @@ int SampleUtil_PrintEvent(IN Upnp_EventType EventType, IN void *Event)
break;
/* SOAP */
case UPNP_CONTROL_ACTION_REQUEST: {
UpnpActionRequest *a_event = (UpnpActionRequest *)Event;
IXML_Document *actionRequestDoc = NULL;
IXML_Document *actionResultDoc = NULL;
struct Upnp_Action_Request *a_event =
(struct Upnp_Action_Request *)Event;
char *xmlbuff = NULL;
SampleUtil_Print(
"ErrCode = %d\n"
"ErrStr = %s\n"
"ActionName = %s\n"
"UDN = %s\n"
"ServiceID = %s\n",
UpnpActionRequest_get_ErrCode(a_event),
UpnpString_get_String(UpnpActionRequest_get_ErrStr(a_event)),
UpnpString_get_String(UpnpActionRequest_get_ActionName(a_event)),
UpnpString_get_String(UpnpActionRequest_get_DevUDN(a_event)),
UpnpString_get_String(UpnpActionRequest_get_ServiceID(a_event)));
actionRequestDoc = UpnpActionRequest_get_ActionRequest(a_event);
if (actionRequestDoc) {
xmlbuff = ixmlPrintNode((IXML_Node *)actionRequestDoc);
if (xmlbuff) {
SampleUtil_Print("ErrCode = %s(%d)\n",
UpnpGetErrorMessage(a_event->ErrCode), a_event->ErrCode);
SampleUtil_Print("ErrStr = %s\n", a_event->ErrStr);
SampleUtil_Print("ActionName = %s\n", a_event->ActionName);
SampleUtil_Print("UDN = %s\n", a_event->DevUDN);
SampleUtil_Print("ServiceID = %s\n", a_event->ServiceID);
if (a_event->ActionRequest) {
xmlbuff = ixmlPrintNode((IXML_Node *)a_event->ActionRequest);
if ( xmlbuff ) {
SampleUtil_Print("ActRequest = %s\n", xmlbuff);
ixmlFreeDOMString(xmlbuff);
}
@@ -493,9 +475,8 @@ int SampleUtil_PrintEvent(IN Upnp_EventType EventType, IN void *Event)
} else {
SampleUtil_Print("ActRequest = (null)\n");
}
actionResultDoc = UpnpActionRequest_get_ActionResult(a_event);
if (actionResultDoc) {
xmlbuff = ixmlPrintNode((IXML_Node *)actionResultDoc);
if (a_event->ActionResult) {
xmlbuff = ixmlPrintNode((IXML_Node *)a_event->ActionResult);
if (xmlbuff) {
SampleUtil_Print("ActResult = %s\n", xmlbuff);
ixmlFreeDOMString(xmlbuff);
@@ -507,22 +488,15 @@ int SampleUtil_PrintEvent(IN Upnp_EventType EventType, IN void *Event)
break;
}
case UPNP_CONTROL_ACTION_COMPLETE: {
UpnpActionComplete *a_event = (UpnpActionComplete *)Event;
struct Upnp_Action_Complete *a_event =
(struct Upnp_Action_Complete *)Event;
char *xmlbuff = NULL;
int errCode = UpnpActionComplete_get_ErrCode(a_event);
const char *ctrlURL = UpnpString_get_String(
UpnpActionComplete_get_CtrlUrl(a_event));
IXML_Document *actionRequest =
UpnpActionComplete_get_ActionRequest(a_event);
IXML_Document *actionResult =
UpnpActionComplete_get_ActionResult(a_event);
SampleUtil_Print(
"ErrCode = %d\n"
"CtrlUrl = %s\n",
errCode, ctrlURL);
if (actionRequest) {
xmlbuff = ixmlPrintNode((IXML_Node *)actionRequest);
SampleUtil_Print("ErrCode = %s(%d)\n",
UpnpGetErrorMessage(a_event->ErrCode), a_event->ErrCode);
SampleUtil_Print("CtrlUrl = %s\n", a_event->CtrlUrl);
if (a_event->ActionRequest) {
xmlbuff = ixmlPrintNode((IXML_Node *)a_event->ActionRequest);
if (xmlbuff) {
SampleUtil_Print("ActRequest = %s\n", xmlbuff);
ixmlFreeDOMString(xmlbuff);
@@ -531,8 +505,8 @@ int SampleUtil_PrintEvent(IN Upnp_EventType EventType, IN void *Event)
} else {
SampleUtil_Print("ActRequest = (null)\n");
}
if (actionResult) {
xmlbuff = ixmlPrintNode((IXML_Node *)actionResult);
if (a_event->ActionResult) {
xmlbuff = ixmlPrintNode((IXML_Node *)a_event->ActionResult);
if (xmlbuff) {
SampleUtil_Print("ActResult = %s\n", xmlbuff);
ixmlFreeDOMString(xmlbuff);
@@ -544,114 +518,89 @@ int SampleUtil_PrintEvent(IN Upnp_EventType EventType, IN void *Event)
break;
}
case UPNP_CONTROL_GET_VAR_REQUEST: {
UpnpStateVarRequest *sv_event = (UpnpStateVarRequest *)Event;
struct Upnp_State_Var_Request *sv_event =
(struct Upnp_State_Var_Request *)Event;
SampleUtil_Print(
"ErrCode = %d\n"
"ErrStr = %s\n"
"UDN = %s\n"
"ServiceID = %s\n"
"StateVarName= %s\n"
"CurrentVal = %s\n",
UpnpStateVarRequest_get_ErrCode(sv_event),
UpnpString_get_String(UpnpStateVarRequest_get_ErrStr(sv_event)),
UpnpString_get_String(UpnpStateVarRequest_get_DevUDN(sv_event)),
UpnpString_get_String(UpnpStateVarRequest_get_ServiceID(sv_event)),
UpnpString_get_String(UpnpStateVarRequest_get_StateVarName(sv_event)),
UpnpStateVarRequest_get_CurrentVal(sv_event));
SampleUtil_Print("ErrCode = %s(%d)\n",
UpnpGetErrorMessage(sv_event->ErrCode), sv_event->ErrCode);
SampleUtil_Print("ErrStr = %s\n", sv_event->ErrStr);
SampleUtil_Print("UDN = %s\n", sv_event->DevUDN);
SampleUtil_Print("ServiceID = %s\n", sv_event->ServiceID);
SampleUtil_Print("StateVarName= %s\n", sv_event->StateVarName);
SampleUtil_Print("CurrentVal = %s\n", sv_event->CurrentVal);
break;
}
case UPNP_CONTROL_GET_VAR_COMPLETE: {
UpnpStateVarComplete *sv_event = (UpnpStateVarComplete *)Event;
struct Upnp_State_Var_Complete *sv_event =
(struct Upnp_State_Var_Complete *)Event;
SampleUtil_Print(
"ErrCode = %d\n"
"CtrlUrl = %s\n"
"StateVarName= %s\n"
"CurrentVal = %s\n",
UpnpStateVarComplete_get_ErrCode(sv_event),
UpnpString_get_String(UpnpStateVarComplete_get_CtrlUrl(sv_event)),
UpnpString_get_String(UpnpStateVarComplete_get_StateVarName(sv_event)),
UpnpStateVarComplete_get_CurrentVal(sv_event));
SampleUtil_Print("ErrCode = %s(%d)\n",
UpnpGetErrorMessage(sv_event->ErrCode), sv_event->ErrCode);
SampleUtil_Print("CtrlUrl = %s\n", sv_event->CtrlUrl);
SampleUtil_Print("StateVarName= %s\n", sv_event->StateVarName);
SampleUtil_Print("CurrentVal = %s\n", sv_event->CurrentVal);
break;
}
/* GENA */
case UPNP_EVENT_SUBSCRIPTION_REQUEST: {
UpnpSubscriptionRequest *sr_event = (UpnpSubscriptionRequest *)Event;
struct Upnp_Subscription_Request *sr_event =
(struct Upnp_Subscription_Request *)Event;
SampleUtil_Print(
"ServiceID = %s\n"
"UDN = %s\n"
"SID = %s\n",
UpnpString_get_String(UpnpSubscriptionRequest_get_ServiceId(sr_event)),
UpnpString_get_String(UpnpSubscriptionRequest_get_UDN(sr_event)),
UpnpString_get_String(UpnpSubscriptionRequest_get_SID(sr_event)));
SampleUtil_Print("ServiceID = %s\n", sr_event->ServiceId);
SampleUtil_Print("UDN = %s\n", sr_event->UDN);
SampleUtil_Print("SID = %s\n", sr_event->Sid);
break;
}
case UPNP_EVENT_RECEIVED: {
UpnpEvent *e_event = (UpnpEvent *)Event;
struct Upnp_Event *e_event = (struct Upnp_Event *)Event;
char *xmlbuff = NULL;
xmlbuff = ixmlPrintNode(
(IXML_Node *)UpnpEvent_get_ChangedVariables(e_event));
SampleUtil_Print(
"SID = %s\n"
"EventKey = %d\n"
"ChangedVars = %s\n",
UpnpString_get_String(UpnpEvent_get_SID(e_event)),
UpnpEvent_get_EventKey(e_event),
xmlbuff);
SampleUtil_Print("SID = %s\n", e_event->Sid);
SampleUtil_Print("EventKey = %d\n", e_event->EventKey);
xmlbuff = ixmlPrintNode((IXML_Node *)e_event->ChangedVariables);
SampleUtil_Print("ChangedVars = %s\n", xmlbuff);
ixmlFreeDOMString(xmlbuff);
xmlbuff = NULL;
break;
}
case UPNP_EVENT_RENEWAL_COMPLETE: {
UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event;
struct Upnp_Event_Subscribe *es_event =
(struct Upnp_Event_Subscribe *)Event;
SampleUtil_Print(
"SID = %s\n"
"ErrCode = %d\n"
"TimeOut = %d\n",
UpnpString_get_String(UpnpEventSubscribe_get_SID(es_event)),
UpnpEventSubscribe_get_ErrCode(es_event),
UpnpEventSubscribe_get_TimeOut(es_event));
SampleUtil_Print("SID = %s\n", es_event->Sid);
SampleUtil_Print("ErrCode = %s(%d)\n",
UpnpGetErrorMessage(es_event->ErrCode), es_event->ErrCode);
SampleUtil_Print("TimeOut = %d\n", es_event->TimeOut);
break;
}
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE: {
UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event;
struct Upnp_Event_Subscribe *es_event =
(struct Upnp_Event_Subscribe *)Event;
SampleUtil_Print(
"SID = %s\n"
"ErrCode = %d\n"
"PublisherURL= %s\n"
"TimeOut = %d\n",
UpnpString_get_String(UpnpEventSubscribe_get_SID(es_event)),
UpnpEventSubscribe_get_ErrCode(es_event),
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
UpnpEventSubscribe_get_TimeOut(es_event));
SampleUtil_Print("SID = %s\n", es_event->Sid);
SampleUtil_Print("ErrCode = %s(%d)\n",
UpnpGetErrorMessage(es_event->ErrCode), es_event->ErrCode);
SampleUtil_Print("PublisherURL= %s\n", es_event->PublisherUrl);
SampleUtil_Print("TimeOut = %d\n", es_event->TimeOut);
break;
}
case UPNP_EVENT_AUTORENEWAL_FAILED:
case UPNP_EVENT_SUBSCRIPTION_EXPIRED: {
UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event;
struct Upnp_Event_Subscribe *es_event =
(struct Upnp_Event_Subscribe *)Event;
SampleUtil_Print(
"SID = %s\n"
"ErrCode = %d\n"
"PublisherURL= %s\n"
"TimeOut = %d\n",
UpnpString_get_String(UpnpEventSubscribe_get_SID(es_event)),
UpnpEventSubscribe_get_ErrCode(es_event),
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
UpnpEventSubscribe_get_TimeOut(es_event));
SampleUtil_Print("SID = %s\n", es_event->Sid);
SampleUtil_Print("ErrCode = %s(%d)\n",
UpnpGetErrorMessage(es_event->ErrCode), es_event->ErrCode);
SampleUtil_Print("PublisherURL= %s\n", es_event->PublisherUrl);
SampleUtil_Print("TimeOut = %d\n", es_event->TimeOut);
break;
}
}
SampleUtil_Print(
"----------------------------------------------------------------------\n"
"======================================================================\n"
"\n\n\n");
SampleUtil_Print("----------------------------------------------------------------------\n");
SampleUtil_Print("======================================================================\n");
ithread_mutex_unlock(&display_mutex);

View File

@@ -1,55 +1,51 @@
/*******************************************************************************
*
* 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 "ithread.h"
#include "ixml.h" /* for IXML_Document, IXML_Element */
#include "upnp.h" /* for Upnp_EventType */
#include "upnptools.h"
#include <stdlib.h>
#include <string.h>
#include "ithread.h"
#include "ixml.h"
#include "upnptools.h"
/* mutex to control displaying of events */
// mutex to control displaying of events
extern ithread_mutex_t display_mutex;
@@ -170,7 +166,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

@@ -937,25 +937,23 @@ TvStateUpdate( char *UDN,
*
********************************************************************************/
void TvCtrlPointHandleEvent(
const UpnpString *sid,
const Upnp_SID sid,
int evntkey,
IXML_Document *changes)
{
struct TvDeviceNode *tmpdevnode;
int service;
const char *aux_sid = NULL;
ithread_mutex_lock(&DeviceListMutex);
tmpdevnode = GlobalDeviceList;
while (tmpdevnode) {
for (service = 0; service < TV_SERVICE_SERVCOUNT; ++service) {
aux_sid = UpnpString_get_String(sid);
if (strcmp(tmpdevnode->device.TvService[service].SID, aux_sid) == 0) {
if(strcmp(tmpdevnode->device.TvService[service].SID, sid) == 0) {
SampleUtil_Print("Received Tv %s Event: %d for SID %s",
TvServiceName[service],
evntkey,
aux_sid);
sid );
TvStateUpdate(
tmpdevnode->device.UDN,
service,
@@ -1057,31 +1055,29 @@ void TvCtrlPointHandleGetVar(
********************************************************************************/
int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Cookie)
{
int errCode = 0;
/*int errCode = 0;*/
SampleUtil_PrintEvent(EventType, Event);
switch ( EventType ) {
/* SSDP Stuff */
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
case UPNP_DISCOVERY_SEARCH_RESULT: {
UpnpDiscovery *d_event = (UpnpDiscovery *)Event;
struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event;
IXML_Document *DescDoc = NULL;
const char *location = NULL;
int errCode = UpnpDiscovery_get_ErrCode(d_event);
int ret;
if (errCode != UPNP_E_SUCCESS) {
if (d_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Discovery Callback -- %d", errCode);
"Error in Discovery Callback -- %d", d_event->ErrCode);
}
location = UpnpString_get_String(UpnpDiscovery_get_Location(d_event));
errCode = UpnpDownloadXmlDoc(location, &DescDoc);
if (errCode != UPNP_E_SUCCESS) {
ret = UpnpDownloadXmlDoc(d_event->Location, &DescDoc);
if (ret != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error obtaining device description from %s -- error = %d",
location, errCode);
d_event->Location, ret);
} else {
TvCtrlPointAddDevice(
DescDoc, location, UpnpDiscovery_get_Expires(d_event));
DescDoc, d_event->Location, d_event->Expires);
}
if (DescDoc) {
ixmlDocument_free(DescDoc);
@@ -1093,93 +1089,90 @@ int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void
/* Nothing to do here... */
break;
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE: {
UpnpDiscovery *d_event = (UpnpDiscovery *)Event;
int errCode = UpnpDiscovery_get_ErrCode(d_event);
const char *deviceId = UpnpString_get_String(
UpnpDiscovery_get_DeviceID(d_event));
struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event;
if (errCode != UPNP_E_SUCCESS) {
if (d_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Discovery ByeBye Callback -- %d", errCode);
"Error in Discovery ByeBye Callback -- %d", d_event->ErrCode);
}
SampleUtil_Print("Received ByeBye for Device: %s", deviceId);
TvCtrlPointRemoveDevice(deviceId);
SampleUtil_Print("Received ByeBye for Device: %s", d_event->DeviceId);
TvCtrlPointRemoveDevice(d_event->DeviceId);
SampleUtil_Print("After byebye:");
TvCtrlPointPrintList();
break;
}
/* SOAP Stuff */
case UPNP_CONTROL_ACTION_COMPLETE: {
UpnpActionComplete *a_event = (UpnpActionComplete *)Event;
int errCode = UpnpActionComplete_get_ErrCode(a_event);
if (errCode != UPNP_E_SUCCESS) {
struct Upnp_Action_Complete *a_event = (struct Upnp_Action_Complete *)Event;
if (a_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Action Complete Callback -- %d",
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: {
UpnpStateVarComplete *sv_event = (UpnpStateVarComplete *)Event;
int errCode = UpnpStateVarComplete_get_ErrCode(sv_event);
if (errCode != UPNP_E_SUCCESS) {
struct Upnp_State_Var_Complete *sv_event = (struct Upnp_State_Var_Complete *)Event;
if (sv_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Get Var Complete Callback -- %d", errCode);
"Error in Get Var Complete Callback -- %d", sv_event->ErrCode);
} else {
TvCtrlPointHandleGetVar(
UpnpString_get_String(UpnpStateVarComplete_get_CtrlUrl(sv_event)),
UpnpString_get_String(UpnpStateVarComplete_get_StateVarName(sv_event)),
UpnpStateVarComplete_get_CurrentVal(sv_event));
sv_event->CtrlUrl,
sv_event->StateVarName,
sv_event->CurrentVal);
}
break;
}
/* GENA Stuff */
case UPNP_EVENT_RECEIVED: {
UpnpEvent *e_event = (UpnpEvent *)Event;
struct Upnp_Event *e_event = (struct Upnp_Event *)Event;
TvCtrlPointHandleEvent(
UpnpEvent_get_SID(e_event),
UpnpEvent_get_EventKey(e_event),
UpnpEvent_get_ChangedVariables(e_event));
e_event->Sid,
e_event->EventKey,
e_event->ChangedVariables);
break;
}
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
case UPNP_EVENT_RENEWAL_COMPLETE: {
UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event;
struct Upnp_Event_Subscribe *es_event = (struct Upnp_Event_Subscribe *)Event;
errCode = UpnpEventSubscribe_get_ErrCode(es_event);
if (errCode != UPNP_E_SUCCESS) {
if (es_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Event Subscribe Callback -- %d", errCode);
"Error in Event Subscribe Callback -- %d", es_event->ErrCode);
} else {
TvCtrlPointHandleSubscribeUpdate(
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
UpnpString_get_String(UpnpEventSubscribe_get_SID(es_event)),
UpnpEventSubscribe_get_TimeOut(es_event));
es_event->PublisherUrl,
es_event->Sid,
es_event->TimeOut);
}
break;
}
case UPNP_EVENT_AUTORENEWAL_FAILED:
case UPNP_EVENT_SUBSCRIPTION_EXPIRED: {
UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event;
struct Upnp_Event_Subscribe *es_event = (struct Upnp_Event_Subscribe *)Event;
int TimeOut = default_timeout;
Upnp_SID newSID;
int ret;
errCode = UpnpSubscribe(
ret = UpnpSubscribe(
ctrlpt_handle,
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
es_event->PublisherUrl,
&TimeOut,
newSID);
if (errCode == UPNP_E_SUCCESS) {
if (ret == UPNP_E_SUCCESS) {
SampleUtil_Print("Subscribed to EventURL with SID=%s", newSID);
TvCtrlPointHandleSubscribeUpdate(
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
es_event->PublisherUrl,
newSID,
TimeOut);
} else {
SampleUtil_Print("Error Subscribing to EventURL -- %d", errCode);
SampleUtil_Print("Error Subscribing to EventURL -- %d", ret);
}
break;
}
@@ -1317,7 +1310,8 @@ int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionP
SampleUtil_Print(
"Initializing UPnP Sdk with\n"
"\tipaddress = %s port = %u\n",
ip_address, port);
ip_address ? ip_address : "{NULL}",
port);
rc = UpnpInit(ip_address, port);
if (rc != UPNP_E_SUCCESS) {

View File

@@ -1,4 +1,4 @@
/**************************************************************************
/*******************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
@@ -27,39 +27,29 @@
* 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 "sample_util.h"
#include <stdio.h>
#include "ithread.h"
#include "upnp.h"
#include "upnptools.h"
#include <signal.h>
#ifndef WIN32
#include <unistd.h>
#endif
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#ifdef WIN32
/* Do not #include <unistd.h> */
#else
#include <unistd.h>
#endif
#include "upnp.h"
#include "upnptools.h"
#include "sample_util.h"
#define TV_SERVICE_SERVCOUNT 2
#define TV_SERVICE_CONTROL 0
@@ -78,12 +68,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[];
@@ -120,11 +110,11 @@ extern ithread_mutex_t DeviceListMutex;
extern UpnpClient_Handle ctrlpt_handle;
void TvCtrlPointPrintHelp();
int TvCtrlPointDeleteNode(struct TvDeviceNode*);
void TvCtrlPointPrintHelp( void );
int TvCtrlPointDeleteNode(struct TvDeviceNode *);
int TvCtrlPointRemoveDevice(const char *);
int TvCtrlPointRemoveAll();
int TvCtrlPointRefresh();
int TvCtrlPointRemoveAll( void );
int TvCtrlPointRefresh( void );
int TvCtrlPointSendAction(int, int, char *, char **, char **, int);
@@ -153,7 +143,7 @@ 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 UpnpString *, int, IXML_Document *);
void TvCtrlPointHandleEvent(const Upnp_SID, int, IXML_Document *);
void TvCtrlPointHandleSubscribeUpdate(const char *, const Upnp_SID, int);
int TvCtrlPointCallbackEventHandler(Upnp_EventType, void *, void *);
void TvCtrlPointVerifyTimeouts(int);

View File

@@ -38,8 +38,10 @@
#define DEFAULT_WEB_DIR "./web"
#define DESC_URL_SIZE 200
/*
Device type for tv device
*/
@@ -369,28 +371,23 @@ TvDeviceStateTableInit( IN char *DescDocURL )
* sr_event -- The subscription request event structure
*
*****************************************************************************/
int TvDeviceHandleSubscriptionRequest(IN const UpnpSubscriptionRequest *sr_event)
int
TvDeviceHandleSubscriptionRequest( IN struct Upnp_Subscription_Request
*sr_event )
{
unsigned int i = 0;
//unsigned int j = 0;
int cmp1 = 0;
int cmp2 = 0;
const char *l_serviceId = NULL;
const char *l_udn = NULL;
const char *l_sid = NULL;
unsigned int i = 0; //,j=0;
// IXML_Document *PropSet = NULL;
// lock state mutex
ithread_mutex_lock( &TVDevMutex );
l_serviceId = UpnpString_get_String(UpnpSubscriptionRequest_get_ServiceId(sr_event));
l_udn = UpnpString_get_String(UpnpSubscriptionRequest_get_UDN(sr_event));
l_sid = UpnpString_get_String(UpnpSubscriptionRequest_get_SID(sr_event));
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
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 ) ) {
/*
PropSet = NULL;
for (j = 0; j< tv_service_table[i].VariableCount; ++j) {
@@ -405,23 +402,25 @@ int TvDeviceHandleSubscriptionRequest(IN const UpnpSubscriptionRequest *sr_event
// dump initial state
UpnpAcceptSubscriptionExt(
device_handle,
l_udn,
l_serviceId,
sr_event->UDN,
sr_event->ServiceId,
PropSet,
l_sid);
sr_event->Sid);
// free document
Document_free(PropSet);
#endif
UpnpAcceptSubscription(
device_handle,
l_udn,
l_serviceId,
*/
UpnpAcceptSubscription( device_handle,
sr_event->UDN,
sr_event->ServiceId,
(const char **)tv_service_table[i].
VariableName,
(const char **)tv_service_table[i].
VariableStrVal,
tv_service_table[i].VariableCount,
l_sid);
sr_event->Sid);
}
}
@@ -444,32 +443,31 @@ int TvDeviceHandleSubscriptionRequest(IN const UpnpSubscriptionRequest *sr_event
*
*****************************************************************************/
int
TvDeviceHandleGetVarRequest( INOUT UpnpStateVarRequest *cgv_event )
TvDeviceHandleGetVarRequest( INOUT struct Upnp_State_Var_Request
*cgv_event )
{
unsigned int i = 0;
unsigned int j = 0;
int getvar_succeeded = 0;
UpnpStateVarRequest_set_CurrentVal(cgv_event, NULL);
cgv_event->CurrentVal = NULL;
ithread_mutex_lock( &TVDevMutex );
for( i = 0; i < TV_SERVICE_SERVCOUNT; i++ ) {
// check udn and service id
const char *devUDN =
UpnpString_get_String(UpnpStateVarRequest_get_DevUDN(cgv_event));
const char *serviceID =
UpnpString_get_String(UpnpStateVarRequest_get_ServiceID(cgv_event));
if( ( strcmp( devUDN, tv_service_table[i].UDN ) == 0 ) &&
( strcmp( serviceID, tv_service_table[i].ServiceId ) == 0 ) ) {
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++ ) {
const char *stateVarName =
UpnpString_get_String(UpnpStateVarRequest_get_StateVarName(cgv_event));
if( strcmp( stateVarName, tv_service_table[i].VariableName[j] ) == 0 ) {
if( strcmp( cgv_event->StateVarName,
tv_service_table[i].VariableName[j] ) == 0 ) {
getvar_succeeded = 1;
UpnpStateVarRequest_set_CurrentVal(cgv_event,
tv_service_table[i].VariableStrVal[j] );
cgv_event->CurrentVal =
ixmlCloneDOMString( tv_service_table[i].
VariableStrVal[j] );
break;
}
}
@@ -477,19 +475,19 @@ TvDeviceHandleGetVarRequest( INOUT UpnpStateVarRequest *cgv_event )
}
if( getvar_succeeded ) {
UpnpStateVarRequest_set_ErrCode(cgv_event, UPNP_E_SUCCESS);
cgv_event->ErrCode = UPNP_E_SUCCESS;
} else {
SampleUtil_Print(
"Error in UPNP_CONTROL_GET_VAR_REQUEST callback:\n"
" Unknown variable name = %s\n",
UpnpString_get_String(UpnpStateVarRequest_get_StateVarName(cgv_event)) );
UpnpStateVarRequest_set_ErrCode(cgv_event, 404);
UpnpStateVarRequest_strcpy_ErrStr(cgv_event, "Invalid Variable" );
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 );
return UpnpStateVarRequest_get_ErrCode(cgv_event) == UPNP_E_SUCCESS;
return ( cgv_event->ErrCode == UPNP_E_SUCCESS );
}
/******************************************************************************
@@ -505,7 +503,7 @@ TvDeviceHandleGetVarRequest( INOUT UpnpStateVarRequest *cgv_event )
*
*****************************************************************************/
int
TvDeviceHandleActionRequest( INOUT UpnpActionRequest *ca_event )
TvDeviceHandleActionRequest( INOUT struct Upnp_Action_Request *ca_event )
{
/*
Defaults if action not found
@@ -515,38 +513,51 @@ TvDeviceHandleActionRequest( INOUT UpnpActionRequest *ca_event )
int service = -1;
int retCode = 0;
char *errorString = NULL;
const char *devUDN = NULL;
const char *serviceID = NULL;
const char *actionName = NULL;
IXML_Document *actionResult = NULL;
UpnpActionRequest_set_ErrCode(ca_event, 0);
UpnpActionRequest_set_ActionResult(ca_event, NULL);
ca_event->ErrCode = 0;
ca_event->ActionResult = NULL;
devUDN = UpnpString_get_String(UpnpActionRequest_get_DevUDN( ca_event));
serviceID = UpnpString_get_String(UpnpActionRequest_get_ServiceID( ca_event));
actionName = UpnpString_get_String(UpnpActionRequest_get_ActionName(ca_event));
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 */
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( 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 */
} 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. */
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](
UpnpActionRequest_get_ActionRequest(ca_event),
&actionResult,
//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( 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 );
UpnpActionRequest_set_ActionResult(ca_event, actionResult);
} else {
errorString = "Power is Off";
retCode = UPNP_E_INTERNAL_ERROR;
@@ -557,25 +568,25 @@ TvDeviceHandleActionRequest( INOUT UpnpActionRequest *ca_event )
}
if( !action_found ) {
UpnpActionRequest_set_ActionResult(ca_event, NULL);
UpnpActionRequest_strcpy_ErrStr(ca_event, "Invalid Action" );
UpnpActionRequest_set_ErrCode(ca_event, 401);
ca_event->ActionResult = NULL;
strcpy( ca_event->ErrStr, "Invalid Action" );
ca_event->ErrCode = 401;
} else {
if( retCode == UPNP_E_SUCCESS ) {
UpnpActionRequest_set_ErrCode(ca_event, UPNP_E_SUCCESS);
ca_event->ErrCode = UPNP_E_SUCCESS;
} else {
// copy the error string
UpnpActionRequest_strcpy_ErrStr(ca_event, errorString );
strcpy( ca_event->ErrStr, errorString );
switch ( retCode ) {
case UPNP_E_INVALID_PARAM:
{
UpnpActionRequest_set_ErrCode(ca_event, 402);
ca_event->ErrCode = 402;
break;
}
case UPNP_E_INTERNAL_ERROR:
default:
{
UpnpActionRequest_set_ErrCode(ca_event, 501);
ca_event->ErrCode = 501;
break;
}
@@ -583,7 +594,7 @@ TvDeviceHandleActionRequest( INOUT UpnpActionRequest *ca_event )
}
}
return UpnpActionRequest_get_ErrCode(ca_event);
return ( ca_event->ErrCode );
}
/******************************************************************************
@@ -1761,15 +1772,20 @@ int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Co
{
switch ( EventType ) {
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
TvDeviceHandleSubscriptionRequest((UpnpSubscriptionRequest *)Event);
TvDeviceHandleSubscriptionRequest( ( struct
Upnp_Subscription_Request
* )Event );
break;
case UPNP_CONTROL_GET_VAR_REQUEST:
TvDeviceHandleGetVarRequest( (UpnpStateVarRequest *)Event );
TvDeviceHandleGetVarRequest( ( struct Upnp_State_Var_Request
* )Event );
break;
case UPNP_CONTROL_ACTION_REQUEST:
TvDeviceHandleActionRequest( (UpnpActionRequest *)Event );
TvDeviceHandleActionRequest( ( struct Upnp_Action_Request * )
Event );
break;
/*
@@ -1856,7 +1872,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 ) {
@@ -1870,8 +1887,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 = "tvcombodesc.xml";

View File

@@ -1,65 +1,52 @@
/**************************************************************************
*
* 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 "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>
#ifndef WIN32
#include <unistd.h>
#endif
#include <string.h>
#include "upnp.h"
#include "sample_util.h"
//Color constants
#define MAX_COLOR 10
@@ -161,7 +148,8 @@ 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 */
@@ -205,7 +193,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
@@ -239,7 +227,7 @@ int TvDeviceStateTableInit(char*);
* sr_event -- The subscription request event structure
*
*****************************************************************************/
int TvDeviceHandleSubscriptionRequest(const UpnpSubscriptionRequest *);
int TvDeviceHandleSubscriptionRequest(struct Upnp_Subscription_Request *);
/******************************************************************************
* TvDeviceHandleGetVarRequest
@@ -253,7 +241,7 @@ int TvDeviceHandleSubscriptionRequest(const UpnpSubscriptionRequest *);
* cgv_event -- The control get variable request event structure
*
*****************************************************************************/
int TvDeviceHandleGetVarRequest(UpnpStateVarRequest *);
int TvDeviceHandleGetVarRequest(struct Upnp_State_Var_Request *);
/******************************************************************************
* TvDeviceHandleActionRequest
@@ -267,7 +255,7 @@ int TvDeviceHandleGetVarRequest(UpnpStateVarRequest *);
* ca_event -- The control action request event structure
*
*****************************************************************************/
int TvDeviceHandleActionRequest(UpnpActionRequest *);
int TvDeviceHandleActionRequest(struct Upnp_Action_Request *);
/******************************************************************************
* TvDeviceCallbackEventHandler
@@ -325,7 +313,8 @@ 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
@@ -340,7 +329,8 @@ int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out, OUT char **e
* 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
@@ -357,7 +347,8 @@ int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out, OUT char **e
* 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
@@ -372,7 +363,8 @@ int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT char *
* 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
*
@@ -386,7 +378,8 @@ int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT c
* 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
*
@@ -402,7 +395,8 @@ int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT c
* 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
@@ -417,7 +411,8 @@ int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **
* 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);
/******************************************************************************
@@ -433,7 +428,8 @@ int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT ch
* 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
@@ -453,7 +449,8 @@ int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT ch
* 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);
/******************************************************************************
@@ -468,7 +465,8 @@ int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out, OUT char **e
* 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
@@ -482,7 +480,8 @@ int TvDeviceIncreaseColor(IN IXML_Document * in, OUT IXML_Document **out, OUT ch
* 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,7 +498,8 @@ int TvDeviceDecreaseColor(IN IXML_Document * in, OUT IXML_Document **out, OUT ch
* 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,7 +514,8 @@ int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char **er
* 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
@@ -529,7 +530,8 @@ int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char
* 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
@@ -546,7 +548,8 @@ int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char
* 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
@@ -562,7 +565,8 @@ int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out, OUT char
* 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
*
@@ -576,7 +580,8 @@ int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out, 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
@@ -590,7 +595,8 @@ int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out, 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
@@ -605,7 +611,8 @@ int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out, OUT cha
* 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
@@ -619,7 +626,8 @@ int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out, OU
* 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

@@ -943,25 +943,23 @@ TvStateUpdate( char *UDN,
*
********************************************************************************/
void TvCtrlPointHandleEvent(
const UpnpString *sid,
const Upnp_SID sid,
int evntkey,
IXML_Document *changes)
{
struct TvDeviceNode *tmpdevnode;
int service;
const char *aux_sid = NULL;
ithread_mutex_lock(&DeviceListMutex);
tmpdevnode = GlobalDeviceList;
while (tmpdevnode) {
for (service = 0; service < TV_SERVICE_SERVCOUNT; ++service) {
aux_sid = UpnpString_get_String(sid);
if (strcmp(tmpdevnode->device.TvService[service].SID, aux_sid) == 0) {
if (strcmp(tmpdevnode->device.TvService[service].SID, sid) == 0) {
SampleUtil_Print("Received Tv %s Event: %d for SID %s",
TvServiceName[service],
evntkey,
aux_sid);
sid);
TvStateUpdate(
tmpdevnode->device.UDN,
service,
@@ -1063,31 +1061,30 @@ TvCtrlPointHandleGetVar( const char *controlURL,
********************************************************************************/
int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Cookie)
{
int errCode = 0;
/*int errCode = 0;*/
SampleUtil_PrintEvent(EventType, Event);
switch ( EventType ) {
/* SSDP Stuff */
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
case UPNP_DISCOVERY_SEARCH_RESULT: {
UpnpDiscovery *d_event = (UpnpDiscovery *)Event;
struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event;
IXML_Document *DescDoc = NULL;
const char *location = NULL;
int errCode = UpnpDiscovery_get_ErrCode(d_event);
if (errCode != UPNP_E_SUCCESS) {
int ret;
if (d_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Discovery Callback -- %d", errCode);
"Error in Discovery Callback -- %d", d_event->ErrCode);
}
location = UpnpString_get_String(UpnpDiscovery_get_Location(d_event));
errCode = UpnpDownloadXmlDoc(location, &DescDoc);
if (errCode != UPNP_E_SUCCESS) {
ret = UpnpDownloadXmlDoc(d_event->Location, &DescDoc);
if (ret != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error obtaining device description from %s -- error = %d",
location, errCode);
d_event->Location, ret );
} else {
TvCtrlPointAddDevice(
DescDoc, location, UpnpDiscovery_get_Expires(d_event));
DescDoc, d_event->Location, d_event->Expires);
}
if( DescDoc ) {
@@ -1103,33 +1100,29 @@ int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void
break;
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE: {
UpnpDiscovery *d_event = (UpnpDiscovery *)Event;
int errCode = UpnpDiscovery_get_ErrCode(d_event);
const char *deviceId = UpnpString_get_String(
UpnpDiscovery_get_DeviceID(d_event));
struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event;
if (errCode != UPNP_E_SUCCESS) {
if (d_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Discovery ByeBye Callback -- %d", errCode);
"Error in Discovery ByeBye Callback -- %d", d_event->ErrCode);
}
SampleUtil_Print("Received ByeBye for Device: %s", deviceId);
TvCtrlPointRemoveDevice(deviceId);
SampleUtil_Print("Received ByeBye for Device: %s", d_event->DeviceId);
TvCtrlPointRemoveDevice(d_event->DeviceId);
SampleUtil_Print("After byebye:");
TvCtrlPointPrintList();
break;
}
/* SOAP Stuff */
case UPNP_CONTROL_ACTION_COMPLETE: {
UpnpActionComplete *a_event = (UpnpActionComplete *)Event;
int errCode = UpnpActionComplete_get_ErrCode(a_event);
if (errCode != UPNP_E_SUCCESS) {
struct Upnp_Action_Complete *a_event = (struct Upnp_Action_Complete *)Event;
if (a_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Action Complete Callback -- %d",
errCode);
a_event->ErrCode);
}
/* No need for any processing here, just print out results.
@@ -1137,76 +1130,73 @@ int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void
break;
}
case UPNP_CONTROL_GET_VAR_COMPLETE: {
UpnpStateVarComplete *sv_event = (UpnpStateVarComplete *)Event;
int errCode = UpnpStateVarComplete_get_ErrCode(sv_event);
if (errCode != UPNP_E_SUCCESS) {
struct Upnp_State_Var_Complete *sv_event = (struct Upnp_State_Var_Complete *)Event;
if (sv_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Get Var Complete Callback -- %d",
errCode );
sv_event->ErrCode);
} else {
TvCtrlPointHandleGetVar(
UpnpString_get_String(UpnpStateVarComplete_get_CtrlUrl(sv_event)),
UpnpString_get_String(UpnpStateVarComplete_get_StateVarName(sv_event)),
UpnpStateVarComplete_get_CurrentVal(sv_event) );
sv_event->CtrlUrl,
sv_event->StateVarName,
sv_event->CurrentVal);
}
break;
}
/* GENA Stuff */
case UPNP_EVENT_RECEIVED: {
UpnpEvent *e_event = (UpnpEvent *)Event;
struct Upnp_Event *e_event = (struct Upnp_Event *)Event;
TvCtrlPointHandleEvent(
UpnpEvent_get_SID(e_event),
UpnpEvent_get_EventKey(e_event),
UpnpEvent_get_ChangedVariables(e_event));
e_event->Sid,
e_event->EventKey,
e_event->ChangedVariables);
break;
}
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
case UPNP_EVENT_RENEWAL_COMPLETE: {
UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event;
errCode = UpnpEventSubscribe_get_ErrCode(es_event);
if (errCode != UPNP_E_SUCCESS) {
struct Upnp_Event_Subscribe *es_event = (struct Upnp_Event_Subscribe *)Event;
if (es_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Event Subscribe Callback -- %d",
errCode);
es_event->ErrCode);
} else {
TvCtrlPointHandleSubscribeUpdate(
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
UpnpString_get_String(UpnpEventSubscribe_get_SID(es_event)),
UpnpEventSubscribe_get_TimeOut(es_event));
es_event->PublisherUrl,
es_event->Sid,
es_event->TimeOut);
}
break;
}
case UPNP_EVENT_AUTORENEWAL_FAILED:
case UPNP_EVENT_SUBSCRIPTION_EXPIRED: {
UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event;
struct Upnp_Event_Subscribe *es_event = (struct Upnp_Event_Subscribe *)Event;
int TimeOut = default_timeout;
Upnp_SID newSID;
int ret;
errCode = UpnpSubscribe(
ret = UpnpSubscribe(
ctrlpt_handle,
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
es_event->PublisherUrl,
&TimeOut,
newSID);
if (errCode == UPNP_E_SUCCESS) {
if (ret == UPNP_E_SUCCESS) {
SampleUtil_Print("Subscribed to EventURL with SID=%s", newSID);
TvCtrlPointHandleSubscribeUpdate(
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
es_event->PublisherUrl,
newSID,
TimeOut);
} else {
SampleUtil_Print("Error Subscribing to EventURL -- %d", errCode);
SampleUtil_Print("Error Subscribing to EventURL -- %d", ret);
}
break;
}
/* ignore these cases, since this is not a device */
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
case UPNP_CONTROL_GET_VAR_REQUEST:
@@ -1341,7 +1331,8 @@ int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionP
SampleUtil_Print(
"Initializing UPnP Sdk with\n"
"\tipaddress = %s port = %u\n",
ip_address, port);
ip_address ? ip_address : "{NULL}",
port);
rc = UpnpInit(ip_address, port);
if (rc != UPNP_E_SUCCESS) {
@@ -1358,8 +1349,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

@@ -120,11 +120,11 @@ extern ithread_mutex_t DeviceListMutex;
extern UpnpClient_Handle ctrlpt_handle;
void TvCtrlPointPrintHelp();
void TvCtrlPointPrintHelp(void);
int TvCtrlPointDeleteNode(struct TvDeviceNode*);
int TvCtrlPointRemoveDevice(const char *);
int TvCtrlPointRemoveAll();
int TvCtrlPointRefresh();
int TvCtrlPointRemoveAll(void);
int TvCtrlPointRefresh(void);
int TvCtrlPointSendAction(int, int, char *, char **, char **, int);
@@ -153,7 +153,7 @@ 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 UpnpString *, int, IXML_Document *);
void TvCtrlPointHandleEvent(const Upnp_SID, int, IXML_Document *);
void TvCtrlPointHandleSubscribeUpdate(const char *, const Upnp_SID, int);
int TvCtrlPointCallbackEventHandler(Upnp_EventType, void *, void *);
void TvCtrlPointVerifyTimeouts(int);

View File

@@ -373,28 +373,23 @@ TvDeviceStateTableInit( IN char *DescDocURL )
* sr_event -- The subscription request event structure
*
*****************************************************************************/
int TvDeviceHandleSubscriptionRequest(IN const UpnpSubscriptionRequest *sr_event)
int
TvDeviceHandleSubscriptionRequest( IN struct Upnp_Subscription_Request
*sr_event )
{
unsigned int i = 0;
//unsigned int j = 0;
int cmp1 = 0;
int cmp2 = 0;
const char *l_serviceId = NULL;
const char *l_udn = NULL;
const char *l_sid = NULL;
unsigned int i = 0; //,j=0;
// IXML_Document *PropSet = NULL;
// lock state mutex
ithread_mutex_lock( &TVDevMutex );
l_serviceId = UpnpString_get_String(UpnpSubscriptionRequest_get_ServiceId(sr_event));
l_udn = UpnpString_get_String(UpnpSubscriptionRequest_get_UDN(sr_event));
l_sid = UpnpString_get_String(UpnpSubscriptionRequest_get_SID(sr_event));
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
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 ) ) {
/*
PropSet = NULL;
for (j = 0; j< tv_service_table[i].VariableCount; ++j) {
@@ -409,23 +404,25 @@ int TvDeviceHandleSubscriptionRequest(IN const UpnpSubscriptionRequest *sr_event
// dump initial state
UpnpAcceptSubscriptionExt(
device_handle,
l_udn,
l_serviceId,
sr_event->UDN,
sr_event->ServiceId,
PropSet,
l_sid);
sr_event->Sid);
// free document
Document_free(PropSet);
#endif
UpnpAcceptSubscription(
device_handle,
l_udn,
l_serviceId,
*/
UpnpAcceptSubscription( device_handle,
sr_event->UDN,
sr_event->ServiceId,
(const char **)tv_service_table[i].
VariableName,
(const char **)tv_service_table[i].
VariableStrVal,
tv_service_table[i].VariableCount,
l_sid);
sr_event->Sid);
}
}
@@ -448,32 +445,31 @@ int TvDeviceHandleSubscriptionRequest(IN const UpnpSubscriptionRequest *sr_event
*
*****************************************************************************/
int
TvDeviceHandleGetVarRequest( INOUT UpnpStateVarRequest *cgv_event )
TvDeviceHandleGetVarRequest( INOUT struct Upnp_State_Var_Request
*cgv_event )
{
unsigned int i = 0;
unsigned int j = 0;
int getvar_succeeded = 0;
UpnpStateVarRequest_set_CurrentVal(cgv_event, NULL);
cgv_event->CurrentVal = NULL;
ithread_mutex_lock( &TVDevMutex );
for( i = 0; i < TV_SERVICE_SERVCOUNT; i++ ) {
// check udn and service id
const char *devUDN =
UpnpString_get_String(UpnpStateVarRequest_get_DevUDN(cgv_event));
const char *serviceID =
UpnpString_get_String(UpnpStateVarRequest_get_ServiceID(cgv_event));
if( ( strcmp( devUDN, tv_service_table[i].UDN ) == 0 ) &&
( strcmp( serviceID, tv_service_table[i].ServiceId ) == 0 ) ) {
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++ ) {
const char *stateVarName =
UpnpString_get_String(UpnpStateVarRequest_get_StateVarName(cgv_event));
if( strcmp( stateVarName, tv_service_table[i].VariableName[j] ) == 0 ) {
if( strcmp( cgv_event->StateVarName,
tv_service_table[i].VariableName[j] ) == 0 ) {
getvar_succeeded = 1;
UpnpStateVarRequest_set_CurrentVal(cgv_event,
tv_service_table[i].VariableStrVal[j] );
cgv_event->CurrentVal =
ixmlCloneDOMString( tv_service_table[i].
VariableStrVal[j] );
break;
}
}
@@ -481,19 +477,19 @@ TvDeviceHandleGetVarRequest( INOUT UpnpStateVarRequest *cgv_event )
}
if( getvar_succeeded ) {
UpnpStateVarRequest_set_ErrCode(cgv_event, UPNP_E_SUCCESS);
cgv_event->ErrCode = UPNP_E_SUCCESS;
} else {
SampleUtil_Print(
"Error in UPNP_CONTROL_GET_VAR_REQUEST callback:\n"
" Unknown variable name = %s\n",
UpnpString_get_String(UpnpStateVarRequest_get_StateVarName(cgv_event)) );
UpnpStateVarRequest_set_ErrCode(cgv_event, 404);
UpnpStateVarRequest_strcpy_ErrStr(cgv_event, "Invalid Variable" );
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 );
return UpnpStateVarRequest_get_ErrCode(cgv_event) == UPNP_E_SUCCESS;
return ( cgv_event->ErrCode == UPNP_E_SUCCESS );
}
/******************************************************************************
@@ -509,7 +505,7 @@ TvDeviceHandleGetVarRequest( INOUT UpnpStateVarRequest *cgv_event )
*
*****************************************************************************/
int
TvDeviceHandleActionRequest( INOUT UpnpActionRequest *ca_event )
TvDeviceHandleActionRequest( INOUT struct Upnp_Action_Request *ca_event )
{
/*
Defaults if action not found
@@ -519,38 +515,51 @@ TvDeviceHandleActionRequest( INOUT UpnpActionRequest *ca_event )
int service = -1;
int retCode = 0;
char *errorString = NULL;
const char *devUDN = NULL;
const char *serviceID = NULL;
const char *actionName = NULL;
IXML_Document *actionResult = NULL;
UpnpActionRequest_set_ErrCode(ca_event, 0);
UpnpActionRequest_set_ActionResult(ca_event, NULL);
ca_event->ErrCode = 0;
ca_event->ActionResult = NULL;
devUDN = UpnpString_get_String(UpnpActionRequest_get_DevUDN( ca_event));
serviceID = UpnpString_get_String(UpnpActionRequest_get_ServiceID( ca_event));
actionName = UpnpString_get_String(UpnpActionRequest_get_ActionName(ca_event));
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 */
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( 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 */
} 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. */
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](
UpnpActionRequest_get_ActionRequest(ca_event),
&actionResult,
//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( 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 );
UpnpActionRequest_set_ActionResult(ca_event, actionResult);
} else {
errorString = "Power is Off";
retCode = UPNP_E_INTERNAL_ERROR;
@@ -561,25 +570,25 @@ TvDeviceHandleActionRequest( INOUT UpnpActionRequest *ca_event )
}
if( !action_found ) {
UpnpActionRequest_set_ActionResult(ca_event, NULL);
UpnpActionRequest_strcpy_ErrStr(ca_event, "Invalid Action" );
UpnpActionRequest_set_ErrCode(ca_event, 401);
ca_event->ActionResult = NULL;
strcpy( ca_event->ErrStr, "Invalid Action" );
ca_event->ErrCode = 401;
} else {
if( retCode == UPNP_E_SUCCESS ) {
UpnpActionRequest_set_ErrCode(ca_event, UPNP_E_SUCCESS);
ca_event->ErrCode = UPNP_E_SUCCESS;
} else {
// copy the error string
UpnpActionRequest_strcpy_ErrStr(ca_event, errorString );
strcpy( ca_event->ErrStr, errorString );
switch ( retCode ) {
case UPNP_E_INVALID_PARAM:
{
UpnpActionRequest_set_ErrCode(ca_event, 402);
ca_event->ErrCode = 402;
break;
}
case UPNP_E_INTERNAL_ERROR:
default:
{
UpnpActionRequest_set_ErrCode(ca_event, 501);
ca_event->ErrCode = 501;
break;
}
@@ -587,7 +596,7 @@ TvDeviceHandleActionRequest( INOUT UpnpActionRequest *ca_event )
}
}
return UpnpActionRequest_get_ErrCode(ca_event);
return ( ca_event->ErrCode );
}
/******************************************************************************
@@ -1765,15 +1774,20 @@ int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Co
{
switch ( EventType ) {
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
TvDeviceHandleSubscriptionRequest((UpnpSubscriptionRequest *)Event);
TvDeviceHandleSubscriptionRequest( ( struct
Upnp_Subscription_Request
* )Event );
break;
case UPNP_CONTROL_GET_VAR_REQUEST:
TvDeviceHandleGetVarRequest( (UpnpStateVarRequest *)Event );
TvDeviceHandleGetVarRequest( ( struct Upnp_State_Var_Request
* )Event );
break;
case UPNP_CONTROL_ACTION_REQUEST:
TvDeviceHandleActionRequest( (UpnpActionRequest *)Event );
TvDeviceHandleActionRequest( ( struct Upnp_Action_Request * )
Event );
break;
/*

View File

@@ -1,4 +1,4 @@
/**************************************************************************
/*******************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
@@ -27,39 +27,27 @@
* 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 "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>
#ifndef WIN32
#include <unistd.h>
#endif
#include <string.h>
#include "upnp.h"
#include "sample_util.h"
//Color constants
#define MAX_COLOR 10
@@ -161,7 +149,8 @@ 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 */
@@ -205,7 +194,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
@@ -239,7 +228,7 @@ int TvDeviceStateTableInit(char*);
* sr_event -- The subscription request event structure
*
*****************************************************************************/
int TvDeviceHandleSubscriptionRequest(const UpnpSubscriptionRequest *);
int TvDeviceHandleSubscriptionRequest(struct Upnp_Subscription_Request *);
/******************************************************************************
* TvDeviceHandleGetVarRequest
@@ -253,7 +242,7 @@ int TvDeviceHandleSubscriptionRequest(const UpnpSubscriptionRequest *);
* cgv_event -- The control get variable request event structure
*
*****************************************************************************/
int TvDeviceHandleGetVarRequest(UpnpStateVarRequest *);
int TvDeviceHandleGetVarRequest(struct Upnp_State_Var_Request *);
/******************************************************************************
* TvDeviceHandleActionRequest
@@ -267,7 +256,7 @@ int TvDeviceHandleGetVarRequest(UpnpStateVarRequest *);
* ca_event -- The control action request event structure
*
*****************************************************************************/
int TvDeviceHandleActionRequest(UpnpActionRequest *);
int TvDeviceHandleActionRequest(struct Upnp_Action_Request *);
/******************************************************************************
* TvDeviceCallbackEventHandler
@@ -325,7 +314,8 @@ 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
@@ -340,7 +330,8 @@ int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out, OUT char **e
* 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
@@ -357,7 +348,8 @@ int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out, OUT char **e
* 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
@@ -372,7 +364,8 @@ int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT char *
* 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
*
@@ -386,7 +379,8 @@ int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT c
* 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
*
@@ -402,7 +396,8 @@ int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT c
* 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
@@ -417,7 +412,8 @@ int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **
* 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);
/******************************************************************************
@@ -433,7 +429,8 @@ int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT ch
* 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
@@ -453,7 +450,8 @@ int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT ch
* 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);
/******************************************************************************
@@ -468,7 +466,8 @@ int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out, OUT char **e
* 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
@@ -482,7 +481,8 @@ int TvDeviceIncreaseColor(IN IXML_Document * in, OUT IXML_Document **out, OUT ch
* 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,7 +499,8 @@ int TvDeviceDecreaseColor(IN IXML_Document * in, OUT IXML_Document **out, OUT ch
* 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,7 +515,8 @@ int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char **er
* 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
@@ -529,7 +531,8 @@ int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char
* 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
@@ -546,7 +549,8 @@ int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char
* 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
@@ -562,7 +566,8 @@ int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out, OUT char
* 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
*
@@ -576,7 +581,8 @@ int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out, 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
@@ -590,7 +596,8 @@ int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out, 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
@@ -605,7 +612,8 @@ int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out, OUT cha
* 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
@@ -619,7 +627,8 @@ int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out, OU
* 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

@@ -1,157 +0,0 @@
/*!
* \file
*
* \brief UpnpActionComplete object implementation.
*
* \author Marcelo Roberto Jimenez
*/
#include "config.h"
#include "ActionComplete.h"
#include <stdlib.h> /* for calloc(), free() */
#include <string.h> /* for strlen(), strdup() */
/*!
* \brief Internal implementation of the UpnpActionComplete object.
*/
struct SUpnpActionComplete
{
/*! The result of the operation */
int m_errCode;
/*! The control URL for service. */
UpnpString *m_ctrlUrl;
/*! The DOM document describing the action. */
IXML_Document *m_actionRequest;
/*! The DOM document describing the result of the action */
IXML_Document *m_actionResult;
};
UpnpActionComplete *UpnpActionComplete_new()
{
struct SUpnpActionComplete *p = calloc(1, sizeof (struct SUpnpActionComplete));
#if 0
p->m_errCode = 0;
#endif
p->m_ctrlUrl = UpnpString_new();
#if 0
p->m_actionRequest = NULL;
p->m_actionResult = NULL;
#endif
return (UpnpActionComplete *)p;
}
void UpnpActionComplete_delete(UpnpActionComplete *p)
{
struct SUpnpActionComplete *q = (struct SUpnpActionComplete *)p;
if (!q) return;
q->m_errCode = 0;
UpnpString_delete(q->m_ctrlUrl);
q->m_ctrlUrl = NULL;
UpnpActionComplete_set_ActionRequest(p, NULL);
UpnpActionComplete_set_ActionResult(p, NULL);
free(p);
}
UpnpActionComplete *UpnpActionComplete_dup(const UpnpActionComplete *p)
{
UpnpActionComplete *q = UpnpActionComplete_new();
UpnpActionComplete_assign(q, p);
return q;
}
void UpnpActionComplete_assign(UpnpActionComplete *p, const UpnpActionComplete *q)
{
if (p != q) {
UpnpActionComplete_set_ErrCode(p, UpnpActionComplete_get_ErrCode(q));
UpnpActionComplete_set_CtrlUrl(p, UpnpActionComplete_get_CtrlUrl(q));
UpnpActionComplete_set_ActionRequest(p, UpnpActionComplete_get_ActionRequest(q));
UpnpActionComplete_set_ActionResult(p, UpnpActionComplete_get_ActionResult(q));
}
}
int UpnpActionComplete_get_ErrCode(const UpnpActionComplete *p)
{
return ((struct SUpnpActionComplete *)p)->m_errCode;
}
void UpnpActionComplete_set_ErrCode(UpnpActionComplete *p, int n)
{
((struct SUpnpActionComplete *)p)->m_errCode = n;
}
const UpnpString *UpnpActionComplete_get_CtrlUrl(const UpnpActionComplete *p)
{
return ((struct SUpnpActionComplete *)p)->m_ctrlUrl;
}
const char *UpnpActionComplete_get_CtrlUrl_cstr(const UpnpActionComplete *p)
{
return UpnpString_get_String(UpnpActionComplete_get_CtrlUrl(p));
}
void UpnpActionComplete_set_CtrlUrl(UpnpActionComplete *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpActionComplete *)p)->m_ctrlUrl);
((struct SUpnpActionComplete *)p)->m_ctrlUrl = UpnpString_dup(s);
}
void UpnpActionComplete_strcpy_CtrlUrl(UpnpActionComplete *p, const char *s)
{
UpnpString_delete(((struct SUpnpActionComplete *)p)->m_ctrlUrl);
((struct SUpnpActionComplete *)p)->m_ctrlUrl = UpnpString_new();
UpnpString_set_String(((struct SUpnpActionComplete *)p)->m_ctrlUrl, s);
}
IXML_Document *UpnpActionComplete_get_ActionRequest(const UpnpActionComplete *p)
{
return ((struct SUpnpActionComplete *)p)->m_actionRequest;
}
void UpnpActionComplete_set_ActionRequest(UpnpActionComplete *p, IXML_Document *d)
{
ixmlDocument_free(((struct SUpnpActionComplete *)p)->m_actionRequest);
((struct SUpnpActionComplete *)p)->m_actionRequest = d;
}
IXML_Document *UpnpActionComplete_get_ActionResult(const UpnpActionComplete *p)
{
return ((struct SUpnpActionComplete *)p)->m_actionResult;
}
void UpnpActionComplete_set_ActionResult(UpnpActionComplete *p, IXML_Document *d)
{
ixmlDocument_free(((struct SUpnpActionComplete *)p)->m_actionResult);
((struct SUpnpActionComplete *)p)->m_actionResult = d;
}

View File

@@ -1,283 +0,0 @@
/*!
* \file
*
* \brief UpnpActionRequest object implementation.
*
* \author Marcelo Roberto Jimenez
*/
#include "config.h"
#include "ActionRequest.h"
#include <stdlib.h> /* for calloc(), free() */
#include <string.h> /* for memset(), strlen(), strdup() */
struct SUpnpActionRequest
{
int m_errCode;
int m_socket;
UpnpString *m_errStr;
UpnpString *m_actionName;
UpnpString *m_devUDN;
UpnpString *m_serviceID;
IXML_Document *m_actionRequest;
IXML_Document *m_actionResult;
IXML_Document *m_soapHeader;
/* Variables should be declared with struct sockaddr_storage,
* but users must only see a struct sockaddr pointer */
struct sockaddr_storage m_ctrlPtIPAddr;
};
UpnpActionRequest *UpnpActionRequest_new()
{
struct SUpnpActionRequest *p = calloc(1, sizeof (struct SUpnpActionRequest));
#if 0
p->m_errCode = 0;
p->m_socket = 0;
#endif
p->m_errStr = UpnpString_new();
p->m_actionName = UpnpString_new();
p->m_devUDN = UpnpString_new();
p->m_serviceID = UpnpString_new();
#if 0
p->m_actionRequest = NULL;
p->m_actionResult = NULL;
p->m_soapHeader = NULL;
memset(&p->m_ctrlPtIPAddr, 0, sizeof (struct sockaddr_storage));
#endif
return (UpnpActionRequest *)p;
}
void UpnpActionRequest_delete(UpnpActionRequest *p)
{
struct SUpnpActionRequest *q = (struct SUpnpActionRequest *)p;
if (!q) return;
q->m_errCode = 0;
q->m_socket = 0;
UpnpString_delete(q->m_errStr);
q->m_errStr = NULL;
UpnpString_delete(q->m_actionName);
q->m_actionName = NULL;
UpnpString_delete(q->m_devUDN);
q->m_devUDN = NULL;
UpnpString_delete(q->m_serviceID);
q->m_serviceID = NULL;
UpnpActionRequest_set_ActionRequest(p, NULL);
UpnpActionRequest_set_ActionResult(p, NULL);
UpnpActionRequest_set_SoapHeader(p, NULL);
memset(&q->m_ctrlPtIPAddr, 0, sizeof (struct sockaddr_storage));
free(p);
}
UpnpActionRequest *UpnpActionRequest_dup(const UpnpActionRequest *p)
{
UpnpActionRequest *q = UpnpActionRequest_new();
UpnpActionRequest_assign(q, p);
return q;
}
void UpnpActionRequest_assign(UpnpActionRequest *p, const UpnpActionRequest *q)
{
if (p != q) {
UpnpActionRequest_set_ErrCode(p, UpnpActionRequest_get_ErrCode(q));
UpnpActionRequest_set_Socket(p, UpnpActionRequest_get_Socket(q));
UpnpActionRequest_set_ErrStr(p, UpnpActionRequest_get_ErrStr(q));
UpnpActionRequest_set_ActionName(p, UpnpActionRequest_get_ActionName(q));
UpnpActionRequest_set_DevUDN(p, UpnpActionRequest_get_DevUDN(q));
UpnpActionRequest_set_ServiceID(p, UpnpActionRequest_get_ServiceID(q));
UpnpActionRequest_set_ActionRequest(p, UpnpActionRequest_get_ActionRequest(q));
UpnpActionRequest_set_ActionResult(p, UpnpActionRequest_get_ActionResult(q));
UpnpActionRequest_set_CtrlPtIPAddr(p, UpnpActionRequest_get_CtrlPtIPAddr(q));
UpnpActionRequest_set_SoapHeader(p, UpnpActionRequest_get_SoapHeader(q));
}
}
int UpnpActionRequest_get_ErrCode(const UpnpActionRequest *p)
{
return ((struct SUpnpActionRequest *)p)->m_errCode;
}
void UpnpActionRequest_set_ErrCode(UpnpActionRequest *p, int n)
{
((struct SUpnpActionRequest *)p)->m_errCode = n;
}
int UpnpActionRequest_get_Socket(const UpnpActionRequest *p)
{
return ((struct SUpnpActionRequest *)p)->m_socket;
}
void UpnpActionRequest_set_Socket(UpnpActionRequest *p, int n)
{
((struct SUpnpActionRequest *)p)->m_socket = n;
}
const UpnpString *UpnpActionRequest_get_ErrStr(const UpnpActionRequest *p)
{
return ((struct SUpnpActionRequest *)p)->m_errStr;
}
const char *UpnpActionRequest_get_ErrStr_cstr(const UpnpActionRequest *p)
{
return UpnpString_get_String(UpnpActionRequest_get_ErrStr(p));
}
void UpnpActionRequest_set_ErrStr(UpnpActionRequest *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpActionRequest *)p)->m_errStr);
((struct SUpnpActionRequest *)p)->m_errStr = UpnpString_dup(s);
}
void UpnpActionRequest_strcpy_ErrStr(UpnpActionRequest *p, const char *s)
{
UpnpString_delete(((struct SUpnpActionRequest *)p)->m_errStr);
((struct SUpnpActionRequest *)p)->m_errStr = UpnpString_new();
UpnpString_set_String(((struct SUpnpActionRequest *)p)->m_errStr, s);
}
const UpnpString *UpnpActionRequest_get_ActionName(const UpnpActionRequest *p)
{
return ((struct SUpnpActionRequest *)p)->m_actionName;
}
const char *UpnpActionRequest_get_ActionName_cstr(const UpnpActionRequest *p)
{
return UpnpString_get_String(UpnpActionRequest_get_ActionName(p));
}
void UpnpActionRequest_set_ActionName(UpnpActionRequest *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpActionRequest *)p)->m_actionName);
((struct SUpnpActionRequest *)p)->m_actionName = UpnpString_dup(s);
}
void UpnpActionRequest_strcpy_ActionName(UpnpActionRequest *p, const char *s)
{
UpnpString_delete(((struct SUpnpActionRequest *)p)->m_actionName);
((struct SUpnpActionRequest *)p)->m_actionName = UpnpString_new();
UpnpString_set_String(((struct SUpnpActionRequest *)p)->m_actionName, s);
}
const UpnpString *UpnpActionRequest_get_DevUDN(const UpnpActionRequest *p)
{
return ((struct SUpnpActionRequest *)p)->m_devUDN;
}
const char *UpnpActionRequest_get_DevUDN_cstr(const UpnpActionRequest *p)
{
return UpnpString_get_String(UpnpActionRequest_get_DevUDN(p));
}
void UpnpActionRequest_set_DevUDN(UpnpActionRequest *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpActionRequest *)p)->m_devUDN);
((struct SUpnpActionRequest *)p)->m_devUDN = UpnpString_dup(s);
}
const UpnpString *UpnpActionRequest_get_ServiceID(const UpnpActionRequest *p)
{
return ((struct SUpnpActionRequest *)p)->m_serviceID;
}
const char *UpnpActionRequest_get_ServiceID_cstr(const UpnpActionRequest *p)
{
return UpnpString_get_String(UpnpActionRequest_get_ServiceID(p));
}
void UpnpActionRequest_set_ServiceID(UpnpActionRequest *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpActionRequest *)p)->m_serviceID);
((struct SUpnpActionRequest *)p)->m_serviceID = UpnpString_dup(s);
}
IXML_Document *UpnpActionRequest_get_ActionRequest(const UpnpActionRequest *p)
{
return ((struct SUpnpActionRequest *)p)->m_actionRequest;
}
void UpnpActionRequest_set_ActionRequest(UpnpActionRequest *p, IXML_Document *d)
{
ixmlDocument_free(((struct SUpnpActionRequest *)p)->m_actionRequest);
((struct SUpnpActionRequest *)p)->m_actionRequest = d;
}
IXML_Document *UpnpActionRequest_get_ActionResult(const UpnpActionRequest *p)
{
return ((struct SUpnpActionRequest *)p)->m_actionResult;
}
void UpnpActionRequest_set_ActionResult(UpnpActionRequest *p, IXML_Document *d)
{
ixmlDocument_free(((struct SUpnpActionRequest *)p)->m_actionResult);
((struct SUpnpActionRequest *)p)->m_actionResult = d;
}
const struct sockaddr *UpnpActionRequest_get_CtrlPtIPAddr(const UpnpActionRequest *p)
{
return (struct sockaddr *)&((struct SUpnpActionRequest *)p)->m_ctrlPtIPAddr;
}
void UpnpActionRequest_set_CtrlPtIPAddr(UpnpActionRequest *p, const struct sockaddr *ia)
{
((struct SUpnpActionRequest *)p)->m_ctrlPtIPAddr = *(struct sockaddr_storage *)ia;
}
IXML_Document *UpnpActionRequest_get_SoapHeader(const UpnpActionRequest *p)
{
return ((struct SUpnpActionRequest *)p)->m_soapHeader;
}
void UpnpActionRequest_set_SoapHeader(UpnpActionRequest *p, IXML_Document *d)
{
ixmlDocument_free(((struct SUpnpActionRequest *)p)->m_soapHeader);
((struct SUpnpActionRequest *)p)->m_soapHeader = d;
}

View File

@@ -1,396 +0,0 @@
/*!
* \file
*
* \brief UpnpDiscovery object implementation.
*
* \author Marcelo Roberto Jimenez
*/
#include "config.h"
#include "Discovery.h"
#include <stdlib.h> /* for calloc(), free() */
#include <string.h> /* for memset() */
struct SUpnpDiscovery
{
int m_errCode;
int m_expires;
UpnpString *m_deviceID;
UpnpString *m_deviceType;
UpnpString *m_serviceType;
UpnpString *m_serviceVer;
UpnpString *m_location;
UpnpString *m_os;
UpnpString *m_date;
UpnpString *m_ext;
/* Variables should be declared with struct sockaddr_storage,
* but users must only see a struct sockaddr pointer */
struct sockaddr_storage m_destAddr;
};
UpnpDiscovery *UpnpDiscovery_new()
{
struct SUpnpDiscovery *p = calloc(1, sizeof (struct SUpnpDiscovery));
#if 0
p->errCode = 0;
p->m_expires = 0;
#endif
p->m_deviceID = UpnpString_new();
p->m_deviceType = UpnpString_new();
p->m_serviceType = UpnpString_new();
p->m_serviceVer = UpnpString_new();
p->m_location = UpnpString_new();
p->m_os = UpnpString_new();
p->m_date = UpnpString_new();
p->m_ext = UpnpString_new();
memset(&p->m_destAddr, 0, sizeof(struct sockaddr_storage));
return (UpnpDiscovery *)p;
}
void UpnpDiscovery_delete(UpnpDiscovery *p)
{
struct SUpnpDiscovery *q = (struct SUpnpDiscovery *)p;
if (!q) return;
q->m_errCode = 0;
q->m_expires = 0;
UpnpString_delete(q->m_deviceID);
q->m_deviceID = NULL;
UpnpString_delete(q->m_deviceType);
q->m_deviceType = NULL;
UpnpString_delete(q->m_serviceType);
q->m_serviceType = NULL;
UpnpString_delete(q->m_serviceVer);
q->m_serviceVer = NULL;
UpnpString_delete(q->m_location);
q->m_location = NULL;
UpnpString_delete(q->m_os);
q->m_os = NULL;
UpnpString_delete(q->m_date);
q->m_date = NULL;
UpnpString_delete(q->m_ext);
q->m_ext = NULL;
memset(&q->m_destAddr, 0, sizeof(struct sockaddr_storage));
free(p);
}
UpnpDiscovery *UpnpDiscovery_dup(const UpnpDiscovery *p)
{
UpnpDiscovery *q = UpnpDiscovery_new();
UpnpDiscovery_assign(q, p);
return q;
}
void UpnpDiscovery_assign(UpnpDiscovery *p, const UpnpDiscovery *q)
{
if (p != q) {
UpnpDiscovery_set_ErrCode(p, UpnpDiscovery_get_ErrCode(q));
UpnpDiscovery_set_Expires(p, UpnpDiscovery_get_Expires(q));
UpnpDiscovery_set_DeviceID(p, UpnpDiscovery_get_DeviceID(q));
UpnpDiscovery_set_DeviceType(p, UpnpDiscovery_get_DeviceType(q));
UpnpDiscovery_set_ServiceType(p, UpnpDiscovery_get_ServiceType(q));
UpnpDiscovery_set_ServiceVer(p, UpnpDiscovery_get_ServiceVer(q));
UpnpDiscovery_set_Location(p, UpnpDiscovery_get_Location(q));
UpnpDiscovery_set_Os(p, UpnpDiscovery_get_Os(q));
UpnpDiscovery_set_Date(p, UpnpDiscovery_get_Date(q));
UpnpDiscovery_set_Ext(p, UpnpDiscovery_get_Ext(q));
UpnpDiscovery_set_DestAddr(p, UpnpDiscovery_get_DestAddr(q));
}
}
int UpnpDiscovery_get_ErrCode(const UpnpDiscovery *p)
{
return ((struct SUpnpDiscovery *)p)->m_errCode;
}
void UpnpDiscovery_set_ErrCode(UpnpDiscovery *p, int n)
{
((struct SUpnpDiscovery *)p)->m_errCode = n;
}
int UpnpDiscovery_get_Expires(const UpnpDiscovery *p)
{
return ((struct SUpnpDiscovery *)p)->m_expires;
}
void UpnpDiscovery_set_Expires(UpnpDiscovery *p, int n)
{
((struct SUpnpDiscovery *)p)->m_expires = n;
}
const UpnpString *UpnpDiscovery_get_DeviceID(const UpnpDiscovery *p)
{
return ((struct SUpnpDiscovery *)p)->m_deviceID;
}
const char *UpnpDiscovery_get_DeviceID_cstr(const UpnpDiscovery *p)
{
return UpnpString_get_String(UpnpDiscovery_get_DeviceID(p));
}
void UpnpDiscovery_set_DeviceID(UpnpDiscovery *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_deviceID);
((struct SUpnpDiscovery *)p)->m_deviceID = UpnpString_dup(s);
}
void UpnpDiscovery_strcpy_DeviceID(UpnpDiscovery *p, const char *s)
{
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_deviceID);
((struct SUpnpDiscovery *)p)->m_deviceID = UpnpString_new();
UpnpString_set_String(((struct SUpnpDiscovery *)p)->m_deviceID, s);
}
const UpnpString *UpnpDiscovery_get_DeviceType(const UpnpDiscovery *p)
{
return ((struct SUpnpDiscovery *)p)->m_deviceType;
}
const char *UpnpDiscovery_get_DeviceType_cstr(const UpnpDiscovery *p)
{
return UpnpString_get_String(UpnpDiscovery_get_DeviceType(p));
}
void UpnpDiscovery_set_DeviceType(UpnpDiscovery *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_deviceType);
((struct SUpnpDiscovery *)p)->m_deviceType = UpnpString_dup(s);
}
void UpnpDiscovery_strcpy_DeviceType(UpnpDiscovery *p, const char *s)
{
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_deviceType);
((struct SUpnpDiscovery *)p)->m_deviceType = UpnpString_new();
UpnpString_set_String(((struct SUpnpDiscovery *)p)->m_deviceType, s);
}
const UpnpString *UpnpDiscovery_get_ServiceType(const UpnpDiscovery *p)
{
return ((struct SUpnpDiscovery *)p)->m_serviceType;
}
const char *UpnpDiscovery_get_ServiceType_cstr(const UpnpDiscovery *p)
{
return UpnpString_get_String(UpnpDiscovery_get_ServiceType(p));
}
void UpnpDiscovery_set_ServiceType(UpnpDiscovery *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_serviceType);
((struct SUpnpDiscovery *)p)->m_serviceType = UpnpString_dup(s);
}
void UpnpDiscovery_strcpy_ServiceType(UpnpDiscovery *p, const char *s)
{
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_serviceType);
((struct SUpnpDiscovery *)p)->m_serviceType = UpnpString_new();
UpnpString_set_String(((struct SUpnpDiscovery *)p)->m_serviceType, s);
}
const UpnpString *UpnpDiscovery_get_ServiceVer(const UpnpDiscovery *p)
{
return ((struct SUpnpDiscovery *)p)->m_serviceVer;
}
const char *UpnpDiscovery_get_ServiceVer_cstr(const UpnpDiscovery *p)
{
return UpnpString_get_String(UpnpDiscovery_get_ServiceVer(p));
}
void UpnpDiscovery_set_ServiceVer(UpnpDiscovery *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_serviceVer);
((struct SUpnpDiscovery *)p)->m_serviceVer = UpnpString_dup(s);
}
void UpnpDiscovery_strcpy_ServiceVer(UpnpDiscovery *p, const char *s)
{
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_serviceVer);
((struct SUpnpDiscovery *)p)->m_serviceVer = UpnpString_new();
UpnpString_set_String(((struct SUpnpDiscovery *)p)->m_serviceVer, s);
}
const UpnpString *UpnpDiscovery_get_Location(const UpnpDiscovery *p)
{
return ((struct SUpnpDiscovery *)p)->m_location;
}
const char *UpnpDiscovery_get_Location_cstr(const UpnpDiscovery *p)
{
return UpnpString_get_String(UpnpDiscovery_get_Location(p));
}
void UpnpDiscovery_set_Location(UpnpDiscovery *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_location);
((struct SUpnpDiscovery *)p)->m_location = UpnpString_dup(s);
}
void UpnpDiscovery_strcpy_Location(UpnpDiscovery *p, const char *s)
{
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_location);
((struct SUpnpDiscovery *)p)->m_location = UpnpString_new();
UpnpString_set_String(((struct SUpnpDiscovery *)p)->m_location, s);
}
void UpnpDiscovery_strncpy_Location(UpnpDiscovery *p, const char *s, int n)
{
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_location);
((struct SUpnpDiscovery *)p)->m_location = UpnpString_new();
UpnpString_set_StringN(((struct SUpnpDiscovery *)p)->m_location, s, n);
}
const UpnpString *UpnpDiscovery_get_Os(const UpnpDiscovery *p)
{
return ((struct SUpnpDiscovery *)p)->m_os;
}
const char *UpnpDiscovery_get_Os_cstr(const UpnpDiscovery *p)
{
return UpnpString_get_String(UpnpDiscovery_get_Os(p));
}
void UpnpDiscovery_set_Os(UpnpDiscovery *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_os);
((struct SUpnpDiscovery *)p)->m_os = UpnpString_dup(s);
}
void UpnpDiscovery_strcpy_Os(UpnpDiscovery *p, const char *s)
{
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_os);
((struct SUpnpDiscovery *)p)->m_os = UpnpString_new();
UpnpString_set_String(((struct SUpnpDiscovery *)p)->m_os, s);
}
void UpnpDiscovery_strncpy_Os(UpnpDiscovery *p, const char *s, int n)
{
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_os);
((struct SUpnpDiscovery *)p)->m_os = UpnpString_new();
UpnpString_set_StringN(((struct SUpnpDiscovery *)p)->m_os, s, n);
}
const UpnpString *UpnpDiscovery_get_Date(const UpnpDiscovery *p)
{
return ((struct SUpnpDiscovery *)p)->m_date;
}
const char *UpnpDiscovery_get_Date_cstr(const UpnpDiscovery *p)
{
return UpnpString_get_String(UpnpDiscovery_get_Date(p));
}
void UpnpDiscovery_set_Date(UpnpDiscovery *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_date);
((struct SUpnpDiscovery *)p)->m_date = UpnpString_dup(s);
}
void UpnpDiscovery_strcpy_Date(UpnpDiscovery *p, const char *s)
{
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_date);
((struct SUpnpDiscovery *)p)->m_date = UpnpString_new();
UpnpString_set_String(((struct SUpnpDiscovery *)p)->m_date, s);
}
const UpnpString *UpnpDiscovery_get_Ext(const UpnpDiscovery *p)
{
return ((struct SUpnpDiscovery *)p)->m_ext;
}
const char *UpnpDiscovery_get_Ext_cstr(const UpnpDiscovery *p)
{
return UpnpString_get_String(UpnpDiscovery_get_Ext(p));
}
void UpnpDiscovery_set_Ext(UpnpDiscovery *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_ext);
((struct SUpnpDiscovery *)p)->m_ext = UpnpString_dup(s);
}
void UpnpDiscovery_strcpy_Ext(UpnpDiscovery *p, const char *s)
{
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_ext);
((struct SUpnpDiscovery *)p)->m_ext = UpnpString_new();
UpnpString_set_String(((struct SUpnpDiscovery *)p)->m_ext, s);
}
void UpnpDiscovery_strncpy_Ext(UpnpDiscovery *p, const char *s, int n)
{
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_ext);
((struct SUpnpDiscovery *)p)->m_ext = UpnpString_new();
UpnpString_set_StringN(((struct SUpnpDiscovery *)p)->m_ext, s, n);
}
const struct sockaddr *UpnpDiscovery_get_DestAddr(const UpnpDiscovery *p)
{
return (struct sockaddr *)&((struct SUpnpDiscovery *)p)->m_destAddr;
}
void UpnpDiscovery_set_DestAddr(UpnpDiscovery *p, const struct sockaddr *sa)
{
((struct SUpnpDiscovery *)p)->m_destAddr = *(struct sockaddr_storage *)sa;
}

View File

@@ -1,121 +0,0 @@
/*!
* \file
*
* \brief UpnpEvent object implementation.
*
* \author Marcelo Roberto Jimenez
*/
#include "config.h"
#include "Event.h"
#include <stdlib.h> /* for calloc(), free() */
struct SUpnpEvent
{
int m_eventKey;
IXML_Document *m_changedVariables;
UpnpString *m_SID;
};
UpnpEvent *UpnpEvent_new()
{
struct SUpnpEvent *p = calloc(1, sizeof (struct SUpnpEvent));
#if 0
p->m_eventKey = 0;
p->m_changedVariables = NULL;
#endif
p->m_SID = UpnpString_new();
return (UpnpEvent *)p;
}
void UpnpEvent_delete(UpnpEvent *p)
{
struct SUpnpEvent *q = (struct SUpnpEvent *)p;
if (!q) return;
q->m_eventKey = 0;
q->m_changedVariables = NULL;
UpnpString_delete(q->m_SID);
q->m_SID = NULL;
free(p);
}
UpnpEvent *UpnpEvent_dup(const UpnpEvent *p)
{
UpnpEvent *q = UpnpEvent_new();
UpnpEvent_assign(q, p);
return q;
}
void UpnpEvent_assign(UpnpEvent *p, const UpnpEvent *q)
{
if (p != q) {
UpnpEvent_set_EventKey(p, UpnpEvent_get_EventKey(q));
UpnpEvent_set_ChangedVariables(p, UpnpEvent_get_ChangedVariables(q));
UpnpEvent_set_SID(p, UpnpEvent_get_SID(q));
}
}
int UpnpEvent_get_EventKey(const UpnpEvent *p)
{
return ((struct SUpnpEvent *)p)->m_eventKey;
}
void UpnpEvent_set_EventKey(UpnpEvent *p, int n)
{
((struct SUpnpEvent *)p)->m_eventKey = n;
}
IXML_Document *UpnpEvent_get_ChangedVariables(const UpnpEvent *p)
{
return ((struct SUpnpEvent *)p)->m_changedVariables;
}
void UpnpEvent_set_ChangedVariables(UpnpEvent *p, IXML_Document *d)
{
ixmlDocument_free(((struct SUpnpEvent *)p)->m_changedVariables);
((struct SUpnpEvent *)p)->m_changedVariables = d;
}
const UpnpString *UpnpEvent_get_SID(const UpnpEvent *p)
{
return ((struct SUpnpEvent *)p)->m_SID;
}
const char *UpnpEvent_get_SID_cstr(const UpnpEvent *p)
{
return UpnpString_get_String(UpnpEvent_get_SID(p));
}
void UpnpEvent_set_SID(UpnpEvent *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpEvent *)p)->m_SID);
((struct SUpnpEvent *)p)->m_SID = UpnpString_dup(s);
}

View File

@@ -1,159 +0,0 @@
/*!
* \file
*
* \brief UpnpEventSubscribe object implementation.
*
* \author Marcelo Roberto Jimenez
*/
#include "config.h"
#include "EventSubscribe.h"
#include <stdlib.h> /* for calloc(), free() */
struct SEventSubscribe
{
int m_errCode;
int m_timeOut;
UpnpString *m_SID;
UpnpString *m_publisherUrl;
};
UpnpEventSubscribe *UpnpEventSubscribe_new()
{
struct SEventSubscribe *p = calloc(1, sizeof (struct SEventSubscribe));
#if 0
p->errCode = 0;
p->timeOut = 0;
#endif
p->m_SID = UpnpString_new();
p->m_publisherUrl = UpnpString_new();
return (UpnpEventSubscribe *)p;
}
void UpnpEventSubscribe_delete(UpnpEventSubscribe *p)
{
struct SEventSubscribe *q = (struct SEventSubscribe *)p;
if (!q) return;
q->m_errCode = 0;
q->m_timeOut = 0;
UpnpString_delete(q->m_publisherUrl);
q->m_publisherUrl = NULL;
UpnpString_delete(q->m_SID);
q->m_SID = NULL;
free(p);
}
UpnpEventSubscribe *UpnpEventSubscribe_dup(const UpnpEventSubscribe *p)
{
UpnpEventSubscribe *q = UpnpEventSubscribe_new();
UpnpEventSubscribe_assign(q, p);
return q;
}
void UpnpEventSubscribe_assign(UpnpEventSubscribe *p, const UpnpEventSubscribe *q)
{
if (p != q) {
UpnpEventSubscribe_set_ErrCode(p, UpnpEventSubscribe_get_ErrCode(q));
UpnpEventSubscribe_set_TimeOut(p, UpnpEventSubscribe_get_TimeOut(q));
UpnpEventSubscribe_set_SID(p, UpnpEventSubscribe_get_SID(q));
UpnpEventSubscribe_set_PublisherUrl(p, UpnpEventSubscribe_get_PublisherUrl(q));
}
}
int UpnpEventSubscribe_get_ErrCode(const UpnpEventSubscribe *p)
{
return ((struct SEventSubscribe *)p)->m_errCode;
}
void UpnpEventSubscribe_set_ErrCode(UpnpEventSubscribe *p, int n)
{
((struct SEventSubscribe *)p)->m_errCode = n;
}
int UpnpEventSubscribe_get_TimeOut(const UpnpEventSubscribe *p)
{
return ((struct SEventSubscribe *)p)->m_timeOut;
}
void UpnpEventSubscribe_set_TimeOut(UpnpEventSubscribe *p, int n)
{
((struct SEventSubscribe *)p)->m_timeOut = n;
}
const UpnpString *UpnpEventSubscribe_get_SID(const UpnpEventSubscribe *p)
{
return ((struct SEventSubscribe *)p)->m_SID;
}
const char *UpnpEventSubscribe_get_SID_cstr(const UpnpEventSubscribe *p)
{
return UpnpString_get_String(UpnpEventSubscribe_get_SID(p));
}
void UpnpEventSubscribe_set_SID(UpnpEventSubscribe *p, const UpnpString *s)
{
UpnpString_delete(((struct SEventSubscribe *)p)->m_SID);
((struct SEventSubscribe *)p)->m_SID = UpnpString_dup(s);
}
void UpnpEventSubscribe_strcpy_SID(UpnpEventSubscribe *p, const char *s)
{
UpnpString_delete(((struct SEventSubscribe *)p)->m_SID);
((struct SEventSubscribe *)p)->m_SID = UpnpString_new();
UpnpString_set_String(((struct SEventSubscribe *)p)->m_SID, s);
}
const UpnpString *UpnpEventSubscribe_get_PublisherUrl(const UpnpEventSubscribe *p)
{
return ((struct SEventSubscribe *)p)->m_publisherUrl;
}
const char *UpnpEventSubscribe_get_PublisherUrl_cstr(const UpnpEventSubscribe *p)
{
return UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(p));
}
void UpnpEventSubscribe_set_PublisherUrl(UpnpEventSubscribe *p, const UpnpString *s)
{
UpnpString_delete(((struct SEventSubscribe *)p)->m_publisherUrl);
((struct SEventSubscribe *)p)->m_publisherUrl = UpnpString_dup(s);
}
void UpnpEventSubscribe_strcpy_PublisherUrl(UpnpEventSubscribe *p, const char *s)
{
UpnpString_delete(((struct SEventSubscribe *)p)->m_publisherUrl);
((struct SEventSubscribe *)p)->m_publisherUrl = UpnpString_new();
UpnpString_set_String(((struct SEventSubscribe *)p)->m_publisherUrl, s);
}

View File

@@ -1,179 +0,0 @@
/*!
* \file
*
* \brief UpnpFileInfo object implementation.
*
* \author Marcelo Roberto Jimenez
*/
#include "config.h"
#include "FileInfo.h"
#include <stdlib.h> /* for calloc(), free() */
#include <string.h> /* for strlen(), strdup() */
struct SUpnpFileInfo
{
off_t m_fileLength;
time_t m_lastModified;
int m_isDirectory;
int m_isReadable;
DOMString m_contentType;
DOMString m_extraHeaders;
};
UpnpFileInfo *UpnpFileInfo_new()
{
struct SUpnpFileInfo *p = calloc(1, sizeof (struct SUpnpFileInfo));
#if 0
p->m_fileLength = 0;
p->m_lastModified = 0;
p->m_isDirectory = 0;
p->m_isReadable = 0;
p->m_contentType = NULL;
p->m_extraHeaders = NULL;
#endif
return (UpnpFileInfo *)p;
}
void UpnpFileInfo_delete(UpnpFileInfo *p)
{
struct SUpnpFileInfo *q = (struct SUpnpFileInfo *)p;
if (!q) return;
q->m_fileLength = 0;
q->m_lastModified = 0;
q->m_isDirectory = 0;
q->m_isReadable = 0;
ixmlFreeDOMString(q->m_contentType);
q->m_contentType = NULL;
ixmlFreeDOMString(q->m_extraHeaders);
q->m_extraHeaders = NULL;
free(p);
}
UpnpFileInfo *UpnpFileInfo_dup(const UpnpFileInfo *p)
{
UpnpFileInfo *q = UpnpFileInfo_new();
UpnpFileInfo_assign(q, p);
return q;
}
void UpnpFileInfo_assign(UpnpFileInfo *p, const UpnpFileInfo *q)
{
if (p != q) {
UpnpFileInfo_set_FileLength(p, UpnpFileInfo_get_FileLength(q));
UpnpFileInfo_set_LastModified(p, UpnpFileInfo_get_LastModified(q));
UpnpFileInfo_set_IsDirectory(p, UpnpFileInfo_get_IsDirectory(q));
UpnpFileInfo_set_IsReadable(p, UpnpFileInfo_get_IsReadable(q));
UpnpFileInfo_set_ContentType(p, UpnpFileInfo_get_ContentType(q));
UpnpFileInfo_set_ExtraHeaders(p, UpnpFileInfo_get_ExtraHeaders(q));
}
}
off_t UpnpFileInfo_get_FileLength(const UpnpFileInfo *p)
{
return ((struct SUpnpFileInfo *)p)->m_fileLength;
}
void UpnpFileInfo_set_FileLength(UpnpFileInfo *p, off_t l)
{
((struct SUpnpFileInfo *)p)->m_fileLength = l;
}
const time_t *UpnpFileInfo_get_LastModified(const UpnpFileInfo *p)
{
return &((struct SUpnpFileInfo *)p)->m_lastModified;
}
void UpnpFileInfo_set_LastModified(UpnpFileInfo *p, const time_t *t)
{
((struct SUpnpFileInfo *)p)->m_lastModified = *t;
}
int UpnpFileInfo_get_IsDirectory(const UpnpFileInfo *p)
{
return ((struct SUpnpFileInfo *)p)->m_isDirectory;
}
void UpnpFileInfo_set_IsDirectory(UpnpFileInfo *p, int b)
{
((struct SUpnpFileInfo *)p)->m_isDirectory = b;
}
int UpnpFileInfo_get_IsReadable(const UpnpFileInfo *p)
{
return ((struct SUpnpFileInfo *)p)->m_isReadable;
}
void UpnpFileInfo_set_IsReadable(UpnpFileInfo *p, int b)
{
((struct SUpnpFileInfo *)p)->m_isReadable = b;
}
const DOMString UpnpFileInfo_get_ContentType(const UpnpFileInfo *p)
{
return ((struct SUpnpFileInfo *)p)->m_contentType;
}
const char *UpnpFileInfo_get_ContentType_cstr(const UpnpFileInfo *p)
{
return (const char *)UpnpFileInfo_get_ContentType(p);
}
void UpnpFileInfo_set_ContentType(UpnpFileInfo *p, const DOMString s)
{
ixmlFreeDOMString(((struct SUpnpFileInfo *)p)->m_contentType);
((struct SUpnpFileInfo *)p)->m_contentType = ixmlCloneDOMString(s);
}
const DOMString UpnpFileInfo_get_ExtraHeaders(const UpnpFileInfo *p)
{
return ((struct SUpnpFileInfo *)p)->m_extraHeaders;
}
const char *UpnpFileInfo_get_ExtraHeaders_cstr(const UpnpFileInfo *p)
{
return (const char *)UpnpFileInfo_get_ExtraHeaders(p);
}
void UpnpFileInfo_set_ExtraHeaders(UpnpFileInfo *p, const DOMString s)
{
ixmlFreeDOMString(((struct SUpnpFileInfo *)p)->m_extraHeaders);
((struct SUpnpFileInfo *)p)->m_extraHeaders = ixmlCloneDOMString(s);
}

View File

@@ -1,170 +0,0 @@
/*!
* \file
*
* \brief UpnpStateVarComplete object implementation.
*
* \author Marcelo Roberto Jimenez
*/
#include "config.h"
#include "StateVarComplete.h"
#include <stdlib.h> /* for calloc(), free() */
#include <string.h> /* for strlen(), strdup() */
struct SUpnpStateVarComplete
{
int m_errCode;
UpnpString *m_ctrlUrl;
UpnpString *m_stateVarName;
DOMString m_currentVal;
};
UpnpStateVarComplete *UpnpStateVarComplete_new()
{
struct SUpnpStateVarComplete *p = calloc(1, sizeof (struct SUpnpStateVarComplete));
#if 0
p->m_errCode = 0;
#endif
p->m_ctrlUrl = UpnpString_new();
p->m_stateVarName = UpnpString_new();
#if 0
p->m_currentVal = NULL;
#endif
return (UpnpStateVarComplete *)p;
}
void UpnpStateVarComplete_delete(UpnpStateVarComplete *p)
{
struct SUpnpStateVarComplete *q = (struct SUpnpStateVarComplete *)p;
if (!q) return;
q->m_errCode = 0;
UpnpString_delete(q->m_ctrlUrl);
q->m_ctrlUrl = NULL;
UpnpString_delete(q->m_stateVarName);
q->m_stateVarName = NULL;
ixmlFreeDOMString(q->m_currentVal);
q->m_currentVal = NULL;
free(p);
}
UpnpStateVarComplete *UpnpStateVarComplete_dup(const UpnpStateVarComplete *p)
{
UpnpStateVarComplete *q = UpnpStateVarComplete_new();
UpnpStateVarComplete_assign(q, p);
return q;
}
void UpnpStateVarComplete_assign(UpnpStateVarComplete *p, const UpnpStateVarComplete *q)
{
if (p != q) {
UpnpStateVarComplete_set_ErrCode(p, UpnpStateVarComplete_get_ErrCode(q));
UpnpStateVarComplete_set_CtrlUrl(p, UpnpStateVarComplete_get_CtrlUrl(q));
UpnpStateVarComplete_set_StateVarName(p, UpnpStateVarComplete_get_StateVarName(q));
UpnpStateVarComplete_set_CurrentVal(p, UpnpStateVarComplete_get_CurrentVal(q));
}
}
int UpnpStateVarComplete_get_ErrCode(const UpnpStateVarComplete *p)
{
return ((struct SUpnpStateVarComplete *)p)->m_errCode;
}
void UpnpStateVarComplete_set_ErrCode(UpnpStateVarComplete *p, int n)
{
((struct SUpnpStateVarComplete *)p)->m_errCode = n;
}
const UpnpString *UpnpStateVarComplete_get_CtrlUrl(const UpnpStateVarComplete *p)
{
return ((struct SUpnpStateVarComplete *)p)->m_ctrlUrl;
}
const char *UpnpStateVarComplete_get_CtrlUrl_cstr(const UpnpStateVarComplete *p)
{
return UpnpString_get_String(UpnpStateVarComplete_get_CtrlUrl(p));
}
void UpnpStateVarComplete_set_CtrlUrl(UpnpStateVarComplete *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpStateVarComplete *)p)->m_ctrlUrl);
((struct SUpnpStateVarComplete *)p)->m_ctrlUrl = UpnpString_dup(s);
}
void UpnpStateVarComplete_strcpy_CtrlUrl(UpnpStateVarComplete *p, const char *s)
{
UpnpString_delete(((struct SUpnpStateVarComplete *)p)->m_ctrlUrl);
((struct SUpnpStateVarComplete *)p)->m_ctrlUrl = UpnpString_new();
UpnpString_set_String(((struct SUpnpStateVarComplete *)p)->m_ctrlUrl, s);
}
const UpnpString *UpnpStateVarComplete_get_StateVarName(const UpnpStateVarComplete *p)
{
return ((struct SUpnpStateVarComplete *)p)->m_stateVarName;
}
const char *UpnpStateVarComplete_get_StateVarName_cstr(const UpnpStateVarComplete *p)
{
return UpnpString_get_String(UpnpStateVarComplete_get_StateVarName(p));
}
void UpnpStateVarComplete_set_StateVarName(UpnpStateVarComplete *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpStateVarComplete *)p)->m_stateVarName);
((struct SUpnpStateVarComplete *)p)->m_stateVarName = UpnpString_dup(s);
}
void UpnpStateVarComplete_strcpy_StateVarName(UpnpStateVarComplete *p, const char *s)
{
UpnpString_delete(((struct SUpnpStateVarComplete *)p)->m_ctrlUrl);
((struct SUpnpStateVarComplete *)p)->m_ctrlUrl = UpnpString_new();
UpnpString_set_String(((struct SUpnpStateVarComplete *)p)->m_ctrlUrl, s);
}
const DOMString UpnpStateVarComplete_get_CurrentVal(const UpnpStateVarComplete *p)
{
return ((struct SUpnpStateVarComplete *)p)->m_currentVal;
}
const char *UpnpStateVarComplete_get_CurrentVal_cstr(const UpnpStateVarComplete *p)
{
return (const char *)UpnpStateVarComplete_get_CurrentVal(p);
}
void UpnpStateVarComplete_set_CurrentVal(UpnpStateVarComplete *p, const DOMString s)
{
ixmlFreeDOMString(((struct SUpnpStateVarComplete *)p)->m_currentVal);
((struct SUpnpStateVarComplete *)p)->m_currentVal = ixmlCloneDOMString(s);
}

View File

@@ -1,254 +0,0 @@
/*!
* \file
*
* \brief UpnpStateVarRequest object implementation.
*
* \author Marcelo Roberto Jimenez
*/
#include "config.h"
#include "StateVarRequest.h"
#include <stdlib.h> /* for calloc(), free() */
#include <string.h> /* for memset(), strlen(), strdup() */
struct SUpnpStateVarRequest
{
int m_errCode;
int m_socket;
UpnpString *m_errStr;
UpnpString *m_devUDN;
UpnpString *m_serviceID;
UpnpString *m_stateVarName;
/* Variables should be declared with struct sockaddr_storage,
* but users must only see a struct sockaddr pointer */
struct sockaddr_storage m_ctrlPtIPAddr;
DOMString m_currentVal;
};
UpnpStateVarRequest *UpnpStateVarRequest_new()
{
struct SUpnpStateVarRequest *p = calloc(1, sizeof (struct SUpnpStateVarRequest));
#if 0
p->m_errCode = 0;
p->m_socket = 0;
#endif
p->m_errStr = UpnpString_new();
p->m_devUDN = UpnpString_new();
p->m_serviceID = UpnpString_new();
p->m_stateVarName = UpnpString_new();
#if 0
memset(&q->m_ctrlPtIPAddr, 0, sizeof (struct sockaddr_storage));
p->m_currentVal = NULL;
#endif
return (UpnpStateVarRequest *)p;
}
void UpnpStateVarRequest_delete(UpnpStateVarRequest *p)
{
struct SUpnpStateVarRequest *q = (struct SUpnpStateVarRequest *)p;
if (!q) return;
q->m_errCode = 0;
q->m_socket = 0;
UpnpString_delete(q->m_errStr);
q->m_errStr = NULL;
UpnpString_delete(q->m_devUDN);
q->m_devUDN = NULL;
UpnpString_delete(q->m_serviceID);
q->m_serviceID = NULL;
UpnpString_delete(q->m_stateVarName);
q->m_stateVarName = NULL;
memset(&q->m_ctrlPtIPAddr, 0, sizeof (struct sockaddr_storage));
ixmlFreeDOMString(q->m_currentVal);
q->m_currentVal = NULL;
free(p);
}
UpnpStateVarRequest *UpnpStateVarRequest_dup(const UpnpStateVarRequest *p)
{
UpnpStateVarRequest *q = UpnpStateVarRequest_new();
UpnpStateVarRequest_assign(q, p);
return q;
}
void UpnpStateVarRequest_assign(UpnpStateVarRequest *p, const UpnpStateVarRequest *q)
{
if (p != q) {
UpnpStateVarRequest_set_ErrCode(p, UpnpStateVarRequest_get_ErrCode(q));
UpnpStateVarRequest_set_Socket(p, UpnpStateVarRequest_get_Socket(q));
UpnpStateVarRequest_set_ErrStr(p, UpnpStateVarRequest_get_ErrStr(q));
UpnpStateVarRequest_set_StateVarName(p, UpnpStateVarRequest_get_StateVarName(q));
UpnpStateVarRequest_set_DevUDN(p, UpnpStateVarRequest_get_DevUDN(q));
UpnpStateVarRequest_set_ServiceID(p, UpnpStateVarRequest_get_ServiceID(q));
UpnpStateVarRequest_set_CtrlPtIPAddr(p, UpnpStateVarRequest_get_CtrlPtIPAddr(q));
UpnpStateVarRequest_set_CurrentVal(p, UpnpStateVarRequest_get_CurrentVal(q));
}
}
int UpnpStateVarRequest_get_ErrCode(const UpnpStateVarRequest *p)
{
return ((struct SUpnpStateVarRequest *)p)->m_errCode;
}
void UpnpStateVarRequest_set_ErrCode(UpnpStateVarRequest *p, int n)
{
((struct SUpnpStateVarRequest *)p)->m_errCode = n;
}
int UpnpStateVarRequest_get_Socket(const UpnpStateVarRequest *p)
{
return ((struct SUpnpStateVarRequest *)p)->m_socket;
}
void UpnpStateVarRequest_set_Socket(UpnpStateVarRequest *p, int n)
{
((struct SUpnpStateVarRequest *)p)->m_socket = n;
}
const UpnpString *UpnpStateVarRequest_get_ErrStr(const UpnpStateVarRequest *p)
{
return ((struct SUpnpStateVarRequest *)p)->m_errStr;
}
const char *UpnpStateVarRequest_get_ErrStr_cstr(const UpnpStateVarRequest *p)
{
return UpnpString_get_String(UpnpStateVarRequest_get_ErrStr(p));
}
void UpnpStateVarRequest_set_ErrStr(UpnpStateVarRequest *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpStateVarRequest *)p)->m_errStr);
((struct SUpnpStateVarRequest *)p)->m_errStr = UpnpString_dup(s);
}
void UpnpStateVarRequest_strcpy_ErrStr(UpnpStateVarRequest *p, const char *s)
{
UpnpString_delete(((struct SUpnpStateVarRequest *)p)->m_errStr);
((struct SUpnpStateVarRequest *)p)->m_errStr = UpnpString_new();
UpnpString_set_String(((struct SUpnpStateVarRequest *)p)->m_errStr, s);
}
const UpnpString *UpnpStateVarRequest_get_DevUDN(const UpnpStateVarRequest *p)
{
return ((struct SUpnpStateVarRequest *)p)->m_devUDN;
}
const char *UpnpStateVarRequest_get_DevUDN_cstr(const UpnpStateVarRequest *p)
{
return UpnpString_get_String(UpnpStateVarRequest_get_DevUDN(p));
}
void UpnpStateVarRequest_set_DevUDN(UpnpStateVarRequest *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpStateVarRequest *)p)->m_devUDN);
((struct SUpnpStateVarRequest *)p)->m_devUDN = UpnpString_dup(s);
}
const UpnpString *UpnpStateVarRequest_get_ServiceID(const UpnpStateVarRequest *p)
{
return ((struct SUpnpStateVarRequest *)p)->m_serviceID;
}
const char *UpnpStateVarRequest_get_ServiceID_cstr(const UpnpStateVarRequest *p)
{
return UpnpString_get_String(UpnpStateVarRequest_get_ServiceID(p));
}
void UpnpStateVarRequest_set_ServiceID(UpnpStateVarRequest *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpStateVarRequest *)p)->m_serviceID);
((struct SUpnpStateVarRequest *)p)->m_serviceID = UpnpString_dup(s);
}
const UpnpString *UpnpStateVarRequest_get_StateVarName(const UpnpStateVarRequest *p)
{
return ((struct SUpnpStateVarRequest *)p)->m_stateVarName;
}
const char *UpnpStateVarRequest_get_StateVarName_cstr(const UpnpStateVarRequest *p)
{
return UpnpString_get_String(UpnpStateVarRequest_get_StateVarName(p));
}
void UpnpStateVarRequest_set_StateVarName(UpnpStateVarRequest *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpStateVarRequest *)p)->m_stateVarName);
((struct SUpnpStateVarRequest *)p)->m_stateVarName = UpnpString_dup(s);
}
void UpnpStateVarRequest_strcpy_StateVarName(UpnpStateVarRequest *p, const char *s)
{
UpnpString_delete(((struct SUpnpStateVarRequest *)p)->m_errStr);
((struct SUpnpStateVarRequest *)p)->m_errStr = UpnpString_new();
UpnpString_set_String(((struct SUpnpStateVarRequest *)p)->m_errStr, s);
}
const struct sockaddr *UpnpStateVarRequest_get_CtrlPtIPAddr(const UpnpStateVarRequest *p)
{
return (struct sockaddr *)&((struct SUpnpStateVarRequest *)p)->m_ctrlPtIPAddr;
}
void UpnpStateVarRequest_set_CtrlPtIPAddr(UpnpStateVarRequest *p, const struct sockaddr *sa)
{
((struct SUpnpStateVarRequest *)p)->m_ctrlPtIPAddr = *(struct sockaddr_storage *)sa;
}
const DOMString UpnpStateVarRequest_get_CurrentVal(const UpnpStateVarRequest *p)
{
return ((struct SUpnpStateVarRequest *)p)->m_currentVal;
}
const char *UpnpStateVarRequest_get_CurrentVal_cstr(const UpnpStateVarRequest *p)
{
return (const char *)UpnpStateVarRequest_get_CurrentVal(p);
}
void UpnpStateVarRequest_set_CurrentVal(UpnpStateVarRequest *p, const DOMString s)
{
ixmlFreeDOMString(((struct SUpnpStateVarRequest *)p)->m_currentVal);
((struct SUpnpStateVarRequest *)p)->m_currentVal = ixmlCloneDOMString(s);
}

View File

@@ -1,157 +0,0 @@
/*!
* \file
*
* \brief UpnpSubscriptionRequest object implementation.
*
* \author Marcelo Roberto Jimenez
*/
#include "config.h"
#include "SubscriptionRequest.h"
#include <stdlib.h> /* for calloc(), free() */
#include <string.h> /* for memset(), strlen(), strdup() */
struct SUpnpSubscriptionRequest
{
UpnpString *m_serviceId;
UpnpString *m_UDN;
UpnpString *m_SID;
};
UpnpSubscriptionRequest *UpnpSubscriptionRequest_new()
{
struct SUpnpSubscriptionRequest *p = calloc(1, sizeof (struct SUpnpSubscriptionRequest));
p->m_serviceId = UpnpString_new();
p->m_UDN = UpnpString_new();
p->m_SID = UpnpString_new();
return (UpnpSubscriptionRequest *)p;
}
void UpnpSubscriptionRequest_delete(UpnpSubscriptionRequest *p)
{
struct SUpnpSubscriptionRequest *q = (struct SUpnpSubscriptionRequest *)p;
if (!q) return;
UpnpString_delete(q->m_serviceId);
q->m_serviceId = NULL;
UpnpString_delete(q->m_UDN);
q->m_UDN = NULL;
UpnpString_delete(q->m_SID);
q->m_SID = NULL;
free(p);
}
UpnpSubscriptionRequest *UpnpSubscriptionRequest_dup(const UpnpSubscriptionRequest *p)
{
UpnpSubscriptionRequest *q = UpnpSubscriptionRequest_new();
UpnpSubscriptionRequest_assign(q, p);
return q;
}
void UpnpSubscriptionRequest_assign(UpnpSubscriptionRequest *p, const UpnpSubscriptionRequest *q)
{
if (p != q) {
UpnpSubscriptionRequest_set_ServiceId(p, UpnpSubscriptionRequest_get_ServiceId(q));
UpnpSubscriptionRequest_set_UDN(p, UpnpSubscriptionRequest_get_UDN(q));
UpnpSubscriptionRequest_set_SID(p, UpnpSubscriptionRequest_get_SID(q));
}
}
const UpnpString *UpnpSubscriptionRequest_get_ServiceId(const UpnpSubscriptionRequest *p)
{
return ((struct SUpnpSubscriptionRequest *)p)->m_serviceId;
}
const char *UpnpSubscriptionRequest_get_ServiceId_cstr(const UpnpSubscriptionRequest *p)
{
return UpnpString_get_String(UpnpSubscriptionRequest_get_ServiceId(p));
}
void UpnpSubscriptionRequest_set_ServiceId(UpnpSubscriptionRequest *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpSubscriptionRequest *)p)->m_serviceId);
((struct SUpnpSubscriptionRequest *)p)->m_serviceId = UpnpString_dup(s);
}
void UpnpSubscriptionRequest_strcpy_ServiceId(UpnpSubscriptionRequest *p, const char *s)
{
UpnpString_delete(((struct SUpnpSubscriptionRequest *)p)->m_serviceId);
((struct SUpnpSubscriptionRequest *)p)->m_serviceId = UpnpString_new();
UpnpString_set_String(((struct SUpnpSubscriptionRequest *)p)->m_serviceId, s);
}
const UpnpString *UpnpSubscriptionRequest_get_UDN(const UpnpSubscriptionRequest *p)
{
return ((struct SUpnpSubscriptionRequest *)p)->m_UDN;
}
const char *UpnpSubscriptionRequest_get_UDN_cstr(const UpnpSubscriptionRequest *p)
{
return UpnpString_get_String(UpnpSubscriptionRequest_get_UDN(p));
}
void UpnpSubscriptionRequest_set_UDN(UpnpSubscriptionRequest *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpSubscriptionRequest *)p)->m_UDN);
((struct SUpnpSubscriptionRequest *)p)->m_UDN = UpnpString_dup(s);
}
void UpnpSubscriptionRequest_strcpy_UDN(UpnpSubscriptionRequest *p, const char *s)
{
UpnpString_delete(((struct SUpnpSubscriptionRequest *)p)->m_UDN);
((struct SUpnpSubscriptionRequest *)p)->m_UDN = UpnpString_new();
UpnpString_set_String(((struct SUpnpSubscriptionRequest *)p)->m_UDN, s);
}
const UpnpString *UpnpSubscriptionRequest_get_SID(const UpnpSubscriptionRequest *p)
{
return ((struct SUpnpSubscriptionRequest *)p)->m_SID;
}
const char *UpnpSubscriptionRequest_get_SID_cstr(const UpnpSubscriptionRequest *p)
{
return UpnpString_get_String(UpnpSubscriptionRequest_get_SID(p));
}
void UpnpSubscriptionRequest_set_SID(UpnpSubscriptionRequest *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpSubscriptionRequest *)p)->m_SID);
((struct SUpnpSubscriptionRequest *)p)->m_SID = UpnpString_dup(s);
}
void UpnpSubscriptionRequest_strcpy_SID(UpnpSubscriptionRequest *p, const char *s)
{
UpnpString_delete(((struct SUpnpSubscriptionRequest *)p)->m_SID);
((struct SUpnpSubscriptionRequest *)p)->m_SID = UpnpString_new();
UpnpString_set_String(((struct SUpnpSubscriptionRequest *)p)->m_SID, s);
}

View File

@@ -28,6 +28,19 @@
#include <string.h> /* for strlen(), strdup() */
#ifdef WIN32
#define strcasecmp stricmp
#else
/* Other systems have strncasecmp */
#endif
/* strndup() is a GNU extension. Other systems must fix it with elif's. */
#ifdef __GNUC__
extern char *strndup(__const char *__string, size_t __n);
#endif
/*!
* \brief Internal implementation of the class UpnpString.
*
@@ -115,42 +128,78 @@ void UpnpString_assign(UpnpString *p, const UpnpString *q)
}
int UpnpString_get_Length(const UpnpString *p)
size_t UpnpString_get_Length(const UpnpString *p)
{
return ((struct SUpnpString *)p)->m_length;
}
void UpnpString_set_Length(UpnpString *p, size_t n)
{
if (((struct SUpnpString *)p)->m_length > n) {
((struct SUpnpString *)p)->m_length = n;
/* No need to realloc now, will do later when needed. */
((struct SUpnpString *)p)->m_string[n] = 0;
}
}
const char *UpnpString_get_String(const UpnpString *p)
{
return ((struct SUpnpString *)p)->m_string;
}
void UpnpString_set_String(UpnpString *p, const char *s)
int UpnpString_set_String(UpnpString *p, const char *s)
{
char *q = strdup(s);
if (!q) goto error_handler1;
free(((struct SUpnpString *)p)->m_string);
((struct SUpnpString *)p)->m_length = strlen(s);
((struct SUpnpString *)p)->m_string = strdup(s);
((struct SUpnpString *)p)->m_length = strlen(q);
((struct SUpnpString *)p)->m_string = q;
error_handler1:
return q != NULL;
}
void UpnpString_set_StringN(UpnpString *p, const char *s, int n)
int UpnpString_set_StringN(UpnpString *p, const char *s, size_t n)
{
char *q = strndup(s, n);
if (!q) goto error_handler1;
free(((struct SUpnpString *)p)->m_string);
((struct SUpnpString *)p)->m_length = n;
((struct SUpnpString *)p)->m_string = (char *)malloc(n+1);
strncpy(((struct SUpnpString *)p)->m_string, s, n);
((struct SUpnpString *)p)->m_string[n] = 0;
((struct SUpnpString *)p)->m_length = strlen(q);
((struct SUpnpString *)p)->m_string = q;
error_handler1:
return q != NULL;
}
void UpnpString_clear(UpnpString *p)
{
((struct SUpnpString *)p)->m_length = 0;
// No need to realloc now, will do later when needed
/* No need to realloc now, will do later when needed. */
((struct SUpnpString *)p)->m_string[0] = 0;
}
int UpnpString_cmp(UpnpString *p, UpnpString *q)
{
const char *cp = UpnpString_get_String(p);
const char *cq = UpnpString_get_String(q);
return strcmp(cp, cq);
}
int UpnpString_casecmp(UpnpString *p, UpnpString *q)
{
const char *cp = UpnpString_get_String(p);
const char *cq = UpnpString_get_String(q);
return strcasecmp(cp, cq);
}
/* @} UpnpString */

View File

@@ -282,6 +282,7 @@ static int UpnpInitThreadPools(void)
TPAttrInit(&attr);
TPAttrSetMaxThreads(&attr, MAX_THREADS);
TPAttrSetMinThreads(&attr, MIN_THREADS);
TPAttrSetStackSize(&attr, THREAD_STACK_SIZE);
TPAttrSetJobsPerThread(&attr, JOBS_PER_THREAD);
TPAttrSetIdleTime(&attr, THREAD_IDLE_TIME);
TPAttrSetMaxJobsTotal(&attr, MAX_JOBS_TOTAL);
@@ -488,7 +489,7 @@ exit_function:
return retVal;
}
#ifdef UPNP_ENABLE_IPV6
int UpnpInit2(const char *IfName, unsigned short DestPort)
{
int retVal;
@@ -533,8 +534,9 @@ int UpnpInit2(const char *IfName, unsigned short DestPort)
exit_function:
ithread_mutex_unlock(&gSDKInitMutex);
return UPNP_E_SUCCESS;
return retVal;
}
#endif
int UpnpFinish(void)
@@ -620,7 +622,7 @@ unsigned short UpnpGetServerPort(void)
return LOCAL_PORT_V4;
}
#ifdef UPNP_ENABLE_IPV6
unsigned short UpnpGetServerPort6(void)
{
if (UpnpSdkInit != 1) {
@@ -629,6 +631,7 @@ unsigned short UpnpGetServerPort6(void)
return LOCAL_PORT_V6;
}
#endif
char *UpnpGetServerIpAddress(void)
@@ -777,8 +780,10 @@ int UpnpRegisterRootDevice(
HInfo->DeviceList = NULL;
HInfo->ServiceList = NULL;
HInfo->DescDocument = NULL;
CLIENTONLY( ListInit(&HInfo->SsdpSearchList, NULL, NULL); )
CLIENTONLY( HInfo->ClientSubList = NULL; )
#ifdef INCLUDE_CLIENT_APIS
ListInit(&HInfo->SsdpSearchList, NULL, NULL);
HInfo->ClientSubList = NULL;
#endif /* INCLUDE_CLIENT_APIS */
HInfo->MaxSubscriptions = UPNP_INFINITE;
HInfo->MaxSubscriptionTimeOut = UPNP_INFINITE;
HInfo->DeviceAf = AF_INET;
@@ -788,7 +793,9 @@ int UpnpRegisterRootDevice(
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice: error downloading Document: %d\n",
retVal);
CLIENTONLY( ListDestroy(&HInfo->SsdpSearchList, 0); )
#ifdef INCLUDE_CLIENT_APIS
ListDestroy(&HInfo->SsdpSearchList, 0);
#endif /* INCLUDE_CLIENT_APIS */
FreeHandle(*Hnd);
goto exit_function;
}
@@ -800,7 +807,9 @@ int UpnpRegisterRootDevice(
HInfo->DeviceList =
ixmlDocument_getElementsByTagName(HInfo->DescDocument, "device");
if (!HInfo->DeviceList) {
CLIENTONLY( ListDestroy(&HInfo->SsdpSearchList, 0); )
#ifdef INCLUDE_CLIENT_APIS
ListDestroy(&HInfo->SsdpSearchList, 0);
#endif /* INCLUDE_CLIENT_APIS */
ixmlDocument_free(HInfo->DescDocument);
FreeHandle(*Hnd);
UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
@@ -936,8 +945,10 @@ int UpnpRegisterRootDevice2(
HInfo->MaxAge = DEFAULT_MAXAGE;
HInfo->DeviceList = NULL;
HInfo->ServiceList = NULL;
CLIENTONLY( ListInit(&HInfo->SsdpSearchList, NULL, NULL); )
CLIENTONLY( HInfo->ClientSubList = NULL; )
#ifdef INCLUDE_CLIENT_APIS
ListInit(&HInfo->SsdpSearchList, NULL, NULL);
HInfo->ClientSubList = NULL;
#endif /* INCLUDE_CLIENT_APIS */
HInfo->MaxSubscriptions = UPNP_INFINITE;
HInfo->MaxSubscriptionTimeOut = UPNP_INFINITE;
HInfo->DeviceAf = AF_INET;
@@ -950,7 +961,9 @@ int UpnpRegisterRootDevice2(
HInfo->DeviceList =
ixmlDocument_getElementsByTagName( HInfo->DescDocument, "device" );
if (!HInfo->DeviceList) {
CLIENTONLY( ListDestroy(&HInfo->SsdpSearchList, 0); )
#ifdef INCLUDE_CLIENT_APIS
ListDestroy(&HInfo->SsdpSearchList, 0);
#endif /* INCLUDE_CLIENT_APIS */
ixmlDocument_free(HInfo->DescDocument);
FreeHandle(*Hnd);
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
@@ -1010,17 +1023,16 @@ int UpnpRegisterRootDevice3(
struct Handle_Info *HInfo;
int retVal = 0;
int hasServiceTable = 0;
int handler_index = 0;
HandleLock();
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Inside UpnpRegisterRootDevice3\n");
if (UpnpSdkInit != 1) {
retVal = UPNP_E_FINISH;
goto exit_function;
}
if (Hnd == NULL ||
Fun == NULL ||
DescUrl == NULL ||
@@ -1029,17 +1041,14 @@ int UpnpRegisterRootDevice3(
retVal = UPNP_E_INVALID_PARAM;
goto exit_function;
}
/* Test for already regsitered IPV4. */
if (AddressFamily == AF_INET && UpnpSdkDeviceRegisteredV4 == 1) {
retVal = UPNP_E_ALREADY_REGISTERED;
goto exit_function;
}
/* Test for already registered IPV6. IPV6 devices might register on multiple
* IPv6 addresses (link local and GUA or ULA), so we must to check the
* description URL in the HandleTable. */
int handler_index = 0;
while (handler_index < NUM_HANDLE && HandleTable[handler_index] != NULL) {
if (strcmp(((struct Handle_Info *)HandleTable[handler_index])->DescURL, DescUrl)) {
retVal = UPNP_E_ALREADY_REGISTERED;
@@ -1047,13 +1056,11 @@ int UpnpRegisterRootDevice3(
}
handler_index++;
}
*Hnd = GetFreeHandle();
if (*Hnd == UPNP_E_OUTOF_HANDLE) {
retVal = UPNP_E_OUTOF_MEMORY;
goto exit_function;
}
HInfo = (struct Handle_Info *)malloc(sizeof (struct Handle_Info));
if (HInfo == NULL) {
retVal = UPNP_E_OUTOF_MEMORY;
@@ -1062,7 +1069,6 @@ int UpnpRegisterRootDevice3(
HandleTable[*Hnd] = HInfo;
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Root device URL is %s\n", DescUrl);
HInfo->aliasInstalled = 0;
HInfo->HType = HND_DEVICE;
strcpy(HInfo->DescURL, DescUrl);
@@ -1072,15 +1078,18 @@ int UpnpRegisterRootDevice3(
HInfo->DeviceList = NULL;
HInfo->ServiceList = NULL;
HInfo->DescDocument = NULL;
CLIENTONLY( ListInit(&HInfo->SsdpSearchList, NULL, NULL); )
CLIENTONLY( HInfo->ClientSubList = NULL; )
#ifdef INCLUDE_CLIENT_APIS
ListInit(&HInfo->SsdpSearchList, NULL, NULL);
HInfo->ClientSubList = NULL;
#endif /* INCLUDE_CLIENT_APIS */
HInfo->MaxSubscriptions = UPNP_INFINITE;
HInfo->MaxSubscriptionTimeOut = UPNP_INFINITE;
HInfo->DeviceAf = AddressFamily;
retVal = UpnpDownloadXmlDoc(HInfo->DescURL, &(HInfo->DescDocument));
if (retVal != UPNP_E_SUCCESS) {
CLIENTONLY( ListDestroy(&HInfo->SsdpSearchList, 0); )
#ifdef INCLUDE_CLIENT_APIS
ListDestroy(&HInfo->SsdpSearchList, 0);
#endif /* INCLUDE_CLIENT_APIS */
FreeHandle(*Hnd);
goto exit_function;
}
@@ -1092,7 +1101,9 @@ int UpnpRegisterRootDevice3(
HInfo->DeviceList = ixmlDocument_getElementsByTagName(
HInfo->DescDocument, "device");
if (!HInfo->DeviceList) {
CLIENTONLY( ListDestroy(&HInfo->SsdpSearchList, 0); )
#ifdef INCLUDE_CLIENT_APIS
ListDestroy(&HInfo->SsdpSearchList, 0);
#endif /* INCLUDE_CLIENT_APIS */
ixmlDocument_free(HInfo->DescDocument);
FreeHandle(*Hnd);
UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
@@ -1184,7 +1195,9 @@ int UpnpUnRegisterRootDevice(UpnpDevice_Handle Hnd)
ixmlNodeList_free( HInfo->ServiceList );
ixmlDocument_free( HInfo->DescDocument );
CLIENTONLY( ListDestroy( &HInfo->SsdpSearchList, 0 ); )
#ifdef INCLUDE_CLIENT_APIS
ListDestroy( &HInfo->SsdpSearchList, 0 );
#endif /* INCLUDE_CLIENT_APIS */
#ifdef INTERNAL_WEB_SERVER
if( HInfo->aliasInstalled ) {
@@ -3303,7 +3316,7 @@ int UpnpGetIfInfo(const char *IfName)
#ifdef INCLUDE_CLIENT_APIS
void UpnpThreadDistribution(struct UpnpNonblockParam *Param)
{
int errCode = 0;
/*int errCode = 0;*/
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Inside UpnpThreadDistribution \n");
@@ -3311,84 +3324,84 @@ void UpnpThreadDistribution(struct UpnpNonblockParam *Param)
switch (Param->FunName) {
#if EXCLUDE_GENA == 0
case SUBSCRIBE: {
UpnpEventSubscribe *evt = UpnpEventSubscribe_new();
struct Upnp_Event_Subscribe Evt;
/* Cast away constness */
UpnpString *Sid = (UpnpString *)UpnpEventSubscribe_get_SID(evt);
UpnpEventSubscribe_strcpy_PublisherUrl(evt, Param->Url);
errCode = genaSubscribe(
/*UpnpString *Sid = (UpnpString *)UpnpEventSubscribe_get_SID(evt);*/
UpnpString *Sid = UpnpString_new();
UpnpString *Url = UpnpString_new();
UpnpString_set_String(Url, Param->Url);
UpnpString_set_String(Sid, (char *)Evt.Sid);
Evt.ErrCode = genaSubscribe(
Param->Handle,
UpnpEventSubscribe_get_PublisherUrl(evt),
Url,
(int *)&Param->TimeOut,
Sid);
UpnpEventSubscribe_set_ErrCode(evt, errCode);
UpnpEventSubscribe_set_TimeOut(evt, Param->TimeOut);
Param->Fun(UPNP_EVENT_SUBSCRIBE_COMPLETE, evt, Param->Cookie);
UpnpEventSubscribe_delete(evt);
strcpy(Evt.PublisherUrl, Param->Url);
Evt.TimeOut = Param->TimeOut;
Param->Fun(UPNP_EVENT_SUBSCRIBE_COMPLETE, &Evt, Param->Cookie);
UpnpString_delete(Sid);
UpnpString_delete(Url);
free(Param);
break;
}
case UNSUBSCRIBE: {
UpnpEventSubscribe *evt = UpnpEventSubscribe_new();
UpnpEventSubscribe_strcpy_SID(evt, Param->SubsId);
errCode = genaUnSubscribe(
struct Upnp_Event_Subscribe Evt;
UpnpString *Sid = UpnpString_new();
UpnpString_set_String(Sid, Param->SubsId);
Evt.ErrCode = genaUnSubscribe(
Param->Handle,
UpnpEventSubscribe_get_SID(evt));
UpnpEventSubscribe_set_ErrCode(evt, errCode);
UpnpEventSubscribe_strcpy_PublisherUrl(evt, "");
UpnpEventSubscribe_set_TimeOut(evt, 0);
Param->Fun(UPNP_EVENT_UNSUBSCRIBE_COMPLETE, evt, Param->Cookie);
UpnpEventSubscribe_delete(evt);
Sid);
strcpy((char *)Evt.Sid, UpnpString_get_String(Sid));
strcpy(Evt.PublisherUrl, "");
Evt.TimeOut = 0;
Param->Fun(UPNP_EVENT_UNSUBSCRIBE_COMPLETE, &Evt, Param->Cookie);
UpnpString_delete(Sid);
free(Param);
break;
}
case RENEW: {
UpnpEventSubscribe *evt = UpnpEventSubscribe_new();
UpnpEventSubscribe_strcpy_SID(evt, Param->SubsId);
errCode = genaRenewSubscription(
struct Upnp_Event_Subscribe Evt;
UpnpString *Sid = UpnpString_new();
UpnpString_set_String(Sid, Param->SubsId);
Evt.ErrCode = genaRenewSubscription(
Param->Handle,
UpnpEventSubscribe_get_SID(evt),
Sid,
&Param->TimeOut);
UpnpEventSubscribe_set_ErrCode(evt, errCode);
UpnpEventSubscribe_set_TimeOut(evt, Param->TimeOut);
Param->Fun(UPNP_EVENT_RENEWAL_COMPLETE, evt, Param->Cookie);
UpnpEventSubscribe_delete(evt);
Evt.TimeOut = Param->TimeOut;
strcpy((char *)Evt.Sid, UpnpString_get_String(Sid));
Param->Fun(UPNP_EVENT_RENEWAL_COMPLETE, &Evt, Param->Cookie);
UpnpString_delete(Sid);
free(Param);
break;
}
#endif /* EXCLUDE_GENA == 0 */
#if EXCLUDE_SOAP == 0
case ACTION: {
UpnpActionComplete *Evt = UpnpActionComplete_new();
IXML_Document *actionResult = NULL;
int errCode = SoapSendAction(
struct Upnp_Action_Complete Evt;
Evt.ActionResult = NULL;
Evt.ErrCode = SoapSendAction(
Param->Url,
Param->ServiceType,
Param->Act,
&actionResult);
UpnpActionComplete_set_ErrCode(Evt, errCode);
UpnpActionComplete_set_ActionRequest(Evt, Param->Act);
UpnpActionComplete_set_ActionResult(Evt, actionResult);
UpnpActionComplete_strcpy_CtrlUrl(Evt, Param->Url);
Param->Fun(UPNP_CONTROL_ACTION_COMPLETE, Evt, Param->Cookie);
Param->Act, &Evt.ActionResult);
Evt.ActionRequest = Param->Act;
strcpy(Evt.CtrlUrl, Param->Url);
Param->Fun(UPNP_CONTROL_ACTION_COMPLETE, &Evt, Param->Cookie);
ixmlDocument_free(Evt.ActionRequest);
ixmlDocument_free(Evt.ActionResult);
free(Param);
UpnpActionComplete_delete(Evt);
break;
}
case STATUS: {
UpnpStateVarComplete *Evt = UpnpStateVarComplete_new();
DOMString currentVal = NULL;
int errCode = SoapGetServiceVarStatus(
struct Upnp_State_Var_Complete Evt;
Evt.ErrCode = SoapGetServiceVarStatus(
Param->Url,
Param->VarName,
&currentVal);
UpnpStateVarComplete_set_ErrCode(Evt, errCode);
UpnpStateVarComplete_strcpy_CtrlUrl(Evt, Param->Url);
UpnpStateVarComplete_strcpy_StateVarName(Evt, Param->VarName);
UpnpStateVarComplete_set_CurrentVal(Evt, currentVal);
Param->Fun(UPNP_CONTROL_GET_VAR_COMPLETE, Evt, Param->Cookie);
&Evt.CurrentVal);
strcpy(Evt.StateVarName, Param->VarName);
strcpy(Evt.CtrlUrl, Param->Url);
Param->Fun(UPNP_CONTROL_GET_VAR_COMPLETE, &Evt, Param->Cookie);
free(Evt.CurrentVal);
free(Param);
UpnpStateVarComplete_delete(Evt);
break;
}
#endif /* EXCLUDE_SOAP == 0 */

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,5 +324,32 @@ 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 */

View File

@@ -42,7 +42,6 @@
#ifdef INCLUDE_CLIENT_APIS
#include "EventSubscribe.h"
#include "gena.h"
#include "httpparser.h"
#include "httpreadwrite.h"
@@ -65,7 +64,7 @@ static void GenaAutoRenewSubscription(
IN void *input)
{
upnp_timeout *event = (upnp_timeout *) input;
UpnpEventSubscribe *sub_struct = (UpnpEventSubscribe *)event->Event;
struct Upnp_Event_Subscribe *sub_struct = (struct Upnp_Event_Subscribe *)event->Event;
void *cookie;
Upnp_FunPtr callback_fun;
struct Handle_Info *handle_info;
@@ -73,21 +72,23 @@ static void GenaAutoRenewSubscription(
int eventType = 0;
int timeout = 0;
int errCode = 0;
UpnpString *tmpSID = UpnpString_new();
if (AUTO_RENEW_TIME == 0) {
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, "GENA SUB EXPIRED");
UpnpEventSubscribe_set_ErrCode(sub_struct, UPNP_E_SUCCESS);
sub_struct->ErrCode = UPNP_E_SUCCESS;
send_callback = 1;
eventType = UPNP_EVENT_SUBSCRIPTION_EXPIRED;
} else {
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, "GENA AUTO RENEW");
timeout = UpnpEventSubscribe_get_TimeOut(sub_struct);
timeout = sub_struct->TimeOut;
UpnpString_set_String(tmpSID, sub_struct->Sid);
errCode = genaRenewSubscription(
event->handle,
UpnpEventSubscribe_get_SID(sub_struct),
tmpSID,
&timeout);
UpnpEventSubscribe_set_ErrCode(sub_struct, errCode);
UpnpEventSubscribe_set_TimeOut(sub_struct, timeout);
sub_struct->ErrCode = errCode;
sub_struct->TimeOut = timeout;
if (errCode != UPNP_E_SUCCESS &&
errCode != GENA_E_BAD_SID &&
errCode != GENA_E_BAD_HANDLE) {
@@ -115,6 +116,7 @@ static void GenaAutoRenewSubscription(
free_upnp_timeout(event);
end_function:
UpnpString_delete(tmpSID);
return;
}
@@ -133,17 +135,19 @@ static int ScheduleGenaAutoRenew(
/*! [in] Subscription being renewed. */
IN ClientSubscription *sub)
{
UpnpEventSubscribe *RenewEventStruct = NULL;
struct Upnp_Event_Subscribe *RenewEventStruct = NULL;
upnp_timeout *RenewEvent = NULL;
int return_code = GENA_SUCCESS;
ThreadPoolJob job;
const UpnpString *tmpSID = UpnpClientSubscription_get_SID(sub);
const UpnpString *tmpEventURL = UpnpClientSubscription_get_EventURL(sub);
if (TimeOut == UPNP_INFINITE) {
return_code = GENA_SUCCESS;
goto end_function;
}
RenewEventStruct = UpnpEventSubscribe_new();
RenewEventStruct = (struct Upnp_Event_Subscribe *)malloc(sizeof (struct Upnp_Event_Subscribe));
if (RenewEventStruct == NULL) {
return_code = UPNP_E_OUTOF_MEMORY;
goto end_function;
@@ -157,10 +161,11 @@ static int ScheduleGenaAutoRenew(
}
// schedule expire event
UpnpEventSubscribe_set_ErrCode(RenewEventStruct, UPNP_E_SUCCESS);
UpnpEventSubscribe_set_TimeOut(RenewEventStruct, TimeOut);
UpnpEventSubscribe_set_SID(RenewEventStruct, GenlibClientSubscription_get_SID(sub));
UpnpEventSubscribe_set_PublisherUrl(RenewEventStruct, GenlibClientSubscription_get_EventURL(sub));
RenewEventStruct->ErrCode = UPNP_E_SUCCESS;
RenewEventStruct->TimeOut = TimeOut;
strcpy(RenewEventStruct->Sid, UpnpString_get_String(tmpSID));
strncpy(RenewEventStruct->PublisherUrl,
UpnpString_get_String(tmpEventURL), NAME_SIZE - 1);
// RenewEvent->EventType=UPNP_EVENT_SUBSCRIPTION_EXPIRE;
RenewEvent->handle = client_handle;
@@ -183,12 +188,11 @@ static int ScheduleGenaAutoRenew(
goto end_function;
}
GenlibClientSubscription_set_RenewEventId(sub, RenewEvent->eventId);
UpnpClientSubscription_set_RenewEventId(sub, RenewEvent->eventId);
return_code = GENA_SUCCESS;
end_function:
return return_code;
}
@@ -316,18 +320,18 @@ static int gena_subscribe(
"TIMEOUT: Second-", timeout_str );
} else {
// subscribe
if( dest_url.hostport.IPaddress.ss_family == AF_INET6 ) {
if (dest_url.hostport.IPaddress.ss_family == AF_INET6) {
struct sockaddr_in6* DestAddr6 = (struct sockaddr_in6*)&dest_url.hostport.IPaddress;
return_code = http_MakeMessage(
&request, 1, 1,
"q" "sssdsc" "sc" "sscc",
HTTPMETHOD_SUBSCRIBE, &dest_url,
"CALLBACK: <http://[",
((IN6_IS_ADDR_LINKLOCAL(DestAddr6))||(strlen(gIF_IPV6_ULA_GUA) == 0 ))?
gIF_IPV6 : gIF_IPV6_ULA_GUA,
(IN6_IS_ADDR_LINKLOCAL(&DestAddr6->sin6_addr) || strlen(gIF_IPV6_ULA_GUA) == 0) ?
gIF_IPV6 : gIF_IPV6_ULA_GUA,
"]:", LOCAL_PORT_V6, "/>",
"NT: upnp:event",
"TIMEOUT: Second-", timeout_str );
"TIMEOUT: Second-", timeout_str);
} else {
return_code = http_MakeMessage(
&request, 1, 1,
@@ -398,7 +402,7 @@ static int gena_subscribe(
int genaUnregisterClient(UpnpClient_Handle client_handle)
{
ClientSubscription *sub_copy = GenlibClientSubscription_new();
ClientSubscription *sub_copy = UpnpClientSubscription_new();
int return_code = UPNP_E_SUCCESS;
struct Handle_Info *handle_info = NULL;
http_parser_t response;
@@ -415,16 +419,16 @@ int genaUnregisterClient(UpnpClient_Handle client_handle)
return_code = UPNP_E_SUCCESS;
break;
}
GenlibClientSubscription_assign(sub_copy, handle_info->ClientSubList);
UpnpClientSubscription_assign(sub_copy, handle_info->ClientSubList);
RemoveClientSubClientSID(
&handle_info->ClientSubList,
GenlibClientSubscription_get_SID(sub_copy));
UpnpClientSubscription_get_SID(sub_copy));
HandleUnlock();
return_code = gena_unsubscribe(
GenlibClientSubscription_get_EventURL(sub_copy),
GenlibClientSubscription_get_ActualSID(sub_copy),
UpnpClientSubscription_get_EventURL(sub_copy),
UpnpClientSubscription_get_ActualSID(sub_copy),
&response);
if (return_code == 0) {
httpmsg_destroy(&response.msg);
@@ -436,7 +440,7 @@ int genaUnregisterClient(UpnpClient_Handle client_handle)
HandleUnlock();
exit_function:
GenlibClientSubscription_delete(sub_copy);
UpnpClientSubscription_delete(sub_copy);
return return_code;
}
@@ -449,7 +453,7 @@ int genaUnSubscribe(
ClientSubscription *sub = NULL;
int return_code = GENA_SUCCESS;
struct Handle_Info *handle_info;
ClientSubscription *sub_copy = GenlibClientSubscription_new();
ClientSubscription *sub_copy = UpnpClientSubscription_new();
http_parser_t response;
// validate handle and sid
@@ -465,12 +469,12 @@ int genaUnSubscribe(
return_code = GENA_E_BAD_SID;
goto exit_function;
}
GenlibClientSubscription_assign(sub_copy, sub);
UpnpClientSubscription_assign(sub_copy, sub);
HandleUnlock();
return_code = gena_unsubscribe(
GenlibClientSubscription_get_EventURL(sub_copy),
GenlibClientSubscription_get_ActualSID(sub_copy),
UpnpClientSubscription_get_EventURL(sub_copy),
UpnpClientSubscription_get_ActualSID(sub_copy),
&response);
if (return_code == 0) {
httpmsg_destroy(&response.msg);
@@ -487,7 +491,7 @@ int genaUnSubscribe(
HandleUnlock();
exit_function:
GenlibClientSubscription_delete(sub_copy);
UpnpClientSubscription_delete(sub_copy);
return return_code;
}
#endif /* INCLUDE_CLIENT_APIS */
@@ -501,7 +505,7 @@ int genaSubscribe(
UpnpString *out_sid)
{
int return_code = GENA_SUCCESS;
ClientSubscription *newSubscription = GenlibClientSubscription_new();
ClientSubscription *newSubscription = UpnpClientSubscription_new();
uuid_upnp uid;
Upnp_SID temp_sid;
Upnp_SID temp_sid2;
@@ -552,11 +556,11 @@ int genaSubscribe(
return_code = UPNP_E_OUTOF_MEMORY;
goto error_handler;
}
GenlibClientSubscription_set_RenewEventId(newSubscription, -1);
GenlibClientSubscription_set_SID(newSubscription, out_sid);
GenlibClientSubscription_set_ActualSID(newSubscription, ActualSID);
GenlibClientSubscription_set_EventURL(newSubscription, EventURL);
GenlibClientSubscription_set_Next(newSubscription, handle_info->ClientSubList);
UpnpClientSubscription_set_RenewEventId(newSubscription, -1);
UpnpClientSubscription_set_SID(newSubscription, out_sid);
UpnpClientSubscription_set_ActualSID(newSubscription, ActualSID);
UpnpClientSubscription_set_EventURL(newSubscription, EventURL);
UpnpClientSubscription_set_Next(newSubscription, handle_info->ClientSubList);
handle_info->ClientSubList = newSubscription;
// schedule expiration event
@@ -566,7 +570,7 @@ error_handler:
if (return_code != UPNP_E_SUCCESS) {
UpnpString_delete(ActualSID);
UpnpString_delete(EventURL);
GenlibClientSubscription_delete(newSubscription);
UpnpClientSubscription_delete(newSubscription);
}
HandleUnlock();
SubscribeUnlock();
@@ -583,7 +587,7 @@ int genaRenewSubscription(
{
int return_code = GENA_SUCCESS;
ClientSubscription *sub = NULL;
ClientSubscription *sub_copy = GenlibClientSubscription_new();
ClientSubscription *sub_copy = UpnpClientSubscription_new();
struct Handle_Info *handle_info;
UpnpString *ActualSID = UpnpString_new();
ThreadPoolJob tempJob;
@@ -609,22 +613,22 @@ int genaRenewSubscription(
// remove old events
if (TimerThreadRemove(
&gTimerThread,
GenlibClientSubscription_get_RenewEventId(sub),
UpnpClientSubscription_get_RenewEventId(sub),
&tempJob) == 0 ) {
free_upnp_timeout((upnp_timeout *)tempJob.arg);
}
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, "REMOVED AUTO RENEW EVENT");
GenlibClientSubscription_set_RenewEventId(sub, -1);
GenlibClientSubscription_assign(sub_copy, sub);
UpnpClientSubscription_set_RenewEventId(sub, -1);
UpnpClientSubscription_assign(sub_copy, sub);
HandleUnlock();
return_code = gena_subscribe(
GenlibClientSubscription_get_EventURL(sub_copy),
UpnpClientSubscription_get_EventURL(sub_copy),
TimeOut,
GenlibClientSubscription_get_ActualSID(sub_copy),
UpnpClientSubscription_get_ActualSID(sub_copy),
ActualSID);
HandleLock();
@@ -655,21 +659,21 @@ int genaRenewSubscription(
}
// store actual sid
GenlibClientSubscription_set_ActualSID(sub, ActualSID);
UpnpClientSubscription_set_ActualSID(sub, ActualSID);
// start renew subscription timer
return_code = ScheduleGenaAutoRenew(client_handle, *TimeOut, sub);
if (return_code != GENA_SUCCESS) {
RemoveClientSubClientSID(
&handle_info->ClientSubList,
GenlibClientSubscription_get_SID(sub));
UpnpClientSubscription_get_SID(sub));
}
free_client_subscription(sub_copy);
HandleUnlock();
exit_function:
UpnpString_delete(ActualSID);
GenlibClientSubscription_delete(sub_copy);
UpnpClientSubscription_delete(sub_copy);
return return_code;
}
@@ -678,7 +682,7 @@ void gena_process_notification_event(
SOCKINFO *info,
http_message_t *event)
{
UpnpEvent *event_struct = UpnpEvent_new();
struct Upnp_Event event_struct;
IXML_Document *ChangedVars = NULL;
int eventKey;
token sid;
@@ -687,6 +691,7 @@ void gena_process_notification_event(
void *cookie;
Upnp_FunPtr callback;
UpnpClient_Handle client_handle;
const UpnpString *tmpSID = NULL;
memptr sid_hdr;
memptr nt_hdr,
@@ -783,9 +788,10 @@ void gena_process_notification_event(
error_respond(info, HTTP_OK, event);
// fill event struct
UpnpEvent_set_EventKey(event_struct, eventKey);
UpnpEvent_set_ChangedVariables(event_struct, ChangedVars);
UpnpEvent_set_SID(event_struct, GenlibClientSubscription_get_SID(subscription));
tmpSID = UpnpClientSubscription_get_SID(subscription);
strcpy(event_struct.Sid, UpnpString_get_String(tmpSID));
event_struct.EventKey = eventKey;
event_struct.ChangedVariables = ChangedVars;
// copy callback
callback = handle_info->Callback;
@@ -797,11 +803,10 @@ void gena_process_notification_event(
// In future, should find a way of mainting
// that the handle is not unregistered in the middle of a
// callback
callback(UPNP_EVENT_RECEIVED, event_struct, cookie);
callback(UPNP_EVENT_RECEIVED, &event_struct, cookie);
exit_function:
ixmlDocument_free(ChangedVars);
UpnpEvent_delete(event_struct);
}

View File

@@ -178,70 +178,76 @@ static UPNP_INLINE int notify_send_and_recv(
/*! [out] The response from the control point. */
http_parser_t *response)
{
uri_type url;
int conn_fd;
membuffer start_msg;
int ret_code;
int err_code;
int timeout;
SOCKINFO info;
uri_type url;
int conn_fd;
membuffer start_msg;
int ret_code;
int err_code;
int timeout;
SOCKINFO info;
// connect
UpnpPrintf( UPNP_ALL, GENA, __FILE__, __LINE__,
"gena notify to: %.*s\n",
(int)destination_url->hostport.text.size,
destination_url->hostport.text.buff );
/* connect */
UpnpPrintf(UPNP_ALL, GENA, __FILE__, __LINE__,
"gena notify to: %.*s\n",
(int)destination_url->hostport.text.size,
destination_url->hostport.text.buff);
conn_fd = http_Connect( destination_url, &url );
if( conn_fd < 0 ) {
return conn_fd; // return UPNP error
}
conn_fd = http_Connect(destination_url, &url);
if (conn_fd < 0) {
/* return UPNP error */
if( ( ret_code = sock_init( &info, conn_fd ) ) != 0 ) {
sock_destroy( &info, SD_BOTH );
return ret_code;
}
// make start line and HOST header
membuffer_init( &start_msg );
if (http_MakeMessage(
&start_msg, 1, 1,
"q" "s",
HTTPMETHOD_NOTIFY, &url,
mid_msg->buf ) != 0 ) {
membuffer_destroy( &start_msg );
sock_destroy( &info, SD_BOTH );
return UPNP_E_OUTOF_MEMORY;
}
return conn_fd;
}
timeout = HTTP_DEFAULT_TIMEOUT;
ret_code = sock_init(&info, conn_fd);
if (ret_code) {
sock_destroy(&info, SD_BOTH);
// send msg (note +1 for propertyset; null-terminator is also sent)
if( ( ret_code = http_SendMessage( &info, &timeout,
"bb",
start_msg.buf, start_msg.length,
propertySet,
strlen( propertySet ) + 1 ) ) !=
0 ) {
membuffer_destroy( &start_msg );
sock_destroy( &info, SD_BOTH );
return ret_code;
}
return ret_code;
}
/* make start line and HOST header */
membuffer_init(&start_msg);
if (http_MakeMessage(
&start_msg, 1, 1,
"q" "s",
HTTPMETHOD_NOTIFY, &url,
mid_msg->buf) != 0) {
membuffer_destroy(&start_msg);
sock_destroy(&info, SD_BOTH);
if( ( ret_code = http_RecvMessage( &info, response,
HTTPMETHOD_NOTIFY, &timeout,
&err_code ) ) != 0 ) {
membuffer_destroy( &start_msg );
sock_destroy( &info, SD_BOTH );
httpmsg_destroy( &response->msg );
return ret_code;
}
return UPNP_E_OUTOF_MEMORY;
}
sock_destroy( &info, SD_BOTH ); //should shutdown completely
//when closing socket
// sock_destroy( &info,SD_RECEIVE);
membuffer_destroy( &start_msg );
timeout = HTTP_DEFAULT_TIMEOUT;
return UPNP_E_SUCCESS;
/* send msg (note: end of notification will contain "\r\n" twice) */
ret_code = http_SendMessage(&info, &timeout,
"bbb",
start_msg.buf, start_msg.length,
propertySet, strlen(propertySet),
"\r\n", 2);
if (ret_code) {
membuffer_destroy(&start_msg);
sock_destroy(&info, SD_BOTH);
return ret_code;
}
ret_code = http_RecvMessage(&info, response,
HTTPMETHOD_NOTIFY, &timeout, &err_code);
if (ret_code) {
membuffer_destroy(&start_msg);
sock_destroy(&info, SD_BOTH);
httpmsg_destroy(&response->msg);
return ret_code;
}
/* should shutdown completely when closing socket */
sock_destroy(&info, SD_BOTH);
membuffer_destroy(&start_msg);
return UPNP_E_SUCCESS;
}
@@ -336,7 +342,12 @@ static void genaNotifyThread(
struct Handle_Info *handle_info;
ThreadPoolJob job;
HandleReadLock();
/* This should be a HandleLock and not a HandleReadLock otherwise if there
* is a lot of notifications, then multiple threads will acquire a read
* lock and the thread which sends the notification will be blocked forever
* on the HandleLock at the end of this function. */
//HandleReadLock();
HandleLock();
//validate context
if( GetHandleInfo( in->device_handle, &handle_info ) != HND_DEVICE ) {
@@ -354,18 +365,27 @@ static void genaNotifyThread(
HandleUnlock();
return;
}
#ifdef UPNP_ENABLE_NOTIFICATION_REORDERING
//If the event is out of order push it back to the job queue
if( in->eventKey != sub->ToSendEventKey ) {
TPJobInit( &job, ( start_routine ) genaNotifyThread, input );
TPJobSetFreeFunction( &job, ( free_function ) free_notify_struct );
TPJobSetPriority( &job, MED_PRIORITY );
/* Sleep a little before creating another thread otherwise if there is
* a lot of notifications to send, the device will take 100% of the CPU
* to create threads and push them back to the job queue. */
imillisleep( 1 );
ThreadPoolAdd( &gSendThreadPool, &job, NULL );
freeSubscription( &sub_copy );
HandleUnlock();
return;
}
#endif
HandleUnlock();
@@ -1190,7 +1210,7 @@ void gena_process_subscription_request(
SOCKINFO *info,
http_message_t *request)
{
UpnpSubscriptionRequest *request_struct = UpnpSubscriptionRequest_new();
struct Upnp_Subscription_Request request_struct;
Upnp_SID temp_sid;
int return_code = 1;
int time_out = 1801;
@@ -1349,9 +1369,9 @@ void gena_process_subscription_request(
service->TotalSubscriptions++;
// finally generate callback for init table dump
UpnpSubscriptionRequest_strcpy_ServiceId(request_struct, service->serviceId);
UpnpSubscriptionRequest_strcpy_UDN(request_struct, service->UDN);
UpnpSubscriptionRequest_strcpy_SID(request_struct, sub->sid);
request_struct.ServiceId = service->serviceId;
request_struct.UDN = service->UDN;
strcpy((char *)request_struct.Sid, sub->sid);
// copy callback
callback_fun = handle_info->Callback;
@@ -1362,10 +1382,10 @@ void gena_process_subscription_request(
// make call back with request struct
// in the future should find a way of mainting that the handle
// is not unregistered in the middle of a callback
callback_fun(UPNP_EVENT_SUBSCRIPTION_REQUEST, request_struct, cookie);
callback_fun(UPNP_EVENT_SUBSCRIPTION_REQUEST, &request_struct, cookie);
exit_function:
UpnpSubscriptionRequest_delete(request_struct);
return;
}

View File

@@ -1,200 +0,0 @@
/************************************************************************
* Purpose: This file defines the functions for clients. It defines
* functions for adding and removing clients to and from the client table,
* adding and accessing subscription and other attributes pertaining to the
* client
************************************************************************/
#include "config.h"
#include "ClientSubscription.h"
#ifdef INCLUDE_CLIENT_APIS
#include <stdlib.h> // for calloc(), free()
struct SClientSubscription {
int m_renewEventId;
UpnpString *m_SID;
UpnpString *m_actualSID;
UpnpString *m_eventURL;
struct SClientSubscription *m_next;
};
ClientSubscription *GenlibClientSubscription_new()
{
struct SClientSubscription *p = calloc(1, sizeof (struct SClientSubscription));
#if 0
p->renewEventId = 0;
#endif
p->m_SID = UpnpString_new();
p->m_actualSID = UpnpString_new();
p->m_eventURL = UpnpString_new();
p->m_next = NULL;
return (ClientSubscription *)p;
}
void GenlibClientSubscription_delete(ClientSubscription *p)
{
struct SClientSubscription *q = (struct SClientSubscription *)p;
if (!q) return;
q->m_renewEventId = 0;
UpnpString_delete(q->m_SID);
q->m_SID = NULL;
UpnpString_delete(q->m_actualSID);
q->m_actualSID = NULL;
UpnpString_delete(q->m_eventURL);
q->m_eventURL = NULL;
q->m_next = NULL;
free(p);
}
ClientSubscription *GenlibClientSubscription_dup(const ClientSubscription *p)
{
ClientSubscription *q = GenlibClientSubscription_new();
GenlibClientSubscription_assign(q, p);
return q;
}
void GenlibClientSubscription_assign(ClientSubscription *q, const ClientSubscription *p)
{
if (q != p) {
/*struct SClientSubscription *_p = (struct SClientSubscription *)p;*/
struct SClientSubscription *_q = (struct SClientSubscription *)q;
// Do not copy RenewEventId
_q->m_renewEventId = -1;
GenlibClientSubscription_set_SID(q, GenlibClientSubscription_get_SID(p));
GenlibClientSubscription_set_ActualSID(q, GenlibClientSubscription_get_ActualSID(p));
GenlibClientSubscription_set_EventURL(q, GenlibClientSubscription_get_EventURL(p));
// Do not copy m_next
_q->m_next = NULL;
}
}
int GenlibClientSubscription_get_RenewEventId(const ClientSubscription *p)
{
return ((struct SClientSubscription *)p)->m_renewEventId;
}
void GenlibClientSubscription_set_RenewEventId(ClientSubscription *p, int n)
{
((struct SClientSubscription *)p)->m_renewEventId = n;
}
const UpnpString *GenlibClientSubscription_get_SID(const ClientSubscription *p)
{
return ((struct SClientSubscription *)p)->m_SID;
}
const char *GenlibClientSubscription_get_SID_cstr(const ClientSubscription *p)
{
return UpnpString_get_String(GenlibClientSubscription_get_SID(p));
}
void GenlibClientSubscription_set_SID(ClientSubscription *p, const UpnpString *s)
{
UpnpString_delete(((struct SClientSubscription *)p)->m_SID);
((struct SClientSubscription *)p)->m_SID = UpnpString_dup(s);
}
void GenlibClientSubscription_strcpy_SID(ClientSubscription *p, const char *s)
{
UpnpString_delete(((struct SClientSubscription *)p)->m_SID);
((struct SClientSubscription *)p)->m_SID = UpnpString_new();
UpnpString_set_String(((struct SClientSubscription *)p)->m_SID, s);
}
const UpnpString *GenlibClientSubscription_get_ActualSID(const ClientSubscription *p)
{
return ((struct SClientSubscription *)p)->m_actualSID;
}
const char *GenlibClientSubscription_get_ActualSID_cstr(const ClientSubscription *p)
{
return UpnpString_get_String(GenlibClientSubscription_get_ActualSID(p));
}
void GenlibClientSubscription_set_ActualSID(ClientSubscription *p, const UpnpString *s)
{
UpnpString_delete(((struct SClientSubscription *)p)->m_actualSID);
((struct SClientSubscription *)p)->m_actualSID = UpnpString_dup(s);
}
void GenlibClientSubscription_strcpy_ActualSID(ClientSubscription *p, const char *s)
{
UpnpString_delete(((struct SClientSubscription *)p)->m_actualSID);
((struct SClientSubscription *)p)->m_actualSID = UpnpString_new();
UpnpString_set_String(((struct SClientSubscription *)p)->m_actualSID, s);
}
const UpnpString *GenlibClientSubscription_get_EventURL(const ClientSubscription *p)
{
return ((struct SClientSubscription *)p)->m_eventURL;
}
const char *GenlibClientSubscription_get_EventURL_cstr(const ClientSubscription *p)
{
return UpnpString_get_String(GenlibClientSubscription_get_EventURL(p));
}
void GenlibClientSubscription_set_EventURL(ClientSubscription *p, const UpnpString *s)
{
UpnpString_delete(((struct SClientSubscription *)p)->m_eventURL);
((struct SClientSubscription *)p)->m_eventURL = UpnpString_dup(s);
}
void GenlibClientSubscription_strcpy_EventURL(ClientSubscription *p, const char *s)
{
UpnpString_delete(((struct SClientSubscription *)p)->m_eventURL);
((struct SClientSubscription *)p)->m_eventURL = UpnpString_new();
UpnpString_set_String(((struct SClientSubscription *)p)->m_eventURL, s);
}
ClientSubscription *GenlibClientSubscription_get_Next(const ClientSubscription *p)
{
return (ClientSubscription *)(((struct SClientSubscription *)p)->m_next);
}
void GenlibClientSubscription_set_Next(ClientSubscription *p, ClientSubscription *q)
{
((struct SClientSubscription *)p)->m_next = (struct SClientSubscription *)q;
}
#endif /* INCLUDE_CLIENT_APIS */

View File

@@ -1,3 +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.
*
******************************************************************************/
/************************************************************************
* Purpose: This file defines the functions for clients. It defines
@@ -19,14 +49,194 @@
#include <stdlib.h> // for calloc(), free()
struct SClientSubscription {
int m_renewEventId;
UpnpString *m_SID;
UpnpString *m_actualSID;
UpnpString *m_eventURL;
struct SClientSubscription *m_next;
};
/** Constructor */
ClientSubscription *UpnpClientSubscription_new()
{
struct SClientSubscription *p = calloc(1, sizeof (struct SClientSubscription));
#if 0
p->renewEventId = 0;
#endif
p->m_SID = UpnpString_new();
p->m_actualSID = UpnpString_new();
p->m_eventURL = UpnpString_new();
p->m_next = NULL;
return (ClientSubscription *)p;
}
/** Destructor */
void UpnpClientSubscription_delete(ClientSubscription *p)
{
struct SClientSubscription *q = (struct SClientSubscription *)p;
if (!q) return;
q->m_renewEventId = 0;
UpnpString_delete(q->m_SID);
q->m_SID = NULL;
UpnpString_delete(q->m_actualSID);
q->m_actualSID = NULL;
UpnpString_delete(q->m_eventURL);
q->m_eventURL = NULL;
q->m_next = NULL;
free(p);
}
/** Copy Constructor */
ClientSubscription *UpnpClientSubscription_dup(const ClientSubscription *p)
{
ClientSubscription *q = UpnpClientSubscription_new();
UpnpClientSubscription_assign(q, p);
return q;
}
/** Assignment operator */
void UpnpClientSubscription_assign(ClientSubscription *q, const ClientSubscription *p)
{
if (q != p) {
// Do not copy RenewEventId
((struct SClientSubscription *)q)->m_renewEventId = -1;
UpnpClientSubscription_set_SID(q, UpnpClientSubscription_get_SID(p));
UpnpClientSubscription_set_ActualSID(q, UpnpClientSubscription_get_ActualSID(p));
UpnpClientSubscription_set_EventURL(q, UpnpClientSubscription_get_EventURL(p));
// Do not copy m_next
((struct SClientSubscription *)q)->m_next = NULL;
}
}
int UpnpClientSubscription_get_RenewEventId(const ClientSubscription *p)
{
return ((struct SClientSubscription *)p)->m_renewEventId;
}
void UpnpClientSubscription_set_RenewEventId(ClientSubscription *p, int n)
{
((struct SClientSubscription *)p)->m_renewEventId = n;
}
const UpnpString *UpnpClientSubscription_get_SID(const ClientSubscription *p)
{
return ((struct SClientSubscription *)p)->m_SID;
}
const char *UpnpClientSubscription_get_SID_cstr(const ClientSubscription *p)
{
return UpnpString_get_String(UpnpClientSubscription_get_SID(p));
}
void UpnpClientSubscription_set_SID(ClientSubscription *p, const UpnpString *s)
{
UpnpString_delete(((struct SClientSubscription *)p)->m_SID);
((struct SClientSubscription *)p)->m_SID = UpnpString_dup(s);
}
void UpnpClientSubscription_strcpy_SID(ClientSubscription *p, const char *s)
{
UpnpString_delete(((struct SClientSubscription *)p)->m_SID);
((struct SClientSubscription *)p)->m_SID = UpnpString_new();
UpnpString_set_String(((struct SClientSubscription *)p)->m_SID, s);
}
const UpnpString *UpnpClientSubscription_get_ActualSID(const ClientSubscription *p)
{
return ((struct SClientSubscription *)p)->m_actualSID;
}
const char *UpnpClientSubscription_get_ActualSID_cstr(const ClientSubscription *p)
{
return UpnpString_get_String(UpnpClientSubscription_get_ActualSID(p));
}
void UpnpClientSubscription_set_ActualSID(ClientSubscription *p, const UpnpString *s)
{
UpnpString_delete(((struct SClientSubscription *)p)->m_actualSID);
((struct SClientSubscription *)p)->m_actualSID = UpnpString_dup(s);
}
void UpnpClientSubscription_strcpy_ActualSID(ClientSubscription *p, const char *s)
{
UpnpString_delete(((struct SClientSubscription *)p)->m_actualSID);
((struct SClientSubscription *)p)->m_actualSID = UpnpString_new();
UpnpString_set_String(((struct SClientSubscription *)p)->m_actualSID, s);
}
const UpnpString *UpnpClientSubscription_get_EventURL(const ClientSubscription *p)
{
return ((struct SClientSubscription *)p)->m_eventURL;
}
const char *UpnpClientSubscription_get_EventURL_cstr(const ClientSubscription *p)
{
return UpnpString_get_String(UpnpClientSubscription_get_EventURL(p));
}
void UpnpClientSubscription_set_EventURL(ClientSubscription *p, const UpnpString *s)
{
UpnpString_delete(((struct SClientSubscription *)p)->m_eventURL);
((struct SClientSubscription *)p)->m_eventURL = UpnpString_dup(s);
}
void UpnpClientSubscription_strcpy_EventURL(ClientSubscription *p, const char *s)
{
UpnpString_delete(((struct SClientSubscription *)p)->m_eventURL);
((struct SClientSubscription *)p)->m_eventURL = UpnpString_new();
UpnpString_set_String(((struct SClientSubscription *)p)->m_eventURL, s);
}
ClientSubscription *UpnpClientSubscription_get_Next(const ClientSubscription *p)
{
return (ClientSubscription *)(((struct SClientSubscription *)p)->m_next);
}
void UpnpClientSubscription_set_Next(ClientSubscription *p, ClientSubscription *q)
{
((struct SClientSubscription *)p)->m_next = (struct SClientSubscription *)q;
}
void free_client_subscription(ClientSubscription *sub)
{
upnp_timeout *event;
ThreadPoolJob tempJob;
if (sub) {
int renewEventId = GenlibClientSubscription_get_RenewEventId(sub);
GenlibClientSubscription_strcpy_ActualSID(sub, "");
GenlibClientSubscription_strcpy_EventURL(sub, "");
int renewEventId = UpnpClientSubscription_get_RenewEventId(sub);
UpnpClientSubscription_strcpy_ActualSID(sub, "");
UpnpClientSubscription_strcpy_EventURL(sub, "");
if (renewEventId != -1) {
// do not remove timer event of copy
// invalid timer event id
@@ -35,7 +245,7 @@ void free_client_subscription(ClientSubscription *sub)
free_upnp_timeout(event);
}
}
GenlibClientSubscription_set_RenewEventId(sub, -1);
UpnpClientSubscription_set_RenewEventId(sub, -1);
}
}
@@ -45,8 +255,8 @@ void freeClientSubList(ClientSubscription *list)
ClientSubscription *next;
while (list) {
free_client_subscription(list);
next = GenlibClientSubscription_get_Next(list);
GenlibClientSubscription_delete(list);
next = UpnpClientSubscription_get_Next(list);
UpnpClientSubscription_delete(list);
list = next;
}
}
@@ -60,20 +270,20 @@ void RemoveClientSubClientSID(ClientSubscription **head, const UpnpString *sid)
while (finger) {
found = !strcmp(
UpnpString_get_String(sid),
GenlibClientSubscription_get_SID_cstr(finger));
UpnpClientSubscription_get_SID_cstr(finger));
if (found) {
if (previous) {
GenlibClientSubscription_set_Next(previous,
GenlibClientSubscription_get_Next(finger));
UpnpClientSubscription_set_Next(previous,
UpnpClientSubscription_get_Next(finger));
} else {
*head = GenlibClientSubscription_get_Next(finger);
*head = UpnpClientSubscription_get_Next(finger);
}
GenlibClientSubscription_set_Next(finger, NULL);
UpnpClientSubscription_set_Next(finger, NULL);
freeClientSubList(finger);
finger = NULL;
} else {
previous = finger;
finger = GenlibClientSubscription_get_Next(finger);
finger = UpnpClientSubscription_get_Next(finger);
}
}
}
@@ -85,12 +295,12 @@ ClientSubscription *GetClientSubClientSID(ClientSubscription *head, const UpnpSt
int found = 0;
while (next) {
found = !strcmp(
GenlibClientSubscription_get_SID_cstr(next),
UpnpClientSubscription_get_SID_cstr(next),
UpnpString_get_String(sid));
if(found) {
break;
} else {
next = GenlibClientSubscription_get_Next(next);
next = UpnpClientSubscription_get_Next(next);
}
}
@@ -103,11 +313,11 @@ ClientSubscription *GetClientSubActualSID(ClientSubscription *head, token *sid)
ClientSubscription *next = head;
while (next) {
if (!memcmp(
GenlibClientSubscription_get_ActualSID_cstr(next),
UpnpClientSubscription_get_ActualSID_cstr(next),
sid->buff, sid->size)) {
break;
} else {
next = GenlibClientSubscription_get_Next(next);
next = UpnpClientSubscription_get_Next(next);
}
}
@@ -115,5 +325,5 @@ ClientSubscription *GetClientSubActualSID(ClientSubscription *head, token *sid)
}
#endif /* INCLUDE_CLIENT_APIS */
#endif /* INCLUDE_CLIENT_APIS */

View File

@@ -579,41 +579,59 @@ static int get_miniserver_sockets(
{
char errorBuffer[ERROR_BUFFER_LEN];
struct sockaddr_storage __ss_v4;
struct sockaddr_storage __ss_v6;
struct sockaddr_in* serverAddr4 = (struct sockaddr_in*)&__ss_v4;
SOCKET listenfd4 = INVALID_SOCKET;
unsigned short actual_port4;
#ifdef UPNP_ENABLE_IPV6
struct sockaddr_storage __ss_v6;
struct sockaddr_in6* serverAddr6 = (struct sockaddr_in6*)&__ss_v6;
SOCKET listenfd4, listenfd6;
SOCKET listenfd6 = INVALID_SOCKET;
unsigned short actual_port6;
#endif
int ret_code;
unsigned short actual_port4, actual_port6;
int reuseaddr_on = 0;
int sockError = UPNP_E_SUCCESS;
int errCode = 0;
//
// Initialize all the sockets to be invalid
//
out->miniServerSock4 = INVALID_SOCKET;
out->miniServerSock6 = INVALID_SOCKET;
// Create listen socket for IPv4/IPv6. An error here may indicate
// that we don't have an IPv4/IPv6 stack.
listenfd4 = socket(AF_INET, SOCK_STREAM, 0);
listenfd6 = socket(AF_INET6, SOCK_STREAM, 0);
if (listenfd4 == INVALID_SOCKET && listenfd6 == INVALID_SOCKET) {
if (listenfd4 == INVALID_SOCKET) {
return UPNP_E_OUTOF_SOCKET;
}
#ifdef UPNP_ENABLE_IPV6
listenfd6 = socket(AF_INET6, SOCK_STREAM, 0);
if (listenfd6 == INVALID_SOCKET) {
return UPNP_E_OUTOF_SOCKET;
}
#endif
// As per the IANA specifications for the use of ports by applications
// override the listen port passed in with the first available
if (listen_port4 < APPLICATION_LISTENING_PORT) {
listen_port4 = APPLICATION_LISTENING_PORT;
}
#ifdef UPNP_ENABLE_IPV6
if (listen_port6 < APPLICATION_LISTENING_PORT) {
listen_port6 = APPLICATION_LISTENING_PORT;
}
#endif
memset(&__ss_v4, 0, sizeof (__ss_v4));
serverAddr4->sin_family = AF_INET;
serverAddr4->sin_addr.s_addr = htonl(INADDR_ANY);
#ifdef UPNP_ENABLE_IPV6
memset(&__ss_v6, 0, sizeof (__ss_v6));
serverAddr6->sin6_family = AF_INET6;
serverAddr6->sin6_addr = in6addr_any;
#endif
// Getting away with implementation of re-using address:port and instead
// choosing to increment port numbers.
// Keeping the re-use address code as an optional behaviour that can be
@@ -633,8 +651,10 @@ static int get_miniserver_sockets(
if (sockError == -1) {
shutdown(listenfd4, SD_BOTH);
UpnpCloseSocket(listenfd4);
#ifdef UPNP_ENABLE_IPV6
shutdown(listenfd6, SD_BOTH);
UpnpCloseSocket(listenfd6);
#endif
return UPNP_E_SOCKET_BIND;
}
@@ -647,14 +667,17 @@ static int get_miniserver_sockets(
errorBuffer);
shutdown(listenfd4, SD_BOTH);
UpnpCloseSocket(listenfd4);
#ifdef UPNP_ENABLE_IPV6
shutdown(listenfd6, SD_BOTH);
UpnpCloseSocket(listenfd6);
#endif
/* Bind failed */
return UPNP_E_SOCKET_BIND;
}
}
if(listenfd6 != INVALID_SOCKET) {
#ifdef UPNP_ENABLE_IPV6
if (listenfd6 != INVALID_SOCKET) {
sockError = setsockopt(listenfd6, SOL_SOCKET, SO_REUSEADDR,
(const char *)&reuseaddr_on, sizeof (int));
if (sockError == -1) {
@@ -680,6 +703,7 @@ static int get_miniserver_sockets(
return UPNP_E_SOCKET_BIND;
}
}
#endif //IPv6
} else {
if (listenfd4 != INVALID_SOCKET) {
unsigned short orig_listen_port4 = listen_port4;
@@ -707,12 +731,15 @@ static int get_miniserver_sockets(
errorBuffer);
shutdown(listenfd4, SD_BOTH);
UpnpCloseSocket(listenfd4);
#ifdef UPNP_ENABLE_IPV6
shutdown(listenfd6, SD_BOTH);
UpnpCloseSocket(listenfd6);
#endif
return UPNP_E_SOCKET_BIND; // bind failed
}
}
#ifdef UPNP_ENABLE_IPV6
if (listenfd6 != INVALID_SOCKET) {
unsigned short orig_listen_port6 = listen_port6;
do {
@@ -745,6 +772,7 @@ static int get_miniserver_sockets(
return UPNP_E_SOCKET_BIND;
}
}
#endif
}
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
@@ -759,8 +787,10 @@ static int get_miniserver_sockets(
errorBuffer);
shutdown(listenfd4, SD_BOTH);
UpnpCloseSocket(listenfd4);
#ifdef UPNP_ENABLE_IPV6
shutdown(listenfd6, SD_BOTH);
UpnpCloseSocket(listenfd6);
#endif
return UPNP_E_LISTEN;
}
@@ -768,14 +798,17 @@ static int get_miniserver_sockets(
if (actual_port4 <= 0) {
shutdown(listenfd4, SD_BOTH);
UpnpCloseSocket(listenfd4);
#ifdef UPNP_ENABLE_IPV6
shutdown(listenfd6, SD_BOTH);
UpnpCloseSocket(listenfd6);
#endif
return UPNP_E_INTERNAL_ERROR;
}
out->miniServerPort4 = actual_port4;
}
#ifdef UPNP_ENABLE_IPV6
if (listenfd6 != INVALID_SOCKET) {
ret_code = listen(listenfd6, SOMAXCONN);
if (ret_code == -1) {
@@ -801,10 +834,11 @@ static int get_miniserver_sockets(
out->miniServerPort6 = actual_port6;
}
#endif
out->miniServerSock4 = listenfd4;
#ifdef UPNP_ENABLE_IPV6
out->miniServerSock6 = listenfd6;
#endif
return UPNP_E_SUCCESS;
}
#endif /* INTERNAL_WEB_SERVER */

View File

@@ -72,7 +72,6 @@ static str_int_entry Http_Method_Table[NUM_HTTP_METHODS] = {
{"SUBSCRIBE", HTTPMETHOD_SUBSCRIBE},
{"UNSUBSCRIBE", HTTPMETHOD_UNSUBSCRIBE},
{"POST", SOAPMETHOD_POST},
};
#define NUM_HTTP_HEADER_NAMES 33
@@ -113,9 +112,7 @@ str_int_entry Http_Header_Names[NUM_HTTP_HEADER_NAMES] = {
};
/***********************************************************************/
/************* scanner *************/
/***********************************************************************/
#define TOKCHAR_CR 0xD
@@ -134,13 +131,11 @@ str_int_entry Http_Header_Names[NUM_HTTP_HEADER_NAMES] = {
*
* Note :
************************************************************************/
static UPNP_INLINE void
scanner_init( OUT scanner_t *scanner,
IN membuffer *bufptr )
static UPNP_INLINE void scanner_init(OUT scanner_t *scanner, IN membuffer *bufptr)
{
scanner->cursor = 0;
scanner->msg = bufptr;
scanner->entire_msg_loaded = FALSE;
scanner->cursor = 0;
scanner->msg = bufptr;
scanner->entire_msg_loaded = FALSE;
}
/************************************************************************
@@ -155,10 +150,9 @@ scanner_init( OUT scanner_t *scanner,
*
* Note :
************************************************************************/
static UPNP_INLINE xboolean
is_separator_char( IN char c )
static UPNP_INLINE xboolean is_separator_char(IN char c)
{
return strchr( " \t()<>@,;:\\\"/[]?={}", c ) != NULL;
return strchr(" \t()<>@,;:\\\"/[]?={}", c) != NULL;
}
/************************************************************************
@@ -173,10 +167,9 @@ is_separator_char( IN char c )
*
* Note :
************************************************************************/
static UPNP_INLINE xboolean
is_identifier_char( IN char c )
static UPNP_INLINE xboolean is_identifier_char(IN char c)
{
return ( c >= 32 && c <= 126 ) && !is_separator_char( c );
return c >= 32 && c <= 126 && !is_separator_char(c);
}
/************************************************************************
@@ -191,10 +184,9 @@ is_identifier_char( IN char c )
*
* Note :
************************************************************************/
static UPNP_INLINE xboolean
is_control_char( IN char c )
static UPNP_INLINE xboolean is_control_char(IN char c)
{
return ( ( c >= 0 && c <= 31 ) || ( c == 127 ) );
return (c >= 0 && c <= 31) || c == 127;
}
/************************************************************************
@@ -209,8 +201,7 @@ is_control_char( IN char c )
*
* Note :
************************************************************************/
static UPNP_INLINE xboolean
is_qdtext_char( IN char cc )
static UPNP_INLINE xboolean is_qdtext_char(IN char cc)
{
unsigned char c = ( unsigned char )cc;
@@ -244,10 +235,10 @@ is_qdtext_char( IN char cc )
*
* Note :
************************************************************************/
static parse_status_t
scanner_get_token( INOUT scanner_t * scanner,
OUT memptr * token,
OUT token_type_t * tok_type )
static parse_status_t scanner_get_token(
INOUT scanner_t *scanner,
OUT memptr *token,
OUT token_type_t *tok_type)
{
char *cursor;
char *null_terminator; // point to null-terminator in buffer
@@ -388,57 +379,11 @@ scanner_get_token( INOUT scanner_t * scanner,
*
* Note :
************************************************************************/
static UPNP_INLINE char *
scanner_get_str( IN scanner_t * scanner )
static UPNP_INLINE char *scanner_get_str(IN scanner_t * scanner)
{
return scanner->msg->buf + scanner->cursor;
return scanner->msg->buf + scanner->cursor;
}
/************************************************************************
* Function : scanner_pushback
*
* Parameters :
* INOUT scanner_t* scanner ; Scanner Object
* IN size_t pushback_bytes ; Bytes to be moved back
*
* Description : Move back by a certain number of bytes.
* This is used to put back one or more tokens back into the input
*
* Return : void ;
*
* Note :
************************************************************************/
#ifdef WIN32
#pragma message ("The only use of the function 'scanner_pushback()' in the code is commented out.")
#pragma message ("'scanner_pushback()' is a candidate for removal.")
#else
#warning The only use of the function 'scanner_pushback()' in the code is commented out.
#warning 'scanner_pushback()' is a candidate for removal.
#endif
static UPNP_INLINE void
scanner_pushback( INOUT scanner_t * scanner,
IN size_t pushback_bytes )
{
scanner->cursor -= pushback_bytes;
}
/***********************************************************************/
/************* end of scanner **************/
/***********************************************************************/
/***********************************************************************/
/************* parser **************/
/***********************************************************************/
/***********************************************************************/
/************* http_message_t **************/
/***********************************************************************/
/************************************************************************
* Function : httpmsg_compare
@@ -453,15 +398,14 @@ scanner_pushback( INOUT scanner_t * scanner,
*
* Note :
************************************************************************/
static int
httpmsg_compare( void *param1,
void *param2 )
static int httpmsg_compare(void *param1, void *param2)
{
assert( param1 != NULL );
assert( param2 != NULL );
return ( ( http_header_t * ) param1 )->name_id ==
( ( http_header_t * ) param2 )->name_id;
return
((http_header_t *)param1)->name_id ==
((http_header_t *)param2)->name_id;
}
/************************************************************************
@@ -476,8 +420,7 @@ httpmsg_compare( void *param1,
*
* Note :
************************************************************************/
static void
httpheader_free( void *msg )
static void httpheader_free(void *msg)
{
http_header_t *hdr = ( http_header_t * ) msg;
@@ -498,8 +441,7 @@ httpheader_free( void *msg )
*
* Note :
************************************************************************/
void
httpmsg_init( INOUT http_message_t * msg )
void httpmsg_init(INOUT http_message_t *msg)
{
msg->initialized = 1;
msg->entity.buf = NULL;
@@ -521,8 +463,7 @@ httpmsg_init( INOUT http_message_t * msg )
*
* Note :
************************************************************************/
void
httpmsg_destroy( INOUT http_message_t * msg )
void httpmsg_destroy( INOUT http_message_t * msg )
{
assert( msg != NULL );
@@ -550,9 +491,9 @@ httpmsg_destroy( INOUT http_message_t * msg )
*
* Note :
************************************************************************/
http_header_t *
httpmsg_find_hdr_str( IN http_message_t * msg,
IN const char *header_name )
http_header_t *httpmsg_find_hdr_str(
IN http_message_t *msg,
IN const char *header_name)
{
http_header_t *header;
@@ -587,27 +528,21 @@ httpmsg_find_hdr_str( IN http_message_t * msg,
*
* Note :
************************************************************************/
http_header_t *
httpmsg_find_hdr( IN http_message_t * msg,
IN int header_name_id,
OUT memptr * value )
http_header_t *httpmsg_find_hdr(
IN http_message_t *msg,
IN int header_name_id,
OUT memptr *value)
{
http_header_t header; // temp header for searching
ListNode *node;
http_header_t *data;
header.name_id = header_name_id;
node = ListFind( &msg->headers, NULL, &header );
if( node == NULL ) {
return NULL;
}
data = ( http_header_t * ) node->item;
if( value != NULL ) {
value->buf = data->value.buf;
value->length = data->value.length;
@@ -616,12 +551,6 @@ httpmsg_find_hdr( IN http_message_t * msg,
return data;
}
/***********************************************************************/
/************* http_parser_t **************/
/***********************************************************************/
/************************************************************************
* Function : skip_blank_lines
*
@@ -634,26 +563,23 @@ httpmsg_find_hdr( IN http_message_t * msg,
*
* Note :
************************************************************************/
static UPNP_INLINE int
skip_blank_lines( INOUT scanner_t * scanner )
static UPNP_INLINE int skip_blank_lines(INOUT scanner_t *scanner)
{
memptr token;
token_type_t tok_type;
parse_status_t status;
memptr token;
token_type_t tok_type;
parse_status_t status;
// skip ws, crlf
do {
status = scanner_get_token( scanner, &token, &tok_type );
} while( status == PARSE_OK &&
( tok_type == TT_WHITESPACE || tok_type == TT_CRLF ) );
/* skip ws, crlf */
do {
status = scanner_get_token(scanner, &token, &tok_type);
} while (status == PARSE_OK &&
(tok_type == TT_WHITESPACE || tok_type == TT_CRLF));
if (status == PARSE_OK) {
/* pushback a non-whitespace token */
scanner->cursor -= token.length;
}
if( status == PARSE_OK ) {
// pushback a non-whitespace token
scanner->cursor -= token.length;
//scanner_pushback( scanner, token.length );
}
return status;
return status;
}
/************************************************************************
@@ -671,8 +597,7 @@ skip_blank_lines( INOUT scanner_t * scanner )
*
* Note :
************************************************************************/
static UPNP_INLINE int
skip_lws( INOUT scanner_t * scanner )
static UPNP_INLINE int skip_lws(INOUT scanner_t *scanner)
{
memptr token;
token_type_t tok_type;
@@ -726,9 +651,9 @@ skip_lws( INOUT scanner_t * scanner )
*
* Note :
************************************************************************/
static UPNP_INLINE parse_status_t
match_non_ws_string( INOUT scanner_t * scanner,
OUT memptr * str )
static UPNP_INLINE parse_status_t match_non_ws_string(
INOUT scanner_t *scanner,
OUT memptr *str)
{
memptr token;
token_type_t tok_type;
@@ -792,9 +717,9 @@ match_non_ws_string( INOUT scanner_t * scanner,
*
* Note :
************************************************************************/
static UPNP_INLINE parse_status_t
match_raw_value( INOUT scanner_t * scanner,
OUT memptr * raw_value )
static UPNP_INLINE parse_status_t match_raw_value(
INOUT scanner_t * scanner,
OUT memptr *raw_value)
{
memptr token;
token_type_t tok_type;
@@ -883,10 +808,10 @@ match_raw_value( INOUT scanner_t * scanner,
* PARSE_FAILURE -- bad input
* PARSE_INCOMPLETE
************************************************************************/
static UPNP_INLINE int
match_int( INOUT scanner_t * scanner,
IN int base,
OUT int *value )
static UPNP_INLINE int match_int(
INOUT scanner_t *scanner,
IN int base,
OUT int *value)
{
memptr token;
token_type_t tok_type;
@@ -970,36 +895,6 @@ read_until_crlf( INOUT scanner_t * scanner,
return status;
}
/************************************************************************
* Function: skip_to_end_of_header
*
* Parameters:
* INOUT scanner_t* scanner ; Scanner Object
*
* Description: Skip to end of header
*
* Returns:
* PARSE_OK
* PARSE_FAILURE
* PARSE_INCOMPLETE
************************************************************************/
#ifdef WIN32
#pragma message("There are currently no uses of the function 'skip_to_end_of_header()' in the code.")
#pragma message("'skip_to_end_of_header()' is a candidate for removal.")
#else
#warning There are currently no uses of the function 'skip_to_end_of_header()' in the code.
#warning 'skip_to_end_of_header()' is a candidate for removal.
#endif
static UPNP_INLINE int
skip_to_end_of_header( INOUT scanner_t * scanner )
{
memptr dummy_raw_value;
parse_status_t status;
status = match_raw_value( scanner, &dummy_raw_value );
return status;
}
/************************************************************************
* Function: match_char
*
@@ -1754,140 +1649,6 @@ parser_parse_headers( INOUT http_parser_t * parser )
}
////////////////////////////////////////////////////////////////////////
#ifdef HIGHLY_UNLIKELY
// **************
static parse_status_t
parser_parse_headers_old( INOUT http_parser_t * parser )
{
parse_status_t status;
memptr token;
memptr hdr_value;
token_type_t tok_type;
scanner_t *scanner = &parser->scanner;
size_t save_pos;
http_header_t *header;
int header_id;
int ret = 0;
int index;
http_header_t *orig_header;
char save_char;
int ret2,
ret3;
assert( parser->position == POS_HEADERS ||
parser->ent_position == ENTREAD_CHUNKY_HEADERS );
while( TRUE ) {
save_pos = scanner->cursor;
//
// check end of headers
//
status = scanner_get_token( scanner, &token, &tok_type );
if( status != PARSE_OK ) {
return status;
}
if( tok_type == TT_CRLF ) {
// end of headers
parser->position = POS_ENTITY; // read entity next
return PARSE_OK;
}
//
// not end; read header
//
if( tok_type != TT_IDENTIFIER ) {
return PARSE_FAILURE; // didn't see header name
}
status = match( scanner, " : %R%c", &hdr_value );
if( status != PARSE_OK ) {
// pushback tokens; useful only on INCOMPLETE error
scanner->cursor = save_pos;
return status;
}
//
// add header
//
// find header
index = map_str_to_int( token.buf, token.length, Http_Header_Names,
NUM_HTTP_HEADER_NAMES, FALSE );
if( index != -1 ) {
header_id = Http_Header_Names[index].id;
orig_header =
httpmsg_find_hdr( &parser->msg, header_id, NULL );
} else {
header_id = HDR_UNKNOWN;
save_char = token.buf[token.length];
token.buf[token.length] = '\0';
orig_header = httpmsg_find_hdr_str( &parser->msg, token.buf );
token.buf[token.length] = save_char; // restore
}
if( orig_header == NULL ) {
//
// add new header
//
header = ( http_header_t * ) malloc( sizeof( http_header_t ) );
if( header == NULL ) {
parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR;
return PARSE_FAILURE;
}
membuffer_init( &header->multi_hdr_buf );
header->name = token;
header->value = hdr_value;
header->name_id = header_id;
ret = dlist_append( &parser->msg.headers, header );
if( ret == UPNP_E_OUTOF_MEMORY ) {
parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR;
return PARSE_FAILURE;
}
} else if( hdr_value.length > 0 ) {
//
// append value to existing header
//
if( orig_header->multi_hdr_buf.buf == NULL ) {
// store in buffer
ret = membuffer_append( &orig_header->multi_hdr_buf,
orig_header->value.buf,
orig_header->value.length );
}
// append space
ret2 =
membuffer_append( &orig_header->multi_hdr_buf, ", ", 2 );
// append continuation of header value
ret3 = membuffer_append( &orig_header->multi_hdr_buf,
hdr_value.buf, hdr_value.length );
if( ret == UPNP_E_OUTOF_MEMORY ||
ret2 == UPNP_E_OUTOF_MEMORY ||
ret3 == UPNP_E_OUTOF_MEMORY ) {
// not enuf mem
parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR;
return PARSE_FAILURE;
}
// header value points to allocated buf
orig_header->value.buf = orig_header->multi_hdr_buf.buf;
orig_header->value.length = orig_header->multi_hdr_buf.length;
}
} // end while
}
#endif
// ******************************
/************************************************************************
* Function: parser_parse_entity_using_clen
*
@@ -1909,9 +1670,9 @@ parser_parse_entity_using_clen( INOUT http_parser_t * parser )
assert( parser->ent_position == ENTREAD_USING_CLEN );
// determine entity (i.e. body) length so far
//entity_length = parser->msg.msg.length - parser->entity_start_position;
parser->msg.entity.length =
parser->msg.msg.length - parser->entity_start_position;
parser->msg.msg.length - parser->entity_start_position +
parser->msg.entity_offset;
if( parser->msg.entity.length < parser->content_length ) {
// more data to be read
@@ -1919,7 +1680,8 @@ parser_parse_entity_using_clen( INOUT http_parser_t * parser )
} else {
if( parser->msg.entity.length > parser->content_length ) {
// silently discard extra data
parser->msg.msg.buf[parser->entity_start_position +
parser->msg.msg.buf[parser->entity_start_position -
parser->msg.entity_offset +
parser->content_length] = '\0';
}
// save entity length
@@ -2304,6 +2066,7 @@ parser_response_init( OUT http_parser_t * parser,
parser_init( parser );
parser->msg.is_request = FALSE;
parser->msg.request_method = request_method;
parser->msg.entity_offset = 0;
parser->position = POS_RESPONSE_LINE;
}
@@ -2399,10 +2162,6 @@ parser_append( INOUT http_parser_t * parser,
return parser_parse( parser );
}
/************************************************************************
********** end of parser ***********
************************************************************************/
/************************************************************************
* Function: raw_to_int
*
@@ -2415,9 +2174,7 @@ parser_append( INOUT http_parser_t * parser,
* Returns:
* int
************************************************************************/
int
raw_to_int( IN memptr * raw_value,
IN int base )
int raw_to_int(IN memptr *raw_value, IN int base)
{
long num;
char *end_ptr;
@@ -2454,9 +2211,7 @@ raw_to_int( IN memptr * raw_value,
* Returns:
* int - index at which the substring is found.
************************************************************************/
int
raw_find_str( IN memptr *raw_value,
IN const char *str )
int raw_find_str(IN memptr *raw_value, IN const char *str)
{
char c;
char *ptr;
@@ -2499,8 +2254,7 @@ raw_find_str( IN memptr *raw_value,
* Returns:
* const char* ptr - Ptr to the HTTP Method
************************************************************************/
const char *
method_to_str( IN http_method_t method )
const char *method_to_str(IN http_method_t method)
{
int index;
@@ -2544,5 +2298,5 @@ void print_http_headers(http_message_t *hmsg)
/* NNS: node = dlist_next( &hmsg->headers, node ); */
}
}
#endif
#endif /* DEBUG */

File diff suppressed because it is too large Load Diff

View File

@@ -42,7 +42,6 @@
#include "webserver.h"
#include "FileInfo.h"
#include "httpparser.h"
#include "httpreadwrite.h"
#include "ithread.h"
@@ -298,20 +297,20 @@ search_extension( IN const char *extension,
*
* Parameters:
* IN const char* filename,
* OUT UpnpFileInfo *fileInfo
* OUT DOMString* content_type
*
* Description: Based on the extension, sets the content type of fileInfo
* based on type and content subtype. If content type and sub type
* are not found, unknown types are used
* Description: Based on the extension, clones an XML string based on
* type and content subtype. If content type and sub type are not
* found, unknown types are used
*
* Returns:
* 0 - On Sucess
* UPNP_E_OUTOF_MEMORY - on memory allocation failures
************************************************************************/
UPNP_INLINE int
static UPNP_INLINE int
get_content_type(
IN const char *filename,
OUT UpnpFileInfo *fileInfo)
OUT DOMString *content_type)
{
const char *extension;
const char *type;
@@ -320,7 +319,7 @@ get_content_type(
char *temp = NULL;
int length = 0;
UpnpFileInfo_set_ContentType(fileInfo, NULL);
( *content_type ) = NULL;
// get ext
extension = strrchr( filename, '.' );
@@ -342,10 +341,11 @@ get_content_type(
return UPNP_E_OUTOF_MEMORY;
}
sprintf( temp, "%s/%s", type, subtype );
UpnpFileInfo_set_ContentType(fileInfo, temp);
( *content_type ) = ixmlCloneDOMString( temp );
free(temp);
if (!UpnpFileInfo_get_ContentType(fileInfo)) {
if( !content_type ) {
return UPNP_E_OUTOF_MEMORY;
}
@@ -597,7 +597,7 @@ web_server_destroy( void )
*
* Parameters:
* IN const char *filename; Filename having the description document
* OUT UpnpFileInfo *info; File information object having file
* OUT struct File_Info * info ; File information object having file
* attributes such as filelength, when was the file last
* modified, whether a file or a directory and whether the
* file or directory is readable.
@@ -610,16 +610,15 @@ web_server_destroy( void )
* int
************************************************************************/
static int
get_file_info(
IN const char *filename,
OUT UpnpFileInfo *info)
get_file_info( IN const char *filename,
OUT struct File_Info *info )
{
int code;
struct stat s;
FILE *fp;
int rc = 0;
UpnpFileInfo_set_ContentType(info, NULL);
info->content_type = NULL;
code = stat(filename, &s);
if (code == -1) {
@@ -627,31 +626,30 @@ get_file_info(
}
if (S_ISDIR(s.st_mode)) {
UpnpFileInfo_set_IsDirectory(info, TRUE);
info->is_directory = TRUE;
} else if (S_ISREG(s.st_mode)) {
UpnpFileInfo_set_IsDirectory(info, FALSE);
info->is_directory = FALSE;
} else {
return -1;
}
// check readable
fp = fopen(filename, "r");
UpnpFileInfo_set_IsReadable(info, fp != NULL);
info->is_readable = ( fp != NULL );
if (fp) {
fclose(fp);
}
UpnpFileInfo_set_FileLength(info, s.st_size);
UpnpFileInfo_set_LastModified(info, &s.st_mtime);
info->file_length = s.st_size;
info->last_modified = s.st_mtime;
rc = get_content_type(filename, info);
rc = get_content_type( filename, &info->content_type );
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
"file info: %s, length: %lld, last_mod=%s readable=%d\n",
filename,
(long long)UpnpFileInfo_get_FileLength(info),
asctime(gmtime(UpnpFileInfo_get_LastModified(info))),
UpnpFileInfo_get_IsReadable(info));
filename, (long long)info->file_length,
asctime( gmtime( &info->last_modified ) ),
info->is_readable );
return rc;
}
@@ -698,7 +696,7 @@ web_server_set_root_dir( IN const char *root_dir )
* IN const char *request_file; request file passed in to be compared with
* OUT struct xml_alias_t* alias ; xml alias object which has a file name
* stored
* OUT UpnpFileInfo *info; File information object which will be
* OUT struct File_Info * info ; File information object which will be
* filled up if the file comparison succeeds
*
* Description: Compare the files names between the one on the XML alias
@@ -710,18 +708,17 @@ web_server_set_root_dir( IN const char *root_dir )
* FALSE if request is not an alias
************************************************************************/
static UPNP_INLINE xboolean
get_alias(
IN const char *request_file,
get_alias( IN const char *request_file,
OUT struct xml_alias_t *alias,
OUT UpnpFileInfo *info)
OUT struct File_Info *info )
{
int cmp = strcmp(alias->name.buf, request_file);
if (cmp == 0) {
// fill up info
UpnpFileInfo_set_FileLength(info, alias->doc.length);
UpnpFileInfo_set_IsDirectory(info, FALSE);
UpnpFileInfo_set_IsReadable(info, TRUE);
UpnpFileInfo_set_LastModified(info, &alias->last_modified);
info->file_length = alias->doc.length;
info->is_readable = TRUE;
info->is_directory = FALSE;
info->last_modified = alias->last_modified;
}
return cmp == 0;
@@ -1127,6 +1124,12 @@ CheckOtherHTTPHeaders( IN http_message_t * Req,
return RetCode;
}
break;
case HDR_ACCEPT_LANGUAGE:
{
memcpy( RespInstr->AcceptLanguageHeader, TmpBuf,
sizeof( RespInstr->AcceptLanguageHeader ) - 1 );
break;
}
default:
/*
TODO
@@ -1141,7 +1144,6 @@ CheckOtherHTTPHeaders( IN http_message_t * Req,
case HDR_CONTENT_LOCATION://return 1;
case HDR_ACCEPT: //return 1;
case HDR_ACCEPT_CHARSET://return 1;
case HDR_ACCEPT_LANGUAGE://return 1;
case HDR_USER_AGENT: break;//return 1;
*/
@@ -1208,7 +1210,7 @@ process_request( IN http_message_t * req,
int err_code;
char *request_doc;
UpnpFileInfo *finfo;
struct File_Info finfo;
xboolean using_alias;
xboolean using_virtual_dir;
uri_type *url;
@@ -1217,7 +1219,7 @@ process_request( IN http_message_t * req,
int resp_minor;
xboolean alias_grabbed;
size_t dummy;
const char *extra_headers;
const char *extra_headers = NULL;
print_http_headers( req );
@@ -1229,7 +1231,7 @@ process_request( IN http_message_t * req,
// init
request_doc = NULL;
finfo = UpnpFileInfo_new();
finfo.content_type = NULL;
alias_grabbed = FALSE;
err_code = HTTP_INTERNAL_SERVER_ERROR; // default error
using_virtual_dir = FALSE;
@@ -1273,10 +1275,12 @@ process_request( IN http_message_t * req,
if (is_valid_alias(&gAliasDoc)) {
alias_grab(alias);
alias_grabbed = TRUE;
using_alias = get_alias(request_doc, alias, finfo);
using_alias = get_alias( request_doc, alias, &finfo );
if (using_alias == TRUE) {
UpnpFileInfo_set_ContentType(finfo, "text/xml; charset=\"utf-8\"");
if (UpnpFileInfo_get_ContentType(finfo) == NULL) {
finfo.content_type = ixmlCloneDOMString( "text/xml" );
if( finfo.content_type == NULL ) {
goto error_handler;
}
}
@@ -1286,12 +1290,12 @@ process_request( IN http_message_t * req,
if (using_virtual_dir) {
if (req->method != HTTPMETHOD_POST) {
// get file info
if (virtualDirCallback.get_info(filename->buf, finfo) != 0) {
if (virtualDirCallback.get_info(filename->buf, &finfo) != 0) {
err_code = HTTP_NOT_FOUND;
goto error_handler;
}
// try index.html if req is a dir
if (UpnpFileInfo_get_IsDirectory(finfo)) {
if( finfo.is_directory ) {
if (filename->buf[filename->length - 1] == '/') {
temp_str = "index.html";
} else {
@@ -1301,14 +1305,14 @@ process_request( IN http_message_t * req,
goto error_handler;
}
// get info
if (virtualDirCallback.get_info(filename->buf, finfo) != UPNP_E_SUCCESS ||
UpnpFileInfo_get_IsDirectory(finfo)) {
if( (virtualDirCallback.get_info(filename->buf, &finfo ) != UPNP_E_SUCCESS ) ||
finfo.is_directory) {
err_code = HTTP_NOT_FOUND;
goto error_handler;
}
}
// not readable
if (!UpnpFileInfo_get_IsReadable(finfo)) {
if( !finfo.is_readable ) {
err_code = HTTP_FORBIDDEN;
goto error_handler;
}
@@ -1339,12 +1343,12 @@ process_request( IN http_message_t * req,
if( req->method != HTTPMETHOD_POST ) {
// get info on file
if (get_file_info(filename->buf, finfo) != 0) {
if( get_file_info( filename->buf, &finfo ) != 0 ) {
err_code = HTTP_NOT_FOUND;
goto error_handler;
}
// try index.html if req is a dir
if (UpnpFileInfo_get_IsDirectory(finfo)) {
if( finfo.is_directory ) {
if( filename->buf[filename->length - 1] == '/' ) {
temp_str = "index.html";
} else {
@@ -1354,14 +1358,14 @@ process_request( IN http_message_t * req,
goto error_handler;
}
// get info
if (get_file_info(filename->buf, finfo) != 0 ||
UpnpFileInfo_get_IsDirectory(finfo)) {
if( get_file_info( filename->buf, &finfo ) != 0 ||
finfo.is_directory ) {
err_code = HTTP_NOT_FOUND;
goto error_handler;
}
}
// not readable
if (!UpnpFileInfo_get_IsReadable(finfo)) {
if( !finfo.is_readable ) {
err_code = HTTP_FORBIDDEN;
goto error_handler;
}
@@ -1374,12 +1378,12 @@ process_request( IN http_message_t * req,
// }
}
RespInstr->ReadSendSize = UpnpFileInfo_get_FileLength(finfo);
RespInstr->ReadSendSize = finfo.file_length;
// Check other header field.
err_code =
CheckOtherHTTPHeaders(req, RespInstr, UpnpFileInfo_get_FileLength(finfo));
if ( err_code != HTTP_OK ) {
if( ( err_code =
CheckOtherHTTPHeaders( req, RespInstr,
finfo.file_length ) ) != HTTP_OK ) {
goto error_handler;
}
@@ -1389,7 +1393,7 @@ process_request( IN http_message_t * req,
goto error_handler;
}
extra_headers = UpnpFileInfo_get_ExtraHeaders(finfo);
/*extra_headers = UpnpFileInfo_get_ExtraHeaders(finfo);*/
if (!extra_headers) {
extra_headers = "";
}
@@ -1399,12 +1403,13 @@ process_request( IN http_message_t * req,
// Transfer-Encoding: chunked
if (http_MakeMessage(
headers, resp_major, resp_minor,
"R" "T" "GKD" "s" "tcS" "Xc" "sCc",
"R" "T" "GKLD" "s" "tcS" "Xc" "sCc",
HTTP_PARTIAL_CONTENT, // status code
UpnpFileInfo_get_ContentType(finfo), // content type
finfo.content_type, // content type
RespInstr, // range info
RespInstr, // language info
"LAST-MODIFIED: ",
UpnpFileInfo_get_LastModified(finfo),
&finfo.last_modified,
X_USER_AGENT,
extra_headers) != 0 ) {
goto error_handler;
@@ -1414,13 +1419,14 @@ process_request( IN http_message_t * req,
// Transfer-Encoding: chunked
if (http_MakeMessage(
headers, resp_major, resp_minor,
"R" "N" "T" "GD" "s" "tcS" "Xc" "sCc",
"R" "N" "T" "GLD" "s" "tcS" "Xc" "sCc",
HTTP_PARTIAL_CONTENT, // status code
RespInstr->ReadSendSize, // content length
UpnpFileInfo_get_ContentType(finfo), // content type
finfo.content_type, // content type
RespInstr, // range info
RespInstr, // language info
"LAST-MODIFIED: ",
UpnpFileInfo_get_LastModified(finfo),
&finfo.last_modified,
X_USER_AGENT,
extra_headers) != 0 ) {
goto error_handler;
@@ -1431,11 +1437,12 @@ process_request( IN http_message_t * req,
// Transfer-Encoding: chunked
if (http_MakeMessage(
headers, resp_major, resp_minor,
"RK" "TD" "s" "tcS" "Xc" "sCc",
"RK" "TLD" "s" "tcS" "Xc" "sCc",
HTTP_OK, // status code
UpnpFileInfo_get_ContentType(finfo), // content type
finfo.content_type, // content type
RespInstr, // language info
"LAST-MODIFIED: ",
UpnpFileInfo_get_LastModified(finfo),
&finfo.last_modified,
X_USER_AGENT,
extra_headers) != 0 ) {
goto error_handler;
@@ -1447,12 +1454,13 @@ process_request( IN http_message_t * req,
// Transfer-Encoding: chunked
if (http_MakeMessage(
headers, resp_major, resp_minor,
"R" "N" "TD" "s" "tcS" "Xc" "sCc",
"R" "N" "TLD" "s" "tcS" "Xc" "sCc",
HTTP_OK, // status code
RespInstr->ReadSendSize, // content length
UpnpFileInfo_get_ContentType(finfo), // content type
finfo.content_type, // content type
RespInstr, // language info
"LAST-MODIFIED: ",
UpnpFileInfo_get_LastModified(finfo),
&finfo.last_modified,
X_USER_AGENT,
extra_headers) != 0 ) {
goto error_handler;
@@ -1462,11 +1470,12 @@ process_request( IN http_message_t * req,
// Transfer-Encoding: chunked
if (http_MakeMessage(
headers, resp_major, resp_minor,
"R" "TD" "s" "tcS" "b" "Xc" "sCc",
"R" "TLD" "s" "tcS" "b" "Xc" "sCc",
HTTP_OK, // status code
UpnpFileInfo_get_ContentType(finfo), // content type
finfo.content_type, // content type
RespInstr, // language info
"LAST-MODIFIED: ",
UpnpFileInfo_get_LastModified(finfo),
&finfo.last_modified,
X_USER_AGENT,
extra_headers) != 0 ) {
goto error_handler;
@@ -1496,7 +1505,7 @@ process_request( IN http_message_t * req,
error_handler:
free(request_doc);
UpnpFileInfo_delete(finfo);
ixmlFreeDOMString( finfo.content_type );
if (err_code != UPNP_E_SUCCESS && alias_grabbed) {
alias_release(alias);
}
@@ -1698,6 +1707,8 @@ web_server_callback( IN http_parser_t * parser,
RespInstr.IsChunkActive = 0;
RespInstr.IsRangeActive = 0;
RespInstr.IsTrailers = 0;
memset( RespInstr.AcceptLanguageHeader, 0,
sizeof( RespInstr.AcceptLanguageHeader ) );
// init
membuffer_init( &headers );
membuffer_init( &filename );
@@ -1752,7 +1763,7 @@ web_server_callback( IN http_parser_t * parser,
http_MakeMessage(
&headers, 1, 1,
"RTDSXcCc",
"RTLSXcCc",
ret,
"text/html",
X_USER_AGENT );

View File

@@ -153,15 +153,31 @@ subscription *GetSubscriptionSID(const Upnp_SID sid, service_info *service)
}
subscription *GetNextSubscription(service_info *service, subscription *current)
/************************************************************************
* 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 )
{
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;
@@ -186,26 +202,52 @@ subscription *GetNextSubscription(service_info *service, subscription *current)
return next;
}
subscription *GetFirstSubscription(service_info *service)
/************************************************************************
* 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;
subscription temp;
subscription *next = NULL;
temp.next = service->subscriptionList;
next = GetNextSubscription(service, &temp);
service->subscriptionList = temp.next;
// service->subscriptionList = next;
return next;
temp.next = service->subscriptionList;
next = GetNextSubscription( service, &temp );
service->subscriptionList = temp.next;
// service->subscriptionList=next;
return next;
}
void freeSubscription(subscription *sub)
/************************************************************************
* 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 )
{
if (sub) {
free_URL_list(&sub->DeliveryURLs);
}
if( sub ) {
free_URL_list( &sub->DeliveryURLs );
}
}
/************************************************************************
@@ -871,8 +913,10 @@ getServiceList( IXML_Node * node,
( *end ) = current;
return head;
} else
} else {
( *end ) = NULL;
return NULL;
}
}
@@ -918,7 +962,8 @@ getAllServiceList( IXML_Node * node,
if( head ) {
end->next =
getServiceList( currentDevice, &next_end, URLBase );
end = next_end;
if ( next_end )
end = next_end;
} else
head = getServiceList( currentDevice, &end, URLBase );

View File

@@ -1,59 +1,65 @@
/*******************************************************************************
*
* 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.
*/
///////////////////////////////////////////////////////////////////////////
//
// 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.
//
///////////////////////////////////////////////////////////////////////////
/************************************************************************
* 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>
#include <stdlib.h> /* for free() */
void free_upnp_timeout(upnp_timeout *event)
/************************************************************************
* 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 )
{
if (event) {
if (event->Event) {
free(event->Event);
}
free(event);
}
}
if( event ) {
if( event->Event )
free( event->Event );
free( event );
}
}

View File

@@ -1,199 +0,0 @@
#ifndef CLIENTSUBSCRIPTION_H
#define CLIENTSUBSCRIPTION_H
/*!
* \file
*/
#ifdef __cplusplus
extern "C" {
#endif
#include "UpnpString.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#ifdef INCLUDE_CLIENT_APIS
typedef struct s_ClientSubscription ClientSubscription;
/*!
* \brief Constructor.
*/
ClientSubscription *GenlibClientSubscription_new();
/*!
* \brief Destructor.
*/
void GenlibClientSubscription_delete(
/*! [in] The \b this pointer. */
ClientSubscription *p);
/*!
* \brief Copy Constructor.
*/
ClientSubscription *GenlibClientSubscription_dup(
/*! [in] The \b this pointer. */
const ClientSubscription *p);
/*!
* \brief Assignment operator.
*/
void GenlibClientSubscription_assign(
/*! [in] The \b this pointer. */
ClientSubscription *q,
const ClientSubscription *p);
/*!
* \brief
*/
int GenlibClientSubscription_get_RenewEventId(
/*! [in] The \b this pointer. */
const ClientSubscription *p);
/*!
* \brief
*/
void GenlibClientSubscription_set_RenewEventId(
/*! [in] The \b this pointer. */
ClientSubscription *p,
/*! [in] . */
int n);
/*!
* \brief
*/
const UpnpString *GenlibClientSubscription_get_SID(
/*! [in] The \b this pointer. */
const ClientSubscription *p);
/*!
* \brief
*/
const char *GenlibClientSubscription_get_SID_cstr(
/*! [in] The \b this pointer. */
const ClientSubscription *p);
/*!
* \brief
*/
void GenlibClientSubscription_set_SID(
/*! [in] The \b this pointer. */
ClientSubscription *p,
const UpnpString *s);
/*!
* \brief
*/
void GenlibClientSubscription_strcpy_SID(
/*! [in] The \b this pointer. */
ClientSubscription *p,
const char *s);
/*!
* \brief
*/
const UpnpString *GenlibClientSubscription_get_ActualSID(
/*! [in] The \b this pointer. */
const ClientSubscription *p);
/*!
* \brief
*/
const char *GenlibClientSubscription_get_ActualSID_cstr(
/*! [in] The \b this pointer. */
const ClientSubscription *p);
/*!
* \brief
*/
void GenlibClientSubscription_set_ActualSID(
/*! [in] The \b this pointer. */
ClientSubscription *p,
const UpnpString *s);
/*!
* \brief
*/
void GenlibClientSubscription_strcpy_ActualSID(
/*! [in] The \b this pointer. */
ClientSubscription *p,
const char *s);
/*!
* \brief
*/
const UpnpString *GenlibClientSubscription_get_EventURL(
/*! [in] The \b this pointer. */
const ClientSubscription *p);
/*!
* \brief
*/
void GenlibClientSubscription_set_EventURL(
/*! [in] The \b this pointer. */
ClientSubscription *p,
const UpnpString *s);
/*!
* \brief
*/
void GenlibClientSubscription_strcpy_EventURL(
/*! [in] The \b this pointer. */
ClientSubscription *p,
const char *s);
/*!
* \brief
*/
ClientSubscription *GenlibClientSubscription_get_Next(
/*! [in] The \b this pointer. */
const ClientSubscription *p);
/*!
* \brief
*/
void GenlibClientSubscription_set_Next(
/*! [in] The \b this pointer. */
ClientSubscription *p,
ClientSubscription *q);
#endif /* INCLUDE_CLIENT_APIS */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* CLIENTSUBSCRIPTION_H */

View File

@@ -13,7 +13,6 @@ extern "C" {
#endif
#include "ClientSubscription.h"
#include "service_table.h"
#include "upnp.h"
#include "UpnpString.h"
@@ -33,6 +32,154 @@ extern TimerThread gTimerThread;
#ifdef INCLUDE_CLIENT_APIS
typedef struct s_ClientSubscription ClientSubscription;
/*!
* \brief Constructor.
*/
ClientSubscription *UpnpClientSubscription_new();
/*!
* \brief Destructor.
*/
void UpnpClientSubscription_delete(
/*! [in] The \b this pointer. */
ClientSubscription *p);
/*!
* \brief Copy Constructor.
*/
ClientSubscription *UpnpClientSubscription_dup(
/*! [in] The \b this pointer. */
const ClientSubscription *p);
/*!
* \brief Assignment operator.
*/
void UpnpClientSubscription_assign(
/*! [in] The \b this pointer. */
ClientSubscription *q,
const ClientSubscription *p);
/*!
* \brief
*/
int UpnpClientSubscription_get_RenewEventId(
/*! [in] The \b this pointer. */
const ClientSubscription *p);
/*!
* \brief
*/
void UpnpClientSubscription_set_RenewEventId(
/*! [in] The \b this pointer. */
ClientSubscription *p,
/*! [in] . */
int n);
/*!
* \brief
*/
const UpnpString *UpnpClientSubscription_get_SID(
/*! [in] The \b this pointer. */
const ClientSubscription *p);
/*!
* \brief
*/
void UpnpClientSubscription_set_SID(
/*! [in] The \b this pointer. */
ClientSubscription *p,
const UpnpString *s);
/*!
* \brief
*/
void UpnpClientSubscription_strcpy_SID(
/*! [in] The \b this pointer. */
ClientSubscription *p,
const char *s);
/*!
* \brief
*/
const UpnpString *UpnpClientSubscription_get_ActualSID(
/*! [in] The \b this pointer. */
const ClientSubscription *p);
/*!
* \brief
*/
void UpnpClientSubscription_set_ActualSID(
/*! [in] The \b this pointer. */
ClientSubscription *p,
const UpnpString *s);
/*!
* \brief
*/
void UpnpClientSubscription_strcpy_ActualSID(
/*! [in] The \b this pointer. */
ClientSubscription *p,
const char *s);
/*!
* \brief
*/
const UpnpString *UpnpClientSubscription_get_EventURL(
/*! [in] The \b this pointer. */
const ClientSubscription *p);
/*!
* \brief
*/
void UpnpClientSubscription_set_EventURL(
/*! [in] The \b this pointer. */
ClientSubscription *p,
const UpnpString *s);
/*!
* \brief
*/
void UpnpClientSubscription_strcpy_EventURL(
/*! [in] The \b this pointer. */
ClientSubscription *p,
const char *s);
/*!
* \brief
*/
ClientSubscription *UpnpClientSubscription_get_Next(
/*! [in] The \b this pointer. */
const ClientSubscription *p);
/*!
* \brief
*/
void UpnpClientSubscription_set_Next(
/*! [in] The \b this pointer. */
ClientSubscription *p,
ClientSubscription *q);
/*!
* \brief Free memory allocated for client subscription data.
*

View File

@@ -29,7 +29,6 @@
*
**************************************************************************/
#ifndef INTERNAL_CONFIG_H
#define INTERNAL_CONFIG_H
@@ -112,6 +111,24 @@
/* @} */
/*!
* \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
@@ -175,6 +192,20 @@
#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
*
@@ -395,17 +426,9 @@
#endif
#ifdef INCLUDE_CLIENT_APIS
# define CLIENTONLY(x) x
#else /* INCLUDE_CLIENT_APIS */
# define CLIENTONLY(x)
#endif /* INCLUDE_CLIENT_APIS */
/*
* @}
*/
#endif /* INTERNAL_CONFIG_H */

View File

@@ -1,64 +1,52 @@
/*******************************************************************************
*
* 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
*/
///////////////////////////////////////////////////////////////////////////
//
// 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 "sock.h"
/*!
* \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 */
/************************************************************************
* 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 );

View File

@@ -1,79 +1,88 @@
/*******************************************************************************
*
* 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
*/
///////////////////////////////////////////////////////////////////////////
//
// 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 "sock.h"
/*!
* \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_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 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_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 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 */
/****************************************************************************
* 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 );

View File

@@ -1,49 +1,42 @@
/*******************************************************************************
*
* 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
/*!
* \file
*/
#include "LinkedList.h"
#include "util.h"
#include "membuffer.h"
#include "uri.h"
#include "util.h"
#include "LinkedList.h"
////// private types ////////////
@@ -200,7 +193,8 @@ typedef struct // http_message_t
// private fields
membuffer msg; // entire raw message
char *urlbuf; // storage for url string
char *urlbuf; // storage for url string
size_t entity_offset;
} http_message_t;
typedef struct // http_parser_t
@@ -484,22 +478,27 @@ int raw_find_str( IN memptr* raw_value, IN const char* str );
************************************************************************/
const char* method_to_str( IN http_method_t method );
/*!
* \brief Print the HTTP headers.
*/
/************************************************************************
* Function: print_http_headers
*
* Parameters:
* http_message_t* hmsg ; HTTP Message object
*
* Description:
*
* Returns:
* void
************************************************************************/
#ifdef DEBUG
void print_http_headers(
/*! [in] HTTP Message object. */
http_message_t *hmsg );
void print_http_headers( IN http_message_t *hmsg );
#else
static UPNP_INLINE void print_http_headers(http_message_t *hmsg) {}
static UPNP_INLINE void print_http_headers( IN 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

@@ -6,6 +6,9 @@
#ifdef WIN32
#ifdef IPV6_
#define INET_IPV6
#endif
#include "unixutil.h"

View File

@@ -55,9 +55,11 @@ typedef struct MServerSockArray {
SOCKET miniServerPort4;
SOCKET miniServerPort6;
#ifdef INCLUDE_CLIENT_APIS
/* socket for sending search requests and receiving search replies */
CLIENTONLY(SOCKET ssdpReqSock4;)
CLIENTONLY(SOCKET ssdpReqSock6;)
SOCKET ssdpReqSock4;
SOCKET ssdpReqSock6;
#endif /* INCLUDE_CLIENT_APIS */
} MiniServerSockArray;

View File

@@ -1,133 +1,135 @@
///////////////////////////////////////////////////////////////////////////
//
// 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 SOAPLIB_H
#define SOAPLIB_H
// SOAP module API to be called in Upnp-Dk API
/* SOAP module API to be called in Upnp-Dk API */
/****************************************************************************
* Function : soap_device_callback
*
* Parameters :
* IN http_parser_t *parser : Parsed request received by the device
* IN http_message_t* request : HTTP request
* INOUT SOCKINFO *info : socket info
*
* Description : This is a callback called by minisever after receiving
* the request from the control point. This function will start
* processing the request. It calls handle_invoke_action to handle the
* SOAP action
*
* Return : void
*
* Note :
****************************************************************************/
* Function: soap_device_callback
*
* Parameters:
* IN http_parser_t *parser: Parsed request received by the device
* IN http_message_t* request: HTTP request
* INOUT SOCKINFO *info: socket info
*
* Description: This is a callback called by minisever after receiving
* the request from the control point. This function will start
* processing the request. It calls handle_invoke_action to handle the
* SOAP action
*
* Return: void
*
* Note:
****************************************************************************/
void soap_device_callback(
IN http_parser_t *parser,
IN http_message_t* request,
INOUT SOCKINFO *info );
INOUT SOCKINFO *info);
/****************************************************************************
* Function : SoapSendAction
*
* Parameters :
* IN char* action_url : device contrl URL
* IN char *service_type : device service type
* IN IXML_Document *action_node : SOAP action node
* OUT IXML_Document **response_node : SOAP response node
*
* Description : This function is called by UPnP API to send the SOAP
* action request and waits till it gets the response from the device
* pass the response to the API layer
*
* Return : int
* returns UPNP_E_SUCCESS if successful else returns appropriate error
* Note :
****************************************************************************/
* Function: SoapSendAction
*
* Parameters:
* IN char* action_url: device contrl URL
* IN char *service_type: device service type
* IN IXML_Document *action_node: SOAP action node
* OUT IXML_Document **response_node: SOAP response node
*
* Description: This function is called by UPnP API to send the SOAP
* action request and waits till it gets the response from the device
* pass the response to the API layer
*
* Return: int
* returns UPNP_E_SUCCESS if successful else returns appropriate error
* Note:
****************************************************************************/
int SoapSendAction(
IN char* action_url,
IN char *service_type,
IN IXML_Document *action_node,
OUT IXML_Document **response_node );
IN char* action_url,
IN char *service_type,
IN IXML_Document *action_node,
OUT IXML_Document **response_node);
/****************************************************************************
* Function : SoapSendActionEx
*
* Parameters :
* IN char* action_url : device contrl URL
* IN char *service_type : device service type
IN IXML_Document *Header: Soap header
* IN IXML_Document *action_node : SOAP action node ( SOAP body)
* OUT IXML_Document **response_node : SOAP response node
*
* Description : This function is called by UPnP API to send the SOAP
* action request and waits till it gets the response from the device
* pass the response to the API layer. This action is similar to the
* the SoapSendAction with only difference that it allows users to
* pass the SOAP header along the SOAP body ( soap action request)
*
* Return : int
* returns UPNP_E_SUCCESS if successful else returns appropriate error
* Note :
****************************************************************************/
* Function: SoapSendActionEx
*
* Parameters:
* IN char* action_url: device contrl URL
* IN char *service_type: device service type
* IN IXML_Document *Header: Soap header
* IN IXML_Document *action_node: SOAP action node (SOAP body)
* OUT IXML_Document **response_node: SOAP response node
*
* Description: This function is called by UPnP API to send the SOAP
* action request and waits till it gets the response from the device
* pass the response to the API layer. This action is similar to the
* the SoapSendAction with only difference that it allows users to
* pass the SOAP header along the SOAP body ( soap action request)
*
* Return: int
* returns UPNP_E_SUCCESS if successful else returns appropriate error
* Note:
****************************************************************************/
int SoapSendActionEx(
IN char * ActionURL,
IN char *ServiceType,
IN IXML_Document *Header,
IN IXML_Document *ActNode ,
OUT IXML_Document **RespNode) ;
IN char * ActionURL,
IN char *ServiceType,
IN IXML_Document *Header,
IN IXML_Document *ActNode,
OUT IXML_Document **RespNode);
/****************************************************************************
* Function : SoapGetServiceVarStatus
*
* Parameters :
* IN char * action_url : Address to send this variable
* query message.
* IN char *var_name : Name of the variable.
* OUT char **var_value : Output value.
*
* Description : This function creates a status variable query message
* send it to the specified URL. It also collect the response.
*
* Return : int
*
* Note :
****************************************************************************/
* Function: SoapGetServiceVarStatus
*
* Parameters:
* IN char * action_url: Address to send this variable query message.
* IN char *var_name: Name of the variable.
* OUT char **var_value: Output value.
*
* Description: This function creates a status variable query message
* send it to the specified URL. It also collect the response.
*
* Return: int
*
* Note:
****************************************************************************/
int SoapGetServiceVarStatus(
IN char * ActionURL,
IN DOMString VarName,
OUT DOMString *StVar) ;
IN char * ActionURL,
IN DOMString VarName,
OUT DOMString *StVar);
extern const char* ContentTypeHeader;
#endif //SOAPLIB_H
#endif /* SOAPLIB_H */

View File

@@ -47,15 +47,17 @@
#ifdef WIN32
#else
#else /* WIN32 */
#include <syslog.h>
#include <sys/socket.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#ifndef __APPLE__
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#endif /* __APPLE__ */
#include <sys/time.h>
#include <arpa/inet.h>
#endif
#endif /* WIN32 */
/* Enumeration to define all different types of ssdp searches */
@@ -138,6 +140,15 @@ typedef void (* SsdpFunPtr)(Event *);
typedef Event SsdpEvent ;
//Structure to contain Discovery response
typedef struct resultData
{
struct Upnp_Discovery param;
void *cookie;
Upnp_FunPtr ctrlpt_callback;
}ResultData;
typedef struct TData
{
int Mx;
@@ -174,9 +185,12 @@ typedef struct
/* globals */
CLIENTONLY(extern SOCKET gSsdpReqSocket4;);
CLIENTONLY(extern SOCKET gSsdpReqSocket6;);
#ifdef INCLUDE_CLIENT_APIS
extern SOCKET gSsdpReqSocket4;
#ifdef UPNP_ENABLE_IPV6
extern SOCKET gSsdpReqSocket6;
#endif /* UPNP_ENABLE_IPV6 */
#endif /* INCLUDE_CLIENT_APIS */
typedef int (*ParserFun)(char *, Event *);

View File

@@ -1,62 +1,58 @@
/*******************************************************************************
*
* 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;
/*!
* \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 */
/************************************************************************
* 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);
#endif

View File

@@ -48,6 +48,7 @@ struct SendInstruction
int IsRangeActive;
int IsTrailers;
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.
@@ -56,91 +57,90 @@ struct SendInstruction
};
/************************************************************************
* 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();
* 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();
* 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 );
/************************************************************************
* 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_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);
* 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 );
/************************************************************************
* 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);
* 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 );
#ifdef __cplusplus

View File

@@ -47,8 +47,6 @@
#define QUERY_STATE_VAR_URN "urn:schemas-upnp-org:control-1-0"
#include "ActionRequest.h"
#include "httpparser.h"
#include "httpreadwrite.h"
#include "parsetools.h"
@@ -583,8 +581,8 @@ check_soap_action_header( IN http_message_t * request,
* IN http_message_t* request : HTTP request
* IN int isQuery : flag for a querry
* IN IXML_Document *actionDoc : action request document
* OUT UpnpString *device_udn : Device UDN string
* OUT UpnpString *service_id : Service ID string
* OUT char device_udn[LINE_SIZE] : Device UDN string
* OUT char service_id[LINE_SIZE] : Service ID string
* OUT Upnp_FunPtr *callback : callback function of the device
* application
* OUT void** cookie : cookie stored by device application
@@ -604,8 +602,8 @@ get_device_info( IN http_message_t *request,
IN int isQuery,
IN IXML_Document *actionDoc,
IN int AddressFamily,
OUT UpnpString *device_udn,
OUT UpnpString *service_id,
OUT char device_udn[LINE_SIZE],
OUT char service_id[LINE_SIZE],
OUT Upnp_FunPtr *callback,
OUT void **cookie )
{
@@ -670,8 +668,8 @@ get_device_info( IN http_message_t *request,
}
}
UpnpString_set_String( device_udn, serv_info->UDN );
UpnpString_set_String( service_id, serv_info->serviceId );
namecopy( service_id, serv_info->serviceId );
namecopy( device_udn, serv_info->UDN );
*callback = device_info->Callback;
*cookie = device_info->Cookie;
@@ -861,10 +859,10 @@ static UPNP_INLINE void handle_query_variable(
IN http_message_t *request,
IN IXML_Document *xml_doc )
{
UpnpStateVarRequest *variable = UpnpStateVarRequest_new();
Upnp_FunPtr soap_event_callback;
void *cookie;
char var_name[LINE_SIZE];
struct Upnp_State_Var_Request variable;
const char *err_str;
int err_code;
@@ -876,50 +874,53 @@ static UPNP_INLINE void handle_query_variable(
}
// get info for event
err_code = get_device_info(
request, 1, xml_doc,
info->foreign_sockaddr.ss_family,
(UpnpString *)UpnpStateVarRequest_get_DevUDN(variable),
(UpnpString *)UpnpStateVarRequest_get_ServiceID(variable),
&soap_event_callback,
&cookie);
request, 1, xml_doc,
info->foreign_sockaddr.ss_family,
variable.DevUDN,
variable.ServiceID,
&soap_event_callback,
&cookie);
if( err_code != 0 ) {
send_error_response( info, SOAP_INVALID_VAR,
Soap_Invalid_Var, request );
return;
}
UpnpStateVarRequest_set_ErrCode(variable, UPNP_E_SUCCESS);
UpnpStateVarRequest_strcpy_StateVarName(variable, var_name);
UpnpStateVarRequest_set_CtrlPtIPAddr(variable, (struct sockaddr *)&info->foreign_sockaddr);
linecopy( variable.ErrStr, "" );
variable.ErrCode = UPNP_E_SUCCESS;
namecopy( variable.StateVarName, var_name );
variable.CurrentVal = NULL;
variable.CtrlPtIPAddr = info->foreign_sockaddr;
// send event
soap_event_callback( UPNP_CONTROL_GET_VAR_REQUEST, variable, cookie );
soap_event_callback( UPNP_CONTROL_GET_VAR_REQUEST, &variable, cookie );
UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
"Return from callback for var request\n" );
// validate, and handle result
if( UpnpStateVarRequest_get_CurrentVal(variable) == NULL ) {
if( variable.CurrentVal == NULL ) {
err_code = SOAP_ACTION_FAILED;
err_str = Soap_Action_Failed;
send_error_response( info, SOAP_INVALID_VAR, Soap_Invalid_Var, request );
return;
}
if( UpnpStateVarRequest_get_ErrCode(variable) != UPNP_E_SUCCESS ) {
if( UpnpString_get_Length(UpnpStateVarRequest_get_ErrStr(variable)) > 0 ) {
if( variable.ErrCode != UPNP_E_SUCCESS ) {
if( strlen( variable.ErrStr ) > 0 ) {
err_code = SOAP_INVALID_VAR;
err_str = Soap_Invalid_Var;
} else {
err_code = UpnpStateVarRequest_get_ErrCode(variable);
err_str = UpnpStateVarRequest_get_ErrStr_cstr(variable);
err_code = variable.ErrCode;
err_str = variable.ErrStr;
}
send_error_response( info, err_code, err_str, request );
return;
}
// send response
send_var_query_response( info, UpnpStateVarRequest_get_CurrentVal(variable), request );
UpnpStateVarRequest_delete(variable);
send_var_query_response( info, variable.CurrentVal, request );
ixmlFreeDOMString( variable.CurrentVal );
}
/****************************************************************************
@@ -947,16 +948,15 @@ handle_invoke_action( IN SOCKINFO * info,
IN IXML_Document * xml_doc )
{
char save_char;
UpnpActionRequest *action = UpnpActionRequest_new();
UpnpString *devUDN = UpnpString_new();
UpnpString *serviceID = UpnpString_new();
IXML_Document *actionRequestDoc = NULL;
IXML_Document *actionResultDoc = NULL;
IXML_Document *resp_node = NULL;
struct Upnp_Action_Request action;
Upnp_FunPtr soap_event_callback;
void *cookie = NULL;
int err_code;
const char *err_str;
action.ActionResult = NULL;
// null-terminate
save_char = action_name.buf[action_name.length];
action_name.buf[action_name.length] = '\0';
@@ -966,7 +966,7 @@ handle_invoke_action( IN SOCKINFO * info,
err_str = Soap_Invalid_Action;
// get action node
if( get_action_node( xml_doc, action_name.buf, &actionRequestDoc ) == -1 ) {
if( get_action_node( xml_doc, action_name.buf, &resp_node ) == -1 ) {
goto error_handler;
}
// get device info for action event
@@ -975,58 +975,55 @@ handle_invoke_action( IN SOCKINFO * info,
0,
xml_doc,
info->foreign_sockaddr.ss_family,
devUDN,
serviceID,
&soap_event_callback,
action.DevUDN,
action.ServiceID,
&soap_event_callback,
&cookie );
if( err_code != UPNP_E_SUCCESS ) {
goto error_handler;
}
UpnpActionRequest_set_ErrCode(action, UPNP_E_SUCCESS);
UpnpActionRequest_strcpy_ErrStr(action, "");
UpnpActionRequest_strcpy_ActionName(action, action_name.buf);
UpnpActionRequest_set_DevUDN(action, devUDN);
UpnpActionRequest_set_ServiceID(action, serviceID);
UpnpActionRequest_set_ActionRequest(action, actionRequestDoc);
UpnpActionRequest_set_CtrlPtIPAddr(action, (struct sockaddr *)&info->foreign_sockaddr);
namecopy( action.ActionName, action_name.buf );
linecopy( action.ErrStr, "" );
action.ActionRequest = resp_node;
action.ActionResult = NULL;
action.ErrCode = UPNP_E_SUCCESS;
action.CtrlPtIPAddr = info->foreign_sockaddr;
UpnpPrintf(UPNP_INFO, SOAP, __FILE__, __LINE__, "Calling Callback\n");
soap_event_callback(UPNP_CONTROL_ACTION_REQUEST, action, cookie);
soap_event_callback( UPNP_CONTROL_ACTION_REQUEST, &action, cookie );
err_code = UpnpActionRequest_get_ErrCode(action);
if (err_code != UPNP_E_SUCCESS) {
err_str = UpnpActionRequest_get_ErrStr_cstr(action);
if (strlen(err_str) <= 0) {
if( action.ErrCode != UPNP_E_SUCCESS ) {
if( strlen( action.ErrStr ) <= 0 ) {
err_code = SOAP_ACTION_FAILED;
err_str = Soap_Action_Failed;
} else {
err_code = action.ErrCode;
err_str = action.ErrStr;
}
goto error_handler;
}
// validate, and handle action error
actionResultDoc = UpnpActionRequest_get_ActionResult(action);
if (actionResultDoc == NULL) {
if( action.ActionResult == NULL ) {
err_code = SOAP_ACTION_FAILED;
err_str = Soap_Action_Failed;
goto error_handler;
}
// send response
send_action_response(info, actionResultDoc, request);
send_action_response( info, action.ActionResult, request );
err_code = 0;
// error handling and cleanup
error_handler:
ixmlDocument_free( action.ActionResult );
ixmlDocument_free( resp_node );
action_name.buf[action_name.length] = save_char; // restore
if( err_code != 0 ) {
send_error_response( info, err_code, err_str, request );
}
UpnpString_delete(serviceID);
UpnpString_delete(devUDN);
UpnpActionRequest_delete(action);
}
/****************************************************************************

View File

@@ -1,135 +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 SOAPLIB_H
#define SOAPLIB_H
//SOAP module API to be called in Upnp-Dk API
/****************************************************************************
* Function : soap_device_callback
*
* Parameters :
* IN http_parser_t *parser : Parsed request received by the device
* IN http_message_t* request : HTTP request
* INOUT SOCKINFO *info : socket info
*
* Description : This is a callback called by minisever after receiving
* the request from the control point. This function will start
* processing the request. It calls handle_invoke_action to handle the
* SOAP action
*
* Return : void
*
* Note :
****************************************************************************/
void soap_device_callback(
IN http_parser_t *parser,
IN http_message_t* request,
INOUT SOCKINFO *info );
/****************************************************************************
* Function : SoapSendAction
*
* Parameters :
* IN char* action_url : device contrl URL
* IN char *service_type : device service type
* IN IXML_Document *action_node : SOAP action node
* OUT IXML_Document **response_node : SOAP response node
*
* Description : This function is called by UPnP API to send the SOAP
* action request and waits till it gets the response from the device
* pass the response to the API layer
*
* Return : int
* returns UPNP_E_SUCCESS if successful else returns appropriate error
* Note :
****************************************************************************/
int SoapSendAction(
IN char* action_url,
IN char *service_type,
IN IXML_Document *action_node,
OUT IXML_Document **response_node );
/****************************************************************************
* Function : SoapSendActionEx
*
* Parameters :
* IN char* action_url : device contrl URL
* IN char *service_type : device service type
IN IXML_Document *Header: Soap header
* IN IXML_Document *action_node : SOAP action node ( SOAP body)
* OUT IXML_Document **response_node : SOAP response node
*
* Description : This function is called by UPnP API to send the SOAP
* action request and waits till it gets the response from the device
* pass the response to the API layer. This action is similar to the
* the SoapSendAction with only difference that it allows users to
* pass the SOAP header along the SOAP body ( soap action request)
*
* Return : int
* returns UPNP_E_SUCCESS if successful else returns appropriate error
* Note :
****************************************************************************/
int SoapSendActionEx(
IN char * ActionURL,
IN char *ServiceType,
IN IXML_Document *Header,
IN IXML_Document *ActNode ,
OUT IXML_Document **RespNode) ;
/****************************************************************************
* Function : SoapGetServiceVarStatus
*
* Parameters :
* IN char * action_url : Address to send this variable
* query message.
* IN char *var_name : Name of the variable.
* OUT char **var_value : Output value.
*
* Description : This function creates a status variable query message
* send it to the specified URL. It also collect the response.
*
* Return : int
*
* Note :
****************************************************************************/
int SoapGetServiceVarStatus(
IN char * ActionURL,
IN DOMString VarName,
OUT DOMString *StVar) ;
// extern form the HTTP parser.
extern const char* ContentTypeHeader;
#endif //SOAPLIB_H

View File

@@ -1,115 +0,0 @@
#include "config.h"
#include "ssdp_ResultData.h"
#include <stdlib.h> // for calloc(), free()
struct SSSDPResultData
{
UpnpDiscovery *m_param;
void *m_cookie;
Upnp_FunPtr m_ctrlpt_callback;
};
SSDPResultData *SSDPResultData_new()
{
struct SSSDPResultData *p = calloc(1, sizeof (struct SSSDPResultData));
p->m_param = UpnpDiscovery_new();
#if 0
p->m_cookie = NULL;
p->m_ctrlpt_callback = NULL;
#endif
return (SSDPResultData *)p;
}
void SSDPResultData_delete(SSDPResultData *p)
{
struct SSSDPResultData *q = (struct SSSDPResultData *)p;
if (!q) return;
UpnpDiscovery_delete(q->m_param);
q->m_param = NULL;
q->m_cookie = NULL;
q->m_ctrlpt_callback = NULL;
free(p);
}
SSDPResultData *SSDPResultData_dup(const SSDPResultData *p)
{
SSDPResultData *q = SSDPResultData_new();
SSDPResultData_assign(q, p);
return q;
}
void SSDPResultData_assign(SSDPResultData *q, const SSDPResultData *p)
{
if (q != p) {
SSDPResultData_set_Param(q, SSDPResultData_get_Param(p));
SSDPResultData_set_Cookie(q, SSDPResultData_get_Cookie(p));
SSDPResultData_set_CtrlptCallback(q, SSDPResultData_get_CtrlptCallback(p));
}
}
UpnpDiscovery *SSDPResultData_get_Param(const SSDPResultData *p)
{
return ((struct SSSDPResultData *)p)->m_param;
}
void SSDPResultData_set_Param(SSDPResultData *p, const UpnpDiscovery *d)
{
UpnpDiscovery_assign(((struct SSSDPResultData *)p)->m_param, d);
}
void *SSDPResultData_get_Cookie(const SSDPResultData *p)
{
return ((struct SSSDPResultData *)p)->m_cookie;
}
void SSDPResultData_set_Cookie(SSDPResultData *p, void *c)
{
((struct SSSDPResultData *)p)->m_cookie = c;
}
Upnp_FunPtr SSDPResultData_get_CtrlptCallback(const SSDPResultData *p)
{
return ((struct SSSDPResultData *)p)->m_ctrlpt_callback;
}
void SSDPResultData_set_CtrlptCallback(SSDPResultData *p, Upnp_FunPtr f)
{
((struct SSSDPResultData *)p)->m_ctrlpt_callback = f;
}
void SSDPResultData_Callback(const SSDPResultData *p)
{
struct SSSDPResultData *q = (struct SSSDPResultData *)p;
q->m_ctrlpt_callback(
UPNP_DISCOVERY_SEARCH_RESULT,
q->m_param,
q->m_cookie);
}

View File

@@ -1,43 +0,0 @@
#ifndef SSDP_RESULTDATA_H
#define SSDP_RESULTDATA_H
/** Structure to contain Discovery response */
typedef struct s_SSDPResultData SSDPResultData;
#include "Discovery.h" /* for UpnpDiscovery */
#include "upnp.h" /* for Upnp_FunPtr */
/** Constructor */
SSDPResultData *SSDPResultData_new();
/** Destructor */
void SSDPResultData_delete(SSDPResultData *p);
/** Copy Constructor */
SSDPResultData *SSDPResultData_dup(const SSDPResultData *p);
/** Assignment operator */
void SSDPResultData_assign(SSDPResultData *q, const SSDPResultData *p);
/** */
UpnpDiscovery *SSDPResultData_get_Param(const SSDPResultData *p);
void SSDPResultData_set_Param(SSDPResultData *p, const UpnpDiscovery *d);
/** */
void *SSDPResultData_get_Cookie(const SSDPResultData *p);
void SSDPResultData_set_Cookie(SSDPResultData *p, void *c);
/** */
Upnp_FunPtr SSDPResultData_get_CtrlptCallback(const SSDPResultData *p);
void SSDPResultData_set_CtrlptCallback(SSDPResultData *p, Upnp_FunPtr f);
/** */
void SSDPResultData_Callback(const SSDPResultData *p);
#endif /* SSDP_RESULTDATA_H */

View File

@@ -42,7 +42,7 @@
#include "httpparser.h"
#include "httpreadwrite.h"
#include "ssdp_ResultData.h"
/*#include "ssdp_ResultData.h"*/
#include "ssdplib.h"
#include "statcodes.h"
#include "unixutil.h"
@@ -74,10 +74,11 @@
***************************************************************************/
void send_search_result(IN void *data)
{
SSDPResultData *temp = (SSDPResultData *)data;
ResultData *temp = ( ResultData * ) data;
SSDPResultData_Callback(temp);
SSDPResultData_delete(temp);
temp->ctrlpt_callback( UPNP_DISCOVERY_SEARCH_RESULT,
&temp->param, temp->cookie );
free( temp );
}
/************************************************************************
@@ -114,9 +115,7 @@ void ssdp_handle_ctrlpt_msg(
struct Handle_Info *ctrlpt_info = NULL;
memptr hdr_value;
xboolean is_byebye; // byebye or alive
UpnpDiscovery *param = UpnpDiscovery_new();
int expires;
int ret;
struct Upnp_Discovery param;
SsdpEvent event;
xboolean nt_found;
xboolean usn_found;
@@ -128,7 +127,7 @@ void ssdp_handle_ctrlpt_msg(
ListNode *node = NULL;
SsdpSearchArg *searchArg = NULL;
int matched = 0;
SSDPResultData *threadData = NULL;
ResultData *threadData;
ThreadPoolJob job;
// we are assuming that there can be only one client supported at a time
@@ -137,7 +136,7 @@ void ssdp_handle_ctrlpt_msg(
if ( GetClientHandleInfo( &handle, &ctrlpt_info ) != HND_CLIENT ) {
HandleUnlock();
goto end_ssdp_handle_ctrlpt_msg;
return;
}
// copy
ctrlpt_callback = ctrlpt_info->Callback;
@@ -147,45 +146,51 @@ void ssdp_handle_ctrlpt_msg(
// search timeout
if ( timeout ) {
ctrlpt_callback( UPNP_DISCOVERY_SEARCH_TIMEOUT, NULL, cookie );
goto end_ssdp_handle_ctrlpt_msg;
return;
}
UpnpDiscovery_set_ErrCode(param, UPNP_E_SUCCESS);
param.ErrCode = UPNP_E_SUCCESS;
// MAX-AGE
// assume error
expires = -1;
UpnpDiscovery_set_Expires(param, expires);
if ( httpmsg_find_hdr( hmsg, HDR_CACHE_CONTROL, &hdr_value ) != NULL ) {
ret = matchstr( hdr_value.buf, hdr_value.length, "%imax-age = %d%0", &expires );
UpnpDiscovery_set_Expires(param, expires);
if( ret != PARSE_OK ) {
goto end_ssdp_handle_ctrlpt_msg;
}
param.Expires = -1; // assume error
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;
}
// DATE
if ( httpmsg_find_hdr( hmsg, HDR_DATE, &hdr_value ) != NULL ) {
UpnpDiscovery_strcpy_Date(param, hdr_value.buf);
param.Date[0] = '\0';
if( httpmsg_find_hdr( hmsg, HDR_DATE, &hdr_value ) != NULL ) {
linecopylen( param.Date, hdr_value.buf, hdr_value.length );
}
// dest addr
UpnpDiscovery_set_DestAddr(param, dest_addr);
memcpy(&param.DestAddr, dest_addr, sizeof(struct sockaddr_in) );
// EXT
if ( httpmsg_find_hdr( hmsg, HDR_EXT, &hdr_value ) != NULL ) {
UpnpDiscovery_strncpy_Ext(param, hdr_value.buf, hdr_value.length);
param.Ext[0] = '\0';
if( httpmsg_find_hdr( hmsg, HDR_EXT, &hdr_value ) != NULL ) {
linecopylen( param.Ext, hdr_value.buf, hdr_value.length );
}
// LOCATION
if ( httpmsg_find_hdr( hmsg, HDR_LOCATION, &hdr_value ) != NULL ) {
UpnpDiscovery_strncpy_Location(param, hdr_value.buf, hdr_value.length);
param.Location[0] = '\0';
if( httpmsg_find_hdr( hmsg, HDR_LOCATION, &hdr_value ) != NULL ) {
linecopylen( param.Location, hdr_value.buf, hdr_value.length );
}
// SERVER / USER-AGENT
if ( httpmsg_find_hdr( hmsg, HDR_SERVER, &hdr_value ) != NULL ||
param.Os[0] = '\0';
if( httpmsg_find_hdr( hmsg, HDR_SERVER, &hdr_value ) != NULL ||
httpmsg_find_hdr( hmsg, HDR_USER_AGENT, &hdr_value ) != NULL ) {
UpnpDiscovery_strncpy_Os(param, hdr_value.buf, hdr_value.length);
linecopylen( param.Os, hdr_value.buf, hdr_value.length );
}
// clear everything
param.DeviceId[0] = '\0';
param.DeviceType[0] = '\0';
param.ServiceType[0] = '\0';
param.ServiceVer[0] = '\0'; // not used; version is in ServiceType
event.UDN[0] = '\0';
event.DeviceType[0] = '\0';
event.ServiceType[0] = '\0';
@@ -208,32 +213,29 @@ void ssdp_handle_ctrlpt_msg(
}
if ( nt_found || usn_found ) {
UpnpDiscovery_strcpy_DeviceID( param, event.UDN);
UpnpDiscovery_strcpy_DeviceType( param, event.DeviceType);
UpnpDiscovery_strcpy_ServiceType(param, event.ServiceType);
strcpy( param.DeviceId, event.UDN );
strcpy( param.DeviceType, event.DeviceType );
strcpy( param.ServiceType, event.ServiceType );
}
// ADVERT. OR BYEBYE
if( hmsg->is_request ) {
// use NTS hdr to determine advert., or byebye
if ( httpmsg_find_hdr( hmsg, HDR_NTS, &hdr_value ) == NULL ) {
// error; NTS header not found
goto end_ssdp_handle_ctrlpt_msg;
return; // error; NTS header not found
}
if ( memptr_cmp( &hdr_value, "ssdp:alive" ) == 0 ) {
is_byebye = FALSE;
} else if( memptr_cmp( &hdr_value, "ssdp:byebye" ) == 0 ) {
is_byebye = TRUE;
} else {
// bad value
goto end_ssdp_handle_ctrlpt_msg;
return; // bad value
}
if ( is_byebye ) {
// check device byebye
if( !nt_found || !usn_found ) {
// bad byebye
goto end_ssdp_handle_ctrlpt_msg;
return; // bad byebye
}
event_type = UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE;
} else {
@@ -242,19 +244,17 @@ void ssdp_handle_ctrlpt_msg(
// only. Expires should be greater than 1800 (30 mins)
if( !nt_found ||
!usn_found ||
UpnpString_get_Length(UpnpDiscovery_get_Location(param)) == 0 ||
UpnpDiscovery_get_Expires(param) <= 0 ) {
// bad advertisement
goto end_ssdp_handle_ctrlpt_msg;
strlen( param.Location ) == 0 || param.Expires <= 0 ) {
return; // bad advertisement
}
event_type = UPNP_DISCOVERY_ADVERTISEMENT_ALIVE;
}
// call callback
ctrlpt_callback( event_type, param, ctrlpt_cookie );
} else {
// reply (to a SEARCH)
//
ctrlpt_callback( event_type, &param, ctrlpt_cookie );
} else // reply (to a SEARCH)
{
// only checking to see if there is a valid ST header
st_found = FALSE;
if( httpmsg_find_hdr( hmsg, HDR_ST, &hdr_value ) != NULL ) {
@@ -264,18 +264,15 @@ void ssdp_handle_ctrlpt_msg(
hdr_value.buf[hdr_value.length] = save_char;
}
if( hmsg->status_code != HTTP_OK ||
UpnpDiscovery_get_Expires(param) <= 0 ||
UpnpString_get_Length(UpnpDiscovery_get_Location(param)) == 0 ||
!usn_found ||
!st_found ) {
// bad reply
goto end_ssdp_handle_ctrlpt_msg;
param.Expires <= 0 ||
strlen( param.Location ) == 0 || !usn_found || !st_found ) {
return; // bad reply
}
// check each current search
HandleLock();
if( GetClientHandleInfo( &handle, &ctrlpt_info ) != HND_CLIENT ) {
HandleUnlock();
goto end_ssdp_handle_ctrlpt_msg;
return;
}
node = ListHead( &ctrlpt_info->SsdpSearchList );
@@ -321,14 +318,16 @@ void ssdp_handle_ctrlpt_msg(
if (matched) {
// schedule call back
threadData = SSDPResultData_new();
threadData =
( ResultData * ) malloc( sizeof( ResultData ) );
if (threadData != NULL) {
SSDPResultData_set_Param(threadData, param);
SSDPResultData_set_Cookie(threadData, searchArg->cookie);
SSDPResultData_set_CtrlptCallback(threadData, ctrlpt_callback);
TPJobInit(&job, (start_routine)send_search_result, threadData);
threadData->param = param;
threadData->cookie = searchArg->cookie;
threadData->ctrlpt_callback = ctrlpt_callback;
TPJobInit( &job, ( start_routine ) send_search_result,
threadData );
TPJobSetPriority(&job, MED_PRIORITY);
TPJobSetFreeFunction(&job, (free_routine)SSDPResultData_delete);
TPJobSetFreeFunction( &job, ( free_routine ) free );
ThreadPoolAdd(&gRecvThreadPool, &job, NULL);
}
}
@@ -336,10 +335,8 @@ void ssdp_handle_ctrlpt_msg(
}
HandleUnlock();
//ctrlpt_callback( UPNP_DISCOVERY_SEARCH_RESULT, param, cookie );
//ctrlpt_callback( UPNP_DISCOVERY_SEARCH_RESULT, &param, cookie );
}
end_ssdp_handle_ctrlpt_msg:
UpnpDiscovery_delete(param);
}
@@ -513,7 +510,6 @@ int SearchByTarget(
IN void *Cookie)
{
char errorBuffer[ERROR_BUFFER_LEN];
int socklen = sizeof( struct sockaddr_storage );
int *id = NULL;
int ret = 0;
char ReqBufv4[BUFSIZE];
@@ -598,12 +594,14 @@ int SearchByTarget(
FD_SET(gSsdpReqSocket4, &wrSet);
max_fd = max(max_fd, gSsdpReqSocket4);
}
#ifdef UPNP_ENABLE_IPV6
if (gSsdpReqSocket6 != INVALID_SOCKET) {
setsockopt(gSsdpReqSocket6, IPPROTO_IPV6, IPV6_MULTICAST_IF,
(char *)&gIF_INDEX, sizeof (gIF_INDEX));
FD_SET(gSsdpReqSocket6, &wrSet);
max_fd = max(max_fd, gSsdpReqSocket6);
}
#endif
ret = select(max_fd + 1, NULL, &wrSet, NULL, NULL);
if (ret == -1) {
@@ -613,11 +611,13 @@ int SearchByTarget(
errorBuffer);
shutdown(gSsdpReqSocket4, SD_BOTH);
UpnpCloseSocket(gSsdpReqSocket4);
#ifdef UPNP_ENABLE_IPV6
shutdown(gSsdpReqSocket6, SD_BOTH);
UpnpCloseSocket(gSsdpReqSocket6);
#endif
return UPNP_E_INTERNAL_ERROR;
}
#ifdef UPNP_ENABLE_IPV6
if (gSsdpReqSocket6 != INVALID_SOCKET &&
FD_ISSET(gSsdpReqSocket6, &wrSet)) {
int NumCopy = 0;
@@ -625,28 +625,38 @@ int SearchByTarget(
while (NumCopy < NUM_SSDP_COPY) {
sendto(gSsdpReqSocket6,
ReqBufv6UlaGua, strlen(ReqBufv6UlaGua), 0,
(struct sockaddr *)&__ss_v6, socklen);
(struct sockaddr *)&__ss_v6,
sizeof(struct sockaddr_in));
NumCopy++;
imillisleep(SSDP_PAUSE);
}
NumCopy = 0;
inet_pton(AF_INET6, SSDP_IPV6_LINKLOCAL, &destAddr6->sin6_addr);
while (NumCopy < NUM_SSDP_COPY) {
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
">>> SSDP SEND M-SEARCH >>>\n%s\n",
ReqBufv6);
sendto(gSsdpReqSocket6,
ReqBufv6, strlen(ReqBufv6), 0,
(struct sockaddr *)&__ss_v6, socklen);
ReqBufv6, strlen(ReqBufv6), 0,
(struct sockaddr *)&__ss_v6,
sizeof(struct sockaddr_in6));
NumCopy++;
imillisleep(SSDP_PAUSE);
}
}
#endif //IPv6
if (gSsdpReqSocket4 != INVALID_SOCKET &&
FD_ISSET(gSsdpReqSocket4, &wrSet)) {
int NumCopy = 0;
while (NumCopy < NUM_SSDP_COPY) {
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
">>> SSDP SEND M-SEARCH >>>\n%s\n",
ReqBufv4);
sendto(gSsdpReqSocket4,
ReqBufv4, strlen(ReqBufv4), 0,
(struct sockaddr *)&__ss_v4, socklen);
(struct sockaddr *)&__ss_v4,
sizeof(struct sockaddr_in));
NumCopy++;
imillisleep(SSDP_PAUSE);
}

View File

@@ -229,6 +229,7 @@ NewRequestHandler( IN struct sockaddr *DestAddr,
int ttl = 4; // a/c to UPNP Spec
int hops = 1;
char buf_ntop[64];
int ret = UPNP_E_SUCCESS;
ReplySock = socket( DestAddr->sa_family, SOCK_DGRAM, 0 );
if ( ReplySock == -1 ) {
@@ -247,6 +248,7 @@ NewRequestHandler( IN struct sockaddr *DestAddr,
(char *)&replyAddr, sizeof (replyAddr) );
setsockopt( ReplySock, IPPROTO_IP, IP_MULTICAST_TTL,
(char *)&ttl, sizeof (int) );
socklen = sizeof(struct sockaddr_in);
} else if( DestAddr->sa_family == AF_INET6 ) {
inet_ntop(AF_INET6, &((struct sockaddr_in6*)DestAddr)->sin6_addr,
buf_ntop, sizeof(buf_ntop));
@@ -257,6 +259,8 @@ NewRequestHandler( IN struct sockaddr *DestAddr,
} else {
UpnpPrintf( UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
"Invalid destination address specified." );
ret = UPNP_E_NETWORK_ERROR;
goto end_NewRequestHandler;
}
for( Index = 0; Index < NumPacket; Index++ ) {
@@ -280,15 +284,27 @@ NewRequestHandler( IN struct sockaddr *DestAddr,
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;
}
}
end_NewRequestHandler:
shutdown( ReplySock, SD_BOTH );
UpnpCloseSocket( ReplySock );
return UPNP_E_SUCCESS;
return ret;
}
/**
@@ -405,6 +421,7 @@ void CreateServicePacket(
}
} else if (msg_type == MSGTYPE_ADVERTISEMENT ||
msg_type == MSGTYPE_SHUTDOWN) {
char *host = NULL;
if (msg_type == MSGTYPE_ADVERTISEMENT) {
nts = "ssdp:alive";
} else {
@@ -413,7 +430,6 @@ void CreateServicePacket(
}
/* NOTE: The CACHE-CONTROL and LOCATION headers are not present in
* a shutdown msg, but are present here for MS WinMe interop. */
char *host = NULL;
if (AddressFamily == AF_INET) {
host = SSDP_IP;
} else {

View File

@@ -50,26 +50,36 @@
#define MAX_TIME_TOREAD 45
CLIENTONLY( SOCKET gSsdpReqSocket4 = INVALID_SOCKET; )
CLIENTONLY( SOCKET gSsdpReqSocket6 = INVALID_SOCKET; )
#ifdef INCLUDE_CLIENT_APIS
SOCKET gSsdpReqSocket4 = INVALID_SOCKET;
#ifdef UPNP_ENABLE_IPV6
SOCKET gSsdpReqSocket6 = INVALID_SOCKET;
#endif /* UPNP_ENABLE_IPV6 */
#endif /* INCLUDE_CLIENT_APIS */
void RequestHandler();
int create_ssdp_sock_v4( SOCKET* ssdpSock );
#ifdef UPNP_ENABLE_IPV6
int create_ssdp_sock_v6( SOCKET* ssdpSock );
int create_ssdp_sock_v6_ula_gua( SOCKET* ssdpSock );
#endif
#if INCLUDE_CLIENT_APIS
int create_ssdp_sock_reqv4( SOCKET* ssdpReqSock );
#ifdef UPNP_ENABLE_IPV6
int create_ssdp_sock_reqv6( SOCKET* ssdpReqSock );
#endif
#endif
Event ErrotEvt;
enum Listener { Idle, Stopping, Running };
struct SSDPSockArray {
// socket for incoming advertisments and search requests
/* socket for incoming advertisments and search requests */
SOCKET ssdpSock;
// socket for sending search requests and receiving search replies
CLIENTONLY( int ssdpReqSock; )
#ifdef INCLUDE_CLIENT_APIS
/* socket for sending search requests and receiving search replies */
int ssdpReqSock;
#endif /* INCLUDE_CLIENT_APIS */
};
#ifdef INCLUDE_DEVICE_APIS
@@ -258,7 +268,7 @@ int AdvertiseAndReply(
}
}
case SSDP_DEVICETYPE: {
if (!strncasecmp(DeviceType, devType, strlen(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 */
@@ -301,6 +311,7 @@ int AdvertiseAndReply(
}
ixmlNodeList_free(nodeList);
if (!tmpNode) {
nodeList = NULL;
continue;
}
nodeList = ixmlElement_getElementsByTagName(
@@ -732,26 +743,26 @@ 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;
ssdp_thread_data *data = (ssdp_thread_data *)the_data;
http_message_t *hmsg = &data->parser.msg;
if( start_event_handler( the_data ) != 0 ) {
return;
}
// send msg to device or ctrlpt
if( ( hmsg->method == HTTPMETHOD_NOTIFY ) ||
( hmsg->request_method == HTTPMETHOD_MSEARCH ) ) {
CLIENTONLY( ssdp_handle_ctrlpt_msg( hmsg,
(struct sockaddr*)&data->dest_addr, FALSE, NULL );)
} else {
ssdp_handle_device_request( hmsg, (struct sockaddr*)&data->dest_addr );
}
if (start_event_handler(the_data) != 0) {
return;
}
/* send msg to device or ctrlpt */
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);
#endif /* INCLUDE_CLIENT_APIS */
} else {
ssdp_handle_device_request(hmsg, (struct sockaddr*)&data->dest_addr);
}
// free data
free_ssdp_event_handler_data( data );
/* free data */
free_ssdp_event_handler_data(data);
}
/************************************************************************
@@ -791,11 +802,20 @@ readFromSSDPSocket( SOCKET socket )
//initialize parser
#ifdef INCLUDE_CLIENT_APIS
#ifdef UPNP_ENABLE_IPV6
if( socket == gSsdpReqSocket4 || socket == gSsdpReqSocket6 ) {
parser_response_init( &data->parser, HTTPMETHOD_MSEARCH );
} else {
parser_request_init( &data->parser );
}
#else
if( socket == gSsdpReqSocket4 ) {
parser_response_init( &data->parser, HTTPMETHOD_MSEARCH );
} else {
parser_request_init( &data->parser );
}
#endif
#else
parser_request_init( &data->parser );
#endif
@@ -820,8 +840,10 @@ readFromSSDPSocket( SOCKET socket )
if( __ss.ss_family == AF_INET )
inet_ntop( AF_INET, &((struct sockaddr_in*)&__ss)->sin_addr, ntop_buf, sizeof(ntop_buf) );
#ifdef UPNP_ENABLE_IPV6
else if( __ss.ss_family == AF_INET6 )
inet_ntop( AF_INET6, &((struct sockaddr_in6*)&__ss)->sin6_addr, ntop_buf, sizeof(ntop_buf) );
#endif
else
strncpy( ntop_buf, "<Invalid address family>", sizeof(ntop_buf) );
@@ -876,6 +898,9 @@ int get_ssdp_sockets(MiniServerSockArray *out)
{
int retVal;
out->ssdpReqSock4 = INVALID_SOCKET;
out->ssdpReqSock6 = INVALID_SOCKET;
#if INCLUDE_CLIENT_APIS
/* Create the IPv4 socket for SSDP REQUESTS */
if(strlen(gIF_IPV4) > 0) {
@@ -890,6 +915,7 @@ int get_ssdp_sockets(MiniServerSockArray *out)
}
/* Create the IPv6 socket for SSDP REQUESTS */
#ifdef UPNP_ENABLE_IPV6
if (strlen(gIF_IPV6) > 0) {
retVal = create_ssdp_sock_reqv6(&out->ssdpReqSock6);
if (retVal != UPNP_E_SUCCESS) {
@@ -902,6 +928,9 @@ int get_ssdp_sockets(MiniServerSockArray *out)
} else {
out->ssdpReqSock6 = INVALID_SOCKET;
}
#endif //IPv6
#endif /* INCLUDE_CLIENT_APIS */
/* Create the IPv4 socket for SSDP */
@@ -921,6 +950,7 @@ int get_ssdp_sockets(MiniServerSockArray *out)
}
/* Create the IPv6 socket for SSDP */
#ifdef UPNP_ENABLE_IPV6
if (strlen(gIF_IPV6) > 0) {
retVal = create_ssdp_sock_v6(&out->ssdpSock6);
if (retVal != UPNP_E_SUCCESS) {
@@ -956,6 +986,8 @@ int get_ssdp_sockets(MiniServerSockArray *out)
} else {
out->ssdpSock6UlaGua = INVALID_SOCKET;
}
#endif //IPv6
return UPNP_E_SUCCESS;
}
@@ -1011,6 +1043,7 @@ int create_ssdp_sock_reqv4( SOCKET* ssdpReqSock )
* Returns: void
*
***************************************************************************/
#ifdef UPNP_ENABLE_IPV6
int create_ssdp_sock_reqv6( SOCKET* ssdpReqSock )
{
char errorBuffer[ERROR_BUFFER_LEN];
@@ -1035,6 +1068,8 @@ int create_ssdp_sock_reqv6( SOCKET* ssdpReqSock )
return UPNP_E_SUCCESS;
}
#endif // IPv6
#endif /* INCLUDE_CLIENT_APIS */
@@ -1178,6 +1213,7 @@ int create_ssdp_sock_v4( SOCKET* ssdpSock )
* Returns: void
*
***************************************************************************/
#ifdef UPNP_ENABLE_IPV6
int create_ssdp_sock_v6( SOCKET* ssdpSock )
{
char errorBuffer[ERROR_BUFFER_LEN];
@@ -1274,7 +1310,7 @@ int create_ssdp_sock_v6( SOCKET* ssdpSock )
return UPNP_E_SUCCESS;
}
#endif // IPv6
/************************************************************************
* Function : create_ssdp_sock_v6_ula_gua
@@ -1288,6 +1324,7 @@ int create_ssdp_sock_v6( SOCKET* ssdpSock )
* Returns: void
*
***************************************************************************/
#ifdef UPNP_ENABLE_IPV6
int create_ssdp_sock_v6_ula_gua(SOCKET *ssdpSock)
{
char errorBuffer[ERROR_BUFFER_LEN];
@@ -1385,7 +1422,7 @@ int create_ssdp_sock_v6_ula_gua(SOCKET *ssdpSock)
return UPNP_E_SUCCESS;
}
#endif //IPv6
#endif /* EXCLUDE_SSDP */