Go to the documentation of this file.
33 #ifdef INCLUDE_CLIENT_APIS
43 GenlibClientSubscription *sub);
51 GenlibClientSubscription *list);
61 GenlibClientSubscription **head,
74 GenlibClientSubscription *head,
87 GenlibClientSubscription *head,
int web_server_set_root_dir(const char *root_dir)
Assign the path specfied by the input const char* root_dir parameter to the global Document root dire...
Definition: webserver.c:562
int UpnpRegisterRootDevice3(const char *DescUrl, Upnp_FunPtr Callback, const void *Cookie, UpnpDevice_Handle *Hnd, int AddressFamily)
Registers a device application for a specific address family with the UPnP library.
Definition: upnpapi.c:1064
int(* VDCallback_Read)(UpnpWebFileHandle fileHnd, char *buf, size_t buflen, const void *cookie)
Read callback function prototype.
Definition: upnp.h:2575
void RemoveSubscriptionSID(Upnp_SID sid, service_info *service)
Definition: service_table.c:98
EXPORT_SPEC const char * ixmlNode_getNodeName(IXML_Node *nodeptr)
Returns the name of the Node, depending on what type of Node it is, in a read-only string.
Definition: node.c:122
void SetHTTPGetCallback(MiniServerCallback callback)
Set HTTP Get Callback.
static struct document_type_t gMediaTypeList[70]
Definition: webserver.c:229
int UpnpVirtualDir_set_WriteCallback(VDCallback_Write callback)
Sets the write callback function to be used to access a virtual directory.
Definition: upnpapi.c:4163
SOCKET ssdpReqSock6
Definition: miniserver.h:70
int UpnpGetServiceVarStatus(UpnpClient_Handle Hnd, const char *ActionURL, const char *VarName, DOMString *StVarVal)
Queries the state of a state variable of a service on another device.
Definition: upnpapi.c:2942
UpnpActionComplete object declaration.
int UpnpInitLog(void)
Initialize the log files.
Definition: upnpdebug.c:69
ThreadPool gSendThreadPool
Definition: upnpapi.c:122
char * m_string
Pointer to a dynamically allocated area that holds the NULL terminated string.
Definition: UpnpString.c:74
Definition: miniserver.h:45
int UpnpCloseHttpConnection(void *handle)
Closes the connection created with UpnpOpenHttpConnection and frees any memory associated with the co...
Definition: upnpapi.c:3167
void freeService(service_info *in)
Free's memory allocated for the various components of the service entry in the service table.
Definition: service_table.c:538
int(* VDCallback_Close)(UpnpWebFileHandle fileHnd, const void *cookie)
Close callback function prototype.
Definition: upnp.h:2649
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.
Definition: ssdp_server.c:92
int entire_msg_loaded
Definition: httpparser.h:68
UpnpStateVarRequest object declararion.
void gena_process_subscription_request(SOCKINFO *info, http_message_t *request)
Handles a subscription request from a ctrl point. The socket is not closed on return.
Definition: gena_device.c:1181
void free_URL_list(URL_list *list)
Frees the memory associated with a URL_list.
Definition: uri.c:252
@ UPNPREG_BUF_DESC
Definition: upnp.h:488
size_t g_maxContentLength
Definition: upnpapi.c:166
Upnp_DescType_e
Specifies the type of description in UpnpRegisterRootDevice2.
Definition: upnp.h:478
int g_UpnpSdkEQMaxAge
Definition: upnpapi.c:182
static ithread_mutex_t GlobalDebugMutex
Definition: upnpdebug.c:52
http_method_t request_method
Definition: httpparser.h:186
EXPORT_SPEC void ixmlNodeList_free(IXML_NodeList *nList)
Frees a NodeList object.
Definition: nodeList.c:143
int TPAttrInit(ThreadPoolAttr *attr)
Initializes thread pool attributes. Sets values to defaults defined in ThreadPool....
Definition: ThreadPool.c:1055
int sock_make_blocking(SOCKET sock)
Make socket blocking.
Definition: sock.c:277
void freeServiceList(service_info *head)
Free's memory allocated for the various components of each service entry in the service table.
Definition: service_table.c:581
void SetSoapCallback(MiniServerCallback callback)
Set SOAP Callback.
@ UPNP_EVENT_SUBSCRIPTION_REQUEST
Definition: Callback.h:83
int UpnpOpenHttpGetProxy(const char *url, const char *proxy_str, void **handle, char **contentType, int *contentLength, int *httpStatus, int timeout)
Gets a file specified in a URL through the specified proxy.
Definition: upnpapi.c:3059
UpnpFileInfo object declararion.
#define UPNP_E_SOCKET_BIND
The SDK had a problem binding a socket to a network interface.
Definition: upnp.h:267
int rc
Definition: upnptools.c:69
Definition: ssdplib.h:144
int UpnpOpenHttpPost(const char *url, void **handle, const char *contentType, int contentLength, int timeout)
Makes an HTTP POST request message, opens a connection to the server and sends the POST request to th...
Definition: upnpapi.c:2998
struct sockaddr_storage foreign_sockaddr
Definition: miniserver.c:75
int genaUnSubscribe(UpnpClient_Handle client_handle, const UpnpString *in_sid)
Unsubscribes a SID.
Definition: gena_ctrlpt.c:457
subscription * GetSubscriptionSID(const Upnp_SID sid, service_info *service)
Return the subscription from the service table that matches const Upnp_SID sid value.
Definition: service_table.c:123
int membuffer_set_size(membuffer *m, size_t new_length)
Increases or decreases buffer cap so that at least 'new_length' bytes can be stored.
Definition: membuffer.c:104
Definition: upnp_timeout.h:45
#define UPNP_E_FILE_NOT_FOUND
The filename passed to one of the device registration functions was not found or was not accessible.
Definition: upnp.h:350
int UpnpSdkClientRegistered
Definition: upnpapi.c:190
int TPAttrSetMinThreads(ThreadPoolAttr *attr, int minThreads)
Sets the min threads for the thread pool attributes.
Definition: ThreadPool.c:1116
uint16_t miniStopSockPort
Definition: miniserver.c:89
static void GenaAutoRenewSubscription(IN void *input)
This is a thread function to send the renewal just before the subscription times out.
Definition: gena_ctrlpt.c:67
static UPNP_INLINE void glob_alias_init(void)
Initialize the global XML document. Allocate buffers for the XML document.
Definition: webserver.c:360
A thread pool similar to the thread pool in the UPnP SDK.
Definition: ThreadPool.h:213
int UpnpRegisterRootDevice(const char *DescUrl, Upnp_FunPtr Callback, const void *Cookie, UpnpDevice_Handle *Hnd)
Registers a device application with the UPnP Library.
Definition: upnpapi.c:763
service_table ServiceTable
Definition: upnpapi.h:106
EXPORT_SPEC char * ixmlPrintNode(IXML_Node *doc)
Renders a Node and all sub-elements into an XML text representation.
Definition: ixml.c:365
EXPORT_SPEC IXML_Node * ixmlNode_getFirstChild(IXML_Node *nodeptr)
Retrieves the first child Node of a Node.
Definition: node.c:307
int SearchByTarget(int Hnd, int Mx, char *St, void *Cookie)
Creates and send the search request for a specific URL.
Definition: ssdp_ctrlpt.c:545
Represents a list of URLs as in the "callback" header of SUBSCRIBE message in GENA....
Definition: uri.h:149
VDCallback_Close close
Definition: VirtualDir.h:57
int UpnpSetContentLength(UpnpClient_Handle Hnd, size_t contentLength)
Definition: upnpapi.c:4201
void UpnpPrintf(Upnp_LogLevel DLevel, Dbg_Module Module, const char *DbgFileName, int DbgLineNo, const char *FmtStr,...)
Prints the debug statement either on the standard output or log file along with the information from ...
Definition: upnpdebug.c:127
#define UPNP_E_SUBSCRIBE_UNACCEPTED
A subscription request was rejected from the remote side.
Definition: upnp.h:326
Upnp_Handle_Type GetHandleInfo(UpnpClient_Handle Hnd, struct Handle_Info **HndInfo)
Get handle information.
Definition: upnpapi.c:3855
int UpnpSetMaxSubscriptions(UpnpDevice_Handle Hnd, int MaxSubscriptions)
Sets the maximum number of subscriptions accepted per service.
Definition: upnpapi.c:1814
EXPORT_SPEC void ixmlFreeDOMString(char *buf)
Frees a DOMString.
time_t last_modified
Definition: webserver.c:98
#define UPNP_E_SOCKET_CONNECT
The SDK had a problem connecting to a remote host.
Definition: upnp.h:277
Definition: ThreadPool.h:141
SOCKET socket
Definition: sock.h:62
static int get_port(SOCKET sockfd, uint16_t *port)
Returns port to which socket, sockfd, is bound.
Definition: miniserver.c:458
void * ListDelNode(LinkedList *list, ListNode *dnode, int freeItem)
Removes a node from the list. The memory for the node is freed.
Definition: LinkedList.c:177
Represents a host port: e.g. "127.127.0.1:80" text is a token pointing to the full string representat...
Definition: uri.h:126
static struct xml_alias_t gAliasDoc
Definition: webserver.c:235
void printService(service_info *service, Upnp_LogLevel level, Dbg_Module module)
For debugging purposes prints information from the service passed into the function.
Definition: service_table.c:396
#define MEMBUF_DEF_SIZE_INC
Definition: membuffer.h:66
char Upnp_SID[44]
Holds the subscription identifier for a subscription between a client and a device.
Definition: upnp.h:445
UpnpString * UpnpString_dup(const UpnpString *p)
Copy Constructor.
Definition: UpnpString.c:117
int UpnpAcceptSubscription(UpnpDevice_Handle Hnd, const char *DevID, const char *ServID, const char **VarName, const char **NewVal, int cVariables, const Upnp_SID SubsId)
Accepts a subscription request and sends out the current state of the eventable variables for a servi...
Definition: upnpapi.c:2380
char LowerDescURL[LINE_SIZE]
Definition: upnpapi.h:88
int UpnpCloseHttpGet(void *handle)
Closes the connection and frees memory that was allocated for the handle parameter.
Definition: upnpapi.c:3104
static void ToUpperCase(char *s)
Converts input string to upper case.
Definition: webserver.c:655
int UpnpRenewSubscription(UpnpClient_Handle Hnd, int *TimeOut, const Upnp_SID SubsId)
Renews a subscription that is about to expire.
Definition: upnpapi.c:2151
IXML_NodeList * ServiceList
Definition: upnpapi.h:104
int sock_read(SOCKINFO *info, char *buffer, size_t bufsize, int *timeoutSecs)
Reads data on socket in sockinfo.
Definition: sock.c:266
int get_ssdp_sockets(MiniServerSockArray *out)
Creates the IPv4 and IPv6 ssdp sockets required by the control point and device operation.
Definition: ssdp_server.c:1165
int status_code
Definition: httpparser.h:188
ThreadPool gMiniServerThreadPool
Definition: upnpapi.c:128
void UpnpSetLogLevel(Upnp_LogLevel log_level)
Set the log level (see Upnp_LogLevel).
Definition: upnpdebug.c:85
void(* free_routine)(void *arg)
Definition: ThreadPool.h:135
SOCKET miniServerSock4
Definition: miniserver.h:47
SOCKET ssdpSock4
Definition: miniserver.h:53
static FILE * InfoFileHnd
Definition: upnpdebug.c:61
int sock_write(SOCKINFO *info, const char *buffer, size_t bufsize, int *timeoutSecs)
Writes data on the socket in sockinfo.
Definition: sock.c:271
Definition: httpparser.h:213
int UpnpDownloadXmlDoc(const char *url, IXML_Document **xmlDoc)
Downloads an XML document specified in a URL.
Definition: upnpapi.c:3190
int gena_validate_delivery_urls(SOCKINFO *info, URL_list *url_list)
Validate that the URLs passed by the user are on the same network segment than the device.
Definition: gena_device.c:1127
int UpnpSendActionExAsync(UpnpClient_Handle Hnd, const char *ActionURL, const char *ServiceType, const char *DevUDN, IXML_Document *Header, IXML_Document *Action, Upnp_FunPtr Fun, const void *Cookie)
Sends a message to change a state variable in a service, generating a callback when the operation is ...
Definition: upnpapi.c:2751
static MiniServerState gMServState
Definition: miniserver.c:94
int UpnpClient_Handle
Returned when a control point application registers with UpnpRegisterClient.
Definition: upnp.h:426
int UpnpAcceptSubscriptionExt(UpnpDevice_Handle Hnd, const char *DevID, const char *ServID, IXML_Document *PropSet, const Upnp_SID SubsId)
Similar to UpnpAcceptSubscription() except that it takes a DOM document for the variables to event ra...
Definition: upnpapi.c:2459
void soap_device_callback(http_parser_t *parser, http_message_t *request, SOCKINFO *info)
This is a callback called by minisever after receiving the request from the control point....
Definition: soap_device.c:701
static int ScheduleGenaAutoRenew(IN int client_handle, IN int TimeOut, IN GenlibClientSubscription *sub)
Schedules a job to renew the subscription just before time out.
Definition: gena_ctrlpt.c:132
@ UPNP_EVENT_RENEWAL_COMPLETE
Definition: Callback.h:93
int genaUnregisterClient(UpnpClient_Handle client_handle)
Unsubcribes all the outstanding subscriptions and cleans the subscription list.
Definition: gena_ctrlpt.c:411
#define UPNP_E_INVALID_ACTION
The SOAP action message is invalid.
Definition: upnp.h:182
void UpnpRemoveAllVirtualDirs(void)
Removes all virtual directory mappings.
Definition: upnpapi.c:4055
static const char * infoFileName
Definition: upnpdebug.c:67
#define UPNP_E_INVALID_PARAM
One or more of the parameters passed to the function is not valid.
Definition: upnp.h:110
struct sockaddr_storage foreign_sockaddr
Definition: sock.h:64
int UpnpSendAdvertisementLowPower(UpnpDevice_Handle Hnd, int Exp, int PowerState, int SleepPeriod, int RegistrationState)
Sends out the discovery announcements for all devices and services for a device.
Definition: upnpapi.c:1645
IXML_Document * DescDocument
Definition: upnpapi.h:100
EXPORT_SPEC const char * ixmlNode_getNodeValue(IXML_Node *nodeptr)
Returns the value of the Node as a string.
Definition: node.c:253
void print_http_headers(http_message_t *hmsg)
Print the HTTP headers.
Definition: httpparser.c:2199
int http_OpenHttpConnection(const char *url_str, void **Handle, int timeout)
Opens a connection to the server.
Definition: httpreadwrite.c:1103
int UpnpGetServiceVarStatusAsync(UpnpClient_Handle Hnd, const char *ActionURL, const char *VarName, Upnp_FunPtr Fun, const void *Cookie)
Queries the state of a variable of a service, generating a callback when the operation is complete.
Definition: upnpapi.c:2873
void linecopylen(char dest[LINE_SIZE], const char *src, size_t srclen)
Determine if the srclen passed in paramter is less than the permitted LINE_SIZE. If it is use the pas...
Definition: util.c:60
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,...
Definition: upnpapi.c:923
@ MSERV_STOPPING
Definition: miniserver.c:85
int remove_escaped_chars(char *in, size_t *size)
Removes http escaped characters such as: "%20" and replaces them with their character representation....
void printServiceList(service_info *service, Upnp_LogLevel level, Dbg_Module module)
For debugging purposes prints information of each service from the service table passed into the func...
Definition: service_table.c:453
char * buf
Definition: membuffer.h:58
void(* MiniServerCallback)(http_parser_t *parser, http_message_t *request, SOCKINFO *info)
Definition: miniserver.h:75
int TPAttrSetJobsPerThread(ThreadPoolAttr *attr, int jobsPerThread)
Sets the jobs per thread ratio.
Definition: ThreadPool.c:1143
int UpnpOpenHttpGetEx(const char *url, void **handle, char **contentType, int *contentLength, int *httpStatus, int lowRange, int highRange, int timeout)
Gets specified number of bytes from a file specified in the URL.
Definition: upnpapi.c:3082
int UpnpVirtualDir_set_GetInfoCallback(VDCallback_GetInfo callback)
Sets the get_info callback function to be used to access a virtual directory.
Definition: upnpapi.c:4124
int UpnpRemoveVirtualDir(const char *dirName)
Removes a virtual directory mapping made with UpnpAddVirtualDir.
Definition: upnpapi.c:4006
#define UPNP_E_INVALID_SERVICE
The device ID/service ID pair does not refer to a valid service.
Definition: upnp.h:164
#define UPNP_E_LISTEN
The SDK had a problem setting the socket to listen for incoming connections.
Definition: upnp.h:295
int TPAttrSetMaxJobsTotal(ThreadPoolAttr *attr, int maxJobsTotal)
Sets the maximum number jobs that can be qeued totally.
Definition: ThreadPool.c:1170
#define RESERVED
Definition: uri.h:80
int copy_subscription(subscription *in, subscription *out)
Makes a copy of the subscription.
Definition: service_table.c:62
@ UPNP_EVENT_UNSUBSCRIBE_COMPLETE
Definition: Callback.h:103
int(* Upnp_FunPtr)(Upnp_EventType EventType, const void *Event, void *Cookie)
Definition: Callback.h:145
#define UPNP_E_OUTOF_SOCKET
The SDK cannot create any more sockets.
Definition: upnp.h:287
service_info * FindServiceControlURLPath(service_table *table, const char *controlURLPath)
Traverses the service table and finds the node whose control URL Path matches a know value.
Definition: service_table.c:348
void error_respond(SOCKINFO *info, int error_code, http_message_t *hmsg)
Sends an error message to the control point in the case of incorrect GENA requests.
ListNode * ListFind(LinkedList *list, ListNode *start, void *item)
Finds the specified item in the list.
Definition: LinkedList.c:272
#define UpnpCloseSocket
Definition: UpnpInet.h:57
static size_t parse_uric(const char *in, size_t max, token *out)
Parses a string of uric characters starting at in[0] as defined in http://www.ietf....
Definition: uri.c:171
@ PARSE_OK
Definition: httpparser.h:161
int UpnpRegisterClient(Upnp_FunPtr Callback, const void *Cookie, UpnpClient_Handle *Hnd)
Registers a control point application with the UPnP Library.
Definition: upnpapi.c:1308
SOCKET miniServerSock6
Definition: miniserver.h:49
static int respond_ok(SOCKINFO *info, int time_out, subscription *sub, http_message_t *request)
Returns OK message in the case of a subscription request.
Definition: gena_device.c:969
int membuffer_insert(membuffer *m, const void *buf, size_t buf_len, size_t index)
Allocates memory for the new data to be inserted. Does memory management by moving the data from the ...
Definition: membuffer.c:212
void namecopy(char dest[NAME_SIZE], const char *src)
Copy no of bytes spcified by the NAME_SIZE constant, from the source buffer. Null terminate the desti...
Definition: util.c:53
UpnpDiscovery object declararion.
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....
Definition: upnpapi.c:3782
Data structure representing the DOM Document.
Definition: ixml.h:198
void UpnpActionComplete_delete(UpnpActionComplete *p)
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....
Definition: upnpapi.c:1080
int getSubElement(const char *element_name, IXML_Node *node, IXML_Node **out)
Traverses through a list of XML nodes to find the node with the known element name.
Definition: service_table.c:678
static int Check_Connect_And_Wait_Connection(SOCKET sock, int connect_res)
Checks socket connection and wait if it is not connected. It should be called just after connect.
Definition: httpreadwrite.c:93
EXPORT_SPEC int ixmlNode_appendChild(IXML_Node *nodeptr, IXML_Node *newChild)
Appends a child Node to the list of children of a Node.
Definition: node.c:606
@ UPNP_EVENT_SUBSCRIPTION_EXPIRED
Definition: Callback.h:115
int memptr_cmp(memptr *m, const char *s)
Compares characters of strings passed for number of bytes. If equal for the number of bytes,...
Definition: membuffer.c:63
@ PARSE_INCOMPLETE_ENTITY
Definition: httpparser.h:157
int sock_destroy(SOCKINFO *info, int ShutdownMethod)
Associates an SSL object with the socket and begins the client-side SSL/TLS handshake.
Definition: sock.c:118
memptr entity
Definition: httpparser.h:205
unsigned short UpnpGetServerPort(void)
Returns the internal server IPv4 UPnP listening port.
Definition: upnpapi.c:659
int UpnpSdkInit
Definition: upnpapi.c:186
int membuffer_assign_str(membuffer *m, const char *c_str)
Wrapper function for membuffer_assign().
Definition: membuffer.c:195
DOMString getElementValue(IXML_Node *node)
Returns the clone of the element value.
Definition: service_table.c:645
int TimerThreadShutdown(TimerThread *timer)
Shutdown the timer thread.
Definition: TimerThread.c:352
@ UPNPREG_URL_DESC
Definition: upnp.h:480
static char * StrTok(char **Src, const char *Del)
Finds next token in a string.
Definition: webserver.c:707
int UpnpUnSubscribeAsync(UpnpClient_Handle Hnd, Upnp_SID SubsId, Upnp_FunPtr Fun, const void *Cookie)
Removes a subscription of a control point from a service previously subscribed to using UpnpSubscribe...
Definition: upnpapi.c:2083
int TPJobSetPriority(ThreadPoolJob *job, ThreadPriority priority)
Sets the max threads for the thread pool attributes.
Definition: ThreadPool.c:1083
#define UPNP_E_ALREADY_REGISTERED
A client or a device is already registered.
Definition: upnp.h:222
void UpnpString_delete(UpnpString *p)
Destructor.
Definition: UpnpString.c:103
int UpnpWriteHttpPost(void *handle, char *buf, size_t *size, int timeout)
Sends a request to a server to copy the contents of a buffer to the URI specified in the UpnpOpenHttp...
Definition: upnpapi.c:3014
Definition: membuffer.h:47
Structure to maintain a error code and string associated with the error code.
Definition: upnptools.c:67
size_t length
Definition: membuffer.h:51
#define PRIzd
Supply the PRId64 printf() macro.
Definition: UpnpGlobal.h:116
void UpnpString_clear(UpnpString *p)
Clears the string, sets its size to zero.
Definition: UpnpString.c:188
void UpnpThreadDistribution(struct UpnpNonblockParam *Param)
Schedule async functions in threadpool.
Definition: upnpapi.c:3646
int UpnpVirtualDir_set_ReadCallback(VDCallback_Read callback)
Sets the read callback function to be used to access a virtual directory.
Definition: upnpapi.c:4150
int is_escaped(const char *in)
Returns a 1 if a char[3] sequence is ESCAPED as defined in http://www.ietf.org/rfc/rfc2396....
Definition: uri.c:124
EXPORT_SPEC IXML_Element * ixmlDocument_createElement(IXML_Document *doc, const char *tagName)
Creates a new Element node with the given tag name.
WebServerState bWebServerState
Definition: upnpapi.c:131
uri_type uri
Definition: httpparser.h:184
SOCKET miniServerStopSock
Definition: miniserver.h:51
#define UPNP_DEFAULT_LOG_LEVEL
Definition: upnpdebug.h:94
int UpnpAddVirtualDir(const char *dirName, const void *cookie, const void **oldcookie)
Adds a virtual directory mapping.
Definition: upnpapi.c:3937
Definition: VirtualDir.h:12
void SetGenaCallback(MiniServerCallback callback)
Set GENA Callback.
SsdpSearchType
Definition: ssdplib.h:66
membuffer name
Definition: webserver.c:94
UpnpActionRequest object declaration.
void UpnpString_assign(UpnpString *p, const UpnpString *q)
Assignment operator.
Definition: UpnpString.c:138
int UpnpInit2(const char *IfName, unsigned short DestPort)
Initializes the Linux SDK for UPnP Devices (IPv4 or IPv6).
Definition: upnpapi.c:460
int TimerThreadSchedule(TimerThread *timer, time_t timeout, TimeoutType type, ThreadPoolJob *job, Duration duration, int *id)
Schedules an event to run at a specified time.
Definition: TimerThread.c:245
int UpnpReadHttpGet(void *handle, char *buf, size_t *size, int timeout)
Gets specified number of bytes from a file specified in a URL.
Definition: upnpapi.c:3110
#define UPNP_E_SUCCESS
The operation completed successfully.
Definition: upnp.h:97
int UpnpEndHttpRequest(void *handle, int timeout)
Indicates the end of a HTTP request previously made by UpnpMakeHttpRequest.
Definition: upnpapi.c:3145
#define UPNP_E_OUTOF_HANDLE
The SDK does not have any more space for additional handles.
Definition: upnp.h:117
static int CreateHTTPRangeResponseHeader(char *ByteRangeSpecifier, off_t FileLength, struct SendInstruction *Instr)
Fills in the Offset, read size and contents to send out as an HTTP Range Response.
Definition: webserver.c:790
void membuffer_init(membuffer *m)
Wrapper to membuffer_initialize().
Definition: membuffer.c:152
#define UPNP_E_INVALID_ARGUMENT
One or more of the parameters passed to a function is invalid.
Definition: upnp.h:344
int TPAttrSetStackSize(ThreadPoolAttr *attr, size_t stackSize)
Sets the stack size for the thread pool attributes.
Definition: ThreadPool.c:1125
#define UPNP_INLINE
Declares an inline function.
Definition: UpnpGlobal.h:99
void free_client_subscription(GenlibClientSubscription *sub)
Free memory allocated for client subscription data.
Definition: client_table.c:22
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.
Definition: httpreadwrite.c:1162
size_t m_length
Length of the string.
Definition: UpnpString.c:71
const char * content_type
Definition: webserver.c:87
int web_server_init()
Initilialize the different documents. Initialize the memory for root directory for web server....
Definition: webserver.c:467
int UpnpUnRegisterRootDevice(UpnpDevice_Handle Hnd)
Unregisters a root device registered with UpnpRegisterRootDevice, UpnpRegisterRootDevice2,...
Definition: upnpapi.c:1226
static int create_url_list(memptr *url_list, URL_list *out)
Function to parse the Callback header value in subscription requests.
Definition: gena_device.c:1037
int UpnpVirtualDir_set_CloseCallback(VDCallback_Close callback)
Sets the close callback function to be used to access a virtual directory.
Definition: upnpapi.c:4189
Definition: membuffer.h:56
Buffer used in parsinghttp messages, urls, etc. generally this simply holds a pointer into a larger a...
Definition: uri.h:117
int DeviceAf
Definition: upnpapi.h:112
@ PARSE_CONTINUE_1
Definition: httpparser.h:165
@ UPNP_EVENT_RECEIVED
Definition: Callback.h:88
#define UPNP_E_INVALID_URL
An URL passed into the function is invalid.
Definition: upnp.h:152
int UpnpUnSubscribe(UpnpClient_Handle Hnd, const Upnp_SID SubsId)
Removes the subscription of a control point from a service previously subscribed to using UpnpSubscri...
Definition: upnpapi.c:2035
#define UPNP_E_FINISH
UpnpInit2 has not been called, or UpnpFinish has already been called.
Definition: upnp.h:189
int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionPtr, int combo)
Call this function to initialize the UPnP library and start the TV Control Point. This function creat...
Definition: tv_ctrlpt.c:1216
static int gena_subscribe(IN const UpnpString *url, INOUT int *timeout, IN const UpnpString *renewal_sid, OUT UpnpString *sid)
Subscribes or renew subscription.
Definition: gena_ctrlpt.c:269
char gIF_IPV6[INET6_ADDRSTRLEN]
Definition: upnpapi.c:143
@ UPNP_CONTROL_GET_VAR_COMPLETE
Definition: Callback.h:41
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.
Definition: upnpapi.c:1593
static UPNP_INLINE int get_content_type(const char *filename, OUT UpnpFileInfo *fileInfo)
Based on the extension, clones an XML string based on type and content subtype. If content type and s...
Definition: webserver.c:314
static int genaNotify(char *headers, char *propertySet, subscription *sub)
Function to Notify a particular subscription of a particular event.
Definition: gena_device.c:254
int UpnpIsWebserverEnabled(void)
Returns TRUE if the webserver is enabled, or FALSE if it is not.
Definition: upnpapi.c:4114
static void free_notify_struct(notify_thread_struct *input)
Frees memory used in notify_threads if the reference count is 0, otherwise decrements the refrence co...
Definition: gena_device.c:148
EXPORT_SPEC char * ixmlCloneDOMString(const char *src)
Clones an existing DOMString.
SOCKET ssdpReqSock4
Definition: miniserver.h:67
char gIF_NAME[LINE_SIZE]
Definition: upnpapi.c:134
Definition: strintmap.h:41
int(* VDCallback_Write)(UpnpWebFileHandle fileHnd, char *buf, size_t buflen, const void *cookie)
Write callback function prototype.
Definition: upnp.h:2598
TimerThread gTimerThread
Definition: upnpapi.c:119
static int parse_hostport(const char *in, unsigned short int defaultPort, hostport_type *out)
Parses a string representing a host and port (e.g. "127.127.0.1:80" or "localhost") and fills out a h...
Definition: uri.c:323
static UPNP_INLINE int notify_send_and_recv(uri_type *destination_url, membuffer *mid_msg, char *propertySet, http_parser_t *response)
Sends the notify message and returns a reply.
Definition: gena_device.c:170
#define UPNP_E_FILE_READ_ERROR
An error happened while reading a file.
Definition: upnp.h:355
size_t capacity
Definition: membuffer.h:62
#define UPNP_E_NOT_FOUND
The response to a SOAP request did not contain the required XML constructs.
Definition: upnp.h:370
GenlibClientSubscription object declararion.
int membuffer_assign(membuffer *m, const void *buf, size_t buf_len)
Allocate memory to membuffer *m and copy the contents of the in parameter const void *buf.
Definition: membuffer.c:170
#define UPNP_E_SOCKET_ERROR
Generic socket error code for conditions not covered by other error codes.
Definition: upnp.h:311
int StartMiniServer(uint16_t *listen_port4, uint16_t *listen_port6)
Initialize the sockets functionality for the Miniserver.
Definition: miniserver.c:862
static UPNP_INLINE int search_extension(const char *extension, const char **con_type, const char **con_subtype)
Based on the extension, returns the content type and content subtype.
Definition: webserver.c:271
int sock_make_no_blocking(SOCKET sock)
Make socket non-blocking.
Definition: sock.c:294
int UpnpDownloadUrlItem(const char *url, char **outBuf, char *contentType)
Downloads a file specified in a URL.
Definition: upnpapi.c:3173
Definition: TimerThread.h:68
GenlibClientSubscription * ClientSubList
Definition: upnpapi.h:118
void web_server_destroy(void)
Release memory allocated for the global web server root directory and the global XML document....
Definition: webserver.c:495
int UpnpSdkDeviceregisteredV6
Definition: upnpapi.c:198
EXPORT_SPEC void ixmlDocument_free(IXML_Document *doc)
Frees a Document object and all Nodes associated with it.
Definition: document.c:54
#define UPNP_E_TIMEDOUT
Too much time elapsed before the required number of bytes were sent or received over a socket.
Definition: upnp.h:303
struct s_UpnpActionComplete UpnpActionComplete
Definition: TemplateInclude.h:136
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.
Definition: httpreadwrite.c:1256
#define SOCKET_ERROR
Definition: UpnpInet.h:54
int UpnpSendAction(UpnpClient_Handle Hnd, const char *ActionURL, const char *ServiceType, const char *DevUDN, IXML_Document *Action, IXML_Document **RespNode)
Sends a message to change a state variable in a service.
Definition: upnpapi.c:2544
char * Cookie
Definition: upnpapi.h:78
char * membuffer_detach(membuffer *m)
Definition: membuffer.c:273
size_t amount_discarded
Definition: httpparser.h:194
int UpnpMakeHttpRequest(Upnp_HttpMethod method, const char *url, void *handle, UpnpString *headers, const char *contentType, int contentLength, int timeout)
Makes a HTTP request using a connection previously created by UpnpOpenHttpConnection.
Definition: upnpapi.c:3129
int copy_URL_list(URL_list *in, URL_list *out)
Copies one URL_list into another.
Definition: uri.c:214
int http_EndHttpRequest(void *Handle, int timeout)
Indicates the end of a HTTP request previously made by UpnpMakeHttpRequest.
Definition: httpreadwrite.c:1238
void AutoAdvertise(void *input)
This function is a timer thread scheduled by UpnpSendAdvertisement to the send advetisement again.
Definition: upnpapi.c:3910
Upnp_Handle_Type GetClientHandleInfo(UpnpClient_Handle *client_handle_out, struct Handle_Info **HndInfo)
Get client handle info.
Definition: upnpapi.c:3760
Definition: miniserver.c:71
int MaxSubscriptionTimeOut
Definition: upnpapi.h:110
int DebugAtThisLevel(Upnp_LogLevel DLevel, Dbg_Module Module)
Returns true if debug output should be done in this module.
Definition: upnpdebug.c:111
#define INVALID_SOCKET
Definition: UpnpInet.h:51
parse_status_t
Definition: httpparser.h:151
static int GetFreeHandle()
Get a free handle.
Definition: upnpapi.c:717
ListNode * ListNext(LinkedList *list, ListNode *node)
Returns the next item in the list.
Definition: LinkedList.c:245
Definition: LinkedList.h:61
int PrintHandleInfo(UpnpClient_Handle Hnd)
Print handle info.
Definition: upnpapi.c:3882
int UpnpHttpGetProgress(void *handle, size_t *length, size_t *total)
Retrieve progress information of a http-get transfer.
Definition: upnpapi.c:3116
Definition: webserver.c:92
ListNode * ListHead(LinkedList *list)
Returns the head of the list.
Definition: LinkedList.c:219
static void alias_release(struct xml_alias_t *alias)
Release the XML document referred to by the input parameter. Free the allocated buffers associated wi...
Definition: webserver.c:401
static int FreeHandle(int Upnp_Handle)
Free handle.
Definition: upnpapi.c:735
int UpnpString_cmp(UpnpString *p, UpnpString *q)
Compares two strings for equality. Case matters.
Definition: UpnpString.c:195
int SOCKET
Definition: UpnpInet.h:48
static int isFileInVirtualDir(char *filePath, const void **cookie)
Compares filePath with paths from the list of virtual directory lists.
Definition: webserver.c:614
void PrintThreadPoolStats(ThreadPool *tp, const char *DbgFileName, int DbgLineNo, const char *msg)
Prints thread pool statistics.
Definition: upnpapi.c:529
static int GetNextRange(char **SrcRangeStr, off_t *FirstByte, off_t *LastByte)
Returns a range of integers from a string.
Definition: webserver.c:736
unsigned short LOCAL_PORT_V6
Definition: upnpapi.c:155
struct s_UpnpString UpnpString
Type of the string objects inside libupnp.
Definition: UpnpString.h:38
ListNode * ListAddTail(LinkedList *list, void *item)
Adds a node to the tail of the list. Node gets added immediately before list.tail.
Definition: LinkedList.c:119
MiniServerState
Definition: miniserver.c:79
EXPORT_SPEC IXML_Node * ixmlDocument_createTextNode(IXML_Document *doc, const char *data)
Creates a new Text node with the given data.
static UPNP_INLINE int get_alias(const char *request_file, struct xml_alias_t *alias, UpnpFileInfo *info)
Compare the files names between the one on the XML alias the one passed in as the input parameter....
Definition: webserver.c:588
static UPNP_INLINE void media_list_init(void)
Decodes list and stores it in gMediaTypeList.
Definition: webserver.c:242
Definition: ThreadPool.h:164
EXPORT_SPEC IXML_Node * ixmlNodeList_item(IXML_NodeList *nList, unsigned long index)
Retrieves a Node from a NodeList specified by a numerical index.
Definition: nodeList.c:54
token text
Definition: uri.h:128
Data structure common to all types of nodes.
Definition: ixml.h:173
const char * UpnpString_get_String(const UpnpString *p)
Returns the pointer to char.
Definition: UpnpString.c:159
static void genaNotifyThread(void *input)
Thread job to Notify a control point.
Definition: gena_device.c:311
char * buf
Definition: membuffer.h:49
service_info * FindServiceId(service_table *table, const char *serviceId, const char *UDN)
Traverses through the service table and returns a pointer to the service node that matches a known se...
Definition: service_table.c:259
int ListInit(LinkedList *list, cmp_routine cmp_func, free_function free_func)
Initializes LinkedList. Must be called first and only once for List.
Definition: LinkedList.c:84
const char * rcError
Definition: upnptools.c:71
#define UPNP_E_INVALID_HANDLE
The handle passed to a function is not a recognized as a valid handle.
Definition: upnp.h:102
int token_string_casecmp(token *in1, const char *in2)
Compares buffer in the token object with the buffer in in2.
Definition: uri.c:289
int UpnpSubscribe(UpnpClient_Handle Hnd, const char *PublisherUrl, int *TimeOut, Upnp_SID SubsId)
Registers a control point to receive event notifications from another device.
Definition: upnpapi.c:1964
void membuffer_delete(membuffer *m, size_t index, size_t num_bytes)
Shrink the size of the buffer depending on the current size of the bufer and te input parameters....
Definition: membuffer.c:240
int http_SendMessage(SOCKINFO *info, int *TimeOut, const char *fmt,...)
Sends a message to the destination based on the format parameter.
Definition: httpreadwrite.c:437
size_t size_inc
Definition: membuffer.h:64
void print_uri(uri_type *in)
Function useful in debugging for printing a parsed uri.
Definition: uri.c:265
int MaxSubscriptions
Definition: upnpapi.h:108
static int http_RecvPostMessage(http_parser_t *parser, SOCKINFO *info, char *filename, struct SendInstruction *Instr)
Receives the HTTP post message.
Definition: webserver.c:1354
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.
Definition: gena_device.c:927
int UpnpUnRegisterRootDeviceLowPower(UpnpDevice_Handle Hnd, int PowerState, int SleepPeriod, int RegistrationState)
Unregisters a root device registered with UpnpRegisterRootDevice, UpnpRegisterRootDevice2,...
Definition: upnpapi.c:1233
SOCKET connfd
Definition: miniserver.c:73
@ PARSE_INCOMPLETE
Definition: httpparser.h:155
ithread_mutex_t gUUIDMutex
Definition: upnpapi.c:113
int aliasInstalled
Definition: upnpapi.h:80
int memptr_cmp_nocase(memptr *m, const char *s)
Compares characters of 2 strings irrespective of the case for a specific count of bytes.
Definition: membuffer.c:78
#define UPNP_E_BAD_HTTPMSG
The HTTP message contains invalid message headers.
Definition: upnp.h:214
#define TRUE
Definition: upnputil.h:63
Definition: httpparser.h:179
UpnpEvent object declararion.
Definition: webserver.c:83
static char * StrStr(char *s1, const char *s2)
Finds a substring from a string in a case insensitive way.
Definition: webserver.c:670
int ThreadPoolShutdown(ThreadPool *tp)
Shuts the thread pool down. Waits for all threads to finish. May block indefinitely if jobs do not ex...
Definition: ThreadPool.c:978
Definition: upnpapi.h:249
void UpnpCloseLog(void)
Closes the log files.
Definition: upnpdebug.c:90
int http_error_code
Definition: httpparser.h:217
#define UPNP_E_NETWORK_ERROR
A network error occurred.
Definition: upnp.h:237
Definition: httpreadwrite.c:922
struct TOKEN token
Buffer used in parsinghttp messages, urls, etc. generally this simply holds a pointer into a larger a...
int UpnpNotify(UpnpDevice_Handle, const char *DevID, const char *ServID, const char **VarName, const char **NewVal, int cVariables)
Sends out an event change notification to all control points subscribed to a particular service.
Definition: upnpapi.c:2279
void gena_process_unsubscribe_request(SOCKINFO *info, http_message_t *request)
Handles a subscription cancellation request from a ctrl point. The connection is not destroyed on ret...
Definition: gena_device.c:1486
void RemoveClientSubClientSID(GenlibClientSubscription **head, const UpnpString *sid)
Remove the client subscription matching the subscritpion id represented by the const Upnp_SID sid par...
Definition: client_table.c:55
int UpnpSendActionAsync(UpnpClient_Handle Hnd, const char *ActionURL, const char *ServiceType, const char *DevUDN, IXML_Document *Action, Upnp_FunPtr Fun, const void *Cookie)
Sends a message to change a state variable in a service, generating a callback when the operation is ...
Definition: upnpapi.c:2656
unsigned short UpnpGetServerPort6(void)
Returns the internal server IPv6 UPnP listening port.
Definition: upnpapi.c:667
static int UpnpInitPreamble(void)
Performs the initial steps in initializing the UPnP SDK.
Definition: upnpapi.c:339
int UpnpCancelHttpGet(void *handle)
Set the cancel flag of the handle parameter.
Definition: upnpapi.c:3098
void free_upnp_timeout(upnp_timeout *event)
Free memory associated with event and memory for any sub-elements.
Definition: upnp_timeout.c:50
int UpnpSendActionEx(UpnpClient_Handle Hnd, const char *ActionURL, const char *ServiceType, const char *DevUDN, IXML_Document *Header, IXML_Document *Action, IXML_Document **RespNode)
Sends a message to change a state variable in a service.
Definition: upnpapi.c:2600
int ListDestroy(LinkedList *list, int freeItem)
Removes all memory associated with list nodes. Does not free LinkedList *list.
Definition: LinkedList.c:200
membuffer doc
Definition: webserver.c:96
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,...
Definition: upnpapi.c:3818
Upnp_Handle_Type HType
Definition: upnpapi.h:74
Represents a URI used in parse_uri and elsewhere.
Definition: uri.h:136
int TvDeviceStop(void)
Stops the device. Uninitializes the sdk.
Definition: tv_device.c:1378
int UpnpVirtualDir_set_OpenCallback(VDCallback_Open callback)
Sets the open callback function to be used to access a virtual directory.
Definition: upnpapi.c:4137
int TPJobInit(ThreadPoolJob *job, start_routine func, void *arg)
Initializes thread pool job. Sets the priority to default defined in ThreadPool.h....
Definition: ThreadPool.c:1071
void linecopy(char dest[LINE_SIZE], const char *src)
Copy no of bytes spcified by the LINE_SIZE constant, from the source buffer. Null terminate the desti...
Definition: util.c:46
int UpnpOpenHttpGet(const char *url, void **handle, char **contentType, int *contentLength, int *httpStatus, int timeout)
Gets a file specified in a URL.
Definition: upnpapi.c:3037
#define UPNP_E_INVALID_DESC
The description document passed to UpnpRegisterRootDevice, UpnpRegisterRootDevice2 UpnpRegisterRootDe...
Definition: upnp.h:143
int UpnpRenewSubscriptionAsync(UpnpClient_Handle Hnd, int TimeOut, Upnp_SID SubsId, Upnp_FunPtr Fun, const void *Cookie)
Renews a subscription that is about to expire, generating a callback when the operation is complete.
Definition: upnpapi.c:2207
void freeClientSubList(GenlibClientSubscription *list)
Free the client subscription table.
Definition: client_table.c:43
int ThreadPoolAddPersistent(ThreadPool *tp, ThreadPoolJob *job, int *jobId)
Adds a persistent job to the thread pool.
Definition: ThreadPool.c:768
Internal implementation of the class UpnpString.
Definition: UpnpString.c:69
int SampleUtil_Print(const char *fmt,...)
Function emulating printf that ultimately calls the registered print function with the formatted stri...
Definition: sample_util.c:634
void linux_print(const char *format,...)
Prints a string to standard out.
Definition: sample_util.c:666
int UpnpVirtualDir_set_SeekCallback(VDCallback_Seek callback)
Sets the seek callback function to be used to access a virtual directory.
Definition: upnpapi.c:4176
@ UPNPREG_FILENAME_DESC
Definition: upnp.h:484
int http_CloseHttpConnection(void *Handle)
Closes the connection created with UpnpOpenHttpConnection and frees any memory associated with the co...
Definition: httpreadwrite.c:1413
size_t length
Definition: membuffer.h:60
int web_server_set_alias(const char *alias_name, const char *alias_content, size_t alias_content_length, time_t last_modified)
Replaces current alias with the given alias. To remove the current alias, set alias_name to NULL.
Definition: webserver.c:421
off_t ReadSendSize
Definition: webserver.h:54
Definition: service_table.h:87
EXPORT_SPEC unsigned short ixmlNode_getNodeType(IXML_Node *nodeptr)
Retrieves the type of a Node. Note that not all possible return values are actually implemented.
Definition: node.c:287
int addServiceTable(IXML_Node *node, service_table *in, const char *DefaultURLBase)
Add Service to the table.
Definition: service_table.c:992
int UpnpString_set_StringN(UpnpString *p, const char *s, size_t n)
Sets the string from a pointer to char using a maximum of N chars.
Definition: UpnpString.c:176
int TimerThreadRemove(TimerThread *timer, int id, ThreadPoolJob *out)
Removes an event from the timer Q.
Definition: TimerThread.c:314
int UpnpGetIfInfo(const char *IfName)
Retrieve interface information and keep it in global variables. If NULL, we'll find the first suitabl...
Definition: upnpapi.c:3251
UpnpActionComplete * UpnpActionComplete_new()
#define UPNP_E_INVALID_INTERFACE
The interface provided to UpnpInit2 is unknown or does not have a valid IPv4 or IPv6 address configur...
Definition: upnp.h:228
void freeServiceTable(service_table *table)
Free's dynamic memory in table (does not free table, only memory within the structure).
Definition: service_table.c:623
int g_UpnpSdkEQMaxLen
Definition: upnpapi.c:172
static size_t parse_scheme(const char *in, size_t max, token *out)
parses a uri scheme starting at in[0] as defined in http://www.ietf.org/rfc/rfc2396....
Definition: uri.c:469
struct VirtualDirCallbacks virtualDirCallback
Definition: upnpapi.c:98
int UpnpSendAdvertisement(UpnpDevice_Handle Hnd, int Exp)
Sends out the discovery announcements for all devices and services for a device.
Definition: upnpapi.c:1638
static int sock_read_write(SOCKINFO *info, char *buffer, size_t bufsize, int *timeoutSecs, int bRead)
Receives or sends data. Also returns the time taken to receive or send data.
Definition: sock.c:154
int(* VDCallback_GetInfo)(const char *filename, UpnpFileInfo *info, const void *cookie)
Get-info callback function prototype.
Definition: upnp.h:2532
static FILE * ErrFileHnd
Definition: upnpdebug.c:58
char gIF_IPV4[INET_ADDRSTRLEN]
Definition: upnpapi.c:137
SOCKET ssdpSock6
Definition: miniserver.h:55
int parse_uri_and_unescape(char *in, size_t max, uri_type *out)
Same as parse_uri(), except that all strings are unescaped (XX replaced by chars).
Definition: uri.c:759
#define UPNP_E_URL_TOO_BIG
The URL passed into a function is too long.
Definition: upnp.h:203
void UpnpPrintf(Upnp_LogLevel DLevel, Dbg_Module Module, const char *DbgFileName, int DbgLineNo, const char *FmtStr,...)
Prints the debug statement either on the standard output or log file along with the information from ...
Definition: upnpdebug.c:127
int UpnpSubscribeAsync(UpnpClient_Handle Hnd, const char *PublisherUrl, int TimeOut, Upnp_FunPtr Fun, const void *Cookie)
Performs the same operation as UpnpSubscribe, but returns immediately and calls the registered callba...
Definition: upnpapi.c:1890
int ThreadPoolInit(ThreadPool *tp, ThreadPoolAttr *attr)
Initializes and starts ThreadPool. Must be called first and only once for ThreadPool.
Definition: ThreadPool.c:700
UpnpWebFileHandle(* VDCallback_Open)(const char *filename, enum UpnpOpenFileMode Mode, const void *cookie)
Open callback function prototype.
Definition: upnp.h:2553
UpnpString * UpnpString_new(void)
Constructor.
Definition: UpnpString.c:77
void freeSubscriptionList(subscription *head)
Free's memory allocated for all the subscriptions in the service table.
Definition: service_table.c:228
int TPAttrSetMaxThreads(ThreadPoolAttr *attr, int maxThreads)
Sets the max threads for the thread pool attributes.
Definition: ThreadPool.c:1107
int sock_init(SOCKINFO *info, SOCKET sockfd)
Assign the passed in socket descriptor to socket descriptor in the SOCKINFO structure.
Definition: sock.c:73
Definition: httpparser.h:61
void UpnpString_set_Length(UpnpString *p, size_t n)
Truncates the string to the specified lenght, or does nothing if the current lenght is less than or e...
Definition: UpnpString.c:150
int UpnpDevice_Handle
Returned when a device application registers with UpnpRegisterRootDevice, UpnpRegisterRootDevice2,...
Definition: upnp.h:436
int UpnpSetMaxSubscriptionTimeOut(UpnpDevice_Handle Hnd, int MaxSubscriptionTimeOut)
Sets the maximum time-out accepted for a subscription request or renewal.
Definition: upnpapi.c:1851
ithread_rwlock_t GlobalHndRWLock
Definition: upnpapi.c:109
static char * AllocGenaHeaders(const DOMString propertySet)
Allocates the GENA header.
Definition: gena_device.c:403
Definition: ThreadPool.h:175
int membuffer_append_str(membuffer *m, const char *c_str)
Invokes function to appends data from a constant string to the buffer.
Definition: membuffer.c:207
int ThreadPoolGetStats(ThreadPool *tp, ThreadPoolStats *stats)
Returns various statistics about the thread pool.
Definition: ThreadPool.c:1201
IXML_NodeList * DeviceList
Definition: upnpapi.h:102
int TPJobSetFreeFunction(ThreadPoolJob *job, free_routine func)
Sets the max threads for the thread pool attributes.
Definition: ThreadPool.c:1098
char gIF_IPV4_NETMASK[INET_ADDRSTRLEN]
Definition: upnpapi.c:140
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...
Definition: gena_device.c:666
int UpnpOpenHttpConnection(const char *url, void **handle, int timeout)
Opens a connection to the server.
Definition: upnpapi.c:3122
#define UPNP_E_INIT_FAILED
UpnpInit2 cannot complete.
Definition: upnp.h:196
membuffer msg
Definition: httpparser.h:208
static int UpnpInitMutexes(void)
Initializes the global mutexes used by the UPnP SDK.
Definition: upnpapi.c:260
Definition: LinkedList.h:84
static int gena_unsubscribe(IN const UpnpString *url, IN const UpnpString *sid, OUT http_parser_t *response)
Sends the UNSUBCRIBE gena request and recieves the response from the device and returns it as a param...
Definition: gena_ctrlpt.c:209
SOCKET ssdpSock6UlaGua
Definition: miniserver.h:57
int token_cmp(token *in1, token *in2)
Compares two tokens.
Definition: uri.c:308
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 is_request
Definition: httpparser.h:197
int is_unreserved(char in)
Returns a 1 if a char is an UNRESERVED char as defined in http://www.ietf.org/rfc/rfc2396....
Definition: uri.c:104
VDCallback_Read read
Definition: VirtualDir.h:31
long RecvWriteSize
Definition: webserver.h:56
Data structure representing a list of nodes.
Definition: ixml.h:246
int getServiceTable(IXML_Node *node, service_table *out, const char *DefaultURLBase)
Retrieve service from the table.
Definition: service_table.c:1045
resp_type
Definition: webserver.c:74
#define DOMString
The type of DOM strings.
Definition: ixml.h:59
char * UpnpGetServerIpAddress(void)
Returns the local IPv4 listening ip address.
Definition: upnpapi.c:679
EXPORT_SPEC IXML_NodeList * ixmlDocument_getElementsByTagName(IXML_Document *doc, const char *tagName)
Returns a NodeList of all Elements that match the given tag name in the order in which they were enco...
char * UpnpGetServerIp6Address(void)
Returns the local IPv6 listening ip address.
Definition: upnpapi.c:687
static int UpnpInitThreadPools(void)
Initializes the global threadm pools used by the UPnP SDK.
Definition: upnpapi.c:290
int UpnpSearchAsync(UpnpClient_Handle Hnd, int Mx, const char *TTarget_constarget_const, const void *Cookie_const)
Searches for devices matching the given search target.
Definition: upnpapi.c:1757
int UpnpSdkDeviceRegisteredV4
Definition: upnpapi.c:194
int membuffer_append(membuffer *m, const void *buf, size_t buf_len)
Invokes function to appends data from a constant buffer to the buffer.
Definition: membuffer.c:200
static int CheckOtherHTTPHeaders(http_message_t *Req, struct SendInstruction *RespInstr, off_t FileSize)
Get header id from the request parameter and take appropriate action based on the ids as an HTTP Rang...
Definition: webserver.c:908
ithread_mutex_t GlobalClientSubscribeMutex
Definition: upnpapi.c:105
int(* VDCallback_Seek)(UpnpWebFileHandle fileHnd, off_t offset, int origin, const void *cookie)
Seek callback function prototype.
Definition: upnp.h:2621
char * str_alloc(const char *str, size_t str_len)
Allocate memory and copy information from the input string to the newly allocated memory.
Definition: membuffer.c:48
static int GeneratePropertySet(char **names, char **values, int count, DOMString *out)
Generates XML property set for notifications.
Definition: gena_device.c:96
EXPORT_SPEC unsigned long ixmlNodeList_length(IXML_NodeList *nList)
Returns the number of Nodes in a NodeList.
Definition: nodeList.c:128
GenlibClientSubscription * GetClientSubClientSID(GenlibClientSubscription *head, const UpnpString *sid)
Return the client subscription from the client table that matches const Upnp_SID sid subscrition id v...
Definition: client_table.c:82
unsigned gIF_INDEX
Definition: upnpapi.c:149
membuffer gDocumentRootDir
Definition: webserver.c:232
int ThreadPoolAdd(ThreadPool *tp, ThreadPoolJob *job, int *jobId)
Adds a job to the thread pool. Job will be run as soon as possible.
Definition: ThreadPool.c:816
@ PARSE_FAILURE
Definition: httpparser.h:159
int uuid_create(uuid_upnp *uid)
Generator of a UUID.
Definition: uuid.c:53
VDCallback_Write write
Definition: VirtualDir.h:38
Upnp_FunPtr Callback
Definition: upnpapi.h:76
int http_MakeMessage(membuffer *buf, int http_major_version, int http_minor_version, const char *fmt,...)
Generate an HTTP message based on the format that is specified in the input parameters.
Definition: httpreadwrite.c:1470
@ UPNP_EVENT_SUBSCRIBE_COMPLETE
Definition: Callback.h:98
int UpnpString_casecmp(UpnpString *p, UpnpString *q)
Compares two strings for equality. Case does not matter.
Definition: UpnpString.c:203
int genaRenewSubscription(UpnpClient_Handle client_handle, const UpnpString *in_sid, int *TimeOut)
Renews a SID.
Definition: gena_ctrlpt.c:598
int is_mark(char in)
Returns a 1 if a char is a MARK char as defined in http://www.ietf.org/rfc/rfc2396....
Definition: uri.c:86
int UpnpInitLog(void)
Initialize the log files.
Definition: upnpdebug.c:69
static int ReadResponseLineAndHeaders(IN SOCKINFO *info, IN OUT http_parser_t *parser, IN OUT int *timeout_secs, IN OUT int *http_error_code)
Parses already exiting data. If not complete reads more data on the connected socket....
Definition: httpreadwrite.c:941
char * urlbuf
Definition: httpparser.h:210
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).
Definition: gena_ctrlpt.c:509
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.
Definition: gena_device.c:624
UpnpEventSubscribe object declararion.
LinkedList headers
Definition: httpparser.h:203
size_t cursor
Definition: httpparser.h:65
@ UPNP_CONTROL_ACTION_COMPLETE
Definition: Callback.h:30
int device_main(int argc, char *argv[])
Main entry point for tv device application.
Definition: tv_device.c:1418
int UpnpNotifyExt(UpnpDevice_Handle, const char *DevID, const char *ServID, IXML_Document *PropSet)
Similar to UpnpNotify except that it takes a DOM document for the event rather than an array of strin...
Definition: upnpapi.c:2333
static UPNP_INLINE int sock_close(SOCKET sock)
Closes the socket if it is different from -1.
Definition: sock.h:79
unsigned short LOCAL_PORT_V4
Definition: upnpapi.c:152
int parse_uri(const char *in, size_t max, uri_type *out)
Parses a uri as defined in http://www.ietf.org/rfc/rfc2396.txt (RFC explaining URIs).
Definition: uri.c:707
LinkedList SsdpSearchList
Definition: upnpapi.h:120
long ListSize(LinkedList *list)
Returns the size of the list.
Definition: LinkedList.c:301
http_method_t method
Definition: httpparser.h:182
#define UPNP_E_SOCKET_READ
An error happened while reading from a socket.
Definition: upnp.h:257
UpnpSubscriptionRequest object declararion.
int remove_dots(char *buf, size_t size)
Removes ".", and ".." from a path.
Definition: uri.c:527
char DescURL[LINE_SIZE]
Definition: upnpapi.h:85
static int get_file_info(const char *filename, OUT UpnpFileInfo *info)
Release memory allocated for the global web server root directory and the global XML document....
Definition: webserver.c:517
int genaUnregisterDevice(UpnpDevice_Handle device_handle)
Unregisters a device.
Definition: gena_device.c:66
static Upnp_LogLevel g_log_level
Definition: upnpdebug.c:55
static const char * errFileName
Definition: upnpdebug.c:64
int sock_init_with_ip(SOCKINFO *info, SOCKET sockfd, struct sockaddr *foreign_sockaddr)
Calls the sock_init function and assigns the passed in IP address and port to the IP address and port...
Definition: sock.c:83
void upnp_uuid_unpack(uuid_upnp *u, char *out)
Out will be xxxx-xx-xx-xx-xxxxxx format.
Definition: uuid.c:85
VDCallback_Open open
Definition: VirtualDir.h:20
@ PARSE_SUCCESS
Definition: httpparser.h:153
int UpnpWriteHttpRequest(void *handle, char *buf, size_t *size, int timeout)
Writes the content of a HTTP request initiated by a UpnpMakeHttpRequest call. The end of the content ...
Definition: upnpapi.c:3138
static void copy_token(const token *in, const char *in_base, token *out, char *out_base)
Tokens are generally pointers into other strings. This copies the offset and size from a token (in) r...
Definition: uri.c:199
@ PARSE_NO_MATCH
Definition: httpparser.h:163
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 content ...
Definition: httpreadwrite.c:1191
#define SubscribeLock()
Locks the subscription.
Definition: gena.h:122
#define UPNP_E_INTERNAL_ERROR
Generic error code for internal conditions not covered by other error codes.
Definition: upnp.h:376
const void * Cookie
Definition: webserver.h:58
void * TvCtrlPointCommandLoop(void *args)
Function that receives commands from the user at the command prompt during the lifetime of the device...
Definition: tv_ctrlpt.c:1458
UpnpString object declaration.
int UpnpReadHttpResponse(void *handle, char *buf, size_t *size, int timeout)
Reads the content of a response using a connection previously created by UpnpOpenHttpConnection.
Definition: upnpapi.c:3160
Definition: service_table.h:58
void UpnpSetLogFileNames(const char *ErrFileName, const char *InfoFileName)
Set the name for error and information files, respectively.
Definition: upnpdebug.c:101
int UpnpString_set_String(UpnpString *p, const char *s)
Sets the string from a pointer to char.
Definition: UpnpString.c:164
int TPAttrSetIdleTime(ThreadPoolAttr *attr, int idleTime)
Sets the idle time for the thread pool attributes.
Definition: ThreadPool.c:1134
static int get_miniserver_stopsock(MiniServerSockArray *out)
Creates the miniserver STOP socket. This socket is created and listened on to know when it is time to...
Definition: miniserver.c:805
int TimerThreadInit(TimerThread *timer, ThreadPool *tp)
Initializes and starts timer thread.
Definition: TimerThread.c:189
#define UPNP_E_UNSUBSCRIBE_UNACCEPTED
An unsubscribe request was rejected from the remote side.
Definition: upnp.h:331
static void * HandleTable[NUM_HANDLE]
Definition: upnpapi.c:158
@ REL_SEC
Definition: TimerThread.h:55
#define UPNP_E_BAD_RESPONSE
The response received from the remote side of a connection is not correct for the protocol.
Definition: upnp.h:172
@ MSERV_RUNNING
Definition: miniserver.c:83
EXPORT_SPEC int ixmlParseBufferEx(const char *buffer, IXML_Document **doc)
Parses an XML text buffer converting it into an IXML DOM representation.
Definition: ixml.c:428
int StopMiniServer()
Stop and Shutdown the MiniServer and free socket resources.
Definition: miniserver.c:968
const char * content_subtype
Definition: webserver.c:89
int UpnpSetMaxContentLength(size_t contentLength)
Sets the maximum content-length that the SDK will process on an incoming SOAP requests or responses.
Definition: upnpapi.c:4232
Data structure representing an Element node.
Definition: ixml.h:216
Definition: VirtualDir.h:62
#define UPNP_E_CANCELED
The operation was canceled.
Definition: upnp.h:319
UpnpStateVarComplete object declararion.
void gena_process_subscription_renewal_request(SOCKINFO *info, http_message_t *request)
Handles a subscription renewal request from a ctrl point. The connection is not destroyed on return.
Definition: gena_device.c:1376
@ UPNP_EVENT_AUTORENEWAL_FAILED
Definition: Callback.h:109
void * TvDeviceCommandLoop(void *args)
Function that receives commands from the user at the command prompt during the lifetime of the device...
Definition: tv_device.c:1388
Provides a platform independent way to include TCP/IP types and functions.
membuffer status_msg
Definition: httpparser.h:190
int UpnpGetHttpResponse(void *handle, UpnpString *headers, char **contentType, int *contentLength, int *httpStatus, int timeout)
Gets the response from the server using a connection previously created by UpnpOpenHttpConnection.
Definition: upnpapi.c:3151
int UpnpEnableWebserver(int enable)
Enables or disables the webserver.
Definition: upnpapi.c:4077
void printServiceTable(service_table *table, Upnp_LogLevel level, Dbg_Module module)
For debugging purposes prints the URL base of the table and information of each service from the serv...
Definition: service_table.c:512
static void alias_grab(struct xml_alias_t *alias)
Copy the contents of the global XML document into the local output parameter.
Definition: webserver.c:386
#define SubscribeUnlock()
Unlocks the subscription.
Definition: gena.h:133
int removeServiceTable(IXML_Node *node, service_table *in)
This function assumes that services for a particular root device are placed linearly in the service t...
Definition: service_table.c:917
Upnp_FunPtr GetCallBackFn(UpnpClient_Handle Hnd)
Get callback function ptr from a handle.
Definition: upnpapi.c:3753
void membuffer_attach(membuffer *m, char *new_buf, size_t buf_len)
Definition: membuffer.c:287
char gIF_IPV6_ULA_GUA[INET6_ADDRSTRLEN]
Definition: upnpapi.c:146
void gena_process_notification_event(SOCKINFO *info, http_message_t *event)
This function processes NOTIFY events that are sent by devices.
Definition: gena_ctrlpt.c:696
int UpnpFinish(void)
Initializes the OpenSSL library, and the OpenSSL context for use with pupnp.
Definition: upnpapi.c:585
void membuffer_destroy(membuffer *m)
Free's memory allocated for membuffer* m.
Definition: membuffer.c:160
int UpnpUnRegisterClient(UpnpClient_Handle Hnd)
Unregisters a control point application, unsubscribing all active subscriptions.
Definition: upnpapi.c:1356
service_info * FindServiceEventURLPath(service_table *table, const char *eventURLPath)
Traverses the service table and finds the node whose event URL Path matches a know value.
Definition: service_table.c:296
static int process_request(http_message_t *req, enum resp_type *rtype, membuffer *headers, membuffer *filename, struct xml_alias_t *alias, struct SendInstruction *RespInstr)
Processes the request and returns the result in the output parameters.
Definition: webserver.c:1034
int UpnpSetWebServerRootDir(const char *rootDir)
Sets the document root directory for the internal web server.
void(* free_function)(void *arg)
Definition: LinkedList.h:52
size_t entity_start_position
Definition: httpparser.h:228
ThreadPool gRecvThreadPool
Definition: upnpapi.c:125
int UpnpCloseHttpPost(void *handle, int *httpStatus, int timeout)
Sends and receives any pending data, closes the connection with the server, and frees memory allocate...
Definition: upnpapi.c:3024
char * resolve_rel_url(char *base_url, char *rel_url)
resolves a relative url with a base url returning a NEW (dynamically allocated with malloc) full url.
Definition: uri.c:593
#define UPNP_E_SOCKET_WRITE
An error happened while writing to a socket.
Definition: upnp.h:247
void print_token(token *in)
Function useful in debugging for printing a token.
Definition: uri.c:276
VDCallback_Seek seek
Definition: VirtualDir.h:51
UpnpDevice_Handle device_handle
Definition: tv_device.c:73
static void RunMiniServer(MiniServerSockArray *miniSock)
Run the miniserver.
Definition: miniserver.c:371
VDCallback_GetInfo get_info
Definition: VirtualDir.h:15
subscription * GetNextSubscription(service_info *service, subscription *current)
Get current and valid subscription from the service table.
Definition: service_table.c:159
ithread_mutex_t gSDKInitMutex
Definition: upnpapi.c:116
EXPORT_SPEC IXML_Node * ixmlNode_getNextSibling(IXML_Node *nodeptr)
Retrieves the sibling Node immediately following this Node.
Definition: node.c:346
#define UPNP_E_NOTIFY_UNACCEPTED
The remote host did not accept the notify sent from the local device.
Definition: upnp.h:336
#define APPLICATION_LISTENING_PORT
Definition: miniserver.c:69
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.
Definition: httpreadwrite.c:1315
int genaNotifyAllExt(UpnpDevice_Handle device_handle, char *UDN, char *servId, IXML_Document *PropSet)
Sends a notification to all the subscribed control points.
Definition: gena_device.c:891
const char * file_ext
Definition: webserver.c:85
GenlibClientSubscription * GetClientSubActualSID(GenlibClientSubscription *head, token *sid)
Returns the client subscription from the client subscription table that has the matching token *sid b...
Definition: client_table.c:101
@ MSERV_IDLE
Definition: miniserver.c:81
int token_string_cmp(token *in1, char *in2)
Compares a null terminated string to a token (exact).
Definition: uri.c:299
virtualDirList * pVirtualDirList
Definition: upnpapi.c:101
char * URLs
Definition: uri.h:153
Definition: webserver.h:45
static int WinsockInit(void)
(Windows Only) Initializes the Windows Winsock library.
Definition: upnpapi.c:217
#define UPNP_E_EXT_NOT_XML
The file name of the description document passed to UpnpRegisterRootDevice2 does not end in "....
Definition: upnp.h:361
void freeSubscription(subscription *sub)
Free's the memory allocated for storing the URL of the subscription.
Definition: service_table.c:206
#define UPNP_E_INIT
The SDK has already been initialized.
Definition: upnp.h:134
subscription * GetFirstSubscription(service_info *service)
Gets pointer to the first subscription node in the service table.
Definition: service_table.c:192
void readFromSSDPSocket(SOCKET socket)
This function reads the data from the ssdp socket.
Definition: ssdp_server.c:694
EXPORT_SPEC IXML_NodeList * ixmlElement_getElementsByTagName(IXML_Element *element, const char *tagName)
Returns a NodeList of all descendant Elements with a given tag name, in the order in which they are e...
int replace_escaped(char *in, size_t index, size_t *max)
Replaces an escaped sequence with its unescaped version as in http://www.ietf.org/rfc/rfc2396....
Definition: uri.c:135
void UpnpDisplayFileAndLine(FILE *fd, const char *DbgFileName, int DbgLineNo)
Writes the file name and file number from where debug statement is coming to the log file.
Definition: upnpdebug.c:176
Definition: service_table.h:74
int * ct
Definition: webserver.c:100
#define UPNP_E_OUTOF_MEMORY
Not enough resources are currently available to complete the operation.
Definition: upnp.h:126
size_t UpnpString_get_Length(const UpnpString *p)
Returns the length of the string.
Definition: UpnpString.c:145
void UpnpCloseLog(void)
Closes the log files.
Definition: upnpdebug.c:90
static int is_reserved(char in)
Returns a 1 if a char is a RESERVED char as defined in http://www.ietf.org/rfc/rfc2396....
Definition: uri.c:68
static int UpnpInitStartServers(unsigned short DestPort)
Finishes initializing the UPnP SDK.
Definition: upnpapi.c:421
static UPNP_INLINE int is_valid_alias(const struct xml_alias_t *alias)
Check for the validity of the XML object buffer.
Definition: webserver.c:375
int http_RecvMessage(IN SOCKINFO *info, OUT http_parser_t *parser, IN http_method_t request_method, IN OUT int *timeout_secs, OUT int *http_error_code)
Get the data on the socket and take actions based on the read data to modify the parser objects buffe...
Definition: httpreadwrite.c:344