5 * Copyright (C) 2007-2010 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>
33 #include <connman/types.h>
34 #include <connman/ipconfig.h>
38 * @title: Element premitives
39 * @short_description: Functions for handling elements
42 enum connman_element_type {
43 CONNMAN_ELEMENT_TYPE_UNKNOWN = 0,
44 CONNMAN_ELEMENT_TYPE_ROOT = 1,
45 CONNMAN_ELEMENT_TYPE_PROFILE = 2,
46 CONNMAN_ELEMENT_TYPE_DEVICE = 3,
47 CONNMAN_ELEMENT_TYPE_NETWORK = 4,
48 CONNMAN_ELEMENT_TYPE_SERVICE = 5,
49 CONNMAN_ELEMENT_TYPE_IPV4 = 7,
50 CONNMAN_ELEMENT_TYPE_IPV6 = 8,
51 CONNMAN_ELEMENT_TYPE_DHCP = 9,
52 CONNMAN_ELEMENT_TYPE_BOOTP = 10,
53 CONNMAN_ELEMENT_TYPE_ZEROCONF = 11,
54 CONNMAN_ELEMENT_TYPE_CONNECTION = 42,
55 CONNMAN_ELEMENT_TYPE_VENDOR = 10000,
58 enum connman_element_state {
59 CONNMAN_ELEMENT_STATE_UNKNOWN = 0,
60 CONNMAN_ELEMENT_STATE_ERROR = 1,
61 CONNMAN_ELEMENT_STATE_IDLE = 2,
62 CONNMAN_ELEMENT_STATE_DONE = 3,
65 enum connman_element_error {
66 CONNMAN_ELEMENT_ERROR_UNKNOWN = 0,
67 CONNMAN_ELEMENT_ERROR_FAILED = 1,
68 CONNMAN_ELEMENT_ERROR_DHCP_FAILED = 2,
69 CONNMAN_ELEMENT_ERROR_CONNECT_FAILED = 3,
72 struct connman_driver;
74 struct connman_element {
79 enum connman_element_type type;
80 enum connman_element_state state;
81 enum connman_element_error error;
86 struct connman_element *parent;
88 struct connman_driver *driver;
91 void (*destruct) (struct connman_element *element);
95 struct connman_device *device;
96 struct connman_network *network;
99 GHashTable *properties;
102 enum connman_ipconfig_method method;
114 enum connman_ipconfig_method method;
122 struct connman_element *connman_element_create(const char *name);
123 struct connman_element *connman_element_ref(struct connman_element *element);
124 void connman_element_unref(struct connman_element *element);
126 int connman_element_get_value(struct connman_element *element,
127 enum connman_property_id id, void *value);
129 int connman_element_set_string(struct connman_element *element,
130 const char *key, const char *value);
131 const char *connman_element_get_string(struct connman_element *element,
133 int connman_element_set_bool(struct connman_element *element,
134 const char *key, connman_bool_t value);
135 connman_bool_t connman_element_get_bool(struct connman_element *element,
137 int connman_element_set_uint8(struct connman_element *element,
138 const char *key, connman_uint8_t value);
139 connman_uint8_t connman_element_get_uint8(struct connman_element *element,
141 int connman_element_set_blob(struct connman_element *element,
142 const char *key, const void *data, unsigned int size);
143 const void *connman_element_get_blob(struct connman_element *element,
144 const char *key, unsigned int *size);
146 int connman_element_register(struct connman_element *element,
147 struct connman_element *parent);
148 void connman_element_unregister(struct connman_element *element);
149 void connman_element_unregister_children(struct connman_element *element);
150 void connman_element_unregister_children_type(struct connman_element *element,
151 enum connman_element_type type);
152 void connman_element_update(struct connman_element *element);
154 int connman_element_set_enabled(struct connman_element *element,
156 void connman_element_set_error(struct connman_element *element,
157 enum connman_element_error error);
159 static inline void *connman_element_get_data(struct connman_element *element)
161 return element->driver_data;
164 static inline void connman_element_set_data(struct connman_element *element,
167 element->driver_data = data;
174 #endif /* __CONNMAN_ELEMENT_H */