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

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

#include "includes.h"
#include <time.h>
#include <net/if.h>
#include <netdb.h>
#include <sys/ioctl.h>
#include "common.h"
#include "uuid.h"
#include "base64.h"
#include "wps.h"
#include "wps_i.h"
#include "wps_upnp.h"
#include "wps_upnp_i.h"

Macros

#define NO_DOMAIN_NAME_RESOLUTION   1 /* 1 to allow only dotted ip addresses */
 
#define MAX_SUBSCRIPTIONS   4 /* how many subscribing clients we handle */
 
#define MAX_ADDR_PER_SUBSCRIPTION   8
 
#define MAX_EVENTS_PER_SEC   5
 

Functions

void format_date (struct wpabuf *buf)
 
void subscr_addr_delete (struct subscr_addr *a)
 
void subscription_destroy (struct subscription *s)
 
struct subscriptionsubscription_find (struct upnp_wps_device_sm *sm, const u8 uuid[UUID_LEN])
 
struct subscriptionsubscription_start (struct upnp_wps_device_sm *sm, const char *callback_urls)
 Remember a UPnP control point to send events to. More...
 
struct subscriptionsubscription_renew (struct upnp_wps_device_sm *sm, const u8 uuid[UUID_LEN])
 
int upnp_wps_device_send_wlan_event (struct upnp_wps_device_sm *sm, const u8 from_mac_addr[ETH_ALEN], enum upnp_wps_wlanevent_type ev_type, const struct wpabuf *msg)
 Event notification. More...
 
int get_netif_info (const char *net_if, unsigned *ip_addr, char **ip_addr_text, u8 mac[ETH_ALEN])
 Get hw and IP addresses for network device. More...
 
void upnp_wps_device_deinit (struct upnp_wps_device_sm *sm, void *priv)
 Deinitialize WPS UPnP. More...
 
struct upnp_wps_device_smupnp_wps_device_init (struct upnp_wps_device_ctx *ctx, struct wps_context *wps, void *priv, char *net_if)
 Initialize WPS UPnP. More...
 
int upnp_wps_subscribers (struct upnp_wps_device_sm *sm)
 Check whether there are any event subscribers. More...
 
int upnp_wps_set_ap_pin (struct upnp_wps_device_sm *sm, const char *ap_pin)
 

Detailed Description

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

See below for more details on licensing and code history.

Function Documentation

int get_netif_info ( const char *  net_if,
unsigned *  ip_addr,
char **  ip_addr_text,
u8  mac[ETH_ALEN] 
)

Get hw and IP addresses for network device.

Parameters
net_ifSelected network interface name
ip_addrBuffer for returning IP address in network byte order
ip_addr_textBuffer for returning a pointer to allocated IP address text
macBuffer for returning MAC address
Returns
0 on success, -1 on failure
struct subscription* subscription_start ( struct upnp_wps_device_sm sm,
const char *  callback_urls 
)

Remember a UPnP control point to send events to.

Parameters
smWPS UPnP state machine from upnp_wps_device_init()
callback_urlsCallback URLs
Returns
NULL on error, or pointer to new subscription structure.
void upnp_wps_device_deinit ( struct upnp_wps_device_sm sm,
void *  priv 
)

Deinitialize WPS UPnP.

Parameters
smWPS UPnP state machine from upnp_wps_device_init()
privExternal context data that was used in upnp_wps_device_init() call
struct upnp_wps_device_sm* upnp_wps_device_init ( struct upnp_wps_device_ctx ctx,
struct wps_context wps,
void *  priv,
char *  net_if 
)

Initialize WPS UPnP.

Parameters
ctxcallback table; we must eventually free it
wpsPointer to longterm WPS context
privExternal context data that will be used in callbacks
net_ifSelected network interface name
Returns
WPS UPnP state or NULL on failure
int upnp_wps_device_send_wlan_event ( struct upnp_wps_device_sm sm,
const u8  from_mac_addr[ETH_ALEN],
enum upnp_wps_wlanevent_type  ev_type,
const struct wpabuf msg 
)

Event notification.

Parameters
smWPS UPnP state machine from upnp_wps_device_init()
from_mac_addrSource (Enrollee) MAC address for the event
ev_typeEvent type
msgEvent data
Returns
0 on success, -1 on failure

Tell external Registrars (UPnP control points) that something happened. In particular, events include WPS messages from clients that are proxied to external Registrars.

int upnp_wps_subscribers ( struct upnp_wps_device_sm sm)

Check whether there are any event subscribers.

Parameters
smWPS UPnP state machine from upnp_wps_device_init()
Returns
0 if no subscribers, 1 if subscribers