46 #include "httpreadwrite.h"
52 #include <sys/types.h>
58 #include <netinet/in_systm.h>
59 #include <netinet/ip.h>
60 #include <netinet/ip_icmp.h>
77 #define BUFSIZE (size_t)2500
78 #define SSDP_IP "239.255.255.250"
79 #define SSDP_IPV6_LINKLOCAL "FF02::C"
80 #define SSDP_IPV6_SITELOCAL "FF05::C"
81 #define SSDP_PORT 1900
82 #define SSDP_PORT_STR "1900"
84 #define THREAD_LIMIT 50
85 #define COMMAND_LEN 300
95 #define X_USER_AGENT "redsonic"
99 #define NO_ERROR_FOUND 0
100 #define E_REQUEST_INVALID -3
101 #define E_RES_EXPIRED -4
102 #define E_MEM_ALLOC -5
103 #define E_HTTP_SYNTEX -6
106 #define RQST_TIMEOUT 20
116 char DeviceType[LINE_SIZE];
118 char ServiceType[LINE_SIZE];
119 char Location[LINE_SIZE];
120 char HostAddr[LINE_SIZE];
123 char Date[LINE_SIZE];
124 struct sockaddr *DestAddr;
135 struct sockaddr_storage DestAddr;
142 struct sockaddr_storage dest_addr;
163 struct sockaddr_storage dest_addr;
168 #ifdef INCLUDE_CLIENT_APIS
169 extern SOCKET gSsdpReqSocket4;
170 #ifdef UPNP_ENABLE_IPV6
171 extern SOCKET gSsdpReqSocket6;
174 typedef int (*ParserFun)(
char *,
SsdpEvent *);
195 struct sockaddr *DestAddr,
277 struct sockaddr_storage *dest_addr,
331 #ifdef INCLUDE_DEVICE_APIS
336 struct sockaddr_storage *dest_addr);
342 struct sockaddr_storage *dest_addr)
371 int RegistrationState);
381 struct sockaddr *DestAddr,
399 int RegistrationState);
409 struct sockaddr *DestAddr,
425 int RegistrationState);
449 int RegistrationState);
459 struct sockaddr *DestAddr,
473 int RegistrationState);
497 int RegistrationState);
523 int RegistrationState);
Definition: miniserver.h:45
Definition: httpparser.h:181
Definition: ssdplib.h:160
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:909
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:789
int readFromSSDPSocket(SOCKET socket)
This function reads the data from the ssdp socket.
Definition: ssdp_server.c:808
struct SsdpEventStruct SsdpEvent
Definition: ssdplib.h:146
int ssdp_request_type(char *cmd, SsdpEvent *Evt)
Starts filling the SSDP event structure based upon the request received.
Definition: ssdp_server.c:650
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:76
Definition: ssdplib.h:109
enum SsdpSearchType SType
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:1091
Definition: ssdplib.h:130
int SearchByTarget(int Hnd, int Mx, char *St, void *Cookie)
Creates and send the search request for a specific URL.
Definition: ssdp_ctrlpt.c:573
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
Provides a platform independent way to include TCP/IP types and functions.
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:635
int UpnpDevice_Handle
Returned when a device application registers with UpnpRegisterRootDevice, UpnpRegisterRootDevice2, UpnpRegisterRootDevice3 or UpnpRegisterRootDevice4.
Definition: upnp.h:439
Definition: ssdplib.h:138
int SOCKET
Definition: UpnpInet.h:50
void advertiseAndReplyThread(void *data)
Wrapper function to reply the search request coming from the control point.
Definition: ssdp_device.c:64
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:1263
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:1158
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:90
SsdpSearchType
Definition: ssdplib.h:66
Definition: httpparser.h:216
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:1001
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:543
Definition: ssdplib.h:154
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:1478
#define UPNP_INLINE
Declares an inline function.
Definition: UpnpGlobal.h:119
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:1196