libUPnP  1.6.26
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 "ixml.h"
45 #include "upnpconfig.h"
46 #include "UpnpGlobal.h"
47 #include "UpnpInet.h"
48 #include "UpnpString.h"
49 
50 /*
51  * \todo Document the exact reason of these include files and solve this
52  * include mess in an include file like UpnpTime.h
53  */
54 #ifdef WIN32
55  #include <time.h>
56  #ifdef UPNP_USE_MSVCPP
57  #include <sys/types.h> /* needed for off_t */
58  #endif
59 #elif (defined(BSD) && BSD >= 199306)
60  #include <time.h>
61 #else
62  /* Other systems ??? */
63 #endif
64 
65 #define LINE_SIZE (size_t)180
66 #define NAME_SIZE (size_t)256
67 #define MNFT_NAME_SIZE 64
68 #define MODL_NAME_SIZE 32
69 #define SERL_NUMR_SIZE 64
70 #define MODL_DESC_SIZE 64
71 #define UPNP_INFINITE -1
72 #define UPNP_USING_CHUNKED -3
73 #define UPNP_UNTIL_CLOSE -4
74 
94 #define UPNP_E_SUCCESS 0
95 
99 #define UPNP_E_INVALID_HANDLE -100
100 
107 #define UPNP_E_INVALID_PARAM -101
108 
114 #define UPNP_E_OUTOF_HANDLE -102
115 
116 #define UPNP_E_OUTOF_CONTEXT -103
117 
123 #define UPNP_E_OUTOF_MEMORY -104
124 
131 #define UPNP_E_INIT -105
132 
133 #define UPNP_E_BUFFER_TOO_SMALL -106
134 
140 #define UPNP_E_INVALID_DESC -107
141 
149 #define UPNP_E_INVALID_URL -108
150 
151 #define UPNP_E_INVALID_SID -109
152 
153 #define UPNP_E_INVALID_DEVICE -110
154 
161 #define UPNP_E_INVALID_SERVICE -111
162 
169 #define UPNP_E_BAD_RESPONSE -113
170 
171 #define UPNP_E_BAD_REQUEST -114
172 
179 #define UPNP_E_INVALID_ACTION -115
180 
186 #define UPNP_E_FINISH -116
187 
193 #define UPNP_E_INIT_FAILED -117
194 
200 #define UPNP_E_URL_TOO_BIG -118
201 
211 #define UPNP_E_BAD_HTTPMSG -119
212 
219 #define UPNP_E_ALREADY_REGISTERED -120
220 
225 #define UPNP_E_INVALID_INTERFACE -121
226 
234 #define UPNP_E_NETWORK_ERROR -200
235 
244 #define UPNP_E_SOCKET_WRITE -201
245 
254 #define UPNP_E_SOCKET_READ -202
255 
264 #define UPNP_E_SOCKET_BIND -203
265 
274 #define UPNP_E_SOCKET_CONNECT -204
275 
284 #define UPNP_E_OUTOF_SOCKET -205
285 
292 #define UPNP_E_LISTEN -206
293 
300 #define UPNP_E_TIMEDOUT -207
301 
308 #define UPNP_E_SOCKET_ERROR -208
309 
310 #define UPNP_E_FILE_WRITE_ERROR -209
311 
316 #define UPNP_E_CANCELED -210
317 
318 #define UPNP_E_EVENT_PROTOCOL -300
319 
323 #define UPNP_E_SUBSCRIBE_UNACCEPTED -301
324 
328 #define UPNP_E_UNSUBSCRIBE_UNACCEPTED -302
329 
333 #define UPNP_E_NOTIFY_UNACCEPTED -303
334 
341 #define UPNP_E_INVALID_ARGUMENT -501
342 
347 #define UPNP_E_FILE_NOT_FOUND -502
348 
352 #define UPNP_E_FILE_READ_ERROR -503
353 
358 #define UPNP_E_EXT_NOT_XML -504
359 
360 #define UPNP_E_NO_WEB_SERVER -505
361 #define UPNP_E_OUTOF_BOUNDS -506
362 
367 #define UPNP_E_NOT_FOUND -507
368 
373 #define UPNP_E_INTERNAL_ERROR -911
374 
375 /* SOAP-related error codes */
376 #define UPNP_SOAP_E_INVALID_ACTION 401
377 #define UPNP_SOAP_E_INVALID_ARGS 402
378 #define UPNP_SOAP_E_OUT_OF_SYNC 403
379 #define UPNP_SOAP_E_INVALID_VAR 404
380 #define UPNP_SOAP_E_ACTION_FAILED 501
381 
382 /* @} ErrorCodes */
383 
384 
391 enum UpnpOpenFileMode
392 {
393  UPNP_READ,
394  UPNP_WRITE
395 };
396 
404 typedef int UpnpClient_Handle;
405 
414 typedef int UpnpDevice_Handle;
415 
424  /*
425  * Control callbacks
426  */
427 
433 
438 
444 
449 
450  /*
451  * Discovery callbacks
452  */
453 
459 
465 
471 
476 
477  /*
478  * Eventing callbacks
479  */
480 
491 
496 
501 
506 
511 
517 
523 };
524 
525 typedef enum Upnp_EventType_e Upnp_EventType;
526 
534 typedef char Upnp_SID[44];
535 
547 
550 
553 
557 };
558 
559 typedef enum Upnp_SType_e Upnp_SType;
560 
570 
574 
578 };
579 
580 typedef enum Upnp_DescType_e Upnp_DescType;
581 
585 {
587  int ErrCode;
588 
590  int Socket;
591 
593  char ErrStr[LINE_SIZE];
594 
596  char ActionName[NAME_SIZE];
597 
599  char DevUDN[NAME_SIZE];
600 
602  char ServiceID[NAME_SIZE];
603 
606 
609 
611  struct sockaddr_storage CtrlPtIPAddr;
612 
616 };
617 
618 /* compat code for libupnp-1.8 */
620 #define UpnpActionRequest_get_ErrCode(x) ((x)->ErrCode)
621 #define UpnpActionRequest_set_ErrCode(x, v) ((x)->ErrCode = (v))
622 #define UpnpActionRequest_get_Socket(x) ((x)->Socket)
623 #define UpnpActionRequest_get_ErrStr_cstr(x) ((x)->ErrStr)
624 #define UpnpActionRequest_set_ErrStr(x, v) (strncpy((x)->ErrStr, UpnpString_get_String((v)), LINE_SIZE))
625 #define UpnpActionRequest_get_ActionName_cstr(x) ((x)->ActionName)
626 #define UpnpActionRequest_get_DevUDN_cstr(x) ((x)->DevUDN)
627 #define UpnpActionRequest_get_ServiceID_cstr(x) ((x)->ServiceID)
628 #define UpnpActionRequest_get_ActionRequest(x) ((x)->ActionRequest)
629 #define UpnpActionRequest_set_ActionRequest(x, v) ((x)->ActionRequest = (v))
630 #define UpnpActionRequest_get_ActionResult(x) ((x)->ActionResult)
631 #define UpnpActionRequest_set_ActionResult(x, v) ((x)->ActionResult = (v))
632 
634 {
636  int ErrCode;
637 
640 
643 
646 
647 };
648 
649 /* compat code for libupnp-1.8 */
651 #define UpnpActionComplete_get_ErrCode(x) ((x)->ErrCode)
652 #define UpnpActionComplete_get_CtrlUrl_cstr(x) (UpnpString_get_String((x)->CtrlUrl))
653 #define UpnpActionComplete_get_ActionRequest(x) ((x)->ActionRequest)
654 #define UpnpActionComplete_get_ActionResult(x) ((x)->ActionResult)
655 
660 {
662  int ErrCode;
663 
665  int Socket;
666 
668  char ErrStr[LINE_SIZE];
669 
671  char DevUDN[NAME_SIZE];
672 
674  char ServiceID[NAME_SIZE];
675 
677  char StateVarName[NAME_SIZE];
678 
680  struct sockaddr_storage CtrlPtIPAddr;
681 
685 };
686 
687 /* compat code for libupnp-1.8 */
689 #define UpnpStateVarRequest_get_ErrCode(x) ((x)->ErrCode)
690 #define UpnpStateVarRequest_set_ErrCode(x, v) ((x)->ErrCode = (v))
691 #define UpnpStateVarRequest_get_Socket(x) ((x)->Socket)
692 #define UpnpStateVarRequest_get_ErrStr_cstr(x) ((x)->ErrStr)
693 #define UpnpStateVarRequest_get_DevUDN_cstr(x) ((x)->DevUDN)
694 #define UpnpStateVarRequest_get_ServiceID_cstr(x) ((x)->ServiceID)
695 #define UpnpStateVarRequest_get_StateVarName_cstr(x) ((x)->StateVarName)
696 #define UpnpStateVarRequest_get_CurrentVal(x) ((x)->CurrentVal)
697 #define UpnpStateVarRequest_set_CurrentVal(x, v) ((x)->CurrentVal = (v))
698 
703 {
705  int ErrCode;
706 
709 
711  char StateVarName[NAME_SIZE];
712 
715 };
716 
717 /* compat code for libupnp-1.8 */
719 #define UpnpStateVarComplete_get_ErrCode(x) ((x)->ErrCode)
720 #define UpnpStateVarComplete_get_CtrlUrl_cstr(x) (UpnpString_get_String((x)->CtrlUrl))
721 #define UpnpStateVarComplete_get_StateVarName_cstr(x) ((x)->StateVarName)
722 
726 {
729 
731  int EventKey;
732 
735 
736 };
737 
738 /* compat code for libupnp-1.8 */
739 typedef struct Upnp_Event UpnpEvent;
740 #define UpnpEvent_get_SID_cstr(x) ((x)->Sid)
741 #define UpnpEvent_get_EventKey(x) ((x)->EventKey)
742 #define UpnpEvent_get_ChangedVariables(x) ((x)->ChangedVariables)
743 
744 /*
745  * This typedef is required by Doc++ to parse the last entry of the
746  * Upnp_Discovery structure correctly.
747  */
748 
749 
752 {
754  int ErrCode;
755 
757  int Expires;
758 
760  char DeviceId[LINE_SIZE];
761 
763  char DeviceType[LINE_SIZE];
764 
766  char ServiceType[LINE_SIZE];
767 
769  char ServiceVer[LINE_SIZE];
770 
772  char Location[LINE_SIZE];
773 
775  char Os[LINE_SIZE];
776 
778  char Date[LINE_SIZE];
779 
781  char Ext[LINE_SIZE];
782 
784  struct sockaddr_storage DestAddr;
785 };
786 
787 /* compat code for libupnp-1.8 */
788 typedef struct Upnp_Discovery UpnpDiscovery;
789 #define UpnpDiscovery_get_ErrCode(x) ((x)->ErrCode)
790 #define UpnpDiscovery_get_Expires(x) ((x)->Expires)
791 #define UpnpDiscovery_get_DeviceID_cstr(x) ((x)->DeviceId)
792 #define UpnpDiscovery_get_DeviceType_cstr(x) ((x)->DeviceType)
793 #define UpnpDiscovery_get_ServiceType_cstr(x) ((x)->ServiceType)
794 #define UpnpDiscovery_get_ServiceVer_cstr(x) ((x)->ServiceVer)
795 #define UpnpDiscovery_get_Location_cstr(x) ((x)->Location)
796 #define UpnpDiscovery_get_Os_cstr(x) ((x)->Os)
797 #define UpnpDiscovery_get_Date_cstr(x) ((x)->Date)
798 #define UpnpDiscovery_get_Ext_cstr(x) ((x)->Ext)
799 
804 
812 
814  int ErrCode;
815 
818 
820  int TimeOut;
821 
822 };
823 
824 /* compat code for libupnp-1.8 */
826 #define UpnpEventSubscribe_get_SID_cstr(x) ((x)->Sid)
827 #define UpnpEventSubscribe_get_ErrCode(x) ((x)->ErrCode)
828 #define UpnpEventSubscribe_get_PublisherUrl_cstr(x) (UpnpString_get_String((x)->PublisherUrl))
829 #define UpnpEventSubscribe_get_TimeOut(x) ((x)->TimeOut)
830 
835 {
837  char *ServiceId;
838 
840  char *UDN;
841 
844 };
845 
846 /* compat code for libupnp-1.8 */
848 #define UpnpSubscriptionRequest_get_ServiceId_cstr(x) ((x)->ServiceId)
849 #define UpnpSubscriptionRequest_get_UDN_cstr(x) ((x)->UDN)
850 #define UpnpSubscriptionRequest_get_SID_cstr(x) ((x)->Sid)
851 
853 {
857  char *name;
858  char *value;
859  DOMString resp;
860 };
861 
862 struct File_Info
863 {
867  off_t file_length;
868 
872 
876 
880 
885 
890 };
891 
892 /* compat code for libupnp-1.8 */
893 typedef struct File_Info UpnpFileInfo;
894 #define UpnpFileInfo_get_FileLength(x) ((x)->file_length)
895 #define UpnpFileInfo_set_FileLength(x, v) ((x)->file_length = (v))
896 #define UpnpFileInfo_get_LastModified(x) ((x)->last_modified)
897 #define UpnpFileInfo_set_LastModified(x, v) ((x)->last_modified = (v))
898 #define UpnpFileInfo_get_IsDirectory(x) ((x)->is_directory)
899 #define UpnpFileInfo_set_IsDirectory(x, v) ((x)->is_directory = (v))
900 #define UpnpFileInfo_get_IsReadable(x) ((x)->is_readable)
901 #define UpnpFileInfo_set_IsReadable(x, v) ((x)->is_readable = (v))
902 #define UpnpFileInfo_get_ContentType(x) ((x)->content_type)
903 #define UpnpFileInfo_set_ContentType(x, v) ((x)->content_type = (v))
904 
930 typedef int (*Upnp_FunPtr)(
932  Upnp_EventType EventType,
934  void *Event,
936  void *Cookie);
937 
938 /* @} Constants and Types */
939 
940 #ifdef __cplusplus
941 extern "C" {
942 #endif /* __cplusplus */
943 
986  const char *HostIP,
989  unsigned short DestPort);
990 
1023 #ifdef UPNP_ENABLE_IPV6
1024 EXPORT_SPEC int UpnpInit2(
1028  const char *IfName,
1031  unsigned short DestPort);
1032 #endif
1033 
1053 EXPORT_SPEC int UpnpFinish(void);
1054 
1066 EXPORT_SPEC unsigned short UpnpGetServerPort(void);
1067 
1079 #ifdef UPNP_ENABLE_IPV6
1080 EXPORT_SPEC unsigned short UpnpGetServerPort6(void);
1081 #endif
1082 
1094 
1106 #ifdef UPNP_ENABLE_IPV6
1108 
1109 EXPORT_SPEC char *UpnpGetServerUlaGuaIp6Address(void);
1110 #endif
1111 
1150  const char *DescUrl,
1152  Upnp_FunPtr Callback,
1154  const void *Cookie,
1156  UpnpDevice_Handle *Hnd);
1157 
1228  Upnp_DescType descriptionType,
1231  const char* description,
1234  size_t bufferLen,
1237  int config_baseURL,
1239  Upnp_FunPtr Fun,
1242  const void* Cookie,
1244  UpnpDevice_Handle* Hnd);
1245 
1284  const char *DescUrl,
1286  Upnp_FunPtr Callback,
1288  const void *Cookie,
1290  UpnpDevice_Handle *Hnd,
1293  int AddressFamily);
1294 
1334  const char *DescUrl,
1336  Upnp_FunPtr Callback,
1338  const void *Cookie,
1340  UpnpDevice_Handle *Hnd,
1343  int AddressFamily,
1346  const char *LowerDescUrl);
1347 
1366  UpnpDevice_Handle Hnd);
1367 
1389  UpnpDevice_Handle Hnd,
1391  int PowerState,
1393  int SleepPeriod,
1395  int RegistrationState);
1396 
1417  Upnp_FunPtr Callback,
1419  const void *Cookie,
1421  UpnpClient_Handle *Hnd);
1422 
1441  UpnpClient_Handle Hnd);
1442 
1452  UpnpClient_Handle Hnd,
1454  size_t contentLength);
1455 
1475  size_t contentLength);
1476 
1477 /* @} Initialization and Registration */
1478 
1479 /******************************************************************************
1480  ******************************************************************************
1481  * *
1482  * D I S C O V E R Y *
1483  * *
1484  ******************************************************************************
1485  ******************************************************************************/
1486 
1518  UpnpClient_Handle Hnd,
1523  int Mx,
1526  const char *TTarget_constarget_const,
1528  const void *Cookie_const);
1529 
1547  UpnpDevice_Handle Hnd,
1553  int Exp);
1554 
1575  UpnpDevice_Handle Hnd,
1581  int Exp,
1583  int PowerState,
1585  int SleepPeriod,
1587  int RegistrationState);
1588 
1589 /* @} Discovery */
1590 
1591 /******************************************************************************
1592  ******************************************************************************
1593  * *
1594  * C O N T R O L *
1595  * *
1596  ******************************************************************************
1597  ******************************************************************************/
1598 
1632  UpnpClient_Handle Hnd,
1634  const char *ActionURL,
1636  const char *VarName,
1640  DOMString *StVarVal);
1641 
1661  UpnpClient_Handle Hnd,
1663  const char *ActionURL,
1665  const char *VarName,
1668  Upnp_FunPtr Fun,
1670  const void *Cookie);
1671 
1697  UpnpClient_Handle Hnd,
1699  const char *ActionURL,
1701  const char *ServiceType,
1703  const char *DevUDN,
1705  IXML_Document *Action,
1708  IXML_Document **RespNode);
1709 
1735  UpnpClient_Handle Hnd,
1737  const char *ActionURL,
1739  const char *ServiceType,
1741  const char *DevUDN,
1744  IXML_Document *Header,
1746  IXML_Document *Action,
1749  IXML_Document **RespNode);
1750 
1774  UpnpClient_Handle Hnd,
1776  const char *ActionURL,
1778  const char *ServiceType,
1780  const char *DevUDN,
1782  IXML_Document *Action,
1785  Upnp_FunPtr Fun,
1788  const void *Cookie);
1789 
1813  UpnpClient_Handle Hnd,
1815  const char *ActionURL,
1817  const char *ServiceType,
1819  const char *DevUDN,
1822  IXML_Document *Header,
1824  IXML_Document *Action,
1827  Upnp_FunPtr Fun,
1830  const void *Cookie);
1831 
1834 /******************************************************************************
1835  ******************************************************************************
1836  * *
1837  * E V E N T I N G *
1838  * *
1839  ******************************************************************************
1840  ******************************************************************************/
1841 
1875  UpnpDevice_Handle Hnd,
1877  const char *DevID,
1879  const char *ServID,
1881  const char **VarName,
1883  const char **NewVal,
1885  int cVariables,
1887  const Upnp_SID SubsId);
1888 
1913  UpnpDevice_Handle Hnd,
1915  const char *DevID,
1917  const char *ServID,
1921  IXML_Document *PropSet,
1923  Upnp_SID SubsId);
1924 
1950  const char *DevID,
1952  const char *ServID,
1954  const char **VarName,
1956  const char **NewVal,
1958  int cVariables);
1959 
1985  const char *DevID,
1987  const char *ServID,
1991  IXML_Document *PropSet);
1992 
2023  UpnpClient_Handle Hnd,
2026  int *TimeOut,
2028  const Upnp_SID SubsId);
2029 
2079  UpnpClient_Handle Hnd,
2082  int TimeOut,
2084  Upnp_SID SubsId,
2087  Upnp_FunPtr Fun,
2089  const void *Cookie);
2090 
2107  UpnpDevice_Handle Hnd,
2109  int MaxSubscriptions);
2110 
2128  UpnpDevice_Handle Hnd,
2130  int MaxSubscriptionTimeOut);
2131 
2163  UpnpClient_Handle Hnd,
2165  const char *PublisherUrl,
2169  int *TimeOut,
2171  Upnp_SID SubsId);
2172 
2223  UpnpClient_Handle Hnd,
2225  const char *PublisherUrl,
2228  int TimeOut,
2230  Upnp_FunPtr Fun,
2232  const void *Cookie);
2233 
2265  UpnpClient_Handle Hnd,
2267  const Upnp_SID SubsId);
2268 
2317  UpnpClient_Handle Hnd,
2319  Upnp_SID SubsId,
2322  Upnp_FunPtr Fun,
2324  const void *Cookie);
2325 
2329 /******************************************************************************
2330  ******************************************************************************
2331  * *
2332  * C L I E N T - A P I *
2333  * *
2334  ******************************************************************************
2335  ******************************************************************************/
2336 
2371  const char *url,
2373  char **outBuf,
2376  char *contentType);
2377 
2408  const char *url,
2410  void **handle,
2412  char **contentType,
2414  int *contentLength,
2416  int *httpStatus,
2420  int timeout);
2421 
2452  const char *url,
2454  const char *proxy_str,
2456  void **handle,
2458  char **contentType,
2460  int *contentLength,
2462  int *httpStatus,
2466  int timeout);
2467 
2500  const char *url,
2502  void **handle,
2504  char **contentType,
2506  int *contentLength,
2508  int *httpStatus,
2510  int lowRange,
2512  int highRange,
2516  int timeout);
2517 
2537  void *handle,
2539  char *buf,
2541  size_t *size,
2545  int timeout);
2546 
2557  void *handle,
2559  size_t *length,
2561  size_t *total);
2562 
2573  void *handle);
2574 
2586  void *handle);
2587 
2615  const char *url,
2618  void **handle,
2620  const char *contentType,
2622  int contentLength,
2625  int timeout);
2626 
2643  void *handle,
2645  char *buf,
2647  size_t *size,
2650  int timeout);
2651 
2668  void *handle,
2670  int *httpStatus,
2673  int timeout);
2674 
2704  const char *url,
2706  IXML_Document **xmlDoc);
2707 
2710 /******************************************************************************
2711  ******************************************************************************
2712  * *
2713  * W E B S E R V E R A P I *
2714  * *
2715  ******************************************************************************
2716  ******************************************************************************/
2717 
2742  const char *rootDir);
2743 
2747 typedef void *UpnpWebFileHandle;
2748 
2752 typedef int (*VDCallback_GetInfo)(
2754  const char *filename,
2756  struct File_Info *info);
2757 
2767 
2773  const char *filename,
2776  enum UpnpOpenFileMode Mode);
2777 
2787 
2791 typedef int (*VDCallback_Read)(
2793  UpnpWebFileHandle fileHnd,
2795  char *buf,
2797  size_t buflen);
2798 
2808 
2812 typedef int (*VDCallback_Write)(
2814  UpnpWebFileHandle fileHnd,
2816  char *buf,
2818  size_t buflen);
2819 
2829 
2833 typedef int (*VDCallback_Seek) (
2835  UpnpWebFileHandle fileHnd,
2839  off_t offset,
2844  int origin);
2845 
2855 
2859 typedef int (*VDCallback_Close)(
2861  UpnpWebFileHandle fileHnd);
2862 
2872 
2879 {
2880  VDCallback_GetInfo get_info;
2881  VDCallback_Open open;
2882  VDCallback_Read read;
2883  VDCallback_Write write;
2884  VDCallback_Seek seek;
2885  VDCallback_Close close;
2886 };
2887 
2897  int enable);
2898 
2907 
2917  struct UpnpVirtualDirCallbacks *callbacks );
2918 
2935  const char *dirName);
2936 
2946  const char *dirName);
2947 
2952 
2953 /* @} Web Server API */
2954 
2955 #ifdef __cplusplus
2956 }
2957 #endif /* __cplusplus */
2958 
2959 /* @} UPnPAPI UPnP API */
2960 
2961 #endif /* UPNP_H */
int UpnpDownloadXmlDoc(const char *url, IXML_Document **xmlDoc)
Downloads an XML document specified in a URL.
Definition: upnpapi.c:3189
char * ServiceId
Definition: upnp.h:837
Definition: upnp.h:510
int UpnpClient_Handle
Returned when a control point application registers with UpnpRegisterClient.
Definition: upnp.h:404
IXML_Document * ActionResult
Definition: upnp.h:645
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:1099
char ActionName[(size_t) 256]
Definition: upnp.h:596
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:953
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:788
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:2455
int(* VDCallback_Seek)(UpnpWebFileHandle fileHnd, off_t offset, int origin)
Seek callback function prototype.
Definition: upnp.h:2833
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:567
Definition: upnp.h:522
Definition: upnp.h:751
The { UpnpVirtualDirCallbacks} structure contains the pointers to file-related callback functions a d...
Definition: upnp.h:2878
IXML_Document * ActionRequest
Definition: upnp.h:605
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:3073
char DevUDN[(size_t) 256]
Definition: upnp.h:599
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:2826
int ErrCode
Definition: upnp.h:814
int(* VDCallback_GetInfo)(const char *filename, struct File_Info *info)
Get-info callback function prototype.
Definition: upnp.h:2752
int UpnpVirtualDir_set_GetInfoCallback(VDCallback_GetInfo callback)
Sets the get_info callback function to be used to access a virtual directory.
Definition: upnpapi.c:4263
Definition: upnp.h:516
Definition: upnp.h:470
void UpnpRemoveAllVirtualDirs(void)
Removes all virtual directory mappings.
Definition: upnpapi.c:4173
UpnpWebFileHandle(* VDCallback_Open)(const char *filename, enum UpnpOpenFileMode Mode)
Open callback function prototype.
Definition: upnp.h:2771
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:2948
int UpnpRenewSubscription(UpnpClient_Handle Hnd, int *TimeOut, const Upnp_SID SubsId)
Renews a subscription that is about to expire.
Definition: upnpapi.c:2226
int(* VDCallback_Close)(UpnpWebFileHandle fileHnd)
Close callback function prototype.
Definition: upnp.h:2859
IXML_Document * ActionRequest
Definition: upnp.h:642
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:3095
int is_readable
Definition: upnp.h:879
Upnp_SType_e
Represents the different types of searches that can be performed using the SDK for UPnP Devices API...
Definition: upnp.h:544
int UpnpSetVirtualDirCallbacks(struct UpnpVirtualDirCallbacks *callbacks)
Sets the callback functions to be used to access a virtual directory.
Definition: upnpapi.c:4241
time_t last_modified
Definition: upnp.h:871
UpnpString object declaration.
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:3117
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:1696
int Socket
Definition: upnp.h:665
int UpnpAcceptSubscriptionExt(UpnpDevice_Handle Hnd, const char *DevID, const char *ServID, IXML_Document *PropSet, Upnp_SID SubsId)
Similar to UpnpAcceptSubscription() except that it takes a DOM document for the variables to event ra...
Definition: upnpapi.c:2534
Definition: upnp.h:475
unsigned short UpnpGetServerPort(void)
Returns the internal server IPv4 UPnP listening port.
Definition: upnpapi.c:694
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:2158
int UpnpSetMaxSubscriptions(UpnpDevice_Handle Hnd, int MaxSubscriptions)
Sets the maximum number of subscriptions accepted per service.
Definition: upnpapi.c:1865
struct Extra_Headers * extra_headers
Definition: upnp.h:889
int UpnpRemoveVirtualDir(const char *dirName)
Removes a virtual directory mapping made with UpnpAddVirtualDir.
Definition: upnpapi.c:4124
Definition: upnp.h:495
Definition: upnp.h:437
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:2039
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:1284
int UpnpCloseHttpGet(void *handle)
Closes the connection and frees memory that was allocated for the handle parameter.
Definition: upnpapi.c:3154
Definition: upnp.h:577
int(* VDCallback_Read)(UpnpWebFileHandle fileHnd, char *buf, size_t buflen)
Read callback function prototype.
Definition: upnp.h:2791
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:1115
char * UDN
Definition: upnp.h:840
Definition: upnp.h:546
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:3160
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:2110
Definition: upnp.h:549
int UpnpVirtualDir_set_CloseCallback(VDCallback_Close callback)
Sets the close callback function to be used to access a virtual directory.
Definition: upnpapi.c:4328
Definition: upnp.h:490
int UpnpSetContentLength(UpnpClient_Handle Hnd, size_t contentLength)
Definition: upnpapi.c:4340
int TimeOut
Definition: upnp.h:820
int UpnpVirtualDir_set_OpenCallback(VDCallback_Open callback)
Sets the open callback function to be used to access a virtual directory.
Definition: upnpapi.c:4276
Definition: upnp.h:573
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:3132
Definition: upnp.h:852
int UpnpInit2(const char *IfName, unsigned short DestPort)
Initializes the Linux SDK for UPnP Devices (IPv4 or IPv6).
Definition: upnp.h:803
int ErrCode
Definition: upnp.h:662
int UpnpUnRegisterRootDevice(UpnpDevice_Handle Hnd)
Unregisters a root device registered with UpnpRegisterRootDevice, UpnpRegisterRootDevice2, UpnpRegisterRootDevice3 or UpnpRegisterRootDevice4.
Definition: upnpapi.c:1277
DOMString content_type
Definition: upnp.h:884
int UpnpSendAdvertisement(UpnpDevice_Handle Hnd, int Exp)
Sends out the discovery announcements for all devices and services for a device.
Definition: upnpapi.c:1689
int ErrCode
Definition: upnp.h:754
int Expires
Definition: upnp.h:757
Definition: upnp.h:556
Definition: upnp.h:702
int(* Upnp_FunPtr)(Upnp_EventType EventType, void *Event, void *Cookie)
Definition: upnp.h:930
Definition: upnp.h:584
char ServiceID[(size_t) 256]
Definition: upnp.h:602
Upnp_EventType_e
The reason code for an event callback.
Definition: upnp.h:423
Definition: upnp.h:505
Definition: upnp.h:569
int UpnpVirtualDir_set_SeekCallback(VDCallback_Seek callback)
Sets the seek callback function to be used to access a virtual directory.
Definition: upnpapi.c:4315
int UpnpIsWebserverEnabled(void)
Returns TRUE if the webserver is enabled, or FALSE if it is not.
Definition: upnpapi.c:4232
Definition: upnp.h:834
int UpnpVirtualDir_set_ReadCallback(VDCallback_Read callback)
Sets the read callback function to be used to access a virtual directory.
Definition: upnpapi.c:4289
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:2619
Provides a platform independent way to include TCP/IP types and functions.
int UpnpDownloadUrlItem(const char *url, char **outBuf, char *contentType)
Downloads a file specified in a URL.
Definition: upnpapi.c:3172
struct sockaddr_storage CtrlPtIPAddr
Definition: upnp.h:611
Definition: upnp.h:443
Upnp_SID Sid
Definition: upnp.h:843
Definition: upnp.h:659
UpnpString * CtrlUrl
Definition: upnp.h:639
Upnp_SID Sid
Definition: upnp.h:728
int UpnpInit(const char *HostIP, unsigned short DestPort)
Initializes the Linux SDK for UPnP Devices (IPv4 only).
Definition: upnpapi.c:448
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:3085
UpnpString * PublisherUrl
Definition: upnp.h:817
IXML_Document * SoapHeader
Definition: upnp.h:615
int ErrCode
Definition: upnp.h:587
int UpnpCancelHttpGet(void *handle)
Set the cancel flag of the handle parameter.
Definition: upnpapi.c:3148
int is_directory
Definition: upnp.h:875
Upnp_SID Sid
Definition: upnp.h:811
Definition: upnp.h:862
int UpnpDevice_Handle
Returned when a device application registers with UpnpRegisterRootDevice, UpnpRegisterRootDevice2, UpnpRegisterRootDevice3 or UpnpRegisterRootDevice4.
Definition: upnp.h:414
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...
Definition: upnpapi.c:2354
DOMString CurrentVal
Definition: upnp.h:684
DOMString CurrentVal
Definition: upnp.h:714
Definition: upnp.h:725
Definition: upnp.h:448
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:3104
IXML_Document * ActionResult
Definition: upnp.h:608
int UpnpSetMaxSubscriptionTimeOut(UpnpDevice_Handle Hnd, int MaxSubscriptionTimeOut)
Sets the maximum time-out accepted for a subscription request or renewal.
Definition: upnpapi.c:1902
unsigned short UpnpGetServerPort6(void)
Returns the internal server IPv6 UPnP listening port.
int UpnpHttpGetProgress(void *handle, size_t *length, size_t *total)
Retrieve progress information of a http-get transfer.
Definition: upnpapi.c:3166
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:2675
int ErrCode
Definition: upnp.h:636
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...
Definition: upnpapi.c:2408
int ErrCode
Definition: upnp.h:705
int UpnpVirtualDir_set_WriteCallback(VDCallback_Write callback)
Sets the write callback function to be used to access a virtual directory.
Definition: upnpapi.c:4302
#define DOMString
The type of DOM strings.
Definition: ixml.h:59
char * UpnpGetServerIpAddress(void)
Returns the local IPv4 listening ip address.
Definition: upnpapi.c:712
char * UpnpGetServerIp6Address(void)
Returns the local IPv6 listening ip address.
Definition: upnpapi.c:720
Definition: upnp.h:552
Definition: upnp.h:432
void * UpnpWebFileHandle
The type of handle returned by the web server for open requests.
Definition: upnp.h:2747
off_t file_length
Definition: upnp.h:867
int UpnpUnRegisterClient(UpnpClient_Handle Hnd)
Unregisters a control point application, unsubscribing all active subscriptions.
Definition: upnpapi.c:1407
Data structure representing the DOM Document.
Definition: ixml.h:187
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:2731
int(* VDCallback_Write)(UpnpWebFileHandle fileHnd, char *buf, size_t buflen)
Write callback function prototype.
Definition: upnp.h:2812
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:1965
struct s_UpnpString UpnpString
Type of the string objects inside libupnp.
Definition: UpnpString.h:38
char Upnp_SID[44]
Holds the subscription identifier for a subscription between a client and a device.
Definition: upnp.h:534
int UpnpFinish(void)
Terminates the Linux SDK for UPnP Devices.
Definition: upnpapi.c:613
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:2282
UpnpString * CtrlUrl
Definition: upnp.h:708
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:1808
int EventKey
Definition: upnp.h:731
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:4371
Definition: upnp.h:500
int UpnpEnableWebserver(int enable)
Enables or disables the webserver.
Definition: upnpapi.c:4195
#define EXPORT_SPEC
Export functions on WIN32 DLLs.
Definition: UpnpGlobal.h:81
int Socket
Definition: upnp.h:590
char * name
Definition: upnp.h:857
IXML_Document * ChangedVariables
Definition: upnp.h:734
Definition: upnp.h:633
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:1359
int UpnpAddVirtualDir(const char *dirName)
Adds a virtual directory mapping.
Definition: upnpapi.c:4061
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:3017
char ErrStr[(size_t) 180]
Definition: upnp.h:593