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
83 #define THREAD_LIMIT 50
84 #define COMMAND_LEN 300
94 #define X_USER_AGENT "redsonic"
98 #define NO_ERROR_FOUND 0
99 #define E_REQUEST_INVALID -3
100 #define E_RES_EXPIRED -4
101 #define E_MEM_ALLOC -5
102 #define E_HTTP_SYNTEX -6
105 #define RQST_TIMEOUT 20
115 char DeviceType[LINE_SIZE];
117 char ServiceType[LINE_SIZE];
118 char Location[LINE_SIZE];
119 char HostAddr[LINE_SIZE];
122 char Date[LINE_SIZE];
123 struct sockaddr *DestAddr;
134 struct sockaddr_storage DestAddr;
141 struct sockaddr_storage dest_addr;
162 struct sockaddr_storage dest_addr;
167 #ifdef INCLUDE_CLIENT_APIS
168 extern SOCKET gSsdpReqSocket4;
169 #ifdef UPNP_ENABLE_IPV6
170 extern SOCKET gSsdpReqSocket6;
173 typedef int (*ParserFun)(
char *,
SsdpEvent *);
194 struct sockaddr *DestAddr,
276 struct sockaddr_storage *dest_addr,
330 #ifdef INCLUDE_DEVICE_APIS
335 struct sockaddr_storage *dest_addr);
341 struct sockaddr_storage *dest_addr)
370 int RegistrationState);
380 struct sockaddr *DestAddr,
398 int RegistrationState);
408 struct sockaddr *DestAddr,
424 int RegistrationState);
448 int RegistrationState);
458 struct sockaddr *DestAddr,
472 int RegistrationState);
496 int RegistrationState);
522 int RegistrationState);
#define UPNP_INLINE
Declares an inline function.
Definition: UpnpGlobal.h:119
Provides a platform independent way to include TCP/IP types and functions.
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
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:949
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
int ssdp_request_type(char *cmd, SsdpEvent *Evt)
Starts filling the SSDP event structure based upon the request received.
Definition: ssdp_server.c:650
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:739
struct SsdpEventStruct SsdpEvent
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:1471
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:1211
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:81
enum SsdpSearchType SType
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
void advertiseAndReplyThread(void *data)
Wrapper function to reply the search request coming from the control point.
Definition: ssdp_device.c:65
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:1039
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:1144
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
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:857
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
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:1106
SsdpSearchType
Definition: ssdplib.h:67
int readFromSSDPSocket(SOCKET socket)
This function reads the data from the ssdp socket.
Definition: ssdp_server.c:808
@ SSDP_SERROR
Definition: ssdplib.h:69
int SOCKET
Definition: UpnpInet.h:48
int UpnpDevice_Handle
Returned when a device application registers with UpnpRegisterRootDevice, UpnpRegisterRootDevice2,...
Definition: upnp.h:439
Definition: miniserver.h:46
Definition: ssdplib.h:109
Definition: ssdplib.h:130
Definition: httpparser.h:182
Definition: httpparser.h:217
Definition: ssdplib.h:160
Definition: ssdplib.h:146
Definition: ssdplib.h:154
Definition: ssdplib.h:138