libUPnP 1.14.19
upnpapi.h
Go to the documentation of this file.
1/*******************************************************************************
2 *
3 * Copyright (c) 2000-2003 Intel Corporation
4 * All rights reserved.
5 * Copyright (C) 2011-2012 France Telecom All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * * Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 * * Neither name of Intel Corporation nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 ******************************************************************************/
32
33#ifndef UPNPAPI_H
34#define UPNPAPI_H
35
40#include "VirtualDir.h" /* for struct VirtualDirCallbacks */
41#include "client_table.h"
42
43#define MAX_INTERFACES 256
44
45#define DEV_LIMIT 200
46
47#define DEFAULT_MX 5
48
49#define DEFAULT_MAXAGE 1800
50
51#define DEFAULT_SOAP_CONTENT_LENGTH 16000
52#define MAX_SOAP_CONTENT_LENGTH (size_t)32000
53
54#define NUM_HANDLE 200
55
56extern size_t g_maxContentLength;
57extern int g_UpnpSdkEQMaxLen;
58extern int g_UpnpSdkEQMaxAge;
59
60/* 30-second timeout */
61#define UPNP_TIMEOUT 30
62
63typedef enum
64{
65 HND_INVALID = -1,
66 HND_CLIENT,
67 HND_DEVICE
68} Upnp_Handle_Type;
69
70/* Data to be stored in handle table for */
72{
74 Upnp_Handle_Type HType;
78 char *Cookie;
81
82 /* Device Only */
83#ifdef INCLUDE_DEVICE_APIS
85 char DescURL[LINE_SIZE];
88 char LowerDescURL[LINE_SIZE];
90 char DescXML[LINE_SIZE];
91 /* Advertisement timeout */
92 int MaxAge;
93 /* Power State as defined by UPnP Low Power. */
94 int PowerState;
95 /* Sleep Period as defined by UPnP Low Power. */
96 int SleepPeriod;
97 /* Registration State as defined by UPnP Low Power. */
98 int RegistrationState;
113#endif
114
115 /* Client only */
116#ifdef INCLUDE_CLIENT_APIS
121#endif
122};
123
124extern ithread_rwlock_t GlobalHndRWLock;
125
131Upnp_Handle_Type GetHandleInfo(
133 int Hnd,
135 struct Handle_Info **HndInfo);
136
137#define HandleLock() HandleWriteLock()
138
139#define HandleWriteLock() \
140 UpnpPrintf( \
141 UPNP_INFO, API, __FILE__, __LINE__, "Trying a write lock\n"); \
142 ithread_rwlock_wrlock(&GlobalHndRWLock); \
143 UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Write lock acquired\n");
144
145#define HandleReadLock() \
146 UpnpPrintf( \
147 UPNP_INFO, API, __FILE__, __LINE__, "Trying a read lock\n"); \
148 ithread_rwlock_rdlock(&GlobalHndRWLock); \
149 UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Read lock acquired\n");
150
151#define HandleUnlock() \
152 UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Trying Unlock\n"); \
153 ithread_rwlock_unlock(&GlobalHndRWLock); \
154 UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Unlocked rwlock\n");
155
163Upnp_Handle_Type GetClientHandleInfo(
165 int *client_handle_out,
167 struct Handle_Info **HndInfo);
176Upnp_Handle_Type GetDeviceHandleInfo(
178 UpnpDevice_Handle start,
180 int AddressFamily,
182 int *device_handle_out,
184 struct Handle_Info **HndInfo);
185
193Upnp_Handle_Type GetDeviceHandleInfoForPath(
195 const char *path,
197 int AddressFamily,
199 int *device_handle_out,
201 struct Handle_Info **HndInfo,
203 service_info **serv_info);
204
205extern char gIF_NAME[LINE_SIZE];
206extern char gIF_IPV4[INET_ADDRSTRLEN];
207extern char gIF_IPV4_NETMASK[INET_ADDRSTRLEN];
208extern char gIF_IPV6[INET6_ADDRSTRLEN];
209extern unsigned gIF_IPV6_PREFIX_LENGTH;
210
211extern char gIF_IPV6_ULA_GUA[INET6_ADDRSTRLEN];
212extern unsigned gIF_IPV6_ULA_GUA_PREFIX_LENGTH;
213
214extern unsigned gIF_INDEX;
215
216extern unsigned short LOCAL_PORT_V4;
217extern unsigned short LOCAL_PORT_V6;
218extern unsigned short LOCAL_PORT_V6_ULA_GUA;
219
222
227
228typedef enum
229{
230 SUBSCRIBE,
231 UNSUBSCRIBE,
232 DK_NOTIFY,
233 QUERY,
234 ACTION,
235 STATUS,
236 DEVDESCRIPTION,
237 SERVDESCRIPTION,
238 MINI,
239 RENEW
240} UpnpFunName;
241
243{
244 UpnpFunName FunName;
245 int Handle;
246 int TimeOut;
247 char VarName[NAME_SIZE];
248 char NewVal[NAME_SIZE];
249 char DevType[NAME_SIZE];
250 char DevId[NAME_SIZE];
251 char ServiceType[NAME_SIZE];
252 char ServiceVer[NAME_SIZE];
253 char Url[NAME_SIZE];
254 Upnp_SID SubsId;
255 char *Cookie;
256 Upnp_FunPtr Fun;
257 IXML_Document *Header;
258 IXML_Document *Act;
259 struct DevDesc *Devdesc;
260};
261
264
265typedef enum
266{
267 WEB_SERVER_DISABLED,
268 WEB_SERVER_ENABLED
269} WebServerState;
270
271#define E_HTTP_SYNTAX -6
272
292int UpnpGetIfInfo(
294 const char *IfName);
295
296void UpnpThreadDistribution(struct UpnpNonblockParam *Param);
297
302void AutoAdvertise(
304 void *input);
305
314
316extern WebServerState bWebServerState;
317
319extern WebCallback_HostValidate gWebCallback_HostValidate;
320
323
326
327#endif /* UPNPAPI_H */
int(* Upnp_FunPtr)(Upnp_EventType EventType, const void *Event, void *Cookie)
Definition Callback.h:145
WebCallback_HostValidate gWebCallback_HostValidate
Definition upnpapi.c:144
unsigned gIF_IPV6_ULA_GUA_PREFIX_LENGTH
Definition upnpapi.c:173
char Upnp_SID[44]
Holds the subscription identifier for a subscription between a client and a device.
Definition upnp.h:448
struct VirtualDirCallbacks virtualDirCallback
Definition upnpapi.c:109
void UpnpThreadDistribution(struct UpnpNonblockParam *Param)
Schedule async functions in threadpool.
Definition upnpapi.c:4004
ThreadPool gSendThreadPool
Definition upnpapi.c:132
char gIF_IPV6_ULA_GUA[INET6_ADDRSTRLEN]
Definition upnpapi.c:170
ThreadPool gRecvThreadPool
Definition upnpapi.c:135
unsigned short LOCAL_PORT_V6_ULA_GUA
Definition upnpapi.c:185
int gAllowLiteralHostRedirection
Definition upnpapi.c:150
int PrintHandleInfo(UpnpClient_Handle Hnd)
Print handle info.
Definition upnpapi.c:4259
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
unsigned gIF_IPV6_PREFIX_LENGTH
Definition upnpapi.c:166
void * gWebCallback_HostValidateCookie
Definition upnpapi.c:147
size_t g_maxContentLength
Definition upnpapi.c:196
int UpnpClient_Handle
Returned when a control point application registers with UpnpRegisterClient.
Definition upnp.h:429
virtualDirList * pVirtualDirList
Definition upnpapi.c:112
int g_UpnpSdkEQMaxLen
Definition upnpapi.c:202
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
unsigned short LOCAL_PORT_V6
Definition upnpapi.c:182
unsigned short LOCAL_PORT_V4
Definition upnpapi.c:179
ithread_rwlock_t GlobalHndRWLock
Definition upnpapi.c:120
int UpnpDevice_Handle
Returned when a device application registers with UpnpRegisterRootDevice, UpnpRegisterRootDevice2,...
Definition upnp.h:439
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
void AutoAdvertise(void *input)
This function is a timer thread scheduled by UpnpSendAdvertisement to the send advetisement again.
Definition upnpapi.c:4298
char gIF_IPV4[INET_ADDRSTRLEN]
Definition upnpapi.c:156
TimerThread gTimerThread
Definition upnpapi.c:129
char gIF_NAME[LINE_SIZE]
Definition upnpapi.c:153
unsigned gIF_INDEX
Definition upnpapi.c:176
ThreadPool gMiniServerThreadPool
Definition upnpapi.c:138
char gIF_IPV4_NETMASK[INET_ADDRSTRLEN]
Definition upnpapi.c:159
int g_UpnpSdkEQMaxAge
Definition upnpapi.c:212
char gIF_IPV6[INET6_ADDRSTRLEN]
Definition upnpapi.c:163
Upnp_Handle_Type GetHandleInfo(int Hnd, struct Handle_Info **HndInfo)
Get handle information.
Definition upnpapi.c:4223
Upnp_Handle_Type GetClientHandleInfo(int *client_handle_out, struct Handle_Info **HndInfo)
Get client handle info.
Definition upnpapi.c:4126
WebServerState bWebServerState
Definition upnpapi.c:141
Definition upnpapi.h:72
Upnp_Handle_Type HType
Definition upnpapi.h:74
IXML_NodeList * ServiceList
Definition upnpapi.h:104
int aliasInstalled
Definition upnpapi.h:80
char DescXML[LINE_SIZE]
Definition upnpapi.h:90
GenlibClientSubscription * ClientSubList
Definition upnpapi.h:118
service_table ServiceTable
Definition upnpapi.h:106
char LowerDescURL[LINE_SIZE]
Definition upnpapi.h:88
char DescURL[LINE_SIZE]
Definition upnpapi.h:85
IXML_Document * DescDocument
Definition upnpapi.h:100
char * Cookie
Definition upnpapi.h:78
Upnp_FunPtr Callback
Definition upnpapi.h:76
int MaxSubscriptionTimeOut
Definition upnpapi.h:110
int MaxSubscriptions
Definition upnpapi.h:108
LinkedList SsdpSearchList
Definition upnpapi.h:120
IXML_NodeList * DeviceList
Definition upnpapi.h:102
int DeviceAf
Definition upnpapi.h:112
Definition LinkedList.h:84
Definition service_table.h:72
Definition service_table.h:90
A thread pool similar to the thread pool in the UPnP SDK.
Definition ThreadPool.h:217
Definition TimerThread.h:69
Definition upnpapi.h:243
Definition VirtualDir.h:11
Data structure representing the DOM Document.
Definition ixml.h:160
Data structure representing a list of nodes.
Definition ixml.h:203
Definition GenlibClientSubscription.c:19
Definition VirtualDir.h:61
Upnp_SID gUpnpSdkNLSuuid