libUPnP  1.14.22
upnp.h
Go to the documentation of this file.
1 #ifndef UPNP_H
2 #define UPNP_H
3 
4 /*******************************************************************************
5  *
6  * Copyright (c) 2000-2003 Intel Corporation
7  * All rights reserved.
8  * Copyright (C) 2011-2012 France Telecom All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions are met:
12  *
13  * * Redistributions of source code must retain the above copyright notice,
14  * this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  * * Neither name of Intel Corporation nor the names of its contributors
19  * may be used to endorse or promote products derived from this software
20  * without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
26  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
30  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  ******************************************************************************/
35 
44 #include "UpnpGlobal.h"
45 #include "UpnpInet.h"
46 #include "ixml.h"
47 #include "upnpconfig.h" // IWYU pragma: keep
48 
49 /*
50  * \todo Document the exact reason of these include files and solve this
51  * include mess in an include file like UpnpTime.h
52  */
53 #ifdef _WIN32
54  #include <time.h>
55  #if defined(UPNP_USE_MSVCPP) || defined(UPNP_USE_BCBPP)
56  #include <sys/types.h> /* needed for off_t */
57  #endif
58 #elif (defined(BSD) && BSD >= 199306)
59  #include <time.h>
60 #else
61  /* Other systems ??? */
62 #endif
63 
64 #ifdef UPNP_ENABLE_OPEN_SSL
65  #include <openssl/ssl.h>
66 #endif
67 
68 #define LINE_SIZE (size_t)180
69 #define NAME_SIZE (size_t)256
70 #define MNFT_NAME_SIZE 64
71 #define MODL_NAME_SIZE 32
72 #define SERL_NUMR_SIZE 64
73 #define MODL_DESC_SIZE 64
74 #define UPNP_INFINITE -1
75 #define UPNP_USING_CHUNKED -3
76 #define UPNP_UNTIL_CLOSE -4
77 
97 #define UPNP_E_SUCCESS 0
98 
102 #define UPNP_E_INVALID_HANDLE -100
103 
110 #define UPNP_E_INVALID_PARAM -101
111 
117 #define UPNP_E_OUTOF_HANDLE -102
118 
119 #define UPNP_E_OUTOF_CONTEXT -103
120 
127 #define UPNP_E_OUTOF_MEMORY -104
128 
135 #define UPNP_E_INIT -105
136 
137 #define UPNP_E_BUFFER_TOO_SMALL -106
138 
144 #define UPNP_E_INVALID_DESC -107
145 
153 #define UPNP_E_INVALID_URL -108
154 
155 #define UPNP_E_INVALID_SID -109
156 
157 #define UPNP_E_INVALID_DEVICE -110
158 
165 #define UPNP_E_INVALID_SERVICE -111
166 
173 #define UPNP_E_BAD_RESPONSE -113
174 
175 #define UPNP_E_BAD_REQUEST -114
176 
183 #define UPNP_E_INVALID_ACTION -115
184 
191 #define UPNP_E_FINISH -116
192 
198 #define UPNP_E_INIT_FAILED -117
199 
205 #define UPNP_E_URL_TOO_BIG -118
206 
216 #define UPNP_E_BAD_HTTPMSG -119
217 
224 #define UPNP_E_ALREADY_REGISTERED -120
225 
230 #define UPNP_E_INVALID_INTERFACE -121
231 
239 #define UPNP_E_NETWORK_ERROR -200
240 
249 #define UPNP_E_SOCKET_WRITE -201
250 
259 #define UPNP_E_SOCKET_READ -202
260 
269 #define UPNP_E_SOCKET_BIND -203
270 
279 #define UPNP_E_SOCKET_CONNECT -204
280 
289 #define UPNP_E_OUTOF_SOCKET -205
290 
297 #define UPNP_E_LISTEN -206
298 
305 #define UPNP_E_TIMEDOUT -207
306 
313 #define UPNP_E_SOCKET_ERROR -208
314 
315 #define UPNP_E_FILE_WRITE_ERROR -209
316 
322 #define UPNP_E_CANCELED -210
323 
324 #define UPNP_E_EVENT_PROTOCOL -300
325 
329 #define UPNP_E_SUBSCRIBE_UNACCEPTED -301
330 
334 #define UPNP_E_UNSUBSCRIBE_UNACCEPTED -302
335 
339 #define UPNP_E_NOTIFY_UNACCEPTED -303
340 
347 #define UPNP_E_INVALID_ARGUMENT -501
348 
353 #define UPNP_E_FILE_NOT_FOUND -502
354 
358 #define UPNP_E_FILE_READ_ERROR -503
359 
364 #define UPNP_E_EXT_NOT_XML -504
365 
366 #define UPNP_E_NO_WEB_SERVER -505
367 #define UPNP_E_OUTOF_BOUNDS -506
368 
373 #define UPNP_E_NOT_FOUND -507
374 
379 #define UPNP_E_INTERNAL_ERROR -911
380 
381 /* SOAP-related error codes */
382 #define UPNP_SOAP_E_INVALID_ACTION 401
383 #define UPNP_SOAP_E_INVALID_ARGS 402
384 #define UPNP_SOAP_E_OUT_OF_SYNC 403
385 #define UPNP_SOAP_E_INVALID_VAR 404
386 #define UPNP_SOAP_E_ACTION_FAILED 501
387 
388 /* @} ErrorCodes */
389 
390 /*
391  * Opaque data structures. The following includes are data structures that
392  * must be externally visible. Since version 1.8.0, only an opaque typedef
393  * is visible from the outside world. Any operation on these data types
394  * must be done using the appropriate interface functions.
395  *
396  * This policy has the great advantage that it is now possible to change
397  * the internal implementation of these data structures without breaking
398  * the API.
399  */
400 #include "UpnpActionComplete.h" // IWYU pragma: keep
401 #include "UpnpActionRequest.h" // IWYU pragma: keep
402 #include "UpnpDiscovery.h" // IWYU pragma: keep
403 #include "UpnpEvent.h" // IWYU pragma: keep
404 #include "UpnpEventSubscribe.h" // IWYU pragma: keep
405 #include "UpnpFileInfo.h" // IWYU pragma: keep
406 #include "UpnpStateVarComplete.h" // IWYU pragma: keep
407 #include "UpnpStateVarRequest.h" // IWYU pragma: keep
408 #include "UpnpSubscriptionRequest.h" // IWYU pragma: keep
409 
416 enum UpnpOpenFileMode
417 {
418  UPNP_READ,
419  UPNP_WRITE
420 };
421 
429 typedef int UpnpClient_Handle;
430 
439 typedef int UpnpDevice_Handle;
440 
448 typedef char Upnp_SID[44];
449 
459 {
462 
465 
469 
473 };
474 
475 typedef enum Upnp_SType_e Upnp_SType;
476 
484 {
487 
491 
495 };
496 
497 typedef enum Upnp_DescType_e Upnp_DescType;
498 
499 #include "Callback.h"
500 
501 /* @} Constants and Types */
502 
503 #ifdef __cplusplus
504 extern "C" {
505 #endif /* __cplusplus */
506 
549  const char *IfName,
552  unsigned short DestPort);
553 
566 #ifdef UPNP_ENABLE_OPEN_SSL
572  int initOpenSslLib,
575  const SSL_METHOD *sslMethod);
576 #endif
577 
597 UPNP_EXPORT_SPEC int UpnpFinish(void);
598 
610 UPNP_EXPORT_SPEC unsigned short UpnpGetServerPort(void);
611 
623 UPNP_EXPORT_SPEC unsigned short UpnpGetServerPort6(void);
624 
636 UPNP_EXPORT_SPEC unsigned short UpnpGetServerUlaGuaPort6(void);
637 
650 
663 
716  const char *DescUrl,
719  Upnp_FunPtr Callback,
722  const void *Cookie,
724  UpnpDevice_Handle *Hnd);
725 
796  Upnp_DescType descriptionType,
799  const char *description,
802  size_t bufferLen,
805  int config_baseURL,
808  Upnp_FunPtr Fun,
811  const void *Cookie,
813  UpnpDevice_Handle *Hnd);
814 
853  const char *DescUrl,
856  Upnp_FunPtr Callback,
859  const void *Cookie,
861  UpnpDevice_Handle *Hnd,
864  int AddressFamily);
865 
905  const char *DescUrl,
908  Upnp_FunPtr Callback,
911  const void *Cookie,
913  UpnpDevice_Handle *Hnd,
916  int AddressFamily,
919  const char *LowerDescUrl);
920 
939  UpnpDevice_Handle Hnd);
940 
962  UpnpDevice_Handle Hnd,
964  int PowerState,
966  int SleepPeriod,
968  int RegistrationState);
969 
990  Upnp_FunPtr Callback,
993  const void *Cookie,
996  UpnpClient_Handle *Hnd);
997 
1016  UpnpClient_Handle Hnd);
1017 
1027  UpnpClient_Handle Hnd,
1029  size_t contentLength);
1030 
1050  size_t contentLength);
1051 
1052 /* @} Initialization and Registration */
1053 
1054 /******************************************************************************
1055  ******************************************************************************
1056  * *
1057  * D I S C O V E R Y *
1058  * *
1059  ******************************************************************************
1060  ******************************************************************************/
1061 
1093  UpnpClient_Handle Hnd,
1098  int Mx,
1101  const char *TTarget_constarget_const,
1103  const void *Cookie_const);
1104 
1122  UpnpDevice_Handle Hnd,
1128  int Exp);
1129 
1150  UpnpDevice_Handle Hnd,
1156  int Exp,
1158  int PowerState,
1160  int SleepPeriod,
1162  int RegistrationState);
1163 
1164 /* @} Discovery */
1165 
1166 /******************************************************************************
1167  ******************************************************************************
1168  * *
1169  * C O N T R O L *
1170  * *
1171  ******************************************************************************
1172  ******************************************************************************/
1173 
1207  UpnpClient_Handle Hnd,
1209  const char *ActionURL,
1211  const char *VarName,
1215  DOMString *StVarVal);
1216 
1236  UpnpClient_Handle Hnd,
1238  const char *ActionURL,
1240  const char *VarName,
1243  Upnp_FunPtr Fun,
1246  const void *Cookie);
1247 
1273  UpnpClient_Handle Hnd,
1275  const char *ActionURL,
1277  const char *ServiceType,
1279  const char *DevUDN,
1281  IXML_Document *Action,
1284  IXML_Document **RespNode);
1285 
1311  UpnpClient_Handle Hnd,
1313  const char *ActionURL,
1315  const char *ServiceType,
1317  const char *DevUDN,
1320  IXML_Document *Header,
1322  IXML_Document *Action,
1325  IXML_Document **RespNode);
1326 
1350  UpnpClient_Handle Hnd,
1352  const char *ActionURL,
1354  const char *ServiceType,
1356  const char *DevUDN,
1358  IXML_Document *Action,
1361  Upnp_FunPtr Fun,
1364  const void *Cookie);
1365 
1389  UpnpClient_Handle Hnd,
1391  const char *ActionURL,
1393  const char *ServiceType,
1395  const char *DevUDN,
1398  IXML_Document *Header,
1400  IXML_Document *Action,
1403  Upnp_FunPtr Fun,
1406  const void *Cookie);
1407 
1410 /******************************************************************************
1411  ******************************************************************************
1412  * *
1413  * E V E N T I N G *
1414  * *
1415  ******************************************************************************
1416  ******************************************************************************/
1417 
1451  UpnpDevice_Handle Hnd,
1454  const char *DevID,
1457  const char *ServID,
1459  const char **VarName,
1461  const char **NewVal,
1463  int cVariables,
1465  const Upnp_SID SubsId);
1466 
1491  UpnpDevice_Handle Hnd,
1494  const char *DevID,
1497  const char *ServID,
1501  IXML_Document *PropSet,
1503  const Upnp_SID SubsId);
1504 
1531  const char *DevID,
1533  const char *ServID,
1535  const char **VarName,
1537  const char **NewVal,
1539  int cVariables);
1540 
1567  const char *DevID,
1569  const char *ServID,
1573  IXML_Document *PropSet);
1574 
1606  UpnpClient_Handle Hnd,
1609  int *TimeOut,
1611  const Upnp_SID SubsId);
1612 
1663  UpnpClient_Handle Hnd,
1666  int TimeOut,
1668  Upnp_SID SubsId,
1671  Upnp_FunPtr Fun,
1674  const void *Cookie);
1675 
1692  UpnpDevice_Handle Hnd,
1694  int MaxSubscriptions);
1695 
1713  UpnpDevice_Handle Hnd,
1715  int MaxSubscriptionTimeOut);
1716 
1748  UpnpClient_Handle Hnd,
1750  const char *PublisherUrl,
1754  int *TimeOut,
1756  Upnp_SID SubsId);
1757 
1808  UpnpClient_Handle Hnd,
1810  const char *PublisherUrl,
1813  int TimeOut,
1815  Upnp_FunPtr Fun,
1817  const void *Cookie);
1818 
1850  UpnpClient_Handle Hnd,
1853  const Upnp_SID SubsId);
1854 
1905  UpnpClient_Handle Hnd,
1908  Upnp_SID SubsId,
1911  Upnp_FunPtr Fun,
1914  const void *Cookie);
1915 
1918 /******************************************************************************
1919  ******************************************************************************
1920  * *
1921  * C L I E N T - A P I *
1922  * *
1923  ******************************************************************************
1924  ******************************************************************************/
1925 
1936 {
1937  UPNP_HTTPMETHOD_PUT = 0,
1938  UPNP_HTTPMETHOD_DELETE = 1,
1939  UPNP_HTTPMETHOD_GET = 2,
1940  UPNP_HTTPMETHOD_HEAD = 3,
1941  UPNP_HTTPMETHOD_POST = 4
1942 };
1943 
1944 typedef enum Upnp_HttpMethod_e Upnp_HttpMethod;
1945 
1974  const char *url,
1976  char **outBuf,
1979  char *contentType);
1980 
2013  const char *url,
2015  void **handle,
2017  char **contentType,
2019  int *contentLength,
2021  int *httpStatus,
2026  int timeout);
2027 
2060  const char *url,
2062  const char *proxy_str,
2064  void **handle,
2066  char **contentType,
2068  int *contentLength,
2070  int *httpStatus,
2075  int timeout);
2076 
2109  const char *url,
2111  void **handle,
2113  char **contentType,
2115  int *contentLength,
2118  int *httpStatus,
2121  int lowRange,
2124  int highRange,
2128  int timeout);
2129 
2149  void *handle,
2151  char *buf,
2153  size_t *size,
2158  int timeout);
2159 
2170  void *handle,
2172  size_t *length,
2174  size_t *total);
2175 
2186  void *handle);
2187 
2199  void *handle);
2200 
2228  const char *url,
2232  void **handle,
2235  const char *contentType,
2237  int contentLength,
2241  int timeout);
2242 
2259  void *handle,
2261  char *buf,
2263  size_t *size,
2267  int timeout);
2268 
2285  void *handle,
2288  int *httpStatus,
2292  int timeout);
2293 
2320  const char *url,
2324  void **handle,
2328  int timeout);
2329 
2356  /* ![in] The method to use to make the request. */
2357  Upnp_HttpMethod method,
2361  const char *url,
2363  void *handle,
2368  UpnpString *headers,
2370  const char *contentType,
2375  int contentLength,
2379  int timeout);
2380 
2398  void *handle,
2400  char *buf,
2402  size_t *size,
2406  int timeout);
2407 
2428  void *handle,
2432  int timeout);
2433 
2465  void *handle,
2468  UpnpString *headers,
2470  char **contentType,
2472  int *contentLength,
2474  int *httpStatus,
2479  int timeout);
2480 
2502  void *handle,
2504  char *buf,
2506  size_t *size,
2511  int timeout);
2512 
2528  void *handle);
2529 
2559  const char *url,
2561  IXML_Document **xmlDoc);
2562 
2565 /******************************************************************************
2566  ******************************************************************************
2567  * *
2568  * W E B S E R V E R A P I *
2569  * *
2570  ******************************************************************************
2571  ******************************************************************************/
2572 
2597  const char *rootDir);
2598 
2602 typedef void *UpnpWebFileHandle;
2603 
2607 typedef int (*VDCallback_GetInfo)(
2609  const char *filename,
2612  UpnpFileInfo *info,
2614  const void *cookie,
2616  const void **request_cookie);
2617 
2627  VDCallback_GetInfo callback);
2628 
2634  const char *filename,
2637  enum UpnpOpenFileMode Mode,
2639  const void *cookie,
2641  const void *request_cookie);
2642 
2652 
2656 typedef int (*VDCallback_Read)(
2658  UpnpWebFileHandle fileHnd,
2660  char *buf,
2662  size_t buflen,
2664  const void *cookie,
2666  const void *request_cookie);
2667 
2677 
2681 typedef int (*VDCallback_Write)(
2683  UpnpWebFileHandle fileHnd,
2685  char *buf,
2687  size_t buflen,
2689  const void *cookie,
2691  const void *request_cookie);
2692 
2702  VDCallback_Write callback);
2703 
2707 typedef int (*VDCallback_Seek)(
2709  UpnpWebFileHandle fileHnd,
2713  off_t offset,
2718  int origin,
2720  const void *cookie,
2722  const void *request_cookie);
2723 
2733 
2737 typedef int (*VDCallback_Close)(
2739  UpnpWebFileHandle fileHnd,
2741  const void *cookie,
2743  const void *request_cookie);
2744 
2754  VDCallback_Close callback);
2755 
2768  int enable);
2769 
2778 
2779 /*
2780  * \brief Callback for validating HTTP requests HOST header values.
2781  *
2782  * @param hostname the value in the request HOST header.
2783  * @return An integer representing one of the following:
2784  * \li \c UPNP_E_SUCCESS: a request with the HOST header set to hostname
2785  * should be processed.
2786  * \li \c UPNP_E_BAD_HTTPMSG the request should be rejected.
2787  */
2788 typedef int (*WebCallback_HostValidate)(const char *hostname, void *cookie);
2789 
2790 /*
2791  * \brief Set callback for validating HTTP requests HOST header values.
2792  *
2793  * @param callback the host validating callback function or NULL.
2794  * @param cookie the chocolate you like.
2795  */
2796 UPNP_EXPORT_SPEC void UpnpSetHostValidateCallback(
2797  WebCallback_HostValidate callback, void *cookie);
2798 
2799 /*
2800  * \brief Enable or disable literal IP redirection.
2801  *
2802  * @param enable Zero to disable (default) non-zero to enable.
2803  */
2804 UPNP_EXPORT_SPEC void UpnpSetAllowLiteralHostRedirection(int enable);
2805 
2819  const char *corsString);
2820 
2837  const char *dirName,
2839  const void *cookie,
2842  const void **oldcookie);
2843 
2853  const char *dirName);
2854 
2859 
2860 /* @} Web Server API */
2861 
2862 #ifdef __cplusplus
2863 }
2864 #endif /* __cplusplus */
2865 
2866 /* @} UPnPAPI UPnP API */
2867 
2868 #endif /* UPNP_H */
int UpnpDownloadXmlDoc(const char *url, IXML_Document **xmlDoc)
Downloads an XML document specified in a URL.
Definition: upnpapi.c:3550
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
int UpnpRegisterRootDevice3(const char *DescUrl, Upnp_FunPtr Callback, const void *Cookie, UpnpDevice_Handle *Hnd, int AddressFamily)
Registers a device application for a specific address family with the UPnP library.
Definition: upnpapi.c:1256
int UpnpRegisterRootDevice2(Upnp_DescType descriptionType, const char *description, size_t bufferLen, int config_baseURL, Upnp_FunPtr Fun, const void *Cookie, UpnpDevice_Handle *Hnd)
Registers a device application with the UPnP Library. Similar to UpnpRegisterRootDevice, except that it also allows the description document to be specified as a file or a memory buffer.
Definition: upnpapi.c:1084
int UpnpRegisterRootDevice(const char *DescUrl, Upnp_FunPtr Callback, const void *Cookie, UpnpDevice_Handle *Hnd)
Registers a device application with the UPnP Library.
Definition: upnpapi.c:891
int UpnpAcceptSubscription(UpnpDevice_Handle Hnd, const char *DevID, const char *ServID, const char **VarName, const char **NewVal, int cVariables, const Upnp_SID SubsId)
Accepts a subscription request and sends out the current state of the eventable variables for a servi...
Definition: upnpapi.c:2697
int UpnpSetWebServerRootDir(const char *rootDir)
Sets the document root directory for the internal web server.
Upnp_DescType_e
Specifies the type of description in UpnpRegisterRootDevice2.
Definition: upnp.h:483
int UpnpOpenHttpPost(const char *url, void **handle, const char *contentType, int contentLength, int timeout)
Makes an HTTP POST request message, opens a connection to the server and sends the POST request to th...
Definition: upnpapi.c:3346
Header file for UpnpActionRequest methods.
int UpnpSendActionExAsync(UpnpClient_Handle Hnd, const char *ActionURL, const char *ServiceType, const char *DevUDN, IXML_Document *Header, IXML_Document *Action, Upnp_FunPtr Fun, const void *Cookie)
Sends a message to change a state variable in a service, generating a callback when the operation is ...
Definition: upnpapi.c:3086
int UpnpVirtualDir_set_GetInfoCallback(VDCallback_GetInfo callback)
Sets the get_info callback function to be used to access a virtual directory.
Definition: upnpapi.c:4544
void UpnpRemoveAllVirtualDirs(void)
Removes all virtual directory mappings.
Definition: upnpapi.c:4472
int UpnpGetServiceVarStatusAsync(UpnpClient_Handle Hnd, const char *ActionURL, const char *VarName, Upnp_FunPtr Fun, const void *Cookie)
Queries the state of a variable of a service, generating a callback when the operation is complete...
Definition: upnpapi.c:3215
int UpnpRenewSubscription(UpnpClient_Handle Hnd, int *TimeOut, const Upnp_SID SubsId)
Renews a subscription that is about to expire.
Definition: upnpapi.c:2468
Header file for UpnpStateVarRequest methods.
int UpnpCloseHttpPost(void *handle, int *httpStatus, int timeout)
Sends and receives any pending data, closes the connection with the server, and frees memory allocate...
Definition: upnpapi.c:3370
UpnpWebFileHandle(* VDCallback_Open)(const char *filename, enum UpnpOpenFileMode Mode, const void *cookie, const void *request_cookie)
Open callback function prototype.
Definition: upnp.h:2632
Upnp_SType_e
Represents the different types of searches that can be performed using the SDK for UPnP Devices API...
Definition: upnp.h:458
int UpnpOpenHttpGetProxy(const char *url, const char *proxy_str, void **handle, char **contentType, int *contentLength, int *httpStatus, int timeout)
Gets a file specified in a URL through the specified proxy.
Definition: upnpapi.c:3412
int UpnpSendAdvertisementLowPower(UpnpDevice_Handle Hnd, int Exp, int PowerState, int SleepPeriod, int RegistrationState)
Sends out the discovery announcements for all devices and services for a device.
Definition: upnpapi.c:1930
unsigned short UpnpGetServerPort(void)
Returns the internal server IPv4 UPnP listening port.
Definition: upnpapi.c:760
int UpnpUnSubscribeAsync(UpnpClient_Handle Hnd, Upnp_SID SubsId, Upnp_FunPtr Fun, const void *Cookie)
Removes a subscription of a control point from a service previously subscribed to using UpnpSubscribe...
Definition: upnpapi.c:2393
int UpnpSetMaxSubscriptions(UpnpDevice_Handle Hnd, int MaxSubscriptions)
Sets the maximum number of subscriptions accepted per service.
Definition: upnpapi.c:2107
int UpnpRemoveVirtualDir(const char *dirName)
Removes a virtual directory mapping made with UpnpAddVirtualDir.
Definition: upnpapi.c:4425
int UpnpSubscribe(UpnpClient_Handle Hnd, const char *PublisherUrl, int *TimeOut, Upnp_SID SubsId)
Registers a control point to receive event notifications from another device.
Definition: upnpapi.c:2268
int UpnpUnRegisterRootDeviceLowPower(UpnpDevice_Handle Hnd, int PowerState, int SleepPeriod, int RegistrationState)
Unregisters a root device registered with UpnpRegisterRootDevice, UpnpRegisterRootDevice2, UpnpRegisterRootDevice3 or UpnpRegisterRootDevice4.
Definition: upnpapi.c:1461
int UpnpMakeHttpRequest(Upnp_HttpMethod method, const char *url, void *handle, UpnpString *headers, const char *contentType, int contentLength, int timeout)
Makes a HTTP request using a connection previously created by UpnpOpenHttpConnection.
Definition: upnpapi.c:3482
int UpnpCloseHttpGet(void *handle)
Closes the connection and frees memory that was allocated for the handle parameter.
Definition: upnpapi.c:3465
Definition: upnp.h:494
int UpnpRegisterRootDevice4(const char *DescUrl, Upnp_FunPtr Callback, const void *Cookie, UpnpDevice_Handle *Hnd, int AddressFamily, const char *LowerDescUrl)
Registers a device application for a specific address family with the UPnP library. This function can also be used to specify a dedicated description URL to be returned for legacy CPs.
Definition: upnpapi.c:1273
Definition: upnp.h:461
int UpnpReadHttpGet(void *handle, char *buf, size_t *size, int timeout)
Gets specified number of bytes from a file specified in a URL.
Definition: upnpapi.c:3467
int UpnpUnSubscribe(UpnpClient_Handle Hnd, const Upnp_SID SubsId)
Removes the subscription of a control point from a service previously subscribed to using UpnpSubscri...
Definition: upnpapi.c:2341
Definition: upnp.h:464
int UpnpVirtualDir_set_CloseCallback(VDCallback_Close callback)
Sets the close callback function to be used to access a virtual directory.
Definition: upnpapi.c:4604
unsigned short UpnpGetServerUlaGuaPort6(void)
Returns the internal server IPv6 ULA or GUA UPnP listening port.
Definition: upnpapi.c:780
Header file for UpnpDiscovery methods.
int UpnpSetContentLength(UpnpClient_Handle Hnd, size_t contentLength)
Definition: upnpapi.c:4616
int UpnpVirtualDir_set_OpenCallback(VDCallback_Open callback)
Sets the open callback function to be used to access a virtual directory.
Definition: upnpapi.c:4556
Definition: upnp.h:490
int UpnpOpenHttpGetEx(const char *url, void **handle, char **contentType, int *contentLength, int *httpStatus, int lowRange, int highRange, int timeout)
Gets specified number of bytes from a file specified in the URL.
Definition: upnpapi.c:3444
int(* VDCallback_Close)(UpnpWebFileHandle fileHnd, const void *cookie, const void *request_cookie)
Close callback function prototype.
Definition: upnp.h:2737
Header file for UpnpEventSubscribe methods.
int UpnpInit2(const char *IfName, unsigned short DestPort)
Initializes the Linux SDK for UPnP Devices (IPv4 or IPv6).
Definition: upnpapi.c:538
int UpnpUnRegisterRootDevice(UpnpDevice_Handle Hnd)
Unregisters a root device registered with UpnpRegisterRootDevice, UpnpRegisterRootDevice2, UpnpRegisterRootDevice3 or UpnpRegisterRootDevice4.
Definition: upnpapi.c:1451
Header file for UpnpSubscriptionRequest methods.
int UpnpSendAdvertisement(UpnpDevice_Handle Hnd, int Exp)
Sends out the discovery announcements for all devices and services for a device.
Definition: upnpapi.c:1920
int UpnpEndHttpRequest(void *handle, int timeout)
Indicates the end of a HTTP request previously made by UpnpMakeHttpRequest.
Definition: upnpapi.c:3504
Definition: upnp.h:472
int(* VDCallback_Read)(UpnpWebFileHandle fileHnd, char *buf, size_t buflen, const void *cookie, const void *request_cookie)
Read callback function prototype.
Definition: upnp.h:2656
Definition: upnp.h:486
int UpnpVirtualDir_set_SeekCallback(VDCallback_Seek callback)
Sets the seek callback function to be used to access a virtual directory.
Definition: upnpapi.c:4592
int UpnpIsWebserverEnabled(void)
Returns 1 if the webserver is enabled, or 0 if it is not.
Definition: upnpapi.c:4523
int UpnpVirtualDir_set_ReadCallback(VDCallback_Read callback)
Sets the read callback function to be used to access a virtual directory.
Definition: upnpapi.c:4568
int UpnpSendAction(UpnpClient_Handle Hnd, const char *ActionURL, const char *ServiceType, const char *DevUDN, IXML_Document *Action, IXML_Document **RespNode)
Sends a message to change a state variable in a service.
Definition: upnpapi.c:2872
Provides a platform independent way to include TCP/IP types and functions.
int UpnpAddVirtualDir(const char *dirName, const void *cookie, const void **oldcookie)
Adds a virtual directory mapping.
Definition: upnpapi.c:4356
int UpnpDownloadUrlItem(const char *url, char **outBuf, char *contentType)
Downloads a file specified in a URL.
Definition: upnpapi.c:3534
Header file for UpnpStateVarComplete methods.
int UpnpWriteHttpPost(void *handle, char *buf, size_t *size, int timeout)
Sends a request to a server to copy the contents of a buffer to the URI specified in the UpnpOpenHttp...
Definition: upnpapi.c:3365
int UpnpInitSslContext(int initOpenSslLib, const SSL_METHOD *sslMethod)
Initializes the OpenSSL library, and the OpenSSL context for use with pupnp.
int UpnpCancelHttpGet(void *handle)
Set the cancel flag of the handle parameter.
Definition: upnpapi.c:3463
int(* VDCallback_GetInfo)(const char *filename, UpnpFileInfo *info, const void *cookie, const void **request_cookie)
Get-info callback function prototype.
Definition: upnp.h:2607
int UpnpDevice_Handle
Returned when a device application registers with UpnpRegisterRootDevice, UpnpRegisterRootDevice2, UpnpRegisterRootDevice3 or UpnpRegisterRootDevice4.
Definition: upnp.h:439
int UpnpNotify(UpnpDevice_Handle, const char *DevID, const char *ServID, const char **VarName, const char **NewVal, int cVariables)
Sends out an event change notification to all control points subscribed to a particular service...
int UpnpGetHttpResponse(void *handle, UpnpString *headers, char **contentType, int *contentLength, int *httpStatus, int timeout)
Gets the response from the server using a connection previously created by UpnpOpenHttpConnection.
Definition: upnpapi.c:3509
int UpnpOpenHttpGet(const char *url, void **handle, char **contentType, int *contentLength, int *httpStatus, int timeout)
Gets a file specified in a URL.
Definition: upnpapi.c:3381
int UpnpSetMaxSubscriptionTimeOut(UpnpDevice_Handle Hnd, int MaxSubscriptionTimeOut)
Sets the maximum time-out accepted for a subscription request or renewal.
Definition: upnpapi.c:2147
unsigned short UpnpGetServerPort6(void)
Returns the internal server IPv6 link-local (LLA) UPnP listening port.
Definition: upnpapi.c:768
int UpnpHttpGetProgress(void *handle, size_t *length, size_t *total)
Retrieve progress information of a http-get transfer.
Definition: upnpapi.c:3472
int UpnpSendActionEx(UpnpClient_Handle Hnd, const char *ActionURL, const char *ServiceType, const char *DevUDN, IXML_Document *Header, IXML_Document *Action, IXML_Document **RespNode)
Sends a message to change a state variable in a service.
Definition: upnpapi.c:2929
int UpnpOpenHttpConnection(const char *url, void **handle, int timeout)
Opens a connection to the server.
Definition: upnpapi.c:3477
Header file for UpnpEvent methods.
Definition: UpnpFileInfo.c:18
int UpnpNotifyExt(UpnpDevice_Handle, const char *DevID, const char *ServID, IXML_Document *PropSet)
Similar to UpnpNotify except that it takes a DOM document for the event rather than an array of strin...
int UpnpVirtualDir_set_WriteCallback(VDCallback_Write callback)
Sets the write callback function to be used to access a virtual directory.
Definition: upnpapi.c:4580
int UpnpCloseHttpConnection(void *handle)
Closes the connection created with UpnpOpenHttpConnection and frees any memory associated with the co...
Definition: upnpapi.c:3529
#define DOMString
The type of DOM strings.
Definition: ixml.h:48
char * UpnpGetServerIpAddress(void)
Returns the local IPv4 listening ip address.
Definition: upnpapi.c:792
char * UpnpGetServerIp6Address(void)
Returns the IPv6 link-local listening ip address.
Definition: upnpapi.c:800
Definition: upnp.h:468
int UpnpSetWebServerCorsString(const char *corsString)
Assign the Access-Control-Allow-Origin specfied by the input const char* cors_string parameterto the ...
void * UpnpWebFileHandle
The type of handle returned by the web server for open requests.
Definition: upnp.h:2602
#define UPNP_EXPORT_SPEC
Export functions on WIN32 DLLs.
Definition: UpnpGlobal.h:105
int UpnpUnRegisterClient(UpnpClient_Handle Hnd)
Unregisters a control point application, unsubscribing all active subscriptions.
Definition: upnpapi.c:1605
Data structure representing the DOM Document.
Definition: ixml.h:159
int UpnpSendActionAsync(UpnpClient_Handle Hnd, const char *ActionURL, const char *ServiceType, const char *DevUDN, IXML_Document *Action, Upnp_FunPtr Fun, const void *Cookie)
Sends a message to change a state variable in a service, generating a callback when the operation is ...
Definition: upnpapi.c:2987
int UpnpSubscribeAsync(UpnpClient_Handle Hnd, const char *PublisherUrl, int TimeOut, Upnp_FunPtr Fun, const void *Cookie)
Performs the same operation as UpnpSubscribe, but returns immediately and calls the registered callba...
Definition: upnpapi.c:2191
Header file for UpnpFileInfo methods.
struct s_UpnpString UpnpString
Type of the string objects inside libupnp.
Definition: UpnpString.h:33
Upnp_HttpMethod_e
Different HTTP methods.
Definition: upnp.h:1935
char Upnp_SID[44]
Holds the subscription identifier for a subscription between a client and a device.
Definition: upnp.h:448
int UpnpFinish(void)
Terminates the Linux SDK for UPnP Devices.
Definition: upnpapi.c:669
int(* VDCallback_Seek)(UpnpWebFileHandle fileHnd, off_t offset, int origin, const void *cookie, const void *request_cookie)
Seek callback function prototype.
Definition: upnp.h:2707
int UpnpRenewSubscriptionAsync(UpnpClient_Handle Hnd, int TimeOut, Upnp_SID SubsId, Upnp_FunPtr Fun, const void *Cookie)
Renews a subscription that is about to expire, generating a callback when the operation is complete...
Definition: upnpapi.c:2529
int(* VDCallback_Write)(UpnpWebFileHandle fileHnd, char *buf, size_t buflen, const void *cookie, const void *request_cookie)
Write callback function prototype.
Definition: upnp.h:2681
int UpnpWriteHttpRequest(void *handle, char *buf, size_t *size, int timeout)
Writes the content of a HTTP request initiated by a UpnpMakeHttpRequest call. The end of the content ...
Definition: upnpapi.c:3499
int UpnpSearchAsync(UpnpClient_Handle Hnd, int Mx, const char *TTarget_constarget_const, const void *Cookie_const)
Searches for devices matching the given search target.
Definition: upnpapi.c:2051
int UpnpAcceptSubscriptionExt(UpnpDevice_Handle Hnd, const char *DevID, const char *ServID, IXML_Document *PropSet, const Upnp_SID SubsId)
Similar to UpnpAcceptSubscription() except that it takes a DOM document for the variables to event ra...
Definition: upnpapi.c:2782
int UpnpReadHttpResponse(void *handle, char *buf, size_t *size, int timeout)
Reads the content of a response using a connection previously created by UpnpOpenHttpConnection.
Definition: upnpapi.c:3524
int UpnpSetMaxContentLength(size_t contentLength)
Sets the maximum content-length that the SDK will process on an incoming SOAP requests or responses...
Definition: upnpapi.c:4647
int UpnpEnableWebserver(int enable)
Enables or disables the webserver.
Definition: upnpapi.c:4493
Defines constants that for some reason are not defined on some systems.
int UpnpRegisterClient(Upnp_FunPtr Callback, const void *Cookie, UpnpClient_Handle *Hnd)
Registers a control point application with the UPnP Library.
Definition: upnpapi.c:1549
char * UpnpGetServerUlaGuaIp6Address(void)
Returns the IPv6 unique-local or globally-unique listening ip address.
Definition: upnpapi.c:812
int UpnpGetServiceVarStatus(UpnpClient_Handle Hnd, const char *ActionURL, const char *VarName, DOMString *StVarVal)
Queries the state of a state variable of a service on another device.
Definition: upnpapi.c:3287
Header file for UpnpActionComplete methods.