upnpapi.h
Go to the documentation of this file.
/*******************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
* Copyright (C) 2011-2012 France Telecom All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#ifndef UPNPAPI_H
#define UPNPAPI_H
#include "VirtualDir.h" /* for struct VirtualDirCallbacks */
#include "client_table.h"
#define MAX_INTERFACES 256
#define DEV_LIMIT 200
#define DEFAULT_MX 5
#define DEFAULT_MAXAGE 1800
#define DEFAULT_SOAP_CONTENT_LENGTH 16000
#define MAX_SOAP_CONTENT_LENGTH (size_t)32000
#define NUM_HANDLE 200
extern size_t g_maxContentLength;
extern int g_UpnpSdkEQMaxLen;
extern int g_UpnpSdkEQMaxAge;
/* 30-second timeout */
#define UPNP_TIMEOUT 30
typedef enum
{
HND_INVALID = -1,
HND_CLIENT,
HND_DEVICE
} Upnp_Handle_Type;
/* Data to be stored in handle table for */
struct Handle_Info
{
Upnp_Handle_Type HType;
Upnp_FunPtr Callback;
char *Cookie;
int aliasInstalled;
/* Device Only */
#ifdef INCLUDE_DEVICE_APIS
char DescURL[LINE_SIZE];
char LowerDescURL[LINE_SIZE];
char DescXML[LINE_SIZE];
/* Advertisement timeout */
int MaxAge;
/* Power State as defined by UPnP Low Power. */
int PowerState;
/* Sleep Period as defined by UPnP Low Power. */
int SleepPeriod;
/* Registration State as defined by UPnP Low Power. */
int RegistrationState;
IXML_Document *DescDocument;
IXML_NodeList *DeviceList;
IXML_NodeList *ServiceList;
service_table ServiceTable;
int MaxSubscriptions;
int MaxSubscriptionTimeOut;
int DeviceAf;
#endif
/* Client only */
#ifdef INCLUDE_CLIENT_APIS
GenlibClientSubscription *ClientSubList;
LinkedList SsdpSearchList;
#endif
};
extern ithread_rwlock_t GlobalHndRWLock;
Upnp_Handle_Type GetHandleInfo(
int Hnd,
struct Handle_Info **HndInfo);
#define HandleLock() HandleWriteLock()
#define HandleWriteLock() \
UpnpPrintf( \
UPNP_INFO, API, __FILE__, __LINE__, "Trying a write lock\n"); \
ithread_rwlock_wrlock(&GlobalHndRWLock); \
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Write lock acquired\n");
#define HandleReadLock() \
UpnpPrintf( \
UPNP_INFO, API, __FILE__, __LINE__, "Trying a read lock\n"); \
ithread_rwlock_rdlock(&GlobalHndRWLock); \
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Read lock acquired\n");
#define HandleUnlock() \
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Trying Unlock\n"); \
ithread_rwlock_unlock(&GlobalHndRWLock); \
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Unlocked rwlock\n");
Upnp_Handle_Type GetClientHandleInfo(
int *client_handle_out,
struct Handle_Info **HndInfo);
Upnp_Handle_Type GetDeviceHandleInfo(
UpnpDevice_Handle start,
int AddressFamily,
int *device_handle_out,
struct Handle_Info **HndInfo);
Upnp_Handle_Type GetDeviceHandleInfoForPath(
const char *path,
int AddressFamily,
int *device_handle_out,
struct Handle_Info **HndInfo,
service_info **serv_info);
extern char gIF_NAME[LINE_SIZE];
extern char gIF_IPV4[INET_ADDRSTRLEN];
extern char gIF_IPV4_NETMASK[INET_ADDRSTRLEN];
extern char gIF_IPV6[INET6_ADDRSTRLEN];
extern unsigned gIF_IPV6_PREFIX_LENGTH;
extern char gIF_IPV6_ULA_GUA[INET6_ADDRSTRLEN];
extern unsigned gIF_IPV6_ULA_GUA_PREFIX_LENGTH;
extern unsigned gIF_INDEX;
extern unsigned short LOCAL_PORT_V4;
extern unsigned short LOCAL_PORT_V6;
extern unsigned short LOCAL_PORT_V6_ULA_GUA;
extern Upnp_SID gUpnpSdkNLSuuid;
extern TimerThread gTimerThread;
extern ThreadPool gRecvThreadPool;
extern ThreadPool gSendThreadPool;
extern ThreadPool gMiniServerThreadPool;
typedef enum
{
SUBSCRIBE,
UNSUBSCRIBE,
DK_NOTIFY,
QUERY,
ACTION,
STATUS,
DEVDESCRIPTION,
SERVDESCRIPTION,
MINI,
RENEW
} UpnpFunName;
struct UpnpNonblockParam
{
UpnpFunName FunName;
int Handle;
int TimeOut;
char VarName[NAME_SIZE];
char NewVal[NAME_SIZE];
char DevType[NAME_SIZE];
char DevId[NAME_SIZE];
char ServiceType[NAME_SIZE];
char ServiceVer[NAME_SIZE];
char Url[NAME_SIZE];
Upnp_SID SubsId;
char *Cookie;
Upnp_FunPtr Fun;
IXML_Document *Header;
IXML_Document *Act;
struct DevDesc *Devdesc;
};
extern virtualDirList *pVirtualDirList;
extern struct VirtualDirCallbacks virtualDirCallback;
typedef enum
{
WEB_SERVER_DISABLED,
WEB_SERVER_ENABLED
} WebServerState;
#define E_HTTP_SYNTAX -6
int UpnpGetIfInfo(
const char *IfName);
void UpnpThreadDistribution(struct UpnpNonblockParam *Param);
void AutoAdvertise(
void *input);
int PrintHandleInfo(
UpnpClient_Handle Hnd);
extern WebServerState bWebServerState;
extern WebCallback_HostValidate gWebCallback_HostValidate;
extern void *gWebCallback_HostValidateCookie;
extern int gAllowLiteralHostRedirection;
#endif /* UPNPAPI_H */
Upnp_FunPtr
int(* Upnp_FunPtr)(Upnp_EventType EventType, const void *Event, void *Cookie)
Definition Callback.h:145
client_table.h
gWebCallback_HostValidate
WebCallback_HostValidate gWebCallback_HostValidate
Definition upnpapi.c:144
gIF_IPV6_ULA_GUA_PREFIX_LENGTH
unsigned gIF_IPV6_ULA_GUA_PREFIX_LENGTH
Definition upnpapi.c:173
Upnp_SID
char Upnp_SID[44]
Holds the subscription identifier for a subscription between a client and a device.
Definition upnp.h:448
virtualDirCallback
struct VirtualDirCallbacks virtualDirCallback
Definition upnpapi.c:109
UpnpThreadDistribution
void UpnpThreadDistribution(struct UpnpNonblockParam *Param)
Schedule async functions in threadpool.
Definition upnpapi.c:4004
gSendThreadPool
ThreadPool gSendThreadPool
Definition upnpapi.c:132
gIF_IPV6_ULA_GUA
char gIF_IPV6_ULA_GUA[INET6_ADDRSTRLEN]
Definition upnpapi.c:170
gRecvThreadPool
ThreadPool gRecvThreadPool
Definition upnpapi.c:135
LOCAL_PORT_V6_ULA_GUA
unsigned short LOCAL_PORT_V6_ULA_GUA
Definition upnpapi.c:185
gAllowLiteralHostRedirection
int gAllowLiteralHostRedirection
Definition upnpapi.c:150
PrintHandleInfo
int PrintHandleInfo(UpnpClient_Handle Hnd)
Print handle info.
Definition upnpapi.c:4259
GetDeviceHandleInfoForPath
Upnp_Handle_Type GetDeviceHandleInfoForPath(const char *path, int AddressFamily, int *device_handle_out, struct Handle_Info **HndInfo, service_info **serv_info)
Retrieves the device handle and information of the first device of the address family specified,...
Definition upnpapi.c:4183
gIF_IPV6_PREFIX_LENGTH
unsigned gIF_IPV6_PREFIX_LENGTH
Definition upnpapi.c:166
gWebCallback_HostValidateCookie
void * gWebCallback_HostValidateCookie
Definition upnpapi.c:147
g_maxContentLength
size_t g_maxContentLength
Definition upnpapi.c:196
UpnpClient_Handle
int UpnpClient_Handle
Returned when a control point application registers with UpnpRegisterClient.
Definition upnp.h:429
pVirtualDirList
virtualDirList * pVirtualDirList
Definition upnpapi.c:112
g_UpnpSdkEQMaxLen
int g_UpnpSdkEQMaxLen
Definition upnpapi.c:202
UpnpGetIfInfo
int UpnpGetIfInfo(const char *IfName)
Retrieve interface information and keep it in global variables. If NULL, we'll find the first suitabl...
Definition upnpapi.c:3651
LOCAL_PORT_V6
unsigned short LOCAL_PORT_V6
Definition upnpapi.c:182
LOCAL_PORT_V4
unsigned short LOCAL_PORT_V4
Definition upnpapi.c:179
GlobalHndRWLock
ithread_rwlock_t GlobalHndRWLock
Definition upnpapi.c:120
UpnpDevice_Handle
int UpnpDevice_Handle
Returned when a device application registers with UpnpRegisterRootDevice, UpnpRegisterRootDevice2,...
Definition upnp.h:439
GetDeviceHandleInfo
Upnp_Handle_Type GetDeviceHandleInfo(UpnpDevice_Handle start, int AddressFamily, int *device_handle_out, struct Handle_Info **HndInfo)
Retrieves the device handle and information of the first device of the address family specified....
Definition upnpapi.c:4146
AutoAdvertise
void AutoAdvertise(void *input)
This function is a timer thread scheduled by UpnpSendAdvertisement to the send advetisement again.
Definition upnpapi.c:4298
gIF_IPV4
char gIF_IPV4[INET_ADDRSTRLEN]
Definition upnpapi.c:156
gTimerThread
TimerThread gTimerThread
Definition upnpapi.c:129
gIF_NAME
char gIF_NAME[LINE_SIZE]
Definition upnpapi.c:153
gIF_INDEX
unsigned gIF_INDEX
Definition upnpapi.c:176
gMiniServerThreadPool
ThreadPool gMiniServerThreadPool
Definition upnpapi.c:138
gIF_IPV4_NETMASK
char gIF_IPV4_NETMASK[INET_ADDRSTRLEN]
Definition upnpapi.c:159
g_UpnpSdkEQMaxAge
int g_UpnpSdkEQMaxAge
Definition upnpapi.c:212
gIF_IPV6
char gIF_IPV6[INET6_ADDRSTRLEN]
Definition upnpapi.c:163
GetHandleInfo
Upnp_Handle_Type GetHandleInfo(int Hnd, struct Handle_Info **HndInfo)
Get handle information.
Definition upnpapi.c:4223
GetClientHandleInfo
Upnp_Handle_Type GetClientHandleInfo(int *client_handle_out, struct Handle_Info **HndInfo)
Get client handle info.
Definition upnpapi.c:4126
bWebServerState
WebServerState bWebServerState
Definition upnpapi.c:141
Handle_Info
Definition upnpapi.h:72
Handle_Info::HType
Upnp_Handle_Type HType
Definition upnpapi.h:74
Handle_Info::ServiceList
IXML_NodeList * ServiceList
Definition upnpapi.h:104
Handle_Info::aliasInstalled
int aliasInstalled
Definition upnpapi.h:80
Handle_Info::DescXML
char DescXML[LINE_SIZE]
Definition upnpapi.h:90
Handle_Info::ClientSubList
GenlibClientSubscription * ClientSubList
Definition upnpapi.h:118
Handle_Info::ServiceTable
service_table ServiceTable
Definition upnpapi.h:106
Handle_Info::LowerDescURL
char LowerDescURL[LINE_SIZE]
Definition upnpapi.h:88
Handle_Info::DescURL
char DescURL[LINE_SIZE]
Definition upnpapi.h:85
Handle_Info::DescDocument
IXML_Document * DescDocument
Definition upnpapi.h:100
Handle_Info::Cookie
char * Cookie
Definition upnpapi.h:78
Handle_Info::Callback
Upnp_FunPtr Callback
Definition upnpapi.h:76
Handle_Info::MaxSubscriptionTimeOut
int MaxSubscriptionTimeOut
Definition upnpapi.h:110
Handle_Info::MaxSubscriptions
int MaxSubscriptions
Definition upnpapi.h:108
Handle_Info::SsdpSearchList
LinkedList SsdpSearchList
Definition upnpapi.h:120
Handle_Info::DeviceList
IXML_NodeList * DeviceList
Definition upnpapi.h:102
Handle_Info::DeviceAf
int DeviceAf
Definition upnpapi.h:112
LINKEDLIST
Definition LinkedList.h:84
SERVICE_INFO
Definition service_table.h:72
SERVICE_TABLE
Definition service_table.h:90
THREADPOOL
A thread pool similar to the thread pool in the UPnP SDK.
Definition ThreadPool.h:217
TIMERTHREAD
Definition TimerThread.h:69
UpnpNonblockParam
Definition upnpapi.h:243
VirtualDirCallbacks
Definition VirtualDir.h:11
_IXML_Document
Data structure representing the DOM Document.
Definition ixml.h:160
_IXML_NodeList
Data structure representing a list of nodes.
Definition ixml.h:203
s_GenlibClientSubscription
Definition GenlibClientSubscription.c:19
virtual_Dir_List
Definition VirtualDir.h:61
gUpnpSdkNLSuuid
Upnp_SID gUpnpSdkNLSuuid