Rewrite supplicant support for new element infrastructure
[connman] / plugins / wifi.c
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007-2008  Intel Corporation. All rights reserved.
6  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <connman/plugin.h>
27 #include <connman/driver.h>
28 #include <connman/log.h>
29
30 #include "supplicant.h"
31
32 static void scan_result(struct connman_element *element,
33                                         struct supplicant_network *network)
34 {
35         DBG("element %p name %s", element, element->name);
36
37         DBG("network %p identifier %s", network, network->identifier);
38 }
39
40 static struct supplicant_callback wifi_callback = {
41         .scan_result    = scan_result,
42 };
43
44 static int wifi_probe(struct connman_element *element)
45 {
46         int err;
47
48         DBG("element %p name %s", element, element->name);
49
50         err = __supplicant_start(element, &wifi_callback);
51         if (err < 0)
52                 return err;
53
54         __supplicant_scan(element);
55
56         return 0;
57 }
58
59 static void wifi_remove(struct connman_element *element)
60 {
61         DBG("element %p name %s", element, element->name);
62
63         __supplicant_stop(element);
64 }
65
66 static struct connman_driver wifi_driver = {
67         .name           = "wifi",
68         .type           = CONNMAN_ELEMENT_TYPE_DEVICE,
69         .subtype        = CONNMAN_ELEMENT_SUBTYPE_WIFI,
70         .probe          = wifi_probe,
71         .remove         = wifi_remove,
72 };
73
74 static int wifi_init(void)
75 {
76         return connman_driver_register(&wifi_driver);
77 }
78
79 static void wifi_exit(void)
80 {
81         connman_driver_unregister(&wifi_driver);
82 }
83
84 CONNMAN_PLUGIN_DEFINE("WiFi", "WiFi interface plugin", VERSION,
85                                                         wifi_init, wifi_exit)