Add resolver plugin using resolvconf helper tool
[connman] / plugins / 80203.c
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007  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 <stdio.h>
27 #include <errno.h>
28 #include <sys/stat.h>
29
30 #include <connman/plugin.h>
31 #include <connman/iface.h>
32 #include <connman/log.h>
33
34 static int ethernet_probe(struct connman_iface *iface)
35 {
36         char sysfs_path[PATH_MAX];
37         struct stat st;
38
39         DBG("iface %p", iface);
40
41         snprintf(sysfs_path, PATH_MAX, "%s/bridge", iface->sysfs);
42
43         if (stat(sysfs_path, &st) == 0 && (st.st_mode & S_IFDIR))
44                 return -ENODEV;
45
46         iface->type = CONNMAN_IFACE_TYPE_80203;
47
48         iface->flags = CONNMAN_IFACE_FLAG_RTNL |
49                                 CONNMAN_IFACE_FLAG_IPV4;
50
51         return 0;
52 }
53
54 static void ethernet_remove(struct connman_iface *iface)
55 {
56         DBG("iface %p", iface);
57 }
58
59 static struct connman_iface_driver ethernet_driver = {
60         .name           = "80203",
61         .capability     = "net.80203",
62         .probe          = ethernet_probe,
63         .remove         = ethernet_remove,
64 };
65
66 static int ethernet_init(void)
67 {
68         return connman_iface_register(&ethernet_driver);
69 }
70
71 static void ethernet_exit(void)
72 {
73         connman_iface_unregister(&ethernet_driver);
74 }
75
76 CONNMAN_PLUGIN_DEFINE("80203", "IEEE 802.03 interface plugin", VERSION,
77                                                 ethernet_init, ethernet_exit)