| OLD | NEW |
| 1 /* | 1 /* |
| 2 * New WiFi - communicate with wpa_supplicant using the "new D-Bus api" | 2 * New WiFi - communicate with wpa_supplicant using the "new D-Bus api" |
| 3 * | 3 * |
| 4 * This file initially created by Google, Inc. | 4 * This file initially created by Google, Inc. |
| 5 * | 5 * |
| 6 * This program is free software; you can redistribute it and/or modify | 6 * This program is free software; you can redistribute it and/or modify |
| 7 * it under the terms of the GNU General Public License version 2 as | 7 * it under the terms of the GNU General Public License version 2 as |
| 8 * published by the Free Software Foundation. | 8 * published by the Free Software Foundation. |
| 9 * | 9 * |
| 10 * This program is distributed in the hope that it will be useful, | 10 * This program is distributed in the hope that it will be useful, |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 * Supplicant scan result request parameters. | 196 * Supplicant scan result request parameters. |
| 197 */ | 197 */ |
| 198 struct supplicant_scan_request { | 198 struct supplicant_scan_request { |
| 199 const char *scan_type; | 199 const char *scan_type; |
| 200 GSList *ssids; | 200 GSList *ssids; |
| 201 }; | 201 }; |
| 202 | 202 |
| 203 #define MAX_SSID_LEN 32 /* 802.11 SSID length (octets) */ | 203 #define MAX_SSID_LEN 32 /* 802.11 SSID length (octets) */ |
| 204 | 204 |
| 205 /* | 205 /* |
| 206 * Supplicant network modes |
| 207 */ |
| 208 #define SUPPLICANT_NETWORK_MODE_MANAGED 0 |
| 209 #define SUPPLICANT_NETWORK_MODE_ADHOC 1 |
| 210 #define SUPPLICANT_NETWORK_MODE_HOSTAP 2 |
| 211 #define SUPPLICANT_NETWORK_MODE_DEFAULT SUPPLICANT_NETWORK_MODE_MANAGED |
| 212 |
| 213 /* |
| 206 * Per-bss state collected from supplicant scan results. | 214 * Per-bss state collected from supplicant scan results. |
| 207 */ | 215 */ |
| 208 struct supplicant_result { | 216 struct supplicant_result { |
| 209 char path[2*ETH_ALEN+2*MAX_SSID_LEN+1]; | 217 char path[2*ETH_ALEN+2*MAX_SSID_LEN+1]; |
| 210 char name[MAX_SSID_LEN+1]; | 218 char name[MAX_SSID_LEN+1]; |
| 211 unsigned char addr[ETH_ALEN]; | 219 unsigned char addr[ETH_ALEN]; |
| 212 unsigned char ssid[MAX_SSID_LEN]; | 220 unsigned char ssid[MAX_SSID_LEN]; |
| 213 unsigned int ssid_len; | 221 unsigned int ssid_len; |
| 214 gboolean privacy; | 222 gboolean privacy; |
| 215 gboolean has_wpa_psk; | 223 gboolean has_wpa_psk; |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 snprintf(key_name, sizeof(key_name), "wep_key%d", key_index); | 870 snprintf(key_name, sizeof(key_name), "wep_key%d", key_index); |
| 863 | 871 |
| 864 key_matter = connman_network_get_blob(network, "WiFi.WEPKey", &key_len); | 872 key_matter = connman_network_get_blob(network, "WiFi.WEPKey", &key_len); |
| 865 CONNMAN_ASSERT(key_matter != NULL); | 873 CONNMAN_ASSERT(key_matter != NULL); |
| 866 append_byte_array(dict, key_name, key_matter, key_len); | 874 append_byte_array(dict, key_name, key_matter, key_len); |
| 867 | 875 |
| 868 connman_dbus_dict_append_variant(dict, "wep_tx_keyidx", | 876 connman_dbus_dict_append_variant(dict, "wep_tx_keyidx", |
| 869 DBUS_TYPE_UINT32, &key_index); | 877 DBUS_TYPE_UINT32, &key_index); |
| 870 } | 878 } |
| 871 | 879 |
| 880 static void append_mode(DBusMessageIter *dict, struct connman_network *network) |
| 881 { |
| 882 dbus_int32_t mode_val = SUPPLICANT_NETWORK_MODE_DEFAULT; |
| 883 const char *mode_str = connman_network_get_string(network, "WiFi.Mode"); |
| 884 |
| 885 if (g_ascii_strcasecmp(mode_str, "managed") == 0) |
| 886 mode_val = SUPPLICANT_NETWORK_MODE_MANAGED; |
| 887 else if (g_ascii_strcasecmp(mode_str, "adhoc") == 0) { |
| 888 /* |
| 889 * NB: wpa_supplicant does not use scan results for |
| 890 * configuring IBSS so we need to manually select the |
| 891 * frequency. |
| 892 */ |
| 893 dbus_int32_t frequency = |
| 894 connman_network_get_uint16(network, "Frequency"); |
| 895 |
| 896 if (frequency != 0) |
| 897 connman_dbus_dict_append_variant(dict, "frequency", |
| 898 DBUS_TYPE_INT32, |
| 899 &frequency); |
| 900 mode_val = SUPPLICANT_NETWORK_MODE_ADHOC; |
| 901 } else if (g_ascii_strcasecmp(mode_str, "hostap") == 0) |
| 902 mode_val = SUPPLICANT_NETWORK_MODE_HOSTAP; |
| 903 |
| 904 connman_dbus_dict_append_variant(dict, "mode", |
| 905 DBUS_TYPE_INT32, &mode_val); |
| 906 } |
| 907 |
| 872 /* | 908 /* |
| 873 * Append properties for the specified network to a dbus message. | 909 * Append properties for the specified network to a dbus message. |
| 874 */ | 910 */ |
| 875 static void append_network_properties(struct supplicant_task *task, | 911 static void append_network_properties(struct supplicant_task *task, |
| 876 struct connman_network *network, DBusMessageIter *array) | 912 struct connman_network *network, DBusMessageIter *array) |
| 877 { | 913 { |
| 878 DBusMessageIter dict; | 914 DBusMessageIter dict; |
| 879 dbus_uint32_t scan_ssid = 1; /* NB: use directed ProbReq */ | 915 dbus_uint32_t scan_ssid = 1; /* NB: use directed ProbReq */ |
| 880 const void *ssid; | 916 const void *ssid; |
| 881 unsigned int ssid_len; | 917 unsigned int ssid_len; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 903 g_ascii_strcasecmp(security, "rsn") == 0) { | 939 g_ascii_strcasecmp(security, "rsn") == 0) { |
| 904 append_wpa(&dict, network); | 940 append_wpa(&dict, network); |
| 905 } else if (g_ascii_strcasecmp(security, "wep") == 0) { | 941 } else if (g_ascii_strcasecmp(security, "wep") == 0) { |
| 906 append_wep(&dict, network); | 942 append_wep(&dict, network); |
| 907 } else { | 943 } else { |
| 908 const char *key_mgmt = "NONE"; | 944 const char *key_mgmt = "NONE"; |
| 909 connman_dbus_dict_append_variant(&dict, "key_mgmt", | 945 connman_dbus_dict_append_variant(&dict, "key_mgmt", |
| 910 DBUS_TYPE_STRING, &key_mgmt); | 946 DBUS_TYPE_STRING, &key_mgmt); |
| 911 } | 947 } |
| 912 | 948 |
| 949 append_mode(&dict, network); |
| 950 |
| 913 dbus_message_iter_close_container(array, &dict); | 951 dbus_message_iter_close_container(array, &dict); |
| 914 } | 952 } |
| 915 | 953 |
| 916 /* | 954 /* |
| 917 * Add a new netblock with properties for the specified network. | 955 * Add a new netblock with properties for the specified network. |
| 918 */ | 956 */ |
| 919 static char *network_add(struct supplicant_task *task, | 957 static char *network_add(struct supplicant_task *task, |
| 920 struct connman_network *network) | 958 struct connman_network *network) |
| 921 { | 959 { |
| 922 const char *request = "AddNetwork"; | 960 const char *request = "AddNetwork"; |
| (...skipping 2043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2966 dbus_bus_remove_match(connection, bss_rule, NULL); | 3004 dbus_bus_remove_match(connection, bss_rule, NULL); |
| 2967 dbus_bus_remove_match(connection, interface_rule, NULL); | 3005 dbus_bus_remove_match(connection, interface_rule, NULL); |
| 2968 dbus_connection_flush(connection); | 3006 dbus_connection_flush(connection); |
| 2969 dbus_connection_remove_filter(connection, supplicant_filter, NULL); | 3007 dbus_connection_remove_filter(connection, supplicant_filter, NULL); |
| 2970 dbus_connection_unref(connection); | 3008 dbus_connection_unref(connection); |
| 2971 connection = NULL; | 3009 connection = NULL; |
| 2972 } | 3010 } |
| 2973 | 3011 |
| 2974 CONNMAN_PLUGIN_DEFINE(newwifi, "New WiFi interface", VERSION, | 3012 CONNMAN_PLUGIN_DEFINE(newwifi, "New WiFi interface", VERSION, |
| 2975 CONNMAN_PLUGIN_PRIORITY_DEFAULT, new_wifi_init, new_wifi_finis) | 3013 CONNMAN_PLUGIN_PRIORITY_DEFAULT, new_wifi_init, new_wifi_finis) |
| OLD | NEW |