Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: plugins/newwifi.c

Issue 6611013: Enable joining of IBSS (AdHoc) networks (Closed) Base URL: http://git.chromium.org/git/flimflam.git@master
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_AP 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
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 dbus_int32_t frequency = 0;
885
886 if (g_ascii_strcasecmp(mode_str, "managed") == 0) {
887 mode_val = SUPPLICANT_NETWORK_MODE_MANAGED;
888 } else if (g_ascii_strcasecmp(mode_str, "adhoc") == 0) {
889 mode_val = SUPPLICANT_NETWORK_MODE_ADHOC;
890
891 /*
892 * NB: wpa_supplicant does not use scan results for
893 * configuring IBSS so we need to manually select the
894 * frequency.
895 */
896 frequency = connman_network_get_uint16(network, "Frequency");
897
898 if (frequency != 0)
899 connman_dbus_dict_append_variant(dict, "frequency",
900 DBUS_TYPE_INT32,
901 &frequency);
902 } else if (g_ascii_strcasecmp(mode_str, "ap") == 0) {
Sam Leffler 2011/03/03 15:51:06 I prefer "hostap" to "ap" (if you change please al
Paul Stewart 2011/03/03 21:59:26 Done.
903 mode_val = SUPPLICANT_NETWORK_MODE_AP;
904 }
905
906 if (mode_val != SUPPLICANT_NETWORK_MODE_DEFAULT)
Sam Leffler 2011/03/03 15:51:06 do you need to avoid sending "mode"? (i.e. just dr
Paul Stewart 2011/03/03 21:59:26 Done.
907 connman_dbus_dict_append_variant(dict, "mode",
908 DBUS_TYPE_INT32, &mode_val);
909 }
910
872 /* 911 /*
873 * Append properties for the specified network to a dbus message. 912 * Append properties for the specified network to a dbus message.
874 */ 913 */
875 static void append_network_properties(struct supplicant_task *task, 914 static void append_network_properties(struct supplicant_task *task,
876 struct connman_network *network, DBusMessageIter *array) 915 struct connman_network *network, DBusMessageIter *array)
877 { 916 {
878 DBusMessageIter dict; 917 DBusMessageIter dict;
879 dbus_uint32_t scan_ssid = 1; /* NB: use directed ProbReq */ 918 dbus_uint32_t scan_ssid = 1; /* NB: use directed ProbReq */
880 const void *ssid; 919 const void *ssid;
881 unsigned int ssid_len; 920 unsigned int ssid_len;
(...skipping 21 matching lines...) Expand all
903 g_ascii_strcasecmp(security, "rsn") == 0) { 942 g_ascii_strcasecmp(security, "rsn") == 0) {
904 append_wpa(&dict, network); 943 append_wpa(&dict, network);
905 } else if (g_ascii_strcasecmp(security, "wep") == 0) { 944 } else if (g_ascii_strcasecmp(security, "wep") == 0) {
906 append_wep(&dict, network); 945 append_wep(&dict, network);
907 } else { 946 } else {
908 const char *key_mgmt = "NONE"; 947 const char *key_mgmt = "NONE";
909 connman_dbus_dict_append_variant(&dict, "key_mgmt", 948 connman_dbus_dict_append_variant(&dict, "key_mgmt",
910 DBUS_TYPE_STRING, &key_mgmt); 949 DBUS_TYPE_STRING, &key_mgmt);
911 } 950 }
912 951
952 append_mode(&dict, network);
953
913 dbus_message_iter_close_container(array, &dict); 954 dbus_message_iter_close_container(array, &dict);
914 } 955 }
915 956
916 /* 957 /*
917 * Add a new netblock with properties for the specified network. 958 * Add a new netblock with properties for the specified network.
918 */ 959 */
919 static char *network_add(struct supplicant_task *task, 960 static char *network_add(struct supplicant_task *task,
920 struct connman_network *network) 961 struct connman_network *network)
921 { 962 {
922 const char *request = "AddNetwork"; 963 const char *request = "AddNetwork";
(...skipping 2043 matching lines...) Expand 10 before | Expand all | Expand 10 after
2966 dbus_bus_remove_match(connection, bss_rule, NULL); 3007 dbus_bus_remove_match(connection, bss_rule, NULL);
2967 dbus_bus_remove_match(connection, interface_rule, NULL); 3008 dbus_bus_remove_match(connection, interface_rule, NULL);
2968 dbus_connection_flush(connection); 3009 dbus_connection_flush(connection);
2969 dbus_connection_remove_filter(connection, supplicant_filter, NULL); 3010 dbus_connection_remove_filter(connection, supplicant_filter, NULL);
2970 dbus_connection_unref(connection); 3011 dbus_connection_unref(connection);
2971 connection = NULL; 3012 connection = NULL;
2972 } 3013 }
2973 3014
2974 CONNMAN_PLUGIN_DEFINE(newwifi, "New WiFi interface", VERSION, 3015 CONNMAN_PLUGIN_DEFINE(newwifi, "New WiFi interface", VERSION,
2975 CONNMAN_PLUGIN_PRIORITY_DEFAULT, new_wifi_init, new_wifi_finis) 3016 CONNMAN_PLUGIN_PRIORITY_DEFAULT, new_wifi_init, new_wifi_finis)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698