libUPnP  1.8.4
FreeList.h
Go to the documentation of this file.
1 /*******************************************************************************
2  *
3  * Copyright (c) 2000-2003 Intel Corporation
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * * Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  * * Neither name of Intel Corporation nor the names of its contributors
15  * may be used to endorse or promote products derived from this software
16  * without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
22  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  ******************************************************************************/
31 
32 #ifndef FREE_LIST_H
33 #define FREE_LIST_H
34 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 #include "ithread.h"
44 
45 #include <errno.h>
46 
52 typedef struct FREELISTNODE
53 {
54  struct FREELISTNODE *next;
56 
61 typedef struct FREELIST
62 {
63  FreeListNode *head;
64  size_t element_size;
65  int maxFreeListLength;
66  int freeListLength;
68 
78 int FreeListInit(
80  FreeList *free_list,
82  size_t elementSize,
85  int maxFreeListLength);
86 
95 void *FreeListAlloc(
97  FreeList *free_list);
98 
109 int FreeListFree(
111  FreeList *free_list,
113  void *element);
114 
122 int FreeListDestroy(
124  FreeList *free_list);
125 
126 #ifdef __cplusplus
127 }
128 #endif
129 
130 #endif /* FREE_LIST_H */
131 
ixmlNode_getNodeName
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
MServerSockArray::ssdpReqSock6
SOCKET ssdpReqSock6
Definition: miniserver.h:70
MServerSockArray
Definition: miniserver.h:45
start_event_handler
static UPNP_INLINE int start_event_handler(void *Data)
Parses the message and dispatches it to a handler which handles the ssdp request msg.
Definition: ssdp_server.c:628
DeviceShutdown
int DeviceShutdown(char *DevType, int RootDev, char *Udn, char *Location, int Duration, int AddressFamily, int PowerState, int SleepPeriod, int RegistrationState)
Creates a HTTP device shutdown request packet and send it to the multicast channel through RequestHan...
Definition: ssdp_device.c:834
AdvertiseAndReply
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
ServiceReply
int ServiceReply(struct sockaddr *DestAddr, char *ServType, char *Udn, char *Location, int Duration, int PowerState, int SleepPeriod, int RegistrationState)
Creates the advertisement packet based on the input parameter, and send it to the multicast channel.
Definition: ssdp_device.c:757
http_message_t::request_method
http_method_t request_method
Definition: httpparser.h:186
ixmlNodeList_free
EXPORT_SPEC void ixmlNodeList_free(IXML_NodeList *nList)
Frees a NodeList object.
Definition: nodeList.c:143
UPNP_E_SOCKET_BIND
#define UPNP_E_SOCKET_BIND
The SDK had a problem binding a socket to a network interface.
Definition: upnp.h:267
membuffer_set_size
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
Handle_Info
Definition: upnpapi.h:72
ixmlNode_getFirstChild
EXPORT_SPEC IXML_Node * ixmlNode_getFirstChild(IXML_Node *nodeptr)
Retrieves the first child Node of a Node.
Definition: node.c:307
GetHandleInfo
Upnp_Handle_Type GetHandleInfo(UpnpClient_Handle Hnd, struct Handle_Info **HndInfo)
Get handle information.
Definition: upnpapi.c:3855
ServiceAdvertisement
int ServiceAdvertisement(char *Udn, char *ServType, char *Location, int Duration, int AddressFamily, int PowerState, int SleepPeriod, int RegistrationState)
Creates the advertisement packet based on the input parameter, and send it to the multicast channel.
Definition: ssdp_device.c:706
Handle_Info::LowerDescURL
char LowerDescURL[LINE_SIZE]
Definition: upnpapi.h:88
FreeListDestroy
int FreeListDestroy(FreeList *free_list)
Releases the resources stored with the free list.
Definition: FreeList.c:92
get_ssdp_sockets
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
upnpapi.h
MServerSockArray::ssdpSock4
SOCKET ssdpSock4
Definition: miniserver.h:53
http_parser_t
Definition: httpparser.h:213
unique_service_name
int unique_service_name(char *cmd, SsdpEvent *Evt)
Fills the fields of the event structure like DeviceType, Device UDN and Service Type.
Definition: ssdp_server.c:447
ixmlNode_getNodeValue
EXPORT_SPEC const char * ixmlNode_getNodeValue(IXML_Node *nodeptr)
Returns the value of the Node as a string.
Definition: node.c:253
membuffer::buf
char * buf
Definition: membuffer.h:58
UPNP_E_OUTOF_SOCKET
#define UPNP_E_OUTOF_SOCKET
The SDK cannot create any more sockets.
Definition: upnp.h:287
UpnpCloseSocket
#define UpnpCloseSocket
Definition: UpnpInet.h:57
ServiceShutdown
int ServiceShutdown(char *Udn, char *ServType, char *Location, int Duration, int AddressFamily, int PowerState, int SleepPeriod, int RegistrationState)
Creates a HTTP service shutdown request packet and sends it to the multicast channel through RequestH...
Definition: ssdp_device.c:783
memptr_cmp
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
ssdp_thread_data
Definition: ssdplib.h:158
TPJobSetPriority
int TPJobSetPriority(ThreadPoolJob *job, ThreadPriority priority)
Sets the max threads for the thread pool attributes.
Definition: ThreadPool.c:1083
memptr
Definition: membuffer.h:47
ssdp_request_type1
enum SsdpSearchType ssdp_request_type1(char *cmd)
This function figures out the type of the SSDP search in the in the request.
Definition: ssdp_server.c:533
ssdplib.h
http_message_t::uri
uri_type uri
Definition: httpparser.h:184
SsdpSearchType
SsdpSearchType
Definition: ssdplib.h:66
create_ssdp_sock_reqv4
static int create_ssdp_sock_reqv4(SOCKET *ssdpReqSock)
Creates the SSDP IPv4 socket to be used by the control point.
Definition: ssdp_server.c:895
FreeList
struct FREELIST FreeList
UPNP_E_SUCCESS
#define UPNP_E_SUCCESS
The operation completed successfully.
Definition: upnp.h:97
UPNP_INLINE
#define UPNP_INLINE
Declares an inline function.
Definition: UpnpGlobal.h:99
create_ssdp_sock_v4
static int create_ssdp_sock_v4(SOCKET *ssdpSock)
Definition: ssdp_server.c:782
SendReply
int SendReply(struct sockaddr *DestAddr, char *DevType, int RootDev, char *Udn, char *Location, int Duration, int ByType, int PowerState, int SleepPeriod, int RegistrationState)
Creates the reply packet based on the input parameter, and send it to the client addesss given in its...
Definition: ssdp_device.c:579
httpparser.h
Handle_Info::DeviceAf
int DeviceAf
Definition: upnpapi.h:112
gIF_IPV6
char gIF_IPV6[INET6_ADDRSTRLEN]
Definition: upnpapi.c:143
MServerSockArray::ssdpReqSock4
SOCKET ssdpReqSock4
Definition: miniserver.h:67
UPNP_E_SOCKET_ERROR
#define UPNP_E_SOCKET_ERROR
Generic socket error code for conditions not covered by other error codes.
Definition: upnp.h:311
sock_make_no_blocking
int sock_make_no_blocking(SOCKET sock)
Make socket non-blocking.
Definition: sock.c:294
SSDP_SERROR
@ SSDP_SERROR
Definition: ssdplib.h:68
ThreadPool.h
INVALID_SOCKET
#define INVALID_SOCKET
Definition: UpnpInet.h:51
parse_status_t
parse_status_t
Definition: httpparser.h:151
FreeListAlloc
void * FreeListAlloc(FreeList *free_list)
Allocates chunk of set size.
Definition: FreeList.c:51
SsdpEventStruct
Definition: ssdplib.h:107
SOCKET
int SOCKET
Definition: UpnpInet.h:48
THREADPOOLJOB
Definition: ThreadPool.h:164
SSDPSockArray::ssdpSock
SOCKET ssdpSock
Definition: ssdp_server.c:82
ixmlNodeList_item
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
_IXML_Node
Data structure common to all types of nodes.
Definition: ixml.h:173
membuffer.h
UPNP_E_INVALID_HANDLE
#define UPNP_E_INVALID_HANDLE
The handle passed to a function is not a recognized as a valid handle.
Definition: upnp.h:102
FreeListNode
struct FREELISTNODE FreeListNode
DeviceReply
int DeviceReply(struct sockaddr *DestAddr, char *DevType, int RootDev, char *Udn, char *Location, int Duration, int PowerState, int SleepPeriod, int RegistrationState)
Creates the reply packet based on the input parameter, and send it to the client address given in its...
Definition: ssdp_device.c:643
TRUE
#define TRUE
Definition: upnputil.h:63
http_message_t
Definition: httpparser.h:179
UPNP_E_NETWORK_ERROR
#define UPNP_E_NETWORK_ERROR
A network error occurred.
Definition: upnp.h:237
http_parser_t::valid_ssdp_notify_hack
int valid_ssdp_notify_hack
Definition: httpparser.h:220
TPJobInit
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
FREELISTNODE
Definition: FreeList.h:53
membuffer::length
size_t length
Definition: membuffer.h:60
ssdp_event_handler_thread
static void ssdp_event_handler_thread(void *the_data)
This function is a thread that handles SSDP requests.
Definition: ssdp_server.c:669
gIF_IPV4
char gIF_IPV4[INET_ADDRSTRLEN]
Definition: upnpapi.c:137
MServerSockArray::ssdpSock6
SOCKET ssdpSock6
Definition: miniserver.h:55
UpnpPrintf
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
ithread.h
UpnpDevice_Handle
int UpnpDevice_Handle
Returned when a device application registers with UpnpRegisterRootDevice, UpnpRegisterRootDevice2,...
Definition: upnp.h:436
Handle_Info::DeviceList
IXML_NodeList * DeviceList
Definition: upnpapi.h:102
TPJobSetFreeFunction
int TPJobSetFreeFunction(ThreadPoolJob *job, free_routine func)
Sets the max threads for the thread pool attributes.
Definition: ThreadPool.c:1098
http_message_t::msg
membuffer msg
Definition: httpparser.h:208
FREELIST
Definition: FreeList.h:62
MServerSockArray::ssdpSock6UlaGua
SOCKET ssdpSock6UlaGua
Definition: miniserver.h:57
_IXML_NodeList
Data structure representing a list of nodes.
Definition: ixml.h:246
DOMString
#define DOMString
The type of DOM strings.
Definition: ixml.h:59
valid_ssdp_msg
static UPNP_INLINE int valid_ssdp_msg(http_message_t *hmsg)
Does some quick checking of the ssdp msg.
Definition: ssdp_server.c:584
FreeListInit
int FreeListInit(FreeList *free_list, size_t elementSize, int maxFreeListLength)
Initializes Free List.
Definition: FreeList.c:37
ssdp_handle_device_request
void ssdp_handle_device_request(http_message_t *hmsg, struct sockaddr_storage *dest_addr)
Handles the search request. It does the sanity checks of the request and then schedules a thread to s...
Definition: ssdp_device.c:80
gIF_INDEX
unsigned gIF_INDEX
Definition: upnpapi.c:149
ThreadPoolAdd
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
FreeListFree
int FreeListFree(FreeList *free_list, void *element)
Returns an item to the Free List.
Definition: FreeList.c:71
miniserver.h
PARSE_FAILURE
@ PARSE_FAILURE
Definition: httpparser.h:159
FreeList.h
free_ssdp_event_handler_data
static void free_ssdp_event_handler_data(void *the_data)
Frees the ssdp request.
Definition: ssdp_server.c:564
SSDPSockArray::ssdpReqSock
int ssdpReqSock
Definition: ssdp_server.c:85
http_message_t::method
http_method_t method
Definition: httpparser.h:182
DeviceAdvertisement
int DeviceAdvertisement(char *DevType, int RootDev, char *Udn, char *Location, int Duration, int AddressFamily, int PowerState, int SleepPeriod, int RegistrationState)
Creates the device advertisement request based on the input parameter, and send it to the multicast c...
Definition: ssdp_device.c:495
SSDPSockArray
Definition: ssdp_server.c:80
Handle_Info::DescURL
char DescURL[LINE_SIZE]
Definition: upnpapi.h:85
PARSE_SUCCESS
@ PARSE_SUCCESS
Definition: httpparser.h:153
NO_ERROR_FOUND
#define NO_ERROR_FOUND
Definition: ssdplib.h:97
_IXML_Element
Data structure representing an Element node.
Definition: ixml.h:216
gIF_IPV6_ULA_GUA
char gIF_IPV6_ULA_GUA[INET6_ADDRSTRLEN]
Definition: upnpapi.c:146
gRecvThreadPool
ThreadPool gRecvThreadPool
Definition: upnpapi.c:125
sock.h
ixmlNode_getNextSibling
EXPORT_SPEC IXML_Node * ixmlNode_getNextSibling(IXML_Node *nodeptr)
Retrieves the sibling Node immediately following this Node.
Definition: node.c:346
ssdp_handle_ctrlpt_msg
void ssdp_handle_ctrlpt_msg(http_message_t *hmsg, struct sockaddr_storage *dest_addr, int timeout)
This function handles the ssdp messages from the devices. These messages includes the search replies,...
Definition: ssdp_ctrlpt.c:78
readFromSSDPSocket
void readFromSSDPSocket(SOCKET socket)
This function reads the data from the ssdp socket.
Definition: ssdp_server.c:694
ixmlElement_getElementsByTagName
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...
ssdp_request_type
int ssdp_request_type(char *cmd, SsdpEvent *Evt)
Starts filling the SSDP event structure based upon the request received.
Definition: ssdp_server.c:548