wps_upnp_ssdp.c File Reference

#include "includes.h"
#include <fcntl.h>
#include <sys/ioctl.h>
#include <net/route.h>
#include "common.h"
#include "uuid.h"
#include "eloop.h"
#include "wps.h"
#include "wps_upnp.h"
#include "wps_upnp_i.h"
Include dependency graph for wps_upnp_ssdp.c:

Go to the source code of this file.

Defines

#define MAX_MSEARCH   20
#define SSDP_NETMASK   "255.0.0.0"
#define SSDP_TARGET   "239.0.0.0"
#define UPNP_ADVERTISE_REPEAT   2
#define UPNP_CACHE_SEC   (UPNP_CACHE_SEC_MIN + 1)
#define UPNP_CACHE_SEC_MIN   1800

Functions

int add_ssdp_network (const char *net_if)
static void advertisement_state_machine_handler (void *eloop_data, void *user_ctx)
int advertisement_state_machine_start (struct upnp_wps_device_sm *sm)
void advertisement_state_machine_stop (struct upnp_wps_device_sm *sm, int send_byebye)
static int line_length (const char *l)
static int line_length_stripped (const char *l)
static void msearchreply_state_machine_handler (void *eloop_data, void *user_ctx)
static void msearchreply_state_machine_start (struct upnp_wps_device_sm *sm, struct sockaddr_in *client, int mx)
void msearchreply_state_machine_stop (struct advertisement_state_machine *a)
static struct wpabufnext_advertisement (struct upnp_wps_device_sm *sm, struct advertisement_state_machine *a, int *islast)
static void ssdp_listener_handler (int sd, void *eloop_ctx, void *sock_ctx)
int ssdp_listener_open (void)
int ssdp_listener_start (struct upnp_wps_device_sm *sm)
void ssdp_listener_stop (struct upnp_wps_device_sm *sm)
int ssdp_open_multicast (struct upnp_wps_device_sm *sm)
int ssdp_open_multicast_sock (u32 ip_addr)
static void ssdp_parse_msearch (struct upnp_wps_device_sm *sm, struct sockaddr_in *client, const char *data)
static int str_starts (const char *str, const char *start)
static int token_eq (const char *s1, const char *s2)
static int token_length (const char *s)
static int word_separation_length (const char *s)

Define Documentation

#define MAX_MSEARCH   20

Definition at line 27 of file wps_upnp_ssdp.c.

#define SSDP_NETMASK   "255.0.0.0"

Definition at line 29 of file wps_upnp_ssdp.c.

#define SSDP_TARGET   "239.0.0.0"

Definition at line 28 of file wps_upnp_ssdp.c.

#define UPNP_ADVERTISE_REPEAT   2

Definition at line 26 of file wps_upnp_ssdp.c.

#define UPNP_CACHE_SEC   (UPNP_CACHE_SEC_MIN + 1)

Definition at line 24 of file wps_upnp_ssdp.c.

#define UPNP_CACHE_SEC_MIN   1800

Definition at line 25 of file wps_upnp_ssdp.c.


Function Documentation

int add_ssdp_network ( const char *  net_if  ) 

add_ssdp_network - Add routing entry for SSDP : Selected network interface name Returns: 0 on success, -1 on failure

This function assures that the multicast address will be properly handled by Linux networking code (by a modification to routing tables). This must be done per network interface. It really only needs to be done once after booting up, but it does not hurt to call this more frequently "to be safe".

Definition at line 810 of file wps_upnp_ssdp.c.

static void advertisement_state_machine_handler ( void *  eloop_data,
void *  user_ctx 
) [static]

Definition at line 269 of file wps_upnp_ssdp.c.

int advertisement_state_machine_start ( struct upnp_wps_device_sm sm  ) 

advertisement_state_machine_start - Start SSDP advertisements : WPS UPnP state machine from upnp_wps_device_init() Returns: 0 on success, -1 on failure

Definition at line 346 of file wps_upnp_ssdp.c.

void advertisement_state_machine_stop ( struct upnp_wps_device_sm sm,
int  send_byebye 
)

advertisement_state_machine_stop - Stop SSDP advertisements : WPS UPnP state machine from upnp_wps_device_init() : Send byebye advertisement messages immediately

Definition at line 234 of file wps_upnp_ssdp.c.

static int line_length ( const char *  l  )  [static]

Definition at line 89 of file wps_upnp_ssdp.c.

static int line_length_stripped ( const char *  l  )  [static]

Definition at line 101 of file wps_upnp_ssdp.c.

static void msearchreply_state_machine_handler ( void *  eloop_data,
void *  user_ctx 
) [static]

Definition at line 389 of file wps_upnp_ssdp.c.

static void msearchreply_state_machine_start ( struct upnp_wps_device_sm sm,
struct sockaddr_in *  client,
int  mx 
) [static]

msearchreply_state_machine_start - Reply to M-SEARCH discovery request : WPS UPnP state machine from upnp_wps_device_init() : Client address : Maximum delay in seconds

Use TTL of 4 (this was done when socket set up). A response should be given in randomized portion of min(MX,120) seconds

UPnP-arch-DeviceArchitecture, 1.2.3: To be found, a device must send a UDP response to the source IP address and port that sent the request to the multicast channel. Devices respond if the ST header of the M-SEARCH request is "ssdp:all", "upnp:rootdevice", "uuid:" followed by a UUID that exactly matches one advertised by the device.

Definition at line 458 of file wps_upnp_ssdp.c.

void msearchreply_state_machine_stop ( struct advertisement_state_machine a  ) 

msearchreply_state_machine_stop - Stop M-SEARCH reply state machine : Selected advertisement/reply state

Definition at line 381 of file wps_upnp_ssdp.c.

static struct wpabuf* next_advertisement ( struct upnp_wps_device_sm sm,
struct advertisement_state_machine a,
int *  islast 
) [static, read]

next_advertisement - Build next message and advance the state machine : Advertisement state : Buffer for indicating whether this is the last message (= 1) Returns: The new message (caller is responsible for freeing this)

Note: next_advertisement is shared code with msearchreply_* functions

Definition at line 133 of file wps_upnp_ssdp.c.

static void ssdp_listener_handler ( int  sd,
void *  eloop_ctx,
void *  sock_ctx 
) [static]

Definition at line 691 of file wps_upnp_ssdp.c.

int ssdp_listener_open ( void   ) 

Definition at line 733 of file wps_upnp_ssdp.c.

int ssdp_listener_start ( struct upnp_wps_device_sm sm  ) 

ssdp_listener_start - Set up for receiving discovery (UDP) packets : WPS UPnP state machine from upnp_wps_device_init() Returns: 0 on success, -1 on failure

The SSDP listener is stopped by calling ssdp_listener_stop().

Definition at line 781 of file wps_upnp_ssdp.c.

void ssdp_listener_stop ( struct upnp_wps_device_sm sm  ) 

ssdp_listener_stop - Stop SSDP listered : WPS UPnP state machine from upnp_wps_device_init()

This function stops the SSDP listener that was started by calling ssdp_listener_start().

Definition at line 674 of file wps_upnp_ssdp.c.

int ssdp_open_multicast ( struct upnp_wps_device_sm sm  ) 

ssdp_open_multicast - Open socket for sending multicast SSDP messages : WPS UPnP state machine from upnp_wps_device_init() Returns: 0 on success, -1 on failure

Definition at line 918 of file wps_upnp_ssdp.c.

int ssdp_open_multicast_sock ( u32  ip_addr  ) 

Definition at line 861 of file wps_upnp_ssdp.c.

static void ssdp_parse_msearch ( struct upnp_wps_device_sm sm,
struct sockaddr_in *  client,
const char *  data 
) [static]

ssdp_parse_msearch - Process a received M-SEARCH : WPS UPnP state machine from upnp_wps_device_init() : Client address : NULL terminated M-SEARCH message

Given that we have received a header w/ M-SEARCH, act upon it

Format of M-SEARCH (case insensitive!):

First line must be: M-SEARCH * HTTP/1.1 Other lines in arbitrary order: HOST:239.255.255.250:1900 ST:<varies -- must match> MAN:"ssdp:discover" MX:<varies>

It should be noted that when Microsoft Vista is still learning its IP address, it sends out host lines like: HOST:[FF02::C]:1900

Definition at line 524 of file wps_upnp_ssdp.c.

static int str_starts ( const char *  str,
const char *  start 
) [static]

Definition at line 110 of file wps_upnp_ssdp.c.

static int token_eq ( const char *  s1,
const char *  s2 
) [static]

Definition at line 35 of file wps_upnp_ssdp.c.

static int token_length ( const char *  s  )  [static]

Definition at line 58 of file wps_upnp_ssdp.c.

static int word_separation_length ( const char *  s  )  [static]

Definition at line 75 of file wps_upnp_ssdp.c.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines


wpa_supplicant
Author(s): Package maintained by Blaise Gassend
autogenerated on Fri Jan 11 10:05:14 2013