5 * Copyright (C) 2007-2013 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 __VPN_PROVIDER_H
23 #define __VPN_PROVIDER_H
35 * @title: Provider premitives
36 * @short_description: Functions for handling providers
39 enum vpn_provider_type {
40 VPN_PROVIDER_TYPE_UNKNOWN = 0,
41 VPN_PROVIDER_TYPE_VPN = 1,
44 enum vpn_provider_state {
45 VPN_PROVIDER_STATE_UNKNOWN = 0,
46 VPN_PROVIDER_STATE_IDLE = 1,
47 VPN_PROVIDER_STATE_CONNECT = 2,
48 VPN_PROVIDER_STATE_READY = 3,
49 VPN_PROVIDER_STATE_DISCONNECT = 4,
50 VPN_PROVIDER_STATE_FAILURE = 5,
53 enum vpn_provider_error {
54 VPN_PROVIDER_ERROR_UNKNOWN = 0,
55 VPN_PROVIDER_ERROR_CONNECT_FAILED = 1,
56 VPN_PROVIDER_ERROR_LOGIN_FAILED = 2,
57 VPN_PROVIDER_ERROR_AUTH_FAILED = 3,
61 struct connman_ipaddress;
63 #define vpn_provider_ref(provider) \
64 vpn_provider_ref_debug(provider, __FILE__, __LINE__, __func__)
66 #define vpn_provider_unref(provider) \
67 vpn_provider_unref_debug(provider, __FILE__, __LINE__, __func__)
70 vpn_provider_ref_debug(struct vpn_provider *provider,
71 const char *file, int line, const char *caller);
72 void vpn_provider_unref_debug(struct vpn_provider *provider,
73 const char *file, int line, const char *caller);
75 int vpn_provider_set_string(struct vpn_provider *provider,
76 const char *key, const char *value);
77 int vpn_provider_set_string_hide_value(struct vpn_provider *provider,
78 const char *key, const char *value);
79 const char *vpn_provider_get_string(struct vpn_provider *provider,
82 int vpn_provider_set_state(struct vpn_provider *provider,
83 enum vpn_provider_state state);
85 int vpn_provider_indicate_error(struct vpn_provider *provider,
86 enum vpn_provider_error error);
88 void vpn_provider_set_index(struct vpn_provider *provider, int index);
89 int vpn_provider_get_index(struct vpn_provider *provider);
91 void vpn_provider_set_data(struct vpn_provider *provider, void *data);
92 void *vpn_provider_get_data(struct vpn_provider *provider);
93 int vpn_provider_set_ipaddress(struct vpn_provider *provider,
94 struct connman_ipaddress *ipaddress);
95 int vpn_provider_set_pac(struct vpn_provider *provider,
97 int vpn_provider_set_domain(struct vpn_provider *provider,
99 int vpn_provider_set_nameservers(struct vpn_provider *provider,
100 const char *nameservers);
101 int vpn_provider_append_route(struct vpn_provider *provider,
102 const char *key, const char *value);
104 const char *vpn_provider_get_driver_name(struct vpn_provider *provider);
105 const char *vpn_provider_get_save_group(struct vpn_provider *provider);
107 const char *vpn_provider_get_name(struct vpn_provider *provider);
108 const char *vpn_provider_get_host(struct vpn_provider *provider);
109 const char *vpn_provider_get_path(struct vpn_provider *provider);
110 void vpn_provider_change_address(struct vpn_provider *provider);
111 void vpn_provider_clear_address(struct vpn_provider *provider, int family);
113 typedef void (* vpn_provider_connect_cb_t) (struct vpn_provider *provider,
114 void *user_data, int error);
116 typedef void (* vpn_provider_auth_cb_t) (struct vpn_provider *provider,
117 const char *authenticator,
118 const char *error, void *user_data);
120 typedef void (* vpn_provider_password_cb_t) (struct vpn_provider *provider,
121 const char *username,
122 const char *password,
123 const char *error, void *user_data);
125 struct vpn_provider_driver {
127 enum vpn_provider_type type;
128 int (*probe) (struct vpn_provider *provider);
129 int (*remove) (struct vpn_provider *provider);
130 int (*connect) (struct vpn_provider *provider,
131 vpn_provider_connect_cb_t cb, const char *dbus_sender,
133 int (*disconnect) (struct vpn_provider *provider);
134 int (*save) (struct vpn_provider *provider, GKeyFile *keyfile);
135 int (*set_state)(struct vpn_provider *provider,
136 enum vpn_provider_state state);
139 int vpn_provider_driver_register(struct vpn_provider_driver *driver);
140 void vpn_provider_driver_unregister(struct vpn_provider_driver *driver);
146 #endif /* __VPN_PROVIDER_H */