libUPnP  1.14.5
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 
34 #ifndef UPNPAPI_H
35 #define UPNPAPI_H
36 
37 
43 #include "client_table.h"
44 #include "upnp.h"
45 #include "VirtualDir.h" /* for struct VirtualDirCallbacks */
46 
47 
48 #define MAX_INTERFACES 256
49 
50 #define DEV_LIMIT 200
51 
52 #define DEFAULT_MX 5
53 
54 #define DEFAULT_MAXAGE 1800
55 
56 #define DEFAULT_SOAP_CONTENT_LENGTH 16000
57 #define MAX_SOAP_CONTENT_LENGTH (size_t)32000
58 
59 #define NUM_HANDLE 200
60 
61 extern size_t g_maxContentLength;
62 extern int g_UpnpSdkEQMaxLen;
63 extern int g_UpnpSdkEQMaxAge;
64 
65 /* 30-second timeout */
66 #define UPNP_TIMEOUT 30
67 
68 typedef enum {HND_INVALID=-1,HND_CLIENT,HND_DEVICE} 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
84 
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;
112  int DeviceAf;
113 #endif
114 
115  /* Client only */
116 #ifdef INCLUDE_CLIENT_APIS
117 
121 #endif
122 };
123 
124 extern ithread_rwlock_t GlobalHndRWLock;
125 
131 Upnp_Handle_Type GetHandleInfo(
133  int Hnd,
135  struct Handle_Info **HndInfo);
136 
137 
138 #define HandleLock() HandleWriteLock()
139 
140 
141 #define HandleWriteLock() \
142  UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Trying a write lock\n"); \
143  ithread_rwlock_wrlock(&GlobalHndRWLock); \
144  UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Write lock acquired\n");
145 
146 
147 #define HandleReadLock() \
148  UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Trying a read lock\n"); \
149  ithread_rwlock_rdlock(&GlobalHndRWLock); \
150  UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Read lock acquired\n");
151 
152 
153 #define HandleUnlock() \
154  UpnpPrintf(UPNP_INFO, API,__FILE__, __LINE__, "Trying Unlock\n"); \
155  ithread_rwlock_unlock(&GlobalHndRWLock); \
156  UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Unlocked rwlock\n");
157 
158 
166 Upnp_Handle_Type GetClientHandleInfo(
168  int *client_handle_out,
170  struct Handle_Info **HndInfo);
179 Upnp_Handle_Type GetDeviceHandleInfo(
181  UpnpDevice_Handle start,
183  int AddressFamily,
185  int *device_handle_out,
187  struct Handle_Info **HndInfo);
188 
196 Upnp_Handle_Type GetDeviceHandleInfoForPath(
198  const char *path,
200  int AddressFamily,
202  int *device_handle_out,
204  struct Handle_Info **HndInfo,
206  service_info **serv_info
207  );
208 
209 
210 extern char gIF_NAME[LINE_SIZE];
211 extern char gIF_IPV4[INET_ADDRSTRLEN];
212 extern char gIF_IPV4_NETMASK[INET_ADDRSTRLEN];
213 extern char gIF_IPV6[INET6_ADDRSTRLEN];
214 extern unsigned gIF_IPV6_PREFIX_LENGTH;
215 
216 extern char gIF_IPV6_ULA_GUA[INET6_ADDRSTRLEN];
217 extern unsigned gIF_IPV6_ULA_GUA_PREFIX_LENGTH;
218 
219 extern unsigned gIF_INDEX;
220 
221 
222 extern unsigned short LOCAL_PORT_V4;
223 extern unsigned short LOCAL_PORT_V6;
224 extern unsigned short LOCAL_PORT_V6_ULA_GUA;
225 
226 
229 
230 
235 
236 
237 typedef enum {
238  SUBSCRIBE,
239  UNSUBSCRIBE,
240  DK_NOTIFY,
241  QUERY,
242  ACTION,
243  STATUS,
244  DEVDESCRIPTION,
245  SERVDESCRIPTION,
246  MINI,
247  RENEW
248 } UpnpFunName;
249 
250 
252 {
253  UpnpFunName FunName;
254  int Handle;
255  int TimeOut;
256  char VarName[NAME_SIZE];
257  char NewVal[NAME_SIZE];
258  char DevType[NAME_SIZE];
259  char DevId[NAME_SIZE];
260  char ServiceType[NAME_SIZE];
261  char ServiceVer[NAME_SIZE];
262  char Url[NAME_SIZE];
263  Upnp_SID SubsId;
264  char *Cookie;
265  Upnp_FunPtr Fun;
266  IXML_Document *Header;
267  IXML_Document *Act;
268  struct DevDesc *Devdesc;
269 };
270 
271 
273 extern struct VirtualDirCallbacks virtualDirCallback;
274 
275 
276 typedef enum {
277  WEB_SERVER_DISABLED,
278  WEB_SERVER_ENABLED
279 } WebServerState;
280 
281 
282 #define E_HTTP_SYNTAX -6
283 
284 
304 int UpnpGetIfInfo(
306  const char *IfName);
307 
308 
309 void UpnpThreadDistribution(struct UpnpNonblockParam * Param);
310 
311 
316 void AutoAdvertise(
318  void *input);
319 
320 
326 int PrintHandleInfo(
328  UpnpClient_Handle Hnd);
329 
330 
331 extern WebServerState bWebServerState;
332 
333 
334 #endif /* UPNPAPI_H */
335 
Upnp_FunPtr Callback
Definition: upnpapi.h:76
int UpnpClient_Handle
Returned when a control point application registers with UpnpRegisterClient.
Definition: upnp.h:429
int(* Upnp_FunPtr)(Upnp_EventType EventType, const void *Event, void *Cookie)
Definition: Callback.h:145
IXML_Document * DescDocument
Definition: upnpapi.h:100
size_t g_maxContentLength
Definition: upnpapi.c:185
char DescURL[LINE_SIZE]
Definition: upnpapi.h:85
Definition: service_table.h:71
Definition: TimerThread.h:67
unsigned gIF_IPV6_PREFIX_LENGTH
Definition: upnpapi.c:155
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:4049
Definition: upnpapi.h:251
IXML_NodeList * DeviceList
Definition: upnpapi.h:102
Upnp_Handle_Type GetHandleInfo(int Hnd, struct Handle_Info **HndInfo)
Get handle information.
Definition: upnpapi.c:4126
char LowerDescURL[LINE_SIZE]
Definition: upnpapi.h:88
int g_UpnpSdkEQMaxAge
Definition: upnpapi.c:201
Upnp_Handle_Type HType
Definition: upnpapi.h:74
LinkedList SsdpSearchList
Definition: upnpapi.h:120
Definition: VirtualDir.h:11
ThreadPool gSendThreadPool
Definition: upnpapi.c:130
IXML_NodeList * ServiceList
Definition: upnpapi.h:104
WebServerState bWebServerState
Definition: upnpapi.c:139
GenlibClientSubscription * ClientSubList
Definition: upnpapi.h:118
Upnp_SID gUpnpSdkNLSuuid
int PrintHandleInfo(UpnpClient_Handle Hnd)
Print handle info.
Definition: upnpapi.c:4162
char gIF_IPV6[INET6_ADDRSTRLEN]
Definition: upnpapi.c:152
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:4086
int MaxSubscriptionTimeOut
Definition: upnpapi.h:110
A thread pool similar to the thread pool in the UPnP SDK.
Definition: ThreadPool.h:215
unsigned short LOCAL_PORT_V6
Definition: upnpapi.c:171
TimerThread gTimerThread
Definition: upnpapi.c:127
int aliasInstalled
Definition: upnpapi.h:80
Definition: service_table.h:89
char gIF_IPV4_NETMASK[INET_ADDRSTRLEN]
Definition: upnpapi.c:148
void AutoAdvertise(void *input)
This function is a timer thread scheduled by UpnpSendAdvertisement to the send advetisement again...
Definition: upnpapi.c:4201
unsigned short LOCAL_PORT_V4
Definition: upnpapi.c:168
unsigned gIF_IPV6_ULA_GUA_PREFIX_LENGTH
Definition: upnpapi.c:162
void UpnpThreadDistribution(struct UpnpNonblockParam *Param)
Schedule async functions in threadpool.
Definition: upnpapi.c:3917
char gIF_NAME[LINE_SIZE]
Definition: upnpapi.c:142
char gIF_IPV4[INET_ADDRSTRLEN]
Definition: upnpapi.c:145
int UpnpDevice_Handle
Returned when a device application registers with UpnpRegisterRootDevice, UpnpRegisterRootDevice2, UpnpRegisterRootDevice3 or UpnpRegisterRootDevice4.
Definition: upnp.h:439
ithread_rwlock_t GlobalHndRWLock
Definition: upnpapi.c:118
Upnp_Handle_Type GetClientHandleInfo(int *client_handle_out, struct Handle_Info **HndInfo)
Get client handle info.
Definition: upnpapi.c:4029
service_table ServiceTable
Definition: upnpapi.h:106
Data structure representing a list of nodes.
Definition: ixml.h:202
virtualDirList * pVirtualDirList
Definition: upnpapi.c:110
unsigned gIF_INDEX
Definition: upnpapi.c:165
unsigned short LOCAL_PORT_V6_ULA_GUA
Definition: upnpapi.c:174
char * Cookie
Definition: upnpapi.h:78
int MaxSubscriptions
Definition: upnpapi.h:108
int DeviceAf
Definition: upnpapi.h:112
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:3575
int g_UpnpSdkEQMaxLen
Definition: upnpapi.c:191
Data structure representing the DOM Document.
Definition: ixml.h:159
ThreadPool gRecvThreadPool
Definition: upnpapi.c:133
Definition: VirtualDir.h:61
char Upnp_SID[44]
Holds the subscription identifier for a subscription between a client and a device.
Definition: upnp.h:448
char gIF_IPV6_ULA_GUA[INET6_ADDRSTRLEN]
Definition: upnpapi.c:159
ThreadPool gMiniServerThreadPool
Definition: upnpapi.c:136
char DescXML[LINE_SIZE]
Definition: upnpapi.h:90
Definition: GenlibClientSubscription.c:18
Definition: upnpapi.h:71
Definition: LinkedList.h:83