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_BLUETOOTH_PAN = 8,
45 CONNMAN_NETWORK_TYPE_BLUETOOTH_DUN = 9,
46 CONNMAN_NETWORK_TYPE_CELLULAR = 10,
47 CONNMAN_NETWORK_TYPE_VENDOR = 10000,
50 enum connman_network_error {
51 CONNMAN_NETWORK_ERROR_UNKNOWN = 0,
52 CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL = 1,
53 CONNMAN_NETWORK_ERROR_CONFIGURE_FAIL = 2,
54 CONNMAN_NETWORK_ERROR_INVALID_KEY = 3,
55 CONNMAN_NETWORK_ERROR_CONNECT_FAIL = 4,
58 #define CONNMAN_NETWORK_PRIORITY_LOW -100
59 #define CONNMAN_NETWORK_PRIORITY_DEFAULT 0
60 #define CONNMAN_NETWORK_PRIORITY_HIGH 100
62 struct connman_network;
64 struct connman_network *connman_network_create(const char *identifier,
65 enum connman_network_type type);
67 #define connman_network_ref(network) \
68 connman_network_ref_debug(network, __FILE__, __LINE__, __func__)
70 #define connman_network_unref(network) \
71 connman_network_unref_debug(network, __FILE__, __LINE__, __func__)
73 struct connman_network *
74 connman_network_ref_debug(struct connman_network *network,
75 const char *file, int line, const char *caller);
76 void connman_network_unref_debug(struct connman_network *network,
77 const char *file, int line, const char *caller);
79 enum connman_network_type connman_network_get_type(struct connman_network *network);
80 const char *connman_network_get_identifier(struct connman_network *network);
82 void connman_network_set_index(struct connman_network *network, int index);
83 int connman_network_get_index(struct connman_network *network);
85 void connman_network_set_group(struct connman_network *network,
87 const char *connman_network_get_group(struct connman_network *network);
89 connman_bool_t connman_network_get_connecting(struct connman_network *network);
90 int connman_network_set_available(struct connman_network *network,
91 connman_bool_t available);
92 connman_bool_t connman_network_get_available(struct connman_network *network);
93 int connman_network_set_associating(struct connman_network *network,
94 connman_bool_t associating);
95 void connman_network_set_error(struct connman_network *network,
96 enum connman_network_error error);
97 void connman_network_clear_error(struct connman_network *network);
98 int connman_network_set_connected(struct connman_network *network,
99 connman_bool_t connected);
100 connman_bool_t connman_network_get_connected(struct connman_network *network);
102 connman_bool_t connman_network_get_associating(struct connman_network *network);
104 void connman_network_clear_hidden(void *user_data);
105 int connman_network_connect_hidden(struct connman_network *network,
106 char *identity, char* passphrase, void *user_data);
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 */