Manage "Step 1: Discovery" of the UPnP+™ specification for UPnP Devices with SSDP. More...
#include <ssdp_device.hpp>
#include <httpreadwrite.hpp>
#include <statcodes.hpp>
#include <upnpapi.hpp>
#include <webserver.hpp>
#include <umock/sys_socket.hpp>
Go to the source code of this file.
Functions | |
void | ssdp_handle_device_request (http_message_t *hmsg, struct sockaddr_storage *dest_addr) |
Handles the search request. | |
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. | |
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 and send it to the Control Point addesss. | |
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 and send it to the Control Point address. | |
int | ServiceAdvertisement (char *Udn, char *ServType, char *Location, int Duration, int AddressFamily, int PowerState, int SleepPeriod, int RegistrationState) |
Creates the advertisement packet and send it to the multicast channel. | |
int | ServiceReply (struct sockaddr *DestAddr, char *ServType, char *Udn, char *Location, int Duration, int PowerState, int SleepPeriod, int RegistrationState) |
Creates the advertisement packet and send it to the multicast channel. | |
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 RequestHandler. | |
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 RequestHandler. | |
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. | |
void | advertiseAndReplyThread (void *data) |
Wrapper function to reply the search request coming from the control point. | |
Functions scope restricted to file | |
int | anonymous_namespace{ssdp_device.cpp}::NewRequestHandler (struct sockaddr *DestAddr, int NumPacket, char **RqPacket) |
Works as a request handler which passes the HTTP request string to multicast channel. | |
int | anonymous_namespace{ssdp_device.cpp}::extractIPv6address (char *url, char *address) |
Extract IPv6 address. | |
int | anonymous_namespace{ssdp_device.cpp}::isUrlV6UlaGua (char *descdocUrl) |
Test if a Url contains an ULA or GUA IPv6 address. | |
void | anonymous_namespace{ssdp_device.cpp}::CreateServicePacket (int msg_type, const char *nt, char *usn, char *location, int duration, char **packet, int AddressFamily, int PowerState, int SleepPeriod, int RegistrationState) |
Creates a HTTP request packet. | |
Variables | |
Variables scope restricted to file | |
constexpr int | anonymous_namespace{ssdp_device.cpp}::MSGTYPE_SHUTDOWN {0} |
Message type. | |
constexpr int | anonymous_namespace{ssdp_device.cpp}::MSGTYPE_ADVERTISEMENT {1} |
Message type. | |
constexpr int | anonymous_namespace{ssdp_device.cpp}::MSGTYPE_REPLY {2} |
Message type. | |
Manage "Step 1: Discovery" of the UPnP+™ specification for UPnP Devices with SSDP.
Definition in file ssdp_device.cpp.
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 send a random time reply (random within maximum time given by the control point to reply).
[in] | hmsg | |
[in] | dest_addr |
Definition at line 481 of file ssdp_device.cpp.
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.
Create it based on the input parameter, and send it to the multicast channel.
Definition at line 570 of file ssdp_device.cpp.
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 and send it to the Control Point addesss.
Creates the reply packet based on the input parameter, and send it to the Control Point addesss given in its input parameter DestAddr.
[in] | DestAddr | destination IP address. |
[in] | DevType | Device type. |
[in] | RootDev | 1 means root device 0 means embedded device. |
[in] | Udn | Device UDN. |
[in] | Location | Location of Device description document. |
[in] | Duration | Life time of this device. |
[in] | ByType | |
[in] | PowerState | PowerState as defined by UPnP Low Power. |
[in] | SleepPeriod | SleepPeriod as defined by UPnP Low Power. |
[in] | RegistrationState | RegistrationState as defined by UPnP Low Power. |
Definition at line 649 of file ssdp_device.cpp.
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 and send it to the Control Point address.
Creates the reply packet based on the input parameter, and send it to the Control Point address given in its input parameter DestAddr.
[in] | DestAddr | destination IP address. |
[in] | DevType | Device type. |
[in] | RootDev | 1 means root device 0 means embedded device. |
[in] | Udn | Device UDN. |
[in] | Location | Location of Device description document. |
[in] | Duration | Life time of this device. |
[in] | PowerState | PowerState as defined by UPnP Low Power. |
[in] | SleepPeriod | SleepPeriod as defined by UPnP Low Power. |
[in] | RegistrationState | RegistrationState as defined by UPnP Low Power. |
Definition at line 707 of file ssdp_device.cpp.
int ServiceAdvertisement | ( | char * | Udn, |
char * | ServType, | ||
char * | Location, | ||
int | Duration, | ||
int | AddressFamily, | ||
int | PowerState, | ||
int | SleepPeriod, | ||
int | RegistrationState | ||
) |
Creates the advertisement packet and send it to the multicast channel.
[in] | Udn | Device UDN. |
[in] | ServType | Service Type. |
[in] | Location | Location of Device description document. |
[in] | Duration | Life time of this device. |
[in] | AddressFamily | Device address family. |
[in] | PowerState | PowerState as defined by UPnP Low Power. |
[in] | SleepPeriod | SleepPeriod as defined by UPnP Low Power. |
[in] | RegistrationState | RegistrationState as defined by UPnP Low Power. |
Definition at line 767 of file ssdp_device.cpp.
int ServiceReply | ( | struct sockaddr * | DestAddr, |
char * | ServType, | ||
char * | Udn, | ||
char * | Location, | ||
int | Duration, | ||
int | PowerState, | ||
int | SleepPeriod, | ||
int | RegistrationState | ||
) |
Creates the advertisement packet and send it to the multicast channel.
[in] | DestAddr | |
[in] | ServType | Service Type. |
[in] | Udn | Device UDN. |
[in] | Location | Location of Device description document. |
[in] | Duration | Life time of this device. |
[in] | PowerState | PowerState as defined by UPnP Low Power. |
[in] | SleepPeriod | SleepPeriod as defined by UPnP Low Power. |
[in] | RegistrationState | RegistrationState as defined by UPnP Low Power. |
Definition at line 818 of file ssdp_device.cpp.
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 RequestHandler.
Definition at line 843 of file ssdp_device.cpp.
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 RequestHandler.
[in] | DevType | Device Type. |
[in] | RootDev | 1 means root device. |
[in] | Udn | Device UDN. |
[in] | Location | Location URL. |
[in] | Duration | Device duration in sec. |
[in] | AddressFamily | Device address family. |
[in] | PowerState | PowerState as defined by UPnP Low Power. |
[in] | SleepPeriod | SleepPeriod as defined by UPnP Low Power. |
[in] | RegistrationState | RegistrationState as defined by UPnP Low Power. |
Definition at line 894 of file ssdp_device.cpp.
void advertiseAndReplyThread | ( | void * | data | ) |
Wrapper function to reply the search request coming from the control point.
[in] | data | Structure containing the search request. |
Definition at line 1315 of file ssdp_device.cpp.