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>
85#if !defined(ifr_netmask) || defined(DOXYGEN_RUN)
88#define ifr_netmask ifr_addr
91#if !defined(IN6_IS_ADDR_ULA) || defined(DOXYGEN_RUN)
93#define IN6_IS_ADDR_ULA(a) \
94 ((((__const uint32_t*)(a))[0] & htonl((uint32_t)0xfe000000)) == \
95 htonl((uint32_t)0xfc000000))
208#ifdef COMPA_HAVE_OPTION_SSDP
261 const std::string& a_iface =
"")
263 TRACE(
"Executing ::UpnpGetIfInfo()")
267 switch (size(a_iface)) {
269 if (std::isdigit(a_iface[0]))
270 idx = std::stoi(a_iface);
273 if (std::isdigit(a_iface[0]) && std::isdigit(a_iface[1]))
274 idx = std::stoi(a_iface);
284 success = nadaptObj.
find_first(
static_cast<unsigned int>(idx));
288 UPnPsdk_LOGERR(
"MSG1033")
"Local network interface with \""
289 << a_iface <<
"\" not valid for operation or not found.\n";
296 UPnPsdk_LOGERR(
"MSG1045")
"Local network interface address \""
297 << a_iface <<
"\" is not supported.\n";
319 if (saObj.
ss.ss_family == AF_INET6) {
321 (IN6_IS_ADDR_LINKLOCAL(&saObj.
sin6.sin6_addr))) {
326 if (
char* chptr{::strchr(
gIF_IPV6,
'%')})
329 else if (
char* chptr{::strchr(
gIF_IPV6,
']')})
337 if (
char* chptr{::strchr(
gIF_IPV6,
'%')})
347 UPnPsdk_LOGCRIT(
"MSG1029")
"Unsupported address family("
348 << saObj.
ss.ss_family <<
"), only AF_INET6(" << AF_INET6
355 }
catch (
const std::exception& ex) {
356 UPnPsdk_LOGCATCH(
"MSG1006")
"catched next line...\n" << ex.what();
367#if defined(COMPA_HAVE_DEVICE_DESCRIPTION) || \
368 defined(COMPA_HAVE_CTRLPT_DESCRIPTION) || defined(DOXYGEN_RUN)
390#if defined(COMPA_HAVE_DEVICE_DESCRIPTION) || \
391 defined(COMPA_HAVE_CTRLPT_DESCRIPTION) || defined(DOXYGEN_RUN)
402 UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
403 "FreeHandle: entering, Handle is %d\n", Upnp_Handle);
404 if (Upnp_Handle < 1 || Upnp_Handle >=
NUM_HANDLE) {
405 UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
406 "FreeHandle: Handle %d is out of range\n", Upnp_Handle);
408 UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
409 "FreeHandle: HandleTable[%d] is nullptr\n", Upnp_Handle);
416 "FreeHandle: exiting, ret = %d.\n", ret);
434#if defined(COMPA_HAVE_DEVICE_DESCRIPTION)
436 const void*
const Cookie,
438 const int AddressFamily,
439 const char*
const LowerDescUrl) {
440 TRACE(
"Executing UpnpRegisterRootDevice3() (same as "
441 "UpnpRegisterRootDevice4())")
444#ifdef COMPA_HAVE_DEVICE_GENA
445 int hasServiceTable{0};
454 if (Hnd ==
nullptr || Fun ==
nullptr || DescUrl ==
nullptr ||
455 strlen(DescUrl) == 0 ||
456 (AddressFamily != AF_INET && AddressFamily != AF_INET6)) {
462 *Hnd = GetFreeHandle();
468 if (HInfo ==
nullptr) {
473 HandleTable[*Hnd] = HInfo;
475 HInfo->
HType = HND_DEVICE;
478 if (LowerDescUrl ==
nullptr)
484 "MSG1050")
"Following Root UDevice local URL will be used when "
485 "responding to requests from control points: "
488 HInfo->
Cookie = (
char*)Cookie;
493#ifdef COMPA_HAVE_CTRLPT_SSDP
504#ifdef COMPA_HAVE_CTRLPT_SSDP
511 "MSG1051")
"UpnpRegisterRootDevice3(or 4): Valid Description\n"
512 "UpnpRegisterRootDevice3(or 4): DescURL = "
518#ifdef COMPA_HAVE_CTRLPT_SSDP
523 UPnPsdk_LOGCRIT(
"MSG1052")
"UpnpRegisterRootDevice3(or 4): No devices "
524 "found for RootDevice.\n";
533 "MSG1054")
"UpnpRegisterRootDevice3(or 4): No services found for "
537#ifdef COMPA_HAVE_DEVICE_GENA
541 UPnPsdk_LOGINFO(
"MSG1055")
"UpnpRegisterRootDevice3(or 4): Gena Check.\n";
545 if (hasServiceTable) {
547 "MSG1056")
"UpnpRegisterRootDevice3(or 4): GENA Service Table\n"
548 "Here are the known services:\n";
552 "MSG1062")
"\nUpnpRegisterRootDevice3(or 4): Empty service table\n";
556 switch (AddressFamily) {
568 "MSG1064")
"Exiting UpnpRegisterRootDevice3(or 4), return value == "
580#ifdef COMPA_HAVE_DEVICE_SSDP
584static void free_advertise_arg(job_arg* arg) {
585 if (arg->advertise.Event) {
586 free(arg->advertise.Event);
592#ifdef COMPA_HAVE_CTRLPT_SOAP
623#ifdef COMPA_HAVE_OPTION_SSDP
628#ifdef COMPA_HAVE_CTRLPT_GENA
690 TRACE(
"Executing UpnpInitPreamble()")
694 srand((
unsigned int)time(NULL));
709#ifdef COMPA_HAVE_OPTION_SSDP
729#ifdef COMPA_HAVE_DEVICE_SOAP
733#ifdef COMPA_HAVE_DEVICE_GENA
758 [[maybe_unused]] in_port_t DestPort) {
759 UPnPsdk_LOGINFO(
"MSG1061")
"Executing...\n";
762#ifdef COMPA_HAVE_MINISERVER
769 UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
770 "Miniserver failed to start\n");
782 UPnPsdk_LOGINFO(
"MSG1066")
"Finished.\n";
786int UpnpInit2(
const char* IfName,
unsigned short DestPort) {
787 UPnPsdk_LOGINFO(
"MSG1096")
"Executing...\n";
791 if (pthread_mutex_lock(&compa::sdkInit_mutex) != 0) {
828 pthread_mutex_unlock(&compa::sdkInit_mutex);
840 const char* DbgFileName,
847 UpnpPrintf(UPNP_INFO, API, DbgFileName, DbgLineNo,
849 "High Jobs pending: %d\n"
850 "Med Jobs Pending: %d\n"
851 "Low Jobs Pending: %d\n"
852 "Average wait in High Q in milliseconds: %lf\n"
853 "Average wait in Med Q in milliseconds: %lf\n"
854 "Average wait in Low Q in milliseconds: %lf\n"
855 "Max Threads Used: %d\n"
856 "Worker Threads: %d\n"
857 "Persistent Threads: %d\n"
859 "Total Threads: %d\n"
860 "Total Work Time: %lf\n"
861 "Total Idle Time: %lf\n",
862 msg, stats.currentJobsHQ, stats.currentJobsMQ,
863 stats.currentJobsLQ, stats.avgWaitHQ, stats.avgWaitMQ,
864 stats.avgWaitLQ, stats.maxThreads, stats.workerThreads,
865 stats.persistentThreads, stats.idleThreads, stats.totalThreads,
866 stats.totalWorkTime, stats.totalIdleTime);
871#define PrintThreadPoolStats(tp, DbgFileName, DbgLineNo, msg) \
877 TRACE(
"Executing UpnpFinish()")
878 UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
879 "Inside UpnpFinish: UpnpSdkInit is %d\n",
UpnpSdkInit);
880#ifdef COMPA_HAVE_DEVICE_DESCRIPTION
883#ifdef COMPA_HAVE_CTRLPT_DESCRIPTION
886 [[maybe_unused]]
struct Handle_Info* temp{
nullptr};
887#ifdef UPnPsdk_HAVE_OPENSSL
892 UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
893 "UpnpFinish: UpnpSdkInit is ONE\n");
901#ifdef COMPA_HAVE_DEVICE_DESCRIPTION
911#ifdef COMPA_HAVE_CTRLPT_DESCRIPTION
917#ifdef COMPA_HAVE_MINISERVER
920#ifdef COMPA_HAVE_WEBSERVER
925 "MiniServer Thread Pool");
932#ifdef COMPA_HAVE_CTRLPT_GENA
936#ifdef COMPA_HAVE_OPTION_SSDP
941 UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
942 "Exiting UpnpFinish: UpnpSdkInit is :%d:\n",
UpnpSdkInit);
956#ifdef UPNP_ENABLE_IPV6
967#ifdef UPNP_ENABLE_IPV6
985#ifdef UPNP_ENABLE_IPV6
996#ifdef UPNP_ENABLE_IPV6
1006#ifdef COMPA_HAVE_DEVICE_DESCRIPTION
1008 const void*
const Cookie,
1012#ifdef COMPA_HAVE_DEVICE_GENA
1013 int hasServiceTable{0};
1017 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1018 "Inside UpnpRegisterRootDevice\n");
1025 if (Hnd == NULL || Fun == NULL || DescUrl == NULL ||
1026 strlen(DescUrl) == (
size_t)0) {
1038 if (HInfo == NULL) {
1045 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Root device URL is %s\n",
1049 HInfo->
HType = HND_DEVICE;
1052 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1053 "Following Root Device URL will be used when answering to "
1062#ifdef COMPA_HAVE_CTRLPT_SSDP
1072 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1073 "UpnpRegisterRootDevice: error downloading Document: "
1076#ifdef COMPA_HAVE_CTRLPT_SSDP
1082 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1083 "UpnpRegisterRootDevice: Valid Description\n"
1084 "UpnpRegisterRootDevice: DescURL : %s\n",
1090#ifdef COMPA_HAVE_CTRLPT_SSDP
1095 UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
1096 "UpnpRegisterRootDevice: No devices found for "
1105 UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
1106 "UpnpRegisterRootDevice: No services found for "
1110#ifdef COMPA_HAVE_DEVICE_GENA
1114 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1115 "UpnpRegisterRootDevice: Gena Check\n");
1119 if (hasServiceTable) {
1120 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1121 "UpnpRegisterRootDevice: GENA Service Table\n"
1122 "Here are the known services:\n");
1125 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1126 "\nUpnpRegisterRootDevice: Empty service table\n");
1135 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1136 "Exiting RegisterRootDevice, return value == %d\n", retVal);
1143#ifdef COMPA_HAVE_DEVICE_DESCRIPTION
1162#ifdef COMPA_HAVE_DEVICE_DESCRIPTION
1164 const char*
const description_const,
1165 const size_t bufferLen,
1167 const void*
const Cookie,
1171 char* description = (
char*)description_const;
1173#ifdef COMPA_HAVE_DEVICE_GENA
1174 int hasServiceTable{0};
1178 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1179 "Inside UpnpRegisterRootDevice2\n");
1186 if (Hnd == NULL || Fun == NULL) {
1198 if (HInfo == NULL) {
1216#ifdef UPNPLIB_PUPNP_BUG
1226 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1227 "Following Root Device URL will be used when answering to "
1231 HInfo->
HType = HND_DEVICE;
1237#ifdef COMPA_HAVE_CTRLPT_SSDP
1245 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1246 "UpnpRegisterRootDevice2: Valid Description\n"
1247 "UpnpRegisterRootDevice2: DescURL : %s\n",
1253#ifdef COMPA_HAVE_CTRLPT_SSDP
1258 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1259 "UpnpRegisterRootDevice2: No devices found for "
1268 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1269 "UpnpRegisterRootDevice2: No services found for "
1273#ifdef COMPA_HAVE_DEVICE_GENA
1277 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1278 "UpnpRegisterRootDevice2: Gena Check\n");
1282 if (hasServiceTable) {
1283 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1284 "UpnpRegisterRootDevice2: GENA Service Table\n"
1285 "Here are the known services: \n");
1288 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1289 "\nUpnpRegisterRootDevice2: Empty service table\n");
1298 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1299 "Exiting RegisterRootDevice2, return value == %d\n", retVal);
1306#ifdef COMPA_HAVE_DEVICE_DESCRIPTION
1309 const void*
const Cookie,
1311 const int AddressFamily) {
1312 return compa::UpnpRegisterRootDevice3(DescUrl, Fun,
Cookie, Hnd,
1313 AddressFamily,
nullptr);
1318 const void*
const Cookie,
1320 const int AddressFamily,
1321 const char*
const LowerDescUrl) {
1322 return compa::UpnpRegisterRootDevice3(DescUrl, Fun,
Cookie, Hnd,
1323 AddressFamily, LowerDescUrl);
1327#ifdef COMPA_HAVE_DEVICE_DESCRIPTION
1329 UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
1330 "Inside UpnpUnRegisterRootDevice\n");
1341 UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
1342 "Inside UpnpUnRegisterRootDeviceLowPower\n");
1343#ifdef COMPA_HAVE_DEVICE_GENA
1364 (
struct sockaddr*)NULL, (
char*)NULL, (
char*)NULL,
1365 (
char*)NULL, HInfo->
MaxAge);
1378#ifdef COMPA_HAVE_CTRLPT_SSDP
1381#ifdef COMPA_HAVE_WEBSERVER
1398 UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
1399 "Exiting UpnpUnRegisterRootDeviceLowPower\n");
1405#ifdef COMPA_HAVE_CTRLPT_DESCRIPTION
1412 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1413 "Inside UpnpRegisterClient \n");
1414 if (Fun == NULL || Hnd == NULL)
1429 if (HInfo == NULL) {
1433 HInfo->
HType = HND_CLIENT;
1438#ifdef COMPA_HAVE_DEVICE_SSDP
1447 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1448 "Exiting UpnpRegisterClient \n");
1460 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1461 "Inside UpnpUnRegisterClient \n");
1470#ifdef COMPA_HAVE_CTRLPT_GENA
1484 while (node != NULL) {
1498 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1499 "Exiting UpnpUnRegisterClient \n");
1505#ifdef COMPA_HAVE_DEVICE_DESCRIPTION
1519 ext = strrchr(name,
'.');
1520 if (ext == NULL || strcasecmp(ext,
".xml") != 0) {
1524 al = strrchr(name,
'/');
1539 struct sockaddr* serverAddr) {
1540 struct sockaddr_in* sa4 = (
struct sockaddr_in*)serverAddr;
1542 memset(serverAddr, 0,
sizeof(
struct sockaddr_storage));
1544 sa4->sin_family = AF_INET;
1545 inet_pton(AF_INET,
gIF_IPV4, &sa4->sin_addr);
1554 struct sockaddr* serverAddr) {
1555 struct sockaddr_in6* sa6 = (
struct sockaddr_in6*)serverAddr;
1557 memset(serverAddr, 0,
sizeof(
struct sockaddr_storage));
1559 sa6->sin6_family = AF_INET6;
1560 inet_pton(AF_INET6,
gIF_IPV6, &sa6->sin6_addr);
1565#ifdef COMPA_HAVE_DEVICE_DESCRIPTION
1567 char* description,
int config_baseURL,
1571 char* membuf = NULL;
1573 char* temp_str = NULL;
1578 time_t last_modified{};
1579 struct stat file_info;
1580 struct sockaddr_storage serverAddr;
1583 memset(aliasStr, 0,
sizeof(aliasStr));
1584 if (description == NULL)
1595 last_modified = time(NULL);
1600 umock::stdio_h.fopen_s(&fp, description,
"rb");
1602 fp = umock::stdio_h.fopen(description,
"rb");
1607 goto exit_function1;
1613 goto exit_function1;
1615 retVal = fstat(fd, &file_info);
1619 goto exit_function1;
1621 fileLen = (size_t)file_info.st_size;
1622 last_modified = file_info.st_mtime;
1623 membuf = (
char*)malloc(fileLen + (
size_t)1);
1627 goto exit_function1;
1629 num_read = umock::stdio_h.fread(membuf, (
size_t)1, fileLen, fp);
1630 if (num_read != fileLen) {
1633 goto exit_function2;
1635 membuf[fileLen] = 0;
1643 umock::stdio_h.fclose(fp);
1649 last_modified = time(NULL);
1655 if (rc != IXML_SUCCESS &&
1657 if (rc == IXML_INSUFFICIENT_MEMORY)
1663 if (config_baseURL) {
1665 strncpy(aliasStr,
"description.xml",
sizeof(aliasStr) - 1);
1673 if (strlen(temp_str) > (
LINE_SIZE - 1)) {
1677 strncpy(aliasStr, temp_str,
sizeof(aliasStr) - 1);
1679 if (AddressFamily == AF_INET) {
1687 aliasStr, last_modified, descURL);
1694 if (strlen(description) >
LINE_SIZE - 1) {
1698 strncpy(descURL, description,
LINE_SIZE - 1);
1702 assert(*xmlDoc != NULL);
1714#ifdef COMPA_HAVE_DEVICE_SSDP
1716 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1717 "Inside UpnpSendAdvertisement \n");
1722 int PowerState,
int SleepPeriod,
1723 int RegistrationState) {
1725 int retVal = 0, *ptrMx;
1729 memset(&job, 0,
sizeof(job));
1735 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1736 "Inside UpnpSendAdvertisementLowPower \n");
1758 (
struct sockaddr*)NULL, (
char*)NULL, (
char*)NULL,
1763 ptrMx = (
int*)malloc(
sizeof(
int));
1768 if (adEvent == NULL) {
1786#ifdef SSDP_PACKET_DISTRIBUTE
1792 &job, SHORT_TERM, &(adEvent->
advertise.eventId))) !=
1812 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1813 "Exiting UpnpSendAdvertisementLowPower \n");
1819#ifdef COMPA_HAVE_CTRLPT_SSDP
1821 const void* Cookie_const) {
1823 char* Target = (
char*)Target_const;
1830 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Inside UpnpSearchAsync\n");
1843 if (Target == NULL) {
1853 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Exiting UpnpSearchAsync \n");
1865#ifdef COMPA_HAVE_DEVICE_GENA
1873 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1874 "Inside UpnpSetMaxSubscriptions \n");
1891 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1892 "Exiting UpnpSetMaxSubscriptions \n");
1898#ifdef COMPA_HAVE_DEVICE_GENA
1907 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1908 "Inside UpnpSetMaxSubscriptionTimeOut\n");
1928 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1929 "Exiting UpnpSetMaxSubscriptionTimeOut\n");
1935#ifdef COMPA_HAVE_CTRLPT_GENA
1943 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Inside UpnpSubscribe\n");
1950 if (EvtUrl == NULL) {
1954 if (EvtUrl_const == NULL) {
1960 if (SubsIdTmp == NULL) {
1964 if (SubsId == NULL) {
1970 if (TimeOut == NULL) {
1987 memset(SubsId, 0,
sizeof(
Upnp_SID));
1991 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
1992 "Exiting UpnpSubscribe, retVal=%d\n", retVal);
2001#ifdef COMPA_HAVE_CTRLPT_GENA
2003 int TimeOut,
Upnp_FunPtr Fun,
const void* Cookie_const) {
2006 char* EvtUrl = (
char*)EvtUrl_const;
2009 memset(&job, 0,
sizeof(job));
2015 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2016 "Inside UpnpSubscribeAsync\n");
2026 if (EvtUrl == NULL) {
2041 if (Param == NULL) {
2048 strncpy(Param->
Url, EvtUrl,
sizeof(Param->
Url) - 1);
2051 Param->
Cookie = (
char*)Cookie_const;
2060 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2061 "Exiting UpnpSubscribeAsync\n");
2067#ifdef COMPA_HAVE_CTRLPT_GENA
2073 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Inside UpnpUnSubscribe\n");
2080 if (SubsIdTmp == NULL) {
2084 if (SubsId == NULL) {
2104 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2105 "Exiting UpnpUnSubscribe, retVal=%d\n", retVal);
2113#ifdef COMPA_HAVE_CTRLPT_GENA
2121 memset(&job, 0,
sizeof(job));
2123 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2124 "Inside UpnpUnSubscribeAsync\n");
2152 if (Param == NULL) {
2162 Param->
Cookie = (
char*)Cookie_const;
2171 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2172 "Exiting UpnpUnSubscribeAsync\n");
2178#ifdef COMPA_HAVE_CTRLPT_GENA
2185 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2186 "Inside UpnpRenewSubscription\n");
2193 if (SubsIdTmp == NULL) {
2197 if (SubsId == NULL) {
2203 if (TimeOut == NULL) {
2222 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2223 "Exiting UpnpRenewSubscription, retVal=%d\n", retVal);
2231#ifdef COMPA_HAVE_CTRLPT_GENA
2234 const void* Cookie_const) {
2239 memset(&job, 0,
sizeof(job));
2245 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2246 "Inside UpnpRenewSubscriptionAsync\n");
2270 if (Param == NULL) {
2279 Param->
Cookie = (
char*)Cookie_const;
2289 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2290 "Exiting UpnpRenewSubscriptionAsync\n");
2296#ifdef COMPA_HAVE_DEVICE_GENA
2298 const char* ServName_const,
const char** VarName_const,
2299 const char** NewVal_const,
int cVariables) {
2302 char* DevID = (
char*)DevID_const;
2303 char* ServName = (
char*)ServName_const;
2304 char** VarName = (
char**)VarName_const;
2305 char** NewVal = (
char**)NewVal_const;
2311 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Inside UpnpNotify\n");
2321 if (DevID == NULL) {
2325 if (ServName == NULL) {
2329 if (VarName == NULL || NewVal == NULL || cVariables < 0) {
2335 retVal =
genaNotifyAll(Hnd, DevID, ServName, VarName, NewVal, cVariables);
2337 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Exiting UpnpNotify\n");
2346 char* DevID = (
char*)DevID_const;
2347 char* ServName = (
char*)ServName_const;
2353 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Inside UpnpNotify \n");
2363 if (DevID == NULL) {
2367 if (ServName == NULL) {
2375 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Exiting UpnpNotify \n");
2381#ifdef COMPA_HAVE_DEVICE_GENA
2383 const char* ServName_const,
2384 const char** VarName_const,
2385 const char** NewVal_const,
int cVariables,
2390 char* DevID = (
char*)DevID_const;
2391 char* ServName = (
char*)ServName_const;
2392 char** VarName = (
char**)VarName_const;
2393 char** NewVal = (
char**)NewVal_const;
2395 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2396 "Inside UpnpAcceptSubscription\n");
2415 if (DevID == NULL) {
2421 if (ServName == NULL) {
2427 if (SubsId == NULL) {
2436 if (VarName == NULL || NewVal == NULL || cVariables < 0) {
2447 ret =
genaInitNotify(Hnd, DevID, ServName, VarName, NewVal, cVariables,
2452 "Exiting UpnpAcceptSubscription, ret = %d\n", ret);
2458 const char* ServName_const,
2463 char* DevID = (
char*)DevID_const;
2464 char* ServName = (
char*)ServName_const;
2466 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2467 "Inside UpnpAcceptSubscription\n");
2486 if (DevID == NULL) {
2492 if (ServName == NULL) {
2498 if (SubsId == NULL) {
2507 if (PropSet == NULL) {
2522 "Exiting UpnpAcceptSubscription, ret = %d.\n", ret);
2534#ifdef COMPA_HAVE_CTRLPT_SOAP
2536 const char* ServiceType_const,
const char* DevUDN_const,
2540 char* ActionURL = (
char*)ActionURL_const;
2541 char* ServiceType = (
char*)ServiceType_const;
2549 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Inside UpnpSendAction\n");
2550 if (DevUDN_const != NULL) {
2551 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2552 "non NULL DevUDN is ignored\n");
2554 DevUDN_const = NULL;
2566 if (ActionURL == NULL) {
2570 if (ServiceType == NULL || Action == NULL || RespNodePtr == NULL ||
2571 DevUDN_const != NULL) {
2576 retVal =
SoapSendAction(ActionURL, ServiceType, Action, RespNodePtr);
2578 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Exiting UpnpSendAction\n");
2584 const char* ServiceType_const,
const char* DevUDN_const,
2589 char* ActionURL = (
char*)ActionURL_const;
2590 char* ServiceType = (
char*)ServiceType_const;
2598 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Inside UpnpSendActionEx\n");
2600 if (Header == NULL) {
2602 DevUDN_const, Action, RespNodePtr);
2616 if (ActionURL == NULL) {
2619 if (ServiceType == NULL || Action == NULL || RespNodePtr == NULL) {
2626 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"Exiting UpnpSendAction \n");
2632 const char* ServiceType_const,
const char* DevUDN_const,
2634 const void* Cookie_const) {
2640 char* ActionURL = (
char*)ActionURL_const;
2645 memset(&job, 0,
sizeof(job));
2651 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2652 "Inside UpnpSendActionAsync\n");
2664 if (ActionURL == NULL) {
2668 DevUDN_const != NULL) {
2672 if (tmpStr == NULL) {
2678 if (Param == NULL) {
2686 strncpy(Param->
Url, ActionURL,
sizeof(Param->
Url) - 1);
2690 if (rc != IXML_SUCCESS) {
2693 if (rc == IXML_INSUFFICIENT_MEMORY) {
2700 Param->
Cookie = (
char*)Cookie_const;
2711 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2712 "Exiting UpnpSendActionAsync \n");
2718 const char* ServiceType_const,
2721 const void* Cookie_const) {
2726 char* ActionURL = (
char*)ActionURL_const;
2731 memset(&job, 0,
sizeof(job));
2737 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2738 "Inside UpnpSendActionExAsync\n");
2742 DevUDN_const,
Act,
Fun, Cookie_const);
2756 if (ActionURL == NULL) {
2766 if (tmpStr == NULL) {
2772 if (Param == NULL) {
2781 strncpy(Param->
Url, ActionURL,
sizeof(Param->
Url) - 1);
2784 if (retVal != IXML_SUCCESS) {
2788 if (retVal == IXML_INSUFFICIENT_MEMORY) {
2796 if (retVal != IXML_SUCCESS) {
2801 if (retVal == IXML_INSUFFICIENT_MEMORY) {
2811 Param->
Cookie = (
char*)Cookie_const;
2822 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2823 "Exiting UpnpSendActionAsync\n");
2830 const char* ActionURL_const,
2832 const void* Cookie_const) {
2836 char* ActionURL = (
char*)ActionURL_const;
2837 char*
VarName = (
char*)VarName_const;
2839 memset(&job, 0,
sizeof(job));
2845 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2846 "Inside UpnpGetServiceVarStatusAsync\n");
2858 if (ActionURL == NULL) {
2865 if (Param == NULL) {
2872 strncpy(Param->
Url, ActionURL,
sizeof(Param->
Url) - 1);
2875 Param->
Cookie = (
char*)Cookie_const;
2886 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2887 "Exiting UpnpGetServiceVarStatusAsync\n");
2894 const char* VarName_const,
DOMString* StVar) {
2898 char* ActionURL = (
char*)ActionURL_const;
2899 char* VarName = (
char*)VarName_const;
2905 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2906 "Inside UpnpGetServiceVarStatus\n");
2919 if (ActionURL == NULL) {
2922 if (VarName == NULL || StVar == NULL) {
2929 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
2930 "Exiting UpnpGetServiceVarStatus \n");
2941#ifdef COMPA_HAVE_WEBSERVER
2943 int contentLength,
int timeout) {
2947 contentType, contentLength, timeout);
2960 httpStatus, timeout);
2967 int* contentLength,
int* httpStatus,
int timeout) {
2978 httpStatus, timeout);
2984 char** contentType,
int* contentLength,
2985 int* httpStatus,
int timeout) {
2996 httpStatus, timeout);
3002 int* contentLength,
int* httpStatus,
int lowRange,
3003 int highRange,
int timeout) {
3005 httpStatus, lowRange, highRange, timeout);
3025 UpnpString* headers,
const char* contentType,
3026 int contentLength,
int timeout) {
3028 contentLength, timeout);
3040 int* contentLength,
int* httpStatus,
int timeout) {
3042 httpStatus, timeout);
3054#ifdef COMPA_HAVE_WEBSERVER
3059 if (url ==
nullptr || outBuf ==
nullptr || contentType ==
nullptr)
3071 [[maybe_unused]]
char** outBuf,
3072 [[maybe_unused]]
char* contentType) {
3078 TRACE(
"Executing UpnpDownloadXmlDoc()")
3079 if (url ==
nullptr || xmlDoc ==
nullptr) {
3087 UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
3088 "Error downloading document, retCode: %d\n", ret_code);
3092 if (strncasecmp(content_type,
"text/xml", strlen(
"text/xml"))) {
3093 UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
"Not text/xml\n");
3108 if (ret_code != IXML_SUCCESS) {
3109 if (ret_code == IXML_INSUFFICIENT_MEMORY) {
3110 UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
3111 "Out of memory, ixml error code: %d\n", ret_code);
3114 UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
3115 "Invalid Description, ixml error code: %d\n", ret_code);
3121 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
3122 "Printing the Parsed xml document \n %s\n", xml_buf);
3123 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
3124 "****************** END OF Parsed XML Doc "
3125 "*****************\n");
3128 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
3129 "Exiting UpnpDownloadXmlDoc\n");
3138#if defined(COMPA_HAVE_CTRLPT_SOAP) || defined(COMPA_HAVE_CTRLPT_GENA)
3140 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
3141 "Inside UpnpThreadDistribution \n");
3144#ifdef COMPA_HAVE_CTRLPT_GENA
3188#ifdef COMPA_HAVE_CTRLPT_SOAP
3196 Param->
Act, &actionResult);
3230 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
3231 "Exiting UpnpThreadDistribution\n");
3249 for (client = 1; client <
NUM_HANDLE; client++) {
3251 case HND_TABLE_INVALID:
3254 *client_handle_out = client;
3260 *client_handle_out = -1;
3266 [[maybe_unused]]
int AddressFamily,
3269#ifdef COMPA_HAVE_DEVICE_SSDP
3274 *device_handle_out = -1;
3278 *device_handle_out = -1;
3283 for (*device_handle_out = start; *device_handle_out <
NUM_HANDLE;
3284 (*device_handle_out)++) {
3287 if ((*HndInfo)->DeviceAf == AddressFamily) {
3297 *device_handle_out = -1;
3303 [[maybe_unused]]
int AddressFamily,
3307#ifdef COMPA_HAVE_DEVICE_SSDP
3312 *device_handle_out = -1;
3316 for (*device_handle_out = 1; *device_handle_out <
NUM_HANDLE;
3317 (*device_handle_out)++) {
3320 if ((*HndInfo)->DeviceAf == AddressFamily) {
3322 &(*HndInfo)->ServiceTable, path)) != 0) ||
3324 &(*HndInfo)->ServiceTable, path)) != 0)) {
3335 *device_handle_out = -1;
3344 if (HndInfo ==
nullptr) {
3345 UPnPsdk_LOGERR(
"MSG1097")
"No output variable for handle info "
3346 "available (HndInfo==nullptr).\n";
3348 UPnPsdk_LOGERR(
"MSG1130")
"Handle(" << Hnd <<
") out of range.\n";
3356 ret = (*HndInfo)->
HType;
3365 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
3366 "Printing information for Handle_%d\n", Hnd);
3367 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"HType_%d\n",
3369#ifdef COMPA_HAVE_DEVICE_SSDP
3370 switch (HndInfo->
HType) {
3374 UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"DescURL_%s\n",
3385#ifdef COMPA_HAVE_DEVICE_SSDP
3394#ifdef COMPA_HAVE_WEBSERVER
3396 TRACE(
"Executing UpnpSetWebServerRootDir()")
3399 if ((rootDir ==
nullptr) || (strlen(rootDir) == 0)) {
3409#ifdef COMPA_HAVE_WEBSERVER
3413 if ((corsString == NULL) || (strlen(corsString) == 0)) {
3424 const void** oldcookie) {
3430 memset(dirName, 0,
sizeof(dirName));
3436 if ((newDirName == NULL) || (strlen(newDirName) == (
size_t)0)) {
3440 if (*newDirName !=
'/') {
3441 if (strlen(newDirName) >
sizeof(dirName) - 2)
3444 strncpy(dirName + 1, newDirName,
sizeof(dirName) - 2);
3446 if (strlen(newDirName) >
sizeof(dirName) - 1)
3448 strncpy(dirName, newDirName,
sizeof(dirName) - 1);
3452 while (pCurVirtualDir != NULL) {
3454 if (strcmp(pCurVirtualDir->
dirName, dirName) == 0) {
3455 if (oldcookie != NULL)
3456 *oldcookie = pCurVirtualDir->
cookie;
3457 pCurVirtualDir->
cookie = cookie;
3461 pCurVirtualDir = pCurVirtualDir->
next;
3465 if (pNewVirtualDir == NULL) {
3468 pNewVirtualDir->
next = NULL;
3469 if (oldcookie != NULL)
3471 pNewVirtualDir->
cookie = cookie;
3472 memset(pNewVirtualDir->
dirName, 0,
sizeof(pNewVirtualDir->
dirName));
3473#ifdef UPNPLIB_PUPNP_BUG
3478 strncpy(pNewVirtualDir->
dirName, dirName,
3479 sizeof(pNewVirtualDir->
dirName) - 1);
3481 strncpy(pNewVirtualDir->
dirName, dirName,
sizeof(pNewVirtualDir->
dirName));
3483 *(pNewVirtualDir->
dirName + strlen(dirName)) = 0;
3489 while (pLast->
next != NULL) {
3490 pLast = pLast->
next;
3492 pLast->
next = pNewVirtualDir;
3507 if (dirName == NULL) {
3526 while (pCur != NULL) {
3527 if (strcmp(pCur->
dirName, dirName) == 0) {
3554 while (pCur != NULL) {
3565 TRACE(
"Executing UpnpEnableWebserver()")
3569#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.
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 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.
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 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 UpnpRegisterClient(Upnp_FunPtr Fun, const void *Cookie, UpnpClient_Handle *Hnd)
Registers a control point application with the UPnP Library.
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...
PUPNP_Api int UpnpUnRegisterClient(UpnpClient_Handle Hnd)
Unregisters a control point application, unsubscribing all active subscriptions.
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.
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.
Performs HTTP read and write messages.
#define HTTP_DEFAULT_TIMEOUT
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 FreeHandle(int Upnp_Handle)
Free handle.
int GetFreeHandle()
Get a free UPnP Unit handle.
int UpnpGetIfInfo(const std::string &a_iface="")
Retrieve local network adapter information and keep it in global variables.
Handle_Info * HandleTable[NUM_HANDLE]
UPnP Device and Control Point handle table
pthread_mutex_t sdkInit_mutex
Initialization mutex.
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.
bool is_loopback() const
Get if the socket address is a loopback address.
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 GUA port for the mini-server.
unsigned gIF_IPV6_ULA_GUA_PREFIX_LENGTH
IPv6 GUA prefix length. (extern'ed in upnp.h)
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]
IPv6 GUA buffer to contain interface IPv6 global-unicast address.
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 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 void get_server_addr(struct sockaddr *serverAddr)
Fill the sockadr with IPv4 miniserver information.
in_port_t LOCAL_PORT_V4
IPv4 local 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]
IPv4 buffer to contain interface 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]
Buffer to contain used network interface name. (extern'ed in upnp.h)
unsigned gIF_INDEX
Index/scope-id from the used network interface.
ThreadPool gMiniServerThreadPool
Mini server thread pool.
membuffer gWebserverCorsString
char gIF_IPV4_NETMASK[INET_ADDRSTRLEN]
IPv4 buffer to contain interface netmask. (extern'ed in upnp.h)
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]
IPv6 LLA buffer to contain interface address. (extern'ed in upnp.h)
int UpnpSdkDeviceregisteredV6
Global variable to denote the state of Upnp SDK IPv6 device registration.
void UpnpSetAllowLiteralHostRedirection(int enable)
Enable or disable literal IP redirection.
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.
PUPNP_API unsigned gIF_INDEX
Index/scope-id from the used network interface.
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.
PUPNP_API char gIF_IPV4[INET_ADDRSTRLEN]
IPv4 buffer to contain interface address. (extern'ed in upnp.h)
char DescURL[LINE_SIZE]
URL for the use of SSDP.
PUPNP_API char gIF_IPV6[INET6_ADDRSTRLEN]
IPv6 LLA buffer to contain interface address. (extern'ed in upnp.h)
PUPNP_API unsigned gIF_IPV6_ULA_GUA_PREFIX_LENGTH
IPv6 GUA prefix length. (extern'ed in upnp.h)
Upnp_SID SubsId
UpnpNonblockParam
#define HandleUnlock()
HandleUnlock.
IXML_Document * DescDocument
Description parsed in terms of DOM document.
PUPNP_API char gIF_IPV6_ULA_GUA[INET6_ADDRSTRLEN]
IPv6 GUA buffer to contain interface IPv6 global-unicast address.
UpnpFunName FunName
UpnpNonblockParam
int TimeOut
UpnpNonblockParam
int PowerState
Power State as defined by UPnP Low Power.
WebServerState
Possible status of the internal webserver.
PUPNP_API unsigned gIF_IPV6_PREFIX_LENGTH
IPv6 LLA prefix length. (extern'ed in upnp.h)
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.
PUPNP_API char gIF_NAME[LINE_SIZE]
Buffer to contain used network interface name. (extern'ed in upnp.h)
char VarName[NAME_SIZE]
UpnpNonblockParam
int DeviceAf
Address family: AF_INET6 or AF_INET.
char ServiceType[NAME_SIZE]
UpnpNonblockParam
PUPNP_API char gIF_IPV4_NETMASK[INET_ADDRSTRLEN]
IPv4 buffer to contain interface netmask. (extern'ed in upnp.h)
#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.