5 * Copyright (C) 2007-2010 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 #include <sys/ioctl.h>
31 #include <sys/socket.h>
32 #include <linux/if_arp.h>
33 #include <linux/wireless.h>
34 #include <net/ethernet.h>
37 #define IFF_LOWER_UP 0x10000
40 #include <dbus/dbus.h>
43 #define CONNMAN_API_SUBJECT_TO_CHANGE
44 #include <connman/plugin.h>
45 #include <connman/inet.h>
46 #include <connman/device.h>
47 #include <connman/rtnl.h>
48 #include <connman/technology.h>
49 #include <connman/log.h>
50 #include <connman/option.h>
52 #include <gsupplicant/gsupplicant.h>
54 #define CLEANUP_TIMEOUT 8 /* in seconds */
55 #define INACTIVE_TIMEOUT 12 /* in seconds */
57 struct connman_technology *wifi_technology = NULL;
61 struct connman_device *device;
62 struct connman_network *network;
63 struct connman_network *pending_network;
64 GSupplicantInterface *interface;
65 GSupplicantState state;
66 connman_bool_t connected;
67 connman_bool_t disconnecting;
68 connman_bool_t tethering;
74 static GList *iface_list = NULL;
76 static void wifi_newlink(unsigned flags, unsigned change, void *user_data)
78 struct connman_device *device = user_data;
79 struct wifi_data *wifi = connman_device_get_data(device);
81 DBG("index %d flags %d change %d", wifi->index, flags, change);
86 if ((wifi->flags & IFF_UP) != (flags & IFF_UP)) {
90 DBG("interface down");
93 if ((wifi->flags & IFF_LOWER_UP) != (flags & IFF_LOWER_UP)) {
94 if (flags & IFF_LOWER_UP)
103 static int wifi_probe(struct connman_device *device)
105 struct wifi_data *wifi;
107 DBG("device %p", device);
109 wifi = g_try_new0(struct wifi_data, 1);
113 wifi->connected = FALSE;
114 wifi->disconnecting = FALSE;
115 wifi->tethering = FALSE;
116 wifi->state = G_SUPPLICANT_STATE_INACTIVE;
118 connman_device_set_data(device, wifi);
119 wifi->device = connman_device_ref(device);
121 wifi->index = connman_device_get_index(device);
124 wifi->watch = connman_rtnl_add_newlink_watch(wifi->index,
125 wifi_newlink, device);
127 iface_list = g_list_append(iface_list, wifi);
132 static void wifi_remove(struct connman_device *device)
134 struct wifi_data *wifi = connman_device_get_data(device);
136 DBG("device %p", device);
141 iface_list = g_list_remove(iface_list, wifi);
143 if (wifi->pending_network != NULL) {
144 connman_network_unref(wifi->pending_network);
145 wifi->pending_network = NULL;
148 connman_device_set_data(device, NULL);
149 connman_device_unref(wifi->device);
150 connman_rtnl_remove_watch(wifi->watch);
152 g_supplicant_interface_set_data(wifi->interface, NULL);
154 g_free(wifi->identifier);
158 static void interface_create_callback(int result,
159 GSupplicantInterface *interface,
162 struct wifi_data *wifi = user_data;
164 DBG("result %d ifname %s", result,
165 g_supplicant_interface_get_ifname(interface));
170 wifi->interface = interface;
171 g_supplicant_interface_set_data(interface, wifi);
174 static void interface_remove_callback(int result,
175 GSupplicantInterface *interface,
178 struct wifi_data *wifi = user_data;
180 DBG("result %d", result);
185 wifi->interface = NULL;
189 static int wifi_enable(struct connman_device *device)
191 struct wifi_data *wifi = connman_device_get_data(device);
192 const char *interface = connman_device_get_string(device, "Interface");
193 const char *driver = connman_option_get_string("wifi");
195 DBG("device %p %p", device, wifi);
197 return g_supplicant_interface_create(interface, driver, NULL,
198 interface_create_callback,
202 static int wifi_disable(struct connman_device *device)
204 struct wifi_data *wifi = connman_device_get_data(device);
206 DBG("device %p", device);
208 wifi->connected = FALSE;
209 wifi->disconnecting = FALSE;
211 if (wifi->pending_network != NULL) {
212 connman_network_unref(wifi->pending_network);
213 wifi->pending_network = NULL;
216 return g_supplicant_interface_remove(wifi->interface,
217 interface_remove_callback,
221 static void scan_callback(int result, GSupplicantInterface *interface,
224 struct connman_device *device = user_data;
226 DBG("result %d", result);
229 connman_device_reset_scanning(device);
231 connman_device_set_scanning(device, FALSE);
234 static int wifi_scan(struct connman_device *device)
236 struct wifi_data *wifi = connman_device_get_data(device);
239 DBG("device %p %p", device, wifi->interface);
241 if (wifi->tethering == TRUE)
244 ret = g_supplicant_interface_scan(wifi->interface, scan_callback,
247 connman_device_set_scanning(device, TRUE);
252 static struct connman_device_driver wifi_ng_driver = {
254 .type = CONNMAN_DEVICE_TYPE_WIFI,
255 .priority = CONNMAN_DEVICE_PRIORITY_LOW,
257 .remove = wifi_remove,
258 .enable = wifi_enable,
259 .disable = wifi_disable,
263 static void system_ready(void)
267 if (connman_device_driver_register(&wifi_ng_driver) < 0)
268 connman_error("Failed to register WiFi driver");
271 static void system_killed(void)
275 connman_device_driver_unregister(&wifi_ng_driver);
278 static int network_probe(struct connman_network *network)
280 DBG("network %p", network);
285 static void network_remove(struct connman_network *network)
287 DBG("network %p", network);
290 static void connect_callback(int result, GSupplicantInterface *interface,
293 struct connman_network *network = user_data;
295 DBG("network %p result %d", network, result);
297 if (result == -ENOKEY) {
298 connman_network_set_error(network,
299 CONNMAN_NETWORK_ERROR_INVALID_KEY);
300 } else if (result < 0) {
301 connman_network_set_error(network,
302 CONNMAN_NETWORK_ERROR_CONFIGURE_FAIL);
306 static GSupplicantSecurity network_security(const char *security)
308 if (g_str_equal(security, "none") == TRUE)
309 return G_SUPPLICANT_SECURITY_NONE;
310 else if (g_str_equal(security, "wep") == TRUE)
311 return G_SUPPLICANT_SECURITY_WEP;
312 else if (g_str_equal(security, "psk") == TRUE)
313 return G_SUPPLICANT_SECURITY_PSK;
314 else if (g_str_equal(security, "wpa") == TRUE)
315 return G_SUPPLICANT_SECURITY_PSK;
316 else if (g_str_equal(security, "rsn") == TRUE)
317 return G_SUPPLICANT_SECURITY_PSK;
318 else if (g_str_equal(security, "ieee8021x") == TRUE)
319 return G_SUPPLICANT_SECURITY_IEEE8021X;
321 return G_SUPPLICANT_SECURITY_UNKNOWN;
324 static void ssid_init(GSupplicantSSID *ssid, struct connman_network *network)
326 const char *security, *passphrase;
328 memset(ssid, 0, sizeof(*ssid));
329 ssid->mode = G_SUPPLICANT_MODE_INFRA;
330 ssid->ssid = connman_network_get_blob(network, "WiFi.SSID",
333 security = connman_network_get_string(network, "WiFi.Security");
334 ssid->security = network_security(security);
335 passphrase = connman_network_get_string(network,
337 if (passphrase == NULL || strlen(passphrase) == 0)
338 ssid->passphrase = NULL;
340 ssid->passphrase = passphrase;
342 ssid->eap = connman_network_get_string(network, "WiFi.EAP");
345 * If our private key password is unset,
346 * we use the supplied passphrase. That is needed
347 * for PEAP where 2 passphrases (identity and client
348 * cert may have to be provided.
350 if (connman_network_get_string(network,
351 "WiFi.PrivateKeyPassphrase") == NULL)
352 connman_network_set_string(network,
353 "WiFi.PrivateKeyPassphrase",
355 /* We must have an identity for both PEAP and TLS */
356 ssid->identity = connman_network_get_string(network, "WiFi.Identity");
357 ssid->ca_cert_path = connman_network_get_string(network,
359 ssid->client_cert_path = connman_network_get_string(network,
360 "WiFi.ClientCertFile");
361 ssid->private_key_path = connman_network_get_string(network,
362 "WiFi.PrivateKeyFile");
363 ssid->private_key_passphrase = connman_network_get_string(network,
364 "WiFi.PrivateKeyPassphrase");
365 ssid->phase2_auth = connman_network_get_string(network, "WiFi.Phase2");
367 ssid->use_wps = connman_network_get_bool(network, "WiFi.UseWPS");
368 ssid->pin_wps = connman_network_get_string(network, "WiFi.PinWPS");
372 static int network_connect(struct connman_network *network)
374 struct connman_device *device = connman_network_get_device(network);
375 struct wifi_data *wifi;
376 GSupplicantInterface *interface;
377 GSupplicantSSID *ssid;
379 DBG("network %p", network);
384 wifi = connman_device_get_data(device);
388 ssid = g_try_malloc0(sizeof(GSupplicantSSID));
392 interface = wifi->interface;
394 ssid_init(ssid, network);
396 if (wifi->disconnecting == TRUE)
397 wifi->pending_network = connman_network_ref(network);
399 wifi->network = connman_network_ref(network);
401 return g_supplicant_interface_connect(interface, ssid,
402 connect_callback, network);
408 static void disconnect_callback(int result, GSupplicantInterface *interface,
411 struct wifi_data *wifi = user_data;
413 if (wifi->network != NULL) {
415 * if result < 0 supplican return an error because
416 * the network is not current.
417 * we wont receive G_SUPPLICANT_STATE_DISCONNECTED since it
418 * failed, call connman_network_set_connected to report
419 * disconnect is completed.
422 connman_network_set_connected(wifi->network, FALSE);
424 connman_network_unref(wifi->network);
427 wifi->network = NULL;
429 wifi->disconnecting = FALSE;
431 if (wifi->pending_network != NULL) {
432 network_connect(wifi->pending_network);
433 connman_network_unref(wifi->pending_network);
434 wifi->pending_network = NULL;
439 static int network_disconnect(struct connman_network *network)
441 struct connman_device *device = connman_network_get_device(network);
442 struct wifi_data *wifi;
445 DBG("network %p", network);
447 wifi = connman_device_get_data(device);
448 if (wifi == NULL || wifi->interface == NULL)
451 connman_network_set_associating(network, FALSE);
453 if (wifi->disconnecting == TRUE)
456 wifi->disconnecting = TRUE;
458 err = g_supplicant_interface_disconnect(wifi->interface,
459 disconnect_callback, wifi);
461 wifi->disconnecting = FALSE;
466 static struct connman_network_driver network_driver = {
468 .type = CONNMAN_NETWORK_TYPE_WIFI,
469 .priority = CONNMAN_NETWORK_PRIORITY_LOW,
470 .probe = network_probe,
471 .remove = network_remove,
472 .connect = network_connect,
473 .disconnect = network_disconnect,
476 static void interface_added(GSupplicantInterface *interface)
478 const char *ifname = g_supplicant_interface_get_ifname(interface);
479 const char *driver = g_supplicant_interface_get_driver(interface);
480 struct wifi_data *wifi;
482 wifi = g_supplicant_interface_get_data(interface);
485 * We can get here with a NULL wifi pointer when
486 * the interface added signal is sent before the
487 * interface creation callback is called.
492 DBG("ifname %s driver %s wifi %p tethering %d",
493 ifname, driver, wifi, wifi->tethering);
495 if (wifi->device == NULL) {
496 connman_error("WiFi device not set");
500 connman_device_set_powered(wifi->device, TRUE);
502 if (wifi->tethering == TRUE)
505 wifi_scan(wifi->device);
508 static connman_bool_t is_idle(struct wifi_data *wifi)
510 DBG("state %d", wifi->state);
512 switch (wifi->state) {
513 case G_SUPPLICANT_STATE_UNKNOWN:
514 case G_SUPPLICANT_STATE_DISCONNECTED:
515 case G_SUPPLICANT_STATE_INACTIVE:
516 case G_SUPPLICANT_STATE_SCANNING:
519 case G_SUPPLICANT_STATE_AUTHENTICATING:
520 case G_SUPPLICANT_STATE_ASSOCIATING:
521 case G_SUPPLICANT_STATE_ASSOCIATED:
522 case G_SUPPLICANT_STATE_4WAY_HANDSHAKE:
523 case G_SUPPLICANT_STATE_GROUP_HANDSHAKE:
524 case G_SUPPLICANT_STATE_COMPLETED:
531 static connman_bool_t is_idle_wps(GSupplicantInterface *interface,
532 struct wifi_data *wifi)
534 /* First, let's check if WPS processing did not went wrong */
535 if (g_supplicant_interface_get_wps_state(interface) ==
536 G_SUPPLICANT_WPS_STATE_FAIL)
539 /* Unlike normal connection, being associated while processing wps
540 * actually means that we are idling. */
541 switch (wifi->state) {
542 case G_SUPPLICANT_STATE_UNKNOWN:
543 case G_SUPPLICANT_STATE_DISCONNECTED:
544 case G_SUPPLICANT_STATE_INACTIVE:
545 case G_SUPPLICANT_STATE_SCANNING:
546 case G_SUPPLICANT_STATE_ASSOCIATED:
548 case G_SUPPLICANT_STATE_AUTHENTICATING:
549 case G_SUPPLICANT_STATE_ASSOCIATING:
550 case G_SUPPLICANT_STATE_4WAY_HANDSHAKE:
551 case G_SUPPLICANT_STATE_GROUP_HANDSHAKE:
552 case G_SUPPLICANT_STATE_COMPLETED:
559 static connman_bool_t handle_wps_completion(GSupplicantInterface *interface,
560 struct connman_network *network,
561 struct connman_device *device,
562 struct wifi_data *wifi)
566 wps = connman_network_get_bool(network, "WiFi.UseWPS");
568 const unsigned char *ssid, *wps_ssid;
569 unsigned int ssid_len, wps_ssid_len;
572 /* Checking if we got associated with requested
574 ssid = connman_network_get_blob(network, "WiFi.SSID",
577 wps_ssid = g_supplicant_interface_get_wps_ssid(
578 interface, &wps_ssid_len);
580 if (wps_ssid == NULL || wps_ssid_len != ssid_len ||
581 memcmp(ssid, wps_ssid, ssid_len) != 0) {
582 connman_network_set_associating(network, FALSE);
583 g_supplicant_interface_disconnect(wifi->interface,
584 disconnect_callback, wifi);
588 wps_key = g_supplicant_interface_get_wps_key(interface);
589 connman_network_set_string(network, "WiFi.Passphrase",
592 connman_network_set_string(network, "WiFi.PinWPS", NULL);
598 static void interface_state(GSupplicantInterface *interface)
600 struct connman_network *network;
601 struct connman_device *device;
602 struct wifi_data *wifi;
603 GSupplicantState state = g_supplicant_interface_get_state(interface);
606 wifi = g_supplicant_interface_get_data(interface);
608 DBG("wifi %p interface state %d", wifi, state);
613 network = wifi->network;
614 device = wifi->device;
616 if (device == NULL || network == NULL)
620 case G_SUPPLICANT_STATE_SCANNING:
623 case G_SUPPLICANT_STATE_AUTHENTICATING:
624 case G_SUPPLICANT_STATE_ASSOCIATING:
625 connman_network_set_associating(network, TRUE);
628 case G_SUPPLICANT_STATE_COMPLETED:
629 if (handle_wps_completion(interface, network, device, wifi) ==
633 /* reset scan trigger and schedule background scan */
634 connman_device_schedule_scan(device);
636 connman_network_set_connected(network, TRUE);
639 case G_SUPPLICANT_STATE_DISCONNECTED:
641 * If we're in one of the idle modes, we have
642 * not started association yet and thus setting
643 * those ones to FALSE could cancel an association
646 wps = connman_network_get_bool(network, "WiFi.UseWPS");
648 if (is_idle_wps(interface, wifi) == TRUE)
653 connman_network_set_associating(network, FALSE);
654 connman_network_set_connected(network, FALSE);
657 case G_SUPPLICANT_STATE_INACTIVE:
658 connman_network_set_associating(network, FALSE);
661 case G_SUPPLICANT_STATE_UNKNOWN:
662 case G_SUPPLICANT_STATE_ASSOCIATED:
663 case G_SUPPLICANT_STATE_4WAY_HANDSHAKE:
664 case G_SUPPLICANT_STATE_GROUP_HANDSHAKE:
673 static void interface_removed(GSupplicantInterface *interface)
675 const char *ifname = g_supplicant_interface_get_ifname(interface);
676 struct wifi_data *wifi;
678 DBG("ifname %s", ifname);
680 wifi = g_supplicant_interface_get_data(interface);
682 if (wifi != NULL && wifi->tethering == TRUE)
685 if (wifi == NULL || wifi->device == NULL) {
686 connman_error("Wrong wifi pointer");
690 connman_device_set_powered(wifi->device, FALSE);
693 static void scan_started(GSupplicantInterface *interface)
695 struct wifi_data *wifi;
699 wifi = g_supplicant_interface_get_data(interface);
705 static void scan_finished(GSupplicantInterface *interface)
707 struct wifi_data *wifi;
711 wifi = g_supplicant_interface_get_data(interface);
717 static unsigned char calculate_strength(GSupplicantNetwork *supplicant_network)
719 unsigned char strength;
721 strength = 120 + g_supplicant_network_get_signal(supplicant_network);
728 static void network_added(GSupplicantNetwork *supplicant_network)
730 struct connman_network *network;
731 GSupplicantInterface *interface;
732 struct wifi_data *wifi;
733 const char *name, *identifier, *mode, *security, *group;
734 const unsigned char *ssid;
735 unsigned int ssid_len;
740 interface = g_supplicant_network_get_interface(supplicant_network);
741 wifi = g_supplicant_interface_get_data(interface);
742 name = g_supplicant_network_get_name(supplicant_network);
743 identifier = g_supplicant_network_get_identifier(supplicant_network);
744 mode = g_supplicant_network_get_mode(supplicant_network);
745 security = g_supplicant_network_get_security(supplicant_network);
746 group = g_supplicant_network_get_identifier(supplicant_network);
747 wps = g_supplicant_network_get_wps(supplicant_network);
752 ssid = g_supplicant_network_get_ssid(supplicant_network, &ssid_len);
754 network = connman_device_get_network(wifi->device, identifier);
756 if (network == NULL) {
757 network = connman_network_create(identifier,
758 CONNMAN_NETWORK_TYPE_WIFI);
762 connman_network_set_index(network, wifi->index);
764 if (connman_device_add_network(wifi->device, network) < 0) {
765 connman_network_unref(network);
770 if (name != NULL && name[0] != '\0')
771 connman_network_set_name(network, name);
773 connman_network_set_blob(network, "WiFi.SSID",
775 connman_network_set_string(network, "WiFi.Mode", mode);
776 connman_network_set_string(network, "WiFi.Security", security);
777 connman_network_set_strength(network,
778 calculate_strength(supplicant_network));
779 connman_network_set_bool(network, "WiFi.WPS", wps);
781 connman_network_set_available(network, TRUE);
784 connman_network_set_group(network, group);
787 static void network_removed(GSupplicantNetwork *network)
789 GSupplicantInterface *interface;
790 struct wifi_data *wifi;
791 const char *name, *identifier;
793 interface = g_supplicant_network_get_interface(network);
794 wifi = g_supplicant_interface_get_data(interface);
795 identifier = g_supplicant_network_get_identifier(network);
796 name = g_supplicant_network_get_name(network);
798 DBG("name %s", name);
801 connman_device_remove_network(wifi->device, identifier);
804 static void debug(const char *str)
806 if (getenv("CONNMAN_SUPPLICANT_DEBUG"))
807 connman_debug("%s", str);
810 static const GSupplicantCallbacks callbacks = {
811 .system_ready = system_ready,
812 .system_killed = system_killed,
813 .interface_added = interface_added,
814 .interface_state = interface_state,
815 .interface_removed = interface_removed,
816 .scan_started = scan_started,
817 .scan_finished = scan_finished,
818 .network_added = network_added,
819 .network_removed = network_removed,
824 static int tech_probe(struct connman_technology *technology)
826 wifi_technology = technology;
831 static void tech_remove(struct connman_technology *technology)
833 wifi_technology = NULL;
836 struct wifi_tethering_info {
837 struct wifi_data *wifi;
838 struct connman_technology *technology;
841 GSupplicantSSID *ssid;
844 static GSupplicantSSID *ssid_ap_init(const char *ssid, const char *passphrase)
848 ap = g_try_malloc0(sizeof(GSupplicantSSID));
852 ap->mode = G_SUPPLICANT_MODE_MASTER;
854 ap->ssid_len = strlen(ssid);
858 if (passphrase == NULL || strlen(passphrase) == 0) {
859 ap->security = G_SUPPLICANT_SECURITY_NONE;
860 ap->passphrase = NULL;
862 ap->security = G_SUPPLICANT_SECURITY_PSK;
863 ap->protocol = G_SUPPLICANT_PROTO_RSN;
864 ap->pairwise_cipher = G_SUPPLICANT_PAIRWISE_CCMP;
865 ap->group_cipher = G_SUPPLICANT_GROUP_CCMP;
866 ap->passphrase = passphrase;
872 static void ap_start_callback(int result, GSupplicantInterface *interface,
875 struct wifi_tethering_info *info = user_data;
877 DBG("result %d index %d bridge %s",
878 result, info->wifi->index, info->bridge);
881 connman_inet_remove_from_bridge(info->wifi->index,
883 connman_technology_tethering_notify(info->technology, FALSE);
886 g_free(info->ifname);
890 static void ap_create_callback(int result,
891 GSupplicantInterface *interface,
894 struct wifi_tethering_info *info = user_data;
895 struct connman_technology *technology;
897 DBG("result %d ifname %s", result,
898 g_supplicant_interface_get_ifname(interface));
901 connman_inet_remove_from_bridge(info->wifi->index,
903 connman_technology_tethering_notify(info->technology, FALSE);
905 g_free(info->ifname);
910 info->wifi->interface = interface;
911 technology = info->technology;
912 g_supplicant_interface_set_data(interface, info->wifi);
914 if (g_supplicant_interface_set_apscan(interface, 2) < 0)
915 connman_error("Failed to set interface ap_scan property");
917 g_supplicant_interface_connect(interface, info->ssid,
918 ap_start_callback, info);
921 static void sta_remove_callback(int result,
922 GSupplicantInterface *interface,
925 struct wifi_tethering_info *info = user_data;
926 const char *driver = connman_option_get_string("wifi");
928 DBG("ifname %s result %d ", info->ifname, result);
931 info->wifi->tethering = TRUE;
933 g_free(info->ifname);
938 info->wifi->interface = NULL;
940 connman_technology_tethering_notify(info->technology, TRUE);
941 connman_inet_add_to_bridge(info->wifi->index, info->bridge);
943 g_supplicant_interface_create(info->ifname, driver, info->bridge,
948 static int tech_set_tethering(struct connman_technology *technology,
949 const char *identifier, const char *passphrase,
950 const char *bridge, connman_bool_t enabled)
953 GSupplicantInterface *interface;
954 struct wifi_data *wifi;
955 struct wifi_tethering_info *info;
962 if (enabled == FALSE) {
963 for (list = iface_list; list; list = list->next) {
966 if (wifi->tethering == TRUE) {
967 wifi->tethering = FALSE;
969 connman_inet_remove_from_bridge(wifi->index,
974 connman_technology_tethering_notify(technology, FALSE);
979 for (list = iface_list; list; list = list->next) {
982 interface = wifi->interface;
984 if (interface == NULL)
987 ifname = g_supplicant_interface_get_ifname(wifi->interface);
989 mode = g_supplicant_interface_get_mode(interface);
990 if ((mode & G_SUPPLICANT_CAPABILITY_MODE_AP) == 0) {
991 DBG("%s does not support AP mode", ifname);
995 info = g_try_malloc0(sizeof(struct wifi_tethering_info));
1000 info->technology = technology;
1001 info->bridge = bridge;
1002 info->ssid = ssid_ap_init(identifier, passphrase);
1003 if (info->ssid == NULL) {
1007 info->ifname = g_strdup(ifname);
1008 if (info->ifname == NULL) {
1013 info->wifi->tethering = TRUE;
1015 err = g_supplicant_interface_remove(interface,
1016 sta_remove_callback,
1025 static void regdom_callback(void *user_data)
1027 char *alpha2 = user_data;
1031 if (wifi_technology == NULL)
1034 connman_technology_regdom_notify(wifi_technology, alpha2);
1037 static int tech_set_regdom(struct connman_technology *technology, const char *alpha2)
1039 return g_supplicant_set_country(alpha2, regdom_callback, alpha2);
1042 static struct connman_technology_driver tech_driver = {
1044 .type = CONNMAN_SERVICE_TYPE_WIFI,
1045 .probe = tech_probe,
1046 .remove = tech_remove,
1047 .set_tethering = tech_set_tethering,
1048 .set_regdom = tech_set_regdom,
1051 static int wifi_init(void)
1055 err = connman_network_driver_register(&network_driver);
1059 err = g_supplicant_register(&callbacks);
1061 connman_network_driver_unregister(&network_driver);
1065 err = connman_technology_driver_register(&tech_driver);
1067 g_supplicant_unregister(&callbacks);
1068 connman_network_driver_unregister(&network_driver);
1075 static void wifi_exit(void)
1079 connman_technology_driver_unregister(&tech_driver);
1081 g_supplicant_unregister(&callbacks);
1083 connman_network_driver_unregister(&network_driver);
1086 CONNMAN_PLUGIN_DEFINE(wifi, "WiFi interface plugin", VERSION,
1087 CONNMAN_PLUGIN_PRIORITY_DEFAULT, wifi_init, wifi_exit)