wpa_supplicant / hostapd  2.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Functions
wps_upnp_ssdp.c File Reference

UPnP SSDP for WPS Copyright (c) 2006-2007 Sony Corporation Copyright (c) 2008-2009 Atheros Communications Copyright (c) 2009-2013, Jouni Malinen j@w1..nosp@m.fi More...

#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"

Macros

#define UPNP_CACHE_SEC   (UPNP_CACHE_SEC_MIN + 1) /* cache time we use */
 
#define UPNP_CACHE_SEC_MIN   1800 /* min cachable time per UPnP standard */
 
#define UPNP_ADVERTISE_REPEAT   2 /* no more than 3 */
 
#define MAX_MSEARCH   20 /* max simultaneous M-SEARCH replies ongoing */
 
#define SSDP_TARGET   "239.0.0.0"
 
#define SSDP_NETMASK   "255.0.0.0"
 

Functions

void advertisement_state_machine_stop (struct upnp_wps_device_sm *sm, int send_byebye)
 Stop SSDP advertisements. More...
 
int advertisement_state_machine_start (struct upnp_wps_device_sm *sm)
 Start SSDP advertisements. More...
 
void msearchreply_state_machine_stop (struct advertisement_state_machine *a)
 Stop M-SEARCH reply state machine. More...
 
void ssdp_listener_stop (struct upnp_wps_device_sm *sm)
 Stop SSDP listered. More...
 
int ssdp_listener_open (void)
 
int ssdp_listener_start (struct upnp_wps_device_sm *sm)
 Set up for receiving discovery (UDP) packets. More...
 
int add_ssdp_network (const char *net_if)
 Add routing entry for SSDP. More...
 
int ssdp_open_multicast_sock (u32 ip_addr, const char *forced_ifname)
 
int ssdp_open_multicast (struct upnp_wps_device_sm *sm)
 Open socket for sending multicast SSDP messages. More...
 

Detailed Description

UPnP SSDP for WPS Copyright (c) 2006-2007 Sony Corporation Copyright (c) 2008-2009 Atheros Communications Copyright (c) 2009-2013, Jouni Malinen j@w1..nosp@m.fi

See wps_upnp.c for more details on licensing and code history.

Function Documentation

int add_ssdp_network ( const char *  net_if)

Add routing entry for SSDP.

Parameters
net_ifSelected 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".

int advertisement_state_machine_start ( struct upnp_wps_device_sm sm)

Start SSDP advertisements.

Parameters
smWPS UPnP state machine from upnp_wps_device_init()
Returns
0 on success, -1 on failure
void advertisement_state_machine_stop ( struct upnp_wps_device_sm sm,
int  send_byebye 
)

Stop SSDP advertisements.

Parameters
smWPS UPnP state machine from upnp_wps_device_init()
send_byebyeSend byebye advertisement messages immediately
void msearchreply_state_machine_stop ( struct advertisement_state_machine a)

Stop M-SEARCH reply state machine.

Parameters
aSelected advertisement/reply state
int ssdp_listener_start ( struct upnp_wps_device_sm sm)

Set up for receiving discovery (UDP) packets.

Parameters
smWPS 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().

void ssdp_listener_stop ( struct upnp_wps_device_sm sm)

Stop SSDP listered.

Parameters
smWPS UPnP state machine from upnp_wps_device_init()

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

int ssdp_open_multicast ( struct upnp_wps_device_sm sm)

Open socket for sending multicast SSDP messages.

Parameters
smWPS UPnP state machine from upnp_wps_device_init()
Returns
0 on success, -1 on failure