Compare commits
8 Commits
release-1.
...
release-1.
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ba837a528f | ||
![]() |
078f3f8faf | ||
![]() |
1eeaf99b83 | ||
![]() |
f6dd5062fe | ||
![]() |
7d4a610b93 | ||
![]() |
0a074d1989 | ||
![]() |
0475a46680 | ||
![]() |
2a76749682 |
103
ChangeLog
103
ChangeLog
@@ -1,3 +1,100 @@
|
|||||||
|
*******************************************************************************
|
||||||
|
Version 1.6.5
|
||||||
|
*******************************************************************************
|
||||||
|
|
||||||
|
2008-02-02 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Peter Hartley's fix for wrong sized variable beeing passed to
|
||||||
|
http_MakeMessage() on 64 bit architectures.
|
||||||
|
|
||||||
|
|
||||||
|
*******************************************************************************
|
||||||
|
Version 1.6.4
|
||||||
|
*******************************************************************************
|
||||||
|
|
||||||
|
2008-01-23 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
2008-01-22 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
2008-01-22 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Fix for setsockopt() in Threadpool.c to allow more than one process
|
||||||
|
to join the multicast-group on OSX. Thanks to Ingo Hofmann.
|
||||||
|
|
||||||
|
2008-01-22 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Using defined(__OSX__) || defined(__APPLE__) instead of just
|
||||||
|
defined(__OSX__) in the code. Thanks to Ingo Hofmann and Chris
|
||||||
|
Pickel.
|
||||||
|
|
||||||
|
2008-01-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Fix for isFileInVirtualDir. Thanks to Peter Hartley for the patch.
|
||||||
|
|
||||||
|
2008-01-07 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Putting back a "defined(__OSX__)" that has been removed in the
|
||||||
|
previous *BSD patch. Thanks to Chris Pickel for pointing it out.
|
||||||
|
|
||||||
|
2008-01-07 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
*******************************************************************************
|
||||||
|
Version 1.6.3
|
||||||
|
*******************************************************************************
|
||||||
|
|
||||||
|
2007-12-25 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
2007-12-24 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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. Thanks to Jonathan Casiot (no_dice) and Robert Gingher
|
||||||
|
(robsbox).
|
||||||
|
|
||||||
|
2007-12-17 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Removed unused iasnprintf.{c,h} files.
|
||||||
|
|
||||||
|
2007-12-17 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Removed STATSONLY() macro from ThreadPool.{c,h}.
|
||||||
|
* Removed time() usage from ThreadPool.c.
|
||||||
|
* Fixed STATS = 0 compilation.
|
||||||
|
|
||||||
|
2007-12-16 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Library was not compiling on FreeBSD 7. Code now no longer uses
|
||||||
|
ftime(), using gettimeofday() instead. Thanks to Josh Carroll.
|
||||||
|
|
||||||
|
|
||||||
|
*******************************************************************************
|
||||||
|
Version 1.6.2
|
||||||
|
*******************************************************************************
|
||||||
|
|
||||||
|
2007-12-10 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Fixed a compilation error due to a missing #ifdef in
|
||||||
|
upnp/src/genlib/miniserver/miniserver.c. Thanks to Eugene Christensen.
|
||||||
|
|
||||||
|
2007-11-12 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* "make check" was failing because ixml/test/test_document.sh did not
|
||||||
|
have the executable flag set. Thanks to Steve Bresson.
|
||||||
|
|
||||||
|
2007-11-12 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Fixed a memory leak in upnpapi.c to delete gMiniServerThreadPool in
|
||||||
|
the call to UpnpFinish(). Thanks to Fabrice Fontaine.
|
||||||
|
|
||||||
|
2007-11-09 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Added a isleep() call to the error handler of select() in
|
||||||
|
RunMiniServer(), so that it does not take 100% cpu in case select()
|
||||||
|
fails repeatedly.
|
||||||
|
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
Version 1.6.1
|
Version 1.6.1
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
@@ -116,6 +213,10 @@ Version 1.6.0
|
|||||||
an interface change in the library and the minor library version was
|
an interface change in the library and the minor library version was
|
||||||
bumped. Also, the libtool library numbers were changed accordingly.
|
bumped. Also, the libtool library numbers were changed accordingly.
|
||||||
|
|
||||||
|
*******************************************************************************
|
||||||
|
Version 1.4.7
|
||||||
|
*******************************************************************************
|
||||||
|
|
||||||
2007-05-26 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
2007-05-26 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
* Added support for the Basic Device
|
* Added support for the Basic Device
|
||||||
(http://www.upnp.org/standardizeddcps/basic.asp) as suggested by
|
(http://www.upnp.org/standardizeddcps/basic.asp) as suggested by
|
||||||
@@ -333,7 +434,7 @@ Version 1.4.2
|
|||||||
2007-01-23 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
2007-01-23 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
|
||||||
* SF Tracker [ 1634922 ] Support for large files (>= 2 GiB), part 2
|
* SF Tracker [ 1634922 ] Support for large files (>= 2 GiB), part 2
|
||||||
Submitted By: Jonathan - no_dice
|
Submitted By: Jonathan Casiot - no_dice
|
||||||
Summary: This patch hopefully fixes the remaining types and related
|
Summary: This patch hopefully fixes the remaining types and related
|
||||||
code to enable files >= 2 GiB to be streamed. Jonathan claims to have
|
code to enable files >= 2 GiB to be streamed. Jonathan claims to have
|
||||||
tested this with a patched version of ushare-0.9.8 and a D-Link DSM-520.
|
tested this with a patched version of ushare-0.9.8 and a D-Link DSM-520.
|
||||||
|
15
THANKS
15
THANKS
@@ -10,30 +10,39 @@ exempt of errors.
|
|||||||
- Arno Willig
|
- Arno Willig
|
||||||
- Bob Ciora
|
- Bob Ciora
|
||||||
- Chaos
|
- Chaos
|
||||||
|
- Chris Pickel
|
||||||
- Craig Nelson
|
- Craig Nelson
|
||||||
- David Maass
|
- David Maass
|
||||||
- Emil Ljungdahl
|
- Emil Ljungdahl
|
||||||
- Erik Johansson
|
- Erik Johansson
|
||||||
- Eric Tanguy
|
- Eric Tanguy
|
||||||
- Erwan Velu
|
- Erwan Velu
|
||||||
|
- Eugene Christensen
|
||||||
|
- Fabrice Fontaine
|
||||||
- Fredrik Svensson
|
- Fredrik Svensson
|
||||||
- Glen Masgai
|
- Glen Masgai
|
||||||
|
- Hartmut Holzgraefe - hholzgra
|
||||||
|
- Ingo Hofmann
|
||||||
- Jiri Zouhar
|
- Jiri Zouhar
|
||||||
- John Dennis
|
- John Dennis
|
||||||
- Jonathan (no_dice)
|
- Jonathan Casiot (no_dice)
|
||||||
|
- Josh Carroll
|
||||||
- Keith Brindley
|
- Keith Brindley
|
||||||
- Leuk_He
|
- Leuk_He
|
||||||
- Loigu
|
- Loigu
|
||||||
- Luke Kim
|
- Luke Kim
|
||||||
- Marcelo Roberto Jimenez (mroberto)
|
- Marcelo Roberto Jimenez (mroberto)
|
||||||
- Markus Strobl
|
- Markus Strobl
|
||||||
- Nektarios K. Papadopoulos
|
- Nektarios K. Papadopoulos (npapadop)
|
||||||
- Oskar Liljeblad
|
- Oskar Liljeblad
|
||||||
- Michael (Oxy)
|
- Michael (oxygenic)
|
||||||
- Paul Vixie
|
- Paul Vixie
|
||||||
|
- Peter Hartley
|
||||||
- Rene Hexel
|
- Rene Hexel
|
||||||
|
- Robert Gingher (robsbox)
|
||||||
- Siva Chandran
|
- Siva Chandran
|
||||||
- Stéphane Corthésy
|
- Stéphane Corthésy
|
||||||
|
- Steve Bresson
|
||||||
- Timothy Redaelli
|
- Timothy Redaelli
|
||||||
- Titus Winters
|
- Titus Winters
|
||||||
|
|
||||||
|
263
configure.ac
263
configure.ac
@@ -9,97 +9,144 @@
|
|||||||
|
|
||||||
AC_PREREQ(2.60)
|
AC_PREREQ(2.60)
|
||||||
|
|
||||||
AC_INIT([libupnp], [1.6.1], [mroberto@users.sourceforge.net])
|
AC_INIT([libupnp], [1.6.5], [mroberto@users.sourceforge.net])
|
||||||
###############################################################################
|
dnl ############################################################################
|
||||||
# *Independently* of the above libupnp package version, the libtool version
|
dnl # *Independently* of the above libupnp package version, the libtool version
|
||||||
# of the 3 libraries need to be updated whenever there is a change released:
|
dnl # of the 3 libraries need to be updated whenever there is a change released:
|
||||||
# "current:revision:age" (this is NOT the same as the package version), where:
|
dnl # "current:revision:age" (this is NOT the same as the package version),
|
||||||
# - library code modified: revision++
|
dnl # where:
|
||||||
# - interfaces changed/added/removed: current++ and revision=0
|
dnl # - library code modified: revision++
|
||||||
# - interfaces added: age++
|
dnl # - interfaces changed/added/removed: current++ and revision=0
|
||||||
# - interfaces removed: age=0
|
dnl # - interfaces added: age++
|
||||||
# *please update only once, before a formal release, not for each change*
|
dnl # - interfaces removed: age=0
|
||||||
#
|
dnl # *please update only once, before a formal release, not for each change*
|
||||||
###############################################################################
|
dnl #
|
||||||
# Release 1.4.1:
|
dnl ############################################################################
|
||||||
#AC_SUBST([LT_VERSION_IXML], [2:2:0])
|
dnl # Release 1.4.1:
|
||||||
#AC_SUBST([LT_VERSION_THREADUTIL], [2:2:0])
|
dnl #AC_SUBST([LT_VERSION_IXML], [2:2:0])
|
||||||
#AC_SUBST([LT_VERSION_UPNP], [2:2:0])
|
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [2:2:0])
|
||||||
#
|
dnl #AC_SUBST([LT_VERSION_UPNP], [2:2:0])
|
||||||
###############################################################################
|
dnl #
|
||||||
# Release 1.4.6:
|
dnl ############################################################################
|
||||||
# "current:revision:age"
|
dnl # Release 1.4.6:
|
||||||
#
|
dnl # "current:revision:age"
|
||||||
# - Code has changed in ixml
|
dnl #
|
||||||
# revision: 2 -> 3
|
dnl # - Code has changed in ixml
|
||||||
# - Code has changed in threadutil
|
dnl # revision: 2 -> 3
|
||||||
# revision: 2 -> 3
|
dnl # - Code has changed in threadutil
|
||||||
# - Interface added in threadutil
|
dnl # revision: 2 -> 3
|
||||||
# current: 2 -> 3
|
dnl # - Interface added in threadutil
|
||||||
# revisiion: 3 -> 0
|
dnl # current: 2 -> 3
|
||||||
# age: 0 -> 1
|
dnl # revisiion: 3 -> 0
|
||||||
# - Code has changed in upnp
|
dnl # age: 0 -> 1
|
||||||
# revision: 2 -> 3
|
dnl # - Code has changed in upnp
|
||||||
#
|
dnl # revision: 2 -> 3
|
||||||
#AC_SUBST([LT_VERSION_IXML], [2:3:0])
|
dnl #
|
||||||
#AC_SUBST([LT_VERSION_THREADUTIL], [3:0:1])
|
dnl #AC_SUBST([LT_VERSION_IXML], [2:3:0])
|
||||||
#AC_SUBST([LT_VERSION_UPNP], [2:3:0])
|
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [3:0:1])
|
||||||
#
|
dnl #AC_SUBST([LT_VERSION_UPNP], [2:3:0])
|
||||||
###############################################################################
|
dnl #
|
||||||
# Release 1.6.0:
|
dnl ############################################################################
|
||||||
# "current:revision:age"
|
dnl # Release 1.6.0:
|
||||||
#
|
dnl # "current:revision:age"
|
||||||
# - Code has changed in ixml
|
dnl #
|
||||||
# revision: 3 -> 4
|
dnl # - Code has changed in ixml
|
||||||
# - Code has changed in threadutil
|
dnl # revision: 3 -> 4
|
||||||
# revision: 0 -> 1
|
dnl # - Code has changed in threadutil
|
||||||
# - Code has changed in upnp
|
dnl # revision: 0 -> 1
|
||||||
# revision: 3 -> 4
|
dnl # - Code has changed in upnp
|
||||||
# - Interface changed in upnp
|
dnl # revision: 3 -> 4
|
||||||
# current: 2 -> 3
|
dnl # - Interface changed in upnp
|
||||||
# revision: 4 -> 0
|
dnl # current: 2 -> 3
|
||||||
# - Interface removed in upnp
|
dnl # revision: 4 -> 0
|
||||||
# age: 0 -> 0
|
dnl # - Interface removed in upnp
|
||||||
#
|
dnl # age: 0 -> 0
|
||||||
#AC_SUBST([LT_VERSION_IXML], [2:4:0])
|
dnl #
|
||||||
#AC_SUBST([LT_VERSION_THREADUTIL], [3:1:1])
|
dnl #AC_SUBST([LT_VERSION_IXML], [2:4:0])
|
||||||
#AC_SUBST([LT_VERSION_UPNP], [3:0:0])
|
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [3:1:1])
|
||||||
#
|
dnl #AC_SUBST([LT_VERSION_UPNP], [3:0:0])
|
||||||
###############################################################################
|
dnl #
|
||||||
# Release 1.6.1:
|
dnl ############################################################################
|
||||||
# "current:revision:age"
|
dnl # Release 1.6.1:
|
||||||
#
|
dnl # "current:revision:age"
|
||||||
# - Code has changed in threadutil
|
dnl #
|
||||||
# revision: 1 -> 2
|
dnl # - Code has changed in threadutil
|
||||||
# - Interface added in threadutil
|
dnl # revision: 1 -> 2
|
||||||
# current: 3 -> 4
|
dnl # - Interface added in threadutil
|
||||||
# revision: 2 -> 0
|
dnl # current: 3 -> 4
|
||||||
# - Interface added in threadutil
|
dnl # revision: 2 -> 0
|
||||||
# age: 1 -> 2
|
dnl # - Interface added in threadutil
|
||||||
# - Code has changed in upnp
|
dnl # age: 1 -> 2
|
||||||
# revision: 0 -> 1
|
dnl # - Code has changed in upnp
|
||||||
#
|
dnl # revision: 0 -> 1
|
||||||
#AC_SUBST([LT_VERSION_IXML], [2:4:0])
|
dnl #
|
||||||
#AC_SUBST([LT_VERSION_THREADUTIL], [4:0:2])
|
dnl #AC_SUBST([LT_VERSION_IXML], [2:4:0])
|
||||||
#AC_SUBST([LT_VERSION_UPNP], [3:1:0])
|
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [4:0:2])
|
||||||
#
|
dnl #AC_SUBST([LT_VERSION_UPNP], [3:1:0])
|
||||||
###############################################################################
|
dnl #
|
||||||
|
dnl ############################################################################
|
||||||
|
dnl # Release 1.6.2:
|
||||||
|
dnl # "current:revision:age"
|
||||||
|
dnl #
|
||||||
|
dnl # - Code has changed in upnp
|
||||||
|
dnl # revision: 1 -> 2
|
||||||
|
dnl #
|
||||||
|
dnl #AC_SUBST([LT_VERSION_IXML], [2:4:0])
|
||||||
|
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [4:0:2])
|
||||||
|
dnl #AC_SUBST([LT_VERSION_UPNP], [3:2:0])
|
||||||
|
dnl #
|
||||||
|
dnl ############################################################################
|
||||||
|
dnl # Release 1.6.3:
|
||||||
|
dnl # "current:revision:age"
|
||||||
|
dnl #
|
||||||
|
dnl # - Code has changed in threadutil
|
||||||
|
dnl # revision: 0 -> 1
|
||||||
|
dnl #
|
||||||
|
dnl #AC_SUBST([LT_VERSION_IXML], [2:4:0])
|
||||||
|
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [4:1:2])
|
||||||
|
dnl #AC_SUBST([LT_VERSION_UPNP], [3:2:0])
|
||||||
|
dnl #
|
||||||
|
dnl ############################################################################
|
||||||
|
dnl # Release 1.6.4:
|
||||||
|
dnl # "current:revision:age"
|
||||||
|
dnl #
|
||||||
|
dnl # - Code has changed in threadutil
|
||||||
|
dnl # revision: 1 -> 2
|
||||||
|
dnl # - Code has changed in upnp
|
||||||
|
dnl # revision: 2 -> 3
|
||||||
|
dnl #
|
||||||
|
dnl #AC_SUBST([LT_VERSION_IXML], [2:4:0])
|
||||||
|
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [4:2:2])
|
||||||
|
dnl #AC_SUBST([LT_VERSION_UPNP], [3:3:0])
|
||||||
|
dnl #
|
||||||
|
dnl ############################################################################
|
||||||
|
dnl # Release 1.6.5:
|
||||||
|
dnl # "current:revision:age"
|
||||||
|
dnl #
|
||||||
|
dnl # - Code has changed in upnp
|
||||||
|
dnl # revision: 3 -> 4
|
||||||
|
dnl #
|
||||||
|
dnl #AC_SUBST([LT_VERSION_IXML], [2:4:0])
|
||||||
|
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [4:2:2])
|
||||||
|
dnl #AC_SUBST([LT_VERSION_UPNP], [3:4:0])
|
||||||
|
dnl #
|
||||||
|
dnl ############################################################################
|
||||||
AC_SUBST([LT_VERSION_IXML], [2:4:0])
|
AC_SUBST([LT_VERSION_IXML], [2:4:0])
|
||||||
AC_SUBST([LT_VERSION_THREADUTIL], [4:0:2])
|
AC_SUBST([LT_VERSION_THREADUTIL], [4:2:2])
|
||||||
AC_SUBST([LT_VERSION_UPNP], [3:1:0])
|
AC_SUBST([LT_VERSION_UPNP], [3:4:0])
|
||||||
###############################################################################
|
dnl ############################################################################
|
||||||
# Repeating the algorithm so that it is closer to the modificatin place:
|
dnl # Repeating the algorithm to place it closer to the modificatin place:
|
||||||
# - library code modified: revision++
|
dnl # - library code modified: revision++
|
||||||
# - interfaces changed/added/removed: current++ and revision=0
|
dnl # - interfaces changed/added/removed: current++ and revision=0
|
||||||
# - interfaces added: age++
|
dnl # - interfaces added: age++
|
||||||
# - interfaces removed: age=0
|
dnl # - interfaces removed: age=0
|
||||||
# *please update only once, before a formal release, not for each change*
|
dnl # *please update only once, before a formal release, not for each change*
|
||||||
###############################################################################
|
dnl ############################################################################
|
||||||
|
|
||||||
|
|
||||||
AC_CONFIG_AUX_DIR(config.aux)
|
AC_CONFIG_AUX_DIR([build-aux])
|
||||||
AC_CONFIG_MACRO_DIR(m4)
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
AC_CONFIG_SRCDIR(upnp/inc/upnp.h)
|
AC_CONFIG_SRCDIR([upnp/inc/upnp.h])
|
||||||
|
|
||||||
|
|
||||||
AM_INIT_AUTOMAKE([1.8 -Wall foreign subdir-objects dist-bzip2])
|
AM_INIT_AUTOMAKE([1.8 -Wall foreign subdir-objects dist-bzip2])
|
||||||
@@ -129,8 +176,7 @@ AC_REVISION([$Revision: 1.11 $])
|
|||||||
upnpmaj=`echo "$PACKAGE_VERSION" | sed 's/\..*//' `
|
upnpmaj=`echo "$PACKAGE_VERSION" | sed 's/\..*//' `
|
||||||
upnpmin=[`echo "$PACKAGE_VERSION" | sed 's/^[^.]\.// ; s/[^0-9].*$//' `]
|
upnpmin=[`echo "$PACKAGE_VERSION" | sed 's/^[^.]\.// ; s/[^0-9].*$//' `]
|
||||||
upnppatch=[`echo "$PACKAGE_VERSION" | sed 's/^[^.]\.[^.]\.// ; s/[^0-9].*$//' `]
|
upnppatch=[`echo "$PACKAGE_VERSION" | sed 's/^[^.]\.[^.]\.// ; s/[^0-9].*$//' `]
|
||||||
AC_DEFINE_UNQUOTED([UPNP_VERSION_STRING], "$PACKAGE_VERSION",
|
AC_DEFINE_UNQUOTED([UPNP_VERSION_STRING], "$PACKAGE_VERSION", [see upnpconfig.h])
|
||||||
[see upnpconfig.h])
|
|
||||||
AC_DEFINE_UNQUOTED([UPNP_VERSION_MAJOR], $upnpmaj, [see upnpconfig.h])
|
AC_DEFINE_UNQUOTED([UPNP_VERSION_MAJOR], $upnpmaj, [see upnpconfig.h])
|
||||||
AC_DEFINE_UNQUOTED([UPNP_VERSION_MINOR], $upnpmin, [see upnpconfig.h])
|
AC_DEFINE_UNQUOTED([UPNP_VERSION_MINOR], $upnpmin, [see upnpconfig.h])
|
||||||
AC_DEFINE_UNQUOTED([UPNP_VERSION_PATCH], $upnppatch, [see upnpconfig.h])
|
AC_DEFINE_UNQUOTED([UPNP_VERSION_PATCH], $upnppatch, [see upnpconfig.h])
|
||||||
@@ -152,7 +198,6 @@ fi
|
|||||||
#
|
#
|
||||||
# Check for libupnp subsets
|
# Check for libupnp subsets
|
||||||
#
|
#
|
||||||
|
|
||||||
RT_BOOL_ARG_ENABLE([client], [yes], [control point code (client)])
|
RT_BOOL_ARG_ENABLE([client], [yes], [control point code (client)])
|
||||||
if test "x$enable_client" = xyes ; then
|
if test "x$enable_client" = xyes ; then
|
||||||
AC_DEFINE(UPNP_HAVE_CLIENT, 1, [see upnpconfig.h])
|
AC_DEFINE(UPNP_HAVE_CLIENT, 1, [see upnpconfig.h])
|
||||||
@@ -186,11 +231,13 @@ fi
|
|||||||
RT_BOOL_ARG_ENABLE([samples], [yes], [compilation of upnp/sample/ code])
|
RT_BOOL_ARG_ENABLE([samples], [yes], [compilation of upnp/sample/ code])
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
# doc installation
|
# doc installation
|
||||||
# autoconf >= 2.60 already defines ${docdir}, but we will not use its
|
# autoconf >= 2.60 already defines ${docdir}, but we will not use its
|
||||||
# default value, which is ${datarootdir}/doc/${PACKAGE_TARNAME}.
|
# default value, which is ${datarootdir}/doc/${PACKAGE_TARNAME}.
|
||||||
# That would give us ${datarootdir}/doc/libupnp, and we want the package
|
# That would give us ${datarootdir}/doc/libupnp, and we want the package
|
||||||
# version on that.
|
# version on that.
|
||||||
|
#
|
||||||
docdir="${datadir}/doc/${PACKAGE_NAME}-${PACKAGE_VERSION}"
|
docdir="${datadir}/doc/${PACKAGE_NAME}-${PACKAGE_VERSION}"
|
||||||
AC_MSG_CHECKING([for documentation directory])
|
AC_MSG_CHECKING([for documentation directory])
|
||||||
AC_ARG_WITH(
|
AC_ARG_WITH(
|
||||||
@@ -205,7 +252,9 @@ AS_HELP_STRING(
|
|||||||
[],
|
[],
|
||||||
[with_documentation=no])
|
[with_documentation=no])
|
||||||
|
|
||||||
|
#
|
||||||
# If something has been entered after an equal sign, assume it is the directory
|
# If something has been entered after an equal sign, assume it is the directory
|
||||||
|
#
|
||||||
if test x"$with_documentation" != xyes -a x"$with_documentation" != xno; then
|
if test x"$with_documentation" != xyes -a x"$with_documentation" != xno; then
|
||||||
docdir="$with_documentation"
|
docdir="$with_documentation"
|
||||||
fi
|
fi
|
||||||
@@ -291,7 +340,6 @@ AC_CHECK_HEADERS(
|
|||||||
# Checks for typedefs, structures, and compiler characteristics
|
# Checks for typedefs, structures, and compiler characteristics
|
||||||
#
|
#
|
||||||
AC_C_CONST
|
AC_C_CONST
|
||||||
AC_TYPE_SIZE_T
|
|
||||||
TYPE_SOCKLEN_T
|
TYPE_SOCKLEN_T
|
||||||
|
|
||||||
|
|
||||||
@@ -306,9 +354,40 @@ AC_CHECK_FUNCS(ftime,, [AC_CHECK_LIB(compat, ftime)])
|
|||||||
#
|
#
|
||||||
# Checks for POSIX Threads
|
# Checks for POSIX Threads
|
||||||
#
|
#
|
||||||
|
echo "--------------------------- pthread stuff -------------------------------------"
|
||||||
ACX_PTHREAD(
|
ACX_PTHREAD(
|
||||||
[],
|
[],
|
||||||
[AC_MSG_ERROR([POSIX threads are required to build this program])])
|
[AC_MSG_ERROR([POSIX threads are required to build this program])])
|
||||||
|
#
|
||||||
|
# Update environment variables for pthreads
|
||||||
|
#
|
||||||
|
CC="$PTHREAD_CC"
|
||||||
|
CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
|
||||||
|
LIBS="$PTHREAD_LIBS $LIBS"
|
||||||
|
#
|
||||||
|
# Determine if pthread_rwlock_t is available
|
||||||
|
#
|
||||||
|
echo "----------------------- pthread_rwlock_t stuff --------------------------------"
|
||||||
|
AC_MSG_CHECKING([if pthread_rwlock_t is available])
|
||||||
|
AC_LANG([C])
|
||||||
|
AC_COMPILE_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM(
|
||||||
|
[#include <pthread.h>],
|
||||||
|
[pthread_rwlock_t *x;])],
|
||||||
|
[AC_DEFINE([UPNP_USE_RWLOCK], [1], [Use pthread_rwlock_t])
|
||||||
|
AC_MSG_RESULT([yes, supported without any options])],
|
||||||
|
[AC_COMPILE_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM(
|
||||||
|
[#define _GNU_SOURCE
|
||||||
|
#include <pthread.h>],
|
||||||
|
[pthread_rwlock_t *x;])],
|
||||||
|
[AC_DEFINE([UPNP_USE_RWLOCK], [1], [Use pthread_rwlock_t])
|
||||||
|
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
|
||||||
|
AC_MSG_RESULT([yes, definition of _GNU_SOURCE required])],
|
||||||
|
[AC_DEFINE([UPNP_USE_RWLOCK], [0], [Do not use pthread_rwlock_t])
|
||||||
|
AC_MSG_RESULT([no, needs to fallback to pthread_mutex])
|
||||||
|
AC_MSG_ERROR([pthread_rwlock_t not available])])])
|
||||||
|
echo "-------------------------------------------------------------------------------"
|
||||||
|
|
||||||
|
|
||||||
AC_CONFIG_FILES([
|
AC_CONFIG_FILES([
|
||||||
|
4
docs/dist/Makefile.am
vendored
4
docs/dist/Makefile.am
vendored
@@ -39,7 +39,7 @@ EXTRA_DIST = \
|
|||||||
./html/upnp/UPNP_E_SOCKET_ERROR-208.html \
|
./html/upnp/UPNP_E_SOCKET_ERROR-208.html \
|
||||||
./html/upnp/UPNP_E_CANCELED-210.html \
|
./html/upnp/UPNP_E_CANCELED-210.html \
|
||||||
./html/upnp/UPNP_E_SUBSCRIBE_UNACCEPTED-301.html \
|
./html/upnp/UPNP_E_SUBSCRIBE_UNACCEPTED-301.html \
|
||||||
./html/upnp/UPNP_E_UNSUBSCRIBE_UNACCAPTED-302.html \
|
./html/upnp/UPNP_E_UNSUBSCRIBE_UNACCEPTED-302.html \
|
||||||
./html/upnp/UPNP_E_NOTIFY_UNACCEPTED-303.html \
|
./html/upnp/UPNP_E_NOTIFY_UNACCEPTED-303.html \
|
||||||
./html/upnp/UPNP_E_INVALID_ARGUMENT-501.html \
|
./html/upnp/UPNP_E_INVALID_ARGUMENT-501.html \
|
||||||
./html/upnp/UPNP_E_FILE_NOT_FOUND-502.html \
|
./html/upnp/UPNP_E_FILE_NOT_FOUND-502.html \
|
||||||
@@ -295,7 +295,7 @@ if WITH_DOCUMENTATION
|
|||||||
./html/upnp/UPNP_E_SOCKET_ERROR-208.html \
|
./html/upnp/UPNP_E_SOCKET_ERROR-208.html \
|
||||||
./html/upnp/UPNP_E_CANCELED-210.html \
|
./html/upnp/UPNP_E_CANCELED-210.html \
|
||||||
./html/upnp/UPNP_E_SUBSCRIBE_UNACCEPTED-301.html \
|
./html/upnp/UPNP_E_SUBSCRIBE_UNACCEPTED-301.html \
|
||||||
./html/upnp/UPNP_E_UNSUBSCRIBE_UNACCAPTED-302.html \
|
./html/upnp/UPNP_E_UNSUBSCRIBE_UNACCEPTED-302.html \
|
||||||
./html/upnp/UPNP_E_NOTIFY_UNACCEPTED-303.html \
|
./html/upnp/UPNP_E_NOTIFY_UNACCEPTED-303.html \
|
||||||
./html/upnp/UPNP_E_INVALID_ARGUMENT-501.html \
|
./html/upnp/UPNP_E_INVALID_ARGUMENT-501.html \
|
||||||
./html/upnp/UPNP_E_FILE_NOT_FOUND-502.html \
|
./html/upnp/UPNP_E_FILE_NOT_FOUND-502.html \
|
||||||
|
@@ -38,10 +38,6 @@
|
|||||||
#define MINVAL( a, b ) ( (a) < (b) ? (a) : (b) )
|
#define MINVAL( a, b ) ( (a) < (b) ? (a) : (b) )
|
||||||
#define MAXVAL( a, b ) ( (a) > (b) ? (a) : (b) )
|
#define MAXVAL( a, b ) ( (a) > (b) ? (a) : (b) )
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
#define UPNP_INLINE inline
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MEMBUF_DEF_SIZE_INC 20
|
#define MEMBUF_DEF_SIZE_INC 20
|
||||||
|
|
||||||
|
|
||||||
|
@@ -504,14 +504,19 @@ Parser_init( )
|
|||||||
* Parser_isValidEndElement
|
* Parser_isValidEndElement
|
||||||
* check if a new node->nodeName matches top of element stack.
|
* check if a new node->nodeName matches top of element stack.
|
||||||
* Internal to parser only.
|
* Internal to parser only.
|
||||||
*
|
|
||||||
*=================================================================*/
|
*=================================================================*/
|
||||||
static int
|
static int
|
||||||
Parser_isValidEndElement( IN Parser * xmlParser,
|
Parser_isValidEndElement(
|
||||||
|
IN Parser * xmlParser,
|
||||||
IN IXML_Node * newNode )
|
IN IXML_Node * newNode )
|
||||||
{
|
{
|
||||||
return ( strcmp( xmlParser->pCurElement->element, newNode->nodeName )
|
assert( xmlParser );
|
||||||
== 0 );
|
assert( xmlParser->pCurElement );
|
||||||
|
assert( xmlParser->pCurElement->element );
|
||||||
|
assert( newNode );
|
||||||
|
assert( newNode->nodeName );
|
||||||
|
|
||||||
|
return strcmp( xmlParser->pCurElement->element, newNode->nodeName ) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===============================================================
|
/*===============================================================
|
||||||
@@ -921,6 +926,8 @@ Parser_parseDocument( OUT IXML_Document ** retDoc,
|
|||||||
int rc = IXML_SUCCESS;
|
int rc = IXML_SUCCESS;
|
||||||
IXML_CDATASection *cdataSecNode = NULL;
|
IXML_CDATASection *cdataSecNode = NULL;
|
||||||
|
|
||||||
|
// It is important that the node gets initialized here, otherwise things
|
||||||
|
// can go wrong on the error handler.
|
||||||
ixmlNode_init( &newNode );
|
ixmlNode_init( &newNode );
|
||||||
|
|
||||||
rc = ixmlDocument_createDocumentEx( &gRootDoc );
|
rc = ixmlDocument_createDocumentEx( &gRootDoc );
|
||||||
@@ -936,7 +943,9 @@ Parser_parseDocument( OUT IXML_Document ** retDoc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
while( bETag == FALSE ) {
|
while( bETag == FALSE ) {
|
||||||
// clear the newNode contents
|
// clear the newNode contents. Redundant on the first iteration,
|
||||||
|
// but nonetheless, necessary due to the possible calls to
|
||||||
|
// ErrorHandler above. Currently, this is just a memset to zero.
|
||||||
ixmlNode_init( &newNode );
|
ixmlNode_init( &newNode );
|
||||||
|
|
||||||
if( Parser_getNextNode( xmlParser, &newNode, &bETag ) ==
|
if( Parser_getNextNode( xmlParser, &newNode, &bETag ) ==
|
||||||
@@ -2497,3 +2506,4 @@ Parser_getNextNode( IN Parser * xmlParser,
|
|||||||
return IXML_SYNTAX_ERR;
|
return IXML_SYNTAX_ERR;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
0
ixml/test/test_document.sh
Normal file → Executable file
0
ixml/test/test_document.sh
Normal file → Executable file
@@ -1,4 +1,4 @@
|
|||||||
Version: 1.4.2
|
Version: 1.6.5
|
||||||
Summary: Universal Plug and Play (UPnP) SDK
|
Summary: Universal Plug and Play (UPnP) SDK
|
||||||
Name: libupnp
|
Name: libupnp
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
@@ -77,6 +77,12 @@ make install DESTDIR=$RPM_BUILD_ROOT
|
|||||||
rm -rf %{buildroot}
|
rm -rf %{buildroot}
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Nov 19 2007 Marcelo Jimenez <mroberto@users.sourceforge.net> - 1.6.2-1
|
||||||
|
- Update to version 1.6.2
|
||||||
|
|
||||||
|
* Mon Nov 19 2007 Marcelo Jimenez <mroberto@users.sourceforge.net> - 1.4.7-1
|
||||||
|
- Update to version 1.4.7
|
||||||
|
|
||||||
* Fri Feb 02 2007 Eric Tanguy <eric.tanguy@univ-nantes.fr> - 1.4.2-1
|
* Fri Feb 02 2007 Eric Tanguy <eric.tanguy@univ-nantes.fr> - 1.4.2-1
|
||||||
- Update to version 1.4.2
|
- Update to version 1.4.2
|
||||||
|
|
||||||
|
@@ -41,7 +41,7 @@ AC_DEFUN([RT_BOOL_ARG_ENABLE],[
|
|||||||
)])
|
)])
|
||||||
test "x$enable_[$1]" != [x]m4_if([$2],[yes],[no],[yes]) dnl
|
test "x$enable_[$1]" != [x]m4_if([$2],[yes],[no],[yes]) dnl
|
||||||
&& enable_[]Name=[$2]
|
&& enable_[]Name=[$2]
|
||||||
AC_MSG_RESULT($enable_[]Name)dnl
|
AC_MSG_RESULT($enable_[]Name)
|
||||||
AM_CONDITIONAL([ENABLE_]NAME, test x"$enable_[]Name" = xyes)
|
AM_CONDITIONAL([ENABLE_]NAME, test x"$enable_[]Name" = xyes)
|
||||||
dnl
|
dnl
|
||||||
m4_popdef([NAME])dnl
|
m4_popdef([NAME])dnl
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
AM_CPPFLAGS = -I$(srcdir)/inc -I$(srcdir)/src/inc
|
AM_CPPFLAGS = -I$(srcdir)/inc -I$(srcdir)/src/inc
|
||||||
AM_CFLAGS = $(PTHREAD_CFLAGS)
|
|
||||||
|
|
||||||
if ENABLE_DEBUG
|
if ENABLE_DEBUG
|
||||||
AM_CPPFLAGS += -DDEBUG -DSTATS
|
AM_CPPFLAGS += -DDEBUG -DSTATS
|
||||||
@@ -21,12 +20,11 @@ libthreadutil_la_LDFLAGS = -version-info $(LT_VERSION_THREADUTIL)
|
|||||||
|
|
||||||
libthreadutil_la_SOURCES = \
|
libthreadutil_la_SOURCES = \
|
||||||
src/FreeList.c src/LinkedList.c \
|
src/FreeList.c src/LinkedList.c \
|
||||||
src/ThreadPool.c src/TimerThread.c \
|
src/ThreadPool.c src/TimerThread.c
|
||||||
src/iasnprintf.c
|
|
||||||
|
|
||||||
upnpincludedir = $(includedir)/upnp
|
upnpincludedir = $(includedir)/upnp
|
||||||
upnpinclude_HEADERS = \
|
upnpinclude_HEADERS = \
|
||||||
inc/FreeList.h inc/LinkedList.h \
|
inc/FreeList.h inc/LinkedList.h \
|
||||||
inc/ThreadPool.h inc/TimerThread.h \
|
inc/ThreadPool.h inc/TimerThread.h \
|
||||||
inc/iasnprintf.h inc/ithread.h
|
inc/ithread.h
|
||||||
|
|
||||||
|
@@ -32,6 +32,12 @@
|
|||||||
#ifndef THREADPOOL_H
|
#ifndef THREADPOOL_H
|
||||||
#define THREADPOOL_H
|
#define THREADPOOL_H
|
||||||
|
|
||||||
|
#ifdef UPNP_USE_MSVCPP
|
||||||
|
#define UPNP_INLINE
|
||||||
|
#else
|
||||||
|
#define UPNP_INLINE inline
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@@ -64,32 +70,23 @@ typedef enum priority {LOW_PRIORITY,
|
|||||||
#define DEFAULT_FREE_ROUTINE NULL /* default free routine used TPJobInit */
|
#define DEFAULT_FREE_ROUTINE NULL /* default free routine used TPJobInit */
|
||||||
#define DEFAULT_MAX_JOBS_TOTAL 100 /* default max jobs used TPAttrInit */
|
#define DEFAULT_MAX_JOBS_TOTAL 100 /* default max jobs used TPAttrInit */
|
||||||
|
|
||||||
#define STATS 1 /* always include stats because code change is minimal */
|
|
||||||
|
|
||||||
|
|
||||||
/* Statistics */
|
/* Statistics */
|
||||||
#ifdef WIN32 /* TODO: check why STATSONLY fails during compilation */
|
/* always include stats because code change is minimal */
|
||||||
#undef STATS
|
#define STATS 1
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef STATS
|
|
||||||
#define STATSONLY(x) x
|
|
||||||
#else
|
|
||||||
#define STATSONLY(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "LinkedList.h"
|
#include "LinkedList.h"
|
||||||
#include <sys/timeb.h>
|
#include <sys/time.h> /* for gettimeofday() */
|
||||||
#include "FreeList.h"
|
#include "FreeList.h"
|
||||||
|
|
||||||
#include "ithread.h"
|
#include "ithread.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/timeb.h>
|
|
||||||
#define EXPORT
|
#define EXPORT
|
||||||
|
|
||||||
typedef int PolicyType;
|
typedef int PolicyType;
|
||||||
#define DEFAULT_POLICY SCHED_OTHER
|
#define DEFAULT_POLICY SCHED_OTHER
|
||||||
#define DEFAULT_SCHED_PARAM 0 /* default priority */
|
#define DEFAULT_SCHED_PARAM 0 /* default priority */
|
||||||
@@ -111,26 +108,28 @@ typedef void (*free_routine)(void *arg);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
typedef struct THREADPOOLATTR
|
typedef struct THREADPOOLATTR
|
||||||
{
|
{
|
||||||
int minThreads; /* minThreads, ThreadPool will always maintain at least
|
/* minThreads, ThreadPool will always maintain at least this many threads */
|
||||||
this many threads */
|
int minThreads;
|
||||||
|
|
||||||
int maxThreads; /* maxThreads, ThreadPool will never have more than this
|
/* maxThreads, ThreadPool will never have more than this number of threads */
|
||||||
number of threads */
|
int maxThreads;
|
||||||
|
|
||||||
int maxIdleTime; /* maxIdleTime (in milliseconds)
|
/* maxIdleTime (in milliseconds) this is the maximum time a thread will
|
||||||
this is the maximum time a thread will remain idle
|
* remain idle before dying */
|
||||||
before dying */
|
int maxIdleTime;
|
||||||
|
|
||||||
int jobsPerThread; /* jobs per thread to maintain */
|
/* jobs per thread to maintain */
|
||||||
|
int jobsPerThread;
|
||||||
|
|
||||||
int maxJobsTotal; /* maximum number of jobs that can be queued totally. */
|
/* maximum number of jobs that can be queued totally. */
|
||||||
|
int maxJobsTotal;
|
||||||
|
|
||||||
int starvationTime; /* the time a low priority or med priority
|
/* the time a low priority or med priority job waits before getting bumped
|
||||||
job waits before getting bumped
|
* up a priority (in milliseconds) */
|
||||||
up a priority (in milliseconds) */
|
int starvationTime;
|
||||||
|
|
||||||
PolicyType schedPolicy; /* scheduling policy to use */
|
|
||||||
|
|
||||||
|
/* scheduling policy to use */
|
||||||
|
PolicyType schedPolicy;
|
||||||
} ThreadPoolAttr;
|
} ThreadPoolAttr;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -144,7 +143,7 @@ typedef struct THREADPOOLJOB
|
|||||||
start_routine func;
|
start_routine func;
|
||||||
void *arg;
|
void *arg;
|
||||||
free_routine free_func;
|
free_routine free_func;
|
||||||
struct timeb requestTime;
|
struct timeval requestTime;
|
||||||
int priority;
|
int priority;
|
||||||
int jobId;
|
int jobId;
|
||||||
} ThreadPoolJob;
|
} ThreadPoolJob;
|
||||||
@@ -156,8 +155,6 @@ typedef struct THREADPOOLJOB
|
|||||||
* Structure to hold statistics
|
* Structure to hold statistics
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifdef STATS
|
|
||||||
|
|
||||||
typedef struct TPOOLSTATS
|
typedef struct TPOOLSTATS
|
||||||
{
|
{
|
||||||
double totalTimeHQ;
|
double totalTimeHQ;
|
||||||
@@ -181,8 +178,6 @@ typedef struct TPOOLSTATS
|
|||||||
int currentJobsMQ;
|
int currentJobsMQ;
|
||||||
} ThreadPoolStats;
|
} ThreadPoolStats;
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: ThreadPool
|
* Name: ThreadPool
|
||||||
@@ -222,11 +217,8 @@ typedef struct THREADPOOL
|
|||||||
|
|
||||||
ThreadPoolAttr attr; /* thread pool attributes */
|
ThreadPoolAttr attr; /* thread pool attributes */
|
||||||
|
|
||||||
#ifdef STATS
|
|
||||||
/* statistics */
|
/* statistics */
|
||||||
ThreadPoolStats stats;
|
ThreadPoolStats stats;
|
||||||
#endif
|
|
||||||
|
|
||||||
} ThreadPool;
|
} ThreadPool;
|
||||||
|
|
||||||
|
|
||||||
@@ -267,8 +259,7 @@ typedef struct THREADPOOL
|
|||||||
* INVALID_POLICY if schedPolicy can't be set
|
* INVALID_POLICY if schedPolicy can't be set
|
||||||
* EMAXTHREADS if minimum threads is greater than maximum threads
|
* EMAXTHREADS if minimum threads is greater than maximum threads
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int ThreadPoolInit(ThreadPool *tp,
|
int ThreadPoolInit(ThreadPool *tp, ThreadPoolAttr *attr);
|
||||||
ThreadPoolAttr *attr);
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ThreadPoolAddPersistent
|
* Function: ThreadPoolAddPersistent
|
||||||
@@ -290,9 +281,7 @@ int ThreadPoolInit(ThreadPool *tp,
|
|||||||
* EOUTOFMEM not enough memory to add job.
|
* EOUTOFMEM not enough memory to add job.
|
||||||
* EMAXTHREADS not enough threads to add persistent job.
|
* EMAXTHREADS not enough threads to add persistent job.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int ThreadPoolAddPersistent (ThreadPool*tp,
|
int ThreadPoolAddPersistent(ThreadPool*tp, ThreadPoolJob *job, int *jobId);
|
||||||
ThreadPoolJob *job,
|
|
||||||
int *jobId);
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ThreadPoolGetAttr
|
* Function: ThreadPoolGetAttr
|
||||||
@@ -307,8 +296,7 @@ int ThreadPoolAddPersistent (ThreadPool*tp,
|
|||||||
* 0 on success, nonzero on failure
|
* 0 on success, nonzero on failure
|
||||||
* Always returns 0.
|
* Always returns 0.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int ThreadPoolGetAttr(ThreadPool *tp,
|
int ThreadPoolGetAttr(ThreadPool *tp, ThreadPoolAttr *out);
|
||||||
ThreadPoolAttr *out);
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ThreadPoolSetAttr
|
* Function: ThreadPoolSetAttr
|
||||||
*
|
*
|
||||||
@@ -322,8 +310,7 @@ int ThreadPoolGetAttr(ThreadPool *tp,
|
|||||||
* 0 on success, nonzero on failure
|
* 0 on success, nonzero on failure
|
||||||
* Returns INVALID_POLICY if policy can not be set.
|
* Returns INVALID_POLICY if policy can not be set.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int ThreadPoolSetAttr(ThreadPool *tp,
|
int ThreadPoolSetAttr(ThreadPool *tp, ThreadPoolAttr *attr);
|
||||||
ThreadPoolAttr *attr);
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ThreadPoolAdd
|
* Function: ThreadPoolAdd
|
||||||
@@ -342,9 +329,7 @@ int ThreadPoolSetAttr(ThreadPool *tp,
|
|||||||
* 0 on success, nonzero on failure
|
* 0 on success, nonzero on failure
|
||||||
* EOUTOFMEM if not enough memory to add job.
|
* EOUTOFMEM if not enough memory to add job.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int ThreadPoolAdd (ThreadPool*tp,
|
int ThreadPoolAdd (ThreadPool*tp, ThreadPoolJob *job, int *jobId);
|
||||||
ThreadPoolJob *job,
|
|
||||||
int *jobId);
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ThreadPoolRemove
|
* Function: ThreadPoolRemove
|
||||||
@@ -361,8 +346,7 @@ int ThreadPoolAdd (ThreadPool*tp,
|
|||||||
* 0 on success, nonzero on failure.
|
* 0 on success, nonzero on failure.
|
||||||
* INVALID_JOB_ID if job not found.
|
* INVALID_JOB_ID if job not found.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int ThreadPoolRemove(ThreadPool *tp,
|
int ThreadPoolRemove(ThreadPool *tp, int jobId, ThreadPoolJob *out);
|
||||||
int jobId, ThreadPoolJob *out);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -425,7 +409,6 @@ int TPJobSetPriority(ThreadPoolJob *job, ThreadPriority priority);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TPJobSetFreeFunction(ThreadPoolJob *job, free_routine func);
|
int TPJobSetFreeFunction(ThreadPoolJob *job, free_routine func);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: TPAttrInit
|
* Function: TPAttrInit
|
||||||
*
|
*
|
||||||
|
@@ -1,66 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* Copyright (c) 2000-2003 Intel Corporation
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
* * Neither name of Intel Corporation nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#define EXPORT
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allocates enough memory for the
|
|
||||||
* Formatted string, up to max
|
|
||||||
* specified.
|
|
||||||
* With max set to -1, allocates
|
|
||||||
* as much size as needed.
|
|
||||||
* Memory must be freed using free.
|
|
||||||
*/
|
|
||||||
|
|
||||||
EXPORT int iasnprintf(char **ret,
|
|
||||||
int incr,
|
|
||||||
int max,
|
|
||||||
const char * fmt, ...)
|
|
||||||
#ifndef SPARC_SOLARIS
|
|
||||||
#if (__GNUC__ >= 3)
|
|
||||||
__attribute__((format (__printf__, 4, 5)));
|
|
||||||
#else
|
|
||||||
;
|
|
||||||
#endif
|
|
||||||
EXPORT void iasnprintfFree(char *);
|
|
||||||
#else
|
|
||||||
;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#include "LinkedList.h"
|
#include "LinkedList.h"
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#if (defined(BSD) && BSD >= 199306) || defined(__OSX__)
|
#if (defined(BSD) && BSD >= 199306) || defined(__OSX__) || defined(__APPLE__)
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#else
|
#else
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,153 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
// * Neither name of Intel Corporation nor the names of its contributors
|
|
||||||
// may be used to endorse or promote products derived from this software
|
|
||||||
// without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
#if (defined(BSD) && BSD >= 199306) || defined(__OSX__)
|
|
||||||
#include <stdlib.h>
|
|
||||||
#else
|
|
||||||
#include <malloc.h>
|
|
||||||
#endif
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "iasnprintf.h"
|
|
||||||
|
|
||||||
#ifndef NULL
|
|
||||||
#define NULL 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#define vsnprintf _vsnprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allocates enough memory for the
|
|
||||||
* Formatted string, up to max
|
|
||||||
* specified.
|
|
||||||
* With max set to -1, it allocates as
|
|
||||||
* much size as needed.
|
|
||||||
* Memory must be freed using free.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int
|
|
||||||
iasnprintf( char **ret,
|
|
||||||
int incr,
|
|
||||||
int max,
|
|
||||||
const char *fmt,
|
|
||||||
... )
|
|
||||||
{
|
|
||||||
int size = incr;
|
|
||||||
int retc = 0;
|
|
||||||
va_list ap;
|
|
||||||
char *temp = NULL;
|
|
||||||
|
|
||||||
assert( ret );
|
|
||||||
assert( fmt );
|
|
||||||
( *ret ) = ( char * )malloc( incr );
|
|
||||||
|
|
||||||
if( ( *ret ) == NULL ) return -1;
|
|
||||||
|
|
||||||
while( 1 ) {
|
|
||||||
va_start( ap, fmt );
|
|
||||||
retc = vsnprintf( ( *ret ), size, fmt, ap );
|
|
||||||
va_end( ap );
|
|
||||||
|
|
||||||
if( retc < 0 ) {
|
|
||||||
//size not big enough
|
|
||||||
//and vsnprintf does NOT return the
|
|
||||||
//necessary number of bytes
|
|
||||||
if( ( max != -1 ) && ( size == max ) ) //max reached
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
incr *= 2; //increase increment
|
|
||||||
//increase size and try again
|
|
||||||
if( ( max != -1 ) && ( ( size + incr ) > max ) ) {
|
|
||||||
incr = ( max - size );
|
|
||||||
}
|
|
||||||
|
|
||||||
temp = ( char * )realloc( ( *ret ), size + incr );
|
|
||||||
if( temp == NULL ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
size += incr;
|
|
||||||
( *ret ) = temp;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if( ( retc + 1 ) > size ) {
|
|
||||||
//size not big enough
|
|
||||||
//and vsnprintf
|
|
||||||
//returns the necessary
|
|
||||||
//number of bytes
|
|
||||||
if( ( max != -1 ) && ( retc + 1 > max ) ) {
|
|
||||||
retc = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
temp = ( char * )realloc( ( *ret ), retc + 1 );
|
|
||||||
if( temp == NULL ) {
|
|
||||||
retc = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
size = retc + 1;
|
|
||||||
( *ret ) = temp; //size increased try again
|
|
||||||
} else if( ( retc + 1 ) < size ) {
|
|
||||||
//size is bigger than needed
|
|
||||||
//try and reallocate smaller
|
|
||||||
|
|
||||||
temp = ( char * )realloc( ( *ret ), retc + 1 );
|
|
||||||
if( temp != NULL ) {
|
|
||||||
( *ret ) = temp;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
} else //size is just right, exit
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( retc < 0 ) {
|
|
||||||
free( ( *ret ) );
|
|
||||||
( *ret ) = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return retc;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
iasnprintfFree( char *fChar )
|
|
||||||
{
|
|
||||||
free( fChar );
|
|
||||||
fChar = NULL;
|
|
||||||
}
|
|
@@ -11,10 +11,6 @@ AM_CPPFLAGS = \
|
|||||||
-I$(top_srcdir)/threadutil/inc \
|
-I$(top_srcdir)/threadutil/inc \
|
||||||
-I$(top_srcdir)/ixml/inc
|
-I$(top_srcdir)/ixml/inc
|
||||||
|
|
||||||
AM_CFLAGS = $(PTHREAD_CFLAGS)
|
|
||||||
|
|
||||||
AM_LDFLAGS = $(PTHREAD_LIBS)
|
|
||||||
|
|
||||||
LDADD = \
|
LDADD = \
|
||||||
libupnp.la \
|
libupnp.la \
|
||||||
$(top_builddir)/threadutil/libthreadutil.la \
|
$(top_builddir)/threadutil/libthreadutil.la \
|
||||||
|
@@ -413,7 +413,7 @@
|
|||||||
#define UPNP_E_SUBSCRIBE_UNACCEPTED -301
|
#define UPNP_E_SUBSCRIBE_UNACCEPTED -301
|
||||||
/*! @} */
|
/*! @} */
|
||||||
|
|
||||||
/** @name UPNP_E_UNSUBSCRIBE_UNACCAPTED [-302]
|
/** @name UPNP_E_UNSUBSCRIBE_UNACCEPTED [-302]
|
||||||
* {\tt UPNP_E_UNSUBSCRIBE_UNACCEPTED} signifies that an unsubscribe
|
* {\tt UPNP_E_UNSUBSCRIBE_UNACCEPTED} signifies that an unsubscribe
|
||||||
* request was rejected from the remote side.
|
* request was rejected from the remote side.
|
||||||
*/
|
*/
|
||||||
|
@@ -9,10 +9,6 @@ AM_CPPFLAGS = \
|
|||||||
-I$(top_srcdir)/threadutil/inc \
|
-I$(top_srcdir)/threadutil/inc \
|
||||||
-I$(top_srcdir)/ixml/inc
|
-I$(top_srcdir)/ixml/inc
|
||||||
|
|
||||||
AM_CFLAGS = $(PTHREAD_CFLAGS)
|
|
||||||
|
|
||||||
AM_LDFLAGS = $(PTHREAD_LIBS)
|
|
||||||
|
|
||||||
LDADD = \
|
LDADD = \
|
||||||
$(top_builddir)/upnp/libupnp.la \
|
$(top_builddir)/upnp/libupnp.la \
|
||||||
$(top_builddir)/threadutil/libthreadutil.la \
|
$(top_builddir)/threadutil/libthreadutil.la \
|
||||||
|
@@ -92,10 +92,8 @@ CLIENTONLY( ithread_mutex_t GlobalClientSubscribeMutex; )
|
|||||||
|
|
||||||
TimerThread gTimerThread;
|
TimerThread gTimerThread;
|
||||||
|
|
||||||
ThreadPool gRecvThreadPool;
|
|
||||||
|
|
||||||
ThreadPool gSendThreadPool;
|
ThreadPool gSendThreadPool;
|
||||||
|
ThreadPool gRecvThreadPool;
|
||||||
ThreadPool gMiniServerThreadPool;
|
ThreadPool gMiniServerThreadPool;
|
||||||
|
|
||||||
//Flag to indicate the state of web server
|
//Flag to indicate the state of web server
|
||||||
@@ -410,14 +408,15 @@ UpnpFinish()
|
|||||||
}
|
}
|
||||||
|
|
||||||
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||||
"Inside UpnpFinish : UpnpSdkInit is :%d:\n",
|
"Inside UpnpFinish : UpnpSdkInit is :%d:\n", UpnpSdkInit );
|
||||||
UpnpSdkInit );
|
|
||||||
if( UpnpSdkInit == 1 ) {
|
if( UpnpSdkInit == 1 ) {
|
||||||
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||||
"UpnpFinish : UpnpSdkInit is ONE\n" );
|
"UpnpFinish : UpnpSdkInit is ONE\n" );
|
||||||
}
|
}
|
||||||
PrintThreadPoolStats(&gRecvThreadPool, __FILE__, __LINE__, "Recv Thread Pool");
|
|
||||||
PrintThreadPoolStats(&gSendThreadPool, __FILE__, __LINE__, "Send Thread Pool");
|
PrintThreadPoolStats(&gSendThreadPool, __FILE__, __LINE__, "Send Thread Pool");
|
||||||
|
PrintThreadPoolStats(&gRecvThreadPool, __FILE__, __LINE__, "Recv Thread Pool");
|
||||||
|
PrintThreadPoolStats(&gMiniServerThreadPool, __FILE__, __LINE__, "MiniServer Thread Pool");
|
||||||
|
|
||||||
#ifdef INCLUDE_DEVICE_APIS
|
#ifdef INCLUDE_DEVICE_APIS
|
||||||
if( GetDeviceHandleInfo( &device_handle, &temp ) == HND_DEVICE )
|
if( GetDeviceHandleInfo( &device_handle, &temp ) == HND_DEVICE )
|
||||||
UpnpUnRegisterRootDevice( device_handle );
|
UpnpUnRegisterRootDevice( device_handle );
|
||||||
@@ -429,20 +428,19 @@ UpnpFinish()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
TimerThreadShutdown( &gTimerThread );
|
TimerThreadShutdown( &gTimerThread );
|
||||||
|
|
||||||
StopMiniServer();
|
StopMiniServer();
|
||||||
|
|
||||||
#if EXCLUDE_WEB_SERVER == 0
|
#if EXCLUDE_WEB_SERVER == 0
|
||||||
web_server_destroy();
|
web_server_destroy();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ThreadPoolShutdown(&gSendThreadPool);
|
ThreadPoolShutdown(&gMiniServerThreadPool);
|
||||||
ThreadPoolShutdown(&gRecvThreadPool);
|
ThreadPoolShutdown(&gRecvThreadPool);
|
||||||
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
ThreadPoolShutdown(&gSendThreadPool);
|
||||||
"Exiting UpnpFinish : UpnpSdkInit is :%d:\n", UpnpSdkInit);
|
|
||||||
PrintThreadPoolStats(&gRecvThreadPool, __FILE__, __LINE__, "Recv Thread Pool");
|
|
||||||
PrintThreadPoolStats(&gSendThreadPool, __FILE__, __LINE__, "Send Thread Pool");
|
PrintThreadPoolStats(&gSendThreadPool, __FILE__, __LINE__, "Send Thread Pool");
|
||||||
UpnpCloseLog();
|
PrintThreadPoolStats(&gRecvThreadPool, __FILE__, __LINE__, "Recv Thread Pool");
|
||||||
|
PrintThreadPoolStats(&gMiniServerThreadPool, __FILE__, __LINE__, "MiniServer Thread Pool");
|
||||||
|
|
||||||
#ifdef INCLUDE_CLIENT_APIS
|
#ifdef INCLUDE_CLIENT_APIS
|
||||||
ithread_mutex_destroy(&GlobalClientSubscribeMutex);
|
ithread_mutex_destroy(&GlobalClientSubscribeMutex);
|
||||||
@@ -461,6 +459,9 @@ UpnpFinish()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
UpnpSdkInit = 0;
|
UpnpSdkInit = 0;
|
||||||
|
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||||
|
"Exiting UpnpFinish : UpnpSdkInit is :%d:\n", UpnpSdkInit);
|
||||||
|
UpnpCloseLog();
|
||||||
|
|
||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
|
|
||||||
|
@@ -42,12 +42,12 @@
|
|||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#else
|
#else /* WIN32 */
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
|
|
||||||
typedef int socklen_t;
|
typedef int socklen_t;
|
||||||
#define EAFNOSUPPORT 97
|
#define EAFNOSUPPORT 97
|
||||||
#endif
|
#endif /* WIN32 */
|
||||||
#include "unixutil.h"
|
#include "unixutil.h"
|
||||||
#include "ithread.h"
|
#include "ithread.h"
|
||||||
|
|
||||||
@@ -91,13 +91,12 @@ static MiniServerState gMServState = MSERV_IDLE;
|
|||||||
* Function: SetHTTPGetCallback
|
* Function: SetHTTPGetCallback
|
||||||
*
|
*
|
||||||
* Parameters :
|
* Parameters :
|
||||||
* MiniServerCallback callback ; - HTTP Callback to be invoked
|
* MiniServerCallback callback - HTTP Callback to be invoked
|
||||||
*
|
*
|
||||||
* Description : Set HTTP Get Callback
|
* Description:
|
||||||
|
* Set HTTP Get Callback
|
||||||
*
|
*
|
||||||
* Return: void
|
* Return: void
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
void
|
void
|
||||||
SetHTTPGetCallback( MiniServerCallback callback )
|
SetHTTPGetCallback( MiniServerCallback callback )
|
||||||
@@ -109,31 +108,31 @@ SetHTTPGetCallback( MiniServerCallback callback )
|
|||||||
* Function: SetSoapCallback
|
* Function: SetSoapCallback
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* MiniServerCallback callback ; - SOAP Callback to be invoked
|
* MiniServerCallback callback - SOAP Callback to be invoked
|
||||||
*
|
*
|
||||||
* Description : Set SOAP Callback
|
* Description:
|
||||||
|
* Set SOAP Callback
|
||||||
*
|
*
|
||||||
* Return: void
|
* Return: void
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
#ifdef INCLUDE_DEVICE_APIS
|
||||||
void
|
void
|
||||||
SetSoapCallback( MiniServerCallback callback )
|
SetSoapCallback( MiniServerCallback callback )
|
||||||
{
|
{
|
||||||
gSoapCallback = callback;
|
gSoapCallback = callback;
|
||||||
}
|
}
|
||||||
|
#endif /* INCLUDE_DEVICE_APIS */
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: SetGenaCallback
|
* Function: SetGenaCallback
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* MiniServerCallback callback ; - GENA Callback to be invoked
|
* MiniServerCallback callback - GENA Callback to be invoked
|
||||||
*
|
*
|
||||||
* Description : Set GENA Callback
|
* Description:
|
||||||
|
* Set GENA Callback
|
||||||
*
|
*
|
||||||
* Return: void
|
* Return: void
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
void
|
void
|
||||||
SetGenaCallback( MiniServerCallback callback )
|
SetGenaCallback( MiniServerCallback callback )
|
||||||
@@ -145,17 +144,15 @@ SetGenaCallback( MiniServerCallback callback )
|
|||||||
* Function : dispatch_request
|
* Function : dispatch_request
|
||||||
*
|
*
|
||||||
* Parameters :
|
* Parameters :
|
||||||
* IN SOCKINFO *info ; Socket Information object.
|
* IN SOCKINFO *info - Socket Information object.
|
||||||
* http_parser_t* hparser ; HTTP parser object.
|
* http_parser_t* hparser - HTTP parser object.
|
||||||
*
|
*
|
||||||
* Description : Based on the type pf message, appropriate callback
|
* Description :
|
||||||
* is issued
|
* Based on the type pf message, appropriate callback is issued
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* 0 - On Success
|
* 0 - On Success
|
||||||
* HTTP_INTERNAL_SERVER_ERROR - Callback is NULL
|
* HTTP_INTERNAL_SERVER_ERROR - Callback is NULL
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
static int
|
static int
|
||||||
dispatch_request( IN SOCKINFO * info,
|
dispatch_request( IN SOCKINFO * info,
|
||||||
@@ -203,17 +200,15 @@ dispatch_request( IN SOCKINFO * info,
|
|||||||
* Function: handle_error
|
* Function: handle_error
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
|
* IN SOCKINFO *info - Socket Inforamtion Object
|
||||||
|
* int http_error_code - HTTP Error Code
|
||||||
|
* int major - Major Version Number
|
||||||
|
* int minor - Minor Version Number
|
||||||
*
|
*
|
||||||
* IN SOCKINFO *info ; Socket Inforamtion Object
|
* Description:
|
||||||
* int http_error_code ; HTTP Error Code
|
* Send Error Message
|
||||||
* int major ; Major Version Number
|
|
||||||
* int minor ; Minor Version Number
|
|
||||||
*
|
*
|
||||||
* Description : Send Error Message
|
* Return: void
|
||||||
*
|
|
||||||
* Return : void;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
static UPNP_INLINE void
|
static UPNP_INLINE void
|
||||||
handle_error( IN SOCKINFO * info,
|
handle_error( IN SOCKINFO * info,
|
||||||
@@ -230,12 +225,11 @@ handle_error( IN SOCKINFO * info,
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* void *args ; Request Message to be freed
|
* void *args ; Request Message to be freed
|
||||||
*
|
*
|
||||||
* Description : Free memory assigned for handling request and unitial-
|
* Description:
|
||||||
* -ize socket functionality
|
* Free memory assigned for handling request and unitialize socket
|
||||||
|
* functionality
|
||||||
*
|
*
|
||||||
* Return: void
|
* Return: void
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
static void
|
static void
|
||||||
free_handle_request_arg( void *args )
|
free_handle_request_arg( void *args )
|
||||||
@@ -251,13 +245,12 @@ free_handle_request_arg( void *args )
|
|||||||
* Function: handle_request
|
* Function: handle_request
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* void *args ; Request Message to be handled
|
* void *args - Request Message to be handled
|
||||||
*
|
*
|
||||||
* Description : Receive the request and dispatch it for handling
|
* Description:
|
||||||
|
* Receive the request and dispatch it for handling
|
||||||
*
|
*
|
||||||
* Return: void
|
* Return: void
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
static void
|
static void
|
||||||
handle_request( void *args )
|
handle_request( void *args )
|
||||||
@@ -322,16 +315,14 @@ handle_request( void *args )
|
|||||||
* Function: schedule_request_job
|
* Function: schedule_request_job
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN int connfd ; Socket Descriptor on which connection is accepted
|
* IN int connfd - Socket Descriptor on which connection is accepted
|
||||||
* IN struct sockaddr_in* clientAddr ; Clients Address information
|
* IN struct sockaddr_in* clientAddr - Clients Address information
|
||||||
*
|
*
|
||||||
* Description : Initilize the thread pool to handle a request.
|
* Description:
|
||||||
|
* Initilize the thread pool to handle a request.
|
||||||
* Sets priority for the job and adds the job to the thread pool
|
* Sets priority for the job and adds the job to the thread pool
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* Return: void
|
* Return: void
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
static UPNP_INLINE void
|
static UPNP_INLINE void
|
||||||
schedule_request_job( IN int connfd,
|
schedule_request_job( IN int connfd,
|
||||||
@@ -374,29 +365,28 @@ schedule_request_job( IN int connfd,
|
|||||||
* Function: RunMiniServer
|
* Function: RunMiniServer
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* MiniServerSockArray *miniSock ; Socket Array
|
* MiniServerSockArray *miniSock - Socket Array
|
||||||
*
|
*
|
||||||
* Description : Function runs the miniserver. The MiniServer accepts a
|
* Description:
|
||||||
|
* Function runs the miniserver. The MiniServer accepts a
|
||||||
* new request and schedules a thread to handle the new request.
|
* new request and schedules a thread to handle the new request.
|
||||||
* Checks for socket state and invokes appropriate read and shutdown
|
* Checks for socket state and invokes appropriate read and shutdown
|
||||||
* actions for the Miniserver and SSDP sockets
|
* actions for the Miniserver and SSDP sockets
|
||||||
*
|
*
|
||||||
* Return: void
|
* Return: void
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
static void
|
static void
|
||||||
RunMiniServer( MiniServerSockArray * miniSock )
|
RunMiniServer( MiniServerSockArray * miniSock )
|
||||||
{
|
{
|
||||||
struct sockaddr_in clientAddr;
|
struct sockaddr_in clientAddr;
|
||||||
socklen_t clientLen;
|
socklen_t clientLen;
|
||||||
SOCKET miniServSock,
|
SOCKET connectHnd;
|
||||||
connectHnd;
|
SOCKET miniServSock = miniSock->miniServerSock;
|
||||||
SOCKET miniServStopSock;
|
SOCKET miniServStopSock = miniSock->miniServerStopSock;
|
||||||
SOCKET ssdpSock;
|
SOCKET ssdpSock = miniSock->ssdpSock;
|
||||||
|
#ifdef INCLUDE_CLIENT_APIS
|
||||||
CLIENTONLY( SOCKET ssdpReqSock;
|
SOCKET ssdpReqSock = miniSock->ssdpReqSock;
|
||||||
)
|
#endif
|
||||||
|
|
||||||
fd_set expSet;
|
fd_set expSet;
|
||||||
fd_set rdSet;
|
fd_set rdSet;
|
||||||
@@ -404,66 +394,55 @@ RunMiniServer( MiniServerSockArray * miniSock )
|
|||||||
int byteReceived;
|
int byteReceived;
|
||||||
char requestBuf[256];
|
char requestBuf[256];
|
||||||
|
|
||||||
miniServSock = miniSock->miniServerSock;
|
|
||||||
miniServStopSock = miniSock->miniServerStopSock;
|
|
||||||
|
|
||||||
ssdpSock = miniSock->ssdpSock;
|
|
||||||
|
|
||||||
CLIENTONLY( ssdpReqSock = miniSock->ssdpReqSock;
|
|
||||||
);
|
|
||||||
|
|
||||||
gMServState = MSERV_RUNNING;
|
|
||||||
maxMiniSock = max( miniServSock, miniServStopSock) ;
|
maxMiniSock = max( miniServSock, miniServStopSock) ;
|
||||||
maxMiniSock = max( maxMiniSock, (SOCKET)(ssdpSock) );
|
maxMiniSock = max( maxMiniSock, (SOCKET)(ssdpSock) );
|
||||||
|
#ifdef INCLUDE_CLIENT_APIS
|
||||||
CLIENTONLY( maxMiniSock =
|
maxMiniSock = max( maxMiniSock, (SOCKET)(ssdpReqSock) );
|
||||||
max( maxMiniSock, ( SOCKET ) ( ssdpReqSock ) ) );
|
#endif
|
||||||
|
|
||||||
++maxMiniSock;
|
++maxMiniSock;
|
||||||
|
|
||||||
|
gMServState = MSERV_RUNNING;
|
||||||
while( TRUE ) {
|
while( TRUE ) {
|
||||||
FD_ZERO( &rdSet );
|
FD_ZERO( &rdSet );
|
||||||
FD_ZERO( &expSet );
|
FD_ZERO( &expSet );
|
||||||
|
|
||||||
FD_SET( miniServStopSock, &expSet );
|
FD_SET( miniServStopSock, &expSet );
|
||||||
|
|
||||||
FD_SET( miniServSock, &rdSet );
|
FD_SET( miniServSock, &rdSet );
|
||||||
FD_SET( miniServStopSock, &rdSet );
|
FD_SET( miniServStopSock, &rdSet );
|
||||||
FD_SET( ssdpSock, &rdSet );
|
FD_SET( ssdpSock, &rdSet );
|
||||||
CLIENTONLY( FD_SET( ssdpReqSock, &rdSet ) );
|
#ifdef INCLUDE_CLIENT_APIS
|
||||||
|
FD_SET( ssdpReqSock, &rdSet );
|
||||||
|
#endif
|
||||||
|
|
||||||
if( select( maxMiniSock, &rdSet, NULL, &expSet, NULL ) ==
|
if( select( maxMiniSock, &rdSet, NULL, &expSet, NULL ) ==
|
||||||
UPNP_SOCKETERROR ) {
|
UPNP_SOCKETERROR ) {
|
||||||
UpnpPrintf( UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
||||||
"Error in select call !!!\n" );
|
"Error in select call!\n" );
|
||||||
|
/* Avoid 100% CPU in case of repeated error in select() */
|
||||||
|
isleep( 1 );
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if( FD_ISSET( miniServSock, &rdSet ) ) {
|
if( FD_ISSET( miniServSock, &rdSet ) ) {
|
||||||
clientLen = sizeof( struct sockaddr_in );
|
clientLen = sizeof( struct sockaddr_in );
|
||||||
connectHnd = accept( miniServSock,
|
connectHnd = accept( miniServSock,
|
||||||
( struct sockaddr * )&clientAddr,
|
( struct sockaddr * )&clientAddr, &clientLen );
|
||||||
&clientLen );
|
|
||||||
if( connectHnd == UPNP_INVALID_SOCKET ) {
|
if( connectHnd == UPNP_INVALID_SOCKET ) {
|
||||||
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||||
"miniserver: Error"
|
"miniserver: Error in accepting connection\n" );
|
||||||
" in accepting connection\n" );
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
schedule_request_job( connectHnd, &clientAddr );
|
schedule_request_job( connectHnd, &clientAddr );
|
||||||
}
|
}
|
||||||
|
#ifdef INCLUDE_CLIENT_APIS
|
||||||
// ssdp
|
// ssdp
|
||||||
CLIENTONLY( if( FD_ISSET( ssdpReqSock, &rdSet ) ) {
|
if( FD_ISSET( ssdpReqSock, &rdSet ) ) {
|
||||||
|
readFromSSDPSocket( ssdpReqSock );
|
||||||
readFromSSDPSocket( ssdpReqSock );}
|
}
|
||||||
)
|
#endif
|
||||||
|
|
||||||
if( FD_ISSET( ssdpSock, &rdSet ) ) {
|
if( FD_ISSET( ssdpSock, &rdSet ) ) {
|
||||||
readFromSSDPSocket( ssdpSock );
|
readFromSSDPSocket( ssdpSock );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( FD_ISSET( miniServStopSock, &rdSet ) ) {
|
if( FD_ISSET( miniServStopSock, &rdSet ) ) {
|
||||||
|
|
||||||
clientLen = sizeof( struct sockaddr_in );
|
clientLen = sizeof( struct sockaddr_in );
|
||||||
memset( ( char * )&clientAddr, 0,
|
memset( ( char * )&clientAddr, 0,
|
||||||
sizeof( struct sockaddr_in ) );
|
sizeof( struct sockaddr_in ) );
|
||||||
@@ -479,7 +458,6 @@ RunMiniServer( MiniServerSockArray * miniSock )
|
|||||||
UpnpPrintf( UPNP_PACKET, MSERV, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_PACKET, MSERV, __FILE__, __LINE__,
|
||||||
"Received multicast packet: \n %s\n",
|
"Received multicast packet: \n %s\n",
|
||||||
requestBuf );
|
requestBuf );
|
||||||
|
|
||||||
if( NULL != strstr( requestBuf, "ShutDown" ) ) {
|
if( NULL != strstr( requestBuf, "ShutDown" ) ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -494,30 +472,29 @@ RunMiniServer( MiniServerSockArray * miniSock )
|
|||||||
UpnpCloseSocket( miniServStopSock );
|
UpnpCloseSocket( miniServStopSock );
|
||||||
shutdown( ssdpSock, SD_BOTH );
|
shutdown( ssdpSock, SD_BOTH );
|
||||||
UpnpCloseSocket( ssdpSock );
|
UpnpCloseSocket( ssdpSock );
|
||||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
#ifdef INCLUDE_CLIENT_APIS
|
||||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
shutdown( ssdpReqSock, SD_BOTH );
|
||||||
|
UpnpCloseSocket( ssdpReqSock );
|
||||||
|
#endif
|
||||||
|
|
||||||
free( miniSock );
|
free( miniSock );
|
||||||
|
|
||||||
gMServState = MSERV_IDLE;
|
gMServState = MSERV_IDLE;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: get_port
|
* Function: get_port
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* int sockfd ; Socket Descriptor
|
* int sockfd - Socket Descriptor
|
||||||
*
|
*
|
||||||
* Description : Returns port to which socket, sockfd, is bound.
|
* Description:
|
||||||
|
* Returns port to which socket, sockfd, is bound.
|
||||||
*
|
*
|
||||||
* Return : int,
|
* Return: int
|
||||||
* -1 on error; check errno
|
* -1 on error; check errno
|
||||||
* > 0 means port number
|
* > 0 means port number
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
static int
|
static int
|
||||||
get_port( int sockfd )
|
get_port( int sockfd )
|
||||||
@@ -544,24 +521,24 @@ get_port( int sockfd )
|
|||||||
* Function: get_miniserver_sockets
|
* Function: get_miniserver_sockets
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* MiniServerSockArray *out ; Socket Array
|
* MiniServerSockArray *out - Socket Array
|
||||||
* unsigned short listen_port ; port on which the server is listening
|
* unsigned short listen_port - port on which the server is
|
||||||
* for incoming connections
|
* listening for incoming connections
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Creates a STREAM socket, binds to INADDR_ANY and listens for
|
||||||
|
* incoming connecttions. Returns the actual port which the sockets
|
||||||
|
* sub-system returned.
|
||||||
*
|
*
|
||||||
* Description : Creates a STREAM socket, binds to INADDR_ANY and
|
|
||||||
* listens for incoming connecttions. Returns the actual port which
|
|
||||||
* the sockets sub-system returned.
|
|
||||||
* Also creates a DGRAM socket, binds to the loop back address and
|
* Also creates a DGRAM socket, binds to the loop back address and
|
||||||
* returns the port allocated by the socket sub-system.
|
* returns the port allocated by the socket sub-system.
|
||||||
*
|
*
|
||||||
* Return : int :
|
* Return: int
|
||||||
* UPNP_E_OUTOF_SOCKET - Failed to create a socket
|
* UPNP_E_OUTOF_SOCKET - Failed to create a socket
|
||||||
* UPNP_E_SOCKET_BIND - Bind() failed
|
* UPNP_E_SOCKET_BIND - Bind() failed
|
||||||
* UPNP_E_LISTEN - Listen() failed
|
* UPNP_E_LISTEN - Listen() failed
|
||||||
* UPNP_E_INTERNAL_ERROR - Port returned by the socket layer is < 0
|
* UPNP_E_INTERNAL_ERROR - Port returned by the socket layer is < 0
|
||||||
* UPNP_E_SUCCESS - Success
|
* UPNP_E_SUCCESS - Success
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
get_miniserver_sockets( MiniServerSockArray * out,
|
get_miniserver_sockets( MiniServerSockArray * out,
|
||||||
@@ -692,8 +669,8 @@ get_miniserver_sockets( MiniServerSockArray * out,
|
|||||||
miniStopSockPort = get_port( miniServerStopSock );
|
miniStopSockPort = get_port( miniServerStopSock );
|
||||||
if( miniStopSockPort <= 0 ) {
|
if( miniStopSockPort <= 0 ) {
|
||||||
shutdown( miniServerStopSock, SD_BOTH );
|
shutdown( miniServerStopSock, SD_BOTH );
|
||||||
shutdown( listenfd, SD_BOTH );
|
|
||||||
UpnpCloseSocket( miniServerStopSock );
|
UpnpCloseSocket( miniServerStopSock );
|
||||||
|
shutdown( listenfd, SD_BOTH );
|
||||||
UpnpCloseSocket( listenfd );
|
UpnpCloseSocket( listenfd );
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
@@ -711,10 +688,11 @@ get_miniserver_sockets( MiniServerSockArray * out,
|
|||||||
* Function: StartMiniServer
|
* Function: StartMiniServer
|
||||||
*
|
*
|
||||||
* Parameters :
|
* Parameters :
|
||||||
* unsigned short listen_port ; Port on which the server listens for
|
* unsigned short listen_port - Port on which the server listens for
|
||||||
* incoming connections
|
* incoming connections
|
||||||
*
|
*
|
||||||
* Description : Initialize the sockets functionality for the
|
* Description:
|
||||||
|
* Initialize the sockets functionality for the
|
||||||
* Miniserver. Initialize a thread pool job to run the MiniServer
|
* Miniserver. Initialize a thread pool job to run the MiniServer
|
||||||
* and the job to the thread pool. If listen port is 0, port is
|
* and the job to the thread pool. If listen port is 0, port is
|
||||||
* dynamically picked
|
* dynamically picked
|
||||||
@@ -722,17 +700,14 @@ get_miniserver_sockets( MiniServerSockArray * out,
|
|||||||
* Use timer mechanism to start the MiniServer, failure to meet the
|
* Use timer mechanism to start the MiniServer, failure to meet the
|
||||||
* allowed delay aborts the attempt to launch the MiniServer.
|
* allowed delay aborts the attempt to launch the MiniServer.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* Actual port socket is bound to - On Success:
|
* Actual port socket is bound to - On Success
|
||||||
* A negative number UPNP_E_XXX - On Error
|
* A negative number UPNP_E_XXX - On Error
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
StartMiniServer( unsigned short listen_port )
|
StartMiniServer( unsigned short listen_port )
|
||||||
{
|
{
|
||||||
|
|
||||||
int success;
|
int success;
|
||||||
|
|
||||||
int count;
|
int count;
|
||||||
int max_count = 10000;
|
int max_count = 10000;
|
||||||
|
|
||||||
@@ -755,12 +730,10 @@ StartMiniServer( unsigned short listen_port )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( ( success = get_ssdp_sockets( miniSocket ) ) != UPNP_E_SUCCESS ) {
|
if( ( success = get_ssdp_sockets( miniSocket ) ) != UPNP_E_SUCCESS ) {
|
||||||
|
|
||||||
shutdown( miniSocket->miniServerSock, SD_BOTH );
|
shutdown( miniSocket->miniServerSock, SD_BOTH );
|
||||||
UpnpCloseSocket( miniSocket->miniServerSock );
|
UpnpCloseSocket( miniSocket->miniServerSock );
|
||||||
shutdown( miniSocket->miniServerStopSock, SD_BOTH );
|
shutdown( miniSocket->miniServerStopSock, SD_BOTH );
|
||||||
UpnpCloseSocket( miniSocket->miniServerStopSock );
|
UpnpCloseSocket( miniSocket->miniServerStopSock );
|
||||||
|
|
||||||
free( miniSocket );
|
free( miniSocket );
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
@@ -776,14 +749,15 @@ StartMiniServer( unsigned short listen_port )
|
|||||||
|
|
||||||
if( success < 0 ) {
|
if( success < 0 ) {
|
||||||
shutdown( miniSocket->miniServerSock, SD_BOTH );
|
shutdown( miniSocket->miniServerSock, SD_BOTH );
|
||||||
shutdown( miniSocket->miniServerStopSock, SD_BOTH );
|
|
||||||
shutdown( miniSocket->ssdpSock, SD_BOTH );
|
|
||||||
CLIENTONLY( shutdown( miniSocket->ssdpReqSock, SD_BOTH ) );
|
|
||||||
UpnpCloseSocket( miniSocket->miniServerSock );
|
UpnpCloseSocket( miniSocket->miniServerSock );
|
||||||
|
shutdown( miniSocket->miniServerStopSock, SD_BOTH );
|
||||||
UpnpCloseSocket( miniSocket->miniServerStopSock );
|
UpnpCloseSocket( miniSocket->miniServerStopSock );
|
||||||
|
shutdown( miniSocket->ssdpSock, SD_BOTH );
|
||||||
UpnpCloseSocket( miniSocket->ssdpSock );
|
UpnpCloseSocket( miniSocket->ssdpSock );
|
||||||
|
#ifdef INCLUDE_CLIENT_APIS
|
||||||
CLIENTONLY( UpnpCloseSocket( miniSocket->ssdpReqSock ) );
|
shutdown( miniSocket->ssdpReqSock, SD_BOTH );
|
||||||
|
UpnpCloseSocket( miniSocket->ssdpReqSock );
|
||||||
|
#endif
|
||||||
|
|
||||||
return UPNP_E_OUTOF_MEMORY;
|
return UPNP_E_OUTOF_MEMORY;
|
||||||
}
|
}
|
||||||
@@ -796,16 +770,16 @@ StartMiniServer( unsigned short listen_port )
|
|||||||
|
|
||||||
// taking too long to start that thread
|
// taking too long to start that thread
|
||||||
if( count >= max_count ) {
|
if( count >= max_count ) {
|
||||||
|
|
||||||
shutdown( miniSocket->miniServerSock, SD_BOTH );
|
shutdown( miniSocket->miniServerSock, SD_BOTH );
|
||||||
shutdown( miniSocket->miniServerStopSock, SD_BOTH );
|
|
||||||
shutdown( miniSocket->ssdpSock, SD_BOTH );
|
|
||||||
CLIENTONLY( shutdown( miniSocket->ssdpReqSock, SD_BOTH ) );
|
|
||||||
|
|
||||||
UpnpCloseSocket( miniSocket->miniServerSock );
|
UpnpCloseSocket( miniSocket->miniServerSock );
|
||||||
|
shutdown( miniSocket->miniServerStopSock, SD_BOTH );
|
||||||
UpnpCloseSocket( miniSocket->miniServerStopSock );
|
UpnpCloseSocket( miniSocket->miniServerStopSock );
|
||||||
|
shutdown( miniSocket->ssdpSock, SD_BOTH );
|
||||||
UpnpCloseSocket( miniSocket->ssdpSock );
|
UpnpCloseSocket( miniSocket->ssdpSock );
|
||||||
CLIENTONLY( UpnpCloseSocket( miniSocket->ssdpReqSock ) );
|
#ifdef INCLUDE_CLIENT_APIS
|
||||||
|
shutdown( miniSocket->ssdpReqSock, SD_BOTH );
|
||||||
|
UpnpCloseSocket( miniSocket->ssdpReqSock );
|
||||||
|
#endif
|
||||||
|
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
@@ -817,30 +791,30 @@ StartMiniServer( unsigned short listen_port )
|
|||||||
* Function: StopMiniServer
|
* Function: StopMiniServer
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* void ;
|
* void
|
||||||
*
|
*
|
||||||
* Description : Stop and Shutdown the MiniServer and free socket
|
* Description:
|
||||||
|
* Stop and Shutdown the MiniServer and free socket
|
||||||
* resources.
|
* resources.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* Always returns 0
|
* Always returns 0
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
StopMiniServer( void )
|
StopMiniServer( void )
|
||||||
{
|
{
|
||||||
|
|
||||||
int socklen = sizeof( struct sockaddr_in ),
|
int socklen = sizeof( struct sockaddr_in );
|
||||||
sock;
|
int sock;
|
||||||
struct sockaddr_in ssdpAddr;
|
struct sockaddr_in ssdpAddr;
|
||||||
char buf[256] = "ShutDown";
|
char buf[256] = "ShutDown";
|
||||||
int bufLen = strlen( buf );
|
int bufLen = strlen( buf );
|
||||||
|
|
||||||
if( gMServState == MSERV_RUNNING )
|
if( gMServState == MSERV_RUNNING ) {
|
||||||
gMServState = MSERV_STOPPING;
|
gMServState = MSERV_STOPPING;
|
||||||
else
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
sock = socket( AF_INET, SOCK_DGRAM, 0 );
|
sock = socket( AF_INET, SOCK_DGRAM, 0 );
|
||||||
if( sock == UPNP_INVALID_SOCKET ) {
|
if( sock == UPNP_INVALID_SOCKET ) {
|
||||||
@@ -864,3 +838,4 @@ StopMiniServer( void )
|
|||||||
UpnpCloseSocket( sock );
|
UpnpCloseSocket( sock );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -70,8 +70,10 @@
|
|||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
#include "webserver.h"
|
#include "webserver.h"
|
||||||
|
|
||||||
#define DOSOCKET_READ 1
|
|
||||||
#define DOSOCKET_WRITE 0
|
const int CHUNK_HEADER_SIZE = 10;
|
||||||
|
const int CHUNK_TAIL_SIZE = 10;
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_FixUrl
|
* Function: http_FixUrl
|
||||||
@@ -80,7 +82,8 @@
|
|||||||
* IN uri_type* url; URL to be validated and fixed
|
* IN uri_type* url; URL to be validated and fixed
|
||||||
* OUT uri_type* fixed_url; URL after being fixed.
|
* OUT uri_type* fixed_url; URL after being fixed.
|
||||||
*
|
*
|
||||||
* Description: Validates URL
|
* Description:
|
||||||
|
* Validates URL
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* UPNP_E_INVALID_URL
|
* UPNP_E_INVALID_URL
|
||||||
@@ -110,6 +113,7 @@ http_FixUrl( IN uri_type * url,
|
|||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_FixStrUrl
|
* Function: http_FixStrUrl
|
||||||
*
|
*
|
||||||
@@ -118,7 +122,8 @@ http_FixUrl( IN uri_type * url,
|
|||||||
* IN int urlstrlen ; Length of the character string
|
* IN int urlstrlen ; Length of the character string
|
||||||
* OUT uri_type* fixed_url ; Fixed and corrected URL
|
* OUT uri_type* fixed_url ; Fixed and corrected URL
|
||||||
*
|
*
|
||||||
* Description: Parses URL and then validates URL
|
* Description:
|
||||||
|
* Parses URL and then validates URL
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* UPNP_E_INVALID_URL
|
* UPNP_E_INVALID_URL
|
||||||
@@ -138,6 +143,7 @@ http_FixStrUrl( IN char *urlstr,
|
|||||||
return http_FixUrl( &url, fixed_url );
|
return http_FixUrl( &url, fixed_url );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_Connect
|
* Function: http_Connect
|
||||||
*
|
*
|
||||||
@@ -145,8 +151,8 @@ http_FixStrUrl( IN char *urlstr,
|
|||||||
* IN uri_type* destination_url; URL containing destination information
|
* IN uri_type* destination_url; URL containing destination information
|
||||||
* OUT uri_type *url; Fixed and corrected URL
|
* OUT uri_type *url; Fixed and corrected URL
|
||||||
*
|
*
|
||||||
* Description: Gets destination address from URL and then connects to the
|
* Description:
|
||||||
* remote end
|
* Gets destination address from URL and then connects to the remote end
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* socket descriptor on sucess
|
* socket descriptor on sucess
|
||||||
@@ -180,19 +186,21 @@ http_Connect( IN uri_type * destination_url,
|
|||||||
return connfd;
|
return connfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_RecvMessage
|
* Function: http_RecvMessage
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN SOCKINFO *info; Socket information object
|
* IN SOCKINFO *info; Socket information object
|
||||||
* OUT http_parser_t* parser, HTTP parser object
|
* OUT http_parser_t* parser; HTTP parser object
|
||||||
* IN http_method_t request_method; HTTP request method
|
* IN http_method_t request_method; HTTP request method
|
||||||
* IN OUT int* timeout_secs; time out
|
* IN OUT int* timeout_secs; time out
|
||||||
* OUT int* http_error_code; HTTP error code returned
|
* OUT int* http_error_code; HTTP error code returned
|
||||||
*
|
*
|
||||||
* Description: Get the data on the socket and take actions based on the
|
* Description:
|
||||||
* read data to modify the parser objects buffer. If an error is reported
|
* Get the data on the socket and take actions based on the read data
|
||||||
* while parsing the data, the error code is passed in the http_errr_code
|
* to modify the parser objects buffer. If an error is reported while
|
||||||
|
* parsing the data, the error code is passed in the http_errr_code
|
||||||
* parameter
|
* parameter
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
@@ -266,6 +274,7 @@ http_RecvMessage( IN SOCKINFO * info,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_SendMessage
|
* Function: http_SendMessage
|
||||||
*
|
*
|
||||||
@@ -274,7 +283,8 @@ http_RecvMessage( IN SOCKINFO * info,
|
|||||||
* IN OUT int * TimeOut ; time out value
|
* IN OUT int * TimeOut ; time out value
|
||||||
* IN const char* fmt, ... Pattern format to take actions upon
|
* IN const char* fmt, ... Pattern format to take actions upon
|
||||||
*
|
*
|
||||||
* Description: Sends a message to the destination based on the
|
* Description:
|
||||||
|
* Sends a message to the destination based on the
|
||||||
* IN const char* fmt parameter
|
* IN const char* fmt parameter
|
||||||
* fmt types:
|
* fmt types:
|
||||||
* 'f': arg = const char * file name
|
* 'f': arg = const char * file name
|
||||||
@@ -297,22 +307,19 @@ http_SendMessage( IN SOCKINFO * info,
|
|||||||
IN const char *fmt,
|
IN const char *fmt,
|
||||||
... )
|
... )
|
||||||
{
|
{
|
||||||
#define CHUNK_HEADER_SIZE 10
|
|
||||||
#define CHUNK_TAIL_SIZE 10
|
|
||||||
|
|
||||||
char c;
|
char c;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
size_t buf_length;
|
size_t buf_length;
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
FILE *Fp;
|
FILE *Fp;
|
||||||
int num_read,
|
int num_read;
|
||||||
num_written;
|
int num_written;
|
||||||
off_t amount_to_be_read = 0;
|
off_t amount_to_be_read = 0;
|
||||||
va_list argp;
|
va_list argp;
|
||||||
char *file_buf = NULL,
|
char *file_buf = NULL;
|
||||||
*ChunkBuf = NULL;
|
char *ChunkBuf = NULL;
|
||||||
struct SendInstruction *Instr = NULL;
|
struct SendInstruction *Instr = NULL;
|
||||||
char Chunk_Header[10];
|
char Chunk_Header[CHUNK_HEADER_SIZE];
|
||||||
int RetVal = 0;
|
int RetVal = 0;
|
||||||
|
|
||||||
// 10 byte allocated for chunk header.
|
// 10 byte allocated for chunk header.
|
||||||
@@ -322,44 +329,40 @@ http_SendMessage( IN SOCKINFO * info,
|
|||||||
|
|
||||||
while( ( c = *fmt++ ) != 0 ) {
|
while( ( c = *fmt++ ) != 0 ) {
|
||||||
if( c == 'I' ) {
|
if( c == 'I' ) {
|
||||||
Instr = ( struct SendInstruction * )
|
Instr = va_arg(argp, struct SendInstruction *);
|
||||||
va_arg( argp, struct SendInstruction * );
|
|
||||||
|
|
||||||
assert( Instr );
|
assert( Instr );
|
||||||
|
|
||||||
if( Instr->ReadSendSize >= 0 )
|
if( Instr->ReadSendSize >= 0 ) {
|
||||||
amount_to_be_read = Instr->ReadSendSize;
|
amount_to_be_read = Instr->ReadSendSize;
|
||||||
else
|
} else {
|
||||||
amount_to_be_read = Data_Buf_Size;
|
amount_to_be_read = Data_Buf_Size;
|
||||||
|
|
||||||
if( amount_to_be_read < WEB_SERVER_BUF_SIZE )
|
|
||||||
Data_Buf_Size = amount_to_be_read;
|
|
||||||
|
|
||||||
ChunkBuf = ( char * )malloc( Data_Buf_Size +
|
|
||||||
CHUNK_HEADER_SIZE +
|
|
||||||
CHUNK_TAIL_SIZE );
|
|
||||||
if( !ChunkBuf )
|
|
||||||
return UPNP_E_OUTOF_MEMORY;
|
|
||||||
|
|
||||||
file_buf = ChunkBuf + 10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( c == 'f' ) { // file name
|
if( amount_to_be_read < WEB_SERVER_BUF_SIZE ) {
|
||||||
|
Data_Buf_Size = amount_to_be_read;
|
||||||
|
}
|
||||||
|
|
||||||
filename = ( char * )va_arg( argp, char * );
|
ChunkBuf = (char *)malloc(
|
||||||
|
Data_Buf_Size + CHUNK_HEADER_SIZE + CHUNK_TAIL_SIZE);
|
||||||
|
if( !ChunkBuf ) {
|
||||||
|
return UPNP_E_OUTOF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
if( Instr && Instr->IsVirtualFile )
|
file_buf = ChunkBuf + CHUNK_HEADER_SIZE;
|
||||||
|
} else if( c == 'f' ) {
|
||||||
|
// file name
|
||||||
|
filename = va_arg(argp, char *);
|
||||||
|
if( Instr && Instr->IsVirtualFile ) {
|
||||||
Fp = (virtualDirCallback.open)( filename, UPNP_READ );
|
Fp = (virtualDirCallback.open)( filename, UPNP_READ );
|
||||||
else
|
} else {
|
||||||
Fp = fopen( filename, "rb" );
|
Fp = fopen( filename, "rb" );
|
||||||
|
}
|
||||||
if( Fp == NULL ) {
|
if( Fp == NULL ) {
|
||||||
free( ChunkBuf );
|
free( ChunkBuf );
|
||||||
return UPNP_E_FILE_READ_ERROR;
|
return UPNP_E_FILE_READ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert( Fp );
|
|
||||||
|
|
||||||
if( Instr && Instr->IsRangeActive && Instr->IsVirtualFile ) {
|
if( Instr && Instr->IsRangeActive && Instr->IsVirtualFile ) {
|
||||||
if( virtualDirCallback.seek( Fp, Instr->RangeOffset,
|
if( virtualDirCallback.seek( Fp, Instr->RangeOffset,
|
||||||
SEEK_CUR ) != 0 ) {
|
SEEK_CUR ) != 0 ) {
|
||||||
@@ -375,26 +378,14 @@ http_SendMessage( IN SOCKINFO * info,
|
|||||||
|
|
||||||
while( amount_to_be_read ) {
|
while( amount_to_be_read ) {
|
||||||
if( Instr ) {
|
if( Instr ) {
|
||||||
if( amount_to_be_read >= Data_Buf_Size ) {
|
int n = (amount_to_be_read >= Data_Buf_Size) ?
|
||||||
if( Instr->IsVirtualFile )
|
Data_Buf_Size : amount_to_be_read;
|
||||||
num_read = virtualDirCallback.read( Fp,
|
if( Instr->IsVirtualFile ) {
|
||||||
file_buf,
|
num_read = virtualDirCallback.read( Fp, file_buf, n );
|
||||||
Data_Buf_Size );
|
|
||||||
else
|
|
||||||
num_read = fread( file_buf, 1, Data_Buf_Size,
|
|
||||||
Fp );
|
|
||||||
} else {
|
} else {
|
||||||
if( Instr->IsVirtualFile )
|
num_read = fread( file_buf, 1, n, Fp );
|
||||||
num_read = virtualDirCallback.read( Fp,
|
|
||||||
file_buf,
|
|
||||||
amount_to_be_read );
|
|
||||||
else
|
|
||||||
num_read = fread( file_buf, 1,
|
|
||||||
amount_to_be_read, Fp );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
amount_to_be_read = amount_to_be_read - num_read;
|
amount_to_be_read = amount_to_be_read - num_read;
|
||||||
|
|
||||||
if( Instr->ReadSendSize < 0 ) {
|
if( Instr->ReadSendSize < 0 ) {
|
||||||
// read until close
|
// read until close
|
||||||
amount_to_be_read = Data_Buf_Size;
|
amount_to_be_read = Data_Buf_Size;
|
||||||
@@ -403,12 +394,11 @@ http_SendMessage( IN SOCKINFO * info,
|
|||||||
num_read = fread( file_buf, 1, Data_Buf_Size, Fp );
|
num_read = fread( file_buf, 1, Data_Buf_Size, Fp );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( num_read == 0 ) // EOF so no more to send.
|
if( num_read == 0 ) {
|
||||||
{
|
// EOF so no more to send.
|
||||||
if( Instr && Instr->IsChunkActive ) {
|
if( Instr && Instr->IsChunkActive ) {
|
||||||
num_written = sock_write( info, "0\r\n\r\n",
|
char *str = "0\r\n\r\n";
|
||||||
strlen( "0\r\n\r\n" ),
|
num_written = sock_write(info, str, strlen(str), TimeOut);
|
||||||
TimeOut );
|
|
||||||
} else {
|
} else {
|
||||||
RetVal = UPNP_E_FILE_READ_ERROR;
|
RetVal = UPNP_E_FILE_READ_ERROR;
|
||||||
}
|
}
|
||||||
@@ -432,47 +422,41 @@ http_SendMessage( IN SOCKINFO * info,
|
|||||||
// on the top of the buffer.
|
// on the top of the buffer.
|
||||||
//file_buf[num_read+strlen(Chunk_Header)] = NULL;
|
//file_buf[num_read+strlen(Chunk_Header)] = NULL;
|
||||||
//printf("Sending %s\n",file_buf-strlen(Chunk_Header));
|
//printf("Sending %s\n",file_buf-strlen(Chunk_Header));
|
||||||
num_written = sock_write( info,
|
num_written = sock_write(
|
||||||
file_buf -
|
info, file_buf - strlen( Chunk_Header ),
|
||||||
strlen( Chunk_Header ),
|
num_read + strlen( Chunk_Header ) + 2, TimeOut );
|
||||||
num_read +
|
|
||||||
strlen( Chunk_Header ) + 2,
|
|
||||||
TimeOut );
|
|
||||||
|
|
||||||
if( num_written !=
|
if( num_written !=
|
||||||
num_read + ( int )strlen( Chunk_Header )
|
num_read + ( int )strlen( Chunk_Header ) + 2 ) {
|
||||||
+ 2 ) {
|
// Send error nothing we can do.
|
||||||
goto Cleanup_File; //Send error nothing we can do.
|
goto Cleanup_File;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// write data
|
// write data
|
||||||
num_written = sock_write( info, file_buf, num_read,
|
num_written = sock_write( info, file_buf, num_read, TimeOut );
|
||||||
TimeOut );
|
|
||||||
|
|
||||||
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
">>> (SENT) >>>\n%.*s\n------------\n",
|
">>> (SENT) >>>\n%.*s\n------------\n",
|
||||||
( int )num_written, file_buf );
|
( int )num_written, file_buf );
|
||||||
|
|
||||||
// Send error nothing we can do
|
// Send error nothing we can do
|
||||||
if( num_written != num_read ) {
|
if( num_written != num_read ) {
|
||||||
goto Cleanup_File;
|
goto Cleanup_File;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} //While
|
} // while
|
||||||
Cleanup_File:
|
Cleanup_File:
|
||||||
va_end( argp );
|
va_end( argp );
|
||||||
if( Instr && Instr->IsVirtualFile )
|
if( Instr && Instr->IsVirtualFile ) {
|
||||||
virtualDirCallback.close( Fp );
|
virtualDirCallback.close( Fp );
|
||||||
else
|
} else {
|
||||||
fclose( Fp );
|
fclose( Fp );
|
||||||
|
}
|
||||||
free( ChunkBuf );
|
free( ChunkBuf );
|
||||||
return RetVal;
|
return RetVal;
|
||||||
|
|
||||||
} else if( c == 'b' ) { // memory buffer
|
} else if( c == 'b' ) {
|
||||||
|
// memory buffer
|
||||||
buf = ( char * )va_arg( argp, char * );
|
buf = va_arg(argp, char *);
|
||||||
|
buf_length = va_arg(argp, size_t);
|
||||||
buf_length = ( size_t ) va_arg( argp, size_t );
|
|
||||||
if( buf_length > 0 ) {
|
if( buf_length > 0 ) {
|
||||||
num_written = sock_write( info, buf, buf_length, TimeOut );
|
num_written = sock_write( info, buf, buf_length, TimeOut );
|
||||||
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
@@ -480,11 +464,12 @@ http_SendMessage( IN SOCKINFO * info,
|
|||||||
"%.*s\nbuf_length=%d, num_written=%d\n"
|
"%.*s\nbuf_length=%d, num_written=%d\n"
|
||||||
"------------\n",
|
"------------\n",
|
||||||
(int)buf_length, buf, (int)buf_length, num_written );
|
(int)buf_length, buf, (int)buf_length, num_written );
|
||||||
if( ( size_t ) num_written != buf_length )
|
if( (size_t)num_written != buf_length ) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
va_end( argp );
|
va_end( argp );
|
||||||
@@ -492,6 +477,7 @@ http_SendMessage( IN SOCKINFO * info,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_RequestAndResponse
|
* Function: http_RequestAndResponse
|
||||||
*
|
*
|
||||||
@@ -504,7 +490,8 @@ http_SendMessage( IN SOCKINFO * info,
|
|||||||
* IN int timeout_secs; time out value
|
* IN int timeout_secs; time out value
|
||||||
* OUT http_parser_t* response; Parser object to receive the repsonse
|
* OUT http_parser_t* response; Parser object to receive the repsonse
|
||||||
*
|
*
|
||||||
* Description: Initiates socket, connects to the destination, sends a
|
* Description:
|
||||||
|
* Initiates socket, connects to the destination, sends a
|
||||||
* request and waits for the response from the remote end
|
* request and waits for the response from the remote end
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
@@ -564,25 +551,25 @@ http_RequestAndResponse( IN uri_type * destination,
|
|||||||
return ret_code;
|
return ret_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_Download
|
* Function: http_Download
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN const char* url_str: String as a URL
|
* IN const char* url_str; String as a URL
|
||||||
* IN int timeout_secs: time out value
|
* IN int timeout_secs; time out value
|
||||||
* OUT char** document: buffer to store the document extracted
|
* OUT char** document; buffer to store the document extracted
|
||||||
* from the donloaded message.
|
* from the donloaded message.
|
||||||
* OUT int* doc_length: length of the extracted document
|
* OUT int* doc_length; length of the extracted document
|
||||||
* OUT char* content_type: Type of content
|
* OUT char* content_type; Type of content
|
||||||
*
|
*
|
||||||
* Description : Download the document message and extract the document
|
* Description:
|
||||||
|
* Download the document message and extract the document
|
||||||
* from the message.
|
* from the message.
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS;
|
* UPNP_E_SUCCESS
|
||||||
* UPNP_E_INVALID_URL;
|
* UPNP_E_INVALID_URL
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_Download( IN const char *url_str,
|
http_Download( IN const char *url_str,
|
||||||
@@ -684,8 +671,8 @@ http_Download( IN const char *url_str,
|
|||||||
if( ( *doc_length = ( int )response.msg.entity.length ) == 0 ) {
|
if( ( *doc_length = ( int )response.msg.entity.length ) == 0 ) {
|
||||||
// 0-length msg
|
// 0-length msg
|
||||||
*document = NULL;
|
*document = NULL;
|
||||||
} else if( response.msg.status_code == HTTP_OK ) //LEAK_FIX_MK
|
} else if( response.msg.status_code == HTTP_OK ) {
|
||||||
{
|
//LEAK_FIX_MK
|
||||||
// copy entity
|
// copy entity
|
||||||
entity_start = response.msg.entity.buf; // what we want
|
entity_start = response.msg.entity.buf; // what we want
|
||||||
msg_length = response.msg.msg.length; // save for posterity
|
msg_length = response.msg.msg.length; // save for posterity
|
||||||
@@ -727,12 +714,13 @@ typedef struct HTTPPOSTHANDLE {
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* const char *url_str; String as a URL
|
* const char *url_str; String as a URL
|
||||||
* membuffer *request; Buffer containing the request
|
* membuffer *request; Buffer containing the request
|
||||||
* uri_type *url ; URI object containing the scheme, path
|
* uri_type *url; URI object containing the scheme,
|
||||||
* query token, etc.
|
* path query token, etc.
|
||||||
* int contentLength; length of content
|
* int contentLength; length of content
|
||||||
* const char *contentType; Type of content
|
* const char *contentType; Type of content
|
||||||
*
|
*
|
||||||
* Description: Makes the message for the HTTP POST message
|
* Description:
|
||||||
|
* Makes the message for the HTTP POST message
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* UPNP_E_INVALID_URL
|
* UPNP_E_INVALID_URL
|
||||||
@@ -834,15 +822,14 @@ MakePostMessage( const char *url_str,
|
|||||||
* IN unsigned int *size: Size of the data to be sent.
|
* IN unsigned int *size: Size of the data to be sent.
|
||||||
* IN int timeout: time out value
|
* IN int timeout: time out value
|
||||||
*
|
*
|
||||||
* Description : Formats data if format used is UPNP_USING_CHUNKED.
|
* Description:
|
||||||
|
* Formats data if format used is UPNP_USING_CHUNKED.
|
||||||
* Writes data on the socket connected to the peer.
|
* Writes data on the socket connected to the peer.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Success
|
* UPNP_E_SUCCESS - On Success
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
* -1 - On Socket Error.
|
* -1 - On Socket Error.
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_WriteHttpPost( IN void *Handle,
|
http_WriteHttpPost( IN void *Handle,
|
||||||
@@ -864,17 +851,18 @@ http_WriteHttpPost( IN void *Handle,
|
|||||||
if( handle->contentLength == UPNP_USING_CHUNKED ) {
|
if( handle->contentLength == UPNP_USING_CHUNKED ) {
|
||||||
if( ( *size ) ) {
|
if( ( *size ) ) {
|
||||||
int tempSize = 0;
|
int tempSize = 0;
|
||||||
|
tempbuf = ( char * )malloc(
|
||||||
|
*size + CHUNK_HEADER_SIZE + CHUNK_TAIL_SIZE );
|
||||||
|
if ( tempbuf == NULL) {
|
||||||
|
return UPNP_E_OUTOF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
tempbuf =
|
// begin chunk
|
||||||
( char * )malloc( ( *size ) + CHUNK_HEADER_SIZE +
|
sprintf( tempbuf, "%x\r\n", ( *size ) );
|
||||||
CHUNK_TAIL_SIZE );
|
|
||||||
|
|
||||||
if ( tempbuf == NULL) return UPNP_E_OUTOF_MEMORY;
|
|
||||||
|
|
||||||
sprintf( tempbuf, "%x\r\n", ( *size ) ); //begin chunk
|
|
||||||
tempSize = strlen( tempbuf );
|
tempSize = strlen( tempbuf );
|
||||||
memcpy( tempbuf + tempSize, buf, ( *size ) );
|
memcpy( tempbuf + tempSize, buf, ( *size ) );
|
||||||
memcpy( tempbuf + tempSize + ( *size ), "\r\n", 2 ); //end of chunk
|
memcpy( tempbuf + tempSize + ( *size ), "\r\n", 2 );
|
||||||
|
// end of chunk
|
||||||
tempbufSize = tempSize + ( *size ) + 2;
|
tempbufSize = tempSize + ( *size ) + 2;
|
||||||
freeTempbuf = 1;
|
freeTempbuf = 1;
|
||||||
}
|
}
|
||||||
@@ -903,20 +891,19 @@ http_WriteHttpPost( IN void *Handle,
|
|||||||
* Function: http_CloseHttpPost
|
* Function: http_CloseHttpPost
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN void *Handle : Handle to the http post object
|
* IN void *Handle; Handle to the http post object
|
||||||
* IN OUT int *httpStatus : HTTP status returned on receiving a
|
* IN OUT int *httpStatus; HTTP status returned on receiving a
|
||||||
* response message
|
* response message
|
||||||
* IN int timeout : time out value
|
* IN int timeout; time out value
|
||||||
*
|
*
|
||||||
* Description : Sends remaining data if using UPNP_USING_CHUNKED
|
* Description:
|
||||||
|
* Sends remaining data if using UPNP_USING_CHUNKED
|
||||||
* format. Receives any more messages. Destroys socket and any socket
|
* format. Receives any more messages. Destroys socket and any socket
|
||||||
* associated memory. Frees handle associated with the HTTP POST msg.
|
* associated memory. Frees handle associated with the HTTP POST msg.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Sucess ;
|
* UPNP_E_SUCCESS - On Sucess
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter;
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_CloseHttpPost( IN void *Handle,
|
http_CloseHttpPost( IN void *Handle,
|
||||||
@@ -957,25 +944,24 @@ http_CloseHttpPost( IN void *Handle,
|
|||||||
* Function: http_OpenHttpPost
|
* Function: http_OpenHttpPost
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN const char *url_str : String as a URL
|
* IN const char *url_str; String as a URL
|
||||||
* IN OUT void **Handle : Pointer to buffer to store HTTP
|
* IN OUT void **Handle; Pointer to buffer to store HTTP
|
||||||
* post handle
|
* post handle
|
||||||
* IN const char *contentType : Type of content
|
* IN const char *contentType; Type of content
|
||||||
* IN int contentLength : length of content
|
* IN int contentLength; length of content
|
||||||
* IN int timeout : time out value
|
* IN int timeout; time out value
|
||||||
*
|
*
|
||||||
* Description : Makes the HTTP POST message, connects to the peer,
|
* Description:
|
||||||
|
* Makes the HTTP POST message, connects to the peer,
|
||||||
* sends the HTTP POST request. Adds the post handle to buffer of
|
* sends the HTTP POST request. Adds the post handle to buffer of
|
||||||
* such handles
|
* such handles
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return : int;
|
||||||
* UPNP_E_SUCCESS - On Sucess ;
|
* UPNP_E_SUCCESS - On Sucess
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Paramter ;
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
* UPNP_E_OUTOF_MEMORY ;
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_SOCKET_ERROR ;
|
* UPNP_E_SOCKET_ERROR
|
||||||
* UPNP_E_SOCKET_CONNECT ;
|
* UPNP_E_SOCKET_CONNECT
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_OpenHttpPost( IN const char *url_str,
|
http_OpenHttpPost( IN const char *url_str,
|
||||||
@@ -1063,7 +1049,8 @@ typedef struct HTTPGETHANDLE {
|
|||||||
* uri_type *url ; URI object containing the scheme, path
|
* uri_type *url ; URI object containing the scheme, path
|
||||||
* query token, etc.
|
* query token, etc.
|
||||||
*
|
*
|
||||||
* Description: Makes the message for the HTTP GET method
|
* Description:
|
||||||
|
* Makes the message for the HTTP GET method
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* UPNP_E_INVALID_URL
|
* UPNP_E_INVALID_URL
|
||||||
@@ -1153,16 +1140,15 @@ MakeGetMessage( const char *url_str,
|
|||||||
* IN OUT int *timeout_secs; time out value
|
* IN OUT int *timeout_secs; time out value
|
||||||
* IN OUT int *http_error_code; HTTP errror code returned
|
* IN OUT int *http_error_code; HTTP errror code returned
|
||||||
*
|
*
|
||||||
* Description : Parses already exiting data. If not complete reads more
|
* Description:
|
||||||
|
* Parses already exiting data. If not complete reads more
|
||||||
* data on the connected socket. The read data is then parsed. The
|
* data on the connected socket. The read data is then parsed. The
|
||||||
* same methid is carried out for headers.
|
* same methid is carried out for headers.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* PARSE_OK - On Success
|
* PARSE_OK - On Success
|
||||||
* PARSE_FAILURE - Failure to parse data correctly
|
* PARSE_FAILURE - Failure to parse data correctly
|
||||||
* UPNP_E_BAD_HTTPMSG - Socker read() returns an error
|
* UPNP_E_BAD_HTTPMSG - Socker read() returns an error
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
ReadResponseLineAndHeaders( IN SOCKINFO * info,
|
ReadResponseLineAndHeaders( IN SOCKINFO * info,
|
||||||
@@ -1273,22 +1259,21 @@ ReadResponseLineAndHeaders( IN SOCKINFO * info,
|
|||||||
* Function: http_ReadHttpGet
|
* Function: http_ReadHttpGet
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN void *Handle : Handle to the HTTP get object
|
* IN void *Handle; Handle to the HTTP get object
|
||||||
* IN OUT char *buf : Buffer to get the read and parsed data
|
* IN OUT char *buf; Buffer to get the read and parsed data
|
||||||
* IN OUT unsigned int *size : Size of the buffer passed
|
* IN OUT unsigned int *size; Size of the buffer passed
|
||||||
* IN int timeout : time out value
|
* IN int timeout; time out value
|
||||||
*
|
*
|
||||||
* Description : Parses already existing data, then gets new data.
|
* Description:
|
||||||
|
* Parses already existing data, then gets new data.
|
||||||
* Parses and extracts information from the new data.
|
* Parses and extracts information from the new data.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Sucess ;
|
* UPNP_E_SUCCESS - On Sucess
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter;
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
* UPNP_E_BAD_RESPONSE ;
|
* UPNP_E_BAD_RESPONSE
|
||||||
* UPNP_E_BAD_HTTPMSG ;
|
* UPNP_E_BAD_HTTPMSG
|
||||||
* UPNP_E_CANCELED ;
|
* UPNP_E_CANCELED
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_ReadHttpGet( IN void *Handle,
|
http_ReadHttpGet( IN void *Handle,
|
||||||
@@ -1398,18 +1383,16 @@ http_ReadHttpGet( IN void *Handle,
|
|||||||
* Function: http_HttpGetProgress
|
* Function: http_HttpGetProgress
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN void *Handle : Handle to the HTTP get object
|
* IN void *Handle; Handle to the HTTP get object
|
||||||
* OUT unsigned int *length : Buffer to get the read and parsed data
|
* OUT unsigned int *length; Buffer to get the read and parsed data
|
||||||
* OUT unsigned int *total : Size of tge buffer passed
|
* OUT unsigned int *total; Size of tge buffer passed
|
||||||
*
|
*
|
||||||
* Description : Extracts information from the Handle to the HTTP get
|
* Description:
|
||||||
* object.
|
* Extracts information from the Handle to the HTTP get object.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Sucess ;
|
* UPNP_E_SUCCESS - On Sucess
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter;
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_HttpGetProgress( IN void *Handle,
|
int http_HttpGetProgress( IN void *Handle,
|
||||||
OUT unsigned int *length,
|
OUT unsigned int *length,
|
||||||
@@ -1431,13 +1414,12 @@ int http_HttpGetProgress( IN void *Handle,
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* IN void *Handle; Handle to HTTP get object
|
* IN void *Handle; Handle to HTTP get object
|
||||||
*
|
*
|
||||||
* Description : Set the cancel flag of the HttpGet handle
|
* Description:
|
||||||
|
* Set the cancel flag of the HttpGet handle
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Success
|
* UPNP_E_SUCCESS - On Success
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_CancelHttpGet( IN void *Handle )
|
http_CancelHttpGet( IN void *Handle )
|
||||||
@@ -1460,14 +1442,13 @@ http_CancelHttpGet( IN void *Handle )
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* IN void *Handle; Handle to HTTP get object
|
* IN void *Handle; Handle to HTTP get object
|
||||||
*
|
*
|
||||||
* Description : Clears the handle allocated for the HTTP GET operation
|
* Description:
|
||||||
|
* Clears the handle allocated for the HTTP GET operation
|
||||||
* Clears socket states and memory allocated for socket operations.
|
* Clears socket states and memory allocated for socket operations.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Success
|
* UPNP_E_SUCCESS - On Success
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_CloseHttpGet( IN void *Handle )
|
http_CloseHttpGet( IN void *Handle )
|
||||||
@@ -1498,19 +1479,17 @@ http_CloseHttpGet( IN void *Handle )
|
|||||||
* response message
|
* response message
|
||||||
* IN int timeout: time out value
|
* IN int timeout: time out value
|
||||||
*
|
*
|
||||||
* Description : Makes the HTTP GET message, connects to the peer,
|
* Description:
|
||||||
|
* Makes the HTTP GET message, connects to the peer,
|
||||||
* sends the HTTP GET request, gets the response and parses the
|
* sends the HTTP GET request, gets the response and parses the
|
||||||
* response.
|
* response.
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Success ;
|
* UPNP_E_SUCCESS - On Success
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Paramters ;
|
* UPNP_E_INVALID_PARAM - Invalid Paramters
|
||||||
* UPNP_E_OUTOF_MEMORY ;
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_SOCKET_ERROR ;
|
* UPNP_E_SOCKET_ERROR
|
||||||
* UPNP_E_BAD_RESPONSE ;
|
* UPNP_E_BAD_RESPONSE
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
*
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_OpenHttpGet( IN const char *url_str,
|
http_OpenHttpGet( IN const char *url_str,
|
||||||
@@ -1527,30 +1506,27 @@ http_OpenHttpGet( IN const char *url_str,
|
|||||||
* Function: http_OpenHttpGetProxy
|
* Function: http_OpenHttpGetProxy
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN const char *url_str : String as a URL
|
* IN const char *url_str; String as a URL
|
||||||
* IN const char *proxy_str : String as a URL
|
* IN const char *proxy_str; String as a URL
|
||||||
* IN OUT void **Handle : Pointer to buffer to store HTTP
|
* IN OUT void **Handle; Pointer to buffer to store HTTP
|
||||||
* post handle
|
* post handle
|
||||||
* IN OUT char **contentType : Type of content
|
* IN OUT char **contentType; Type of content
|
||||||
* OUT int *contentLength : length of content
|
* OUT int *contentLength; length of content
|
||||||
* OUT int *httpStatus : HTTP status returned on receiving a
|
* OUT int *httpStatus; HTTP status returned on receiving a
|
||||||
* response message
|
* response message
|
||||||
* IN int timeout: time out value
|
* IN int timeout: time out value
|
||||||
*
|
*
|
||||||
* Description : Makes the HTTP GET message, connects to the peer,
|
* Description:
|
||||||
* sends the HTTP GET request, gets the response and parses the
|
* Makes the HTTP GET message, connects to the peer,
|
||||||
* response.
|
* sends the HTTP GET request, gets the response and parses the response.
|
||||||
* If a proxy URL is defined then the connection is made there.
|
* If a proxy URL is defined then the connection is made there.
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Success ;
|
* UPNP_E_SUCCESS - On Success
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Paramters ;
|
* UPNP_E_INVALID_PARAM - Invalid Paramters
|
||||||
* UPNP_E_OUTOF_MEMORY ;
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_SOCKET_ERROR ;
|
* UPNP_E_SOCKET_ERROR
|
||||||
* UPNP_E_BAD_RESPONSE ;
|
* UPNP_E_BAD_RESPONSE
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
*
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_OpenHttpGetProxy( IN const char *url_str,
|
http_OpenHttpGetProxy( IN const char *url_str,
|
||||||
@@ -1685,22 +1661,21 @@ http_OpenHttpGetProxy( IN const char *url_str,
|
|||||||
* Function: http_SendStatusResponse
|
* Function: http_SendStatusResponse
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN SOCKINFO *info : Socket information object
|
* IN SOCKINFO *info; Socket information object
|
||||||
* IN int http_status_code : error code returned while making
|
* IN int http_status_code; error code returned while making
|
||||||
* or sending the response message
|
* or sending the response message
|
||||||
* IN int request_major_version : request major version
|
* IN int request_major_version; request major version
|
||||||
* IN int request_minor_version : request minor version
|
* IN int request_minor_version; request minor version
|
||||||
*
|
*
|
||||||
* Description : Generate a response message for the status query and
|
* Description:
|
||||||
* send the status response.
|
* Generate a response message for the status query and send the
|
||||||
|
* status response.
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* 0 -- success
|
* 0 -- success
|
||||||
* UPNP_E_OUTOF_MEMORY
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_SOCKET_WRITE
|
* UPNP_E_SOCKET_WRITE
|
||||||
* UPNP_E_TIMEDOUT
|
* UPNP_E_TIMEDOUT
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_SendStatusResponse( IN SOCKINFO * info,
|
http_SendStatusResponse( IN SOCKINFO * info,
|
||||||
@@ -1736,23 +1711,26 @@ http_SendStatusResponse( IN SOCKINFO * info,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_MakeMessage
|
* Function: http_MakeMessage
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* INOUT membuffer* buf : buffer with the contents of the
|
* INOUT membuffer* buf; buffer with the contents of the
|
||||||
* message
|
* message
|
||||||
* IN int http_major_version : HTTP major version
|
* IN int http_major_version; HTTP major version
|
||||||
* IN int http_minor_version : HTTP minor version
|
* IN int http_minor_version; HTTP minor version
|
||||||
* IN const char* fmt : Pattern format
|
* IN const char* fmt; Pattern format
|
||||||
* ... :
|
* ...;
|
||||||
*
|
*
|
||||||
* Description : Generate an HTTP message based on the format that is
|
* Description:
|
||||||
* specified in the input parameters.
|
* Generate an HTTP message based on the format that is specified
|
||||||
|
* in the input parameters.
|
||||||
*
|
*
|
||||||
* fmt types:
|
* fmt types:
|
||||||
* 'B': arg = int status_code
|
* 'B': arg = int status_code
|
||||||
* appends content-length, content-type and HTML body for given code
|
* appends content-length, content-type and HTML body
|
||||||
|
* for given code
|
||||||
* 'b': arg1 = const char* buf;
|
* 'b': arg1 = const char* buf;
|
||||||
* arg2 = size_t buf_length memory ptr
|
* arg2 = size_t buf_length memory ptr
|
||||||
* 'C': (no args) appends a HTTP CONNECTION: close header
|
* 'C': (no args) appends a HTTP CONNECTION: close header
|
||||||
@@ -1778,12 +1756,10 @@ http_SendStatusResponse( IN SOCKINFO * info,
|
|||||||
* 'U': (no args) appends HTTP USER-AGENT: header
|
* 'U': (no args) appends HTTP USER-AGENT: header
|
||||||
* 'X': arg = const char useragent; "redsonic" HTTP X-User-Agent: useragent
|
* 'X': arg = const char useragent; "redsonic" HTTP X-User-Agent: useragent
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* 0 - On Success
|
* 0 - On Success
|
||||||
* UPNP_E_OUTOF_MEMORY
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_INVALID_URL;
|
* UPNP_E_INVALID_URL
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_MakeMessage( INOUT membuffer * buf,
|
http_MakeMessage( INOUT membuffer * buf,
|
||||||
@@ -2038,21 +2014,20 @@ error_handler:
|
|||||||
return error_code;
|
return error_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_CalcResponseVersion
|
* Function: http_CalcResponseVersion
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN int request_major_vers : Request major version
|
* IN int request_major_vers; Request major version
|
||||||
* IN int request_minor_vers : Request minor version
|
* IN int request_minor_vers; Request minor version
|
||||||
* OUT int* response_major_vers : Response mojor version
|
* OUT int* response_major_vers; Response mojor version
|
||||||
* OUT int* response_minor_vers : Response minor version
|
* OUT int* response_minor_vers; Response minor version
|
||||||
*
|
*
|
||||||
* Description : Calculate HTTP response versions based on the request
|
* Description:
|
||||||
* versions.
|
* Calculate HTTP response versions based on the request versions.
|
||||||
*
|
*
|
||||||
* Return: void
|
* Return: void
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
void
|
void
|
||||||
http_CalcResponseVersion( IN int request_major_vers,
|
http_CalcResponseVersion( IN int request_major_vers,
|
||||||
@@ -2080,7 +2055,8 @@ http_CalcResponseVersion( IN int request_major_vers,
|
|||||||
* uri_type *url; URI object containing the scheme, path
|
* uri_type *url; URI object containing the scheme, path
|
||||||
* query token, etc.
|
* query token, etc.
|
||||||
*
|
*
|
||||||
* Description: Makes the message for the HTTP GET method
|
* Description:
|
||||||
|
* Makes the message for the HTTP GET method
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* UPNP_E_INVALID_URL
|
* UPNP_E_INVALID_URL
|
||||||
@@ -2167,28 +2143,26 @@ MakeGetMessageEx( const char *url_str,
|
|||||||
* Function: http_OpenHttpGetEx
|
* Function: http_OpenHttpGetEx
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN const char *url_str : String as a URL
|
* IN const char *url_str; String as a URL
|
||||||
* IN OUT void **Handle : Pointer to buffer to store HTTP
|
* IN OUT void **Handle; Pointer to buffer to store HTTP
|
||||||
* post handle
|
* post handle
|
||||||
* IN OUT char **contentType : Type of content
|
* IN OUT char **contentType; Type of content
|
||||||
* OUT int *contentLength : length of content
|
* OUT int *contentLength; length of content
|
||||||
* OUT int *httpStatus : HTTP status returned on receiving a
|
* OUT int *httpStatus; HTTP status returned on receiving a
|
||||||
* response message
|
* response message
|
||||||
* IN int timeout : time out value
|
* IN int timeout; time out value
|
||||||
*
|
*
|
||||||
* Description : Makes the HTTP GET message, connects to the peer,
|
* Description:
|
||||||
|
* Makes the HTTP GET message, connects to the peer,
|
||||||
* sends the HTTP GET request, gets the response and parses the
|
* sends the HTTP GET request, gets the response and parses the
|
||||||
* response.
|
* response.
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Success ;
|
* UPNP_E_SUCCESS - On Success
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Paramters ;
|
* UPNP_E_INVALID_PARAM - Invalid Paramters
|
||||||
* UPNP_E_OUTOF_MEMORY ;
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_SOCKET_ERROR ;
|
* UPNP_E_SOCKET_ERROR
|
||||||
* UPNP_E_BAD_RESPONSE ;
|
* UPNP_E_BAD_RESPONSE
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
*
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_OpenHttpGetEx( IN const char *url_str,
|
http_OpenHttpGetEx( IN const char *url_str,
|
||||||
@@ -2335,19 +2309,18 @@ http_OpenHttpGetEx( IN const char *url_str,
|
|||||||
return errCode;
|
return errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: get_sdk_info
|
* Function: get_sdk_info
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* OUT char *info : buffer to store the operating system
|
* OUT char *info; buffer to store the operating system information
|
||||||
* information
|
|
||||||
*
|
*
|
||||||
* Description : Returns the server information for the operating
|
* Description:
|
||||||
* system
|
* Returns the server information for the operating system
|
||||||
*
|
*
|
||||||
* Return : UPNP_INLINE void
|
* Return:
|
||||||
*
|
* UPNP_INLINE void
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
// 'info' should have a size of at least 100 bytes
|
// 'info' should have a size of at least 100 bytes
|
||||||
void
|
void
|
||||||
@@ -2356,11 +2329,18 @@ get_sdk_info( OUT char *info )
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
OSVERSIONINFO versioninfo;
|
OSVERSIONINFO versioninfo;
|
||||||
versioninfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
versioninfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||||
if (GetVersionEx(&versioninfo)!=0)
|
|
||||||
sprintf( info, "%d.%d.%d %d/%s, UPnP/1.0, Portable SDK for UPnP devices/"PACKAGE_VERSION"\r\n",
|
if (GetVersionEx(&versioninfo)!=0) {
|
||||||
versioninfo.dwMajorVersion, versioninfo.dwMinorVersion, versioninfo.dwBuildNumber, versioninfo.dwPlatformId, versioninfo.szCSDVersion );
|
sprintf( info,
|
||||||
else
|
"%d.%d.%d %d/%s, UPnP/1.0, Portable SDK for UPnP devices/"PACKAGE_VERSION"\r\n",
|
||||||
|
versioninfo.dwMajorVersion,
|
||||||
|
versioninfo.dwMinorVersion,
|
||||||
|
versioninfo.dwBuildNumber,
|
||||||
|
versioninfo.dwPlatformId,
|
||||||
|
versioninfo.szCSDVersion );
|
||||||
|
} else {
|
||||||
*info = '\0';
|
*info = '\0';
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
int ret_code;
|
int ret_code;
|
||||||
struct utsname sys_info;
|
struct utsname sys_info;
|
||||||
@@ -2369,9 +2349,10 @@ get_sdk_info( OUT char *info )
|
|||||||
if( ret_code == -1 ) {
|
if( ret_code == -1 ) {
|
||||||
*info = '\0';
|
*info = '\0';
|
||||||
}
|
}
|
||||||
|
sprintf( info,
|
||||||
sprintf( info, "%s/%s, UPnP/1.0, Portable SDK for UPnP devices/"
|
"%s/%s, UPnP/1.0, Portable SDK for UPnP devices/"PACKAGE_VERSION "\r\n",
|
||||||
PACKAGE_VERSION "\r\n",
|
sys_info.sysname,
|
||||||
sys_info.sysname, sys_info.release );
|
sys_info.release );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,10 +29,10 @@
|
|||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/************************************************************************
|
/******************************************************************************
|
||||||
* Purpose: This file defines the Web Server and has functions to carry out
|
* Purpose: This file defines the Web Server and has functions to carry out
|
||||||
* operations of the Web Server.
|
* operations of the Web Server.
|
||||||
************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@@ -64,7 +64,11 @@
|
|||||||
/*
|
/*
|
||||||
Response Types
|
Response Types
|
||||||
*/
|
*/
|
||||||
enum resp_type { RESP_FILEDOC, RESP_XMLDOC, RESP_HEADERS, RESP_WEBDOC,
|
enum resp_type {
|
||||||
|
RESP_FILEDOC,
|
||||||
|
RESP_XMLDOC,
|
||||||
|
RESP_HEADERS,
|
||||||
|
RESP_WEBDOC,
|
||||||
RESP_POST };
|
RESP_POST };
|
||||||
|
|
||||||
// mapping of file extension to content-type of document
|
// mapping of file extension to content-type of document
|
||||||
@@ -182,12 +186,9 @@ static const char *gEncodedMediaTypes =
|
|||||||
"zip\0" APPLICATION_STR "zip\0" "\0";
|
"zip\0" APPLICATION_STR "zip\0" "\0";
|
||||||
// *** end ***
|
// *** end ***
|
||||||
|
|
||||||
/***********************************************************************/
|
/************************************************************************
|
||||||
/*
|
|
||||||
module variables - Globals, static and externs
|
module variables - Globals, static and externs
|
||||||
*/
|
************************************************************************/
|
||||||
|
|
||||||
/***********************************************************************/
|
|
||||||
static struct document_type_t gMediaTypeList[NUM_MEDIA_TYPES];
|
static struct document_type_t gMediaTypeList[NUM_MEDIA_TYPES];
|
||||||
membuffer gDocumentRootDir; // a local dir which serves as webserver root
|
membuffer gDocumentRootDir; // a local dir which serves as webserver root
|
||||||
static struct xml_alias_t gAliasDoc; // XML document
|
static struct xml_alias_t gAliasDoc; // XML document
|
||||||
@@ -589,10 +590,9 @@ web_server_destroy( void )
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* IN const char* filename ; Filename having the description document
|
* IN const char* filename ; Filename having the description document
|
||||||
* OUT struct File_Info * info ; File information object having file
|
* OUT struct File_Info * info ; File information object having file
|
||||||
* attributes such as filelength, when was
|
* attributes such as filelength, when was the file last
|
||||||
* the file last modified, whether a file
|
* modified, whether a file or a directory and whether the
|
||||||
* or a directory and whether the file or
|
* file or directory is readable.
|
||||||
* directory is readable.
|
|
||||||
*
|
*
|
||||||
* Description: Release memory allocated for the global web server root
|
* Description: Release memory allocated for the global web server root
|
||||||
* directory and the global XML document
|
* directory and the global XML document
|
||||||
@@ -689,8 +689,7 @@ web_server_set_root_dir( IN const char *root_dir )
|
|||||||
* OUT struct xml_alias_t* alias ; xml alias object which has a file name
|
* OUT struct xml_alias_t* alias ; xml alias object which has a file name
|
||||||
* stored
|
* stored
|
||||||
* OUT struct File_Info * info ; File information object which will be
|
* OUT struct File_Info * info ; File information object which will be
|
||||||
* filled up if the file comparison
|
* filled up if the file comparison succeeds
|
||||||
* succeeds
|
|
||||||
*
|
*
|
||||||
* Description: Compare the files names between the one on the XML alias
|
* Description: Compare the files names between the one on the XML alias
|
||||||
* the one passed in as the input parameter. If equal extract file
|
* the one passed in as the input parameter. If equal extract file
|
||||||
@@ -746,7 +745,7 @@ isFileInVirtualDir( IN char *filePath )
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
if( ( strncmp( pCurVirtualDir->dirName, filePath, webDirLen )
|
if( ( strncmp( pCurVirtualDir->dirName, filePath, webDirLen )
|
||||||
== 0 ) && ( filePath[webDirLen] == '/' ) )
|
== 0 ) && ( filePath[webDirLen] == '/' || filePath[webDirLen] == '\0' || filePath[webDirLen] == '?' ) )
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -870,7 +869,7 @@ StrTok( char **Src,
|
|||||||
* OUT int * FirstByte ; gets the first byte of the token
|
* OUT int * FirstByte ; gets the first byte of the token
|
||||||
* OUT int * LastByte ; gets the last byte of the token
|
* OUT int * LastByte ; gets the last byte of the token
|
||||||
*
|
*
|
||||||
* Description: Returns a range of integers from a sring
|
* Description: Returns a range of integers from a string
|
||||||
*
|
*
|
||||||
* Returns: int ;
|
* Returns: int ;
|
||||||
* always returns 1;
|
* always returns 1;
|
||||||
@@ -929,8 +928,8 @@ GetNextRange( char **SrcRangeStr,
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* char * ByteRangeSpecifier ; String containing the range
|
* char * ByteRangeSpecifier ; String containing the range
|
||||||
* long FileLength ; Length of the file
|
* long FileLength ; Length of the file
|
||||||
* OUT struct SendInstruction * Instr ; SendInstruction object where the
|
* OUT struct SendInstruction * Instr ; SendInstruction object
|
||||||
* range operations will be stored
|
* where the range operations will be stored
|
||||||
*
|
*
|
||||||
* Description: Fills in the Offset, read size and contents to send out
|
* Description: Fills in the Offset, read size and contents to send out
|
||||||
* as an HTTP Range Response
|
* as an HTTP Range Response
|
||||||
@@ -1764,3 +1763,4 @@ web_server_callback( IN http_parser_t * parser,
|
|||||||
membuffer_destroy( &headers );
|
membuffer_destroy( &headers );
|
||||||
membuffer_destroy( &filename );
|
membuffer_destroy( &filename );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -555,7 +555,7 @@ parse_hostport( const char *in,
|
|||||||
int begin_port;
|
int begin_port;
|
||||||
int hostport_size = 0;
|
int hostport_size = 0;
|
||||||
int host_size = 0;
|
int host_size = 0;
|
||||||
#if !defined(WIN32) && !defined(__OSX__)
|
#if !defined(WIN32) && !(defined(__OSX__) || defined(__APPLE__))
|
||||||
char temp_hostbyname_buff[BUFFER_SIZE];
|
char temp_hostbyname_buff[BUFFER_SIZE];
|
||||||
struct hostent h_buf;
|
struct hostent h_buf;
|
||||||
#endif
|
#endif
|
||||||
@@ -642,7 +642,7 @@ parse_hostport( const char *in,
|
|||||||
if ( h == NULL ) {
|
if ( h == NULL ) {
|
||||||
errCode = 1;
|
errCode = 1;
|
||||||
}
|
}
|
||||||
#elif defined(__OSX__)
|
#elif defined(__OSX__) || defined(__APPLE__)
|
||||||
h = gethostbyname(temp_host_name);
|
h = gethostbyname(temp_host_name);
|
||||||
if ( h == NULL ) {
|
if ( h == NULL ) {
|
||||||
errCode = 1;
|
errCode = 1;
|
||||||
|
@@ -56,7 +56,8 @@ http_CancelHttpGet( IN void *Handle );
|
|||||||
* IN uri_type* url; URL to be validated and fixed
|
* IN uri_type* url; URL to be validated and fixed
|
||||||
* OUT uri_type* fixed_url; URL after being fixed.
|
* OUT uri_type* fixed_url; URL after being fixed.
|
||||||
*
|
*
|
||||||
* Description: Validates URL
|
* Description:
|
||||||
|
* Validates URL
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* UPNP_E_INVALID_URL
|
* UPNP_E_INVALID_URL
|
||||||
@@ -64,6 +65,7 @@ http_CancelHttpGet( IN void *Handle );
|
|||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_FixUrl( IN uri_type* url, OUT uri_type* fixed_url );
|
int http_FixUrl( IN uri_type* url, OUT uri_type* fixed_url );
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_FixStrUrl
|
* Function: http_FixStrUrl
|
||||||
*
|
*
|
||||||
@@ -72,7 +74,8 @@ int http_FixUrl( IN uri_type* url, OUT uri_type* fixed_url );
|
|||||||
* IN int urlstrlen ; Length of the character string
|
* IN int urlstrlen ; Length of the character string
|
||||||
* OUT uri_type* fixed_url ; Fixed and corrected URL
|
* OUT uri_type* fixed_url ; Fixed and corrected URL
|
||||||
*
|
*
|
||||||
* Description: Parses URL and then validates URL
|
* Description:
|
||||||
|
* Parses URL and then validates URL
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* UPNP_E_INVALID_URL
|
* UPNP_E_INVALID_URL
|
||||||
@@ -88,8 +91,8 @@ int http_FixStrUrl( IN char* urlstr, IN int urlstrlen, OUT uri_type* fixed_url )
|
|||||||
* IN uri_type* destination_url; URL containing destination information
|
* IN uri_type* destination_url; URL containing destination information
|
||||||
* OUT uri_type *url; Fixed and corrected URL
|
* OUT uri_type *url; Fixed and corrected URL
|
||||||
*
|
*
|
||||||
* Description: Gets destination address from URL and then connects to the
|
* Description:
|
||||||
* remote end
|
* Gets destination address from URL and then connects to the remote end
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* socket descriptor on sucess
|
* socket descriptor on sucess
|
||||||
@@ -98,19 +101,21 @@ int http_FixStrUrl( IN char* urlstr, IN int urlstrlen, OUT uri_type* fixed_url )
|
|||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_Connect( IN uri_type* destination_url, OUT uri_type *url );
|
int http_Connect( IN uri_type* destination_url, OUT uri_type *url );
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_RecvMessage
|
* Function: http_RecvMessage
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN SOCKINFO *info; Socket information object
|
* IN SOCKINFO *info; Socket information object
|
||||||
* OUT http_parser_t* parser, HTTP parser object
|
* OUT http_parser_t* parser; HTTP parser object
|
||||||
* IN http_method_t request_method; HTTP request method
|
* IN http_method_t request_method; HTTP request method
|
||||||
* IN OUT int* timeout_secs; time out
|
* IN OUT int* timeout_secs; time out
|
||||||
* OUT int* http_error_code; HTTP error code returned
|
* OUT int* http_error_code; HTTP error code returned
|
||||||
*
|
*
|
||||||
* Description: Get the data on the socket and take actions based on the
|
* Description:
|
||||||
* read data to modify the parser objects buffer. If an error is reported
|
* Get the data on the socket and take actions based on the read data
|
||||||
* while parsing the data, the error code is passed in the http_errr_code
|
* to modify the parser objects buffer. If an error is reported while
|
||||||
|
* parsing the data, the error code is passed in the http_errr_code
|
||||||
* parameter
|
* parameter
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
@@ -131,7 +136,8 @@ int http_RecvMessage( IN SOCKINFO *info, OUT http_parser_t* parser,
|
|||||||
* IN OUT int * TimeOut ; time out value
|
* IN OUT int * TimeOut ; time out value
|
||||||
* IN const char* fmt, ... Pattern format to take actions upon
|
* IN const char* fmt, ... Pattern format to take actions upon
|
||||||
*
|
*
|
||||||
* Description: Sends a message to the destination based on the
|
* Description:
|
||||||
|
* Sends a message to the destination based on the
|
||||||
* IN const char* fmt parameter
|
* IN const char* fmt parameter
|
||||||
* fmt types:
|
* fmt types:
|
||||||
* 'f': arg = const char * file name
|
* 'f': arg = const char * file name
|
||||||
@@ -148,9 +154,12 @@ int http_RecvMessage( IN SOCKINFO *info, OUT http_parser_t* parser,
|
|||||||
* UPNP_E_FILE_READ_ERROR
|
* UPNP_E_FILE_READ_ERROR
|
||||||
* UPNP_E_SUCCESS
|
* UPNP_E_SUCCESS
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_SendMessage( IN SOCKINFO *info, IN OUT int* timeout_secs,
|
int http_SendMessage(
|
||||||
|
IN SOCKINFO *info,
|
||||||
|
IN OUT int* timeout_secs,
|
||||||
IN const char* fmt, ... );
|
IN const char* fmt, ... );
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_RequestAndResponse
|
* Function: http_RequestAndResponse
|
||||||
*
|
*
|
||||||
@@ -163,7 +172,8 @@ int http_SendMessage( IN SOCKINFO *info, IN OUT int* timeout_secs,
|
|||||||
* IN int timeout_secs; time out value
|
* IN int timeout_secs; time out value
|
||||||
* OUT http_parser_t* response; Parser object to receive the repsonse
|
* OUT http_parser_t* response; Parser object to receive the repsonse
|
||||||
*
|
*
|
||||||
* Description: Initiates socket, connects to the destination, sends a
|
* Description:
|
||||||
|
* Initiates socket, connects to the destination, sends a
|
||||||
* request and waits for the response from the remote end
|
* request and waits for the response from the remote end
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
@@ -172,12 +182,15 @@ int http_SendMessage( IN SOCKINFO *info, IN OUT int* timeout_secs,
|
|||||||
* Error Codes returned by http_SendMessage
|
* Error Codes returned by http_SendMessage
|
||||||
* Error Codes returned by http_RecvMessage
|
* Error Codes returned by http_RecvMessage
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_RequestAndResponse( IN uri_type* destination,
|
int http_RequestAndResponse(
|
||||||
IN const char* request, IN size_t request_length,
|
IN uri_type* destination,
|
||||||
|
IN const char* request,
|
||||||
|
IN size_t request_length,
|
||||||
IN http_method_t req_method,
|
IN http_method_t req_method,
|
||||||
IN int timeout_secs,
|
IN int timeout_secs,
|
||||||
OUT http_parser_t* response );
|
OUT http_parser_t* response );
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* return codes:
|
* return codes:
|
||||||
* 0 -- success
|
* 0 -- success
|
||||||
@@ -190,30 +203,31 @@ int http_RequestAndResponse( IN uri_type* destination,
|
|||||||
* UPNP_E_SOCKET_WRITE
|
* UPNP_E_SOCKET_WRITE
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_Download
|
* Function: http_Download
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN const char* url_str : String as a URL
|
* IN const char* url_str; String as a URL
|
||||||
* IN int timeout_secs : time out value
|
* IN int timeout_secs; time out value
|
||||||
* OUT char** document : buffer to store the document extracted
|
* OUT char** document; buffer to store the document extracted
|
||||||
* from the donloaded message.
|
* from the donloaded message.
|
||||||
* OUT int* doc_length : length of the extracted document
|
* OUT int* doc_length; length of the extracted document
|
||||||
* OUT char* content_type : Type of content
|
* OUT char* content_type; Type of content
|
||||||
*
|
*
|
||||||
* Description : Download the document message and extract the document
|
* Description:
|
||||||
|
* Download the document message and extract the document
|
||||||
* from the message.
|
* from the message.
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS;
|
* UPNP_E_SUCCESS
|
||||||
* UPNP_E_INVALID_URL;
|
* UPNP_E_INVALID_URL
|
||||||
*
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_Download( IN const char* url,
|
int http_Download(
|
||||||
|
IN const char* url,
|
||||||
IN int timeout_secs,
|
IN int timeout_secs,
|
||||||
OUT char** document, OUT int* doc_length,
|
OUT char** document,
|
||||||
|
OUT int* doc_length,
|
||||||
OUT char* content_type );
|
OUT char* content_type );
|
||||||
|
|
||||||
|
|
||||||
@@ -227,67 +241,66 @@ int http_Download( IN const char* url,
|
|||||||
* IN unsigned int *size: Size of the data to be sent.
|
* IN unsigned int *size: Size of the data to be sent.
|
||||||
* IN int timeout: time out value
|
* IN int timeout: time out value
|
||||||
*
|
*
|
||||||
* Description : Formats data if format used is UPNP_USING_CHUNKED.
|
* Description:
|
||||||
|
* Formats data if format used is UPNP_USING_CHUNKED.
|
||||||
* Writes data on the socket connected to the peer.
|
* Writes data on the socket connected to the peer.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Success
|
* UPNP_E_SUCCESS - On Success
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
* -1 - On Socket Error.
|
* -1 - On Socket Error.
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_WriteHttpPost(IN void *Handle,
|
int http_WriteHttpPost(IN void *Handle,
|
||||||
IN char *buf,
|
IN char *buf,
|
||||||
IN unsigned int *size,
|
IN unsigned int *size,
|
||||||
IN int timeout);
|
IN int timeout);
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_CloseHttpPost
|
* Function: http_CloseHttpPost
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN void *Handle : Handle to the http post object
|
* IN void *Handle; Handle to the http post object
|
||||||
* IN OUT int *httpStatus : HTTP status returned on receiving a
|
* IN OUT int *httpStatus; HTTP status returned on receiving a
|
||||||
* response message
|
* response message
|
||||||
* IN int timeout : time out value
|
* IN int timeout; time out value
|
||||||
*
|
*
|
||||||
* Description : Sends remaining data if using UPNP_USING_CHUNKED
|
* Description:
|
||||||
|
* Sends remaining data if using UPNP_USING_CHUNKED
|
||||||
* format. Receives any more messages. Destroys socket and any socket
|
* format. Receives any more messages. Destroys socket and any socket
|
||||||
* associated memory. Frees handle associated with the HTTP POST msg.
|
* associated memory. Frees handle associated with the HTTP POST msg.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Sucess ;
|
* UPNP_E_SUCCESS - On Sucess
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter;
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_CloseHttpPost(IN void *Handle,
|
int http_CloseHttpPost(IN void *Handle,
|
||||||
IN OUT int *httpStatus,
|
IN OUT int *httpStatus,
|
||||||
IN int timeout);
|
IN int timeout);
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_OpenHttpPost
|
* Function: http_OpenHttpPost
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN const char *url_str : String as a URL
|
* IN const char *url_str; String as a URL
|
||||||
* IN OUT void **Handle : Pointer to buffer to store HTTP
|
* IN OUT void **Handle; Pointer to buffer to store HTTP
|
||||||
* post handle
|
* post handle
|
||||||
* IN const char *contentType : Type of content
|
* IN const char *contentType; Type of content
|
||||||
* IN int contentLength : length of content
|
* IN int contentLength; length of content
|
||||||
* IN int timeout : time out value
|
* IN int timeout; time out value
|
||||||
*
|
*
|
||||||
* Description : Makes the HTTP POST message, connects to the peer,
|
* Description:
|
||||||
|
* Makes the HTTP POST message, connects to the peer,
|
||||||
* sends the HTTP POST request. Adds the post handle to buffer of
|
* sends the HTTP POST request. Adds the post handle to buffer of
|
||||||
* such handles
|
* such handles
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return : int;
|
||||||
* UPNP_E_SUCCESS - On Sucess ;
|
* UPNP_E_SUCCESS - On Sucess
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Paramter ;
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
* UPNP_E_OUTOF_MEMORY ;
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_SOCKET_ERROR ;
|
* UPNP_E_SOCKET_ERROR
|
||||||
* UPNP_E_SOCKET_CONNECT ;
|
* UPNP_E_SOCKET_CONNECT
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_OpenHttpPost(IN const char *url_str,
|
int http_OpenHttpPost(IN const char *url_str,
|
||||||
IN OUT void **Handle,
|
IN OUT void **Handle,
|
||||||
@@ -295,69 +308,72 @@ int http_OpenHttpPost(IN const char *url_str,
|
|||||||
IN int contentLength,
|
IN int contentLength,
|
||||||
IN int timeout);
|
IN int timeout);
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_ReadHttpGet
|
* Function: http_ReadHttpGet
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN void *Handle : Handle to the HTTP get object
|
* IN void *Handle; Handle to the HTTP get object
|
||||||
* IN OUT char *buf : Buffer to get the read and parsed data
|
* IN OUT char *buf; Buffer to get the read and parsed data
|
||||||
* IN OUT unsigned int *size : Size of tge buffer passed
|
* IN OUT unsigned int *size; Size of the buffer passed
|
||||||
* IN int timeout : time out value
|
* IN int timeout; time out value
|
||||||
*
|
*
|
||||||
* Description : Parses already existing data, then gets new data.
|
* Description:
|
||||||
|
* Parses already existing data, then gets new data.
|
||||||
* Parses and extracts information from the new data.
|
* Parses and extracts information from the new data.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Sucess ;
|
* UPNP_E_SUCCESS - On Sucess
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter;
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
* UPNP_E_BAD_RESPONSE ;
|
* UPNP_E_BAD_RESPONSE
|
||||||
* UPNP_E_BAD_HTTPMSG ;
|
* UPNP_E_BAD_HTTPMSG
|
||||||
*
|
* UPNP_E_CANCELED
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_ReadHttpGet(IN void *Handle,
|
int http_ReadHttpGet(
|
||||||
|
IN void *Handle,
|
||||||
IN OUT char *buf,
|
IN OUT char *buf,
|
||||||
IN OUT unsigned int *size,
|
IN OUT unsigned int *size,
|
||||||
IN int timeout);
|
IN int timeout);
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_HttpGetProgress
|
* Function: http_HttpGetProgress
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN void *Handle : Handle to the HTTP get object
|
* IN void *Handle; Handle to the HTTP get object
|
||||||
* OUT unsigned int *length : Buffer to get the read and parsed data
|
* OUT unsigned int *length; Buffer to get the read and parsed data
|
||||||
* OUT unsigned int *total : Size of tge buffer passed
|
* OUT unsigned int *total; Size of tge buffer passed
|
||||||
*
|
*
|
||||||
* Description : Extracts information from the Handle to the HTTP get
|
* Description:
|
||||||
* object.
|
* Extracts information from the Handle to the HTTP get object.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Sucess ;
|
* UPNP_E_SUCCESS - On Sucess
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter;
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_HttpGetProgress(IN void *Handle,
|
int http_HttpGetProgress(
|
||||||
|
IN void *Handle,
|
||||||
OUT unsigned int *length,
|
OUT unsigned int *length,
|
||||||
OUT unsigned int *total );
|
OUT unsigned int *total );
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_CloseHttpGet
|
* Function: http_CloseHttpGet
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN void *Handle; Handle to HTTP get object
|
* IN void *Handle; Handle to HTTP get object
|
||||||
*
|
*
|
||||||
* Description : Clears the handle allocated for the HTTP GET operation
|
* Description:
|
||||||
|
* Clears the handle allocated for the HTTP GET operation
|
||||||
* Clears socket states and memory allocated for socket operations.
|
* Clears socket states and memory allocated for socket operations.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Success
|
* UPNP_E_SUCCESS - On Success
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_CloseHttpGet(IN void *Handle);
|
int http_CloseHttpGet(IN void *Handle);
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_OpenHttpGet
|
* Function: http_OpenHttpGet
|
||||||
*
|
*
|
||||||
@@ -371,54 +387,52 @@ int http_CloseHttpGet(IN void *Handle);
|
|||||||
* response message
|
* response message
|
||||||
* IN int timeout: time out value
|
* IN int timeout: time out value
|
||||||
*
|
*
|
||||||
* Description : Makes the HTTP GET message, connects to the peer,
|
* Description:
|
||||||
|
* Makes the HTTP GET message, connects to the peer,
|
||||||
* sends the HTTP GET request, gets the response and parses the
|
* sends the HTTP GET request, gets the response and parses the
|
||||||
* response.
|
* response.
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Success ;
|
* UPNP_E_SUCCESS - On Success
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Paramters ;
|
* UPNP_E_INVALID_PARAM - Invalid Paramters
|
||||||
* UPNP_E_OUTOF_MEMORY ;
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_SOCKET_ERROR ;
|
* UPNP_E_SOCKET_ERROR
|
||||||
* UPNP_E_BAD_RESPONSE ;
|
* UPNP_E_BAD_RESPONSE
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
*
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_OpenHttpGet(IN const char *url_str,
|
int http_OpenHttpGet(
|
||||||
|
IN const char *url_str,
|
||||||
IN OUT void **Handle,
|
IN OUT void **Handle,
|
||||||
IN OUT char **contentType,
|
IN OUT char **contentType,
|
||||||
OUT int *contentLength,
|
OUT int *contentLength,
|
||||||
OUT int *httpStatus,
|
OUT int *httpStatus,
|
||||||
IN int timeout);
|
IN int timeout);
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_OpenHttpGetProxy
|
* Function: http_OpenHttpGetProxy
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN const char *url_str : String as a URL
|
* IN const char *url_str; String as a URL
|
||||||
* IN const char *proxy_str : String as a URL to the proxy
|
* IN const char *proxy_str; String as a URL
|
||||||
* IN OUT void **Handle : Pointer to buffer to store HTTP
|
* IN OUT void **Handle; Pointer to buffer to store HTTP
|
||||||
* post handle
|
* post handle
|
||||||
* IN OUT char **contentType : Type of content
|
* IN OUT char **contentType; Type of content
|
||||||
* OUT int *contentLength : length of content
|
* OUT int *contentLength; length of content
|
||||||
* OUT int *httpStatus : HTTP status returned on receiving a
|
* OUT int *httpStatus; HTTP status returned on receiving a
|
||||||
* response message
|
* response message
|
||||||
* IN int timeout: time out value
|
* IN int timeout: time out value
|
||||||
*
|
*
|
||||||
* Description : Makes the HTTP GET message, connects to the peer,
|
* Description:
|
||||||
* sends the HTTP GET request, gets the response and parses the
|
* Makes the HTTP GET message, connects to the peer,
|
||||||
* response.
|
* sends the HTTP GET request, gets the response and parses the response.
|
||||||
*
|
* If a proxy URL is defined then the connection is made there.
|
||||||
* Return : int;
|
|
||||||
* UPNP_E_SUCCESS - On Success ;
|
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Paramters ;
|
|
||||||
* UPNP_E_OUTOF_MEMORY ;
|
|
||||||
* UPNP_E_SOCKET_ERROR ;
|
|
||||||
* UPNP_E_BAD_RESPONSE ;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
*
|
*
|
||||||
|
* Return: int
|
||||||
|
* UPNP_E_SUCCESS - On Success
|
||||||
|
* UPNP_E_INVALID_PARAM - Invalid Paramters
|
||||||
|
* UPNP_E_OUTOF_MEMORY
|
||||||
|
* UPNP_E_SOCKET_ERROR
|
||||||
|
* UPNP_E_BAD_RESPONSE
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_OpenHttpGetProxy(IN const char *url_str,
|
int http_OpenHttpGetProxy(IN const char *url_str,
|
||||||
IN const char *proxy_str,
|
IN const char *proxy_str,
|
||||||
@@ -433,24 +447,25 @@ int http_OpenHttpGetProxy(IN const char *url_str,
|
|||||||
* Function: http_SendStatusResponse
|
* Function: http_SendStatusResponse
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN SOCKINFO *info : Socket information object
|
* IN SOCKINFO *info; Socket information object
|
||||||
* IN int http_status_code : error code returned while making
|
* IN int http_status_code; error code returned while making
|
||||||
* or sending the response message
|
* or sending the response message
|
||||||
* IN int request_major_version : request major version
|
* IN int request_major_version; request major version
|
||||||
* IN int request_minor_version : request minor version
|
* IN int request_minor_version; request minor version
|
||||||
*
|
*
|
||||||
* Description : Generate a response message for the status query and
|
* Description:
|
||||||
* send the status response.
|
* Generate a response message for the status query and send the
|
||||||
|
* status response.
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* 0 -- success
|
* 0 -- success
|
||||||
* UPNP_E_OUTOF_MEMORY
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_SOCKET_WRITE
|
* UPNP_E_SOCKET_WRITE
|
||||||
* UPNP_E_TIMEDOUT
|
* UPNP_E_TIMEDOUT
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_SendStatusResponse( IN SOCKINFO *info, IN int http_status_code,
|
int http_SendStatusResponse(
|
||||||
|
IN SOCKINFO *info,
|
||||||
|
IN int http_status_code,
|
||||||
IN int request_major_version,
|
IN int request_major_version,
|
||||||
IN int request_minor_version );
|
IN int request_minor_version );
|
||||||
|
|
||||||
@@ -459,96 +474,103 @@ int http_SendStatusResponse( IN SOCKINFO *info, IN int http_status_code,
|
|||||||
* Function: http_MakeMessage
|
* Function: http_MakeMessage
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* INOUT membuffer* buf : buffer with the contents of the
|
* INOUT membuffer* buf; buffer with the contents of the
|
||||||
* message
|
* message
|
||||||
* IN int http_major_version : HTTP major version
|
* IN int http_major_version; HTTP major version
|
||||||
* IN int http_minor_version : HTTP minor version
|
* IN int http_minor_version; HTTP minor version
|
||||||
* IN const char* fmt : Pattern format
|
* IN const char* fmt; Pattern format
|
||||||
* ... :
|
* ...;
|
||||||
*
|
*
|
||||||
* Description : Generate an HTTP message based on the format that is
|
* Description:
|
||||||
* specified in the input parameters.
|
* Generate an HTTP message based on the format that is specified
|
||||||
|
* in the input parameters.
|
||||||
*
|
*
|
||||||
* fmt types:
|
* fmt types:
|
||||||
* 's': arg = const char* C_string
|
* 'B': arg = int status_code
|
||||||
* 'b': arg1 = const char* buf; arg2 = size_t buf_length
|
* appends content-length, content-type and HTML body
|
||||||
* memory ptr
|
* for given code
|
||||||
* 'c': (no args) appends CRLF "\r\n"
|
* 'b': arg1 = const char* buf;
|
||||||
* 'd': arg = int number // appends decimal number
|
* arg2 = size_t buf_length memory ptr
|
||||||
* 'h': arg = off_t number // appends off_t number
|
|
||||||
* 't': arg = time_t * gmt_time // appends time in RFC 1123 fmt
|
|
||||||
* 'D': (no args) appends HTTP DATE: header
|
|
||||||
* 'S': (no args) appends HTTP SERVER: header
|
|
||||||
* 'U': (no args) appends HTTP USER-AGENT: header
|
|
||||||
* 'C': (no args) appends a HTTP CONNECTION: close header
|
* 'C': (no args) appends a HTTP CONNECTION: close header
|
||||||
* depending on major,minor version
|
* depending on major,minor version
|
||||||
* 'N': arg1 = int content_length // content-length header
|
* 'c': (no args) appends CRLF "\r\n"
|
||||||
* 'Q': arg1 = http_method_t; arg2 = char* url;
|
* 'D': (no args) appends HTTP DATE: header
|
||||||
* arg3 = int url_length // start line of request
|
* 'd': arg = int number // appends decimal number
|
||||||
|
* 'G': arg = range information // add range header
|
||||||
|
* 'h': arg = off_t number // appends off_t number
|
||||||
|
* 'K': (no args) // add chunky header
|
||||||
|
* 'N': arg1 = off_t content_length // content-length header
|
||||||
|
* 'q': arg1 = http_method_t // request start line and HOST header
|
||||||
|
* arg2 = (uri_type *)
|
||||||
|
* 'Q': arg1 = http_method_t; // start line of request
|
||||||
|
* arg2 = char* url;
|
||||||
|
* arg3 = size_t url_length
|
||||||
* 'R': arg = int status_code // adds a response start line
|
* 'R': arg = int status_code // adds a response start line
|
||||||
* 'B': arg = int status_code
|
* 'S': (no args) appends HTTP SERVER: header
|
||||||
* appends content-length, content-type and HTML body for given code
|
* 's': arg = const char* C_string
|
||||||
* 'T': arg = char * content_type; format e.g: "text/html";
|
* 'T': arg = char * content_type; format
|
||||||
* content-type header
|
* e.g: "text/html"; content-type header
|
||||||
|
* 't': arg = time_t * gmt_time // appends time in RFC 1123 fmt
|
||||||
|
* 'U': (no args) appends HTTP USER-AGENT: header
|
||||||
|
* 'X': arg = const char useragent; "redsonic" HTTP X-User-Agent: useragent
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* 0 - On Success
|
* 0 - On Success
|
||||||
* UPNP_E_OUTOF_MEMORY
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_INVALID_URL;
|
* UPNP_E_INVALID_URL
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_MakeMessage( INOUT membuffer* buf,
|
int http_MakeMessage(
|
||||||
|
INOUT membuffer* buf,
|
||||||
IN int http_major_version,
|
IN int http_major_version,
|
||||||
IN int http_minor_version,
|
IN int http_minor_version,
|
||||||
IN const char* fmt, ... );
|
IN const char* fmt, ... );
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_CalcResponseVersion
|
* Function: http_CalcResponseVersion
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN int request_major_vers : Request major version
|
* IN int request_major_vers; Request major version
|
||||||
* IN int request_minor_vers : Request minor version
|
* IN int request_minor_vers; Request minor version
|
||||||
* OUT int* response_major_vers : Response mojor version
|
* OUT int* response_major_vers; Response mojor version
|
||||||
* OUT int* response_minor_vers : Response minor version
|
* OUT int* response_minor_vers; Response minor version
|
||||||
*
|
*
|
||||||
* Description : Calculate HTTP response versions based on the request
|
* Description:
|
||||||
* versions.
|
* Calculate HTTP response versions based on the request versions.
|
||||||
*
|
*
|
||||||
* Return: void
|
* Return: void
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
void http_CalcResponseVersion(
|
void http_CalcResponseVersion(
|
||||||
IN int request_major_vers, IN int request_minor_vers,
|
IN int request_major_vers,
|
||||||
OUT int* response_major_vers, OUT int* response_minor_vers );
|
IN int request_minor_vers,
|
||||||
|
OUT int* response_major_vers,
|
||||||
|
OUT int* response_minor_vers );
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_OpenHttpGetEx
|
* Function: http_OpenHttpGetEx
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN const char *url_str : String as a URL
|
* IN const char *url_str; String as a URL
|
||||||
* IN OUT void **Handle : Pointer to buffer to store HTTP
|
* IN OUT void **Handle; Pointer to buffer to store HTTP
|
||||||
* post handle
|
* post handle
|
||||||
* IN OUT char **contentType : Type of content
|
* IN OUT char **contentType; Type of content
|
||||||
* OUT int *contentLength : length of content
|
* OUT int *contentLength; length of content
|
||||||
* OUT int *httpStatus : HTTP status returned on receiving a
|
* OUT int *httpStatus; HTTP status returned on receiving a
|
||||||
* response message
|
* response message
|
||||||
* IN int timeout : time out value
|
* IN int timeout; time out value
|
||||||
*
|
*
|
||||||
* Description : Makes the HTTP GET message, connects to the peer,
|
* Description:
|
||||||
|
* Makes the HTTP GET message, connects to the peer,
|
||||||
* sends the HTTP GET request, gets the response and parses the
|
* sends the HTTP GET request, gets the response and parses the
|
||||||
* response.
|
* response.
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Success ;
|
* UPNP_E_SUCCESS - On Success
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Paramters ;
|
* UPNP_E_INVALID_PARAM - Invalid Paramters
|
||||||
* UPNP_E_OUTOF_MEMORY ;
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_SOCKET_ERROR ;
|
* UPNP_E_SOCKET_ERROR
|
||||||
* UPNP_E_BAD_RESPONSE ;
|
* UPNP_E_BAD_RESPONSE
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
*
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_OpenHttpGetEx(IN const char *url_str,
|
int http_OpenHttpGetEx(IN const char *url_str,
|
||||||
IN OUT void **Handle,
|
IN OUT void **Handle,
|
||||||
@@ -559,18 +581,18 @@ int http_OpenHttpGetEx(IN const char *url_str,
|
|||||||
IN int highRange,
|
IN int highRange,
|
||||||
IN int timeout);
|
IN int timeout);
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: get_sdk_info
|
* Function: get_sdk_info
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* OUT char *info ;
|
* OUT char *info; buffer to store the operating system information
|
||||||
*
|
*
|
||||||
* Description : Returns the server information for the operating
|
* Description:
|
||||||
* system
|
* Returns the server information for the operating system
|
||||||
*
|
*
|
||||||
* Return : void ;
|
* Return:
|
||||||
*
|
* UPNP_INLINE void
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
void get_sdk_info( OUT char *info );
|
void get_sdk_info( OUT char *info );
|
||||||
|
|
||||||
@@ -580,3 +602,4 @@ void get_sdk_info( OUT char *info );
|
|||||||
|
|
||||||
|
|
||||||
#endif // GENLIB_NET_HTTP_HTTPREADWRITE_H
|
#endif // GENLIB_NET_HTTP_HTTPREADWRITE_H
|
||||||
|
|
||||||
|
@@ -1,63 +1,67 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
//
|
*
|
||||||
// * Redistributions of source code must retain the above copyright notice,
|
* * Redistributions of source code must retain the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
// * Neither name of Intel Corporation nor the names of its contributors
|
* Neither name of Intel Corporation nor the names of its contributors
|
||||||
// may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* 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.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
************************************************************************/
|
||||||
|
|
||||||
#ifndef MINISERVER_H
|
#ifndef MINISERVER_H
|
||||||
#define MINISERVER_H
|
#define MINISERVER_H
|
||||||
|
|
||||||
|
|
||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
#include "httpparser.h"
|
#include "httpparser.h"
|
||||||
|
|
||||||
|
|
||||||
extern SOCKET gMiniServerStopSock;
|
extern SOCKET gMiniServerStopSock;
|
||||||
|
|
||||||
|
|
||||||
typedef struct MServerSockArray {
|
typedef struct MServerSockArray {
|
||||||
int miniServerSock; //socket for listening for miniserver
|
/* socket for listening for miniserver requests */
|
||||||
//requests
|
int miniServerSock;
|
||||||
int miniServerStopSock; //socket for stopping miniserver
|
/* socket for stopping miniserver */
|
||||||
int ssdpSock; //socket for incoming advertisments and search requests
|
int miniServerStopSock;
|
||||||
|
/* socket for incoming advertisments and search requests */
|
||||||
|
int ssdpSock;
|
||||||
|
|
||||||
int stopPort;
|
int stopPort;
|
||||||
int miniServerPort;
|
int miniServerPort;
|
||||||
|
|
||||||
CLIENTONLY(int ssdpReqSock;) //socket for sending search
|
/* socket for sending search requests and receiving search replies */
|
||||||
//requests and receiving
|
CLIENTONLY(int ssdpReqSock;)
|
||||||
// search replies
|
|
||||||
|
|
||||||
} MiniServerSockArray;
|
} MiniServerSockArray;
|
||||||
|
|
||||||
//typedef void (*MiniServerCallback) ( const char* document, int sockfd );
|
|
||||||
|
|
||||||
typedef void (*MiniServerCallback) ( IN http_parser_t *parser,
|
typedef void (*MiniServerCallback)(
|
||||||
|
IN http_parser_t *parser,
|
||||||
IN http_message_t* request,
|
IN http_message_t* request,
|
||||||
IN SOCKINFO *info );
|
IN SOCKINFO *info );
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@@ -71,8 +75,6 @@ extern "C" {
|
|||||||
* Description: Set HTTP Get Callback
|
* Description: Set HTTP Get Callback
|
||||||
*
|
*
|
||||||
* Return: void
|
* Return: void
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
void SetHTTPGetCallback( MiniServerCallback callback );
|
void SetHTTPGetCallback( MiniServerCallback callback );
|
||||||
|
|
||||||
@@ -85,14 +87,12 @@ void SetHTTPGetCallback( MiniServerCallback callback );
|
|||||||
* Description: Set SOAP Callback
|
* Description: Set SOAP Callback
|
||||||
*
|
*
|
||||||
* Return: void
|
* Return: void
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
#ifdef INCLUDE_DEVICE_APIS
|
#ifdef INCLUDE_DEVICE_APIS
|
||||||
void SetSoapCallback( MiniServerCallback callback );
|
void SetSoapCallback( MiniServerCallback callback );
|
||||||
#else
|
#else /* INCLUDE_DEVICE_APIS */
|
||||||
static inline void SetSoapCallback( MiniServerCallback callback ) {}
|
static inline void SetSoapCallback( MiniServerCallback callback ) {}
|
||||||
#endif
|
#endif /* INCLUDE_DEVICE_APIS */
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: SetGenaCallback
|
* Function: SetGenaCallback
|
||||||
@@ -100,11 +100,9 @@ static inline void SetSoapCallback( MiniServerCallback callback ) {}
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* MiniServerCallback callback; - GENA Callback to be invoked
|
* MiniServerCallback callback; - GENA Callback to be invoked
|
||||||
*
|
*
|
||||||
* Description : Set GENA Callback
|
* D6escription: Set GENA Callback
|
||||||
*
|
*
|
||||||
* Return: void
|
* Return: void
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
void SetGenaCallback( MiniServerCallback callback );
|
void SetGenaCallback( MiniServerCallback callback );
|
||||||
|
|
||||||
@@ -126,7 +124,6 @@ void SetGenaCallback( MiniServerCallback callback );
|
|||||||
* Return: int;
|
* Return: int;
|
||||||
* Actual port socket is bound to - On Success:
|
* Actual port socket is bound to - On Success:
|
||||||
* A negative number UPNP_E_XXX - On Error
|
* A negative number UPNP_E_XXX - On Error
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int StartMiniServer( unsigned short listen_port );
|
int StartMiniServer( unsigned short listen_port );
|
||||||
|
|
||||||
@@ -136,19 +133,18 @@ int StartMiniServer( unsigned short listen_port );
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* void;
|
* void;
|
||||||
*
|
*
|
||||||
* Description : Stop and Shutdown the MiniServer and free socket
|
* Description: Stop and Shutdown the MiniServer and free socket resources.
|
||||||
* resources.
|
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return : int;
|
||||||
* Always returns 0
|
* Always returns 0
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int StopMiniServer( void );
|
int StopMiniServer();
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern C */
|
} /* extern C */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif /* MINISERVER_H */
|
#endif /* MINISERVER_H */
|
||||||
|
|
||||||
|
@@ -126,18 +126,18 @@ int web_server_set_alias( IN const char* alias_name,
|
|||||||
int web_server_set_root_dir( IN const char* root_dir );
|
int web_server_set_root_dir( IN const char* root_dir );
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: web_server_callback *
|
* Function: web_server_callback
|
||||||
* *
|
*
|
||||||
* Parameters: *
|
* Parameters:
|
||||||
* IN http_parser_t *parser, *
|
* IN http_parser_t *parser,
|
||||||
* INOUT http_message_t* req, *
|
* INOUT http_message_t* req,
|
||||||
* IN SOCKINFO *info *
|
* IN SOCKINFO *info
|
||||||
* *
|
*
|
||||||
* Description: main entry point into web server; *
|
* Description: main entry point into web server;
|
||||||
* handles HTTP GET and HEAD requests *
|
* handles HTTP GET and HEAD requests
|
||||||
* *
|
*
|
||||||
* Returns: *
|
* Returns:
|
||||||
* void *
|
* void
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
void web_server_callback( IN http_parser_t *parser, IN http_message_t* req, INOUT SOCKINFO *info );
|
void web_server_callback( IN http_parser_t *parser, IN http_message_t* req, INOUT SOCKINFO *info );
|
||||||
|
|
||||||
@@ -148,3 +148,4 @@ void web_server_callback( IN http_parser_t *parser, IN http_message_t* req, INOU
|
|||||||
|
|
||||||
|
|
||||||
#endif // GENLIB_NET_HTTP_WEBSERVER_H
|
#endif // GENLIB_NET_HTTP_WEBSERVER_H
|
||||||
|
|
||||||
|
@@ -335,7 +335,7 @@ CreateServicePacket( IN int msg_type,
|
|||||||
&buf, 1, 1,
|
&buf, 1, 1,
|
||||||
"Q" "sssdc" "sdc" "ssc" "ssc" "ssc" "S" "Xc" "sscc",
|
"Q" "sssdc" "sdc" "ssc" "ssc" "ssc" "S" "Xc" "sscc",
|
||||||
HTTPMETHOD_NOTIFY, "*",
|
HTTPMETHOD_NOTIFY, "*",
|
||||||
1, "HOST: ", SSDP_IP, ":", SSDP_PORT,
|
(size_t)1, "HOST: ", SSDP_IP, ":", SSDP_PORT,
|
||||||
"CACHE-CONTROL: max-age=", duration,
|
"CACHE-CONTROL: max-age=", duration,
|
||||||
"LOCATION: ", location,
|
"LOCATION: ", location,
|
||||||
"NT: ", nt,
|
"NT: ", nt,
|
||||||
|
@@ -50,8 +50,7 @@
|
|||||||
|
|
||||||
#define MAX_TIME_TOREAD 45
|
#define MAX_TIME_TOREAD 45
|
||||||
|
|
||||||
CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
CLIENTONLY( SOCKET gSsdpReqSocket = 0; )
|
||||||
)
|
|
||||||
|
|
||||||
void RequestHandler();
|
void RequestHandler();
|
||||||
Event ErrotEvt;
|
Event ErrotEvt;
|
||||||
@@ -61,11 +60,10 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
|||||||
unsigned short ssdpStopPort;
|
unsigned short ssdpStopPort;
|
||||||
|
|
||||||
struct SSDPSockArray {
|
struct SSDPSockArray {
|
||||||
int ssdpSock; //socket for incoming advertisments and search requests
|
// socket for incoming advertisments and search requests
|
||||||
CLIENTONLY( int ssdpReqSock;
|
int ssdpSock;
|
||||||
) //socket for sending search
|
// socket for sending search requests and receiving search replies
|
||||||
//requests and receiving
|
CLIENTONLY( int ssdpReqSock; )
|
||||||
// search replies
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef INCLUDE_DEVICE_APIS
|
#ifdef INCLUDE_DEVICE_APIS
|
||||||
@@ -129,7 +127,6 @@ int AdvertiseAndReply( IN int AdFlag,
|
|||||||
return UPNP_E_INVALID_HANDLE;
|
return UPNP_E_INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
defaultExp = SInfo->MaxAge;
|
defaultExp = SInfo->MaxAge;
|
||||||
nodeList = NULL;
|
|
||||||
|
|
||||||
//get server info
|
//get server info
|
||||||
|
|
||||||
@@ -398,8 +395,8 @@ int AdvertiseAndReply( IN int AdFlag,
|
|||||||
|
|
||||||
} /****************** End of AdvertiseAndReply *********************/
|
} /****************** End of AdvertiseAndReply *********************/
|
||||||
|
|
||||||
#endif
|
#endif /* EXCLUDE_SSDP == 0 */
|
||||||
#endif
|
#endif /* INCLUDE_DEVICE_APIS */
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function : Make_Socket_NoBlocking
|
* Function : Make_Socket_NoBlocking
|
||||||
@@ -737,8 +734,7 @@ ssdp_event_handler_thread( void *the_data )
|
|||||||
// send msg to device or ctrlpt
|
// send msg to device or ctrlpt
|
||||||
if( ( hmsg->method == HTTPMETHOD_NOTIFY ) ||
|
if( ( hmsg->method == HTTPMETHOD_NOTIFY ) ||
|
||||||
( hmsg->request_method == HTTPMETHOD_MSEARCH ) ) {
|
( hmsg->request_method == HTTPMETHOD_MSEARCH ) ) {
|
||||||
CLIENTONLY( ssdp_handle_ctrlpt_msg( hmsg, &data->dest_addr,
|
CLIENTONLY( ssdp_handle_ctrlpt_msg( hmsg, &data->dest_addr, FALSE, NULL );)
|
||||||
FALSE, NULL ););
|
|
||||||
} else {
|
} else {
|
||||||
ssdp_handle_device_request( hmsg, &data->dest_addr );
|
ssdp_handle_device_request( hmsg, &data->dest_addr );
|
||||||
}
|
}
|
||||||
@@ -860,35 +856,36 @@ readFromSSDPSocket( SOCKET socket )
|
|||||||
int
|
int
|
||||||
get_ssdp_sockets( MiniServerSockArray * out )
|
get_ssdp_sockets( MiniServerSockArray * out )
|
||||||
{
|
{
|
||||||
SOCKET ssdpSock;
|
|
||||||
|
|
||||||
CLIENTONLY( SOCKET ssdpReqSock; )
|
|
||||||
int onOff = 1;
|
int onOff = 1;
|
||||||
u_char ttl = 4;
|
u_char ttl = 4;
|
||||||
struct ip_mreq ssdpMcastAddr;
|
struct ip_mreq ssdpMcastAddr;
|
||||||
struct sockaddr_in ssdpAddr;
|
struct sockaddr_in ssdpAddr;
|
||||||
int option = 1;
|
int option = 1;
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
|
SOCKET ssdpSock;
|
||||||
|
#if INCLUDE_CLIENT_APIS
|
||||||
|
SOCKET ssdpReqSock;
|
||||||
|
|
||||||
CLIENTONLY(
|
|
||||||
if( ( ssdpReqSock = socket( AF_INET, SOCK_DGRAM, 0 ) ) == UPNP_INVALID_SOCKET ) {
|
if( ( ssdpReqSock = socket( AF_INET, SOCK_DGRAM, 0 ) ) == UPNP_INVALID_SOCKET ) {
|
||||||
UpnpPrintf( UPNP_CRITICAL,
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in socket operation !!!\n" );
|
"Error in socket operation !!!\n" );
|
||||||
|
|
||||||
return UPNP_E_OUTOF_SOCKET;
|
return UPNP_E_OUTOF_SOCKET;
|
||||||
}
|
}
|
||||||
setsockopt( ssdpReqSock, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof( ttl ) );
|
setsockopt( ssdpReqSock, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof( ttl ) );
|
||||||
// just do it, regardless if fails or not.
|
// just do it, regardless if fails or not.
|
||||||
Make_Socket_NoBlocking( ssdpReqSock );
|
Make_Socket_NoBlocking( ssdpReqSock );
|
||||||
gSsdpReqSocket = ssdpReqSock; )
|
gSsdpReqSocket = ssdpReqSock;
|
||||||
// END CLIENTONLY
|
#endif /* INCLUDE_CLIENT_APIS */
|
||||||
|
|
||||||
if( ( ssdpSock = socket( AF_INET, SOCK_DGRAM, 0 ) ) == UPNP_INVALID_SOCKET ) {
|
if( ( ssdpSock = socket( AF_INET, SOCK_DGRAM, 0 ) ) == UPNP_INVALID_SOCKET ) {
|
||||||
UpnpPrintf( UPNP_CRITICAL,
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in socket operation !!!\n" );
|
"Error in socket operation !!!\n" );
|
||||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ); )
|
||||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ); )
|
||||||
|
|
||||||
return UPNP_E_OUTOF_SOCKET;
|
return UPNP_E_OUTOF_SOCKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -898,26 +895,28 @@ CLIENTONLY(
|
|||||||
UpnpPrintf( UPNP_CRITICAL,
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in set reuse addr !!!\n" );
|
"Error in set reuse addr !!!\n" );
|
||||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ); )
|
||||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ); )
|
||||||
shutdown( ssdpSock, SD_BOTH );
|
shutdown( ssdpSock, SD_BOTH );
|
||||||
UpnpCloseSocket( ssdpSock );
|
UpnpCloseSocket( ssdpSock );
|
||||||
|
|
||||||
return UPNP_E_SOCKET_ERROR;
|
return UPNP_E_SOCKET_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __FreeBSD__
|
#if defined(__FreeBSD__) || defined(__OSX__) || defined(__APPLE__)
|
||||||
if( setsockopt( ssdpSock, SOL_SOCKET, SO_REUSEPORT,
|
if( setsockopt( ssdpSock, SOL_SOCKET, SO_REUSEPORT,
|
||||||
( char * )&onOff, sizeof( onOff ) ) != 0 ) {
|
( char * )&onOff, sizeof( onOff ) ) != 0 ) {
|
||||||
UpnpPrintf( UPNP_CRITICAL,
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in set reuse port !!!\n" );
|
"Error in set reuse port !!!\n" );
|
||||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ); )
|
||||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ); )
|
||||||
shutdown( ssdpSock, SD_BOTH );
|
shutdown( ssdpSock, SD_BOTH );
|
||||||
UpnpCloseSocket( ssdpSock );
|
UpnpCloseSocket( ssdpSock );
|
||||||
|
|
||||||
return UPNP_E_SOCKET_ERROR;
|
return UPNP_E_SOCKET_ERROR;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* __FreeBSD__ */
|
||||||
|
|
||||||
memset( ( void * )&ssdpAddr, 0, sizeof( struct sockaddr_in ) );
|
memset( ( void * )&ssdpAddr, 0, sizeof( struct sockaddr_in ) );
|
||||||
ssdpAddr.sin_family = AF_INET;
|
ssdpAddr.sin_family = AF_INET;
|
||||||
@@ -931,8 +930,9 @@ CLIENTONLY(
|
|||||||
"Error in binding !!!\n" );
|
"Error in binding !!!\n" );
|
||||||
shutdown( ssdpSock, SD_BOTH );
|
shutdown( ssdpSock, SD_BOTH );
|
||||||
UpnpCloseSocket( ssdpSock );
|
UpnpCloseSocket( ssdpSock );
|
||||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ); )
|
||||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ); )
|
||||||
|
|
||||||
return UPNP_E_SOCKET_BIND;
|
return UPNP_E_SOCKET_BIND;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -945,9 +945,10 @@ CLIENTONLY(
|
|||||||
SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in joining" " multicast group !!!\n" );
|
"Error in joining" " multicast group !!!\n" );
|
||||||
shutdown( ssdpSock, SD_BOTH );
|
shutdown( ssdpSock, SD_BOTH );
|
||||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ); )
|
||||||
UpnpCloseSocket( ssdpSock );
|
UpnpCloseSocket( ssdpSock );
|
||||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ); )
|
||||||
|
|
||||||
return UPNP_E_SOCKET_ERROR;
|
return UPNP_E_SOCKET_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -961,7 +962,7 @@ CLIENTONLY(
|
|||||||
/* This is probably not a critical error, so let's continue. */
|
/* This is probably not a critical error, so let's continue. */
|
||||||
}
|
}
|
||||||
|
|
||||||
// result is not checked becuase it will fail in WinMe and Win9x.
|
/* result is not checked becuase it will fail in WinMe and Win9x. */
|
||||||
setsockopt( ssdpSock, IPPROTO_IP,
|
setsockopt( ssdpSock, IPPROTO_IP,
|
||||||
IP_MULTICAST_TTL, &ttl, sizeof( ttl ) );
|
IP_MULTICAST_TTL, &ttl, sizeof( ttl ) );
|
||||||
if( setsockopt( ssdpSock, SOL_SOCKET, SO_BROADCAST,
|
if( setsockopt( ssdpSock, SOL_SOCKET, SO_BROADCAST,
|
||||||
@@ -970,16 +971,18 @@ CLIENTONLY(
|
|||||||
SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in setting broadcast !!!\n" );
|
"Error in setting broadcast !!!\n" );
|
||||||
shutdown( ssdpSock, SD_BOTH );
|
shutdown( ssdpSock, SD_BOTH );
|
||||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ); )
|
||||||
UpnpCloseSocket( ssdpSock );
|
UpnpCloseSocket( ssdpSock );
|
||||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ); )
|
||||||
|
|
||||||
return UPNP_E_NETWORK_ERROR;
|
return UPNP_E_NETWORK_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
CLIENTONLY( out->ssdpReqSock = ssdpReqSock; );
|
CLIENTONLY( out->ssdpReqSock = ssdpReqSock; )
|
||||||
out->ssdpSock = ssdpSock;
|
out->ssdpSock = ssdpSock;
|
||||||
|
|
||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // EXCLUDE_SSDP
|
#endif /* EXCLUDE_SSDP */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user