With each provider we now have a VPN type service.
int __connman_tethering_set_status(connman_bool_t status);
void __connman_tethering_update_interface(const char *interface);
+#include <connman/provider.h>
+
+void __connman_provider_list(DBusMessageIter *iter, void *user_data);
+int __connman_provider_create_and_connect(DBusMessage *msg);
+const char * __connman_provider_get_ident(struct connman_provider *provider);
+int __connman_provider_indicate_state(struct connman_provider *provider,
+ enum connman_provider_state state);
+int __connman_provider_indicate_error(struct connman_provider *provider,
+ enum connman_provider_error error);
+int __connman_provider_remove(const char *path);
+void __connman_provider_cleanup(void);
+int __connman_provider_init(void);
+
#include <connman/service.h>
int __connman_service_init(void);
struct connman_service *__connman_service_lookup_from_network(struct connman_network *network);
struct connman_service *__connman_service_create_from_network(struct connman_network *network);
+struct connman_service *__connman_service_create_from_provider(struct connman_provider *provider);
void __connman_service_update_from_network(struct connman_network *network);
void __connman_service_remove_from_network(struct connman_network *network);
int __connman_location_detect(struct connman_service *service);
int __connman_location_finish(struct connman_service *service);
-#include <connman/provider.h>
-
-void __connman_provider_list(DBusMessageIter *iter, void *user_data);
-int __connman_provider_create_and_connect(DBusMessage *msg);
-int __connman_provider_indicate_state(struct connman_provider *provider,
- enum connman_provider_state state);
-int __connman_provider_indicate_error(struct connman_provider *provider,
- enum connman_provider_error error);
-int __connman_provider_remove(const char *path);
-void __connman_provider_cleanup(void);
-int __connman_provider_init(void);
-
#include <connman/notifier.h>
int __connman_technology_init(void);
struct connman_provider {
struct connman_element element;
+ struct connman_service *vpn_service;
char *identifier;
char *path;
enum connman_provider_state state;
struct connman_provider *connman_provider_ref(struct connman_provider *provider)
{
+ DBG("provider %p", provider);
+
if (connman_element_ref(&provider->element) == NULL)
return NULL;
void connman_provider_unref(struct connman_provider *provider)
{
+ DBG("provider %p", provider);
+
connman_element_unref(&provider->element);
}
__connman_provider_indicate_state(provider,
CONNMAN_PROVIDER_STATE_DISCONNECT);
+
+ __connman_service_indicate_state(provider->vpn_service,
+ CONNMAN_SERVICE_STATE_DISCONNECT);
if (err < 0) {
if (err != -EINPROGRESS)
return err;
}
__connman_provider_indicate_state(provider,
CONNMAN_PROVIDER_STATE_READY);
+ __connman_service_indicate_state(provider->vpn_service,
+ CONNMAN_SERVICE_STATE_READY);
} else {
reply_pending(provider, ECONNABORTED);
connman_element_unregister_children(&provider->element);
__connman_provider_indicate_state(provider,
CONNMAN_PROVIDER_STATE_DISCONNECT);
+ __connman_service_indicate_state(provider->vpn_service,
+ CONNMAN_SERVICE_STATE_DISCONNECT);
}
return 0;
g_free(provider->domain);
g_free(provider->identifier);
g_free(provider->dns);
+ __connman_service_put(provider->vpn_service);
}
static void unregister_provider(gpointer data)
{
struct connman_provider *provider = element->private;
+ DBG("provider %p", provider);
+
provider_free(provider);
}
g_dbus_send_reply(connection, msg,
DBUS_TYPE_OBJECT_PATH, &provider->path,
DBUS_TYPE_INVALID);
+
+ provider->vpn_service =
+ __connman_service_create_from_provider(provider);
+
return 0;
failed:
return err;
}
+const char * __connman_provider_get_ident(struct connman_provider *provider)
+{
+ if (provider == NULL)
+ return NULL;
+
+ return provider->identifier;
+}
+
int connman_provider_set_string(struct connman_provider *provider,
const char *key, const char *value)
{
connman_bool_t login_required;
struct connman_ipconfig *ipconfig;
struct connman_network *network;
+ struct connman_provider *provider;
char **nameservers;
char *nameserver;
char **domains;
*
* Look up service by network and if not found, create one
*/
-struct connman_service *__connman_service_create_from_network(struct connman_network *network)
+struct connman_service * __connman_service_create_from_network(struct connman_network *network)
{
struct connman_service *service;
const char *ident, *group;
__connman_service_put(service);
}
+/**
+ * __connman_service_create_from_provider:
+ * @provider: provider structure
+ *
+ * Look up service by provider and if not found, create one
+ */
+struct connman_service *
+__connman_service_create_from_provider(struct connman_provider *provider)
+{
+ struct connman_service *service;
+ const char *ident, *str;
+ char *name;
+ int index = connman_provider_get_index(provider);
+
+ DBG("provider %p", provider);
+
+ ident = __connman_provider_get_ident(provider);
+ if (ident == NULL)
+ return NULL;
+
+ name = g_strdup_printf("vpn_%s", ident);
+ service = __connman_service_get(name);
+ g_free(name);
+
+ if (service == NULL)
+ return NULL;
+
+ service->type = CONNMAN_SERVICE_TYPE_VPN;
+ service->provider = provider;
+ service->autoconnect = FALSE;
+
+ service->state = CONNMAN_SERVICE_STATE_IDLE;
+
+ str = connman_provider_get_string(provider, "Name");
+ if (str != NULL) {
+ g_free(service->name);
+ service->name = g_strdup(str);
+ service->hidden = FALSE;
+ } else {
+ g_free(service->name);
+ service->name = NULL;
+ service->hidden = TRUE;
+ }
+
+ service->strength = 0;
+
+ service->ipconfig = connman_ipconfig_create(index);
+ if (service->ipconfig == NULL)
+ return service;
+
+ connman_ipconfig_set_method(service->ipconfig,
+ CONNMAN_IPCONFIG_METHOD_MANUAL);
+
+ connman_ipconfig_set_data(service->ipconfig, service);
+
+ connman_ipconfig_set_ops(service->ipconfig, &service_ops);
+
+ service_register(service);
+
+ return service;
+}
+
void __connman_service_stats_update(struct connman_service *service,
unsigned int rx_packets, unsigned int tx_packets,
unsigned int rx_bytes, unsigned int tx_bytes,