From: Tomasz Bursztyka Date: Fri, 20 Apr 2012 12:18:34 +0000 (+0300) Subject: gsupplicant: Add WPS specific capabilities parsing for BSS X-Git-Tag: 0.81~10 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Fconnman.git;a=commitdiff_plain;h=26694acdacf8fc5e402bea044bd166677531c423 gsupplicant: Add WPS specific capabilities parsing for BSS --- diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h index 03df6ca..d5f5a29 100644 --- a/gsupplicant/gsupplicant.h +++ b/gsupplicant/gsupplicant.h @@ -75,6 +75,11 @@ extern "C" { #define G_SUPPLICANT_MAX_FAST_SCAN 4 +#define G_SUPPLICANT_WPS_CONFIGURED (1 << 0) +#define G_SUPPLICANT_WPS_PBC (1 << 1) +#define G_SUPPLICANT_WPS_PIN (1 << 2) +#define G_SUPPLICANT_WPS_REGISTRAR (1 << 3) + typedef enum { G_SUPPLICANT_MODE_UNKNOWN, G_SUPPLICANT_MODE_INFRA, diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c index c5a2da7..b44ea69 100644 --- a/gsupplicant/supplicant.c +++ b/gsupplicant/supplicant.c @@ -188,6 +188,7 @@ struct g_supplicant_bss { dbus_bool_t privacy; dbus_bool_t psk; dbus_bool_t ieee8021x; + unsigned int wps_capabilities; }; struct _GSupplicantNetwork { @@ -1248,13 +1249,19 @@ static void bss_process_ies(DBusMessageIter *iter, void *user_data) const unsigned char WPS_OUI[] = { 0x00, 0x50, 0xf2, 0x04 }; unsigned char *ie, *ie_end; DBusMessageIter array; + unsigned int value; int ie_len; #define WMM_WPA1_WPS_INFO 221 #define WPS_INFO_MIN_LEN 6 #define WPS_VERSION_TLV 0x104A #define WPS_STATE_TLV 0x1044 +#define WPS_METHODS_TLV 0x1012 +#define WPS_REGISTRAR_TLV 0x1041 #define WPS_VERSION 0x10 +#define WPS_PBC 0x04 +#define WPS_PIN 0x00 +#define WPS_CONFIGURED 0x02 dbus_message_iter_recurse(iter, &array); dbus_message_iter_get_fixed_array(&array, &ie, &ie_len); @@ -1271,11 +1278,33 @@ static void bss_process_ies(DBusMessageIter *iter, void *user_data) SUPPLICANT_DBG("IE: match WPS_OUI"); - if (get_tlv(&ie[6], ie[1], - WPS_VERSION_TLV) == WPS_VERSION && - get_tlv(&ie[6], ie[1], - WPS_STATE_TLV) != 0) + value = get_tlv(&ie[6], ie[1], WPS_STATE_TLV); + if (get_tlv(&ie[6], ie[1], WPS_VERSION_TLV) == WPS_VERSION && + value != 0) { bss->keymgmt |= G_SUPPLICANT_KEYMGMT_WPS; + + if (value == WPS_CONFIGURED) + bss->wps_capabilities |= + G_SUPPLICANT_WPS_CONFIGURED; + } + + value = get_tlv(&ie[6], ie[1], WPS_METHODS_TLV); + if (value != 0) { + if (GUINT16_FROM_BE(value) == WPS_PBC) + bss->wps_capabilities |= G_SUPPLICANT_WPS_PBC; + if (GUINT16_FROM_BE(value) == WPS_PIN) + bss->wps_capabilities |= G_SUPPLICANT_WPS_PIN; + } else + bss->wps_capabilities |= + G_SUPPLICANT_WPS_PBC | G_SUPPLICANT_WPS_PIN; + + /* If the AP sends this it means it's advertizing + * as a registrar and the WPS process is launched + * on its side */ + if (get_tlv(&ie[6], ie[1], WPS_REGISTRAR_TLV) != 0) + bss->wps_capabilities |= G_SUPPLICANT_WPS_REGISTRAR; + + SUPPLICANT_DBG("WPS Methods 0x%x", bss->wps_capabilities); } }