|
libUPnP
1.8.4
|
#include "config.h"#include "upnpapi.h"#include "httpreadwrite.h"#include "membuffer.h"#include "ssdplib.h"#include "soaplib.h"#include "sysdep.h"#include "ThreadPool.h"#include "UpnpStdInt.h"#include "UpnpUniStd.h"#include "uuid.h"#include "gena.h"#include "miniserver.h"#include "service_table.h"#include <sys/stat.h>#include <assert.h>#include <signal.h>#include <stdlib.h>#include <string.h>#include <sys/ioctl.h>#include <sys/param.h>#include <sys/types.h>
Macros | |
| #define | IN6_IS_ADDR_GLOBAL(a) |
| #define | IN6_IS_ADDR_ULA(a) |
Functions | |
| static int | WinsockInit (void) |
| (Windows Only) Initializes the Windows Winsock library. More... | |
| static int | UpnpInitMutexes (void) |
| Initializes the global mutexes used by the UPnP SDK. More... | |
| static int | UpnpInitThreadPools (void) |
| Initializes the global threadm pools used by the UPnP SDK. More... | |
| static int | UpnpInitPreamble (void) |
| Performs the initial steps in initializing the UPnP SDK. More... | |
| static int | UpnpInitStartServers (unsigned short DestPort) |
| Finishes initializing the UPnP SDK. More... | |
| void | PrintThreadPoolStats (ThreadPool *tp, const char *DbgFileName, int DbgLineNo, const char *msg) |
| Prints thread pool statistics. More... | |
| static int | GetFreeHandle () |
| Get a free handle. More... | |
| static int | FreeHandle (int Upnp_Handle) |
| Free handle. More... | |
| 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. More... | |
| int | UpnpGetIfInfo (const char *IfName) |
| Retrieve interface information and keep it in global variables. If NULL, we'll find the first suitable interface for operation. More... | |
| void | UpnpThreadDistribution (struct UpnpNonblockParam *Param) |
| Schedule async functions in threadpool. More... | |
| Upnp_FunPtr | GetCallBackFn (UpnpClient_Handle Hnd) |
| Get callback function ptr from a handle. More... | |
| Upnp_Handle_Type | GetClientHandleInfo (UpnpClient_Handle *client_handle_out, struct Handle_Info **HndInfo) |
| Get client handle info. More... | |
| 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. The search begins at the 'start' index, which should be 0 for the first call, then the last successful value returned. This allows listing all entries for the address family. More... | |
| 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, with a service having a controlURL or eventSubURL matching the path. More... | |
| Upnp_Handle_Type | GetHandleInfo (UpnpClient_Handle Hnd, struct Handle_Info **HndInfo) |
| Get handle information. More... | |
| int | PrintHandleInfo (UpnpClient_Handle Hnd) |
| Print handle info. More... | |
| int | getlocalhostname (char *out, size_t out_len) |
| Get local IP address. More... | |
| void | AutoAdvertise (void *input) |
| This function is a timer thread scheduled by UpnpSendAdvertisement to the send advetisement again. More... | |
| int | UpnpSetEventQueueLimits (int maxLen, int maxAge) |
Initialization and Registration | |
| int | UpnpInit (const char *HostIP, unsigned short DestPort) |
| Initializes the Linux SDK for UPnP Devices (IPv4 only). More... | |
| int | UpnpInit2 (const char *IfName, unsigned short DestPort) |
| Initializes the Linux SDK for UPnP Devices (IPv4 or IPv6). More... | |
| int | UpnpFinish (void) |
| Initializes the OpenSSL library, and the OpenSSL context for use with pupnp. More... | |
| unsigned short | UpnpGetServerPort (void) |
| Returns the internal server IPv4 UPnP listening port. More... | |
| unsigned short | UpnpGetServerPort6 (void) |
| Returns the internal server IPv6 UPnP listening port. More... | |
| char * | UpnpGetServerIpAddress (void) |
| Returns the local IPv4 listening ip address. More... | |
| char * | UpnpGetServerIp6Address (void) |
| Returns the local IPv6 listening ip address. More... | |
| char * | UpnpGetServerUlaGuaIp6Address (void) |
| int | UpnpRegisterRootDevice (const char *DescUrl, Upnp_FunPtr Callback, const void *Cookie, UpnpDevice_Handle *Hnd) |
| Registers a device application with the UPnP Library. More... | |
| int | UpnpRegisterRootDevice2 (Upnp_DescType descriptionType, const char *description, size_t bufferLen, int config_baseURL, Upnp_FunPtr Fun, const void *Cookie, UpnpDevice_Handle *Hnd) |
| Registers a device application with the UPnP Library. Similar to UpnpRegisterRootDevice, except that it also allows the description document to be specified as a file or a memory buffer. More... | |
| int | UpnpRegisterRootDevice3 (const char *DescUrl, Upnp_FunPtr Callback, const void *Cookie, UpnpDevice_Handle *Hnd, int AddressFamily) |
| Registers a device application for a specific address family with the UPnP library. More... | |
| int | UpnpRegisterRootDevice4 (const char *DescUrl, Upnp_FunPtr Callback, const void *Cookie, UpnpDevice_Handle *Hnd, int AddressFamily, const char *LowerDescUrl) |
| Registers a device application for a specific address family with the UPnP library. This function can also be used to specify a dedicated description URL to be returned for legacy CPs. More... | |
| int | UpnpUnRegisterRootDevice (UpnpDevice_Handle Hnd) |
| Unregisters a root device registered with UpnpRegisterRootDevice, UpnpRegisterRootDevice2, UpnpRegisterRootDevice3 or UpnpRegisterRootDevice4. More... | |
| int | UpnpUnRegisterRootDeviceLowPower (UpnpDevice_Handle Hnd, int PowerState, int SleepPeriod, int RegistrationState) |
| Unregisters a root device registered with UpnpRegisterRootDevice, UpnpRegisterRootDevice2, UpnpRegisterRootDevice3 or UpnpRegisterRootDevice4. More... | |
| int | UpnpRegisterClient (Upnp_FunPtr Callback, const void *Cookie, UpnpClient_Handle *Hnd) |
| Registers a control point application with the UPnP Library. More... | |
| int | UpnpUnRegisterClient (UpnpClient_Handle Hnd) |
| Unregisters a control point application, unsubscribing all active subscriptions. More... | |
| int | UpnpSetContentLength (UpnpClient_Handle Hnd, size_t contentLength) |
| int | UpnpSetMaxContentLength (size_t contentLength) |
| Sets the maximum content-length that the SDK will process on an incoming SOAP requests or responses. More... | |
Discovery | |
| int | UpnpSendAdvertisement (UpnpDevice_Handle Hnd, int Exp) |
| Sends out the discovery announcements for all devices and services for a device. More... | |
| int | UpnpSendAdvertisementLowPower (UpnpDevice_Handle Hnd, int Exp, int PowerState, int SleepPeriod, int RegistrationState) |
| Sends out the discovery announcements for all devices and services for a device. More... | |
| int | UpnpSearchAsync (UpnpClient_Handle Hnd, int Mx, const char *TTarget_constarget_const, const void *Cookie_const) |
| Searches for devices matching the given search target. More... | |
Eventing | |
| int | UpnpSetMaxSubscriptions (UpnpDevice_Handle Hnd, int MaxSubscriptions) |
| Sets the maximum number of subscriptions accepted per service. More... | |
| int | UpnpSetMaxSubscriptionTimeOut (UpnpDevice_Handle Hnd, int MaxSubscriptionTimeOut) |
| Sets the maximum time-out accepted for a subscription request or renewal. More... | |
| int | UpnpSubscribeAsync (UpnpClient_Handle Hnd, const char *PublisherUrl, int TimeOut, Upnp_FunPtr Fun, const void *Cookie) |
| Performs the same operation as UpnpSubscribe, but returns immediately and calls the registered callback function when the operation is complete. More... | |
| int | UpnpSubscribe (UpnpClient_Handle Hnd, const char *PublisherUrl, int *TimeOut, Upnp_SID SubsId) |
| Registers a control point to receive event notifications from another device. More... | |
| int | UpnpUnSubscribe (UpnpClient_Handle Hnd, const Upnp_SID SubsId) |
| Removes the subscription of a control point from a service previously subscribed to using UpnpSubscribe or UpnpSubscribeAsync. More... | |
| int | UpnpUnSubscribeAsync (UpnpClient_Handle Hnd, Upnp_SID SubsId, Upnp_FunPtr Fun, const void *Cookie) |
| Removes a subscription of a control point from a service previously subscribed to using UpnpSubscribe or UpnpSubscribeAsync, generating a callback when the operation is complete. More... | |
| int | UpnpRenewSubscription (UpnpClient_Handle Hnd, int *TimeOut, const Upnp_SID SubsId) |
| Renews a subscription that is about to expire. More... | |
| int | UpnpRenewSubscriptionAsync (UpnpClient_Handle Hnd, int TimeOut, Upnp_SID SubsId, Upnp_FunPtr Fun, const void *Cookie) |
| Renews a subscription that is about to expire, generating a callback when the operation is complete. More... | |
| int | UpnpNotify (UpnpDevice_Handle, const char *DevID, const char *ServID, const char **VarName, const char **NewVal, int cVariables) |
| Sends out an event change notification to all control points subscribed to a particular service. More... | |
| int | UpnpNotifyExt (UpnpDevice_Handle, const char *DevID, const char *ServID, IXML_Document *PropSet) |
| Similar to UpnpNotify except that it takes a DOM document for the event rather than an array of strings. More... | |
| int | UpnpAcceptSubscription (UpnpDevice_Handle Hnd, const char *DevID, const char *ServID, const char **VarName, const char **NewVal, int cVariables, const Upnp_SID SubsId) |
| Accepts a subscription request and sends out the current state of the eventable variables for a service. More... | |
| int | UpnpAcceptSubscriptionExt (UpnpDevice_Handle Hnd, const char *DevID, const char *ServID, IXML_Document *PropSet, const Upnp_SID SubsId) |
| Similar to UpnpAcceptSubscription() except that it takes a DOM document for the variables to event rather than an array of strings. More... | |
Control | |
| int | UpnpSendAction (UpnpClient_Handle Hnd, const char *ActionURL, const char *ServiceType, const char *DevUDN, IXML_Document *Action, IXML_Document **RespNode) |
| Sends a message to change a state variable in a service. More... | |
| int | UpnpSendActionEx (UpnpClient_Handle Hnd, const char *ActionURL, const char *ServiceType, const char *DevUDN, IXML_Document *Header, IXML_Document *Action, IXML_Document **RespNode) |
| Sends a message to change a state variable in a service. More... | |
| int | UpnpSendActionAsync (UpnpClient_Handle Hnd, const char *ActionURL, const char *ServiceType, const char *DevUDN, IXML_Document *Action, Upnp_FunPtr Fun, const void *Cookie) |
| Sends a message to change a state variable in a service, generating a callback when the operation is complete. More... | |
| int | UpnpSendActionExAsync (UpnpClient_Handle Hnd, const char *ActionURL, const char *ServiceType, const char *DevUDN, IXML_Document *Header, IXML_Document *Action, Upnp_FunPtr Fun, const void *Cookie) |
| Sends a message to change a state variable in a service, generating a callback when the operation is complete. More... | |
| int | UpnpGetServiceVarStatusAsync (UpnpClient_Handle Hnd, const char *ActionURL, const char *VarName, Upnp_FunPtr Fun, const void *Cookie) |
| Queries the state of a variable of a service, generating a callback when the operation is complete. More... | |
| int | UpnpGetServiceVarStatus (UpnpClient_Handle Hnd, const char *ActionURL, const char *VarName, DOMString *StVarVal) |
| Queries the state of a state variable of a service on another device. More... | |
Control Point HTTP API | |
| 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 the server if the connection to the server succeeds. More... | |
| 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 UpnpOpenHttpPost call. More... | |
| int | UpnpCloseHttpPost (void *handle, int *httpStatus, int timeout) |
| Sends and receives any pending data, closes the connection with the server, and frees memory allocated during the UpnpOpenHttpPost call. More... | |
| int | UpnpOpenHttpGet (const char *url, void **handle, char **contentType, int *contentLength, int *httpStatus, int timeout) |
| Gets a file specified in a URL. More... | |
| 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. More... | |
| int | UpnpOpenHttpGetEx (const char *url, void **handle, char **contentType, int *contentLength, int *httpStatus, int lowRange, int highRange, int timeout) |
| Gets specified number of bytes from a file specified in the URL. More... | |
| int | UpnpCancelHttpGet (void *handle) |
| Set the cancel flag of the handle parameter. More... | |
| int | UpnpCloseHttpGet (void *handle) |
| Closes the connection and frees memory that was allocated for the handle parameter. More... | |
| int | UpnpReadHttpGet (void *handle, char *buf, size_t *size, int timeout) |
| Gets specified number of bytes from a file specified in a URL. More... | |
| int | UpnpHttpGetProgress (void *handle, size_t *length, size_t *total) |
| Retrieve progress information of a http-get transfer. More... | |
| int | UpnpOpenHttpConnection (const char *url, void **handle, int timeout) |
| Opens a connection to the server. More... | |
| 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. More... | |
| int | UpnpWriteHttpRequest (void *handle, char *buf, size_t *size, int timeout) |
| Writes the content of a HTTP request initiated by a UpnpMakeHttpRequest call. The end of the content should be indicated by a call to UpnpEndHttpRequest. More... | |
| int | UpnpEndHttpRequest (void *handle, int timeout) |
| Indicates the end of a HTTP request previously made by UpnpMakeHttpRequest. More... | |
| 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. More... | |
| int | UpnpReadHttpResponse (void *handle, char *buf, size_t *size, int timeout) |
| Reads the content of a response using a connection previously created by UpnpOpenHttpConnection. More... | |
| int | UpnpCloseHttpConnection (void *handle) |
| Closes the connection created with UpnpOpenHttpConnection and frees any memory associated with the connection. More... | |
| int | UpnpDownloadUrlItem (const char *url, char **outBuf, char *contentType) |
| Downloads a file specified in a URL. More... | |
| int | UpnpDownloadXmlDoc (const char *url, IXML_Document **xmlDoc) |
| Downloads an XML document specified in a URL. More... | |
Web Server API | |
| int | UpnpAddVirtualDir (const char *dirName, const void *cookie, const void **oldcookie) |
| Adds a virtual directory mapping. More... | |
| int | UpnpRemoveVirtualDir (const char *dirName) |
| Removes a virtual directory mapping made with UpnpAddVirtualDir. More... | |
| void | UpnpRemoveAllVirtualDirs (void) |
| Removes all virtual directory mappings. More... | |
| int | UpnpEnableWebserver (int enable) |
| Enables or disables the webserver. More... | |
| int | UpnpIsWebserverEnabled (void) |
Returns TRUE if the webserver is enabled, or FALSE if it is not. More... | |
| int | UpnpVirtualDir_set_GetInfoCallback (VDCallback_GetInfo callback) |
| Sets the get_info callback function to be used to access a virtual directory. More... | |
| int | UpnpVirtualDir_set_OpenCallback (VDCallback_Open callback) |
| Sets the open callback function to be used to access a virtual directory. More... | |
| int | UpnpVirtualDir_set_ReadCallback (VDCallback_Read callback) |
| Sets the read callback function to be used to access a virtual directory. More... | |
| int | UpnpVirtualDir_set_WriteCallback (VDCallback_Write callback) |
| Sets the write callback function to be used to access a virtual directory. More... | |
| int | UpnpVirtualDir_set_SeekCallback (VDCallback_Seek callback) |
| Sets the seek callback function to be used to access a virtual directory. More... | |
| int | UpnpVirtualDir_set_CloseCallback (VDCallback_Close callback) |
| Sets the close callback function to be used to access a virtual directory. More... | |
Variables | |
| struct VirtualDirCallbacks | virtualDirCallback |
| virtualDirList * | pVirtualDirList |
| ithread_mutex_t | GlobalClientSubscribeMutex |
| ithread_rwlock_t | GlobalHndRWLock |
| ithread_mutex_t | gUUIDMutex |
| ithread_mutex_t | gSDKInitMutex = PTHREAD_MUTEX_INITIALIZER |
| TimerThread | gTimerThread |
| ThreadPool | gSendThreadPool |
| ThreadPool | gRecvThreadPool |
| ThreadPool | gMiniServerThreadPool |
| WebServerState | bWebServerState = WEB_SERVER_DISABLED |
| char | gIF_NAME [LINE_SIZE] = { '\0' } |
| char | gIF_IPV4 [INET_ADDRSTRLEN] = { '\0' } |
| char | gIF_IPV6 [INET6_ADDRSTRLEN] = { '\0' } |
| char | gIF_IPV6_ULA_GUA [INET6_ADDRSTRLEN] = { '\0' } |
| unsigned | gIF_INDEX = (unsigned)-1 |
| unsigned short | LOCAL_PORT_V4 |
| unsigned short | LOCAL_PORT_V6 |
| static void * | HandleTable [NUM_HANDLE] |
| membuffer | gDocumentRootDir |
| size_t | g_maxContentLength = DEFAULT_SOAP_CONTENT_LENGTH |
| int | g_UpnpSdkEQMaxLen = MAX_SUBSCRIPTION_QUEUED_EVENTS |
| int | g_UpnpSdkEQMaxAge = MAX_SUBSCRIPTION_EVENT_AGE |
| int | UpnpSdkInit = 0 |
| int | UpnpSdkClientRegistered = 0 |
| int | UpnpSdkDeviceRegisteredV4 = 0 |
| int | UpnpSdkDeviceregisteredV6 = 0 |
1.8.13