X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=hostapd%2Fctrl_iface.c;h=4e31fb3e39093c658889b666f5b791adf088f5b7;hb=fda90ab4b73b19d4638e8b7cd4c90458e51f9e3e;hp=b978f961828775e25c838b87f5a9412bcbc6d4fe;hpb=2fc98d02c1a4239148d6483ec9bd88db9b24afe5;p=wpasupplicant diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c index b978f96..4e31fb3 100644 --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -29,6 +29,8 @@ #include "ctrl_iface.h" #include "sta_info.h" #include "accounting.h" +#include "wps_hostapd.h" +#include "driver.h" struct wpa_ctrl_dst { @@ -40,6 +42,10 @@ struct wpa_ctrl_dst { }; +static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level, + const char *buf, size_t len); + + static int hostapd_ctrl_iface_attach(struct hostapd_data *hapd, struct sockaddr_un *from, socklen_t fromlen) @@ -217,6 +223,38 @@ static int hostapd_ctrl_iface_new_sta(struct hostapd_data *hapd, } +#ifdef CONFIG_IEEE80211W +static int hostapd_ctrl_iface_sa_query(struct hostapd_data *hapd, + const char *txtaddr) +{ + u8 addr[ETH_ALEN]; + u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN]; + + wpa_printf(MSG_DEBUG, "CTRL_IFACE SA_QUERY %s", txtaddr); + + if (hwaddr_aton(txtaddr, addr)) + return -1; + + os_get_random(trans_id, WLAN_SA_QUERY_TR_ID_LEN); + ieee802_11_send_sa_query_req(hapd, addr, trans_id); + + return 0; +} +#endif /* CONFIG_IEEE80211W */ + + +#ifdef CONFIG_WPS +static int hostapd_ctrl_iface_wps_pin(struct hostapd_data *hapd, char *txt) +{ + char *pin = os_strchr(txt, ' '); + if (pin == NULL) + return -1; + *pin++ = '\0'; + return hostapd_wps_add_pin(hapd, txt, pin); +} +#endif /* CONFIG_WPS */ + + static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx, void *sock_ctx) { @@ -300,6 +338,19 @@ static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx, } else if (os_strncmp(buf, "NEW_STA ", 8) == 0) { if (hostapd_ctrl_iface_new_sta(hapd, buf + 8)) reply_len = -1; +#ifdef CONFIG_IEEE80211W + } else if (os_strncmp(buf, "SA_QUERY ", 9) == 0) { + if (hostapd_ctrl_iface_sa_query(hapd, buf + 9)) + reply_len = -1; +#endif /* CONFIG_IEEE80211W */ +#ifdef CONFIG_WPS + } else if (os_strncmp(buf, "WPS_PIN ", 8) == 0) { + if (hostapd_ctrl_iface_wps_pin(hapd, buf + 8)) + reply_len = -1; + } else if (os_strcmp(buf, "WPS_PBC") == 0) { + if (hostapd_wps_button_pushed(hapd)) + reply_len = -1; +#endif /* CONFIG_WPS */ } else { os_memcpy(reply, "UNKNOWN COMMAND\n", 16); reply_len = 16; @@ -335,6 +386,16 @@ static char * hostapd_ctrl_iface_path(struct hostapd_data *hapd) } +static void hostapd_ctrl_iface_msg_cb(void *ctx, int level, + const char *txt, size_t len) +{ + struct hostapd_data *hapd = ctx; + if (hapd == NULL) + return; + hostapd_ctrl_iface_send(hapd, level, txt, len); +} + + int hostapd_ctrl_iface_init(struct hostapd_data *hapd) { struct sockaddr_un addr; @@ -399,6 +460,7 @@ int hostapd_ctrl_iface_init(struct hostapd_data *hapd) hapd->ctrl_sock = s; eloop_register_read_sock(s, hostapd_ctrl_iface_receive, hapd, NULL); + wpa_msg_register_cb(hostapd_ctrl_iface_msg_cb); return 0; @@ -448,8 +510,8 @@ void hostapd_ctrl_iface_deinit(struct hostapd_data *hapd) } -void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level, - char *buf, size_t len) +static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level, + const char *buf, size_t len) { struct wpa_ctrl_dst *dst, *next; struct msghdr msg; @@ -464,7 +526,7 @@ void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level, os_snprintf(levelstr, sizeof(levelstr), "<%d>", level); io[0].iov_base = levelstr; io[0].iov_len = os_strlen(levelstr); - io[1].iov_base = buf; + io[1].iov_base = (char *) buf; io[1].iov_len = len; os_memset(&msg, 0, sizeof(msg)); msg.msg_iov = io;