5 * Copyright (C) 2007-2008 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
22 #ifndef __CONNMAN_ELEMENT_H
23 #define __CONNMAN_ELEMENT_H
32 #include <connman/property.h>
36 * @title: Element premitives
37 * @short_description: Functions for handling elements
40 enum connman_element_state {
41 CONNMAN_ELEMENT_STATE_UNKNOWN = 0,
42 CONNMAN_ELEMENT_STATE_CONNECT = 1,
43 CONNMAN_ELEMENT_STATE_CONNECTED = 2,
44 CONNMAN_ELEMENT_STATE_CLOSED = 3,
47 enum connman_element_type {
48 CONNMAN_ELEMENT_TYPE_UNKNOWN = 0,
49 CONNMAN_ELEMENT_TYPE_ROOT = 1,
50 CONNMAN_ELEMENT_TYPE_DEVICE = 2,
51 CONNMAN_ELEMENT_TYPE_NETWORK = 3,
52 CONNMAN_ELEMENT_TYPE_IPV4 = 4,
53 CONNMAN_ELEMENT_TYPE_IPV6 = 5,
54 CONNMAN_ELEMENT_TYPE_DHCP = 6,
55 CONNMAN_ELEMENT_TYPE_BOOTP = 7,
56 CONNMAN_ELEMENT_TYPE_ZEROCONF = 8,
57 CONNMAN_ELEMENT_TYPE_RESOLVER = 9,
59 CONNMAN_ELEMENT_TYPE_INTERNET = 42,
62 enum connman_element_subtype {
63 CONNMAN_ELEMENT_SUBTYPE_UNKNOWN = 0,
64 CONNMAN_ELEMENT_SUBTYPE_ETHERNET = 1,
65 CONNMAN_ELEMENT_SUBTYPE_WIFI = 2,
66 CONNMAN_ELEMENT_SUBTYPE_WIMAX = 3,
67 CONNMAN_ELEMENT_SUBTYPE_MODEM = 4,
68 CONNMAN_ELEMENT_SUBTYPE_BLUETOOTH = 5,
71 struct connman_driver;
73 struct connman_element {
78 enum connman_element_type type;
79 enum connman_element_subtype subtype;
80 enum connman_element_state state;
84 struct connman_element *parent;
86 struct connman_driver *driver;
111 #define connman_element_lock(element) g_static_mutex_lock(&(element)->mutex)
112 #define connman_element_unlock(element) g_static_mutex_unlock(&(element)->mutex)
114 extern struct connman_element *connman_element_create(void);
115 extern struct connman_element *connman_element_ref(struct connman_element *element);
116 extern void connman_element_unref(struct connman_element *element);
118 extern int connman_element_add_static_property(struct connman_element *element,
119 const char *name, int type, const void *value);
120 extern int connman_element_set_property(struct connman_element *element,
121 enum connman_property_type type, const void *value);
122 extern int connman_element_get_value(struct connman_element *element,
123 enum connman_property_type type, void *value);
125 extern int connman_element_register(struct connman_element *element,
126 struct connman_element *parent);
127 extern void connman_element_unregister(struct connman_element *element);
128 extern void connman_element_unregister_children(struct connman_element *element);
129 extern void connman_element_update(struct connman_element *element);
131 static inline void *connman_element_get_data(struct connman_element *element)
133 return element->driver_data;
136 static inline void connman_element_set_data(struct connman_element *element,
139 element->driver_data = data;
146 #endif /* __CONNMAN_ELEMENT_H */