dfcbd0f001b210f12a25981025f5440d1453bb98
[connman] / include / element.h
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 #ifndef __CONNMAN_ELEMENT_H
23 #define __CONNMAN_ELEMENT_H
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #include <errno.h>
30 #include <glib.h>
31
32 enum connman_element_state {
33         CONNMAN_ELEMENT_STATE_UNKNOWN   = 0,
34         CONNMAN_ELEMENT_STATE_CONNECT   = 1,
35         CONNMAN_ELEMENT_STATE_CONNECTED = 2,
36         CONNMAN_ELEMENT_STATE_CLOSED    = 3,
37 };
38
39 enum connman_element_type {
40         CONNMAN_ELEMENT_TYPE_UNKNOWN    = 0,
41         CONNMAN_ELEMENT_TYPE_ROOT       = 1,
42         CONNMAN_ELEMENT_TYPE_DEVICE     = 2,
43         CONNMAN_ELEMENT_TYPE_NETWORK    = 3,
44         CONNMAN_ELEMENT_TYPE_IPV4       = 4,
45         CONNMAN_ELEMENT_TYPE_IPV6       = 5,
46         CONNMAN_ELEMENT_TYPE_DHCP       = 6,
47         CONNMAN_ELEMENT_TYPE_BOOTP      = 7,
48         CONNMAN_ELEMENT_TYPE_ZEROCONF   = 8,
49
50         CONNMAN_ELEMENT_TYPE_CONNECTION = 42,
51 };
52
53 enum connman_element_subtype {
54         CONNMAN_ELEMENT_SUBTYPE_UNKNOWN   = 0,
55         CONNMAN_ELEMENT_SUBTYPE_ETHERNET  = 1,
56         CONNMAN_ELEMENT_SUBTYPE_WIFI      = 2,
57         CONNMAN_ELEMENT_SUBTYPE_WIMAX     = 3,
58         CONNMAN_ELEMENT_SUBTYPE_MODEM     = 4,
59         CONNMAN_ELEMENT_SUBTYPE_BLUETOOTH = 5,
60 };
61
62 struct connman_driver;
63
64 struct connman_element {
65         gint refcount;
66         gchar *name;
67         gchar *path;
68         enum connman_element_type type;
69         enum connman_element_subtype subtype;
70         enum connman_element_state state;
71
72         struct connman_element *parent;
73
74         struct connman_driver *driver;
75         void *driver_data;
76
77         struct {
78                 gchar *driver;
79                 gchar *vendor;
80                 gchar *product;
81         } info;
82
83         struct {
84                 int index;
85                 short flags;
86                 gchar *name;
87         } netdev;
88
89         struct {
90                 gchar *address;
91                 gchar *netmask;
92                 gchar *gateway;
93                 gchar *network;
94                 gchar *broadcast;
95                 gchar *nameserver;
96         } ipv4;
97 };
98
99 extern struct connman_element *connman_element_create(void);
100 extern struct connman_element *connman_element_ref(struct connman_element *element);
101 extern void connman_element_unref(struct connman_element *element);
102
103 extern int connman_element_register(struct connman_element *element,
104                                         struct connman_element *parent);
105 extern void connman_element_unregister(struct connman_element *element);
106 extern void connman_element_update(struct connman_element *element);
107
108 static inline void *connman_element_get_data(struct connman_element *element)
109 {
110         return element->driver_data;
111 }
112
113 static inline void connman_element_set_data(struct connman_element *element,
114                                                                 void *data)
115 {
116         element->driver_data = data;
117 }
118
119 #ifdef __cplusplus
120 }
121 #endif
122
123 #endif /* __CONNMAN_ELEMENT_H */