6 * Copyright (C) 2007-2012 Intel Corporation. All rights reserved.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef __CONNMAN_NETWORK_H
24 #define __CONNMAN_NETWORK_H
26 #include <connman/types.h>
27 #include <connman/device.h>
28 #include <connman/ipconfig.h>
36 * @title: Network premitives
37 * @short_description: Functions for handling networks
40 enum connman_network_type {
41 CONNMAN_NETWORK_TYPE_UNKNOWN = 0,
42 CONNMAN_NETWORK_TYPE_ETHERNET = 1,
43 CONNMAN_NETWORK_TYPE_WIFI = 2,
44 CONNMAN_NETWORK_TYPE_WIMAX = 3,
45 CONNMAN_NETWORK_TYPE_BLUETOOTH_PAN = 8,
46 CONNMAN_NETWORK_TYPE_BLUETOOTH_DUN = 9,
47 CONNMAN_NETWORK_TYPE_CELLULAR = 10,
48 CONNMAN_NETWORK_TYPE_VENDOR = 10000,
51 enum connman_network_error {
52 CONNMAN_NETWORK_ERROR_UNKNOWN = 0,
53 CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL = 1,
54 CONNMAN_NETWORK_ERROR_CONFIGURE_FAIL = 2,
55 CONNMAN_NETWORK_ERROR_INVALID_KEY = 3,
56 CONNMAN_NETWORK_ERROR_CONNECT_FAIL = 4,
59 #define CONNMAN_NETWORK_PRIORITY_LOW -100
60 #define CONNMAN_NETWORK_PRIORITY_DEFAULT 0
61 #define CONNMAN_NETWORK_PRIORITY_HIGH 100
63 struct connman_network;
65 struct connman_network *connman_network_create(const char *identifier,
66 enum connman_network_type type);
68 #define connman_network_ref(network) \
69 connman_network_ref_debug(network, __FILE__, __LINE__, __func__)
71 #define connman_network_unref(network) \
72 connman_network_unref_debug(network, __FILE__, __LINE__, __func__)
74 struct connman_network *
75 connman_network_ref_debug(struct connman_network *network,
76 const char *file, int line, const char *caller);
77 void connman_network_unref_debug(struct connman_network *network,
78 const char *file, int line, const char *caller);
80 enum connman_network_type connman_network_get_type(struct connman_network *network);
81 const char *connman_network_get_identifier(struct connman_network *network);
83 void connman_network_set_index(struct connman_network *network, int index);
84 int connman_network_get_index(struct connman_network *network);
86 void connman_network_set_group(struct connman_network *network,
88 const char *connman_network_get_group(struct connman_network *network);
90 connman_bool_t connman_network_get_connecting(struct connman_network *network);
91 int connman_network_set_available(struct connman_network *network,
92 connman_bool_t available);
93 connman_bool_t connman_network_get_available(struct connman_network *network);
94 int connman_network_set_associating(struct connman_network *network,
95 connman_bool_t associating);
96 void connman_network_set_error(struct connman_network *network,
97 enum connman_network_error error);
98 void connman_network_clear_error(struct connman_network *network);
99 int connman_network_set_connected(struct connman_network *network,
100 connman_bool_t connected);
101 connman_bool_t connman_network_get_connected(struct connman_network *network);
103 connman_bool_t connman_network_get_associating(struct connman_network *network);
105 int connman_network_connect_hidden(struct connman_network *network,
106 char *identity, char* passphrase);
108 void connman_network_set_ipv4_method(struct connman_network *network,
109 enum connman_ipconfig_method method);
110 void connman_network_set_ipv6_method(struct connman_network *network,
111 enum connman_ipconfig_method method);
112 int connman_network_set_ipaddress(struct connman_network *network,
113 struct connman_ipaddress *ipaddress);
114 int connman_network_set_nameservers(struct connman_network *network,
115 const char *nameservers);
116 int connman_network_set_domain(struct connman_network *network,
118 int connman_network_set_name(struct connman_network *network,
120 int connman_network_set_strength(struct connman_network *network,
121 connman_uint8_t strength);
122 connman_uint8_t connman_network_get_strength(struct connman_network *network);
123 int connman_network_set_frequency(struct connman_network *network,
124 connman_uint16_t frequency);
125 connman_uint16_t connman_network_get_frequency(struct connman_network *network);
126 int connman_network_set_wifi_channel(struct connman_network *network,
127 connman_uint16_t channel);
128 connman_uint16_t connman_network_get_wifi_channel(struct connman_network *network);
130 int connman_network_set_string(struct connman_network *network,
131 const char *key, const char *value);
132 const char *connman_network_get_string(struct connman_network *network,
134 int connman_network_set_bool(struct connman_network *network,
135 const char *key, connman_bool_t value);
136 connman_bool_t connman_network_get_bool(struct connman_network *network,
138 int connman_network_set_blob(struct connman_network *network,
139 const char *key, const void *data, unsigned int size);
140 const void *connman_network_get_blob(struct connman_network *network,
141 const char *key, unsigned int *size);
143 struct connman_device *connman_network_get_device(struct connman_network *network);
145 void *connman_network_get_data(struct connman_network *network);
146 void connman_network_set_data(struct connman_network *network, void *data);
148 void connman_network_update(struct connman_network *network);
150 struct connman_network_driver {
152 enum connman_network_type type;
154 int (*probe) (struct connman_network *network);
155 void (*remove) (struct connman_network *network);
156 int (*connect) (struct connman_network *network);
157 int (*disconnect) (struct connman_network *network);
160 int connman_network_driver_register(struct connman_network_driver *driver);
161 void connman_network_driver_unregister(struct connman_network_driver *driver);
167 #endif /* __CONNMAN_NETWORK_H */