45 #include "httpreadwrite.h"
49 #include <sys/types.h>
58 #include <netinet/in_systm.h>
59 #include <netinet/ip.h>
60 #include <netinet/ip_icmp.h>
76 #define BUFSIZE (size_t)2500
77 #define SSDP_IP "239.255.255.250"
78 #define SSDP_IPV6_LINKLOCAL "FF02::C"
79 #define SSDP_IPV6_SITELOCAL "FF05::C"
80 #define SSDP_PORT 1900
82 #define THREAD_LIMIT 50
83 #define COMMAND_LEN 300
93 #define X_USER_AGENT "redsonic"
97 #define NO_ERROR_FOUND 0
98 #define E_REQUEST_INVALID -3
99 #define E_RES_EXPIRED -4
100 #define E_MEM_ALLOC -5
101 #define E_HTTP_SYNTEX -6
104 #define RQST_TIMEOUT 20
113 char DeviceType[LINE_SIZE];
115 char ServiceType[LINE_SIZE];
116 char Location[LINE_SIZE];
117 char HostAddr[LINE_SIZE];
120 char Date[LINE_SIZE];
121 struct sockaddr *DestAddr;
125 typedef void (* SsdpFunPtr)(
SsdpEvent *);
132 struct sockaddr_storage DestAddr;
139 struct sockaddr_storage dest_addr;
160 struct sockaddr_storage dest_addr;
165 #ifdef INCLUDE_CLIENT_APIS
166 extern SOCKET gSsdpReqSocket4;
167 #ifdef UPNP_ENABLE_IPV6
168 extern SOCKET gSsdpReqSocket6;
171 typedef int (*ParserFun)(
char *,
SsdpEvent *);
192 struct sockaddr *DestAddr,
272 struct sockaddr_storage *dest_addr,
326 #ifdef INCLUDE_DEVICE_APIS
331 struct sockaddr_storage *dest_addr);
337 struct sockaddr_storage *dest_addr) {}
364 int RegistrationState);
374 struct sockaddr *DestAddr,
392 int RegistrationState);
402 struct sockaddr *DestAddr,
418 int RegistrationState);
442 int RegistrationState);
452 struct sockaddr *DestAddr,
466 int RegistrationState);
490 int RegistrationState);
516 int RegistrationState);
Definition: miniserver.h:45
Definition: httpparser.h:181
Definition: ssdplib.h:157
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:586
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:502
void readFromSSDPSocket(SOCKET socket)
This function reads the data from the ssdp socket.
Definition: ssdp_server.c:814
struct SsdpEventStruct SsdpEvent
Definition: ssdplib.h:143
int ssdp_request_type(char *cmd, SsdpEvent *Evt)
Starts filling the SSDP event structure based upon the request received.
Definition: ssdp_server.c:656
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:81
Definition: ssdplib.h:107
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:713
Definition: ssdplib.h:127
int SearchByTarget(int Hnd, int Mx, char *St, void *Cookie)
Creates and send the search request for a specific URL.
Definition: ssdp_ctrlpt.c:578
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:82
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:641
int UpnpDevice_Handle
Returned when a device application registers with UpnpRegisterRootDevice, UpnpRegisterRootDevice2, UpnpRegisterRootDevice3 or UpnpRegisterRootDevice4.
Definition: upnp.h:439
Definition: ssdplib.h:135
int SOCKET
Definition: UpnpInet.h:48
void advertiseAndReplyThread(void *data)
Wrapper function to reply the search request coming from the control point.
Definition: ssdp_device.c:69
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:841
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:764
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:96
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:650
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:549
Definition: ssdplib.h:151
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:1463
#define UPNP_INLINE
Declares an inline function.
Definition: UpnpGlobal.h:103
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:790