Compare commits

..

269 Commits

Author SHA1 Message Date
Marcelo Roberto Jimenez
a15e0c99d7 * upnp/src/api/Discovery.c: Fix a serious bug and memory leak in
UpnpDiscovery_strcpy_DeviceType(). Thanks to David Blanchet for the
patch.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@584 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-22 11:32:09 +00:00
Marcelo Roberto Jimenez
93a3016df1 Forward port of svn rev. 581: White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@583 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-22 02:13:34 +00:00
Marcelo Roberto Jimenez
36d6a34f5d Forward port of svn rev. 580:
The last part of Ronan Menard's patch.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@582 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-22 02:11:44 +00:00
Marcelo Roberto Jimenez
9763158d69 Forward port of svn rev. 578:
* 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/trunk@579 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-22 01:44:25 +00:00
Marcelo Roberto Jimenez
2963919081 Forward port of svn rev. 576:
* upnp/src/genlib/miniserver/miniserver.c: Fix for IPV6 ULA/GUA issues.

Patch submitted by Ronan Menard.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@577 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-21 22:16:24 +00:00
Marcelo Roberto Jimenez
9f7936781e Forward port of svn rev. 574:
* gena_subscribe(): Fix for IPV6 ULA/GUA issues.

Patch submitted by Ronan Menard.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@575 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-21 21:57:40 +00:00
Marcelo Roberto Jimenez
bc724a8073 Forward port of svn rev. 572:
* SOCKET ssdpSock6UlaGua: created variable for later use.

Patch submitted by Ronan Menard.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@573 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-21 21:43:54 +00:00
Marcelo Roberto Jimenez
7ff1d56906 Forward port of svn rev. 569:
* SSDP_IPV6_SITELOCAL: new macro.

Patch submitted by Ronan Menard.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@571 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-21 21:36:22 +00:00
Marcelo Roberto Jimenez
2150bdc5b6 Forward port of svn rev. 568:
The scope of the macro NUM_HANDLE is now restricted to upnpapi.c.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@570 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-21 21:34:17 +00:00
Marcelo Roberto Jimenez
5bb3621626 Forward port of svn rev. 566:
* 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/trunk@567 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-21 21:15:39 +00:00
Marcelo Roberto Jimenez
b895fce678 Forward port of svn rev. 564:
* 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/trunk@565 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-21 20:51:29 +00:00
Marcelo Roberto Jimenez
bc551a1ab3 Forward port of svn rev. 562: English mispelling.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@563 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-19 13:56:00 +00:00
Marcelo Roberto Jimenez
a13d09176f Forward port of svn rev. 560: libUPnP does support IPV6 now.
Patch submitted by Ronan Menard.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@561 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-19 13:50:21 +00:00
Marcelo Roberto Jimenez
03c858af51 Backport of svn rev. 558: 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/trunk@559 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-19 13:39:44 +00:00
Marcelo Roberto Jimenez
b2e38b2fca 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/trunk@556 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-06-28 20:36:30 +00:00
Marcelo Roberto Jimenez
fab22807c0 Remove excessive 'dnl's from libupnp.m4.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@554 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-06-26 11:09:06 +00:00
Marcelo Roberto Jimenez
338b22b754 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/trunk@552 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-06-17 17:02:03 +00:00
Nick Leverton
11524cc218 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/trunk@550 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-05-14 13:09:22 +00:00
Marcelo Roberto Jimenez
54727b2a9e Forward port of svn revision 548:
[svn] 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/trunk@549 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-05-07 11:20:00 +00:00
Marcelo Roberto Jimenez
71ec18a3a9 Remove ifdef's code from upnp.h.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@547 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-05-01 02:25:06 +00:00
Marcelo Roberto Jimenez
99758f2dff Changelog update.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@545 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-25 14:57:48 +00:00
Marcelo Roberto Jimenez
3772ad4595 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/trunk@544 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-25 14:51:57 +00:00
Marcelo Roberto Jimenez
d33ad5c03e Separation of the ClientSubscription object.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@543 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-25 13:57:25 +00:00
Marcelo Roberto Jimenez
ad9bcc9100 Comment.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@542 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-25 12:07:36 +00:00
Marcelo Roberto Jimenez
da5cf568e6 Recasting away constness.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@540 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-25 11:42:32 +00:00
Marcelo Roberto Jimenez
7f1be91e76 Mostly whitespaces and code convergence.
client_table has been totaly rewritten, so remove the old license.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@536 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-25 00:29:52 +00:00
Marcelo Roberto Jimenez
01039a1d9a Protect the object destructors agains null pointers on deletion, which
should be something valid. Missed this one.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@535 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-25 00:25:41 +00:00
Marcelo Roberto Jimenez
472cc5a993 Protect the object destructors agains null pointers on deletion, which
should be something valid.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@534 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-25 00:18:43 +00:00
Marcelo Roberto Jimenez
a627df4d10 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



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@532 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-16 13:38:06 +00:00
Marcelo Roberto Jimenez
8f852b1ee9 Code base convergence.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@531 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-01 20:36:35 +00:00
Marcelo Roberto Jimenez
59ec1fd641 White spaces and code reorganization.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@528 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-31 17:47:55 +00:00
Marcelo Roberto Jimenez
3fb182aa95 * 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/trunk@527 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-27 19:46:16 +00:00
Marcelo Roberto Jimenez
9c440e2cbf Forward port of svn revision 525:
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/trunk@526 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-27 14:55:57 +00:00
Marcelo Roberto Jimenez
c434f275ef White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@522 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-22 09:07:44 +00:00
Marcelo Roberto Jimenez
35392132af Forward port of svn revision 520:
* 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/trunk@521 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 23:10:44 +00:00
Marcelo Roberto Jimenez
5eccaf4b64 Forward port of svn revision 518:
* 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/trunk@519 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 21:32:44 +00:00
Marcelo Roberto Jimenez
c6558b04d5 Thanks update.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@516 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 19:52:22 +00:00
Marcelo Roberto Jimenez
bf169e434c 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/trunk@514 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 19:47:19 +00:00
Marcelo Roberto Jimenez
b26fe55772 Style compatibilization between two similar constructions addressed in two
separate recent patches.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@512 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 17:06:35 +00:00
Marcelo Roberto Jimenez
1e6c3331ed 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/trunk@510 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 16:13:16 +00:00
Marcelo Roberto Jimenez
c7806de98c Changelog update.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@508 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 15:42:29 +00:00
Marcelo Roberto Jimenez
c56ab5613e Cosmetic change to uri.c
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@507 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 15:12:28 +00:00
Marcelo Roberto Jimenez
f6a30b842c Forward port of svn revision 505:
SF Patch Tracker [ 2836704 ] Patch for Solaris10 compilation and usage.
	Submitted By: zephyrus ( zephyrus00jp )



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@506 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 11:50:26 +00:00
Marcelo Roberto Jimenez
cbbbb14e21 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/trunk@504 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-20 22:09:23 +00:00
Marcelo Roberto Jimenez
0c578f7962 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.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@503 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-20 21:35:04 +00:00
Marcelo Roberto Jimenez
500eb1df8f Changelog date fix.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@501 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-20 21:30:29 +00:00
Marcelo Roberto Jimenez
8eac74ee50 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.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@500 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-20 21:27:51 +00:00
Marcelo Roberto Jimenez
b80e888ae2 Fix for the ithread_mutex_unlock() logic in UpnpInit().
Thanks for Nicholas Kraft.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@499 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-17 01:00:47 +00:00
Marcelo Roberto Jimenez
82a3114379 * SF Patch Tracker [ 2203721 ] timeb.h check obsolete
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@497 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-15 23:50:18 +00:00
Marcelo Roberto Jimenez
218d4bf5dd * 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/trunk@495 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-15 23:38:33 +00:00
Marcelo Roberto Jimenez
6b0272d66b 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/trunk@493 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-15 15:33:40 +00:00
Marcelo Roberto Jimenez
aca89457ae 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.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@492 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-15 03:30:11 +00:00
Marcelo Roberto Jimenez
b77fead68a SF Patch Tracker [ 2964685 ] patch for avoiding inet_ntoa (1.8.0)
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.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@491 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-15 03:19:08 +00:00
Marcelo Roberto Jimenez
da3ce95628 Fix for const warning.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@490 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-15 03:07:34 +00:00
Marcelo Roberto Jimenez
44cb915b1b 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().



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@489 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-15 03:05:16 +00:00
Marcelo Roberto Jimenez
bb55b1ed9c * 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.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@488 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-15 01:48:24 +00:00
Marcelo Roberto Jimenez
5c61b05ee9 Changelog update.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@485 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-14 18:28:48 +00:00
Marcelo Roberto Jimenez
285f6a2a72 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/trunk@484 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-14 17:39:30 +00:00
Kim Kyung-San
cd01b538a9 test commit on window, i didn't change at all.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@483 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2009-03-13 08:47:46 +00:00
Oxy
34b5a5ce90 wrong order in parameters corrected
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@482 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2009-03-06 09:38:24 +00:00
Marcelo Roberto Jimenez
78f5e5004f Fix for application compiler warning: "PRId64" redefined.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@479 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-08-14 12:00:01 +00:00
Marcelo Roberto Jimenez
54ab392bbd Comment using UTF-8.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@474 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-27 03:04:40 +00:00
Marcelo Roberto Jimenez
13a771367d Removing unused file src/inc/http_client.h.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@473 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-27 02:33:39 +00:00
Marcelo Roberto Jimenez
7847d15171 Removing header of unused and no longer function parse_port().
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@472 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-27 02:33:01 +00:00
Marcelo Roberto Jimenez
8ab8265fd2 Added upnp/m4/libupnp.m4 to the distribution tarball.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@468 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-25 03:52:31 +00:00
Marcelo Roberto Jimenez
443cc8ea37 Changelog update of backported patch.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@467 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-25 03:43:23 +00:00
Marcelo Roberto Jimenez
cd6d5822fb Fixed a missing HandleUnlock() in upnp/src/gena/gena_device.c plus several
white space changes.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@464 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-25 03:27:42 +00:00
Marcelo Roberto Jimenez
c9484d4f20 Changelog fix for backported patch in svn 453.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@459 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-24 11:38:59 +00:00
Marcelo Roberto Jimenez
8180a54f41 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/trunk@457 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-24 11:29:47 +00:00
Marcelo Roberto Jimenez
1548c9044d Update of the build/inc/*.h files. They have not been updated since 1.4.7.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@456 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-23 18:43:02 +00:00
Marcelo Roberto Jimenez
943483e8b7 UpnpInet.h is now the only place where winsock2.h and Ws2tcpip.h are included.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@455 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-21 22:42:54 +00:00
Marcelo Roberto Jimenez
d991fbe26c ifdef is more clear than ifndef here.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@454 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-17 21:31:42 +00:00
Marcelo Roberto Jimenez
6baedbab55 The same as the last patch, now for vc8.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@453 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-17 20:19:41 +00:00
Marcelo Roberto Jimenez
7d1e026c0c Andre Sodermans (wienerschnitzel) patch for building libupnp under
windows systems with VC9. This one fixes a missing include.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@452 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-17 20:08:57 +00:00
Marcelo Roberto Jimenez
f00392e678 Duplicated definition of ixmlAttr_free(). MSVC compiler is complaining.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@451 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-16 22:22:56 +00:00
Marcelo Roberto Jimenez
654363468a Debug code for http_RecvMessage().
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@448 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-10 03:55:07 +00:00
Marcelo Roberto Jimenez
b0f782f9c2 Update of libupnp.m4.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@447 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-07 01:07:46 +00:00
Marcelo Roberto Jimenez
cb6dfa2824 Small fixes for libupnp.m4.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@446 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-02 02:32:52 +00:00
Marcelo Roberto Jimenez
40b43458f1 Added an m4 macro to deal with finding libupnp in the users' configure script.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@445 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-30 05:53:55 +00:00
Marcelo Roberto Jimenez
3182593c01 Nicholas Kraft's patch to fix some IPv6 copy/paste issues. He
reported to be getting infinite loops with the svn code.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@444 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-27 11:38:03 +00:00
Marcelo Roberto Jimenez
c89f83497e White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@443 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-14 21:32:02 +00:00
Marcelo Roberto Jimenez
46bc551a48 Undoing the patch that fixed this problem. In fact, there was no
problem and the patch was wrong.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@442 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-13 19:15:25 +00:00
Marcelo Roberto Jimenez
087e675c94 Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@441 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-13 19:03:48 +00:00
Marcelo Roberto Jimenez
11a4ce7359 Improove debugging.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@440 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-13 19:00:52 +00:00
Marcelo Roberto Jimenez
a6ba868e58 Avoid a dangling pointer.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@439 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-12 13:58:08 +00:00
Marcelo Roberto Jimenez
9f96b04831 White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@438 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-12 13:47:16 +00:00
Marcelo Roberto Jimenez
219871b1dc Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@437 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-12 03:41:08 +00:00
Marcelo Roberto Jimenez
a583e0a60e Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@436 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-11 23:29:11 +00:00
Marcelo Roberto Jimenez
3906d8c2c7 Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@435 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-11 23:28:08 +00:00
Marcelo Roberto Jimenez
4578ff8452 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/trunk@434 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-11 23:22:08 +00:00
Marcelo Roberto Jimenez
8e03b34739 Ingo Hofmann's patch for "Content-Type in Subscription responses".
Adds charset="utf-8" attribute to the CONTENT-TYPE header line.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@433 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-11 16:48:54 +00:00
Marcelo Roberto Jimenez
5c008e3634 Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@432 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-10 04:31:44 +00:00
Marcelo Roberto Jimenez
7f4bac9727 Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@431 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-10 03:23:08 +00:00
Marcelo Roberto Jimenez
f00752efbd Doxygen and include file reorganization.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@430 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-09 23:19:00 +00:00
Marcelo Roberto Jimenez
b78f27dd3e Typo.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@429 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-09 16:25:29 +00:00
Marcelo Roberto Jimenez
9e3b03e229 Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@428 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-09 16:24:38 +00:00
Marcelo Roberto Jimenez
3d7b653426 Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@427 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-09 03:24:01 +00:00
Marcelo Roberto Jimenez
0f2463f739 Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@426 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-09 02:31:24 +00:00
Marcelo Roberto Jimenez
680db7c78d Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@425 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-07 23:43:45 +00:00
Marcelo Roberto Jimenez
a9064dc0ca White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@424 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-06 22:33:43 +00:00
Marcelo Roberto Jimenez
9ca32e0eb4 Removing replicated #defines and using a single source for them, UpnpGlobal.h.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@423 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-06 22:28:46 +00:00
Marcelo Roberto Jimenez
aa63ef88f1 Removed all #include's from ixml.h.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@422 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-06 22:19:14 +00:00
Marcelo Roberto Jimenez
08a4da2876 Removing some unneeded includes.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@421 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-06 21:53:40 +00:00
Marcelo Roberto Jimenez
93ff2d7361 Missing from the last commit adding the file UpnpInet.h to Makefile.am.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@420 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-06 21:34:19 +00:00
Marcelo Roberto Jimenez
37ecd99305 Include file reorganization.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@419 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-06 21:32:51 +00:00
Marcelo Roberto Jimenez
9fc2c364fa Added EXPORT_SPEC to the new API functions, so that these functions get
exported on win32 DLLs. Also did some doxygenation.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@418 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-05 22:41:50 +00:00
Charles Nepveu
7a796b264e Fixed the MSVC9 project files.
To be tested later when the EXPORT_SPEC thing is fixed.

git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@417 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-05 01:54:05 +00:00
Marcelo Roberto Jimenez
517965c946 DOMString use consistency.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@416 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-04 23:44:12 +00:00
Marcelo Roberto Jimenez
767eac1050 Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@415 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-04 23:14:45 +00:00
Marcelo Roberto Jimenez
ad8a223998 Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@414 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-04 23:06:20 +00:00
Marcelo Roberto Jimenez
00e047f3c8 Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@413 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-04 22:58:07 +00:00
Marcelo Roberto Jimenez
0ea80ee482 Fixed the ixml document tree printing routine to output the namespace tag.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@412 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-04 22:52:11 +00:00
Marcelo Roberto Jimenez
23260a7df1 Doxygen/debugging.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@411 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-04 22:23:18 +00:00
Marcelo Roberto Jimenez
2a4701328c Improoving debug in ixml.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@410 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-04 21:43:21 +00:00
Marcelo Roberto Jimenez
0e7e47d5bd Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@409 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-04 21:29:13 +00:00
Marcelo Roberto Jimenez
e83ccbe4d0 Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@408 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-04 04:06:38 +00:00
Marcelo Roberto Jimenez
ef0835d038 Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@407 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-04 03:48:50 +00:00
Marcelo Roberto Jimenez
3d78996c40 Updating Makefile.am for missing files in the "make dist" tarball.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@406 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-04 03:06:30 +00:00
Marcelo Roberto Jimenez
92f4a78ffa In the debug code, do not consider IXML_FILE_DONE as an error.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@405 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-03 19:56:15 +00:00
Marcelo Roberto Jimenez
6fb2655086 White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@404 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-03 15:19:00 +00:00
Marcelo Roberto Jimenez
441cf2e471 Bob Ciora's patch for "UpnpCreatePropertySet can leak memory".
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@403 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-02 23:08:02 +00:00
Marcelo Roberto Jimenez
eb66b253e2 Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@402 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-02 22:59:53 +00:00
Marcelo Roberto Jimenez
c1ac15fccc Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@401 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-02 22:42:33 +00:00
Charles Nepveu
ecb06fa24f Miniserver is a required part of libupnp, no matter how configured.
However, it is possible to disable parts of the miniserver processing.

git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@400 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-02 15:09:27 +00:00
Marcelo Roberto Jimenez
1175a0cadb Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@399 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-02 03:43:25 +00:00
Marcelo Roberto Jimenez
1401fce206 Charles Nepveu's suggestion of not allocating a thread for MiniServer when it is not compiled.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@398 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-01 04:42:52 +00:00
Marcelo Roberto Jimenez
bbb4478c81 Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@397 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-06-01 03:57:47 +00:00
Marcelo Roberto Jimenez
b4b4ee982f Bob Ciora's patch for lazy UpnpAcceptSubscription().
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@395 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-27 00:24:12 +00:00
Marcelo Roberto Jimenez
a8521c09cf More doxygen. Now some gena files are documented.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@394 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-26 02:19:24 +00:00
Marcelo Roberto Jimenez
d0d4a0631a Second part of Peter Hartley's patch.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@393 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-26 00:46:21 +00:00
Marcelo Roberto Jimenez
494518b14b Doxygenation and improove debugging in gena.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@392 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-26 00:10:49 +00:00
Marcelo Roberto Jimenez
724700be0d Ported Peter Hartley's patch to compile with mingw.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@391 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-25 00:49:43 +00:00
Marcelo Roberto Jimenez
bad7c80e5e Changelog update.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@390 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-24 23:27:43 +00:00
Marcelo Roberto Jimenez
ddb2f2c478 Changelog update.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@389 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-24 23:27:10 +00:00
Marcelo Roberto Jimenez
4beacd4c2d Improoving debug in the parser. Seems like the ixml parser is only able to parse UTF-8.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@388 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-24 22:48:59 +00:00
Marcelo Roberto Jimenez
0e51ee5b61 White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@387 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-24 21:02:01 +00:00
Marcelo Roberto Jimenez
7cf161ad22 Fix for compiler warning message.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@386 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-24 20:50:50 +00:00
Marcelo Roberto Jimenez
2e85c471ca Some fixes on the use of struct sockaddr_storage and struct sockaddr.
This patch does not change any behaviour.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@385 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-23 22:15:52 +00:00
Marcelo Roberto Jimenez
35db3e9bba Header file reordering and sanity. White space patch.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@384 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-23 21:55:04 +00:00
Charles Nepveu
98e2b2b3af Fixed the Visual Studio project file (ixml project):
- Added include directory "..\inc" where the autoconfig.h is relatively positionned.
Removed the #ifdef statement in ixmldebug.c file because now MSVC finds the autoconfig.h file.

git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@383 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-23 19:22:20 +00:00
Marcelo Roberto Jimenez
494613c23b This file should be a copy of upnp/src/inc/config.h. This is a white space patch.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@382 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-23 18:59:44 +00:00
Charles Nepveu
0eba550da0 - Fixed the windows VS2005 project for release and debug.
- Fixed the win32 inclusion of "netinet/net.h" -> "ws2tcpip.h"
- Fixed thread ID cast.

git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@381 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-22 20:00:37 +00:00
Marcelo Roberto Jimenez
90f52baa61 Making things easier for the MSC compiler.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@380 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-22 17:24:56 +00:00
Marcelo Roberto Jimenez
094cedc807 Module String renamed to UpnpString due to case insensitive file systems.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@379 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-09 22:44:14 +00:00
Marcelo Roberto Jimenez
9a98f25b95 Improoving IXML debugging.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@378 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-08 17:21:59 +00:00
Marcelo Roberto Jimenez
e90e549cbb Improoving debug code.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@377 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-07 21:56:49 +00:00
Charles Nepveu
efb6812b3e - Fixed bug in discovery API.
The variable holder for socket addresses (sockaddr's) should always
be 'struct sockaddr_storage'. The struct sockaddr is not big enough
to contain IPv6 addresses.
Although we are always using 'struct sockaddr_storage' we sould always
reference them and cast them to 'struct sockaddr*' when passing as
parameter to a function.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@376 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-07 19:13:29 +00:00
Marcelo Roberto Jimenez
263e616403 Some white spaces, some doxygen, some code reorganizing.
We should try to return only at the end of the function so that
we can use "objects" reliably.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@375 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-06 19:29:24 +00:00
Charles Nepveu
b503c89f78 - Fixed Miniserver start when in an IPv4-only environment.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@374 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-06 13:36:43 +00:00
Marcelo Roberto Jimenez
c60ab8eeac More doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@373 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-06 02:24:12 +00:00
Marcelo Roberto Jimenez
d8fce6e0fe Small fix for ifdef comments.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@372 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-05 23:33:40 +00:00
Marcelo Roberto Jimenez
e56a9d68a3 Removing the useless, unused and undocumented function UpnpFree().
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@371 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-05 23:26:37 +00:00
Marcelo Roberto Jimenez
4e6102d1c2 More doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@370 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-05 23:10:41 +00:00
Marcelo Roberto Jimenez
9e54783740 More doxygen. It's a dirty job, but someone has to do it...
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@369 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-05 22:32:44 +00:00
Marcelo Roberto Jimenez
164dce7fc2 More doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@368 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-05 00:25:22 +00:00
Marcelo Roberto Jimenez
537a9a4d93 Removing dead code.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@367 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-04 19:59:12 +00:00
Marcelo Roberto Jimenez
9326b73d06 Doxygenation.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@366 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-04 19:56:15 +00:00
Marcelo Roberto Jimenez
0fb20847a7 Proper name for a hidden data structure.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@365 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-04 01:52:55 +00:00
Marcelo Roberto Jimenez
6b7dc5d340 Coherent name for the EventSubscribe externally exposed data structure.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@364 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-04 01:36:07 +00:00
Marcelo Roberto Jimenez
a86a127f44 White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@363 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-04 00:57:07 +00:00
Marcelo Roberto Jimenez
7acfd52f6b Hiding UpnpVirtualDirCallbacks and struct virtual_Dir_List.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@362 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-04 00:33:50 +00:00
Marcelo Roberto Jimenez
be2fa49891 White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@361 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-03 21:49:43 +00:00
Marcelo Roberto Jimenez
d2c34a15de Upnp_Subscription_Request becomes UpnpSubscriptionRequest. One less externally visible data structure.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@360 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-03 21:19:08 +00:00
Marcelo Roberto Jimenez
98a45e17b5 struct Upnp_Event becomes UpnpEvent. One less externally visible data structure.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@359 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-03 15:35:14 +00:00
Marcelo Roberto Jimenez
2e4a96f034 Merged Charles Nepveu's IPv6 work. libupnp now is IPv6 enabled.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@358 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-05-02 17:04:22 +00:00
Marcelo Roberto Jimenez
4f2075b7c9 Merge of revision 355 from branch-1.6.x into trunk.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@356 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-04-29 18:10:17 +00:00
Marcelo Roberto Jimenez
7206e80127 Start of 1.8.x development. Sorry for the big commit, but in fact it should have been bigger.
The fact that we now have an active developer on branch ipv6 made me do this before I would like to.
The idea here is to hide libupnp internal data structures from the outside world so that
developers can be free to change them without breaking the interface. There is still some work to do
before a formal release, but the samples (device and control point) should be working.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@353 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-04-26 01:20:09 +00:00
Marcelo Roberto Jimenez
5e742f04e3 Added thread id's to the UpnpPrintf debug messages.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@350 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-04-25 13:32:05 +00:00
Marcelo Roberto Jimenez
0fc29c3d99 Adjust of libtool numbers for threadutil.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@349 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-04-25 11:42:51 +00:00
Marcelo Roberto Jimenez
2c094ee8ea * SF Bug Tracker [ 1948586 ] Uppercase U in in "xmlns:U" in Invoke Action causes seg. f.
Submitted By: Thomas Norheim - kjakan_no
Device no longer segfaults with the following malformed xml action:
<u:SetColor xmlns:U="urn:schemas-upnp-org:service:tvpicture:1">
	<Color>2</Color>
</u:SetColor>



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@348 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-04-24 03:34:16 +00:00
Marcelo Roberto Jimenez
a4a7dda7ef Use -O0 in debug builds so that variables do not get optimized out.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@347 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-04-23 19:33:03 +00:00
Marcelo Roberto Jimenez
a732d1a62e Typo in comment.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@346 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-04-23 19:03:19 +00:00
Marcelo Roberto Jimenez
f18abdb52d Apostolos Syropoulos changes for OpenSolaris x86.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@341 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-04-10 17:36:21 +00:00
Marcelo Roberto Jimenez
85024d9576 More of Andre Sodermans' vc8 patch.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@340 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-03-26 04:01:58 +00:00
Marcelo Roberto Jimenez
8d21e60a2f Changing svn:eol-style back to native.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@337 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-03-25 03:17:21 +00:00
Marcelo Roberto Jimenez
84cb69fc2d White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@336 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-03-22 17:21:43 +00:00
Marcelo Roberto Jimenez
0a173ca0c3 Andre Sodermans (wienerschnitzel) patch for building libupnp under
windows systems with VC9.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@335 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-03-22 17:10:29 +00:00
Marcelo Roberto Jimenez
39e77f6d25 Created directory needed for vc9 files.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@334 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-03-20 23:36:23 +00:00
Marcelo Roberto Jimenez
e599661068 Andre Sodermans (wienerschnitzel) patch for building libupnp under
windows systems.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@333 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-03-20 23:34:45 +00:00
Marcelo Roberto Jimenez
3846fcc9ba Fixed a printf format problem on the upnp_tv_device.c from both
upnp/sample/tvdevie and upnp/sample/tvcombo directories. The variable
port was a short int instead of an unsigned short and it was beeing
print as a negative value.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@332 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-03-09 02:10:18 +00:00
Marcelo Roberto Jimenez
0b39b2ad6c * SF Bug Tracker [ 1902668 ] Cannot compile on MSVC
Submitted By Luke Kim - nereusuj
Version 1.6.5 cannot be compiled because of some changes in 1.6.3.
MSVC does not support stdint.h, gettimeofday(), sys/param.h, const int
variables in array size and Windows does not define _WINDOWS_ but define
_WINDOWS.
* MSVC does not understand "const int"'s as declarators of array
dimensions, we must use #define'd constants.
* Use WIN32 instead of _WINDOWS_ or _WINDOWS.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@331 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-03-09 01:16:58 +00:00
Marcelo Roberto Jimenez
a91534042e White spaces (merge).
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@330 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-03-05 04:58:43 +00:00
Marcelo Roberto Jimenez
04f80795c2 No longer ignore "upnp:rootdevice" advertisement. Thanks to Bob Ciora.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@326 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-02-22 04:16:11 +00:00
Marcelo Roberto Jimenez
6223b7521f Changed "sys_errlist[errno]", which is deprecated, by "strerror_r()",
which is thread safe.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@323 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-02-10 02:15:09 +00:00
Marcelo Roberto Jimenez
04b2ccca92 Changelog update.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@321 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-02-08 02:27:48 +00:00
Marcelo Roberto Jimenez
13bcc67f14 Update of libtool numbers.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@320 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-02-08 00:05:36 +00:00
Marcelo Roberto Jimenez
156ee82358 Slightly improved error report by showing the sys_errlist string corresponding
to errno.
Also, got rid of two useless constants: UPNP_SOCKETERROR and
UPNP_INVALID_SOCKET. They both mean the same, that a network API function has
failed. -1 is the value to check, not an invented constant.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@319 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-02-06 18:32:09 +00:00
Marcelo Roberto Jimenez
6d426a5d2e White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@317 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-02-06 02:14:15 +00:00
Marcelo Roberto Jimenez
59784a134c Homekeeping for the next release.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@316 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-02-03 02:38:11 +00:00
Marcelo Roberto Jimenez
2683d884ce Update of library version.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@310 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-02-03 00:10:27 +00:00
Marcelo Roberto Jimenez
d2d2081230 Peter Hartley's fix for wrong sized variable beeing passed to
http_MakeMessage() on 64 bit architectures.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@309 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-02-02 23:31:34 +00:00
Marcelo Roberto Jimenez
37558fb793 Homekeeping for the next release.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@308 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-01-27 02:35:53 +00:00
Marcelo Roberto Jimenez
fa84a12d61 Update of libtool numbers.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@304 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-01-27 01:29:28 +00:00
Marcelo Roberto Jimenez
5bc8cae4ea Reverting Peter Hartley's last patch.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@303 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-01-27 01:23:54 +00:00
Marcelo Roberto Jimenez
c28942f6fe Update of libtool numbers.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@302 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-01-25 05:21:13 +00:00
Marcelo Roberto Jimenez
cc5ebd5b78 Added build-aux directory to ignore list.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@301 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-01-25 05:10:55 +00:00
Marcelo Roberto Jimenez
d264810747 White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@300 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-01-25 05:10:08 +00:00
Marcelo Roberto Jimenez
77f1cff5d5 Peter Hartley's patch for "extra-headers".
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@299 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-01-25 05:04:36 +00:00
Marcelo Roberto Jimenez
c24997917a Peter Hartley's fix for his own patch.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@298 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-01-24 14:09:46 +00:00
Marcelo Roberto Jimenez
332064ce09 Workaround for a problem with the new automake AM_CONDITIONAL macro
from autotools-1.10. Thanks to Ingo Hofmann for helping with debugging
this one.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@297 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-01-23 11:59:30 +00:00
Marcelo Roberto Jimenez
93d2b99446 White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@296 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-01-22 13:18:11 +00:00
Marcelo Roberto Jimenez
bcfedbc45e Added quoting to macros AC_CONFIG_AUX_DIR, AC_CONFIG_MACRO_DIR and
AC_CONFIG_SRCDIR in configure.ac. Also changed the name of the
auxiliary directory in AC_CONFIG_AUX_DIR to build-aux.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@295 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-01-22 13:16:38 +00:00
Marcelo Roberto Jimenez
7b4dfce3dc Adding svn:ignore for some unversioned files.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@294 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-01-22 11:58:25 +00:00
Marcelo Roberto Jimenez
87eff01a43 Setting eol:style on files that didn't have it native.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@293 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-01-22 11:50:53 +00:00
Marcelo Roberto Jimenez
757caf9284 Fix for setsockopt() in Threadpool.c to allow more than one process
to join the multicast-group on OSX. Thanks to Ingo Hofmann.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@292 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-01-22 10:39:59 +00:00
Marcelo Roberto Jimenez
3b38c5fe68 Using defined(__OSX__) || defined(__APPLE__) instead of just
defined(__OSX__) in the code. Thanks to Ingo Hofmann and Chris
Pickel.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@291 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-01-22 10:36:07 +00:00
Marcelo Roberto Jimenez
1ab5221db5 Fix for isFileInVirtualDir. Thanks to Peter Hartley for the patch.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@290 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-01-21 23:35:08 +00:00
Marcelo Roberto Jimenez
f94b090c80 Putting back a "defined(__OSX__)" that has been removed in the
previous *BSD patch. Thanks to Chris Pickel for pointing it out.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@289 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-01-13 05:33:35 +00:00
Marcelo Roberto Jimenez
5756f589d7 SF Patches Tracker [ 1865812 ] typo in docs comment
Submitted By: Hartmut Holzgraefe - hholzgra
typo in docs comment ACCAPTED instead of ACCEPTED in
@name UPNP_E_UNSUBSCRIBE_UNACCAPTED [-302]
Also, the documentation file name was mispelled and was corrected in
the Makefile.am.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@287 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-01-07 12:02:33 +00:00
Marcelo Roberto Jimenez
ad479caddf Homekeeping for the next release.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@286 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-27 02:20:24 +00:00
Marcelo Roberto Jimenez
16c883932a Using pthread flags for the whole project, not just at the places
individually indicated by several Makefile.am files spread all over
the directories. That was too much error prone.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@282 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-25 18:29:52 +00:00
Marcelo Roberto Jimenez
1457bf5937 Use CPPFLAGS instead of CFLAGS for -D, this is preprocessor stuff.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@281 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-25 13:50:47 +00:00
Marcelo Roberto Jimenez
ff3c4ae623 Make sure we are using the C compiler for these tests.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@280 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-25 13:47:57 +00:00
Marcelo Roberto Jimenez
4e23dd9c1b White spaces in configure.ac.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@279 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-25 13:43:01 +00:00
Marcelo Roberto Jimenez
3fe9ccb9ae Fixes an error introduced in the last configure.ac commit with the usage of
the macro AC_LANG_PROGRAM. The generated test program was incorrect.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@278 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-25 13:14:48 +00:00
Marcelo Roberto Jimenez
4a6014c6f6 Proper thanks and some nicks.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@277 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-24 21:21:48 +00:00
Marcelo Roberto Jimenez
3f4be1ef7b AC_DEFINE macro puts things in autoconfig.h, not in the command line.
But ithread does not use autoconfig.h. So, I will add _GNU_SOURCE to
CFLAGS directly.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@276 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-24 21:06:55 +00:00
Marcelo Roberto Jimenez
868d0f0a03 Removing replicated test.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@275 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-24 13:51:26 +00:00
Marcelo Roberto Jimenez
b66f2646c3 Added a configure test to check if pthread_rwlock_t is available.
Define _GNU_SOURCE if needed. The fallback behaviou will only be
implemented if _GNU_SOURCE prooves to be insufficient on some
platforms.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@274 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-24 03:39:50 +00:00
Marcelo Roberto Jimenez
34e18c2444 Removed unused iasnprintf.{c,h} files.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@273 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-17 11:05:22 +00:00
Marcelo Roberto Jimenez
0ea632f699 UPNP_INLINE is not needed in ixmlmembuf.h
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@272 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-17 10:40:42 +00:00
Marcelo Roberto Jimenez
e156038d5c Removed STATSONLY() macro from ThreadPool.{c,h}.
Removed time() usage from ThreadPool.c.
Fixed STATS = 0 compilation.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@271 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-17 10:39:57 +00:00
Marcelo Roberto Jimenez
9bfac585af Library was not compiling on FreeBSD 7. Code now no longer uses
ftime(), using gettimeofday() instead. Thanks to Josh Carroll.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@270 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-17 01:15:53 +00:00
Marcelo Roberto Jimenez
8faf828b50 Added some assertions to the Parser_isValidEndElement() function. A user has
reported NULL pointers here, so lets check them on debug versions.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@269 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-17 00:37:41 +00:00
Marcelo Roberto Jimenez
44b8ee0b3a Added some comments and white spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@268 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-17 00:03:06 +00:00
Marcelo Roberto Jimenez
66ed0d8f69 Homekeeping for the next release.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@267 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-11 09:26:19 +00:00
Marcelo Roberto Jimenez
be3a6c6825 Fixing configure.ac for release.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@264 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-10 23:05:10 +00:00
Marcelo Roberto Jimenez
6cbd7f0159 Use C comments instead of C++ in headers.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@260 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-10 22:27:20 +00:00
Marcelo Roberto Jimenez
c7c493c043 White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@259 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-10 22:23:20 +00:00
Marcelo Roberto Jimenez
c2f8e8789a Fixed a compilation error due to a missing #ifdef in
upnp/src/genlib/miniserver/miniserver.c. Thanks to Eugene Christensen.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@258 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-10 22:12:54 +00:00
Marcelo Roberto Jimenez
76457d0187 White spaces and comments fix.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@257 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-27 05:19:52 +00:00
Marcelo Roberto Jimenez
9f5d49f9fd Fixed a memory leak in upnpapi.c to delete gMiniServerThreadPool in
the call to UpnpFinish(). Thanks to Fabrice Fontaine.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@256 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-27 05:02:50 +00:00
Marcelo Roberto Jimenez
cad4d05cd7 White space fix.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@255 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-27 03:28:23 +00:00
Marcelo Roberto Jimenez
26b8968e0c Removing unnecessary second time set of nodeList to NULL in AdvertiseAndReply().
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@254 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-27 03:07:13 +00:00
Marcelo Roberto Jimenez
d2eaa23b59 Changelog fix to document the unreleased 1.4.7.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@253 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-19 14:39:21 +00:00
Marcelo Roberto Jimenez
b8aec74782 Spec file update.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@248 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-19 13:49:00 +00:00
Marcelo Roberto Jimenez
851cfbc4db Some rework of http_SendMessage(), no change in functionality. Mostly white spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@246 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-13 04:14:17 +00:00
Marcelo Roberto Jimenez
f42bbb6dc2 "make check" was failing because ixml/test/test_document.sh did not
have the executable flag set. Thanks to Steve Bresson.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@245 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-12 03:27:58 +00:00
Marcelo Roberto Jimenez
bd6027c3d1 Changelog update.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@244 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-09 13:17:30 +00:00
Marcelo Roberto Jimenez
e3865bf6b6 Exit message goes to the end of the UpnpFinish().
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@243 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-09 11:53:43 +00:00
Marcelo Roberto Jimenez
27af41e562 Avoid 100% CPU in case of repeated error in select().
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@242 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-09 11:48:30 +00:00
Marcelo Roberto Jimenez
1f05f5d6cc Removing the macro CLIENTONLY() from miniserver.c. It breaks syntax highlight,
not to mention it is awful.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@241 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-09 10:34:12 +00:00
Marcelo Roberto Jimenez
43b9760840 White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@240 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-09 09:49:54 +00:00
Marcelo Roberto Jimenez
0103424b91 Homekeeping for the next release.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@239 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-08 02:25:38 +00:00
Marcelo Roberto Jimenez
13a1fff7a1 SF Bug Tracker [ 1825278 ] AdvertiseAndReply sleeps with handle lock out
Applied patch from Alex (afaucher) to change some write locks to read
locks.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@237 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-08 01:54:50 +00:00
Marcelo Roberto Jimenez
c9463545a8 Small fix for changelog.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@235 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-06 02:43:44 +00:00
Marcelo Roberto Jimenez
de1d7e81a3 Adjusting libtool library numbers to reflect the last changes.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@234 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-06 02:41:34 +00:00
Marcelo Roberto Jimenez
f87dbf8115 GlobalHndMutex, which was a mutex is now GlobalHndRWLock, which is a
rwlock. HandleLock() is mapped to HandleWriteLock() while all other
instances have not been checked. One instance in AdvertiseAndReply()
has been changed to HandleReadLock(). Thanks to Alex (afaucher) for the 
bug report and suggestions.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@233 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-06 02:29:03 +00:00
Marcelo Roberto Jimenez
83ee32afb7 Added support for rwlocks.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@232 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-06 02:04:38 +00:00
Marcelo Roberto Jimenez
4f960c4e34 Small printf changes. Also reworked PrintThreadPoolStats() so that we can
remove a few #ifdef DEBUG from the main code.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@231 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-05 13:39:58 +00:00
Marcelo Roberto Jimenez
c85537df11 White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@230 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-05 13:12:35 +00:00
Marcelo Roberto Jimenez
20905cb7a7 White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@229 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-05 13:09:33 +00:00
Marcelo Roberto Jimenez
5b744169d5 SF Bug Tracker [ 1825929 ] woker thread still alive after UpnpFinish()
Submitted By: Luke Kim - nereusuj
	Worker thread still alive after calling UpnpFinish() because
	ThreadPoolShutdown() is in the #ifdef DEBUG block.
	421
	422 #ifdef DEBUG
	423 ThreadPoolShutdown( &gSendThreadPool );
	424 ThreadPoolShutdown( &gRecvThreadPool );



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@228 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-05 13:07:54 +00:00
Marcelo Roberto Jimenez
c69e16b347 White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@227 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-05 12:25:18 +00:00
Marcelo Roberto Jimenez
cb7e6b7472 White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@226 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-05 12:06:52 +00:00
Marcelo Roberto Jimenez
fd80e5a8ff Slightly better debug messages and lots of white spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@225 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-10-26 13:21:59 +00:00
Marcelo Roberto Jimenez
b29de32110 White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@224 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-09-01 17:05:07 +00:00
Marcelo Roberto Jimenez
6455ac6eea Changed the calls to virtualDirCallback.open(filename, UPNP_WRITE)
to (virtualDirCallback.open)(filename, UPNP_WRITE) (notice the
parenthesis) due to a change in glibc that produces compilation
errors.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@223 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-09-01 16:58:58 +00:00
Marcelo Roberto Jimenez
f7bb1f9582 Fixed the path in the documentation for upnpdebug.h.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@222 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-08-31 13:12:40 +00:00
Marcelo Roberto Jimenez
0728ab3b25 Initialization of the "randomness" struct so that valgrind does not complain.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@221 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-08-28 14:37:41 +00:00
Marcelo Roberto Jimenez
cb9ee8254c White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@220 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-08-28 14:08:53 +00:00
Marcelo Roberto Jimenez
f08fdac9b6 ReqBuf was not initialized, so it should not be used.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@219 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-08-25 02:28:44 +00:00
Marcelo Roberto Jimenez
0db035cc7b Two unnecessary lines.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@218 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-08-25 01:22:27 +00:00
Marcelo Roberto Jimenez
da11e52924 White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@217 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-08-25 01:20:21 +00:00
Marcelo Roberto Jimenez
bc7b0c9d4d Libtool stuff update.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@216 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-08-06 05:18:25 +00:00
Marcelo Roberto Jimenez
b2757d9d55 Changelog fix.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@215 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-08-06 05:12:17 +00:00
Marcelo Roberto Jimenez
7967a0cd45 Merge of patch submitted By Keith Brindley - brindlk
SF Bug Tracker [ 1762758 ] Seek not working for large files.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@214 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-08-06 05:11:07 +00:00
Marcelo Roberto Jimenez
67b51187b9 Merge of Mac OS X patch from Stéphane Corthésy (davelopper),
SF Bug Tracker [ 1686420 ] Modifications for MacOSX.
Some of the proposed changes were already done by Rene Hexel's patch.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@213 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-08-06 02:07:41 +00:00
Marcelo Roberto Jimenez
491f5ffef6 Bumping library version.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@212 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-06-23 14:38:32 +00:00
94 changed files with 8891 additions and 5489 deletions

105
.gitignore vendored
View File

@@ -1,105 +0,0 @@
#
# 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
docs/doxygen

452
ChangeLog
View File

@@ -1,287 +1,221 @@
*******************************************************************************
Version 1.6.9
Version 1.8.0
*******************************************************************************
2010-10-20 Marcelo Roberto Jimenez <mroberto(at)users.sourceforge.net>
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.
Fix for bug introduced in samples code in svn revision 502, commit
git:25c908c558c8e60eb386c155a6b93add447ffec0
2010-04-25 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
Separation of the ClientSubscription object.
Sample device and combo were aborting with the message:
"***** SampleUtil_Initialize was called multiple times!"
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-11-08 Fabrice Fontaine <fabrice.fontaine(at)orange-ftgroup.com>
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 ?
Make multiple SSDP advertisements faster.
Nick
Put the loop to send multiple copies of each SSDP advertisements in
ssdp_server.c instead of ssdp_device.c so we have only one call to
imillisleep ( SSDP_PAUSE ) to speed up advertisements.
2010-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-11-05 Fabrice Fontaine <fabrice.fontaine(at)orange-ftgroup.com>
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.
Removing unused NUM_COPY variable.
Previously, NUM_COPY was used in ssdp_device.c to send multiple copies
of each advertisements but also multiple replies to each M-SEARCH
request. As sending multiple replies is not compliant with HTTPU/MU
spec, NUM_COPY has been set to 1 in an older patch. However, as this
variable is not needed and has been replaced with SSDP_COPY, it has
been removed.
2010-11-05 Fabrice Fontaine <fabrice.fontaine(at)orange-ftgroup.com>
Use SSDP_COPY to send multiple SSDP advertisements.
Currently, SSDP_COPY is used only to send multiple M-SEARCH requests (in
ssdp_ctrlpt.c). With this patch, SSDP_COPY is also used to send multiple
copies of each advertisements packets (in ssdp_device.c).
2010-11-01 Carl Benson <carl.benson(at)windriver.com>
Fix for Android build.
I had to do some modifications myself though, because the Android
build system insists on having a file named "util.h" taking precedence
in its include path, libupnp gets confused because of the same filename
in upnp/src/inc/util.h
*******************************************************************************
Version 1.6.8
*******************************************************************************
2010-10-20 Marcelo Roberto Jimenez <mroberto(at)users.sourceforge.net>
Fix a long date memory leak in webserver.c:StrStr().
2010-10-19 Marcelo Roberto Jimenez <mroberto(at)users.sourceforge.net>
Bug fix in select of miniserver.c
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 )
Fix a bug in miniserver.c, in which maxMiniSock was wrongly declared as
unsigned int and as a result it was beeng set to ((unsigned int)(-1)).
As a result, after beeing incremented, it became zero, and this value
was beeing used in the select() call.
Internet Gateway Device description contains nested serviceList (rootdevice
-> servicelist, subdevice
and subdevice has the lower-level serviceList, etc..)
Thanks to Fabrice Fontaine for helping and testing with this issue.
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.
2010-10-15 Marcelo Roberto Jimenez <mroberto(at)users.sourceforge.net>
Attached patch modifies this behavior and looks for the service by
visiting all the serviceList in xml document in turn.
Fix for 100% CPU issue in select() in miniserv.c. I have also removed
the sleep() call, it was just a workaround.
With the modified patch (ad additional modification), I could
simulate an IGD device and created a modified control program for that.
SF Bug Tracker [ 3086852 ] 99% CPU loop in miniserver.c on a non ipv6
system.
Patch against 1.6.6
Submitted by: Jin ( jin_eld ) - 2010-10-13 19:29:13 UTC
TIA.
I cross compiled libupnp 1.6.7 for ARM9 using the --disable-ipv6
option, my system is an ipv4 only setup.
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.
I do not know why this problem only appears when running the app in the
background (for instance using nohup &), but then it starts using 99%
CPU.
2010-03-16 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Fix for the ithread_mutex_unlock() logic in UpnpInit().
Thanks for Nicholas Kraft.
I traced the problem down to the select() call in miniserver.c in the
RunMiniServer() function. Select returns code 1, but errno is set to
"Socket operation on non-socket", I also see this when running my app
under strace.
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.
I set all ...Sock6 variables to INVALID_SOCKET to make sure that they
do not get added to the FD_SET and the problem is gone.
2010-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.6.9
PROJECT_NUMBER = 1.8.0
# 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émi Turboult <r3mi@users.sourceforge.net>
# Copyright (C) 2005 R<EFBFBD>mi Turboult <r3mi@users.sourceforge.net>
#
ACLOCAL_AMFLAGS = -I m4
@@ -26,6 +26,7 @@ EXTRA_DIST = \
build/libupnp.dsp \
build/libupnp.dsw \
build/inc/autoconfig.h \
build/inc/config.h \
build/inc/upnpconfig.h \
build/msvc/inttypes.h \
build/msvc/stdint.h \

2
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émi Turboult <r3mi@users.sourceforge.net>
Copyright (c) 2005-2006 R<EFBFBD>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,8 +13,6 @@ exempt of errors.
- Arno Willig
- Bob Ciora
- Carlo Parata
- Carl Benson
- Chandra (inactiveneurons)
- Chaos
- Charles Nepveu (cnepveu)
- Chris Pickel

24
TODO
View File

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

View File

@@ -67,6 +67,9 @@
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/timeb.h> header file. */
#define HAVE_SYS_TIMEB_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
@@ -82,15 +85,11 @@
/* Define to 1 if you have the <ws2tcpip.h> header file. */
/* #undef HAVE_WS2TCPIP_H */
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Define to 1 to prevent compilation of assert() */
#define NDEBUG 1
/* #undef NDEBUG */
/* Define to 1 to prevent some debug code */
#define NO_DEBUG 1
/* #undef NO_DEBUG */
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
/* #undef NO_MINUS_C_MINUS_O */
@@ -105,13 +104,13 @@
#define PACKAGE_NAME "libupnp"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "libupnp 1.6.9"
#define PACKAGE_STRING "libupnp 1.8.0"
/* 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.6.9"
#define PACKAGE_VERSION "1.8.0"
/* Define to necessary symbol if this constant uses a non-standard name on
your system. */
@@ -120,17 +119,11 @@
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* see upnpconfig.h */
/* #undef UPNP_ENABLE_IPV6 */
/* see upnpconfig.h */
#define UPNP_ENABLE_NOTIFICATION_REORDERING 1
/* see upnpconfig.h */
#define UPNP_HAVE_CLIENT 1
/* see upnpconfig.h */
/* #undef UPNP_HAVE_DEBUG */
#define UPNP_HAVE_DEBUG 1
/* see upnpconfig.h */
#define UPNP_HAVE_DEVICE 1
@@ -148,16 +141,16 @@
#define UPNP_VERSION_MAJOR 1
/* see upnpconfig.h */
#define UPNP_VERSION_MINOR 6
#define UPNP_VERSION_MINOR 8
/* see upnpconfig.h */
#define UPNP_VERSION_PATCH 9
#define UPNP_VERSION_PATCH 0
/* see upnpconfig.h */
#define UPNP_VERSION_STRING "1.6.9"
#define UPNP_VERSION_STRING "1.8.0"
/* Version number of package */
#define VERSION "1.6.9"
#define VERSION "1.8.0"
/* File Offset size */
#define _FILE_OFFSET_BITS 64
@@ -166,7 +159,7 @@
/* #undef _LARGEFILE_SOURCE */
/* Large files support */
#define _LARGE_FILE_SOURCE /**/
#define _LARGE_FILE_SOURCE
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */

411
build/inc/config.h Normal file
View File

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

@@ -2,7 +2,7 @@
/* -*- C -*- */
/*******************************************************************************
*
* Copyright (c) 2006 Rémi Turboult <r3mi@users.sourceforge.net>
* Copyright (c) 2006 R<EFBFBD>mi Turboult <r3mi@users.sourceforge.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -40,20 +40,20 @@
***************************************************************************/
/** The library version (string) e.g. "1.3.0" */
#define UPNP_VERSION_STRING "1.6.9"
#define UPNP_VERSION_STRING "1.8.0"
/** Major version of the library */
#define UPNP_VERSION_MAJOR 1
/** Minor version of the library */
#define UPNP_VERSION_MINOR 6
#define UPNP_VERSION_MINOR 8
/** Patch version of the library */
#define UPNP_VERSION_PATCH 9
#define UPNP_VERSION_PATCH 0
/** The library version (numeric) e.g. 10300 means version 1.3.0 */
#define UPNP_VERSION \
((UPNP_VERSION_MAJOR * 100 + UPNP_VERSION_MINOR) * 100 + UPNP_VERSION_PATCH)
((UPNP_VERSION_MAJOR*100 + UPNP_VERSION_MINOR)*100 + UPNP_VERSION_PATCH)
@@ -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 */
/* #undef UPNP_HAVE_DEBUG */
#define UPNP_HAVE_DEBUG 1
/** Defined to 1 if the library has been compiled with client API enabled
@@ -91,9 +91,6 @@
* (i.e. configure --enable-tools) : <upnp/upnptools.h> file is available */
#define UPNP_HAVE_TOOLS 1
/** Defined to 1 if the library has been compiled with ipv6 support
* (i.e. configure --enable-ipv6) */
/* #undef UPNP_ENABLE_IPV6 */
#endif /* UPNP_CONFIG_H */

View File

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

View File

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

View File

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

View File

@@ -9,7 +9,7 @@
AC_PREREQ(2.60)
AC_INIT([libupnp], [1.6.9], [mroberto@users.sourceforge.net])
AC_INIT([libupnp], [1.8.0], [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,59 +144,30 @@ dnl #AC_SUBST([LT_VERSION_THREADUTIL], [4:3:2])
dnl #AC_SUBST([LT_VERSION_UPNP], [3:5:0])
dnl #
dnl ############################################################################
dnl # Release 1.6.7:
dnl # Release 1.8.0:
dnl # "current:revision:age"
dnl #
dnl # - Code has changed in threadutil
dnl # revision: 3 -> 4
dnl # - Code has changed in upnp
dnl # revision: 5 -> 6
dnl # - Interfaces have been changed, added and removed in upnp
dnl # current: 3 -> 4
dnl # revision: 6 -> 0
dnl # - Interfaces removed in upnp:
dnl # age: -> 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
dnl # current: 4 -> 5
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], [3:5:0])
dnl #
dnl # Obs.: 1.6.7 was released with a version error, the correct nubers should
dnl # have been:
dnl #AC_SUBST([LT_VERSION_UPNP], [4:0:0])
dnl #
dnl ############################################################################
dnl # Release 1.6.8:
dnl # "current:revision:age"
dnl #
dnl # - Code has changed in ixml
dnl # revision: 4 -> 5
dnl # - Code has changed in threadutil
dnl # revision: 0 -> 1
dnl # - Code has changed in upnp
dnl # revision: 0 -> 1
dnl #
dnl #AC_SUBST([LT_VERSION_IXML], [2:5:0])
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [5:1:2])
dnl #AC_SUBST([LT_VERSION_UPNP], [4:1:0])
dnl #
dnl ############################################################################
dnl # Release 1.6.9:
dnl # "current:revision:age"
dnl #
dnl # - Code has changed in threadutil
dnl # revision: 1 -> 2
dnl # - Code has changed in upnp
dnl # revision: 1 -> 2
dnl #
dnl #AC_SUBST([LT_VERSION_IXML], [2:5:0])
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [5:2:2])
dnl #AC_SUBST([LT_VERSION_UPNP], [4:2:0])
dnl #
############################################################################
AC_SUBST([LT_VERSION_IXML], [2:5:0])
AC_SUBST([LT_VERSION_THREADUTIL], [5:2:2])
AC_SUBST([LT_VERSION_UPNP], [4:2:0])
AC_SUBST([LT_VERSION_IXML], [2:4:0])
AC_SUBST([LT_VERSION_THREADUTIL], [5:0:2])
AC_SUBST([LT_VERSION_UPNP], [4:0:0])
dnl ############################################################################
dnl # Repeating the algorithm to place it closer to the modificatin place:
dnl # - library code modified: revision++
@@ -290,16 +261,6 @@ 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])
@@ -526,11 +487,3 @@ AC_CONFIG_FILES([
AC_OUTPUT
#
# Files copied for windows compilation.
#
echo "configure: copying \"autoconfig.h\" to \"build/inc/autoconfig.h\""
cp autoconfig.h build/inc/autoconfig.h
echo "configure: copying \"upnp/inc/upnpconfig.h\" to \"build/inc/upnpconfig.h\""
cp upnp/inc/upnpconfig.h build/inc/upnpconfig.h

View File

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

View File

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

View File

@@ -582,14 +582,11 @@ 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;
}

View File

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

View File

@@ -115,10 +115,6 @@ 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
@@ -158,6 +154,10 @@ typedef int PolicyType;
#define DEFAULT_POLICY SCHED_OTHER
/*! Default priority */
#define DEFAULT_SCHED_PARAM 0
/****************************************************************************
* Name: free_routine
*
@@ -182,10 +182,6 @@ 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;
@@ -526,20 +522,6 @@ 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

@@ -85,10 +85,7 @@ extern "C" {
#define ITHREAD_CANCELED PTHREAD_CANCELED
#define ITHREAD_STACK_MIN PTHREAD_STACK_MIN
/***************************************************************************
* Name: ithread_t
*
@@ -174,9 +171,7 @@ 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 */
/****************************************************************************
@@ -187,12 +182,7 @@ 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;
#else
/* Read-write locks aren't available: use mutex instead. */
typedef ithread_mutex_t ithread_rwlock_t;
#endif /* UPNP_USE_RWLOCK */
typedef pthread_rwlock_t ithread_rwlock_t;
/****************************************************************************
@@ -340,7 +330,7 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
#define ithread_mutexattr_setkind_np pthread_mutexattr_settype
#else
#define ithread_mutexattr_setkind_np pthread_mutexattr_setkind_np
#endif /* UPNP_USE_RWLOCK */
#endif
/****************************************************************************
* Function: ithread_mutexattr_getkind_np
@@ -365,7 +355,7 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
#define ithread_mutexattr_getkind_np pthread_mutexattr_gettype
#else
#define ithread_mutexattr_getkind_np pthread_mutexattr_getkind_np
#endif /* UPNP_USE_RWLOCK */
#endif
/****************************************************************************
@@ -453,9 +443,7 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
* Always returns 0.
* See man page for pthread_rwlockattr_init
***************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlockattr_init pthread_rwlockattr_init
#endif /* UPNP_USE_RWLOCK */
#define ithread_rwlockattr_init pthread_rwlockattr_init
/****************************************************************************
@@ -471,9 +459,7 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
* Always returns 0.
* See man page for pthread_rwlockattr_destroy
***************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlockattr_destroy pthread_rwlockattr_destroy
#endif /* UPNP_USE_RWLOCK */
#define ithread_rwlockattr_destroy pthread_rwlockattr_destroy
/****************************************************************************
@@ -494,9 +480,7 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
* Returns EINVAL if the kind is not supported.
* See man page for pthread_rwlockattr_setkind_np
*****************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlockatttr_setpshared pthread_rwlockatttr_setpshared
#endif /* UPNP_USE_RWLOCK */
#define ithread_rwlockatttr_setpshared pthread_rwlockatttr_setpshared
/****************************************************************************
@@ -517,9 +501,7 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
* Always returns 0.
* See man page for pthread_rwlockatttr_getpshared
*****************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlockatttr_getpshared pthread_rwlockatttr_getpshared
#endif /* UPNP_USE_RWLOCK */
#define ithread_rwlockatttr_getpshared pthread_rwlockatttr_getpshared
/****************************************************************************
@@ -537,12 +519,8 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
* Always returns 0.
* See man page for pthread_rwlock_init
*****************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlock_init pthread_rwlock_init
#else
/* Read-write locks aren't available: use mutex instead. */
#define ithread_rwlock_init ithread_mutex_init
#endif
#define ithread_rwlock_init pthread_rwlock_init
/****************************************************************************
* Function: ithread_rwlock_rdlock
@@ -558,12 +536,8 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
* Always returns 0.
* See man page for pthread_rwlock_rdlock
*****************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlock_rdlock pthread_rwlock_rdlock
#else
/* Read-write locks aren't available: use mutex instead. */
#define ithread_rwlock_rdlock ithread_mutex_lock
#endif /* UPNP_USE_RWLOCK */
#define ithread_rwlock_rdlock pthread_rwlock_rdlock
/****************************************************************************
* Function: ithread_rwlock_wrlock
@@ -579,12 +553,7 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
* Always returns 0.
* See man page for pthread_rwlock_wrlock
*****************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlock_wrlock pthread_rwlock_wrlock
#else
/* Read-write locks aren't available: use mutex instead. */
#define ithread_rwlock_wrlock ithread_mutex_lock
#endif /* UPNP_USE_RWLOCK */
#define ithread_rwlock_wrlock pthread_rwlock_wrlock
/****************************************************************************
@@ -602,12 +571,7 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
* Always returns 0.
* See man page for pthread_rwlock_unlock
*****************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlock_unlock pthread_rwlock_unlock
#else
/* Read-write locks aren't available: use mutex instead. */
#define ithread_rwlock_unlock ithread_mutex_unlock
#endif /* UPNP_USE_RWLOCK */
#define ithread_rwlock_unlock pthread_rwlock_unlock
/****************************************************************************
@@ -626,12 +590,7 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
* Always returns 0.
* See man page for pthread_rwlock_destroy
*****************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlock_destroy pthread_rwlock_destroy
#else
/* Read-write locks aren't available: use mutex instead. */
#define ithread_rwlock_destroy ithread_mutex_destroy
#endif /* UPNP_USE_RWLOCK */
#define ithread_rwlock_destroy pthread_rwlock_destroy
/****************************************************************************
@@ -745,49 +704,6 @@ 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
@@ -797,7 +713,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
* ithread_attr_t *attr, IGNORED
* void * (start_routine) (void *arg) (start routine)
* void * arg - argument.
* Returns:

View File

@@ -246,7 +246,7 @@ static int SetPolicyType(PolicyType in)
memset(&current, 0, sizeof(current));
sched_getparam(0, &current);
current.sched_priority = sched_get_priority_min(DEFAULT_POLICY);
current.sched_priority = DEFAULT_SCHED_PARAM;
sched_result = sched_setscheduler(0, in, &current);
retVal = (sched_result != -1 || errno == EPERM) ? 0 : errno;
#else
@@ -609,16 +609,12 @@ 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;
}
ithread_attr_init(&attr);
ithread_attr_setstacksize(&attr, tp->attr.stackSize);
rc = ithread_create(&temp, &attr, WorkerThread, tp);
ithread_attr_destroy(&attr);
rc = ithread_create(&temp, NULL, WorkerThread, tp);
if (rc == 0) {
rc = ithread_detach(temp);
while (tp->totalThreads < currentThreads) {
@@ -1178,7 +1174,6 @@ 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;
@@ -1303,28 +1298,6 @@ 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

@@ -19,6 +19,15 @@ 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 \
@@ -44,6 +53,7 @@ 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 \
@@ -67,16 +77,20 @@ libupnp_la_SOURCES = \
src/inc/sysdep.h \
src/inc/unixutil.h \
src/inc/upnpapi.h \
src/inc/upnpclosesocket.h \
src/inc/upnp_timeout.h \
src/inc/uri.h \
src/inc/urlconfig.h \
src/inc/upnputil.h \
src/inc/util.h \
src/inc/utilall.h \
src/inc/uuid.h \
src/inc/VirtualDir.h \
src/inc/webserver.h
# 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
@@ -90,12 +104,13 @@ 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 \
@@ -112,6 +127,15 @@ 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

173
upnp/inc/ActionComplete.h Normal file
View File

@@ -0,0 +1,173 @@
#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 */

96
upnp/inc/ActionRequest.h Normal file
View File

@@ -0,0 +1,96 @@
#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 */

112
upnp/inc/Discovery.h Normal file
View File

@@ -0,0 +1,112 @@
#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 */

62
upnp/inc/Event.h Normal file
View File

@@ -0,0 +1,62 @@
#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 */

74
upnp/inc/EventSubscribe.h Normal file
View File

@@ -0,0 +1,74 @@
#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 */

84
upnp/inc/FileInfo.h Normal file
View File

@@ -0,0 +1,84 @@
#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

@@ -0,0 +1,72 @@
#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

@@ -0,0 +1,91 @@
#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

@@ -0,0 +1,66 @@
#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

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

View File

@@ -24,9 +24,6 @@
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
#include <stdlib.h> /* for size_t */
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@@ -79,22 +76,11 @@ EXPORT_SPEC void UpnpString_assign(
*
* \return The length of the string.
* */
EXPORT_SPEC size_t UpnpString_get_Length(
EXPORT_SPEC int 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.
*
@@ -108,7 +94,7 @@ EXPORT_SPEC const char *UpnpString_get_String(
/*!
* \brief Sets the string from a pointer to char.
*/
EXPORT_SPEC int UpnpString_set_String(
EXPORT_SPEC void UpnpString_set_String(
/*! [in] The \em \b this pointer. */
UpnpString *p,
/*! [in] (char *) to copy from. */
@@ -118,13 +104,13 @@ EXPORT_SPEC int UpnpString_set_String(
/*!
* \brief Sets the string from a pointer to char using a maximum of N chars.
*/
EXPORT_SPEC int UpnpString_set_StringN(
EXPORT_SPEC void 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.*/
size_t n);
int n);
/*!
@@ -135,30 +121,6 @@ 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

@@ -69,6 +69,22 @@
#endif
#ifdef WIN32
#include <iphlpapi.h>
#else
#define SOCKET int
#define INVALID_SOCKET (SOCKET)(~0)
#endif
#ifdef WIN32
#define UpnpCloseSocket closesocket
#define fseeko fseek
#else
#define UpnpCloseSocket close
#endif
#define LINE_SIZE 180
#define NAME_SIZE 256
#define MNFT_NAME_SIZE 64
@@ -401,7 +417,6 @@
#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
@@ -421,7 +436,6 @@
#include "StateVarComplete.h"
#include "StateVarRequest.h"
#include "SubscriptionRequest.h"
#endif /* UPNP_VERSION >= 10800 */
/*!
@@ -621,234 +635,6 @@ 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
@@ -971,7 +757,6 @@ 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
@@ -980,7 +765,6 @@ EXPORT_SPEC int UpnpInit2(
/*! Local Port to listen for incoming connections.
* \c NULL will pick an arbitrary free port. */
unsigned short DestPort);
#endif
/*!
@@ -1030,9 +814,8 @@ 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.
*
@@ -1058,11 +841,10 @@ 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.
*
@@ -1339,8 +1121,6 @@ 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.
*
@@ -2636,12 +2416,7 @@ 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. */
#if UPNP_VERSION < 10800
struct File_Info *info
#else
UpnpFileInfo *info
#endif /* UPNP_VERSION < 10800 */
);
UpnpFileInfo *info);
/*!

View File

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

@@ -43,8 +43,7 @@
#endif
static int initialize_init = 1;
static int initialize_register = 1;
int initialize = 1;
/*! Function pointers to use for displaying formatted strings.
* Set on Initialization of device. */
@@ -68,7 +67,7 @@ ithread_mutex_t display_mutex;
******************************************************************************/
int SampleUtil_Initialize(print_string print_function)
{
if (initialize_init) {
if (initialize) {
ithread_mutexattr_t attr;
ithread_mutexattr_init(&attr);
@@ -81,7 +80,10 @@ int SampleUtil_Initialize(print_string print_function)
gPrintFun = print_function;
ithread_mutex_unlock(&display_mutex);
initialize_init = 0;
initialize = 0;
} else {
SampleUtil_Print("***** SampleUtil_Initialize was called multiple times!\n");
abort();
}
return UPNP_E_SUCCESS;
@@ -97,9 +99,12 @@ int SampleUtil_Initialize(print_string print_function)
******************************************************************************/
int SampleUtil_RegisterUpdateFunction(state_update update_function)
{
if (initialize_register) {
/* Intialize only once. */
static int initialize = 1;
if (initialize) {
gStateUpdateFun = update_function;
initialize_register = 0;
initialize = 0;
}
return UPNP_E_SUCCESS;
@@ -118,9 +123,7 @@ int SampleUtil_Finish()
{
ithread_mutex_destroy(&display_mutex);
gPrintFun = NULL;
gStateUpdateFun = NULL;
initialize_init = 1;
initialize_register = 1;
initialize = 1;
return UPNP_E_SUCCESS;
}
@@ -434,18 +437,28 @@ int SampleUtil_PrintEvent(IN Upnp_EventType EventType, IN void *Event)
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
case UPNP_DISCOVERY_SEARCH_RESULT: {
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);
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)));
break;
}
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
@@ -453,18 +466,25 @@ int SampleUtil_PrintEvent(IN Upnp_EventType EventType, IN void *Event)
break;
/* SOAP */
case UPNP_CONTROL_ACTION_REQUEST: {
struct Upnp_Action_Request *a_event =
(struct Upnp_Action_Request *)Event;
UpnpActionRequest *a_event = (UpnpActionRequest *)Event;
IXML_Document *actionRequestDoc = NULL;
IXML_Document *actionResultDoc = NULL;
char *xmlbuff = NULL;
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);
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("ActRequest = %s\n", xmlbuff);
ixmlFreeDOMString(xmlbuff);
@@ -473,8 +493,9 @@ int SampleUtil_PrintEvent(IN Upnp_EventType EventType, IN void *Event)
} else {
SampleUtil_Print("ActRequest = (null)\n");
}
if (a_event->ActionResult) {
xmlbuff = ixmlPrintNode((IXML_Node *)a_event->ActionResult);
actionResultDoc = UpnpActionRequest_get_ActionResult(a_event);
if (actionResultDoc) {
xmlbuff = ixmlPrintNode((IXML_Node *)actionResultDoc);
if (xmlbuff) {
SampleUtil_Print("ActResult = %s\n", xmlbuff);
ixmlFreeDOMString(xmlbuff);
@@ -486,15 +507,22 @@ int SampleUtil_PrintEvent(IN Upnp_EventType EventType, IN void *Event)
break;
}
case UPNP_CONTROL_ACTION_COMPLETE: {
struct Upnp_Action_Complete *a_event =
(struct Upnp_Action_Complete *)Event;
UpnpActionComplete *a_event = (UpnpActionComplete *)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 = %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);
SampleUtil_Print(
"ErrCode = %d\n"
"CtrlUrl = %s\n",
errCode, ctrlURL);
if (actionRequest) {
xmlbuff = ixmlPrintNode((IXML_Node *)actionRequest);
if (xmlbuff) {
SampleUtil_Print("ActRequest = %s\n", xmlbuff);
ixmlFreeDOMString(xmlbuff);
@@ -503,8 +531,8 @@ int SampleUtil_PrintEvent(IN Upnp_EventType EventType, IN void *Event)
} else {
SampleUtil_Print("ActRequest = (null)\n");
}
if (a_event->ActionResult) {
xmlbuff = ixmlPrintNode((IXML_Node *)a_event->ActionResult);
if (actionResult) {
xmlbuff = ixmlPrintNode((IXML_Node *)actionResult);
if (xmlbuff) {
SampleUtil_Print("ActResult = %s\n", xmlbuff);
ixmlFreeDOMString(xmlbuff);
@@ -516,84 +544,107 @@ int SampleUtil_PrintEvent(IN Upnp_EventType EventType, IN void *Event)
break;
}
case UPNP_CONTROL_GET_VAR_REQUEST: {
struct Upnp_State_Var_Request *sv_event =
(struct Upnp_State_Var_Request *)Event;
UpnpStateVarRequest *sv_event = (UpnpStateVarRequest *)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);
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));
break;
}
case UPNP_CONTROL_GET_VAR_COMPLETE: {
struct Upnp_State_Var_Complete *sv_event =
(struct Upnp_State_Var_Complete *)Event;
UpnpStateVarComplete *sv_event = (UpnpStateVarComplete *)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);
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));
break;
}
/* GENA */
case UPNP_EVENT_SUBSCRIPTION_REQUEST: {
struct Upnp_Subscription_Request *sr_event =
(struct Upnp_Subscription_Request *)Event;
UpnpSubscriptionRequest *sr_event = (UpnpSubscriptionRequest *)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);
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)));
break;
}
case UPNP_EVENT_RECEIVED: {
struct Upnp_Event *e_event = (struct Upnp_Event *)Event;
UpnpEvent *e_event = (UpnpEvent *)Event;
char *xmlbuff = NULL;
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);
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);
ixmlFreeDOMString(xmlbuff);
xmlbuff = NULL;
break;
}
case UPNP_EVENT_RENEWAL_COMPLETE: {
struct Upnp_Event_Subscribe *es_event =
(struct Upnp_Event_Subscribe *)Event;
UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)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);
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));
break;
}
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE: {
struct Upnp_Event_Subscribe *es_event =
(struct Upnp_Event_Subscribe *)Event;
UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)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);
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));
break;
}
case UPNP_EVENT_AUTORENEWAL_FAILED:
case UPNP_EVENT_SUBSCRIPTION_EXPIRED: {
struct Upnp_Event_Subscribe *es_event =
(struct Upnp_Event_Subscribe *)Event;
UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)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);
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));
break;
}
}

View File

@@ -29,14 +29,9 @@
*
******************************************************************************/
#include "upnp_tv_ctrlpt.h"
#include "upnp.h"
/*!
/*
Mutex for protecting the global device list
in a multi-threaded, asynchronous environment.
All functions should lock this mutex before reading
@@ -53,7 +48,7 @@ char *TvServiceType[] = {
};
char *TvServiceName[] = { "Control", "Picture" };
/*!
/*
Global arrays for storing variable names and counts for
TvControl and TvPicture services
*/
@@ -64,12 +59,12 @@ char *TvVarName[TV_SERVICE_SERVCOUNT][TV_MAXVARS] = {
char TvVarCount[TV_SERVICE_SERVCOUNT] =
{ TV_CONTROL_VARCOUNT, TV_PICTURE_VARCOUNT };
/*!
/*
Timeout to request during subscriptions
*/
int default_timeout = 1801;
/*!
/*
The first node in the global device list, or NULL if empty
*/
struct TvDeviceNode *GlobalDeviceList = NULL;
@@ -942,23 +937,25 @@ TvStateUpdate( char *UDN,
*
********************************************************************************/
void TvCtrlPointHandleEvent(
const char *sid,
const UpnpString *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) {
if (strcmp(tmpdevnode->device.TvService[service].SID, sid) == 0) {
aux_sid = UpnpString_get_String(sid);
if (strcmp(tmpdevnode->device.TvService[service].SID, aux_sid) == 0) {
SampleUtil_Print("Received Tv %s Event: %d for SID %s",
TvServiceName[service],
evntkey,
sid);
aux_sid);
TvStateUpdate(
tmpdevnode->device.UDN,
service,
@@ -1060,29 +1057,31 @@ 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: {
struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event;
UpnpDiscovery *d_event = (UpnpDiscovery *)Event;
IXML_Document *DescDoc = NULL;
int ret;
const char *location = NULL;
int errCode = UpnpDiscovery_get_ErrCode(d_event);
if (d_event->ErrCode != UPNP_E_SUCCESS) {
if (errCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Discovery Callback -- %d", d_event->ErrCode);
"Error in Discovery Callback -- %d", errCode);
}
ret = UpnpDownloadXmlDoc(d_event->Location, &DescDoc);
if (ret != UPNP_E_SUCCESS) {
location = UpnpString_get_String(UpnpDiscovery_get_Location(d_event));
errCode = UpnpDownloadXmlDoc(location, &DescDoc);
if (errCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error obtaining device description from %s -- error = %d",
d_event->Location, ret);
location, errCode);
} else {
TvCtrlPointAddDevice(
DescDoc, d_event->Location, d_event->Expires);
DescDoc, location, UpnpDiscovery_get_Expires(d_event));
}
if (DescDoc) {
ixmlDocument_free(DescDoc);
@@ -1094,90 +1093,93 @@ int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void
/* Nothing to do here... */
break;
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE: {
struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event;
UpnpDiscovery *d_event = (UpnpDiscovery *)Event;
int errCode = UpnpDiscovery_get_ErrCode(d_event);
const char *deviceId = UpnpString_get_String(
UpnpDiscovery_get_DeviceID(d_event));
if (d_event->ErrCode != UPNP_E_SUCCESS) {
if (errCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Discovery ByeBye Callback -- %d", d_event->ErrCode);
"Error in Discovery ByeBye Callback -- %d", errCode);
}
SampleUtil_Print("Received ByeBye for Device: %s", d_event->DeviceId);
TvCtrlPointRemoveDevice(d_event->DeviceId);
SampleUtil_Print("Received ByeBye for Device: %s", deviceId);
TvCtrlPointRemoveDevice(deviceId);
SampleUtil_Print("After byebye:");
TvCtrlPointPrintList();
break;
}
/* SOAP Stuff */
case UPNP_CONTROL_ACTION_COMPLETE: {
struct Upnp_Action_Complete *a_event = (struct Upnp_Action_Complete *)Event;
if (a_event->ErrCode != UPNP_E_SUCCESS) {
UpnpActionComplete *a_event = (UpnpActionComplete *)Event;
int errCode = UpnpActionComplete_get_ErrCode(a_event);
if (errCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Action Complete Callback -- %d", a_event->ErrCode);
"Error in Action Complete Callback -- %d",
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: {
struct Upnp_State_Var_Complete *sv_event = (struct Upnp_State_Var_Complete *)Event;
if (sv_event->ErrCode != UPNP_E_SUCCESS) {
UpnpStateVarComplete *sv_event = (UpnpStateVarComplete *)Event;
int errCode = UpnpStateVarComplete_get_ErrCode(sv_event);
if (errCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Get Var Complete Callback -- %d", sv_event->ErrCode);
"Error in Get Var Complete Callback -- %d", errCode);
} else {
TvCtrlPointHandleGetVar(
sv_event->CtrlUrl,
sv_event->StateVarName,
sv_event->CurrentVal);
UpnpString_get_String(UpnpStateVarComplete_get_CtrlUrl(sv_event)),
UpnpString_get_String(UpnpStateVarComplete_get_StateVarName(sv_event)),
UpnpStateVarComplete_get_CurrentVal(sv_event));
}
break;
}
/* GENA Stuff */
case UPNP_EVENT_RECEIVED: {
struct Upnp_Event *e_event = (struct Upnp_Event *)Event;
UpnpEvent *e_event = (UpnpEvent *)Event;
TvCtrlPointHandleEvent(
e_event->Sid,
e_event->EventKey,
e_event->ChangedVariables);
UpnpEvent_get_SID(e_event),
UpnpEvent_get_EventKey(e_event),
UpnpEvent_get_ChangedVariables(e_event));
break;
}
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
case UPNP_EVENT_RENEWAL_COMPLETE: {
struct Upnp_Event_Subscribe *es_event = (struct Upnp_Event_Subscribe *)Event;
UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event;
if (es_event->ErrCode != UPNP_E_SUCCESS) {
errCode = UpnpEventSubscribe_get_ErrCode(es_event);
if (errCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Event Subscribe Callback -- %d", es_event->ErrCode);
"Error in Event Subscribe Callback -- %d", errCode);
} else {
TvCtrlPointHandleSubscribeUpdate(
es_event->PublisherUrl,
es_event->Sid,
es_event->TimeOut);
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
UpnpString_get_String(UpnpEventSubscribe_get_SID(es_event)),
UpnpEventSubscribe_get_TimeOut(es_event));
}
break;
}
case UPNP_EVENT_AUTORENEWAL_FAILED:
case UPNP_EVENT_SUBSCRIPTION_EXPIRED: {
struct Upnp_Event_Subscribe *es_event = (struct Upnp_Event_Subscribe *)Event;
UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event;
int TimeOut = default_timeout;
Upnp_SID newSID;
int ret;
ret = UpnpSubscribe(
errCode = UpnpSubscribe(
ctrlpt_handle,
es_event->PublisherUrl,
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
&TimeOut,
newSID);
if (ret == UPNP_E_SUCCESS) {
if (errCode == UPNP_E_SUCCESS) {
SampleUtil_Print("Subscribed to EventURL with SID=%s", newSID);
TvCtrlPointHandleSubscribeUpdate(
es_event->PublisherUrl,
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
newSID,
TimeOut);
} else {
SampleUtil_Print("Error Subscribing to EventURL -- %d", ret);
SampleUtil_Print("Error Subscribing to EventURL -- %d", errCode);
}
break;
}
@@ -1315,8 +1317,7 @@ int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionP
SampleUtil_Print(
"Initializing UPnP Sdk with\n"
"\tipaddress = %s port = %u\n",
ip_address ? ip_address : "{NULL}",
port);
ip_address, port);
rc = UpnpInit(ip_address, port);
if (rc != UPNP_E_SUCCESS) {
@@ -1335,9 +1336,8 @@ int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionP
SampleUtil_Print(
"UPnP Initialized\n"
"\tipaddress = %s port = %u\n",
ip_address ? ip_address : "{NULL}",
port);
"\tipaddress= %s port = %u\n",
ip_address, port);
SampleUtil_Print("Registering Control Point");
rc = UpnpRegisterClient(TvCtrlPointCallbackEventHandler,

View File

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

View File

@@ -38,10 +38,8 @@
#define DEFAULT_WEB_DIR "./web"
#define DESC_URL_SIZE 200
/*
Device type for tv device
*/
@@ -371,21 +369,23 @@ TvDeviceStateTableInit( IN char *DescDocURL )
* sr_event -- The subscription request event structure
*
*****************************************************************************/
int TvDeviceHandleSubscriptionRequest(IN struct Upnp_Subscription_Request *sr_event)
int TvDeviceHandleSubscriptionRequest(IN const UpnpSubscriptionRequest *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;
// IXML_Document *PropSet = NULL;
// lock state mutex
ithread_mutex_lock(&TVDevMutex);
ithread_mutex_lock( &TVDevMutex );
l_serviceId = sr_event->ServiceId;
l_udn = sr_event->UDN;
l_sid = sr_event->Sid;
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);
@@ -425,7 +425,7 @@ int TvDeviceHandleSubscriptionRequest(IN struct Upnp_Subscription_Request *sr_ev
}
}
ithread_mutex_unlock(&TVDevMutex);
ithread_mutex_unlock( &TVDevMutex );
return 1;
}
@@ -443,52 +443,53 @@ int TvDeviceHandleSubscriptionRequest(IN struct Upnp_Subscription_Request *sr_ev
* cgv_event -- The control get variable request event structure
*
*****************************************************************************/
int TvDeviceHandleGetVarRequest(INOUT struct Upnp_State_Var_Request *cgv_event)
int
TvDeviceHandleGetVarRequest( INOUT UpnpStateVarRequest *cgv_event )
{
unsigned int i = 0;
unsigned int j = 0;
int getvar_succeeded = 0;
unsigned int i = 0;
unsigned int j = 0;
int getvar_succeeded = 0;
cgv_event->CurrentVal = NULL;
UpnpStateVarRequest_set_CurrentVal(cgv_event, NULL);
ithread_mutex_lock(&TVDevMutex);
ithread_mutex_lock( &TVDevMutex );
for (i = 0; i < TV_SERVICE_SERVCOUNT; i++) {
// check udn and service id
const char *devUDN =
cgv_event->DevUDN;
const char *serviceID =
cgv_event->ServiceID;
if (strcmp(devUDN, tv_service_table[i].UDN) == 0 &&
strcmp(serviceID, tv_service_table[i].ServiceId) == 0) {
// check variable name
for (j = 0; j < tv_service_table[i].VariableCount; j++) {
const char *stateVarName =
cgv_event->StateVarName;
if (strcmp(stateVarName,
tv_service_table[i].VariableName[j]) == 0) {
getvar_succeeded = 1;
cgv_event->CurrentVal = ixmlCloneDOMString(
tv_service_table[i].VariableStrVal[j]);
break;
}
}
}
}
if (getvar_succeeded) {
cgv_event->ErrCode = UPNP_E_SUCCESS;
} else {
SampleUtil_Print(
"Error in UPNP_CONTROL_GET_VAR_REQUEST callback:\n"
" Unknown variable name = %s\n",
cgv_event->StateVarName);
cgv_event->ErrCode = 404;
strcpy(cgv_event->ErrStr, "Invalid Variable");
}
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 ) ) {
// 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 ) {
getvar_succeeded = 1;
UpnpStateVarRequest_set_CurrentVal(cgv_event,
tv_service_table[i].VariableStrVal[j] );
break;
}
}
}
}
ithread_mutex_unlock(&TVDevMutex);
if( getvar_succeeded ) {
UpnpStateVarRequest_set_ErrCode(cgv_event, 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" );
}
return cgv_event->ErrCode == UPNP_E_SUCCESS;
ithread_mutex_unlock( &TVDevMutex );
return UpnpStateVarRequest_get_ErrCode(cgv_event) == UPNP_E_SUCCESS;
}
/******************************************************************************
@@ -503,79 +504,86 @@ int TvDeviceHandleGetVarRequest(INOUT struct Upnp_State_Var_Request *cgv_event)
* ca_event -- The control action request event structure
*
*****************************************************************************/
int TvDeviceHandleActionRequest(INOUT struct Upnp_Action_Request *ca_event)
int
TvDeviceHandleActionRequest( INOUT UpnpActionRequest *ca_event )
{
/* Defaults if action not found. */
int action_found = 0;
int i = 0;
int service = -1;
int retCode = 0;
char *errorString = NULL;
const char *devUDN = NULL;
const char *serviceID = NULL;
const char *actionName = NULL;
/*
Defaults if action not found
*/
int action_found = 0;
int i = 0;
int service = -1;
int retCode = 0;
char *errorString = NULL;
const char *devUDN = NULL;
const char *serviceID = NULL;
const char *actionName = NULL;
IXML_Document *actionResult = NULL;
ca_event->ErrCode = 0;
ca_event->ActionResult = NULL;
UpnpActionRequest_set_ErrCode(ca_event, 0);
UpnpActionRequest_set_ActionResult(ca_event, NULL);
devUDN = ca_event->DevUDN;
serviceID = ca_event->ServiceID;
actionName = ca_event->ActionName;
if (strcmp(devUDN, tv_service_table[TV_SERVICE_CONTROL].UDN) == 0 &&
strcmp(serviceID, tv_service_table[TV_SERVICE_CONTROL].ServiceId) == 0) {
/* Request for action in the TvDevice Control Service. */
service = TV_SERVICE_CONTROL;
} else if (strcmp(devUDN, tv_service_table[TV_SERVICE_PICTURE].UDN) == 0 &&
strcmp(serviceID, tv_service_table[TV_SERVICE_PICTURE].ServiceId) == 0) {
/* Request for action in the TvDevice Picture Service. */
service = TV_SERVICE_PICTURE;
}
/* Find and call appropriate procedure based on action name.
* Each action name has an associated procedure stored in the
* service table. These are set at initialization. */
for (i = 0;
i < TV_MAXACTIONS && tv_service_table[service].ActionNames[i] != NULL;
i++) {
if (!strcmp(actionName, tv_service_table[service].ActionNames[i])) {
if (!strcmp(tv_service_table[TV_SERVICE_CONTROL].
VariableStrVal[TV_CONTROL_POWER], "1") ||
!strcmp(actionName, "PowerOn")) {
retCode = tv_service_table[service].actions[i](
ca_event->ActionRequest,
&ca_event->ActionResult,
&errorString);
} else {
errorString = "Power is Off";
retCode = UPNP_E_INTERNAL_ERROR;
}
action_found = 1;
break;
}
}
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 */
service = TV_SERVICE_CONTROL;
} else if( ( strcmp( devUDN, tv_service_table[TV_SERVICE_PICTURE].UDN ) == 0 ) &&
( strcmp( serviceID, tv_service_table[TV_SERVICE_PICTURE].ServiceId ) == 0 ) ) {
/* Request for action in the TvDevice Picture Service */
service = TV_SERVICE_PICTURE;
}
/* Find and call appropriate procedure based on action name
* Each action name has an associated procedure stored in the
* service table. These are set at initialization. */
for( i = 0; i < TV_MAXACTIONS && tv_service_table[service].ActionNames[i] != NULL; i++ ) {
if( !strcmp( actionName, tv_service_table[service].ActionNames[i] ) ) {
if( ( !strcmp( tv_service_table[TV_SERVICE_CONTROL].VariableStrVal[TV_CONTROL_POWER], "1" ) ) ||
( !strcmp( actionName, "PowerOn" ) ) ) {
retCode = tv_service_table[service].actions[i](
UpnpActionRequest_get_ActionRequest(ca_event),
&actionResult,
&errorString );
UpnpActionRequest_set_ActionResult(ca_event, actionResult);
} else {
errorString = "Power is Off";
retCode = UPNP_E_INTERNAL_ERROR;
}
action_found = 1;
break;
}
}
if (!action_found) {
ca_event->ActionResult = NULL;
strcpy(ca_event->ErrStr, "Invalid Action");
ca_event->ErrCode = 401;
} else {
if (retCode == UPNP_E_SUCCESS) {
ca_event->ErrCode = UPNP_E_SUCCESS;
} else {
// copy the error string
strcpy(ca_event->ErrStr, errorString);
switch (retCode) {
case UPNP_E_INVALID_PARAM:
ca_event->ErrCode = 402;
break;
case UPNP_E_INTERNAL_ERROR:
default:
ca_event->ErrCode = 501;
break;
}
}
}
if( !action_found ) {
UpnpActionRequest_set_ActionResult(ca_event, NULL);
UpnpActionRequest_strcpy_ErrStr(ca_event, "Invalid Action" );
UpnpActionRequest_set_ErrCode(ca_event, 401);
} else {
if( retCode == UPNP_E_SUCCESS ) {
UpnpActionRequest_set_ErrCode(ca_event, UPNP_E_SUCCESS);
} else {
// copy the error string
UpnpActionRequest_strcpy_ErrStr(ca_event, errorString );
switch ( retCode ) {
case UPNP_E_INVALID_PARAM:
{
UpnpActionRequest_set_ErrCode(ca_event, 402);
break;
}
case UPNP_E_INTERNAL_ERROR:
default:
{
UpnpActionRequest_set_ErrCode(ca_event, 501);
break;
}
return ca_event->ErrCode;
}
}
}
return UpnpActionRequest_get_ErrCode(ca_event);
}
/******************************************************************************
@@ -1751,43 +1759,43 @@ TvDeviceDecreaseBrightness( IN IXML_Document *in, OUT IXML_Document **out, OUT c
*****************************************************************************/
int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Cookie)
{
switch (EventType) {
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
TvDeviceHandleSubscriptionRequest((struct Upnp_Subscription_Request *)Event);
break;
switch ( EventType ) {
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
TvDeviceHandleSubscriptionRequest((UpnpSubscriptionRequest *)Event);
break;
case UPNP_CONTROL_GET_VAR_REQUEST:
TvDeviceHandleGetVarRequest((struct Upnp_State_Var_Request *)Event);
break;
case UPNP_CONTROL_GET_VAR_REQUEST:
TvDeviceHandleGetVarRequest( (UpnpStateVarRequest *)Event );
break;
case UPNP_CONTROL_ACTION_REQUEST:
TvDeviceHandleActionRequest((struct Upnp_Action_Request *)Event);
break;
case UPNP_CONTROL_ACTION_REQUEST:
TvDeviceHandleActionRequest( (UpnpActionRequest *)Event );
break;
/*
ignore these cases, since this is not a control point
*/
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
case UPNP_DISCOVERY_SEARCH_RESULT:
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
case UPNP_CONTROL_ACTION_COMPLETE:
case UPNP_CONTROL_GET_VAR_COMPLETE:
case UPNP_EVENT_RECEIVED:
case UPNP_EVENT_RENEWAL_COMPLETE:
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
break;
/*
ignore these cases, since this is not a control point
*/
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
case UPNP_DISCOVERY_SEARCH_RESULT:
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
case UPNP_CONTROL_ACTION_COMPLETE:
case UPNP_CONTROL_GET_VAR_COMPLETE:
case UPNP_EVENT_RECEIVED:
case UPNP_EVENT_RENEWAL_COMPLETE:
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
break;
default:
SampleUtil_Print("Error in TvDeviceCallbackEventHandler: unknown event type %d\n",
EventType);
}
default:
SampleUtil_Print( "Error in TvDeviceCallbackEventHandler: unknown event type %d\n",
EventType );
}
/* Print a summary of the event received */
SampleUtil_PrintEvent(EventType, Event);
/* Print a summary of the event received */
SampleUtil_PrintEvent( EventType, Event );
return 0;
return 0;
}
/******************************************************************************
@@ -1799,7 +1807,8 @@ int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Co
* Parameters:
*
*****************************************************************************/
int TvDeviceStop(void)
int
TvDeviceStop()
{
UpnpUnRegisterRootDevice( device_handle );
UpnpFinish();
@@ -1847,8 +1856,7 @@ TvDeviceStart( char *ip_address,
SampleUtil_Print(
"Initializing UPnP Sdk with\n"
"\tipaddress = %s port = %u\n",
ip_address ? ip_address : "{NULL}",
port);
ip_address, port );
ret = UpnpInit( ip_address, port );
if( ret != UPNP_E_SUCCESS ) {
@@ -1862,9 +1870,8 @@ TvDeviceStart( char *ip_address,
SampleUtil_Print(
"UPnP Initialized\n"
"\tipaddress = %s port = %u\n",
ip_address ? ip_address : "{NULL}",
port);
"\tipaddress= %s port = %u\n",
ip_address, port );
if( desc_doc_name == NULL ) {
desc_doc_name = "tvcombodesc.xml";

View File

@@ -239,7 +239,7 @@ int TvDeviceStateTableInit(char*);
* sr_event -- The subscription request event structure
*
*****************************************************************************/
int TvDeviceHandleSubscriptionRequest(struct Upnp_Subscription_Request *);
int TvDeviceHandleSubscriptionRequest(const UpnpSubscriptionRequest *);
/******************************************************************************
* TvDeviceHandleGetVarRequest
@@ -253,7 +253,7 @@ int TvDeviceHandleSubscriptionRequest(struct Upnp_Subscription_Request *);
* cgv_event -- The control get variable request event structure
*
*****************************************************************************/
int TvDeviceHandleGetVarRequest(struct Upnp_State_Var_Request *);
int TvDeviceHandleGetVarRequest(UpnpStateVarRequest *);
/******************************************************************************
* TvDeviceHandleActionRequest
@@ -267,7 +267,7 @@ int TvDeviceHandleGetVarRequest(struct Upnp_State_Var_Request *);
* ca_event -- The control action request event structure
*
*****************************************************************************/
int TvDeviceHandleActionRequest(struct Upnp_Action_Request *);
int TvDeviceHandleActionRequest(UpnpActionRequest *);
/******************************************************************************
* TvDeviceCallbackEventHandler
@@ -623,7 +623,7 @@ int TvDeviceDecreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out, OU
int TvDeviceStart(char * ip_address, unsigned short port,char * desc_doc_name,
char *web_dir_path, print_string pfun);
int TvDeviceStop(void);
int TvDeviceStop();
#ifdef __cplusplus
}

View File

@@ -143,7 +143,8 @@ TvCtrlPointDeleteNode( struct TvDeviceNode *node )
* UDN -- The Unique Device Name for the device to remove
*
********************************************************************************/
int TvCtrlPointRemoveDevice(const char *UDN)
int
TvCtrlPointRemoveDevice(const char *UDN)
{
struct TvDeviceNode *curdevnode;
struct TvDeviceNode *prevdevnode;
@@ -942,23 +943,25 @@ TvStateUpdate( char *UDN,
*
********************************************************************************/
void TvCtrlPointHandleEvent(
const char *sid,
const UpnpString *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) {
if (strcmp(tmpdevnode->device.TvService[service].SID, sid) == 0) {
aux_sid = UpnpString_get_String(sid);
if (strcmp(tmpdevnode->device.TvService[service].SID, aux_sid) == 0) {
SampleUtil_Print("Received Tv %s Event: %d for SID %s",
TvServiceName[service],
evntkey,
sid);
aux_sid);
TvStateUpdate(
tmpdevnode->device.UDN,
service,
@@ -1018,10 +1021,10 @@ void TvCtrlPointHandleSubscribeUpdate(
ithread_mutex_unlock( &DeviceListMutex );
}
void TvCtrlPointHandleGetVar(
const char *controlURL,
const char *varName,
const DOMString varValue)
void
TvCtrlPointHandleGetVar( const char *controlURL,
const char *varName,
const DOMString varValue )
{
struct TvDeviceNode *tmpdevnode;
@@ -1032,9 +1035,9 @@ void TvCtrlPointHandleGetVar(
tmpdevnode = GlobalDeviceList;
while (tmpdevnode) {
for (service = 0; service < TV_SERVICE_SERVCOUNT; service++) {
if (strcmp(tmpdevnode->device.TvService[service].ControlURL, controlURL) == 0) {
if (strcmp(tmpdevnode->device.TvService[service].ControlURL, controlURL ) == 0 ) {
SampleUtil_StateUpdate(
varName, varValue, tmpdevnode->device.UDN, GET_VAR_COMPLETE);
varName, varValue, tmpdevnode->device.UDN, GET_VAR_COMPLETE );
break;
}
}
@@ -1060,127 +1063,150 @@ 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: {
struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event;
UpnpDiscovery *d_event = (UpnpDiscovery *)Event;
IXML_Document *DescDoc = NULL;
int ret;
if (d_event->ErrCode != UPNP_E_SUCCESS) {
const char *location = NULL;
int errCode = UpnpDiscovery_get_ErrCode(d_event);
if (errCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Discovery Callback -- %d", d_event->ErrCode);
"Error in Discovery Callback -- %d", errCode);
}
ret = UpnpDownloadXmlDoc(d_event->Location, &DescDoc);
if (ret != UPNP_E_SUCCESS) {
location = UpnpString_get_String(UpnpDiscovery_get_Location(d_event));
errCode = UpnpDownloadXmlDoc(location, &DescDoc);
if (errCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error obtaining device description from %s -- error = %d",
d_event->Location, ret);
location, errCode);
} else {
TvCtrlPointAddDevice(
DescDoc, d_event->Location, d_event->Expires);
DescDoc, location, UpnpDiscovery_get_Expires(d_event));
}
if (DescDoc) {
if( DescDoc ) {
ixmlDocument_free(DescDoc);
}
TvCtrlPointPrintList();
break;
}
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
/* Nothing to do here... */
break;
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE: {
struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event;
if (d_event->ErrCode != UPNP_E_SUCCESS) {
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));
if (errCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Discovery ByeBye Callback -- %d", d_event->ErrCode);
"Error in Discovery ByeBye Callback -- %d", errCode);
}
SampleUtil_Print("Received ByeBye for Device: %s", d_event->DeviceId);
TvCtrlPointRemoveDevice(d_event->DeviceId);
SampleUtil_Print("Received ByeBye for Device: %s", deviceId);
TvCtrlPointRemoveDevice(deviceId);
SampleUtil_Print("After byebye:");
TvCtrlPointPrintList();
break;
}
/* SOAP Stuff */
case UPNP_CONTROL_ACTION_COMPLETE: {
struct Upnp_Action_Complete *a_event = (struct Upnp_Action_Complete *)Event;
if (a_event->ErrCode != UPNP_E_SUCCESS) {
UpnpActionComplete *a_event = (UpnpActionComplete *)Event;
int errCode = UpnpActionComplete_get_ErrCode(a_event);
if (errCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Action Complete Callback -- %d", a_event->ErrCode);
"Error in Action Complete Callback -- %d",
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: {
struct Upnp_State_Var_Complete *sv_event = (struct Upnp_State_Var_Complete *)Event;
if (sv_event->ErrCode != UPNP_E_SUCCESS) {
case UPNP_CONTROL_GET_VAR_COMPLETE: {
UpnpStateVarComplete *sv_event = (UpnpStateVarComplete *)Event;
int errCode = UpnpStateVarComplete_get_ErrCode(sv_event);
if (errCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Get Var Complete Callback -- %d", sv_event->ErrCode);
"Error in Get Var Complete Callback -- %d",
errCode );
} else {
TvCtrlPointHandleGetVar(
sv_event->CtrlUrl,
sv_event->StateVarName,
sv_event->CurrentVal);
UpnpString_get_String(UpnpStateVarComplete_get_CtrlUrl(sv_event)),
UpnpString_get_String(UpnpStateVarComplete_get_StateVarName(sv_event)),
UpnpStateVarComplete_get_CurrentVal(sv_event) );
}
break;
}
/* GENA Stuff */
case UPNP_EVENT_RECEIVED: {
struct Upnp_Event *e_event = (struct Upnp_Event *)Event;
UpnpEvent *e_event = (UpnpEvent *)Event;
TvCtrlPointHandleEvent(
e_event->Sid,
e_event->EventKey,
e_event->ChangedVariables);
UpnpEvent_get_SID(e_event),
UpnpEvent_get_EventKey(e_event),
UpnpEvent_get_ChangedVariables(e_event));
break;
}
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
case UPNP_EVENT_RENEWAL_COMPLETE: {
struct Upnp_Event_Subscribe *es_event = (struct Upnp_Event_Subscribe *)Event;
if (es_event->ErrCode != UPNP_E_SUCCESS) {
UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event;
errCode = UpnpEventSubscribe_get_ErrCode(es_event);
if (errCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Event Subscribe Callback -- %d", es_event->ErrCode);
"Error in Event Subscribe Callback -- %d",
errCode);
} else {
TvCtrlPointHandleSubscribeUpdate(
es_event->PublisherUrl,
es_event->Sid,
es_event->TimeOut);
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
UpnpString_get_String(UpnpEventSubscribe_get_SID(es_event)),
UpnpEventSubscribe_get_TimeOut(es_event));
}
break;
}
case UPNP_EVENT_AUTORENEWAL_FAILED:
case UPNP_EVENT_SUBSCRIPTION_EXPIRED: {
struct Upnp_Event_Subscribe *es_event = (struct Upnp_Event_Subscribe *)Event;
UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event;
int TimeOut = default_timeout;
Upnp_SID newSID;
int ret;
ret = UpnpSubscribe(
errCode = UpnpSubscribe(
ctrlpt_handle,
es_event->PublisherUrl,
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
&TimeOut,
newSID);
if (ret == UPNP_E_SUCCESS) {
if (errCode == UPNP_E_SUCCESS) {
SampleUtil_Print("Subscribed to EventURL with SID=%s", newSID);
TvCtrlPointHandleSubscribeUpdate(
es_event->PublisherUrl,
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
newSID,
TimeOut);
} else {
SampleUtil_Print("Error Subscribing to EventURL -- %d", ret);
SampleUtil_Print("Error Subscribing to EventURL -- %d", errCode);
}
break;
}
/* ignore these cases, since this is not a device */
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
case UPNP_CONTROL_GET_VAR_REQUEST:
@@ -1315,8 +1341,7 @@ int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionP
SampleUtil_Print(
"Initializing UPnP Sdk with\n"
"\tipaddress = %s port = %u\n",
ip_address ? ip_address : "{NULL}",
port);
ip_address, port);
rc = UpnpInit(ip_address, port);
if (rc != UPNP_E_SUCCESS) {
@@ -1333,9 +1358,8 @@ int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionP
SampleUtil_Print(
"UPnP Initialized\n"
"\tipaddress = %s port = %u\n",
ip_address ? ip_address : "{NULL}",
port);
"\tipaddress= %s port = %u\n",
ip_address, port);
SampleUtil_Print("Registering Control Point");
rc = UpnpRegisterClient(TvCtrlPointCallbackEventHandler,

View File

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

View File

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

View File

@@ -239,7 +239,7 @@ int TvDeviceStateTableInit(char*);
* sr_event -- The subscription request event structure
*
*****************************************************************************/
int TvDeviceHandleSubscriptionRequest(struct Upnp_Subscription_Request *);
int TvDeviceHandleSubscriptionRequest(const UpnpSubscriptionRequest *);
/******************************************************************************
* TvDeviceHandleGetVarRequest
@@ -253,7 +253,7 @@ int TvDeviceHandleSubscriptionRequest(struct Upnp_Subscription_Request *);
* cgv_event -- The control get variable request event structure
*
*****************************************************************************/
int TvDeviceHandleGetVarRequest(struct Upnp_State_Var_Request *);
int TvDeviceHandleGetVarRequest(UpnpStateVarRequest *);
/******************************************************************************
* TvDeviceHandleActionRequest
@@ -267,7 +267,7 @@ int TvDeviceHandleGetVarRequest(struct Upnp_State_Var_Request *);
* ca_event -- The control action request event structure
*
*****************************************************************************/
int TvDeviceHandleActionRequest(struct Upnp_Action_Request *);
int TvDeviceHandleActionRequest(UpnpActionRequest *);
/******************************************************************************
* TvDeviceCallbackEventHandler

View File

@@ -0,0 +1,157 @@
/*!
* \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

@@ -0,0 +1,283 @@
/*!
* \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;
}

396
upnp/src/api/Discovery.c Normal file
View File

@@ -0,0 +1,396 @@
/*!
* \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;
}

121
upnp/src/api/Event.c Normal file
View File

@@ -0,0 +1,121 @@
/*!
* \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

@@ -0,0 +1,159 @@
/*!
* \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);
}

179
upnp/src/api/FileInfo.c Normal file
View File

@@ -0,0 +1,179 @@
/*!
* \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

@@ -0,0 +1,170 @@
/*!
* \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

@@ -0,0 +1,254 @@
/*!
* \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

@@ -0,0 +1,157 @@
/*!
* \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,19 +28,6 @@
#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.
*
@@ -128,78 +115,42 @@ void UpnpString_assign(UpnpString *p, const UpnpString *q)
}
size_t UpnpString_get_Length(const UpnpString *p)
int 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;
}
int UpnpString_set_String(UpnpString *p, const char *s)
void 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(q);
((struct SUpnpString *)p)->m_string = q;
error_handler1:
return q != NULL;
((struct SUpnpString *)p)->m_length = strlen(s);
((struct SUpnpString *)p)->m_string = strdup(s);
}
int UpnpString_set_StringN(UpnpString *p, const char *s, size_t n)
void UpnpString_set_StringN(UpnpString *p, const char *s, int n)
{
char *q = strndup(s, n);
if (!q) goto error_handler1;
free(((struct SUpnpString *)p)->m_string);
((struct SUpnpString *)p)->m_length = strlen(q);
((struct SUpnpString *)p)->m_string = q;
error_handler1:
return q != NULL;
((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;
}
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

@@ -122,7 +122,6 @@ ithread_mutex_t GlobalClientSubscribeMutex;
/*! rwlock to synchronize handles (root device or control point handle). */
ithread_rwlock_t GlobalHndRWLock;
/*! Mutex to synchronize the uuid creation process. */
ithread_mutex_t gUUIDMutex;
@@ -283,7 +282,6 @@ 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);
@@ -490,7 +488,7 @@ exit_function:
return retVal;
}
#ifdef UPNP_ENABLE_IPV6
int UpnpInit2(const char *IfName, unsigned short DestPort)
{
int retVal;
@@ -535,9 +533,8 @@ int UpnpInit2(const char *IfName, unsigned short DestPort)
exit_function:
ithread_mutex_unlock(&gSDKInitMutex);
return retVal;
return UPNP_E_SUCCESS;
}
#endif
int UpnpFinish(void)
@@ -623,7 +620,7 @@ unsigned short UpnpGetServerPort(void)
return LOCAL_PORT_V4;
}
#ifdef UPNP_ENABLE_IPV6
unsigned short UpnpGetServerPort6(void)
{
if (UpnpSdkInit != 1) {
@@ -632,7 +629,6 @@ unsigned short UpnpGetServerPort6(void)
return LOCAL_PORT_V6;
}
#endif
char *UpnpGetServerIpAddress(void)
@@ -781,10 +777,8 @@ int UpnpRegisterRootDevice(
HInfo->DeviceList = NULL;
HInfo->ServiceList = NULL;
HInfo->DescDocument = NULL;
#ifdef INCLUDE_CLIENT_APIS
ListInit(&HInfo->SsdpSearchList, NULL, NULL);
HInfo->ClientSubList = NULL;
#endif /* INCLUDE_CLIENT_APIS */
CLIENTONLY( ListInit(&HInfo->SsdpSearchList, NULL, NULL); )
CLIENTONLY( HInfo->ClientSubList = NULL; )
HInfo->MaxSubscriptions = UPNP_INFINITE;
HInfo->MaxSubscriptionTimeOut = UPNP_INFINITE;
HInfo->DeviceAf = AF_INET;
@@ -794,9 +788,7 @@ int UpnpRegisterRootDevice(
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice: error downloading Document: %d\n",
retVal);
#ifdef INCLUDE_CLIENT_APIS
ListDestroy(&HInfo->SsdpSearchList, 0);
#endif /* INCLUDE_CLIENT_APIS */
CLIENTONLY( ListDestroy(&HInfo->SsdpSearchList, 0); )
FreeHandle(*Hnd);
goto exit_function;
}
@@ -808,9 +800,7 @@ int UpnpRegisterRootDevice(
HInfo->DeviceList =
ixmlDocument_getElementsByTagName(HInfo->DescDocument, "device");
if (!HInfo->DeviceList) {
#ifdef INCLUDE_CLIENT_APIS
ListDestroy(&HInfo->SsdpSearchList, 0);
#endif /* INCLUDE_CLIENT_APIS */
CLIENTONLY( ListDestroy(&HInfo->SsdpSearchList, 0); )
ixmlDocument_free(HInfo->DescDocument);
FreeHandle(*Hnd);
UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
@@ -946,10 +936,8 @@ int UpnpRegisterRootDevice2(
HInfo->MaxAge = DEFAULT_MAXAGE;
HInfo->DeviceList = NULL;
HInfo->ServiceList = NULL;
#ifdef INCLUDE_CLIENT_APIS
ListInit(&HInfo->SsdpSearchList, NULL, NULL);
HInfo->ClientSubList = NULL;
#endif /* INCLUDE_CLIENT_APIS */
CLIENTONLY( ListInit(&HInfo->SsdpSearchList, NULL, NULL); )
CLIENTONLY( HInfo->ClientSubList = NULL; )
HInfo->MaxSubscriptions = UPNP_INFINITE;
HInfo->MaxSubscriptionTimeOut = UPNP_INFINITE;
HInfo->DeviceAf = AF_INET;
@@ -962,9 +950,7 @@ int UpnpRegisterRootDevice2(
HInfo->DeviceList =
ixmlDocument_getElementsByTagName( HInfo->DescDocument, "device" );
if (!HInfo->DeviceList) {
#ifdef INCLUDE_CLIENT_APIS
ListDestroy(&HInfo->SsdpSearchList, 0);
#endif /* INCLUDE_CLIENT_APIS */
CLIENTONLY( ListDestroy(&HInfo->SsdpSearchList, 0); )
ixmlDocument_free(HInfo->DescDocument);
FreeHandle(*Hnd);
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
@@ -1024,16 +1010,17 @@ 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 ||
@@ -1042,14 +1029,17 @@ 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;
@@ -1057,11 +1047,13 @@ 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;
@@ -1070,6 +1062,7 @@ 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);
@@ -1079,18 +1072,15 @@ int UpnpRegisterRootDevice3(
HInfo->DeviceList = NULL;
HInfo->ServiceList = NULL;
HInfo->DescDocument = NULL;
#ifdef INCLUDE_CLIENT_APIS
ListInit(&HInfo->SsdpSearchList, NULL, NULL);
HInfo->ClientSubList = NULL;
#endif /* INCLUDE_CLIENT_APIS */
CLIENTONLY( ListInit(&HInfo->SsdpSearchList, NULL, NULL); )
CLIENTONLY( HInfo->ClientSubList = NULL; )
HInfo->MaxSubscriptions = UPNP_INFINITE;
HInfo->MaxSubscriptionTimeOut = UPNP_INFINITE;
HInfo->DeviceAf = AddressFamily;
retVal = UpnpDownloadXmlDoc(HInfo->DescURL, &(HInfo->DescDocument));
if (retVal != UPNP_E_SUCCESS) {
#ifdef INCLUDE_CLIENT_APIS
ListDestroy(&HInfo->SsdpSearchList, 0);
#endif /* INCLUDE_CLIENT_APIS */
CLIENTONLY( ListDestroy(&HInfo->SsdpSearchList, 0); )
FreeHandle(*Hnd);
goto exit_function;
}
@@ -1102,9 +1092,7 @@ int UpnpRegisterRootDevice3(
HInfo->DeviceList = ixmlDocument_getElementsByTagName(
HInfo->DescDocument, "device");
if (!HInfo->DeviceList) {
#ifdef INCLUDE_CLIENT_APIS
ListDestroy(&HInfo->SsdpSearchList, 0);
#endif /* INCLUDE_CLIENT_APIS */
CLIENTONLY( ListDestroy(&HInfo->SsdpSearchList, 0); )
ixmlDocument_free(HInfo->DescDocument);
FreeHandle(*Hnd);
UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
@@ -1196,9 +1184,7 @@ int UpnpUnRegisterRootDevice(UpnpDevice_Handle Hnd)
ixmlNodeList_free( HInfo->ServiceList );
ixmlDocument_free( HInfo->DescDocument );
#ifdef INCLUDE_CLIENT_APIS
ListDestroy( &HInfo->SsdpSearchList, 0 );
#endif /* INCLUDE_CLIENT_APIS */
CLIENTONLY( ListDestroy( &HInfo->SsdpSearchList, 0 ); )
#ifdef INTERNAL_WEB_SERVER
if( HInfo->aliasInstalled ) {
@@ -3317,7 +3303,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");
@@ -3325,84 +3311,84 @@ void UpnpThreadDistribution(struct UpnpNonblockParam *Param)
switch (Param->FunName) {
#if EXCLUDE_GENA == 0
case SUBSCRIBE: {
struct Upnp_Event_Subscribe Evt;
UpnpEventSubscribe *evt = UpnpEventSubscribe_new();
/* Cast away constness */
/*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(
UpnpString *Sid = (UpnpString *)UpnpEventSubscribe_get_SID(evt);
UpnpEventSubscribe_strcpy_PublisherUrl(evt, Param->Url);
errCode = genaSubscribe(
Param->Handle,
Url,
UpnpEventSubscribe_get_PublisherUrl(evt),
(int *)&Param->TimeOut,
Sid);
strcpy(Evt.PublisherUrl, Param->Url);
Evt.TimeOut = Param->TimeOut;
Param->Fun(UPNP_EVENT_SUBSCRIBE_COMPLETE, &Evt, Param->Cookie);
UpnpString_delete(Sid);
UpnpString_delete(Url);
UpnpEventSubscribe_set_ErrCode(evt, errCode);
UpnpEventSubscribe_set_TimeOut(evt, Param->TimeOut);
Param->Fun(UPNP_EVENT_SUBSCRIBE_COMPLETE, evt, Param->Cookie);
UpnpEventSubscribe_delete(evt);
free(Param);
break;
}
case UNSUBSCRIBE: {
struct Upnp_Event_Subscribe Evt;
UpnpString *Sid = UpnpString_new();
UpnpString_set_String(Sid, Param->SubsId);
Evt.ErrCode = genaUnSubscribe(
UpnpEventSubscribe *evt = UpnpEventSubscribe_new();
UpnpEventSubscribe_strcpy_SID(evt, Param->SubsId);
errCode = genaUnSubscribe(
Param->Handle,
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);
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);
free(Param);
break;
}
case RENEW: {
struct Upnp_Event_Subscribe Evt;
UpnpString *Sid = UpnpString_new();
UpnpString_set_String(Sid, Param->SubsId);
Evt.ErrCode = genaRenewSubscription(
UpnpEventSubscribe *evt = UpnpEventSubscribe_new();
UpnpEventSubscribe_strcpy_SID(evt, Param->SubsId);
errCode = genaRenewSubscription(
Param->Handle,
Sid,
UpnpEventSubscribe_get_SID(evt),
&Param->TimeOut);
Evt.TimeOut = Param->TimeOut;
strcpy((char *)Evt.Sid, UpnpString_get_String(Sid));
Param->Fun(UPNP_EVENT_RENEWAL_COMPLETE, &Evt, Param->Cookie);
UpnpString_delete(Sid);
UpnpEventSubscribe_set_ErrCode(evt, errCode);
UpnpEventSubscribe_set_TimeOut(evt, Param->TimeOut);
Param->Fun(UPNP_EVENT_RENEWAL_COMPLETE, evt, Param->Cookie);
UpnpEventSubscribe_delete(evt);
free(Param);
break;
}
#endif /* EXCLUDE_GENA == 0 */
#if EXCLUDE_SOAP == 0
case ACTION: {
struct Upnp_Action_Complete Evt;
Evt.ActionResult = NULL;
Evt.ErrCode = SoapSendAction(
UpnpActionComplete *Evt = UpnpActionComplete_new();
IXML_Document *actionResult = NULL;
int errCode = SoapSendAction(
Param->Url,
Param->ServiceType,
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);
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);
free(Param);
UpnpActionComplete_delete(Evt);
break;
}
case STATUS: {
struct Upnp_State_Var_Complete Evt;
Evt.ErrCode = SoapGetServiceVarStatus(
UpnpStateVarComplete *Evt = UpnpStateVarComplete_new();
DOMString currentVal = NULL;
int errCode = SoapGetServiceVarStatus(
Param->Url,
Param->VarName,
&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);
&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);
free(Param);
UpnpStateVarComplete_delete(Evt);
break;
}
#endif /* EXCLUDE_SOAP == 0 */

View File

@@ -42,6 +42,7 @@
#ifdef INCLUDE_CLIENT_APIS
#include "EventSubscribe.h"
#include "gena.h"
#include "httpparser.h"
#include "httpreadwrite.h"
@@ -64,7 +65,7 @@ static void GenaAutoRenewSubscription(
IN void *input)
{
upnp_timeout *event = (upnp_timeout *) input;
struct Upnp_Event_Subscribe *sub_struct = (struct Upnp_Event_Subscribe *)event->Event;
UpnpEventSubscribe *sub_struct = (UpnpEventSubscribe *)event->Event;
void *cookie;
Upnp_FunPtr callback_fun;
struct Handle_Info *handle_info;
@@ -72,23 +73,21 @@ 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");
sub_struct->ErrCode = UPNP_E_SUCCESS;
UpnpEventSubscribe_set_ErrCode(sub_struct, UPNP_E_SUCCESS);
send_callback = 1;
eventType = UPNP_EVENT_SUBSCRIPTION_EXPIRED;
} else {
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, "GENA AUTO RENEW");
timeout = sub_struct->TimeOut;
UpnpString_set_String(tmpSID, sub_struct->Sid);
timeout = UpnpEventSubscribe_get_TimeOut(sub_struct);
errCode = genaRenewSubscription(
event->handle,
tmpSID,
UpnpEventSubscribe_get_SID(sub_struct),
&timeout);
sub_struct->ErrCode = errCode;
sub_struct->TimeOut = timeout;
UpnpEventSubscribe_set_ErrCode(sub_struct, errCode);
UpnpEventSubscribe_set_TimeOut(sub_struct, timeout);
if (errCode != UPNP_E_SUCCESS &&
errCode != GENA_E_BAD_SID &&
errCode != GENA_E_BAD_HANDLE) {
@@ -116,7 +115,6 @@ static void GenaAutoRenewSubscription(
free_upnp_timeout(event);
end_function:
UpnpString_delete(tmpSID);
return;
}
@@ -135,19 +133,17 @@ static int ScheduleGenaAutoRenew(
/*! [in] Subscription being renewed. */
IN ClientSubscription *sub)
{
struct Upnp_Event_Subscribe *RenewEventStruct = NULL;
UpnpEventSubscribe *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 = (struct Upnp_Event_Subscribe *)malloc(sizeof (struct Upnp_Event_Subscribe));
RenewEventStruct = UpnpEventSubscribe_new();
if (RenewEventStruct == NULL) {
return_code = UPNP_E_OUTOF_MEMORY;
goto end_function;
@@ -161,11 +157,10 @@ static int ScheduleGenaAutoRenew(
}
// schedule expire event
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);
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));
// RenewEvent->EventType=UPNP_EVENT_SUBSCRIPTION_EXPIRE;
RenewEvent->handle = client_handle;
@@ -188,11 +183,12 @@ static int ScheduleGenaAutoRenew(
goto end_function;
}
UpnpClientSubscription_set_RenewEventId(sub, RenewEvent->eventId);
GenlibClientSubscription_set_RenewEventId(sub, RenewEvent->eventId);
return_code = GENA_SUCCESS;
end_function:
return return_code;
}
@@ -320,18 +316,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->sin6_addr) || strlen(gIF_IPV6_ULA_GUA) == 0) ?
gIF_IPV6 : gIF_IPV6_ULA_GUA,
((IN6_IS_ADDR_LINKLOCAL(DestAddr6))||(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,
@@ -402,7 +398,7 @@ static int gena_subscribe(
int genaUnregisterClient(UpnpClient_Handle client_handle)
{
ClientSubscription *sub_copy = UpnpClientSubscription_new();
ClientSubscription *sub_copy = GenlibClientSubscription_new();
int return_code = UPNP_E_SUCCESS;
struct Handle_Info *handle_info = NULL;
http_parser_t response;
@@ -419,16 +415,16 @@ int genaUnregisterClient(UpnpClient_Handle client_handle)
return_code = UPNP_E_SUCCESS;
break;
}
UpnpClientSubscription_assign(sub_copy, handle_info->ClientSubList);
GenlibClientSubscription_assign(sub_copy, handle_info->ClientSubList);
RemoveClientSubClientSID(
&handle_info->ClientSubList,
UpnpClientSubscription_get_SID(sub_copy));
GenlibClientSubscription_get_SID(sub_copy));
HandleUnlock();
return_code = gena_unsubscribe(
UpnpClientSubscription_get_EventURL(sub_copy),
UpnpClientSubscription_get_ActualSID(sub_copy),
GenlibClientSubscription_get_EventURL(sub_copy),
GenlibClientSubscription_get_ActualSID(sub_copy),
&response);
if (return_code == 0) {
httpmsg_destroy(&response.msg);
@@ -440,7 +436,7 @@ int genaUnregisterClient(UpnpClient_Handle client_handle)
HandleUnlock();
exit_function:
UpnpClientSubscription_delete(sub_copy);
GenlibClientSubscription_delete(sub_copy);
return return_code;
}
@@ -453,7 +449,7 @@ int genaUnSubscribe(
ClientSubscription *sub = NULL;
int return_code = GENA_SUCCESS;
struct Handle_Info *handle_info;
ClientSubscription *sub_copy = UpnpClientSubscription_new();
ClientSubscription *sub_copy = GenlibClientSubscription_new();
http_parser_t response;
// validate handle and sid
@@ -469,12 +465,12 @@ int genaUnSubscribe(
return_code = GENA_E_BAD_SID;
goto exit_function;
}
UpnpClientSubscription_assign(sub_copy, sub);
GenlibClientSubscription_assign(sub_copy, sub);
HandleUnlock();
return_code = gena_unsubscribe(
UpnpClientSubscription_get_EventURL(sub_copy),
UpnpClientSubscription_get_ActualSID(sub_copy),
GenlibClientSubscription_get_EventURL(sub_copy),
GenlibClientSubscription_get_ActualSID(sub_copy),
&response);
if (return_code == 0) {
httpmsg_destroy(&response.msg);
@@ -491,7 +487,7 @@ int genaUnSubscribe(
HandleUnlock();
exit_function:
UpnpClientSubscription_delete(sub_copy);
GenlibClientSubscription_delete(sub_copy);
return return_code;
}
#endif /* INCLUDE_CLIENT_APIS */
@@ -505,7 +501,7 @@ int genaSubscribe(
UpnpString *out_sid)
{
int return_code = GENA_SUCCESS;
ClientSubscription *newSubscription = UpnpClientSubscription_new();
ClientSubscription *newSubscription = GenlibClientSubscription_new();
uuid_upnp uid;
Upnp_SID temp_sid;
Upnp_SID temp_sid2;
@@ -556,11 +552,11 @@ int genaSubscribe(
return_code = UPNP_E_OUTOF_MEMORY;
goto error_handler;
}
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);
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);
handle_info->ClientSubList = newSubscription;
// schedule expiration event
@@ -570,7 +566,7 @@ error_handler:
if (return_code != UPNP_E_SUCCESS) {
UpnpString_delete(ActualSID);
UpnpString_delete(EventURL);
UpnpClientSubscription_delete(newSubscription);
GenlibClientSubscription_delete(newSubscription);
}
HandleUnlock();
SubscribeUnlock();
@@ -587,7 +583,7 @@ int genaRenewSubscription(
{
int return_code = GENA_SUCCESS;
ClientSubscription *sub = NULL;
ClientSubscription *sub_copy = UpnpClientSubscription_new();
ClientSubscription *sub_copy = GenlibClientSubscription_new();
struct Handle_Info *handle_info;
UpnpString *ActualSID = UpnpString_new();
ThreadPoolJob tempJob;
@@ -613,22 +609,22 @@ int genaRenewSubscription(
// remove old events
if (TimerThreadRemove(
&gTimerThread,
UpnpClientSubscription_get_RenewEventId(sub),
GenlibClientSubscription_get_RenewEventId(sub),
&tempJob) == 0 ) {
free_upnp_timeout((upnp_timeout *)tempJob.arg);
}
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, "REMOVED AUTO RENEW EVENT");
UpnpClientSubscription_set_RenewEventId(sub, -1);
UpnpClientSubscription_assign(sub_copy, sub);
GenlibClientSubscription_set_RenewEventId(sub, -1);
GenlibClientSubscription_assign(sub_copy, sub);
HandleUnlock();
return_code = gena_subscribe(
UpnpClientSubscription_get_EventURL(sub_copy),
GenlibClientSubscription_get_EventURL(sub_copy),
TimeOut,
UpnpClientSubscription_get_ActualSID(sub_copy),
GenlibClientSubscription_get_ActualSID(sub_copy),
ActualSID);
HandleLock();
@@ -659,21 +655,21 @@ int genaRenewSubscription(
}
// store actual sid
UpnpClientSubscription_set_ActualSID(sub, ActualSID);
GenlibClientSubscription_set_ActualSID(sub, ActualSID);
// start renew subscription timer
return_code = ScheduleGenaAutoRenew(client_handle, *TimeOut, sub);
if (return_code != GENA_SUCCESS) {
RemoveClientSubClientSID(
&handle_info->ClientSubList,
UpnpClientSubscription_get_SID(sub));
GenlibClientSubscription_get_SID(sub));
}
free_client_subscription(sub_copy);
HandleUnlock();
exit_function:
UpnpString_delete(ActualSID);
UpnpClientSubscription_delete(sub_copy);
GenlibClientSubscription_delete(sub_copy);
return return_code;
}
@@ -682,7 +678,7 @@ void gena_process_notification_event(
SOCKINFO *info,
http_message_t *event)
{
struct Upnp_Event event_struct;
UpnpEvent *event_struct = UpnpEvent_new();
IXML_Document *ChangedVars = NULL;
int eventKey;
token sid;
@@ -691,7 +687,6 @@ void gena_process_notification_event(
void *cookie;
Upnp_FunPtr callback;
UpnpClient_Handle client_handle;
const UpnpString *tmpSID = NULL;
memptr sid_hdr;
memptr nt_hdr,
@@ -788,10 +783,9 @@ void gena_process_notification_event(
error_respond(info, HTTP_OK, event);
// fill event struct
tmpSID = UpnpClientSubscription_get_SID(subscription);
strcpy(event_struct.Sid, UpnpString_get_String(tmpSID));
event_struct.EventKey = eventKey;
event_struct.ChangedVariables = ChangedVars;
UpnpEvent_set_EventKey(event_struct, eventKey);
UpnpEvent_set_ChangedVariables(event_struct, ChangedVars);
UpnpEvent_set_SID(event_struct, GenlibClientSubscription_get_SID(subscription));
// copy callback
callback = handle_info->Callback;
@@ -803,10 +797,11 @@ 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,76 +178,70 @@ 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 UPNP error */
conn_fd = http_Connect( destination_url, &url );
if( conn_fd < 0 ) {
return conn_fd; // return UPNP error
}
return conn_fd;
}
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;
}
ret_code = sock_init(&info, conn_fd);
if (ret_code) {
sock_destroy(&info, SD_BOTH);
timeout = HTTP_DEFAULT_TIMEOUT;
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);
// 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 UPNP_E_OUTOF_MEMORY;
}
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;
}
timeout = HTTP_DEFAULT_TIMEOUT;
sock_destroy( &info, SD_BOTH ); //should shutdown completely
//when closing socket
// sock_destroy( &info,SD_RECEIVE);
membuffer_destroy( &start_msg );
/* 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;
return UPNP_E_SUCCESS;
}
@@ -342,12 +336,7 @@ static void genaNotifyThread(
struct Handle_Info *handle_info;
ThreadPoolJob job;
/* 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();
HandleReadLock();
//validate context
if( GetHandleInfo( in->device_handle, &handle_info ) != HND_DEVICE ) {
@@ -365,27 +354,18 @@ 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();
@@ -1210,7 +1190,7 @@ void gena_process_subscription_request(
SOCKINFO *info,
http_message_t *request)
{
struct Upnp_Subscription_Request request_struct;
UpnpSubscriptionRequest *request_struct = UpnpSubscriptionRequest_new();
Upnp_SID temp_sid;
int return_code = 1;
int time_out = 1801;
@@ -1369,9 +1349,9 @@ void gena_process_subscription_request(
service->TotalSubscriptions++;
// finally generate callback for init table dump
request_struct.ServiceId = service->serviceId;
request_struct.UDN = service->UDN;
strcpy((char *)request_struct.Sid, sub->sid);
UpnpSubscriptionRequest_strcpy_ServiceId(request_struct, service->serviceId);
UpnpSubscriptionRequest_strcpy_UDN(request_struct, service->UDN);
UpnpSubscriptionRequest_strcpy_SID(request_struct, sub->sid);
// copy callback
callback_fun = handle_info->Callback;
@@ -1382,10 +1362,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:
return;
UpnpSubscriptionRequest_delete(request_struct);
}

View File

@@ -0,0 +1,200 @@
/************************************************************************
* 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,33 +1,3 @@
/*******************************************************************************
*
* 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
@@ -49,194 +19,14 @@
#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 = UpnpClientSubscription_get_RenewEventId(sub);
UpnpClientSubscription_strcpy_ActualSID(sub, "");
UpnpClientSubscription_strcpy_EventURL(sub, "");
int renewEventId = GenlibClientSubscription_get_RenewEventId(sub);
GenlibClientSubscription_strcpy_ActualSID(sub, "");
GenlibClientSubscription_strcpy_EventURL(sub, "");
if (renewEventId != -1) {
// do not remove timer event of copy
// invalid timer event id
@@ -245,7 +35,7 @@ void free_client_subscription(ClientSubscription *sub)
free_upnp_timeout(event);
}
}
UpnpClientSubscription_set_RenewEventId(sub, -1);
GenlibClientSubscription_set_RenewEventId(sub, -1);
}
}
@@ -255,8 +45,8 @@ void freeClientSubList(ClientSubscription *list)
ClientSubscription *next;
while (list) {
free_client_subscription(list);
next = UpnpClientSubscription_get_Next(list);
UpnpClientSubscription_delete(list);
next = GenlibClientSubscription_get_Next(list);
GenlibClientSubscription_delete(list);
list = next;
}
}
@@ -270,20 +60,20 @@ void RemoveClientSubClientSID(ClientSubscription **head, const UpnpString *sid)
while (finger) {
found = !strcmp(
UpnpString_get_String(sid),
UpnpClientSubscription_get_SID_cstr(finger));
GenlibClientSubscription_get_SID_cstr(finger));
if (found) {
if (previous) {
UpnpClientSubscription_set_Next(previous,
UpnpClientSubscription_get_Next(finger));
GenlibClientSubscription_set_Next(previous,
GenlibClientSubscription_get_Next(finger));
} else {
*head = UpnpClientSubscription_get_Next(finger);
*head = GenlibClientSubscription_get_Next(finger);
}
UpnpClientSubscription_set_Next(finger, NULL);
GenlibClientSubscription_set_Next(finger, NULL);
freeClientSubList(finger);
finger = NULL;
} else {
previous = finger;
finger = UpnpClientSubscription_get_Next(finger);
finger = GenlibClientSubscription_get_Next(finger);
}
}
}
@@ -295,12 +85,12 @@ ClientSubscription *GetClientSubClientSID(ClientSubscription *head, const UpnpSt
int found = 0;
while (next) {
found = !strcmp(
UpnpClientSubscription_get_SID_cstr(next),
GenlibClientSubscription_get_SID_cstr(next),
UpnpString_get_String(sid));
if(found) {
break;
} else {
next = UpnpClientSubscription_get_Next(next);
next = GenlibClientSubscription_get_Next(next);
}
}
@@ -313,11 +103,11 @@ ClientSubscription *GetClientSubActualSID(ClientSubscription *head, token *sid)
ClientSubscription *next = head;
while (next) {
if (!memcmp(
UpnpClientSubscription_get_ActualSID_cstr(next),
GenlibClientSubscription_get_ActualSID_cstr(next),
sid->buff, sid->size)) {
break;
} else {
next = UpnpClientSubscription_get_Next(next);
next = GenlibClientSubscription_get_Next(next);
}
}
@@ -325,5 +115,5 @@ ClientSubscription *GetClientSubActualSID(ClientSubscription *head, token *sid)
}
#endif /* INCLUDE_CLIENT_APIS */
#endif /* INCLUDE_CLIENT_APIS */

File diff suppressed because it is too large Load Diff

View File

@@ -72,6 +72,7 @@ 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
@@ -112,7 +113,9 @@ str_int_entry Http_Header_Names[NUM_HTTP_HEADER_NAMES] = {
};
/***********************************************************************/
/************* scanner *************/
/***********************************************************************/
#define TOKCHAR_CR 0xD
@@ -131,11 +134,13 @@ 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;
}
/************************************************************************
@@ -150,9 +155,10 @@ static UPNP_INLINE void scanner_init(OUT scanner_t *scanner, IN membuffer *bufpt
*
* 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;
}
/************************************************************************
@@ -167,9 +173,10 @@ static UPNP_INLINE xboolean 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 );
}
/************************************************************************
@@ -184,9 +191,10 @@ static UPNP_INLINE xboolean 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 ) );
}
/************************************************************************
@@ -201,7 +209,8 @@ static UPNP_INLINE xboolean 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;
@@ -235,10 +244,10 @@ static UPNP_INLINE xboolean 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
@@ -379,11 +388,57 @@ static parse_status_t scanner_get_token(
*
* 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
@@ -398,14 +453,15 @@ static UPNP_INLINE char *scanner_get_str(IN 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;
}
/************************************************************************
@@ -420,7 +476,8 @@ static int httpmsg_compare(void *param1, void *param2)
*
* Note :
************************************************************************/
static void httpheader_free(void *msg)
static void
httpheader_free( void *msg )
{
http_header_t *hdr = ( http_header_t * ) msg;
@@ -441,7 +498,8 @@ static void 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;
@@ -463,7 +521,8 @@ void 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 );
@@ -491,9 +550,9 @@ void 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;
@@ -528,21 +587,27 @@ http_header_t *httpmsg_find_hdr_str(
*
* 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;
@@ -551,6 +616,12 @@ http_header_t *httpmsg_find_hdr(
return data;
}
/***********************************************************************/
/************* http_parser_t **************/
/***********************************************************************/
/************************************************************************
* Function : skip_blank_lines
*
@@ -563,23 +634,26 @@ http_header_t *httpmsg_find_hdr(
*
* 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));
if (status == PARSE_OK) {
/* pushback a non-whitespace token */
scanner->cursor -= token.length;
}
// skip ws, crlf
do {
status = scanner_get_token( scanner, &token, &tok_type );
} while( status == PARSE_OK &&
( tok_type == TT_WHITESPACE || tok_type == TT_CRLF ) );
return status;
if( status == PARSE_OK ) {
// pushback a non-whitespace token
scanner->cursor -= token.length;
//scanner_pushback( scanner, token.length );
}
return status;
}
/************************************************************************
@@ -597,7 +671,8 @@ static UPNP_INLINE int 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;
@@ -651,9 +726,9 @@ static UPNP_INLINE int 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;
@@ -717,9 +792,9 @@ static UPNP_INLINE parse_status_t match_non_ws_string(
*
* 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;
@@ -808,10 +883,10 @@ static UPNP_INLINE parse_status_t match_raw_value(
* 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;
@@ -895,6 +970,36 @@ 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
*
@@ -1649,6 +1754,140 @@ 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
*
@@ -1670,9 +1909,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.entity_offset;
parser->msg.msg.length - parser->entity_start_position;
if( parser->msg.entity.length < parser->content_length ) {
// more data to be read
@@ -1680,8 +1919,7 @@ 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.entity_offset +
parser->msg.msg.buf[parser->entity_start_position +
parser->content_length] = '\0';
}
// save entity length
@@ -2066,7 +2304,6 @@ 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;
}
@@ -2162,6 +2399,10 @@ parser_append( INOUT http_parser_t * parser,
return parser_parse( parser );
}
/************************************************************************
********** end of parser ***********
************************************************************************/
/************************************************************************
* Function: raw_to_int
*
@@ -2174,7 +2415,9 @@ 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;
@@ -2211,7 +2454,9 @@ int raw_to_int(IN memptr *raw_value, IN int base)
* 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;
@@ -2254,7 +2499,8 @@ int raw_find_str(IN memptr *raw_value, IN const char *str)
* 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;
@@ -2298,5 +2544,5 @@ void print_http_headers(http_message_t *hmsg)
/* NNS: node = dlist_next( &hmsg->headers, node ); */
}
}
#endif /* DEBUG */
#endif

File diff suppressed because it is too large Load Diff

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -871,10 +871,8 @@ getServiceList( IXML_Node * node,
( *end ) = current;
return head;
} else {
( *end ) = NULL;
} else
return NULL;
}
}
@@ -920,8 +918,7 @@ getAllServiceList( IXML_Node * node,
if( head ) {
end->next =
getServiceList( currentDevice, &next_end, URLBase );
if ( next_end )
end = next_end;
end = next_end;
} else
head = getServiceList( currentDevice, &end, URLBase );

View File

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

View File

@@ -0,0 +1,199 @@
#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,6 +13,7 @@ extern "C" {
#endif
#include "ClientSubscription.h"
#include "service_table.h"
#include "upnp.h"
#include "UpnpString.h"
@@ -32,154 +33,6 @@ 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

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

@@ -42,7 +42,7 @@
#include "LinkedList.h"
#include "membuffer.h"
#include "uri.h"
#include "upnputil.h"
#include "util.h"
////// private types ////////////
@@ -200,8 +200,7 @@ typedef struct // http_message_t
// private fields
membuffer msg; // entire raw message
char *urlbuf; // storage for url string
size_t entity_offset;
char *urlbuf; // storage for url string
} http_message_t;
typedef struct // http_parser_t

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,135 +1,133 @@
/**************************************************************************
*
* 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);
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 : 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:
****************************************************************************/
* 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

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

View File

@@ -47,17 +47,15 @@
#ifdef WIN32
#else /* WIN32 */
#else
#include <syslog.h>
#include <sys/socket.h>
#ifndef __APPLE__
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#endif /* __APPLE__ */
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <sys/time.h>
#include <arpa/inet.h>
#endif /* WIN32 */
#endif
/* Enumeration to define all different types of ssdp searches */
@@ -90,6 +88,7 @@ typedef enum SsdpCmdType{
#define SSDP_IPV6_SITELOCAL "FF05::C"
#define SSDP_PORT 1900
#define NUM_TRY 3
#define NUM_COPY 1
#define THREAD_LIMIT 50
#define COMMAND_LEN 300
@@ -139,15 +138,6 @@ 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;
@@ -184,12 +174,9 @@ typedef struct
/* globals */
#ifdef INCLUDE_CLIENT_APIS
extern SOCKET gSsdpReqSocket4;
#ifdef UPNP_ENABLE_IPV6
extern SOCKET gSsdpReqSocket6;
#endif /* UPNP_ENABLE_IPV6 */
#endif /* INCLUDE_CLIENT_APIS */
CLIENTONLY(extern SOCKET gSsdpReqSocket4;);
CLIENTONLY(extern SOCKET gSsdpReqSocket6;);
typedef int (*ParserFun)(char *, Event *);
@@ -223,12 +210,12 @@ int Make_Socket_NoBlocking (int sock);
***************************************************************************/
#ifdef INCLUDE_DEVICE_APIS
void ssdp_handle_device_request(
IN http_message_t *hmsg,
IN struct sockaddr *dest_addr);
IN http_message_t* hmsg,
IN struct sockaddr* dest_addr );
#else
static inline void ssdp_handle_device_request(
IN http_message_t *hmsg,
IN struct sockaddr* dest_addr) {}
IN http_message_t* hmsg,
IN struct sockaddr* dest_addr ) {}
#endif
/************************************************************************
@@ -252,10 +239,10 @@ static inline void ssdp_handle_device_request(
*
***************************************************************************/
void ssdp_handle_ctrlpt_msg(
IN http_message_t *hmsg,
IN struct sockaddr *dest_addr,
IN http_message_t* hmsg,
IN struct sockaddr* dest_addr,
IN xboolean timeout,
IN void *cookie);
IN void* cookie );
/************************************************************************
* Function : unique_service_name

View File

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

View File

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

View File

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

34
upnp/src/inc/utilall.h Normal file
View File

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

View File

@@ -1,33 +1,33 @@
/**************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************/
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2003 Intel Corporation
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither name of Intel Corporation nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#ifndef GENLIB_NET_HTTP_WEBSERVER_H
#define GENLIB_NET_HTTP_WEBSERVER_H
@@ -48,85 +48,99 @@ struct SendInstruction
int IsRangeActive;
int IsTrailers;
char RangeHeader[200];
char AcceptLanguageHeader[200];
off_t RangeOffset;
/*! Read from local source and send on the network. */
off_t ReadSendSize;
/*! Recv from the network and write into local file. */
long RecvWriteSize;
/* Later few more member could be added depending
* on the requirement.*/
off_t ReadSendSize; // Read from local source and send on the network.
long RecvWriteSize; // Recv from the network and write into local file.
//Later few more member could be added depending on the requirement.
};
/*!
* \brief Initilialize the different documents. Initialize the memory
* for root directory for web server. Call to initialize global XML
* document. Sets bWebServerState to WEB_SERVER_ENABLED.
/************************************************************************
* Function: web_server_init
*
* \note alias_content is not freed here
* Parameters:
* none
*
* \return
* \li \c 0 - OK
* \li \c UPNP_E_OUTOF_MEMORY
*/
int web_server_init(void);
/*!
* \brief Release memory allocated for the global web server root
* directory and the global XML document. Resets the flag bWebServerState
* to WEB_SERVER_DISABLED.
*/
void web_server_destroy(void);
/*!
* \brief Replaces current alias with the given alias. To remove the current
* alias, set alias_name to NULL.
* 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
*
* \note alias_content is not freed here
* Returns:
* 0 - OK
* UPNP_E_OUTOF_MEMORY: note: alias_content is not freed here
************************************************************************/
int web_server_init();
/************************************************************************
* Function: web_server_destroy
*
* \return
* \li \c 0 - OK
* \li \c UPNP_E_OUTOF_MEMORY
*/
* 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_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] Webserver name of alias; created by caller and freed by caller
* (doesn't even have to be malloc()d. */
const char* alias_name,
/*! [in] The xml doc; this is allocated by the caller; and freed by
* the web server. */
const char* alias_content,
/*! [in] Length of alias body in bytes. */
size_t alias_content_length,
/*! [in] Time when the contents of alias were last changed (local time). */
time_t last_modified);
IN const char* alias_name,
IN const char* alias_content, IN size_t alias_content_length,
IN time_t last_modified);
/*!
* \brief Assign the path specfied by the input const char* root_dir parameter
* to the global Document root directory. Also check for path names ending
* in '/'.
/************************************************************************
* Function: web_server_set_root_dir
*
* \return Integer.
*/
int web_server_set_root_dir(
/*! [in] String having the root directory for the document. */
const char* root_dir);
* Parameters:
* IN const char* root_dir ; String having the root directory for the
* document
*
* Description: Assign the path specfied by the IN const char* root_dir
* parameter to the global Document root directory. Also check for
* path names ending in '/'
*
* Returns:
* int
************************************************************************/
int web_server_set_root_dir(IN const char* root_dir);
/*!
* \brief Main entry point into web server; Handles HTTP GET and HEAD
* requests.
*/
void web_server_callback(
/*! [in] . */
http_parser_t *parser,
/*! [in] . */
http_message_t *req,
/*! [in,out] . */
SOCKINFO *info);
/************************************************************************
* 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,6 +47,8 @@
#define QUERY_STATE_VAR_URN "urn:schemas-upnp-org:control-1-0"
#include "ActionRequest.h"
#include "httpparser.h"
#include "httpreadwrite.h"
#include "parsetools.h"
@@ -581,8 +583,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 char device_udn[LINE_SIZE] : Device UDN string
* OUT char service_id[LINE_SIZE] : Service ID string
* OUT UpnpString *device_udn : Device UDN string
* OUT UpnpString *service_id : Service ID string
* OUT Upnp_FunPtr *callback : callback function of the device
* application
* OUT void** cookie : cookie stored by device application
@@ -602,8 +604,8 @@ get_device_info( IN http_message_t *request,
IN int isQuery,
IN IXML_Document *actionDoc,
IN int AddressFamily,
OUT char device_udn[LINE_SIZE],
OUT char service_id[LINE_SIZE],
OUT UpnpString *device_udn,
OUT UpnpString *service_id,
OUT Upnp_FunPtr *callback,
OUT void **cookie )
{
@@ -668,8 +670,8 @@ get_device_info( IN http_message_t *request,
}
}
namecopy( service_id, serv_info->serviceId );
namecopy( device_udn, serv_info->UDN );
UpnpString_set_String( device_udn, serv_info->UDN );
UpnpString_set_String( service_id, serv_info->serviceId );
*callback = device_info->Callback;
*cookie = device_info->Cookie;
@@ -859,10 +861,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;
@@ -874,53 +876,50 @@ 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,
variable.DevUDN,
variable.ServiceID,
&soap_event_callback,
&cookie);
request, 1, xml_doc,
info->foreign_sockaddr.ss_family,
(UpnpString *)UpnpStateVarRequest_get_DevUDN(variable),
(UpnpString *)UpnpStateVarRequest_get_ServiceID(variable),
&soap_event_callback,
&cookie);
if( err_code != 0 ) {
send_error_response( info, SOAP_INVALID_VAR,
Soap_Invalid_Var, request );
return;
}
linecopy( variable.ErrStr, "" );
variable.ErrCode = UPNP_E_SUCCESS;
namecopy( variable.StateVarName, var_name );
variable.CurrentVal = NULL;
variable.CtrlPtIPAddr = info->foreign_sockaddr;
UpnpStateVarRequest_set_ErrCode(variable, UPNP_E_SUCCESS);
UpnpStateVarRequest_strcpy_StateVarName(variable, var_name);
UpnpStateVarRequest_set_CtrlPtIPAddr(variable, (struct sockaddr *)&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( variable.CurrentVal == NULL ) {
if( UpnpStateVarRequest_get_CurrentVal(variable) == NULL ) {
err_code = SOAP_ACTION_FAILED;
err_str = Soap_Action_Failed;
send_error_response( info, SOAP_INVALID_VAR, Soap_Invalid_Var, request );
return;
}
if( variable.ErrCode != UPNP_E_SUCCESS ) {
if( strlen( variable.ErrStr ) > 0 ) {
if( UpnpStateVarRequest_get_ErrCode(variable) != UPNP_E_SUCCESS ) {
if( UpnpString_get_Length(UpnpStateVarRequest_get_ErrStr(variable)) > 0 ) {
err_code = SOAP_INVALID_VAR;
err_str = Soap_Invalid_Var;
} else {
err_code = variable.ErrCode;
err_str = variable.ErrStr;
err_code = UpnpStateVarRequest_get_ErrCode(variable);
err_str = UpnpStateVarRequest_get_ErrStr_cstr(variable);
}
send_error_response( info, err_code, err_str, request );
return;
}
// send response
send_var_query_response( info, variable.CurrentVal, request );
ixmlFreeDOMString( variable.CurrentVal );
send_var_query_response( info, UpnpStateVarRequest_get_CurrentVal(variable), request );
UpnpStateVarRequest_delete(variable);
}
/****************************************************************************
@@ -948,15 +947,16 @@ handle_invoke_action( IN SOCKINFO * info,
IN IXML_Document * xml_doc )
{
char save_char;
IXML_Document *resp_node = NULL;
struct Upnp_Action_Request action;
UpnpActionRequest *action = UpnpActionRequest_new();
UpnpString *devUDN = UpnpString_new();
UpnpString *serviceID = UpnpString_new();
IXML_Document *actionRequestDoc = NULL;
IXML_Document *actionResultDoc = NULL;
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, &resp_node ) == -1 ) {
if( get_action_node( xml_doc, action_name.buf, &actionRequestDoc ) == -1 ) {
goto error_handler;
}
// get device info for action event
@@ -975,55 +975,58 @@ handle_invoke_action( IN SOCKINFO * info,
0,
xml_doc,
info->foreign_sockaddr.ss_family,
action.DevUDN,
action.ServiceID,
&soap_event_callback,
devUDN,
serviceID,
&soap_event_callback,
&cookie );
if( err_code != UPNP_E_SUCCESS ) {
goto error_handler;
}
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;
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);
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);
if( action.ErrCode != UPNP_E_SUCCESS ) {
if( strlen( action.ErrStr ) <= 0 ) {
err_code = UpnpActionRequest_get_ErrCode(action);
if (err_code != UPNP_E_SUCCESS) {
err_str = UpnpActionRequest_get_ErrStr_cstr(action);
if (strlen(err_str) <= 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
if( action.ActionResult == NULL ) {
actionResultDoc = UpnpActionRequest_get_ActionResult(action);
if (actionResultDoc == NULL) {
err_code = SOAP_ACTION_FAILED;
err_str = Soap_Action_Failed;
goto error_handler;
}
// send response
send_action_response( info, action.ActionResult, request );
send_action_response(info, actionResultDoc, 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);
}
/****************************************************************************

135
upnp/src/soap/soaplib.h Normal file
View File

@@ -0,0 +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.
//
///////////////////////////////////////////////////////////////////////////
#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

@@ -0,0 +1,115 @@
#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

@@ -0,0 +1,43 @@
#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

@@ -33,7 +33,7 @@
#include "config.h"
#include "upnputil.h"
#include "util.h"
#ifdef INCLUDE_CLIENT_APIS
@@ -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,10 @@
***************************************************************************/
void send_search_result(IN void *data)
{
ResultData *temp = ( ResultData * ) data;
SSDPResultData *temp = (SSDPResultData *)data;
temp->ctrlpt_callback(UPNP_DISCOVERY_SEARCH_RESULT, &temp->param, temp->cookie);
free(temp);
SSDPResultData_Callback(temp);
SSDPResultData_delete(temp);
}
/************************************************************************
@@ -114,7 +114,9 @@ void ssdp_handle_ctrlpt_msg(
struct Handle_Info *ctrlpt_info = NULL;
memptr hdr_value;
xboolean is_byebye; // byebye or alive
struct Upnp_Discovery param;
UpnpDiscovery *param = UpnpDiscovery_new();
int expires;
int ret;
SsdpEvent event;
xboolean nt_found;
xboolean usn_found;
@@ -126,7 +128,7 @@ void ssdp_handle_ctrlpt_msg(
ListNode *node = NULL;
SsdpSearchArg *searchArg = NULL;
int matched = 0;
ResultData *threadData = NULL;
SSDPResultData *threadData = NULL;
ThreadPoolJob job;
// we are assuming that there can be only one client supported at a time
@@ -135,7 +137,7 @@ void ssdp_handle_ctrlpt_msg(
if ( GetClientHandleInfo( &handle, &ctrlpt_info ) != HND_CLIENT ) {
HandleUnlock();
return;
goto end_ssdp_handle_ctrlpt_msg;
}
// copy
ctrlpt_callback = ctrlpt_info->Callback;
@@ -145,52 +147,45 @@ void ssdp_handle_ctrlpt_msg(
// search timeout
if ( timeout ) {
ctrlpt_callback( UPNP_DISCOVERY_SEARCH_TIMEOUT, NULL, cookie );
return;
goto end_ssdp_handle_ctrlpt_msg;
}
param.ErrCode = UPNP_E_SUCCESS;
UpnpDiscovery_set_ErrCode(param, UPNP_E_SUCCESS);
// MAX-AGE
// assume error
param.Expires = -1;
expires = -1;
UpnpDiscovery_set_Expires(param, expires);
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;
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;
}
}
// DATE
param.Date[0] = '\0';
if ( httpmsg_find_hdr( hmsg, HDR_DATE, &hdr_value ) != NULL ) {
linecopylen( param.Date, hdr_value.buf, hdr_value.length );
UpnpDiscovery_strcpy_Date(param, hdr_value.buf);
}
// dest addr
memcpy(&param.DestAddr, dest_addr, sizeof(struct sockaddr_in) );
UpnpDiscovery_set_DestAddr(param, dest_addr);
// EXT
param.Ext[0] = '\0';
if ( httpmsg_find_hdr( hmsg, HDR_EXT, &hdr_value ) != NULL ) {
linecopylen( param.Ext, hdr_value.buf, hdr_value.length );
UpnpDiscovery_strncpy_Ext(param, hdr_value.buf, hdr_value.length);
}
// LOCATION
param.Location[0] = '\0';
if ( httpmsg_find_hdr( hmsg, HDR_LOCATION, &hdr_value ) != NULL ) {
linecopylen( param.Location, hdr_value.buf, hdr_value.length );
UpnpDiscovery_strncpy_Location(param, hdr_value.buf, hdr_value.length);
}
// SERVER / USER-AGENT
param.Os[0] = '\0';
if ( httpmsg_find_hdr( hmsg, HDR_SERVER, &hdr_value ) != NULL ||
httpmsg_find_hdr( hmsg, HDR_USER_AGENT, &hdr_value ) != NULL ) {
linecopylen( param.Os, hdr_value.buf, hdr_value.length );
UpnpDiscovery_strncpy_Os(param, 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';
@@ -213,29 +208,32 @@ void ssdp_handle_ctrlpt_msg(
}
if ( nt_found || usn_found ) {
strcpy( param.DeviceId, event.UDN );
strcpy( param.DeviceType, event.DeviceType );
strcpy( param.ServiceType, event.ServiceType );
UpnpDiscovery_strcpy_DeviceID( param, event.UDN);
UpnpDiscovery_strcpy_DeviceType( param, event.DeviceType);
UpnpDiscovery_strcpy_ServiceType(param, 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 ) {
return; // error; NTS header not found
// error; NTS header not found
goto end_ssdp_handle_ctrlpt_msg;
}
if ( memptr_cmp( &hdr_value, "ssdp:alive" ) == 0 ) {
is_byebye = FALSE;
} else if( memptr_cmp( &hdr_value, "ssdp:byebye" ) == 0 ) {
is_byebye = TRUE;
} else {
return; // bad value
// bad value
goto end_ssdp_handle_ctrlpt_msg;
}
if ( is_byebye ) {
// check device byebye
if( !nt_found || !usn_found ) {
return; // bad byebye
// bad byebye
goto end_ssdp_handle_ctrlpt_msg;
}
event_type = UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE;
} else {
@@ -244,17 +242,19 @@ void ssdp_handle_ctrlpt_msg(
// only. Expires should be greater than 1800 (30 mins)
if( !nt_found ||
!usn_found ||
strlen( param.Location ) == 0 || param.Expires <= 0 ) {
return; // bad advertisement
UpnpString_get_Length(UpnpDiscovery_get_Location(param)) == 0 ||
UpnpDiscovery_get_Expires(param) <= 0 ) {
// bad advertisement
goto end_ssdp_handle_ctrlpt_msg;
}
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,15 +264,18 @@ void ssdp_handle_ctrlpt_msg(
hdr_value.buf[hdr_value.length] = save_char;
}
if( hmsg->status_code != HTTP_OK ||
param.Expires <= 0 ||
strlen( param.Location ) == 0 || !usn_found || !st_found ) {
return; // bad reply
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;
}
// check each current search
HandleLock();
if( GetClientHandleInfo( &handle, &ctrlpt_info ) != HND_CLIENT ) {
HandleUnlock();
return;
goto end_ssdp_handle_ctrlpt_msg;
}
node = ListHead( &ctrlpt_info->SsdpSearchList );
@@ -318,16 +321,14 @@ void ssdp_handle_ctrlpt_msg(
if (matched) {
// schedule call back
threadData =
( ResultData * ) malloc( sizeof( ResultData ) );
threadData = SSDPResultData_new();
if (threadData != NULL) {
threadData->param = param;
threadData->cookie = searchArg->cookie;
threadData->ctrlpt_callback = ctrlpt_callback;
TPJobInit( &job, ( start_routine ) send_search_result,
threadData );
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);
TPJobSetPriority(&job, MED_PRIORITY);
TPJobSetFreeFunction(&job, (free_routine)free);
TPJobSetFreeFunction(&job, (free_routine)SSDPResultData_delete);
ThreadPoolAdd(&gRecvThreadPool, &job, NULL);
}
}
@@ -335,8 +336,10 @@ 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);
}
@@ -510,6 +513,7 @@ 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];
@@ -594,14 +598,12 @@ 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) {
@@ -611,13 +613,11 @@ 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,38 +625,28 @@ int SearchByTarget(
while (NumCopy < NUM_SSDP_COPY) {
sendto(gSsdpReqSocket6,
ReqBufv6UlaGua, strlen(ReqBufv6UlaGua), 0,
(struct sockaddr *)&__ss_v6,
sizeof(struct sockaddr_in));
(struct sockaddr *)&__ss_v6, socklen);
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,
sizeof(struct sockaddr_in6));
ReqBufv6, strlen(ReqBufv6), 0,
(struct sockaddr *)&__ss_v6, socklen);
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,
sizeof(struct sockaddr_in));
(struct sockaddr *)&__ss_v4, socklen);
NumCopy++;
imillisleep(SSDP_PAUSE);
}

View File

@@ -1,30 +1,30 @@
/**************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
* 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:
* 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
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************/
@@ -102,9 +102,9 @@ advertiseAndReplyThread( IN void *data )
* 1 if successful else appropriate error
***************************************************************************/
#ifdef INCLUDE_DEVICE_APIS
void ssdp_handle_device_request(
IN http_message_t *hmsg,
IN struct sockaddr *dest_addr)
void
ssdp_handle_device_request( IN http_message_t *hmsg,
IN struct sockaddr *dest_addr )
{
#define MX_FUDGE_FACTOR 10
@@ -223,12 +223,12 @@ NewRequestHandler( IN struct sockaddr *DestAddr,
char errorBuffer[ERROR_BUFFER_LEN];
SOCKET ReplySock;
int socklen = sizeof( struct sockaddr_storage );
int NumCopy;
int Index;
unsigned long replyAddr = inet_addr( gIF_IPV4 );
int ttl = 4; // a/c to UPNP Spec
int hops = 1;
char buf_ntop[64];
int ret = UPNP_E_SUCCESS;
ReplySock = socket( DestAddr->sa_family, SOCK_DGRAM, 0 );
if ( ReplySock == -1 ) {
@@ -247,7 +247,6 @@ 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));
@@ -258,34 +257,38 @@ 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++ ) {
int rc;
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
">>> SSDP SEND to %s >>>\n%s\n",
buf_ntop, *( RqPacket + Index ) );
rc = sendto( ReplySock, *( RqPacket + Index ),
strlen( *( RqPacket + Index ) ),
0, DestAddr, socklen );
if (rc == -1) {
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
// The reason to keep this loop is purely historical/documentation,
// according to section 9.2 of HTTPU spec:
//
// "If a multicast resource would send a response(s) to any copy of the
// request, it SHOULD send its response(s) to each copy of the request
// it receives. It MUST NOT repeat its response(s) per copy of the
// request."
//
// http://www.upnp.org/download/draft-goland-http-udp-04.txt
//
// So, NUM_COPY has been changed from 2 to 1.
NumCopy = 0;
while( NumCopy < NUM_COPY ) {
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
"SSDP_LIB: New Request Handler:"
"Error in socket(): %s\n", errorBuffer );
ret = UPNP_E_SOCKET_WRITE;
goto end_NewRequestHandler;
">>> SSDP SEND to %s >>>\n%s\n",
buf_ntop, *( RqPacket + Index ) );
rc = sendto( ReplySock, *( RqPacket + Index ),
strlen( *( RqPacket + Index ) ),
0, DestAddr, socklen );
imillisleep( SSDP_PAUSE );
++NumCopy;
}
}
end_NewRequestHandler:
shutdown( ReplySock, SD_BOTH );
UpnpCloseSocket( ReplySock );
return ret;
return UPNP_E_SUCCESS;
}
/**
@@ -402,7 +405,6 @@ void CreateServicePacket(
}
} else if (msg_type == MSGTYPE_ADVERTISEMENT ||
msg_type == MSGTYPE_SHUTDOWN) {
char *host = NULL;
if (msg_type == MSGTYPE_ADVERTISEMENT) {
nts = "ssdp:alive";
} else {
@@ -411,6 +413,7 @@ 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 {
@@ -483,7 +486,7 @@ DeviceAdvertisement( IN char *DevType,
//char Mil_Nt[LINE_SIZE]
char Mil_Usn[LINE_SIZE];
char *msgs[3];
int ret_code = UPNP_E_SUCCESS;
int ret_code;
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
"In function DeviceAdvertisement\n" );
@@ -732,7 +735,7 @@ ServiceAdvertisement( IN char *Udn,
{
char Mil_Usn[LINE_SIZE];
char *szReq[1];
int RetVal = UPNP_E_SUCCESS;
int RetVal;
struct sockaddr_storage __ss;
struct sockaddr_in* DestAddr4 = (struct sockaddr_in*)&__ss;
struct sockaddr_in6* DestAddr6 = (struct sockaddr_in6*)&__ss;
@@ -841,7 +844,7 @@ ServiceShutdown( IN char *Udn,
struct sockaddr_storage __ss;
struct sockaddr_in* DestAddr4 = (struct sockaddr_in*)&__ss;
struct sockaddr_in6* DestAddr6 = (struct sockaddr_in6*)&__ss;
int RetVal = UPNP_E_SUCCESS;
int RetVal;
memset( &__ss, 0, sizeof(__ss) );
if( AddressFamily == AF_INET ) {
@@ -907,7 +910,7 @@ DeviceShutdown( IN char *DevType,
struct sockaddr_in6* DestAddr6 = (struct sockaddr_in6*)&__ss;
char *msgs[3];
char Mil_Usn[LINE_SIZE];
int ret_code = UPNP_E_SUCCESS;
int ret_code;
msgs[0] = NULL;
msgs[1] = NULL;

View File

@@ -50,36 +50,26 @@
#define MAX_TIME_TOREAD 45
#ifdef INCLUDE_CLIENT_APIS
SOCKET gSsdpReqSocket4 = INVALID_SOCKET;
#ifdef UPNP_ENABLE_IPV6
SOCKET gSsdpReqSocket6 = INVALID_SOCKET;
#endif /* UPNP_ENABLE_IPV6 */
#endif /* INCLUDE_CLIENT_APIS */
CLIENTONLY( SOCKET gSsdpReqSocket4 = INVALID_SOCKET; )
CLIENTONLY( SOCKET gSsdpReqSocket6 = INVALID_SOCKET; )
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;
#ifdef INCLUDE_CLIENT_APIS
/* socket for sending search requests and receiving search replies */
int ssdpReqSock;
#endif /* INCLUDE_CLIENT_APIS */
// socket for sending search requests and receiving search replies
CLIENTONLY( int ssdpReqSock; )
};
#ifdef INCLUDE_DEVICE_APIS
@@ -135,7 +125,6 @@ int AdvertiseAndReply(
const DOMString tmpStr;
char SERVER[200];
const DOMString dbgStr;
int NumCopy = 0;
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Inside AdvertiseAndReply with AdFlag = %d\n", AdFlag);
@@ -153,251 +142,244 @@ int AdvertiseAndReply(
get_sdk_info(SERVER);
/* parse the device list and send advertisements/replies */
while (NumCopy == 0 || (AdFlag && NumCopy < NUM_SSDP_COPY)) {
if (NumCopy != 0)
imillisleep(SSDP_PAUSE);
NumCopy++;
for (i = 0;; i++) {
for (i = 0;; i++) {
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Entering new device list with i = %d\n\n", i);
tmpNode = ixmlNodeList_item(SInfo->DeviceList, i);
if (!tmpNode) {
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Entering new device list with i = %d\n\n", i);
tmpNode = ixmlNodeList_item(SInfo->DeviceList, i);
if (!tmpNode) {
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Exiting new device list with i = %d\n\n", i);
break;
}
dbgStr = ixmlNode_getNodeName(tmpNode);
"Exiting new device list with i = %d\n\n", i);
break;
}
dbgStr = ixmlNode_getNodeName(tmpNode);
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"Extracting device type once for %s\n", dbgStr);
ixmlNodeList_free(nodeList);
nodeList = ixmlElement_getElementsByTagName(
(IXML_Element *)tmpNode, "deviceType");
if (!nodeList) continue;
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"Extracting device type once for %s\n", dbgStr);
ixmlNodeList_free(nodeList);
nodeList = ixmlElement_getElementsByTagName(
(IXML_Element *)tmpNode, "deviceType");
if (!nodeList) continue;
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Extracting UDN for %s\n", dbgStr);
dbgStr = ixmlNode_getNodeName(tmpNode);
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Extracting device type\n");
tmpNode2 = ixmlNodeList_item(nodeList, 0);
if (!tmpNode2) continue;
textNode = ixmlNode_getFirstChild(tmpNode2);
if (!textNode) continue;
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Extracting device type \n");
tmpStr = ixmlNode_getNodeValue(textNode);
if (!tmpStr) continue;
strcpy(devType, tmpStr);
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"Extracting device type = %s\n", devType);
if (!tmpNode) {
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Extracting UDN for %s\n", dbgStr);
dbgStr = ixmlNode_getNodeName(tmpNode);
"TempNode is NULL\n");
}
dbgStr = ixmlNode_getNodeName(tmpNode);
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Extracting device type\n");
tmpNode2 = ixmlNodeList_item(nodeList, 0);
if (!tmpNode2) continue;
textNode = ixmlNode_getFirstChild(tmpNode2);
if (!textNode) continue;
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Extracting device type \n");
tmpStr = ixmlNode_getNodeValue(textNode);
if (!tmpStr) continue;
strcpy(devType, tmpStr);
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"Extracting device type = %s\n", devType);
if (!tmpNode) {
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"TempNode is NULL\n");
}
dbgStr = ixmlNode_getNodeName(tmpNode);
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Extracting UDN for %s\n", dbgStr);
ixmlNodeList_free(nodeList);
nodeList = ixmlElement_getElementsByTagName(
(IXML_Element *)tmpNode, "UDN");
if (!nodeList) {
UpnpPrintf(UPNP_CRITICAL, API, __FILE__,
__LINE__, "UDN not found!\n");
continue;
}
tmpNode2 = ixmlNodeList_item(nodeList, 0);
if (!tmpNode2) {
UpnpPrintf(UPNP_CRITICAL, API, __FILE__,
__LINE__, "UDN not found!\n");
continue;
}
textNode = ixmlNode_getFirstChild(tmpNode2);
if (!textNode) {
UpnpPrintf(UPNP_CRITICAL, API, __FILE__,
__LINE__, "UDN not found!\n");
continue;
}
tmpStr = ixmlNode_getNodeValue(textNode);
if (!tmpStr) {
UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
"UDN not found!\n");
continue;
}
strcpy(UDNstr, tmpStr);
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"Sending UDNStr = %s \n", UDNstr);
if (AdFlag) {
/* send the device advertisement */
if (AdFlag == 1) {
DeviceAdvertisement(devType, i == 0,
UDNstr, SInfo->DescURL, Exp, SInfo->DeviceAf );
} else {
/* AdFlag == -1 */
DeviceShutdown(devType, i == 0, UDNstr,
SERVER, SInfo->DescURL, Exp, SInfo->DeviceAf );
}
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Extracting UDN for %s\n", dbgStr);
ixmlNodeList_free(nodeList);
nodeList = ixmlElement_getElementsByTagName(
(IXML_Element *)tmpNode, "UDN");
if (!nodeList) {
UpnpPrintf(UPNP_CRITICAL, API, __FILE__,
__LINE__, "UDN not found!\n");
continue;
}
tmpNode2 = ixmlNodeList_item(nodeList, 0);
if (!tmpNode2) {
UpnpPrintf(UPNP_CRITICAL, API, __FILE__,
__LINE__, "UDN not found!\n");
continue;
}
textNode = ixmlNode_getFirstChild(tmpNode2);
if (!textNode) {
UpnpPrintf(UPNP_CRITICAL, API, __FILE__,
__LINE__, "UDN not found!\n");
continue;
}
tmpStr = ixmlNode_getNodeValue(textNode);
if (!tmpStr) {
UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
"UDN not found!\n");
continue;
}
strcpy(UDNstr, tmpStr);
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"Sending UDNStr = %s \n", UDNstr);
if (AdFlag) {
/* send the device advertisement */
if (AdFlag == 1) {
DeviceAdvertisement(devType, i == 0,
UDNstr, SInfo->DescURL, Exp, SInfo->DeviceAf );
} else {
switch (SearchType) {
case SSDP_ALL:
DeviceReply(DestAddr, devType, i == 0,
UDNstr, SInfo->DescURL, defaultExp);
break;
case SSDP_ROOTDEVICE:
if (i == 0) {
SendReply(DestAddr, devType, 1,
UDNstr, SInfo->DescURL, defaultExp, 0);
}
break;
case SSDP_DEVICEUDN: {
if (DeviceUDN && strlen(DeviceUDN) != 0) {
if (strcasecmp(DeviceUDN, UDNstr)) {
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"DeviceUDN=%s and search UDN=%s DID NOT match\n",
UDNstr, DeviceUDN);
break;
} else {
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"DeviceUDN=%s and search UDN=%s MATCH\n",
UDNstr, DeviceUDN);
SendReply(DestAddr, devType, 0,
UDNstr, SInfo->DescURL,
defaultExp, 0);
break;
}
/* AdFlag == -1 */
DeviceShutdown(devType, i == 0, UDNstr,
SERVER, SInfo->DescURL, Exp, SInfo->DeviceAf );
}
} else {
switch (SearchType) {
case SSDP_ALL:
DeviceReply(DestAddr, devType, i == 0,
UDNstr, SInfo->DescURL, defaultExp);
break;
case SSDP_ROOTDEVICE:
if (i == 0) {
SendReply(DestAddr, devType, 1,
UDNstr, SInfo->DescURL, defaultExp, 0);
}
break;
case SSDP_DEVICEUDN: {
if (DeviceUDN && strlen(DeviceUDN) != 0) {
if (strcasecmp(DeviceUDN, UDNstr)) {
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"DeviceUDN=%s and search UDN=%s DID NOT match\n",
UDNstr, DeviceUDN);
break;
} else {
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"DeviceUDN=%s and search UDN=%s MATCH\n",
UDNstr, DeviceUDN);
SendReply(DestAddr, devType, 0,
UDNstr, SInfo->DescURL,
defaultExp, 0);
break;
}
}
case SSDP_DEVICETYPE: {
if (!strncasecmp(DeviceType, devType, strlen(DeviceType)-2)) {
if (atoi(&DeviceType[strlen(DeviceType)-1]) <= atoi(&devType[strlen(devType)-1])) {
/* the requested version is lower than the device version
* must reply with the lower version number */
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"DeviceType=%s and search devType=%s MATCH\n",
devType, DeviceType);
SendReply(DestAddr, DeviceType, 0, UDNstr, SInfo->DescURL, defaultExp, 1);
} else {
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"DeviceType=%s and search devType=%s DID NOT MATCH\n",
devType, DeviceType);
}
}
case SSDP_DEVICETYPE: {
if (!strncasecmp(DeviceType, devType, strlen(DeviceType))) {
if (atoi(&DeviceType[strlen(DeviceType)-1]) <= atoi(&devType[strlen(devType)-1])) {
/* the requested version is lower than the device version
* must reply with the lower version number */
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"DeviceType=%s and search devType=%s MATCH\n",
devType, DeviceType);
SendReply(DestAddr, DeviceType, 0, UDNstr, SInfo->DescURL, defaultExp, 1);
} else {
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"DeviceType=%s and search devType=%s DID NOT MATCH\n",
devType, DeviceType);
}
break;
}
default:
break;
}
}
/* send service advertisements for services corresponding
* to the same device */
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"Sending service Advertisement\n");
/* Correct service traversal such that each device's serviceList
* is directly traversed as a child of its parent device. This
* ensures that the service's alive message uses the UDN of
* the parent device. */
tmpNode = ixmlNode_getFirstChild(tmpNode);
while (tmpNode) {
dbgStr = ixmlNode_getNodeName(tmpNode);
if (!strncmp(dbgStr, SERVICELIST_STR, sizeof SERVICELIST_STR)) {
break;
}
tmpNode = ixmlNode_getNextSibling(tmpNode);
}
ixmlNodeList_free(nodeList);
if (!tmpNode) {
nodeList = NULL;
continue;
}
nodeList = ixmlElement_getElementsByTagName(
(IXML_Element *)tmpNode, "service");
if (!nodeList) {
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"Service not found 3\n" );
continue;
}
for (j = 0;; j++) {
tmpNode = ixmlNodeList_item(nodeList, j);
if (!tmpNode) {
break;
}
ixmlNodeList_free(tmpNodeList);
tmpNodeList = ixmlElement_getElementsByTagName(
(IXML_Element *)tmpNode, "serviceType");
if (!tmpNodeList) {
UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
"ServiceType not found \n");
continue;
}
tmpNode2 = ixmlNodeList_item(tmpNodeList, 0);
if (!tmpNode2) continue;
textNode = ixmlNode_getFirstChild(tmpNode2);
if (!textNode) continue;
/* servType is of format Servicetype:ServiceVersion */
tmpStr = ixmlNode_getNodeValue(textNode);
if (!tmpStr) continue;
strcpy(servType, tmpStr);
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"ServiceType = %s\n", servType);
if (AdFlag) {
if (AdFlag == 1) {
ServiceAdvertisement(UDNstr, servType,
SInfo->DescURL, Exp, SInfo->DeviceAf );
} else {
/* AdFlag == -1 */
ServiceShutdown(UDNstr, servType,
SInfo->DescURL, Exp, SInfo->DeviceAf );
}
} else {
switch (SearchType) {
case SSDP_ALL:
ServiceReply(DestAddr, servType,
UDNstr, SInfo->DescURL,
defaultExp);
break;
case SSDP_SERVICE:
if (ServiceType) {
if (!strncasecmp(ServiceType, servType, strlen(ServiceType) - 2)) {
if (atoi(&ServiceType[strlen(ServiceType)-1]) <= atoi(&servType[strlen(servType)-1])) {
/* the requested version is lower than the service version
* must reply with the lower version number */
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"ServiceType=%s and search servType=%s MATCH\n",
ServiceType, servType);
SendReply(DestAddr, ServiceType, 0, UDNstr, SInfo->DescURL, defaultExp, 1);
} else {
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"ServiceType=%s and search servType=%s DID NOT MATCH\n",
ServiceType, servType);
}
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"DeviceType=%s and search devType=%s DID NOT MATCH\n",
devType, DeviceType);
}
break;
}
default:
break;
}
}
/* send service advertisements for services corresponding
* to the same device */
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"Sending service Advertisement\n");
/* Correct service traversal such that each device's serviceList
* is directly traversed as a child of its parent device. This
* ensures that the service's alive message uses the UDN of
* the parent device. */
tmpNode = ixmlNode_getFirstChild(tmpNode);
while (tmpNode) {
dbgStr = ixmlNode_getNodeName(tmpNode);
if (!strncmp(dbgStr, SERVICELIST_STR, sizeof SERVICELIST_STR)) {
break;
}
tmpNode = ixmlNode_getNextSibling(tmpNode);
}
ixmlNodeList_free(nodeList);
if (!tmpNode) {
continue;
}
nodeList = ixmlElement_getElementsByTagName(
(IXML_Element *)tmpNode, "service");
if (!nodeList) {
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"Service not found 3\n" );
continue;
}
for (j = 0;; j++) {
tmpNode = ixmlNodeList_item(nodeList, j);
if (!tmpNode) {
break;
}
ixmlNodeList_free(tmpNodeList);
tmpNodeList = ixmlElement_getElementsByTagName(
(IXML_Element *)tmpNode, "serviceType");
if (!tmpNodeList) {
UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
"ServiceType not found \n");
continue;
}
tmpNode2 = ixmlNodeList_item(tmpNodeList, 0);
if (!tmpNode2) continue;
textNode = ixmlNode_getFirstChild(tmpNode2);
if (!textNode) continue;
/* servType is of format Servicetype:ServiceVersion */
tmpStr = ixmlNode_getNodeValue(textNode);
if (!tmpStr) continue;
strcpy(servType, tmpStr);
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"ServiceType = %s\n", servType);
if (AdFlag) {
if (AdFlag == 1) {
ServiceAdvertisement(UDNstr, servType,
SInfo->DescURL, Exp, SInfo->DeviceAf );
} else {
/* AdFlag == -1 */
ServiceShutdown(UDNstr, servType,
SInfo->DescURL, Exp, SInfo->DeviceAf );
}
} else {
switch (SearchType) {
case SSDP_ALL:
ServiceReply(DestAddr, servType,
UDNstr, SInfo->DescURL,
defaultExp);
break;
case SSDP_SERVICE:
if (ServiceType) {
if (!strncasecmp(ServiceType, servType, strlen(ServiceType) - 2)) {
if (atoi(&ServiceType[strlen(ServiceType)-1]) <= atoi(&servType[strlen(servType)-1])) {
/* the requested version is lower than the service version
* must reply with the lower version number */
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"ServiceType=%s and search servType=%s MATCH\n",
ServiceType, servType);
SendReply(DestAddr, ServiceType, 0, UDNstr, SInfo->DescURL, defaultExp, 1);
} else {
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"ServiceType=%s and search servType=%s DID NOT MATCH\n",
ServiceType, servType);
}
} else {
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"ServiceType=%s and search servType=%s DID NOT MATCH\n",
ServiceType, servType);
}
break;
default:
break;
}
break;
default:
break;
}
}
ixmlNodeList_free(tmpNodeList);
tmpNodeList = NULL;
ixmlNodeList_free(nodeList);
nodeList = NULL;
}
ixmlNodeList_free(tmpNodeList);
tmpNodeList = NULL;
ixmlNodeList_free(nodeList);
nodeList = NULL;
}
end_function:
@@ -750,26 +732,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) {
#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);
}
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 );
}
/* free data */
free_ssdp_event_handler_data(data);
// free data
free_ssdp_event_handler_data( data );
}
/************************************************************************
@@ -809,20 +791,11 @@ 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
@@ -847,10 +820,8 @@ 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) );
@@ -905,9 +876,6 @@ 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) {
@@ -922,7 +890,6 @@ 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) {
@@ -935,9 +902,6 @@ int get_ssdp_sockets(MiniServerSockArray *out)
} else {
out->ssdpReqSock6 = INVALID_SOCKET;
}
#endif //IPv6
#endif /* INCLUDE_CLIENT_APIS */
/* Create the IPv4 socket for SSDP */
@@ -957,7 +921,6 @@ 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) {
@@ -993,8 +956,6 @@ int get_ssdp_sockets(MiniServerSockArray *out)
} else {
out->ssdpSock6UlaGua = INVALID_SOCKET;
}
#endif //IPv6
return UPNP_E_SUCCESS;
}
@@ -1050,7 +1011,6 @@ 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];
@@ -1075,8 +1035,6 @@ int create_ssdp_sock_reqv6( SOCKET* ssdpReqSock )
return UPNP_E_SUCCESS;
}
#endif // IPv6
#endif /* INCLUDE_CLIENT_APIS */
@@ -1220,7 +1178,6 @@ 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];
@@ -1317,7 +1274,7 @@ int create_ssdp_sock_v6( SOCKET* ssdpSock )
return UPNP_E_SUCCESS;
}
#endif // IPv6
/************************************************************************
* Function : create_ssdp_sock_v6_ula_gua
@@ -1331,7 +1288,6 @@ 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];
@@ -1429,7 +1385,7 @@ int create_ssdp_sock_v6_ula_gua(SOCKET *ssdpSock)
return UPNP_E_SUCCESS;
}
#endif //IPv6
#endif /* EXCLUDE_SSDP */

View File

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