libUPnP  1.6.17
Data Structures | Defines | Typedefs | Enumerations
ssdplib.h File Reference
#include "httpparser.h"
#include "httpreadwrite.h"
#include "miniserver.h"
#include "UpnpInet.h"
#include <sys/types.h>
#include <signal.h>
#include <setjmp.h>
#include <errno.h>
#include <syslog.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <sys/time.h>
Include dependency graph for ssdplib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SsdpEventStruct
struct  TData
struct  ssdpsearchreply
struct  ssdpsearcharg
struct  ssdp_thread_data

Defines

#define BUFSIZE   (size_t)2500
#define SSDP_IP   "239.255.255.250"
#define SSDP_IPV6_LINKLOCAL   "FF02::C"
#define SSDP_IPV6_SITELOCAL   "FF05::C"
#define SSDP_PORT   1900
#define NUM_TRY   3
#define THREAD_LIMIT   50
#define COMMAND_LEN   300

Typedefs

typedef enum SsdpSearchType SType

Enumerations

enum  SsdpSearchType {
  SSDP_SERROR = -1, SSDP_ALL, SSDP_ROOTDEVICE, SSDP_DEVICEUDN,
  SSDP_DEVICETYPE, SSDP_SERVICE
}

Functions

SSDP Server Functions
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.
int unique_service_name (char *cmd, SsdpEvent *Evt)
 Fills the fields of the event structure like DeviceType, Device UDN and Service Type.
enum SsdpSearchType ssdp_request_type1 (char *cmd)
 This function figures out the type of the SSDP search in the in the request.
int ssdp_request_type (char *cmd, SsdpEvent *Evt)
 Starts filling the SSDP event structure based upon the request received.
void readFromSSDPSocket (SOCKET socket)
 This function reads the data from the ssdp socket.
int get_ssdp_sockets (MiniServerSockArray *out)
 Creates the IPv4 and IPv6 ssdp sockets required by the control point and device operation.
SSDP Control Point Functions
void ssdp_handle_ctrlpt_msg (http_message_t *hmsg, struct sockaddr_storage *dest_addr, int timeout, void *cookie)
 This function handles the ssdp messages from the devices. These messages includes the search replies, advertisement of device coming alive and bye byes.
int SearchByTarget (int Mx, char *St, void *Cookie)
 Creates and send the search request for a specific URL.
SSDP Device Functions
void * advertiseAndReplyThread (void *data)
 Wrapper function to reply the search request coming from the control point.
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).
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 channel.
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 input parameter DestAddr.
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 input parameter DestAddr.
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.
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.
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.

X_USER_AGENT

can be overwritten by configure CFLAGS argument.

The { X_USER_AGENT} constant specifies the value of the X-User-Agent: HTTP header. The value "redsonic" is needed for the DSM-320. See https://sourceforge.net/forum/message.php?msg_id=3166856 for more information

#define X_USER_AGENT   "redsonic"
#define NO_ERROR_FOUND   0
#define E_REQUEST_INVALID   -3
#define E_RES_EXPIRED   -4
#define E_MEM_ALLOC   -5
#define E_HTTP_SYNTEX   -6
#define E_SOCKET   -7
#define RQST_TIMEOUT   20
typedef struct SsdpEventStruct SsdpEvent
typedef void(* SsdpFunPtr )(SsdpEvent *)
typedef struct TData ThreadData
typedef struct ssdpsearchreply SsdpSearchReply
typedef struct ssdpsearcharg SsdpSearchArg
typedef int(* ParserFun )(char *, SsdpEvent *)
SOCKET gSsdpReqSocket4

Detailed Description