Remove unneeded callbacks from 802.03 and 802.11 plugins
[connman] / include / iface.h
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 #ifndef __CONNMAN_IFACE_H
23 #define __CONNMAN_IFACE_H
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #include <netinet/in.h>
30
31 enum connman_iface_type {
32         CONNMAN_IFACE_TYPE_UNKNOWN   = 0,
33         CONNMAN_IFACE_TYPE_80203     = 1,
34         CONNMAN_IFACE_TYPE_80211     = 2,
35         CONNMAN_IFACE_TYPE_WIMAX     = 3,
36         CONNMAN_IFACE_TYPE_MODEM     = 4,
37         CONNMAN_IFACE_TYPE_BLUETOOTH = 5,
38 };
39
40 enum connman_iface_flags {
41         CONNMAN_IFACE_FLAG_RTNL     = (1 << 0),
42         CONNMAN_IFACE_FLAG_IPV4     = (1 << 1),
43         CONNMAN_IFACE_FLAG_IPV6     = (1 << 2),
44         CONNMAN_IFACE_FLAG_SCANNING = (1 << 3),
45 };
46
47 enum connman_iface_state {
48         CONNMAN_IFACE_STATE_UNKNOWN   = 0,
49         CONNMAN_IFACE_STATE_OFF       = 1,
50         CONNMAN_IFACE_STATE_ENABLED   = 2,
51         CONNMAN_IFACE_STATE_CONNECT   = 3,
52         CONNMAN_IFACE_STATE_CONFIG    = 4,
53         CONNMAN_IFACE_STATE_CARRIER   = 5,
54         CONNMAN_IFACE_STATE_READY     = 6,
55         CONNMAN_IFACE_STATE_SHUTDOWN  = 7,
56 };
57
58 enum connman_iface_policy {
59         CONNMAN_IFACE_POLICY_UNKNOWN = 0,
60         CONNMAN_IFACE_POLICY_OFF     = 1,
61         CONNMAN_IFACE_POLICY_IGNORE  = 2,
62         CONNMAN_IFACE_POLICY_AUTO    = 3,
63 };
64
65 enum connman_ipv4_method {
66         CONNMAN_IPV4_METHOD_UNKNOWN = 0,
67         CONNMAN_IPV4_METHOD_OFF     = 1,
68         CONNMAN_IPV4_METHOD_STATIC  = 2,
69         CONNMAN_IPV4_METHOD_DHCP    = 3,
70 };
71
72 struct connman_ipv4 {
73         enum connman_ipv4_method method;
74         struct in_addr address;
75         struct in_addr netmask;
76         struct in_addr gateway;
77         struct in_addr network;
78         struct in_addr broadcast;
79         struct in_addr nameserver;
80 };
81
82 struct connman_network {
83         char *essid;
84         char *psk;
85 };
86
87 struct connman_iface {
88         char *path;
89         char *udi;
90         char *sysfs;
91         char *identifier;
92         int index;
93         int carrier;
94         enum connman_iface_type type;
95         enum connman_iface_flags flags;
96         enum connman_iface_state state;
97         enum connman_iface_policy policy;
98         struct connman_network network;
99         struct connman_ipv4 ipv4;
100
101         struct connman_iface_driver *driver;
102         void *driver_data;
103
104         struct {
105                 char *driver;
106                 char *vendor;
107                 char *product;
108         } device;
109 };
110
111 struct connman_iface_driver {
112         const char *name;
113         const char *capability;
114         int (*probe) (struct connman_iface *iface);
115         void (*remove) (struct connman_iface *iface);
116         int (*activate) (struct connman_iface *iface);
117         int (*shutdown) (struct connman_iface *iface);
118         int (*get_ipv4) (struct connman_iface *iface,
119                                         struct connman_ipv4 *ipv4);
120         int (*set_ipv4) (struct connman_iface *iface,
121                                         struct connman_ipv4 *ipv4);
122         int (*scan) (struct connman_iface *iface);
123         int (*connect) (struct connman_iface *iface,
124                                         struct connman_network *network);
125         int (*disconnect) (struct connman_iface *iface);
126
127         void (*set_network) (struct connman_iface *iface,
128                                                 const char *network);
129         void (*set_passphrase) (struct connman_iface *iface,
130                                                 const char *passphrase);
131
132         void (*rtnl_carrier) (struct connman_iface *iface, int carrier);
133         void (*rtnl_wireless) (struct connman_iface *iface,
134                                         void *data, unsigned short len);
135 };
136
137 extern int connman_iface_register(struct connman_iface_driver *driver);
138 extern void connman_iface_unregister(struct connman_iface_driver *driver);
139
140 static inline void *connman_iface_get_data(struct connman_iface *iface)
141 {
142         return iface->driver_data;
143 }
144
145 static inline void connman_iface_set_data(struct connman_iface *iface,
146                                                                 void *data)
147 {
148         iface->driver_data = data;
149 }
150
151 extern int connman_iface_update(struct connman_iface *iface,
152                                         enum connman_iface_state state);
153
154 extern void connman_iface_indicate_carrier(struct connman_iface *iface,
155                                                         int carrier);
156
157 extern int connman_iface_get_ipv4(struct connman_iface *iface,
158                                                 struct connman_ipv4 *ipv4);
159 extern int connman_iface_set_ipv4(struct connman_iface *iface,
160                                                 struct connman_ipv4 *ipv4);
161 extern int connman_iface_clear_ipv4(struct connman_iface *iface);
162
163 #ifdef __cplusplus
164 }
165 #endif
166
167 #endif /* __CONNMAN_IFACE_H */