45#include <httpreadwrite.hpp>
55#include <umock/iphlpapi.hpp>
57#include <umock/ifaddrs.hpp>
58#include <umock/net_if.hpp>
60#include <umock/stdio.hpp>
65#ifdef COMPA_HAVE_WEBSERVER
67#include <webserver.hpp>
123 std::string_view a_iface =
"")
125 TRACE(
"Executing compa::UpnpGetIfInfo()")
132 static_cast<unsigned int>(std::stoi(std::string(a_iface))))) {
133 UPnPsdk_LOGERR(
"MSG1033")
"Local network interface \""
134 << a_iface <<
"\" not found.\n";
155 switch (saObj.
ss.ss_family) {
160 (IN6_IS_ADDR_LINKLOCAL(&saObj.
sin6.sin6_addr) ||
161 IN6_IS_ADDR_LOOPBACK(&saObj.
sin6.sin6_addr))) {
166 if (
char* chptr{::strchr(
gIF_IPV6,
'%')})
169 else if (
char* chptr{::strchr(
gIF_IPV6,
']')})
177 if (
char* chptr{::strchr(
gIF_IPV6,
'%')})
197 UPnPsdk_LOGCRIT(
"MSG1029")
"Unsupported address family("
198 << saObj.
ss.ss_family <<
"), only AF_INET6(" << AF_INET6
199 <<
") or AF_INET(" << AF_INET <<
") are valid.\n";
207 }
catch (
const std::exception& ex) {
208 UPnPsdk_LOGCATCH(
"MSG1006")
"catched next line...\n" << ex.what();
222[[maybe_unused]]
int UpnpGetIfInfo(
224 const char* a_IFace) {
225 TRACE(
"Executing ::UpnpGetIfInfo()")
226 return compa::UpnpGetIfInfo(a_IFace ==
nullptr ?
"" : a_IFace);
233#if !defined(ifr_netmask) || defined(DOXYGEN_RUN)
236#define ifr_netmask ifr_addr
239#if !defined(IN6_IS_ADDR_ULA) || defined(DOXYGEN_RUN)
241#define IN6_IS_ADDR_ULA(a) \
242 ((((__const uint32_t*)(a))[0] & htonl((uint32_t)0xfe000000)) == \
243 htonl((uint32_t)0xfc000000))
369#ifdef COMPA_HAVE_OPTION_SSDP
388#ifdef COMPA_HAVE_DEVICE_SSDP
392static void free_advertise_arg(job_arg* arg) {
393 if (arg->advertise.Event) {
394 free(arg->advertise.Event);
400#ifdef COMPA_HAVE_CTRLPT_SOAP
431#ifdef COMPA_HAVE_OPTION_SSDP
436#ifdef COMPA_HAVE_CTRLPT_GENA
498 TRACE(
"Executing UpnpInitPreamble()")
502 srand((
unsigned int)time(NULL));
517#ifdef COMPA_HAVE_OPTION_SSDP
527 compa::HandleTable[i] =
nullptr;
537#ifdef COMPA_HAVE_DEVICE_SOAP
541#ifdef COMPA_HAVE_DEVICE_GENA
566 [[maybe_unused]] in_port_t DestPort) {
567 UPnPsdk_LOGINFO(
"MSG1061")
"Executing...\n";
570#ifdef COMPA_HAVE_MINISERVER
577 UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
578 "Miniserver failed to start\n");
590 UPnPsdk_LOGINFO(
"MSG1066")
"Finished.\n";
594int UpnpInit2(
const char* IfName,
unsigned short DestPort) {
595 UPnPsdk_LOGINFO(
"MSG1096")
"Executing...\n";
599 if (pthread_mutex_lock(&compa::sdkInit_mutex) != 0) {
621 retVal = compa::UpnpGetIfInfo(IfName ==
nullptr ?
"" : IfName);
636 pthread_mutex_unlock(&compa::sdkInit_mutex);
648 const char* DbgFileName,
655 UpnpPrintf(UPNP_INFO, API, DbgFileName, DbgLineNo,
657 "High Jobs pending: %d\n"
658 "Med Jobs Pending: %d\n"
659 "Low Jobs Pending: %d\n"
660 "Average wait in High Q in milliseconds: %lf\n"
661 "Average wait in Med Q in milliseconds: %lf\n"
662 "Average wait in Low Q in milliseconds: %lf\n"
663 "Max Threads Used: %d\n"
664 "Worker Threads: %d\n"
665 "Persistent Threads: %d\n"
667 "Total Threads: %d\n"
668 "Total Work Time: %lf\n"
669 "Total Idle Time: %lf\n",
670 msg, stats.currentJobsHQ, stats.currentJobsMQ,
671 stats.currentJobsLQ, stats.avgWaitHQ, stats.avgWaitMQ,
672 stats.avgWaitLQ, stats.maxThreads, stats.workerThreads,
673 stats.persistentThreads, stats.idleThreads, stats.totalThreads,
674 stats.totalWorkTime, stats.totalIdleTime);
679#define PrintThreadPoolStats(tp, DbgFileName, DbgLineNo, msg) \
685 TRACE(
"Executing UpnpFinish()")
686 UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
687 "Inside UpnpFinish: UpnpSdkInit is %d\n",
UpnpSdkInit);
688#ifdef COMPA_HAVE_DEVICE_SSDP
691#ifdef COMPA_HAVE_CTRLPT_SSDP
694 [[maybe_unused]]
struct Handle_Info* temp{
nullptr};
695#ifdef UPnPsdk_HAVE_OPENSSL
700 UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
701 "UpnpFinish: UpnpSdkInit is ONE\n");
709#ifdef COMPA_HAVE_DEVICE_SSDP
719#ifdef COMPA_HAVE_CTRLPT_SSDP
725#ifdef COMPA_HAVE_MINISERVER
728#ifdef COMPA_HAVE_WEBSERVER
733 "MiniServer Thread Pool");
740#ifdef COMPA_HAVE_CTRLPT_GENA
744#ifdef COMPA_HAVE_OPTION_SSDP
749 UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
750 "Exiting UpnpFinish: UpnpSdkInit is :%d:\n",
UpnpSdkInit);
764#ifdef UPNP_ENABLE_IPV6
775#ifdef UPNP_ENABLE_IPV6
793#ifdef UPNP_ENABLE_IPV6
804#ifdef UPNP_ENABLE_IPV6
821#if defined(COMPA_HAVE_DEVICE_SSDP) || defined(COMPA_HAVE_CTRLPT_SSDP)
826 while (i <
NUM_HANDLE && compa::HandleTable[i] !=
nullptr)
844 UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
845 "FreeHandle: entering, Handle is %d\n", Upnp_Handle);
846 if (Upnp_Handle < 1 || Upnp_Handle >=
NUM_HANDLE) {
847 UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
848 "FreeHandle: Handle %d is out of range\n", Upnp_Handle);
849 }
else if (compa::HandleTable[Upnp_Handle] ==
nullptr) {
850 UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
851 "FreeHandle: compa::HandleTable[%d] is nullptr\n",
854 free(compa::HandleTable[Upnp_Handle]);
855 compa::HandleTable[Upnp_Handle] =
nullptr;
859 "FreeHandle: exiting, ret = %d.\n", ret);
865#ifdef COMPA_HAVE_DEVICE_SSDP
871#ifdef COMPA_HAVE_DEVICE_GENA
872 int hasServiceTable{0};
877 "Inside UpnpRegisterRootDevice\n");
884 if (Hnd == NULL || Fun == NULL || DescUrl == NULL ||
885 strlen(DescUrl) == (
size_t)0) {
902 compa::HandleTable[*Hnd] = HInfo;
904 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Root device URL is %s\n",
908 HInfo->
HType = HND_DEVICE;
912 "Following Root Device URL will be used when answering to "
921#ifdef COMPA_HAVE_CTRLPT_SSDP
932 "UpnpRegisterRootDevice: error downloading Document: "
935#ifdef COMPA_HAVE_CTRLPT_SSDP
942 "UpnpRegisterRootDevice: Valid Description\n"
943 "UpnpRegisterRootDevice: DescURL : %s\n",
949#ifdef COMPA_HAVE_CTRLPT_SSDP
954 UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
955 "UpnpRegisterRootDevice: No devices found for "
964 UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
965 "UpnpRegisterRootDevice: No services found for "
969#ifdef COMPA_HAVE_DEVICE_GENA
974 "UpnpRegisterRootDevice: Gena Check\n");
978 if (hasServiceTable) {
980 "UpnpRegisterRootDevice: GENA Service Table\n"
981 "Here are the known services:\n");
985 "\nUpnpRegisterRootDevice: Empty service table\n");
995 "Exiting RegisterRootDevice, return value == %d\n", retVal);
1002#ifdef COMPA_HAVE_DEVICE_DESCRIPTION
1021 const char*
const description_const,
1022 const size_t bufferLen,
1024 const void*
const Cookie,
1028 char* description = (
char*)description_const;
1030#ifdef COMPA_HAVE_DEVICE_GENA
1031 int hasServiceTable{0};
1035 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1036 "Inside UpnpRegisterRootDevice2\n");
1043 if (Hnd == NULL || Fun == NULL) {
1055 if (HInfo == NULL) {
1060 compa::HandleTable[*Hnd] = HInfo;
1073#ifdef UPNPLIB_PUPNP_BUG
1083 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1084 "Following Root Device URL will be used when answering to "
1088 HInfo->
HType = HND_DEVICE;
1094#ifdef COMPA_HAVE_CTRLPT_SSDP
1102 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1103 "UpnpRegisterRootDevice2: Valid Description\n"
1104 "UpnpRegisterRootDevice2: DescURL : %s\n",
1110#ifdef COMPA_HAVE_CTRLPT_SSDP
1115 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1116 "UpnpRegisterRootDevice2: No devices found for "
1125 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1126 "UpnpRegisterRootDevice2: No services found for "
1130#ifdef COMPA_HAVE_DEVICE_GENA
1134 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1135 "UpnpRegisterRootDevice2: Gena Check\n");
1139 if (hasServiceTable) {
1140 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1141 "UpnpRegisterRootDevice2: GENA Service Table\n"
1142 "Here are the known services: \n");
1145 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1146 "\nUpnpRegisterRootDevice2: Empty service table\n");
1155 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1156 "Exiting RegisterRootDevice2, return value == %d\n", retVal);
1163#ifdef COMPA_HAVE_DEVICE_SSDP
1169 const void*
const Cookie,
1171 const int AddressFamily,
1172 const char*
const LowerDescUrl) {
1173 TRACE(
"Executing UpnpRegisterRootDevice3() (same as "
1174 "UpnpRegisterRootDevice4())")
1177#ifdef COMPA_HAVE_DEVICE_GENA
1178 int hasServiceTable{0};
1187 if (Hnd ==
nullptr || Fun ==
nullptr || DescUrl ==
nullptr ||
1188 strlen(DescUrl) == 0 ||
1189 (AddressFamily != AF_INET && AddressFamily != AF_INET6)) {
1201 if (HInfo ==
nullptr) {
1206 compa::HandleTable[*Hnd] = HInfo;
1208 HInfo->
HType = HND_DEVICE;
1211 if (LowerDescUrl ==
nullptr)
1217 "MSG1050")
"Following Root UDevice local URL will be used when "
1218 "responding to requests from control points: "
1221 HInfo->
Cookie = (
char*)Cookie;
1226#ifdef COMPA_HAVE_CTRLPT_SSDP
1237#ifdef COMPA_HAVE_CTRLPT_SSDP
1244 "MSG1051")
"UpnpRegisterRootDevice3(or 4): Valid Description\n"
1245 "UpnpRegisterRootDevice3(or 4): DescURL = "
1251#ifdef COMPA_HAVE_CTRLPT_SSDP
1256 UPnPsdk_LOGCRIT(
"MSG1052")
"UpnpRegisterRootDevice3(or 4): No devices "
1257 "found for RootDevice.\n";
1266 "MSG1054")
"UpnpRegisterRootDevice3(or 4): No services found for "
1270#ifdef COMPA_HAVE_DEVICE_GENA
1274 UPnPsdk_LOGINFO(
"MSG1055")
"UpnpRegisterRootDevice3(or 4): Gena Check.\n";
1278 if (hasServiceTable) {
1280 "MSG1056")
"UpnpRegisterRootDevice3(or 4): GENA Service Table\n"
1281 "Here are the known services:\n";
1285 "MSG1062")
"\nUpnpRegisterRootDevice3(or 4): Empty service table\n";
1289 switch (AddressFamily) {
1301 "MSG1064")
"Exiting UpnpRegisterRootDevice3(or 4), return value == "
1312 const void*
const Cookie,
1314 const int AddressFamily) {
1315 return compa::UpnpRegisterRootDevice3(DescUrl, Fun, Cookie, Hnd,
1316 AddressFamily,
nullptr);
1321 const void*
const Cookie,
1323 const int AddressFamily,
1324 const char*
const LowerDescUrl) {
1325 return compa::UpnpRegisterRootDevice3(DescUrl, Fun, Cookie, Hnd,
1326 AddressFamily, LowerDescUrl);
1330#ifdef COMPA_HAVE_DEVICE_SSDP
1332 UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
1333 "Inside UpnpUnRegisterRootDevice\n");
1338 int SleepPeriod,
int RegistrationState) {
1344 UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
1345 "Inside UpnpUnRegisterRootDeviceLowPower\n");
1346#ifdef COMPA_HAVE_DEVICE_GENA
1367 (
struct sockaddr*)NULL, (
char*)NULL, (
char*)NULL,
1368 (
char*)NULL, HInfo->
MaxAge);
1381#ifdef COMPA_HAVE_CTRLPT_SSDP
1384#ifdef COMPA_HAVE_WEBSERVER
1401 UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
1402 "Exiting UpnpUnRegisterRootDeviceLowPower\n");
1408#ifdef COMPA_HAVE_CTRLPT_SSDP
1415 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1416 "Inside UpnpRegisterClient \n");
1417 if (Fun == NULL || Hnd == NULL)
1432 if (HInfo == NULL) {
1436 HInfo->
HType = HND_CLIENT;
1441#ifdef COMPA_HAVE_DEVICE_SSDP
1446 compa::HandleTable[*Hnd] = HInfo;
1450 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1451 "Exiting UpnpRegisterClient \n");
1457#ifdef COMPA_HAVE_CTRLPT_SSDP
1465 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1466 "Inside UpnpUnRegisterClient \n");
1475#ifdef COMPA_HAVE_CTRLPT_GENA
1489 while (node != NULL) {
1503 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1504 "Exiting UpnpUnRegisterClient \n");
1510#ifdef COMPA_HAVE_DEVICE_DESCRIPTION
1524 ext = strrchr(name,
'.');
1525 if (ext == NULL || strcasecmp(ext,
".xml") != 0) {
1529 al = strrchr(name,
'/');
1544 struct sockaddr* serverAddr) {
1545 struct sockaddr_in* sa4 = (
struct sockaddr_in*)serverAddr;
1547 memset(serverAddr, 0,
sizeof(
struct sockaddr_storage));
1549 sa4->sin_family = AF_INET;
1550 inet_pton(AF_INET,
gIF_IPV4, &sa4->sin_addr);
1559 struct sockaddr* serverAddr) {
1560 struct sockaddr_in6* sa6 = (
struct sockaddr_in6*)serverAddr;
1562 memset(serverAddr, 0,
sizeof(
struct sockaddr_storage));
1564 sa6->sin6_family = AF_INET6;
1565 inet_pton(AF_INET6,
gIF_IPV6, &sa6->sin6_addr);
1570 char* description,
int config_baseURL,
1574 char* membuf = NULL;
1576 char* temp_str = NULL;
1581 time_t last_modified{};
1582 struct stat file_info;
1583 struct sockaddr_storage serverAddr;
1586 memset(aliasStr, 0,
sizeof(aliasStr));
1587 if (description == NULL)
1598 last_modified = time(NULL);
1603 umock::stdio_h.fopen_s(&fp, description,
"rb");
1605 fp = umock::stdio_h.fopen(description,
"rb");
1610 goto exit_function1;
1616 goto exit_function1;
1618 retVal = fstat(fd, &file_info);
1622 goto exit_function1;
1624 fileLen = (size_t)file_info.st_size;
1625 last_modified = file_info.st_mtime;
1626 membuf = (
char*)malloc(fileLen + (
size_t)1);
1630 goto exit_function1;
1632 num_read = umock::stdio_h.fread(membuf, (
size_t)1, fileLen, fp);
1633 if (num_read != fileLen) {
1636 goto exit_function2;
1638 membuf[fileLen] = 0;
1646 umock::stdio_h.fclose(fp);
1652 last_modified = time(NULL);
1658 if (rc != IXML_SUCCESS &&
1660 if (rc == IXML_INSUFFICIENT_MEMORY)
1666 if (config_baseURL) {
1668 strncpy(aliasStr,
"description.xml",
sizeof(aliasStr) - 1);
1676 if (strlen(temp_str) > (
LINE_SIZE - 1)) {
1680 strncpy(aliasStr, temp_str,
sizeof(aliasStr) - 1);
1682 if (AddressFamily == AF_INET) {
1690 aliasStr, last_modified, descURL);
1697 if (strlen(description) >
LINE_SIZE - 1) {
1701 strncpy(descURL, description,
LINE_SIZE - 1);
1705 assert(*xmlDoc != NULL);
1717#ifdef COMPA_HAVE_DEVICE_SSDP
1719 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1720 "Inside UpnpSendAdvertisement \n");
1725 int PowerState,
int SleepPeriod,
1726 int RegistrationState) {
1728 int retVal = 0, *ptrMx;
1732 memset(&job, 0,
sizeof(job));
1738 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1739 "Inside UpnpSendAdvertisementLowPower \n");
1761 (
struct sockaddr*)NULL, (
char*)NULL, (
char*)NULL,
1766 ptrMx = (
int*)malloc(
sizeof(
int));
1771 if (adEvent == NULL) {
1789#ifdef SSDP_PACKET_DISTRIBUTE
1795 &job, SHORT_TERM, &(adEvent->
advertise.eventId))) !=
1815 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1816 "Exiting UpnpSendAdvertisementLowPower \n");
1822#ifdef COMPA_HAVE_CTRLPT_SSDP
1824 const void* Cookie_const) {
1826 char* Target = (
char*)Target_const;
1833 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Inside UpnpSearchAsync\n");
1846 if (Target == NULL) {
1856 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Exiting UpnpSearchAsync \n");
1868#ifdef COMPA_HAVE_DEVICE_GENA
1876 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1877 "Inside UpnpSetMaxSubscriptions \n");
1894 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1895 "Exiting UpnpSetMaxSubscriptions \n");
1901#ifdef COMPA_HAVE_DEVICE_GENA
1910 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1911 "Inside UpnpSetMaxSubscriptionTimeOut\n");
1931 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1932 "Exiting UpnpSetMaxSubscriptionTimeOut\n");
1938#ifdef COMPA_HAVE_CTRLPT_GENA
1940 int TimeOut,
Upnp_FunPtr Fun,
const void* Cookie_const) {
1943 char* EvtUrl = (
char*)EvtUrl_const;
1946 memset(&job, 0,
sizeof(job));
1952 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1953 "Inside UpnpSubscribeAsync\n");
1963 if (EvtUrl == NULL) {
1978 if (Param == NULL) {
1985 strncpy(Param->
Url, EvtUrl,
sizeof(Param->
Url) - 1);
1988 Param->
Cookie = (
char*)Cookie_const;
1997 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1998 "Exiting UpnpSubscribeAsync\n");
2004#ifdef COMPA_HAVE_CTRLPT_GENA
2012 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Inside UpnpSubscribe\n");
2019 if (EvtUrl == NULL) {
2023 if (EvtUrl_const == NULL) {
2029 if (SubsIdTmp == NULL) {
2033 if (SubsId == NULL) {
2039 if (TimeOut == NULL) {
2056 memset(SubsId, 0,
sizeof(
Upnp_SID));
2060 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2061 "Exiting UpnpSubscribe, retVal=%d\n", retVal);
2070#ifdef COMPA_HAVE_CTRLPT_GENA
2076 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Inside UpnpUnSubscribe\n");
2083 if (SubsIdTmp == NULL) {
2087 if (SubsId == NULL) {
2107 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2108 "Exiting UpnpUnSubscribe, retVal=%d\n", retVal);
2116#ifdef COMPA_HAVE_CTRLPT_GENA
2124 memset(&job, 0,
sizeof(job));
2126 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2127 "Inside UpnpUnSubscribeAsync\n");
2155 if (Param == NULL) {
2165 Param->
Cookie = (
char*)Cookie_const;
2174 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2175 "Exiting UpnpUnSubscribeAsync\n");
2181#ifdef COMPA_HAVE_CTRLPT_GENA
2188 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2189 "Inside UpnpRenewSubscription\n");
2196 if (SubsIdTmp == NULL) {
2200 if (SubsId == NULL) {
2206 if (TimeOut == NULL) {
2225 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2226 "Exiting UpnpRenewSubscription, retVal=%d\n", retVal);
2234#ifdef COMPA_HAVE_CTRLPT_GENA
2237 const void* Cookie_const) {
2242 memset(&job, 0,
sizeof(job));
2248 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2249 "Inside UpnpRenewSubscriptionAsync\n");
2273 if (Param == NULL) {
2282 Param->
Cookie = (
char*)Cookie_const;
2292 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2293 "Exiting UpnpRenewSubscriptionAsync\n");
2299#ifdef COMPA_HAVE_DEVICE_GENA
2301 const char* ServName_const,
const char** VarName_const,
2302 const char** NewVal_const,
int cVariables) {
2305 char* DevID = (
char*)DevID_const;
2306 char* ServName = (
char*)ServName_const;
2307 char** VarName = (
char**)VarName_const;
2308 char** NewVal = (
char**)NewVal_const;
2314 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Inside UpnpNotify\n");
2324 if (DevID == NULL) {
2328 if (ServName == NULL) {
2332 if (VarName == NULL || NewVal == NULL || cVariables < 0) {
2338 retVal =
genaNotifyAll(Hnd, DevID, ServName, VarName, NewVal, cVariables);
2340 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Exiting UpnpNotify\n");
2349 char* DevID = (
char*)DevID_const;
2350 char* ServName = (
char*)ServName_const;
2356 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Inside UpnpNotify \n");
2366 if (DevID == NULL) {
2370 if (ServName == NULL) {
2378 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Exiting UpnpNotify \n");
2384#ifdef COMPA_HAVE_DEVICE_GENA
2386 const char* ServName_const,
2387 const char** VarName_const,
2388 const char** NewVal_const,
int cVariables,
2393 char* DevID = (
char*)DevID_const;
2394 char* ServName = (
char*)ServName_const;
2395 char** VarName = (
char**)VarName_const;
2396 char** NewVal = (
char**)NewVal_const;
2398 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2399 "Inside UpnpAcceptSubscription\n");
2418 if (DevID == NULL) {
2424 if (ServName == NULL) {
2430 if (SubsId == NULL) {
2439 if (VarName == NULL || NewVal == NULL || cVariables < 0) {
2450 ret =
genaInitNotify(Hnd, DevID, ServName, VarName, NewVal, cVariables,
2455 "Exiting UpnpAcceptSubscription, ret = %d\n", ret);
2461 const char* ServName_const,
2466 char* DevID = (
char*)DevID_const;
2467 char* ServName = (
char*)ServName_const;
2469 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2470 "Inside UpnpAcceptSubscription\n");
2489 if (DevID == NULL) {
2495 if (ServName == NULL) {
2501 if (SubsId == NULL) {
2510 if (PropSet == NULL) {
2525 "Exiting UpnpAcceptSubscription, ret = %d.\n", ret);
2537#ifdef COMPA_HAVE_CTRLPT_SOAP
2539 const char* ServiceType_const,
const char* DevUDN_const,
2543 char* ActionURL = (
char*)ActionURL_const;
2544 char* ServiceType = (
char*)ServiceType_const;
2552 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Inside UpnpSendAction\n");
2553 if (DevUDN_const != NULL) {
2554 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2555 "non NULL DevUDN is ignored\n");
2557 DevUDN_const = NULL;
2569 if (ActionURL == NULL) {
2573 if (ServiceType == NULL || Action == NULL || RespNodePtr == NULL ||
2574 DevUDN_const != NULL) {
2579 retVal =
SoapSendAction(ActionURL, ServiceType, Action, RespNodePtr);
2581 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Exiting UpnpSendAction\n");
2587 const char* ServiceType_const,
const char* DevUDN_const,
2592 char* ActionURL = (
char*)ActionURL_const;
2593 char* ServiceType = (
char*)ServiceType_const;
2601 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Inside UpnpSendActionEx\n");
2603 if (Header == NULL) {
2605 DevUDN_const, Action, RespNodePtr);
2619 if (ActionURL == NULL) {
2622 if (ServiceType == NULL || Action == NULL || RespNodePtr == NULL) {
2629 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Exiting UpnpSendAction \n");
2635 const char* ServiceType_const,
const char* DevUDN_const,
2637 const void* Cookie_const) {
2643 char* ActionURL = (
char*)ActionURL_const;
2648 memset(&job, 0,
sizeof(job));
2654 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2655 "Inside UpnpSendActionAsync\n");
2667 if (ActionURL == NULL) {
2671 DevUDN_const != NULL) {
2675 if (tmpStr == NULL) {
2681 if (Param == NULL) {
2689 strncpy(Param->
Url, ActionURL,
sizeof(Param->
Url) - 1);
2693 if (rc != IXML_SUCCESS) {
2696 if (rc == IXML_INSUFFICIENT_MEMORY) {
2703 Param->
Cookie = (
char*)Cookie_const;
2714 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2715 "Exiting UpnpSendActionAsync \n");
2721 const char* ServiceType_const,
2724 const void* Cookie_const) {
2729 char* ActionURL = (
char*)ActionURL_const;
2734 memset(&job, 0,
sizeof(job));
2740 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2741 "Inside UpnpSendActionExAsync\n");
2745 DevUDN_const,
Act,
Fun, Cookie_const);
2759 if (ActionURL == NULL) {
2769 if (tmpStr == NULL) {
2775 if (Param == NULL) {
2784 strncpy(Param->
Url, ActionURL,
sizeof(Param->
Url) - 1);
2787 if (retVal != IXML_SUCCESS) {
2791 if (retVal == IXML_INSUFFICIENT_MEMORY) {
2799 if (retVal != IXML_SUCCESS) {
2804 if (retVal == IXML_INSUFFICIENT_MEMORY) {
2814 Param->
Cookie = (
char*)Cookie_const;
2825 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2826 "Exiting UpnpSendActionAsync\n");
2833 const char* ActionURL_const,
2835 const void* Cookie_const) {
2839 char* ActionURL = (
char*)ActionURL_const;
2840 char*
VarName = (
char*)VarName_const;
2842 memset(&job, 0,
sizeof(job));
2848 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2849 "Inside UpnpGetServiceVarStatusAsync\n");
2861 if (ActionURL == NULL) {
2868 if (Param == NULL) {
2875 strncpy(Param->
Url, ActionURL,
sizeof(Param->
Url) - 1);
2878 Param->
Cookie = (
char*)Cookie_const;
2889 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2890 "Exiting UpnpGetServiceVarStatusAsync\n");
2897 const char* VarName_const,
DOMString* StVar) {
2901 char* ActionURL = (
char*)ActionURL_const;
2902 char* VarName = (
char*)VarName_const;
2908 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2909 "Inside UpnpGetServiceVarStatus\n");
2922 if (ActionURL == NULL) {
2925 if (VarName == NULL || StVar == NULL) {
2932 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2933 "Exiting UpnpGetServiceVarStatus \n");
2944#ifdef COMPA_HAVE_WEBSERVER
2946 int contentLength,
int timeout) {
2950 contentType, contentLength, timeout);
2963 httpStatus, timeout);
2970 int* contentLength,
int* httpStatus,
int timeout) {
2981 httpStatus, timeout);
2987 char** contentType,
int* contentLength,
2988 int* httpStatus,
int timeout) {
2999 httpStatus, timeout);
3005 int* contentLength,
int* httpStatus,
int lowRange,
3006 int highRange,
int timeout) {
3008 httpStatus, lowRange, highRange, timeout);
3028 UpnpString* headers,
const char* contentType,
3029 int contentLength,
int timeout) {
3031 contentLength, timeout);
3043 int* contentLength,
int* httpStatus,
int timeout) {
3045 httpStatus, timeout);
3057#ifdef COMPA_HAVE_WEBSERVER
3062 if (url ==
nullptr || outBuf ==
nullptr || contentType ==
nullptr)
3074 [[maybe_unused]]
char** outBuf,
3075 [[maybe_unused]]
char* contentType) {
3081 TRACE(
"Executing UpnpDownloadXmlDoc()")
3082 if (url ==
nullptr || xmlDoc ==
nullptr) {
3090 UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
3091 "Error downloading document, retCode: %d\n", ret_code);
3095 if (strncasecmp(content_type,
"text/xml", strlen(
"text/xml"))) {
3096 UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"Not text/xml\n");
3111 if (ret_code != IXML_SUCCESS) {
3112 if (ret_code == IXML_INSUFFICIENT_MEMORY) {
3113 UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
3114 "Out of memory, ixml error code: %d\n", ret_code);
3117 UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
3118 "Invalid Description, ixml error code: %d\n", ret_code);
3124 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
3125 "Printing the Parsed xml document \n %s\n", xml_buf);
3126 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
3127 "****************** END OF Parsed XML Doc "
3128 "*****************\n");
3131 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
3132 "Exiting UpnpDownloadXmlDoc\n");
3141#if defined(COMPA_HAVE_CTRLPT_SOAP) || defined(COMPA_HAVE_CTRLPT_GENA)
3143 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
3144 "Inside UpnpThreadDistribution \n");
3147#ifdef COMPA_HAVE_CTRLPT_GENA
3191#ifdef COMPA_HAVE_CTRLPT_SOAP
3199 Param->
Act, &actionResult);
3233 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
3234 "Exiting UpnpThreadDistribution\n");
3244 return ((
struct Handle_Info*)compa::HandleTable[Hnd])->Callback;
3252 for (client = 1; client <
NUM_HANDLE; client++) {
3254 case HND_TABLE_INVALID:
3257 *client_handle_out = client;
3263 *client_handle_out = -1;
3269 [[maybe_unused]]
int AddressFamily,
3272#ifdef COMPA_HAVE_DEVICE_SSDP
3277 *device_handle_out = -1;
3281 *device_handle_out = -1;
3286 for (*device_handle_out = start; *device_handle_out <
NUM_HANDLE;
3287 (*device_handle_out)++) {
3290 if ((*HndInfo)->DeviceAf == AddressFamily) {
3300 *device_handle_out = -1;
3306 [[maybe_unused]]
int AddressFamily,
3310#ifdef COMPA_HAVE_DEVICE_SSDP
3315 *device_handle_out = -1;
3319 for (*device_handle_out = 1; *device_handle_out <
NUM_HANDLE;
3320 (*device_handle_out)++) {
3323 if ((*HndInfo)->DeviceAf == AddressFamily) {
3325 &(*HndInfo)->ServiceTable, path)) != 0) ||
3327 &(*HndInfo)->ServiceTable, path)) != 0)) {
3338 *device_handle_out = -1;
3347 if (HndInfo ==
nullptr) {
3348 UPnPsdk_LOGERR(
"MSG1097")
"No output variable for handle info "
3349 "available (HndInfo==nullptr).\n";
3351 UPnPsdk_LOGERR(
"MSG1130")
"Handle(" << Hnd <<
") out of range.\n";
3353 }
else if (compa::HandleTable[Hnd] ==
nullptr) {
3358 *HndInfo = compa::HandleTable[Hnd];
3359 ret = (*HndInfo)->
HType;
3366 if (compa::HandleTable[Hnd] !=
nullptr) {
3367 HndInfo = compa::HandleTable[Hnd];
3368 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
3369 "Printing information for Handle_%d\n", Hnd);
3370 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"HType_%d\n",
3372#ifdef COMPA_HAVE_DEVICE_SSDP
3373 switch (HndInfo->
HType) {
3377 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"DescURL_%s\n",
3388#ifdef COMPA_HAVE_DEVICE_SSDP
3397#ifdef COMPA_HAVE_WEBSERVER
3399 TRACE(
"Executing UpnpSetWebServerRootDir()")
3402 if ((rootDir ==
nullptr) || (strlen(rootDir) == 0)) {
3414 if ((corsString == NULL) || (strlen(corsString) == 0)) {
3425 const void** oldcookie) {
3431 memset(dirName, 0,
sizeof(dirName));
3437 if ((newDirName == NULL) || (strlen(newDirName) == (
size_t)0)) {
3441 if (*newDirName !=
'/') {
3442 if (strlen(newDirName) >
sizeof(dirName) - 2)
3445 strncpy(dirName + 1, newDirName,
sizeof(dirName) - 2);
3447 if (strlen(newDirName) >
sizeof(dirName) - 1)
3449 strncpy(dirName, newDirName,
sizeof(dirName) - 1);
3453 while (pCurVirtualDir != NULL) {
3455 if (strcmp(pCurVirtualDir->
dirName, dirName) == 0) {
3456 if (oldcookie != NULL)
3457 *oldcookie = pCurVirtualDir->
cookie;
3458 pCurVirtualDir->
cookie = cookie;
3462 pCurVirtualDir = pCurVirtualDir->
next;
3466 if (pNewVirtualDir == NULL) {
3469 pNewVirtualDir->
next = NULL;
3470 if (oldcookie != NULL)
3472 pNewVirtualDir->
cookie = cookie;
3473 memset(pNewVirtualDir->
dirName, 0,
sizeof(pNewVirtualDir->
dirName));
3474#ifdef UPNPLIB_PUPNP_BUG
3479 strncpy(pNewVirtualDir->
dirName, dirName,
3480 sizeof(pNewVirtualDir->
dirName) - 1);
3482 strncpy(pNewVirtualDir->
dirName, dirName,
sizeof(pNewVirtualDir->
dirName));
3484 *(pNewVirtualDir->
dirName + strlen(dirName)) = 0;
3490 while (pLast->
next != NULL) {
3491 pLast = pLast->
next;
3493 pLast->
next = pNewVirtualDir;
3508 if (dirName == NULL) {
3527 while (pCur != NULL) {
3528 if (strcmp(pCur->
dirName, dirName) == 0) {
3555 while (pCur != NULL) {
3566 TRACE(
"Executing UpnpEnableWebserver()")
3570#ifdef COMPA_HAVE_WEBSERVER
@ UPNP_EVENT_RENEWAL_COMPLETE
@ UPNP_CONTROL_ACTION_COMPLETE
@ UPNP_EVENT_SUBSCRIBE_COMPLETE
@ UPNP_CONTROL_GET_VAR_COMPLETE
@ UPNP_EVENT_UNSUBSCRIBE_COMPLETE
int(* Upnp_FunPtr)(Upnp_EventType EventType, const void *Event, void *Cookie)
char Upnp_SID[44]
Holds the subscription identifier for a subscription between a client and a device.
#define UPNP_E_NO_WEB_SERVER
The operation completed successfully.
Upnp_DescType_e
Specifies the type of description in UpnpRegisterRootDevice2.
#define UPNP_E_OUTOF_BOUNDS
The operation completed successfully.
int UpnpClient_Handle
Returned when a control point application registers with UpnpRegisterClient().
int UpnpDevice_Handle
Returned when a device application registers with UpnpRegisterRootDevice(),UpnpRegisterRootDevice2(),...
enum Upnp_DescType_e Upnp_DescType
Represents the different types of searches that can be performed using the SDK for UPnP Devices API.
int http_ReadHttpResponse(void *Handle, char *buf, size_t *size, int timeout)
Reads the content of a response using a connection previously created by UpnpOpenHttpConnection().
int http_OpenHttpConnection(const char *url_str, void **Handle, int timeout)
Opens a connection to the server.
int http_CloseHttpConnection(void *Handle)
Closes the connection created with UpnpOpenHttpConnection() and frees any memory associated with the ...
int http_Download(const char *url_str, int timeout_secs, char **document, size_t *doc_length, char *content_type)
Download the document message and extract the document from the message.
int http_CancelHttpGet(void *Handle)
Set the cancel flag of the HttpGet handle.
int http_WriteHttpRequest(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 conten...
int http_EndHttpRequest(void *Handle, int timeout)
Indicates the end of a HTTP request previously made by UpnpMakeHttpRequest().
int http_OpenHttpGetEx(const char *url_str, void **Handle, char **contentType, int *contentLength, int *httpStatus, int lowRange, int highRange, int timeout)
Makes the HTTP GET message, connects to the peer, sends the HTTP GET request, gets the response and p...
int http_GetHttpResponse(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().
int http_MakeHttpRequest(Upnp_HttpMethod method, const char *url_str, void *Handle, UpnpString *headers, const char *contentType, int contentLength, int timeout)
Makes a HTTP request using a connection previously created by UpnpOpenHttpConnection().
int http_HttpGetProgress(void *Handle, size_t *length, size_t *total)
Extracts information from the Handle to the HTTP get object.
int web_server_set_root_dir(const char *root_dir)
Assign the path to the global Document root directory.
int web_server_set_cors(const char *cors_string)
Assign the Access-Control-Allow-Origin specfied by the input const char* cors_string parameterto the ...
int web_server_set_alias(const char *a_alias_name, const char *a_alias_content, size_t a_alias_content_length, time_t a_last_modified)
Replaces current alias with the given alias.
void web_server_destroy()
Release memory allocated for the global web server root directory and the global XML document.
void web_server_init()
Initilialize root directory for web server and different documents.
#define HTTP_DEFAULT_TIMEOUT
membuffer gDocumentRootDir
int ListDestroy(LinkedList *list, int freeItem)
Removes all memory associated with list nodes. Does not free LinkedList *list.
void * ListDelNode(LinkedList *list, ListNode *dnode, int freeItem)
Removes a node from the list. The memory for the node is freed.
ListNode * ListHead(LinkedList *list)
Returns the head of the list.
int ListInit(LinkedList *list, cmp_routine cmp_func, free_function free_func)
Initializes LinkedList. Must be called first and only once for List.
Linked list node. Stores generic item and pointers to next and prev.
int ThreadPoolInit(ThreadPool *tp, ThreadPoolAttr *attr)
Initializes and starts ThreadPool.
int ThreadPoolAdd(ThreadPool *tp, ThreadPoolJob *job, int *jobId)
Adds a job to the thread pool.
int TPJobSetFreeFunction(ThreadPoolJob *job, free_routine func)
Sets the jobs free function.
int ThreadPoolShutdown(ThreadPool *tp)
Shuts the thread pool down.
int TPAttrSetMaxJobsTotal(ThreadPoolAttr *attr, int totalMaxJobs)
Sets the maximum number jobs that can be qeued totally.
int TPAttrSetMaxThreads(ThreadPoolAttr *attr, int maxThreads)
Sets the max threads for the thread pool attributes.
int TPJobSetPriority(ThreadPoolJob *job, ThreadPriority priority)
Sets the priority of the threadpool job.
int ThreadPoolGetStats(ThreadPool *tp, ThreadPoolStats *stats)
Returns various statistics about the thread pool.
int TPAttrSetJobsPerThread(ThreadPoolAttr *attr, int jobsPerThread)
Sets the jobs per thread ratio.
int TPJobInit(ThreadPoolJob *job, UPnPsdk::start_routine func, void *arg)
Initializes thread pool job.
int TPAttrInit(ThreadPoolAttr *attr)
Initializes thread pool attributes.
int TPAttrSetIdleTime(ThreadPoolAttr *attr, int idleTime)
Sets the idle time for the thread pool attributes.
int TPAttrSetMinThreads(ThreadPoolAttr *attr, int minThreads)
Sets the min threads for the thread pool attributes.
int TPAttrSetStackSize(ThreadPoolAttr *attr, size_t stackSize)
Sets the stack size for the thread pool attributes.
void(* free_routine)(void *arg)
Structure to hold statistics.
Attributes for thread pool.
int TimerThreadShutdown(TimerThread *timer)
Shutdown the timer thread.
int TimerThreadInit(TimerThread *timer, ThreadPool *tp)
Initializes and starts timer thread.
int TimerThreadSchedule(TimerThread *timer, time_t timeout, TimeoutType type, ThreadPoolJob *job, Duration duration, int *id)
Schedules an event to run at a specified time.
@ REL_SEC
seconds from current time.
A timer thread that allows the scheduling of a job to run at a specified time in the future.
PUPNP_Api int UpnpActionComplete_strcpy_CtrlUrl(UpnpActionComplete *p, const char *s)
PUPNP_Api UpnpActionComplete * UpnpActionComplete_new(void)
PUPNP_Api int UpnpActionComplete_set_ErrCode(UpnpActionComplete *p, int n)
PUPNP_Api void UpnpActionComplete_delete(UpnpActionComplete *p)
PUPNP_Api int UpnpActionComplete_set_ActionRequest(UpnpActionComplete *p, IXML_Document *n)
PUPNP_Api int UpnpActionComplete_set_ActionResult(UpnpActionComplete *p, IXML_Document *n)
PUPNP_Api int UpnpEventSubscribe_set_ErrCode(UpnpEventSubscribe *p, int n)
PUPNP_Api const UpnpString * UpnpEventSubscribe_get_PublisherUrl(const UpnpEventSubscribe *p)
PUPNP_Api UpnpEventSubscribe * UpnpEventSubscribe_new(void)
PUPNP_Api int UpnpEventSubscribe_set_SID(UpnpEventSubscribe *p, const UpnpString *s)
PUPNP_Api const UpnpString * UpnpEventSubscribe_get_SID(const UpnpEventSubscribe *p)
PUPNP_Api int UpnpEventSubscribe_strcpy_SID(UpnpEventSubscribe *p, const char *s)
PUPNP_Api int UpnpEventSubscribe_set_TimeOut(UpnpEventSubscribe *p, int n)
PUPNP_Api int UpnpEventSubscribe_strcpy_PublisherUrl(UpnpEventSubscribe *p, const char *s)
PUPNP_Api void UpnpEventSubscribe_delete(UpnpEventSubscribe *p)
PUPNP_Api UpnpStateVarComplete * UpnpStateVarComplete_new(void)
PUPNP_Api void UpnpStateVarComplete_delete(UpnpStateVarComplete *p)
PUPNP_Api int UpnpStateVarComplete_set_CurrentVal(UpnpStateVarComplete *p, const DOMString s)
PUPNP_Api int UpnpStateVarComplete_set_ErrCode(UpnpStateVarComplete *p, int n)
PUPNP_Api int UpnpStateVarComplete_strcpy_CtrlUrl(UpnpStateVarComplete *p, const char *s)
PUPNP_Api int UpnpStateVarComplete_strcpy_StateVarName(UpnpStateVarComplete *p, const char *s)
VDCallback_GetInfo get_info
struct virtual_Dir_List * next
Declaration of the Addrinfo class.
Get information from local network adapters.
UPnPsdk_API void get_first()
Load a list of network adapters from the operating system and select its first entry.
UPnPsdk_API void socknetmask(SSockaddr &a_snetmask) const
Get socket address netmask from current selected list entry.
UPnPsdk_API void sockaddr(SSockaddr &a_saddr) const
Get socket address from current selected list entry.
UPnPsdk_API bool find_next()
Find next ip address from local network adapters.
UPnPsdk_API unsigned int index() const
Get index number from current selected list entry.
UPnPsdk_API std::string name() const
Get network adapter name from current selected list entry.
UPnPsdk_API bool find_first(std::string_view a_name_or_addr="")
Find local network adapter with given name or ip address.
UPnPsdk_API unsigned int bitmask() const
Get prefix length from the ip address of the current selected local network adapter.
#define MIN_THREADS
The MIN_THREADS constant defines the minimum number of threads the thread pool inside the SDK will cr...
#define MAX_SUBSCRIPTION_QUEUED_EVENTS
The MAX_SUBSCRIPTION_QUEUED_EVENTS determines the maximum number of events which can be queued for a ...
#define MAX_SUBSCRIPTION_EVENT_AGE
The MAX_SUBSCRIPTION__EVENT_AGE determines the maximum number of seconds which an event can spend on ...
#define DEFAULT_SOAP_CONTENT_LENGTH
SOAP messages will read at most DEFAULT_SOAP_CONTENT_LENGTH bytes. This prevents devices that have a ...
#define MAX_THREADS
The MAX_THREADS constant defines the maximum number of threads the thread pool inside the SDK will cr...
#define THREAD_STACK_SIZE
The THREAD_STACK_SIZE constant defines the minimum stack size (in bytes) allocated for the stack of e...
#define THREAD_IDLE_TIME
The THREAD_IDLE_TIME constant determines when a thread will be removed from the thread pool and retur...
#define AUTO_ADVERTISEMENT_TIME
The AUTO_ADVERTISEMENT_TIME is the time, in seconds, before an device advertisements expires before a...
#define JOBS_PER_THREAD
The JOBS_PER_THREAD constant determines when a new thread will be allocated to the thread pool inside...
Manage Eventing with GENA, the General Event Notification Architecture.
void genaCallback(http_parser_t *parser, http_message_t *request, SOCKINFO *info)
This is the callback function called by the miniserver to handle incoming GENA requests.
int clientSubscribeMutexInit()
Initialize the client subsribe mutex.
int genaUnregisterClient(UpnpClient_Handle client_handle)
Unsubcribes all the outstanding subscriptions and cleans the subscription list.
struct UpnpNonblockParam action
UpnpNonblockParam.
int genaUnSubscribe(UpnpClient_Handle client_handle, const UpnpString *in_sid)
Unsubscribes a SID.
struct job_arg::@0 advertise
advertise
int genaSubscribe(UpnpClient_Handle client_handle, const UpnpString *PublisherURL, int *TimeOut, UpnpString *out_sid)
This function subscribes to a PublisherURL (also mentioned as EventURL in some places).
int clientSubscribeMutexDestroy()
Destroy the client subsribe mutex.
int genaRenewSubscription(UpnpClient_Handle client_handle, const UpnpString *in_sid, int *TimeOut)
Renews a SID.
int genaNotifyAll(UpnpDevice_Handle device_handle, char *UDN, char *servId, char **VarNames, char **VarValues, int var_count)
Sends a notification to all the subscribed control points.
int genaUnregisterDevice(UpnpDevice_Handle device_handle)
Cleans the service table of the device.
int genaNotifyAllExt(UpnpDevice_Handle device_handle, char *UDN, char *servId, IXML_Document *PropSet)
Sends a notification to all the subscribed control points.
int genaInitNotifyExt(UpnpDevice_Handle device_handle, char *UDN, char *servId, IXML_Document *PropSet, const Upnp_SID sid)
Similar to the genaInitNofity. The only difference is that it takes the xml document for the state ta...
int genaInitNotify(UpnpDevice_Handle device_handle, char *UDN, char *servId, char **VarNames, char **VarValues, int var_count, const Upnp_SID sid)
Sends the intial state table dump to newly subscribed control point.
int SearchByTarget(int Hnd, int Mx, char *St, void *Cookie)
Creates and send the search request for a specific URL.
int AdvertiseAndReply(int AdFlag, UpnpDevice_Handle Hnd, enum SsdpSearchType SearchType, struct sockaddr *DestAddr, char *DeviceType, char *DeviceUDN, char *ServiceType, int Exp)
Sends SSDP advertisements, replies and shutdown messages.
Internal implementation of the class UpnpString.
PUPNP_Api int UpnpString_set_String(UpnpString *p, const char *s)
Sets the string from a pointer to char.
PUPNP_Api UpnpString * UpnpString_new(void)
Constructor.
PUPNP_Api const char * UpnpString_get_String(const UpnpString *p)
Returns the pointer to char.
PUPNP_Api void UpnpString_delete(UpnpString *p)
Destructor.
Data structure common to all types of nodes.
Data structure representing the DOM Document.
PUPNP_Api DOMString ixmlPrintNode(IXML_Node *doc)
Renders a Node and all sub-elements into an XML text representation.
PUPNP_Api int ixmlParseBufferEx(const char *buffer, IXML_Document **doc)
Parses an XML text buffer converting it into an IXML DOM representation.
#define DOMString
The type of DOM strings.
PUPNP_Api IXML_NodeList * ixmlDocument_getElementsByTagName(IXML_Document *doc, const DOMString tagName)
Returns a NodeList of all Elements that match the given tag name in the order in which they were enco...
PUPNP_Api void ixmlFreeDOMString(DOMString buf)
Frees a DOMString.
PUPNP_Api void ixmlNodeList_free(IXML_NodeList *nList)
Frees a NodeList object.
PUPNP_Api void ixmlDocument_free(IXML_Document *doc)
Frees a Document object and all Nodes associated with it.
PUPNP_Api int UpnpRegisterRootDevice3(const char *const DescUrl, const Upnp_FunPtr Fun, const void *const Cookie, UpnpDevice_Handle *const Hnd, const int AddressFamily)
Registers one UPnP device object for a specific address family with the UPnP library and get a handle...
int UpnpInit2(const char *IfName, unsigned short DestPort)
Initializes the Linux SDK for UPnP Devices.
int UpnpGetServiceVarStatus(UpnpClient_Handle Hnd, const char *ActionURL_const, const char *VarName_const, DOMString *StVar)
Queries the state of a state variable of a service on another device.
Upnp_HttpMethod
Different HTTP methods.
PUPNP_Api int UpnpDownloadXmlDoc(const char *url, IXML_Document **xmlDoc)
Downloads an XML document specified in a URL.
@ UPNP_HTTPMETHOD_GET
GET.
@ UPNP_HTTPMETHOD_POST
POST.
int UpnpSearchAsync(UpnpClient_Handle Hnd, int Mx, const char *Target_const, const void *Cookie_const)
Searches for devices matching the given search target.
int UpnpAcceptSubscription(UpnpDevice_Handle Hnd, const char *DevID_const, const char *ServName_const, const char **VarName_const, const char **NewVal_const, int cVariables, const Upnp_SID SubsId)
Accepts a subscription request and sends out the current state of the eventable variables for a servi...
int(* VDCallback_Close)(UpnpWebFileHandle fileHnd, const void *cookie, const void *request_cookie)
Close callback function prototype.
int(* VDCallback_GetInfo)(const char *filename, UpnpFileInfo *info, const void *cookie, const void **request_cookie)
Get-info callback function prototype.
int(* WebCallback_HostValidate)(const char *hostname, void *cookie)
Callback for validating HTTP requests HOST header values.
int(* VDCallback_Seek)(UpnpWebFileHandle fileHnd, off_t offset, int origin, const void *cookie, const void *request_cookie)
Seek callback function prototype.
int(* VDCallback_Write)(UpnpWebFileHandle fileHnd, char *buf, size_t buflen, const void *cookie, const void *request_cookie)
Write callback function prototype.
int(* VDCallback_Read)(UpnpWebFileHandle fileHnd, char *buf, size_t buflen, const void *cookie, const void *request_cookie)
Read callback function prototype.
UpnpWebFileHandle(* VDCallback_Open)(const char *filename, enum UpnpOpenFileMode Mode, const void *cookie, const void *request_cookie)
Open callback function prototype.
void membuffer_destroy(membuffer *m)
Free's memory allocated for membuffer* m.
Maintains a block of dynamically allocated memory.
#define UPNP_E_OUTOF_HANDLE
The SDK does not have any more space for additional handles.
#define UPNP_E_ALREADY_REGISTERED
A client or a device is already registered.
#define UPNP_E_INVALID_HANDLE
The handle passed to a function is not a recognized as a valid handle.
#define UPNP_E_FILE_READ_ERROR
An error happened while reading a file.
#define UPNP_E_INVALID_INTERFACE
The interface provided to UpnpInit2 is unknown or does not have a valid IPv4 or IPv6 address configur...
#define UPNP_E_FILE_NOT_FOUND
The filename passed to one of the device registration functions was not found or was not accessible.
#define UPNP_E_SUCCESS
The operation completed successfully.
#define UPNP_E_OUTOF_MEMORY
Not enough resources are currently available to complete the operation.
#define UPNP_E_INVALID_URL
An URL passed into the function is invalid.
#define UPNP_E_INVALID_ACTION
The SOAP action message is invalid.
#define UPNP_E_FINISH
UpnpInit2 has not been called, or UpnpFinish has already been called.
#define UPNP_E_INIT_FAILED
UpnpInit2 cannot complete.
#define UPNP_E_INVALID_DESC
The description document passed to UpnpRegisterRootDevice, UpnpRegisterRootDevice2 UpnpRegisterRootDe...
#define UPNP_E_INVALID_PARAM
One or more of the parameters passed to the function is not valid.
#define UPNP_E_URL_TOO_BIG
The URL passed into a function is too long.
#define UPNP_E_INIT
The SDK has already been initialized.
#define UPNP_E_EXT_NOT_XML
The file name of the description document passed to UpnpRegisterRootDevice2 does not end in "....
void SetSoapCallback(MiniServerCallback callback)
Set SOAP Callback.
int StartMiniServer(in_port_t *listen_port4, in_port_t *listen_port6, in_port_t *listen_port6UlaGua)
Initialize the sockets functionality for the Miniserver.
int StopMiniServer()
Stop and Shutdown the MiniServer and free socket resources.
void SetGenaCallback(MiniServerCallback callback)
Set GENA Callback.
Manage "Step 0: Addressing" of the UPnP+™ specification.
int UpnpGetIfInfo(std::string_view a_iface="")
Retrieve local network adapter information and keep it in global variables.
pthread_mutex_t sdkInit_mutex
Initialization mutex.
Handle_Info * HandleTable[NUM_HANDLE]
UPnP Device and Control Point handle table
Refactored pupnp program code that is compatible to the original pupnp code.
Manage information about network adapters.
service_info * FindServiceControlURLPath(service_table *table, const char *controlURLPath)
Traverses the service table and finds the node whose control URL Path matches a known value.
void printServiceTable(service_table *table, Upnp_LogLevel level, Dbg_Module module)
Prints the URL base of the table and information of each service from the service table.
service_info * FindServiceEventURLPath(service_table *table, const char *eventURLPath)
Traverses the service table and finds the node whose event URL Path matches a known value.
int getServiceTable(IXML_Node *node, service_table *out, const char *DefaultURLBase)
Retrieve service from the table.
-brief Service information
SOAP declarations for Control Points using SOAP.
int SoapSendActionEx(char *action_url, char *service_type, IXML_Document *header, IXML_Document *action_node, IXML_Document **response_node)
This extended function is called by UPnP API to send the SOAP action request.
int SoapGetServiceVarStatus(char *action_url, DOMString var_name, DOMString *var_value)
This function creates a status variable query message send it to the specified URL....
int SoapSendAction(char *action_url, char *service_type, IXML_Document *action_node, IXML_Document **response_node)
This function is called by UPnP API to send the SOAP action request.
SOAP declarations for UPnP Devices using SOAP.
void soap_device_callback(http_parser_t *parser, http_message_t *request, SOCKINFO *info)
This is a callback called by minisever.
void freeSslCtx()
Free the OpenSSL context.
SsdpSearchType
Enumeration to define all different types of ssdp searches.
Manage "Step 1: Discovery" of the UPnP+™ specification for Control Points with SSDP.
char * searchTarget
part of search argument
Manage "Step 1: Discovery" of the UPnP+™ specification for UPnP Devices with SSDP.
Trivial ::sockaddr structures enhanced with methods.
sockaddr_in6 & sin6
Reference to sockaddr_in6 struct.
const std::string netaddr() noexcept
Get the assosiated netaddress without port.
sockaddr_storage & ss
Reference to sockaddr_storage struct.
int UpnpSendActionAsync(UpnpClient_Handle Hnd, const char *ActionURL_const, const char *ServiceType_const, const char *DevUDN_const, IXML_Document *Act, Upnp_FunPtr Fun, const void *Cookie_const)
Sends a message to change a state variable in a service, generating a callback when the operation is ...
WebCallback_HostValidate gWebCallback_HostValidate
webCallback for HOST validation.
Upnp_FunPtr GetCallBackFn(UpnpClient_Handle Hnd)
Get callback function ptr from a handle.
int UpnpCloseHttpGet(void *Handle)
Closes the connection and frees memory that was allocated for the handle parameter.
int UpnpSubscribe(UpnpClient_Handle Hnd, const char *EvtUrl_const, int *TimeOut, Upnp_SID SubsId)
Registers a control point to receive event notifications from a UPnP device.
int UpnpVirtualDir_set_GetInfoCallback(VDCallback_GetInfo callback)
Sets the get_info callback function to be used to access a web directory.
in_port_t LOCAL_PORT_V6_ULA_GUA
IPv6 ULA or GUA port for the mini-server.
unsigned gIF_IPV6_ULA_GUA_PREFIX_LENGTH
IPv6 ULA or GUA prefix length. (extern'ed in upnp.h)
int UpnpRegisterClient(Upnp_FunPtr Fun, const void *Cookie, UpnpClient_Handle *Hnd)
Registers a control point application with the UPnP Library.
int UpnpOpenHttpGet(const char *url, void **handle, char **contentType, int *contentLength, int *httpStatus, int timeout)
Gets a file specified in a URL.
int UpnpNotifyExt(UpnpDevice_Handle Hnd, const char *DevID_const, const char *ServName_const, IXML_Document *PropSet)
Similar to UpnpNotify() except that it takes a DOM document for the event rather than an array of str...
struct VirtualDirCallbacks virtualDirCallback
This structure is for virtual directory callbacks.
Upnp_Handle_Type GetHandleInfo(UpnpClient_Handle Hnd, Handle_Info **HndInfo)
Get handle information.
void UpnpThreadDistribution(struct UpnpNonblockParam *Param)
Schedule async functions in threadpool.
ThreadPool gSendThreadPool
Send thread pool.
char gIF_IPV6_ULA_GUA[INET6_ADDRSTRLEN]
Static buffer to contain interface IPv6 unique-local or globally-unique address (ULA or GUA)....
void UpnpSetHostValidateCallback(WebCallback_HostValidate callback, void *cookie)
Set callback for validating HTTP requests HOST header values.
int UpnpCloseHttpPost(void *handle, int *httpStatus, int timeout)
Sends and receives any pending data, closes the connection with the server, and frees memory allocate...
int UpnpRegisterRootDevice3(const char *const DescUrl, const Upnp_FunPtr Fun, const void *const Cookie, UpnpDevice_Handle *const Hnd, const int AddressFamily)
Registers one UPnP device object for a specific address family with the UPnP library and get a handle...
static int UpnpInitStartServers(in_port_t DestPort)
Finishes initializing the UPnP SDK.
int UpnpSendAdvertisementLowPower(UpnpDevice_Handle Hnd, int Exp, int PowerState, int SleepPeriod, int RegistrationState)
Sends out the discovery announcements for all devices and services contained within one root device.
int UpnpRenewSubscription(UpnpClient_Handle Hnd, int *TimeOut, const Upnp_SID SubsId)
Renews a subscription that is about to expire.
ThreadPool gRecvThreadPool
Receive thread pool.
int UpnpEnableWebserver(int enable)
Enables or disables the webserver.
static void free_action_arg(job_arg *arg)
Free memory associated with an action job's argument.
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...
int UpnpDownloadUrlItem(const char *url, char **outBuf, char *contentType)
Downloads a file specified in a URL.
void PrintThreadPoolStats(ThreadPool *tp, const char *DbgFileName, int DbgLineNo, const char *msg)
Prints thread pool statistics if DEBUG is enabled. See also #define PrintThreadPoolStats()
int UpnpRegisterRootDevice4(const char *const DescUrl, const Upnp_FunPtr Fun, const void *const Cookie, UpnpDevice_Handle *const Hnd, const int AddressFamily, const char *const LowerDescUrl)
Same as UpnpRegisterRootDevice3() with additional argument to specify a description URL.
static int UpnpInitPreamble()
Performs the initial steps in initializing the UPnP SDK.
int UpnpCancelHttpGet(void *Handle)
Set the cancel flag of the handle parameter.
int UpnpReadHttpResponse(void *handle, char *buf, size_t *size, int timeout)
Reads the content of a response using a connection previously created by UpnpOpenHttpConnection().
int UpnpSetMaxContentLength(size_t contentLength)
Sets the maximum content-length that the SDK will process on an incoming SOAP requests or responses.
int gAllowLiteralHostRedirection
Allow literal host names redirection to numeric host names.
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().
int PrintHandleInfo(UpnpClient_Handle Hnd)
Print handle info.
int UpnpUnSubscribe(UpnpClient_Handle Hnd, const Upnp_SID SubsId)
Removes the subscription of a control point from a service previously subscribed to using UpnpSubscri...
char * UpnpGetServerIp6Address()
Returns the IPv6 link-local listening ip address.
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.
int UpnpRegisterRootDevice2(const Upnp_DescType descriptionType, const char *const description_const, const size_t bufferLen, const int config_baseURL, const Upnp_FunPtr Fun, const void *const Cookie, UpnpDevice_Handle *const Hnd)
Registers one root- or logical-device object with the UPnP Library with additional description and ge...
Upnp_SID gUpnpSdkNLSuuid
Global variable used in discovery notifications.
pthread_rwlock_t GlobalHndRWLock
rwlock to synchronize handles (root device or control point handle).
unsigned short UpnpGetServerPort()
Returns the internal server IPv4 UPnP listening port.
int UpnpVirtualDir_set_WriteCallback(VDCallback_Write callback)
Sets the write callback function to be used to access a web directory.
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...
Upnp_Handle_Type GetDeviceHandleInfoForPath(const char *path, int AddressFamily, UpnpDevice_Handle *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,...
int UpnpOpenHttpGetEx(const char *url_str, 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.
int UpnpRenewSubscriptionAsync(UpnpClient_Handle Hnd, int TimeOut, Upnp_SID SubsId, Upnp_FunPtr Fun, const void *Cookie_const)
Renews a subscription that is about to expire, generating a callback when the operation is complete.
char * UpnpGetServerUlaGuaIp6Address()
Returns the IPv6 unique-local or globally-unique listening ip address.
int UpnpUnSubscribeAsync(UpnpClient_Handle Hnd, Upnp_SID SubsId, Upnp_FunPtr Fun, const void *Cookie_const)
Removes a subscription of a control point from a service previously subscribed to using UpnpSubscribe...
unsigned gIF_IPV6_PREFIX_LENGTH
IPv6 LLA prefix length. (extern'ed in upnp.h)
int UpnpVirtualDir_set_SeekCallback(VDCallback_Seek callback)
Sets the seek callback function to be used to access a web directory.
int UpnpFinish()
Terminates the Linux SDK for UPnP Devices.
int UpnpSetMaxSubscriptions(UpnpDevice_Handle Hnd, int MaxSubscriptions)
Sets the maximum number of subscriptions accepted per service.
static int UpnpInitMutexes()
Initializes the global mutexes used by the UPnP SDK.
void * gWebCallback_HostValidateCookie
Cookie to the webCallback for HOST validation.
int UpnpVirtualDir_set_ReadCallback(VDCallback_Read callback)
Sets the read callback function to be used to access a web directory.
unsigned short UpnpGetServerPort6()
Returns the internal server IPv6 link-local (LLA) UPnP listening port.
size_t g_maxContentLength
Maximum content-length (in bytes) that the SDK will process on an incoming packet.
int UpnpSetWebServerRootDir(const char *rootDir)
Sets the document root directory for the internal web server.
virtualDirList * pVirtualDirList
Pointer to the virtual directory list.
static int GetNameForAlias(char *name, char **alias)
Determines alias for given name which is a file name or URL.
int g_UpnpSdkEQMaxLen
Global variable to determines the maximum number of events.
int UpnpCloseHttpConnection(void *handle)
Closes the connection created with UpnpOpenHttpConnection() and frees any memory associated with the ...
in_port_t LOCAL_PORT_V6
IPv6 LLA port for the mini-server.
int UpnpNotify(UpnpDevice_Handle Hnd, const char *DevID_const, const char *ServName_const, const char **VarName_const, const char **NewVal_const, int cVariables)
Sends out an event change notification to all control points subscribed to a particular service.
int UpnpGetServiceVarStatusAsync(UpnpClient_Handle Hnd, const char *ActionURL_const, const char *VarName_const, Upnp_FunPtr Fun, const void *Cookie_const)
Queries the state of a variable of a service, generating a callback when the operation is complete.
int UpnpHttpGetProgress(void *Handle, size_t *length, size_t *total)
Retrieve progress information of a http-get transfer.
int UpnpSetMaxSubscriptionTimeOut(UpnpDevice_Handle Hnd, int MaxSubscriptionTimeOut)
Sets the maximum time-out accepted for a subscription request or renewal.
static int GetDescDocumentAndURL(Upnp_DescType descriptionType, char *description, int config_baseURL, int AddressFamily, IXML_Document **xmlDoc, char descURL[LINE_SIZE])
Fills the sockadr_in with miniserver information.
int UpnpReadHttpGet(void *Handle, char *buf, size_t *size, int timeout)
Gets specified number of bytes from a file specified in a URL.
int UpnpRegisterRootDevice(const char *const DescUrl, const Upnp_FunPtr Fun, const void *const Cookie, UpnpDevice_Handle *const Hnd)
Registers one root- or logical-device object with the UPnP Library to get a handle for it.
int UpnpSetContentLength(UpnpClient_Handle Hnd, size_t contentLength)
Sets the content-length that the SDK will process on an incoming SOAP requests or responses.
int UpnpSendAdvertisement(UpnpDevice_Handle Hnd, int Exp)
Sends out the discovery announcements for all devices and services contained within one root device.
unsigned short UpnpGetServerUlaGuaPort6()
Returns the internal server IPv6 ULA or GUA UPnP listening port.
int UpnpSdkInit
Global variable to denote the state of Upnp SDK == 0 if uninitialized, == 1 if initialized.
static int GetFreeHandle()
Get a free UPnP Unit handle.
static void get_server_addr(struct sockaddr *serverAddr)
Fill the sockadr with IPv4 miniserver information.
in_port_t LOCAL_PORT_V4
local IPv4 port for the mini-server
static int UpnpInitThreadPools()
Initializes the global threadm pools used by the UPnP SDK.
int UpnpSendAction(UpnpClient_Handle Hnd, const char *ActionURL_const, const char *ServiceType_const, const char *DevUDN_const, IXML_Document *Action, IXML_Document **RespNodePtr)
Sends a message to change a state variable in a service.
int UpnpAddVirtualDir(const char *newDirName, const void *cookie, const void **oldcookie)
Adds a web directory mapping.
int UpnpSubscribeAsync(UpnpClient_Handle Hnd, const char *EvtUrl_const, int TimeOut, Upnp_FunPtr Fun, const void *Cookie_const)
Performs the same operation as UpnpSubscribe(), but returns immediately and calls the registered call...
int UpnpSdkDeviceRegisteredV4
Global variable to denote the state of Upnp SDK IPv4 device registration.
Upnp_Handle_Type GetDeviceHandleInfo(UpnpDevice_Handle start, int AddressFamily, UpnpDevice_Handle *device_handle_out, struct Handle_Info **HndInfo)
Retrieves the device handle and information of the first device of the address family specified....
int UpnpUnRegisterRootDeviceLowPower(UpnpDevice_Handle Hnd, int PowerState, int SleepPeriod, int RegistrationState)
Unregisters a root device registered with UpnpRegisterRootDevice(), UpnpRegisterRootDevice2(),...
int UpnpSdkClientRegistered
Global variable to denote the state of Upnp SDK client registration.
int UpnpAcceptSubscriptionExt(UpnpDevice_Handle Hnd, const char *DevID_const, const char *ServName_const, IXML_Document *PropSet, const Upnp_SID SubsId)
Similar to UpnpAcceptSubscription() except that it takes a DOM document for the variables to event ra...
void AutoAdvertise(void *input)
This function is a timer thread scheduled by UpnpSendAdvertisement to the send advetisement again.
int UpnpUnRegisterRootDevice(UpnpDevice_Handle Hnd)
Unregisters a root device registered with UpnpRegisterRootDevice(), UpnpRegisterRootDevice2(),...
int UpnpSendActionExAsync(UpnpClient_Handle Hnd, const char *ActionURL_const, const char *ServiceType_const, const char *DevUDN_const, IXML_Document *Header, IXML_Document *Act, Upnp_FunPtr Fun, const void *Cookie_const)
Sends a message to change a state variable in a service, generating a callback when the operation is ...
int UpnpRemoveVirtualDir(const char *dirName)
Removes a web directory mapping made with UpnpAddVirtualDir().
int UpnpEndHttpRequest(void *handle, int timeout)
Indicates the end of a HTTP request previously made by UpnpMakeHttpRequest().
void UpnpRemoveAllVirtualDirs()
Removes all web directory mappings.
int UpnpDownloadXmlDoc(const char *url, IXML_Document **xmlDoc)
Downloads an XML document specified in a URL.
static void get_server_addr6(struct sockaddr *serverAddr)
Fill the sockadr with IPv6 miniserver information.
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 conten...
char gIF_IPV4[INET_ADDRSTRLEN]
Static buffer to contain interface IPv4 address. (extern'ed in upnp.h)
TimerThread gTimerThread
Global timer thread.
static void free_advertise_arg(job_arg *arg)
Free memory associated with advertise job's argument.
int UpnpVirtualDir_set_OpenCallback(VDCallback_Open callback)
Sets the open callback function to be used to access a web directory.
char gIF_NAME[LINE_SIZE]
Static buffer to contain interface name. (extern'ed in upnp.h)
unsigned gIF_INDEX
Contains network interface index of the link local address gIF_IPV6 that is used as its scope_id.
ThreadPool gMiniServerThreadPool
Mini server thread pool.
membuffer gWebserverCorsString
char gIF_IPV4_NETMASK[INET_ADDRSTRLEN]
Static buffer to contain interface IPv4 netmask. (extern'ed in upnp.h)
static int FreeHandle(int Upnp_Handle)
Free handle.
int g_UpnpSdkEQMaxAge
Global variable to determine the maximum number of seconds which an event can spend on a subscription...
int UpnpSendActionEx(UpnpClient_Handle Hnd, const char *ActionURL_const, const char *ServiceType_const, const char *DevUDN_const, IXML_Document *Header, IXML_Document *Action, IXML_Document **RespNodePtr)
Sends a message to change a state variable in a service.
char gIF_IPV6[INET6_ADDRSTRLEN]
Static buffer to contain interface IPv6 link-local address (LLA). (extern'ed in upnp....
int UpnpSdkDeviceregisteredV6
Global variable to denote the state of Upnp SDK IPv6 device registration.
void UpnpSetAllowLiteralHostRedirection(int enable)
Enable or disable literal IP redirection.
int UpnpUnRegisterClient(UpnpClient_Handle Hnd)
Unregisters a control point application, unsubscribing all active subscriptions.
Upnp_Handle_Type GetClientHandleInfo(UpnpClient_Handle *client_handle_out, struct Handle_Info **HndInfo)
Get client handle info.
int UpnpIsWebserverEnabled()
Returns the status of the webserver.
int UpnpOpenHttpConnection(const char *url, void **handle, int timeout)
Opens a connection to the server.
int UpnpSetWebServerCorsString(const char *corsString)
Assign the Access-Control-Allow-Origin specfied by the input const char* cors_string parameter to the...
WebServerState bWebServerState
Flag to indicate the state of web server.
char * UpnpGetServerIpAddress()
Returns the local IPv4 listening ip address.
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().
int UpnpVirtualDir_set_CloseCallback(VDCallback_Close callback)
Sets the close callback function to be used to access a web directory.
Inititalize the compatible library before it can be used.
IXML_Document * Act
UpnpNonblockParam
Upnp_Handle_Type HType
Handle Type.
IXML_Document * Header
UpnpNonblockParam
char * Cookie
UpnpNonblockParam
IXML_NodeList * ServiceList
List of services in the description document.
int aliasInstalled
0 = not installed; otherwise installed.
int Handle
UpnpNonblockParam
#define HandleLock()
HandleLock.
Upnp_FunPtr Fun
UpnpNonblockParam
char Url[NAME_SIZE]
UpnpNonblockParam
GenlibClientSubscription * ClientSubList
Client subscription list.
#define DEFAULT_MAXAGE
DEFAULT_MAXAGE.
service_table ServiceTable
Table holding subscriptions and URL information.
int SleepPeriod
Sleep Period as defined by UPnP Low Power.
#define DEFAULT_MX
DEFAULT_MX.
char LowerDescURL[LINE_SIZE]
URL for the use of SSDP when answering to legacy CPs (CP searching for a v1 when the device is v2).
int RegistrationState
Registration State as defined by UPnP Low Power.
char DescURL[LINE_SIZE]
URL for the use of SSDP.
Upnp_SID SubsId
UpnpNonblockParam
#define HandleUnlock()
HandleUnlock.
IXML_Document * DescDocument
Description parsed in terms of DOM document.
UpnpFunName FunName
UpnpNonblockParam
int TimeOut
UpnpNonblockParam
int PowerState
Power State as defined by UPnP Low Power.
WebServerState
Possible status of the internal webserver.
Upnp_FunPtr Callback
Callback function pointer.
constexpr int NUM_HANDLE
Maximal number of available UPnP Unit handles.
int MaxSubscriptionTimeOut
???
LinkedList SsdpSearchList
Active SSDP searches.
IXML_NodeList * DeviceList
List of devices in the description document.
int MaxAge
Advertisement timeout.
char VarName[NAME_SIZE]
UpnpNonblockParam
int DeviceAf
Address family: AF_INET6 or AF_INET.
#define MAX_SOAP_CONTENT_LENGTH
MAX_SOAP_CONTENT_LENGTH.
char ServiceType[NAME_SIZE]
UpnpNonblockParam
#define HandleReadLock()
HandleReadLock.
Data to be stored in handle table for Handle Info.
UPnPsdk_VIS void UpnpPrintf(Upnp_LogLevel DLevel, Dbg_Module Module, const char *DbgFileName, int DbgLineNo, const char *FmtStr,...)
Prints the debug statement.
UPnPsdk_VIS int UpnpInitLog(void)
Initialize the log files.
UPnPsdk_VIS void UpnpCloseLog(void)
Closes the log files.
Configure the full URL for the description document.
int configure_urlbase(IXML_Document *doc, const sockaddr *serverAddr, const char *alias, time_t last_modified, char docURL[LINE_SIZE])
Configure the full URL for the description document.
void uuidMutexInit()
Initialize mutex for synchronizing the uuid creation process.
void upnp_uuid_unpack(uuid_upnp *u, char *out)
Unpack a UUID.
int uuidMutexDestroy()
Destroy mutex for synchronizing the uuid creation process.
int uuid_create(uuid_upnp *uid)
Generate a UUID.