Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sol-netctl.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Soletta (TM) Project
3  *
4  * Copyright (C) 2015 Intel Corporation. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #pragma once
20 
21 #include <stdbool.h>
22 #include <stdint.h>
23 #include <sol-network.h>
24 #include <sol-buffer.h>
25 #include <sol-vector.h>
26 
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
53 struct sol_netctl_service;
55 
63 typedef struct sol_netctl_network_params {
64 #ifndef SOL_NO_API_VERSION
65 #define SOL_NETCTL_NETWORK_PARAMS_API_VERSION (1)
66 
67  uint16_t api_version;
68 #endif
69 
82 
83 #define SOL_NETCTL_AGENT_NAME "Name"
84 #define SOL_NETCTL_AGENT_IDENTITY "Identity"
85 #define SOL_NETCTL_AGENT_PASSPHRASE "Passphrase"
86 #define SOL_NETCTL_AGENT_WPS "WPS"
87 #define SOL_NETCTL_AGENT_USERNAME "Username"
88 #define SOL_NETCTL_AGENT_PASSWORD "Password"
102 enum sol_netctl_service_state {
103  /*
104  * @brief the service is unknow
105  *
106  * a service is unknow when the service is init
107  * and the service state can't be given.
108  */
110  /*
111  * @brief the service is idle
112  *
113  * a service is idle when the service is not in use
114  * at all at the moment and it is not attempting to
115  * connect or do anything.
116  */
118  /*
119  * @brief the service is association
120  *
121  * a service is association when the service tries to
122  * establish a low-level connection to the network.
123  */
125  /*
126  * @brief the service is configuration
127  *
128  * a service is configuration when the service is trying to
129  * retrieve/configure IP settings.
130  */
132  /*
133  * @brief the service is ready
134  *
135  * a service is ready when a successfully connected device.
136  */
138  /*
139  * @brief the service is online
140  *
141  * a service is online when an internet connection is available
142  * and has been verified.
143  */
145  /*
146  * @brief the service is disconnect
147  *
148  * a service is disconnect when the service is going to terminate
149  * the current connection and will return to "idle".
150  */
152  /*
153  * @brief the service is failure
154  *
155  * a service is failure when the service indicates a wrong behavior.
156  */
158  /*
159  * @brief the service is remove
160  *
161  * a service is remove when the service is not available and removed
162  * from the network system. At the same time, the service handle(pointer)
163  * will become invalid.
164  */
166 };
167 
176 };
177 
184 typedef struct sol_netctl_proxy {
185 #ifndef SOL_NO_API_VERSION
186 #define SOL_NETCTL_PROXY_API_VERSION (1)
187 
188  uint16_t api_version;
189 #endif
190 
193  char *url;
199 
206 typedef struct sol_netctl_provider {
207 #ifndef SOL_NO_API_VERSION
208 #define SOL_NETCTL_PROVIDER_API_VERSION (1)
209 
210  uint16_t api_version;
211 #endif
212 
213  char *host;
215  char *domain;
217  char *name;
219  char *type;
221 
228 typedef struct sol_netctl_ethernet {
229 #ifndef SOL_NO_API_VERSION
230 #define SOL_NETCTL_ETHERNET_API_VERSION (1)
231 
232  uint16_t api_version;
233 #endif
234 
235  char *method;
237  char *interface;
239  char *address;
241  char *duplex;
243  uint16_t mtu;
245  uint16_t speed;
247 
248 #define SOL_NETCTL_SERVICE_TYPE_ETHERNET "ethernet"
249 #define SOL_NETCTL_SERVICE_TYPE_WIFI "wifi"
250 #define SOL_NETCTL_SERVICE_TYPE_BLUETOOTH "bluetooth"
251 #define SOL_NETCTL_SERVICE_TYPE_CELLULAR "cellular"
252 #define SOL_NETCTL_SERVICE_TYPE_GPS "gps"
253 #define SOL_NETCTL_SERVICE_TYPE_VPN "vpn"
254 #define SOL_NETCTL_SERVICE_TYPE_GADGET "gadget"
255 #define SOL_NETCTL_SERVICE_TYPE_P2P "p2p"
266 enum sol_netctl_state {
267  /*
268  * @brief the state is unknow
269  *
270  * a state is unknow when the state is init
271  * and the state can't be given.
272  */
274  /*
275  * @brief the state is idle
276  *
277  * a state is idle when no serives is in either "ready" or "online" state.
278  */
280  /*
281  * @brief the state is ready
282  *
283  * a state is ready when at least one service is in "ready"
284  * state and no service is in "online" state.
285  */
287  /*
288  * @brief the state is online
289  *
290  * a state is online when at least one service is in "online".
291  */
293  /*
294  * @brief the state is offline
295  *
296  * a state is offline when the device is in offline mode and
297  * the user doesn't re-enable individual technologies like
298  * WiFi and Bluetooth while in offline mode.
299  */
301 };
302 
308 typedef struct sol_netctl_agent_input {
309 #ifndef SOL_NO_API_VERSION
310 #define SOL_NETCTL_AGENT_INPUT_API_VERSION (1)
311 
312  uint16_t api_version;
313 #endif
314 
317  char *type;
321  char *input;
323 
329 typedef struct sol_netctl_agent {
330 #ifndef SOL_NO_API_VERSION
331 #define SOL_NETCTL_AGENT_API_VERSION (1)
332  uint16_t api_version;
333 #endif
334 
341  void (*report_error)(void *data, const struct sol_netctl_service *service,
342  const char *error);
350  void (*request_input)(void *data, const struct sol_netctl_service *service,
351  const struct sol_ptr_vector *inputs);
357  void (*cancel)(void *data);
363  void (*release)(void *data);
365 
372 typedef void (*sol_netctl_service_monitor_cb)
373  (void *data,
374  const struct sol_netctl_service *service);
375 
381 typedef void (*sol_netctl_manager_monitor_cb)(void *data);
382 
390 typedef void (*sol_netctl_error_monitor_cb)
391  (void *data, const struct sol_netctl_service *service,
392  unsigned int error);
393 
404 const char *sol_netctl_service_get_name(
405  const struct sol_netctl_service *service);
406 
423  const struct sol_netctl_service *service);
424 
437 const struct sol_ptr_vector *
439 
451 const char *sol_netctl_service_get_error(
452  const struct sol_netctl_service *service);
453 
464 const char *sol_netctl_service_get_type(
465  const struct sol_netctl_service *service);
466 
479  const struct sol_netctl_service *service, struct sol_network_link **link);
480 
493  const struct sol_netctl_service *service);
494 
507  const struct sol_netctl_service *service);
508 
521  const struct sol_netctl_service *service);
522 
535  const struct sol_netctl_service *service);
536 
549  const struct sol_netctl_service *service);
550 
562 const struct sol_ptr_vector *
564 
576 const struct sol_ptr_vector *
578 
590 const struct sol_ptr_vector *
592 
604 const struct sol_netctl_proxy *
605 sol_netctl_service_get_proxy(const struct sol_netctl_service *service);
606 
618 const struct sol_netctl_provider *
620 
632 const struct sol_netctl_ethernet *
634 
648 
660 
673 
690 
707 
723  const void *data);
724 
739  const void *data);
740 
756  const void *data);
757 
770  const void *data);
771 
787  const void *data);
788 
801  const void *data);
811 const struct sol_ptr_vector *sol_netctl_get_services(void);
812 
826 #ifndef DOXYGEN_RUN
828 #endif
829 ;
830 
843 #ifndef DOXYGEN_RUN
844 SOL_ATTR_WARN_UNUSED_RESULT
845 #endif
846 ;
847 
859 static inline struct sol_netctl_service *
860 sol_netctl_find_service_by_name(const char *service_name)
861 {
862  const struct sol_ptr_vector *service_list;
863  struct sol_netctl_service *service;
864  const char *name;
865  uint16_t i;
866 
867  service_list = sol_netctl_get_services();
868  if (!service_list)
869  return NULL;
870 
871  SOL_PTR_VECTOR_FOREACH_IDX (service_list, service, i) {
872  name = sol_netctl_service_get_name(service);
873  if (name && strcmp(name, service_name) == 0)
874  return service;
875  }
876  return NULL;
877 }
878 
891 int sol_netctl_register_agent(const struct sol_netctl_agent *agent, const void *data);
892 
901 
922 int sol_netctl_request_retry(struct sol_netctl_service *service,
923  bool retry);
924 
941 int sol_netctl_request_input(struct sol_netctl_service *service,
942  const struct sol_ptr_vector *inputs);
943 
954 int sol_netctl_scan(void);
955 
960 #ifdef __cplusplus
961 }
962 #endif
enum sol_netctl_service_state sol_netctl_service_get_state(const struct sol_netctl_service *service)
Gets the service state.
struct sol_network_link_addr gateway
The network gateway.
Definition: sol-netctl.h:80
struct sol_network_link_addr addr
The network devices address.
Definition: sol-netctl.h:72
int sol_netctl_unregister_agent(void)
unregister a agent for network connection
const char * sol_netctl_service_state_to_str(enum sol_netctl_service_state state)
Converts sol_netctl_service_state to a string name.
void(* cancel)(void *data)
connection cancel callback used to inform connection cancel
Definition: sol-netctl.h:357
struct sol_network_link_addr netmask
The network devices netmask.
Definition: sol-netctl.h:76
Definition: sol-netctl.h:137
Definition: sol-netctl.h:175
void(* request_input)(void *data, const struct sol_netctl_service *service, const struct sol_ptr_vector *inputs)
connection input callback used to inform connection login input
Definition: sol-netctl.h:350
enum sol_netctl_state sol_netctl_get_state(void)
Gets the global connection state of system.
struct sol_netctl_proxy sol_netctl_proxy
struct to represent a network proxy.
uint16_t api_version
API version.
Definition: sol-netctl.h:210
struct sol_netctl_provider sol_netctl_provider
struct to represent a network provider.
uint16_t api_version
API version.
Definition: sol-netctl.h:67
Definition: sol-netctl.h:131
#define SOL_PTR_VECTOR_FOREACH_IDX(vector, itrvar, idx)
Macro to iterate over the pointer vector easily.
Definition: sol-vector.h:672
int sol_netctl_del_service_monitor(sol_netctl_service_monitor_cb cb, const void *data)
Dels a monitor for the updated netctl services.
struct sol_netctl_agent_input sol_netctl_agent_input
agent input struct
char * interface
Interface name.
Definition: sol-netctl.h:237
Definition: sol-netctl.h:144
enum sol_netctl_service_state sol_netctl_service_state_from_str(const char *state)
Converts a string service state to sol_netctl_service_state.
int sol_netctl_scan(void)
request scan the surrounding devices
char * url
automatic proxy configuration URL
Definition: sol-netctl.h:193
const char * sol_netctl_service_get_name(const struct sol_netctl_service *service)
Gets the service name.
uint16_t speed
Selected speed of line.
Definition: sol-netctl.h:245
Definition: sol-netctl.h:273
Definition: sol-netctl.h:279
static struct sol_netctl_service * sol_netctl_find_service_by_name(const char *service_name)
get so_netctl_service struct from serivce name.
Definition: sol-netctl.h:860
enum sol_netctl_proxy_method method
proxy method provided
Definition: sol-netctl.h:191
int32_t sol_netctl_service_get_strength(const struct sol_netctl_service *service)
Gets the service strength.
Definition: sol-netctl.h:173
static void enabled(void *data, bool powered)
Definition: browse.c:155
uint16_t api_version
Definition: sol-netctl.h:332
uint16_t api_version
API version.
Definition: sol-netctl.h:232
bool sol_netctl_service_is_roaming(const struct sol_netctl_service *service)
Checks whether the service is roaming or not.
void(* sol_netctl_service_monitor_cb)(void *data, const struct sol_netctl_service *service)
Service monitor callback used to inform a service changed.
Definition: sol-netctl.h:373
Definition: sol-netctl.h:286
agent input struct
Definition: sol-netctl.h:308
int sol_netctl_add_service_monitor(sol_netctl_service_monitor_cb cb, const void *data)
Adds a monitor for the updated netctl services.
struct sol_netctl_network_params sol_netctl_network_params
network params
int sol_netctl_service_connect(struct sol_netctl_service *service)
Connect the service.
struct to represent a network provider.
Definition: sol-netctl.h:206
int sol_netctl_del_error_monitor(sol_netctl_error_monitor_cb cb, const void *data)
Dels a monitor for the call error happens.
struct sol_netctl_agent agent
Definition: netctl.c:33
void(* sol_netctl_manager_monitor_cb)(void *data)
Manager monitor callback used to inform a manager updated.
Definition: sol-netctl.h:381
network params
Definition: sol-netctl.h:63
char * input
The agent input value.
Definition: sol-netctl.h:321
uint16_t api_version
API version.
Definition: sol-netctl.h:188
const struct sol_netctl_ethernet * sol_netctl_service_get_ethernet(const struct sol_netctl_service *service)
Gets the service ethernet.
char * duplex
Selected duplex settings of line.
Definition: sol-netctl.h:241
Definition: sol-netctl.h:124
const char * sol_netctl_service_get_type(const struct sol_netctl_service *service)
Gets the service type.
Definition: sol-netctl.h:109
These are routines that Soletta provides for its buffer implementation.
char * domain
VPN Domain.
Definition: sol-netctl.h:215
bool sol_netctl_service_is_autoconnect(const struct sol_netctl_service *service)
Checks whether the service is autoconnect or not.
bool sol_netctl_service_is_immutable(const struct sol_netctl_service *service)
Checks whether the service is immutable or not.
Definition: sol-netctl.h:292
void(* report_error)(void *data, const struct sol_netctl_service *service, const char *error)
connection error callback used to inform connection failure
Definition: sol-netctl.h:341
bool sol_netctl_service_is_favorite(const struct sol_netctl_service *service)
Checks whether the service is favorite or not.
char * host
VPN host IP.
Definition: sol-netctl.h:213
char * name
provider name
Definition: sol-netctl.h:217
#define SOL_ATTR_WARN_UNUSED_RESULT
Causes a warning to be emitted if a caller of the function with this attribute does not use its retur...
Definition: sol-macros.h:187
struct to represent a network ethernet.
Definition: sol-netctl.h:228
uint16_t mtu
The ethernet MTU.
Definition: sol-netctl.h:243
const struct sol_ptr_vector * sol_netctl_service_get_domains(const struct sol_netctl_service *service)
Gets the service domains.
const struct sol_ptr_vector * sol_netctl_get_services(void)
Gets the netctl services.
Definition: sol-netctl.h:300
struct sol_netctl_ethernet sol_netctl_ethernet
struct to represent a network ethernet.
char * type
provider type
Definition: sol-netctl.h:219
sol_netctl_proxy_method
method of proxy generated for a network link.
Definition: sol-netctl.h:172
Definition: sol-netctl.h:165
int sol_netctl_del_manager_monitor(sol_netctl_manager_monitor_cb cb, const void *data)
Dels a monitor for the updated netctl manager properties.
void(* release)(void *data)
agent release callback used to inform agent release
Definition: sol-netctl.h:363
const struct sol_netctl_provider * sol_netctl_service_get_provider(const struct sol_netctl_service *service)
Gets the service provider.
int sol_netctl_add_manager_monitor(sol_netctl_manager_monitor_cb cb, const void *data)
Adds a monitor for the updated netctl manager properties.
agent callback functions
Definition: sol-netctl.h:329
int sol_netctl_service_get_network_address(const struct sol_netctl_service *service, struct sol_network_link **link)
Gets the service network address.
Definition: sol-netctl.h:117
int sol_netctl_request_retry(struct sol_netctl_service *service, bool retry)
request retry the connection or not when error type is reported
struct to represent a network proxy.
Definition: sol-netctl.h:184
Definition: sol-netctl.h:157
bool sol_netctl_get_radios_offline(void)
Gets the global connection state of offline.
Definition: sol-netctl.h:174
const struct sol_netctl_proxy * sol_netctl_service_get_proxy(const struct sol_netctl_service *service)
Gets the service proxy.
char * method
Possible value are auto and manual.
Definition: sol-netctl.h:235
uint16_t api_version
API version.
Definition: sol-netctl.h:312
int sol_netctl_service_disconnect(struct sol_netctl_service *service)
Disconnect the service.
sol_ptr_vector servers
List of proxy URIs when manual method is set.
Definition: sol-netctl.h:195
Soletta pointer vector is a wrapper around vector with an API more convenient to handle pointers...
Definition: sol-vector.h:310
Definition: sol-netctl.h:151
void(* sol_netctl_error_monitor_cb)(void *data, const struct sol_netctl_service *service, unsigned int error)
error monitor callback used to inform a call result
Definition: sol-netctl.h:391
int sol_netctl_register_agent(const struct sol_netctl_agent *agent, const void *data)
register a agent for network connection
int sol_netctl_set_radios_offline(bool enabled)
Sets the global connection state to offline.
sol_ptr_vector excludes
List of host can be accessed directly.
Definition: sol-netctl.h:197
struct sol_netctl_agent sol_netctl_agent
agent callback functions
char * type
The agent prompt type.
Definition: sol-netctl.h:317
int sol_netctl_add_error_monitor(sol_netctl_error_monitor_cb cb, const void *data)
Adds a monitor for the call error happens.
const struct sol_ptr_vector * sol_netctl_service_get_timeservers(const struct sol_netctl_service *service)
Gets the service timeservers.
These are routines that Soletta provides for its vector implementation.
const char * sol_netctl_service_get_error(const struct sol_netctl_service *service)
Gets the service error.
const struct sol_ptr_vector * sol_netctl_service_get_nameservers(const struct sol_netctl_service *service)
Gets the service nameservers.
char * address
Ethernet device address.
Definition: sol-netctl.h:239
struct sol_netctl_service sol_netctl_service
service struct
Definition: sol-netctl.h:54
int sol_netctl_request_input(struct sol_netctl_service *service, const struct sol_ptr_vector *inputs)
request the login input to connection
sol_netctl_state
the global connection state of system
Definition: sol-netctl.h:266
These are routines that Soletta provides for handling network link interfaces, making it possible to ...
const struct sol_ptr_vector * sol_netctl_service_get_security(const struct sol_netctl_service *service)
Gets the service security methods.
sol_netctl_service_state
service state
Definition: sol-netctl.h:102