nodist_include_HEADERS = version.h
-noinst_HEADERS = driver.h element.h property.h ipv4.h rtnl.h dbus.h \
+noinst_HEADERS = driver.h element.h property.h rtnl.h dbus.h \
rfkill.h resolver.h ipconfig.h service.h option.h
MAINTAINERCLEANFILES = Makefile.in
#include <connman/property.h>
#include <connman/types.h>
-#include <connman/ipv4.h>
+#include <connman/ipconfig.h>
/**
* SECTION:element
GHashTable *properties;
struct {
- enum connman_ipv4_method method;
+ enum connman_ipconfig_method method;
gchar *address;
gchar *netmask;
gchar *gateway;
* @short_description: Functions for registering IP configuration modules
*/
+enum connman_ipconfig_type {
+ CONNMAN_IPCONFIG_TYPE_UNKNOWN = 0,
+ CONNMAN_IPCONFIG_TYPE_IPV4 = 1,
+ CONNMAN_IPCONFIG_TYPE_IPV6 = 2,
+};
+
+enum connman_ipconfig_method {
+ CONNMAN_IPCONFIG_METHOD_UNKNOWN = 0,
+ CONNMAN_IPCONFIG_METHOD_OFF = 1,
+ CONNMAN_IPCONFIG_METHOD_STATIC = 2,
+ CONNMAN_IPCONFIG_METHOD_DHCP = 3,
+};
+
+struct connman_ipconfig;
+
+extern struct connman_ipconfig *connman_ipconfig_create(void);
+extern struct connman_ipconfig *connman_ipconfig_ref(struct connman_ipconfig *ipconfig);
+extern void connman_ipconfig_unref(struct connman_ipconfig *ipconfig);
+
#define CONNMAN_IPCONFIG_PRIORITY_LOW -100
#define CONNMAN_IPCONFIG_PRIORITY_DEFAULT 0
#define CONNMAN_IPCONFIG_PRIORITY_HIGH 100
-struct connman_ipconfig {
+struct connman_ipconfig_driver {
const char *name;
+ enum connman_ipconfig_type type;
int priority;
int (*request) (const char *interface);
int (*release) (const char *interface);
int (*renew) (const char *interface);
};
-extern int connman_ipconfig_register(struct connman_ipconfig *ipconfig);
-extern void connman_ipconfig_unregister(struct connman_ipconfig *ipconfig);
+extern int connman_ipconfig_driver_register(struct connman_ipconfig_driver *driver);
+extern void connman_ipconfig_driver_unregister(struct connman_ipconfig_driver *driver);
#ifdef __cplusplus
}
+++ /dev/null
-/*
- *
- * Connection Manager
- *
- * Copyright (C) 2007-2009 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifndef __CONNMAN_IPV4_H
-#define __CONNMAN_IPV4_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * SECTION:ipv4
- * @title: IPv4 premitives
- * @short_description: Functions for handling IPv4
- */
-
-enum connman_ipv4_method {
- CONNMAN_IPV4_METHOD_UNKNOWN = 0,
- CONNMAN_IPV4_METHOD_OFF = 1,
- CONNMAN_IPV4_METHOD_STATIC = 2,
- CONNMAN_IPV4_METHOD_DHCP = 3,
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CONNMAN_IPV4_H */
int __connman_security_check_privilege(DBusMessage *message,
enum connman_security_privilege privilege);
-#include <connman/ipv4.h>
+#include <connman/ipconfig.h>
-const char *__connman_ipv4_method2string(enum connman_ipv4_method method);
-enum connman_ipv4_method __connman_ipv4_string2method(const char *method);
+const char *__connman_ipconfig_method2string(enum connman_ipconfig_method method);
+enum connman_ipconfig_method __connman_ipconfig_string2method(const char *method);
#include <connman/inet.h>
int __connman_rfkill_init(void);
void __connman_rfkill_cleanup(void);
-#include <connman/ipconfig.h>
-
#include <connman/resolver.h>
int __connman_resolver_init(void);
device->disconnected = TRUE;
switch (device->element.ipv4.method) {
- case CONNMAN_IPV4_METHOD_UNKNOWN:
- case CONNMAN_IPV4_METHOD_OFF:
+ case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
+ case CONNMAN_IPCONFIG_METHOD_OFF:
return 0;
- case CONNMAN_IPV4_METHOD_STATIC:
+ case CONNMAN_IPCONFIG_METHOD_STATIC:
type = CONNMAN_ELEMENT_TYPE_IPV4;
break;
- case CONNMAN_IPV4_METHOD_DHCP:
+ case CONNMAN_IPCONFIG_METHOD_DHCP:
type = CONNMAN_ELEMENT_TYPE_DHCP;
break;
}
connman_element_set_string(&device->element,
CONNMAN_PROPERTY_ID_TYPE, str);
- device->element.ipv4.method = CONNMAN_IPV4_METHOD_DHCP;
+ device->element.ipv4.method = CONNMAN_IPCONFIG_METHOD_DHCP;
device->type = type;
device->name = g_strdup(type2description(device->type));
return NULL;
}
-const char *__connman_ipv4_method2string(enum connman_ipv4_method method)
+const char *__connman_ipconfig_method2string(enum connman_ipconfig_method method)
{
switch (method) {
- case CONNMAN_IPV4_METHOD_UNKNOWN:
+ case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
return "unknown";
- case CONNMAN_IPV4_METHOD_OFF:
+ case CONNMAN_IPCONFIG_METHOD_OFF:
return "off";
- case CONNMAN_IPV4_METHOD_STATIC:
+ case CONNMAN_IPCONFIG_METHOD_STATIC:
return "static";
- case CONNMAN_IPV4_METHOD_DHCP:
+ case CONNMAN_IPCONFIG_METHOD_DHCP:
return "dhcp";
}
return "unknown";
}
-enum connman_ipv4_method __connman_ipv4_string2method(const char *method)
+enum connman_ipconfig_method __connman_ipconfig_string2method(const char *method)
{
if (strcasecmp(method, "off") == 0)
- return CONNMAN_IPV4_METHOD_OFF;
+ return CONNMAN_IPCONFIG_METHOD_OFF;
else if (strcasecmp(method, "static") == 0)
- return CONNMAN_IPV4_METHOD_STATIC;
+ return CONNMAN_IPCONFIG_METHOD_STATIC;
else if (strcasecmp(method, "dhcp") == 0)
- return CONNMAN_IPV4_METHOD_DHCP;
+ return CONNMAN_IPCONFIG_METHOD_DHCP;
else
- return CONNMAN_IPV4_METHOD_UNKNOWN;
+ return CONNMAN_IPCONFIG_METHOD_UNKNOWN;
}
static void emit_element_signal(DBusConnection *conn, const char *member,
switch (id) {
case CONNMAN_PROPERTY_ID_IPV4_METHOD:
- if (element->ipv4.method == CONNMAN_IPV4_METHOD_UNKNOWN)
+ if (element->ipv4.method == CONNMAN_IPCONFIG_METHOD_UNKNOWN)
return connman_element_get_value(element->parent,
id, value);
__connman_element_lock(element);
- *((const char **) value) = __connman_ipv4_method2string(element->ipv4.method);
+ *((const char **) value) = __connman_ipconfig_method2string(element->ipv4.method);
__connman_element_unlock(element);
break;
case CONNMAN_PROPERTY_ID_IPV4_ADDRESS:
type = dbus_message_iter_get_arg_type(value);
if (g_str_equal(name, "IPv4.Method") == TRUE) {
- enum connman_ipv4_method method;
+ enum connman_ipconfig_method method;
const char *str;
if (type != DBUS_TYPE_STRING)
return -EINVAL;
dbus_message_iter_get_basic(value, &str);
- method = __connman_ipv4_string2method(str);
- if (method == CONNMAN_IPV4_METHOD_UNKNOWN)
+ method = __connman_ipconfig_string2method(str);
+ if (method == CONNMAN_IPCONFIG_METHOD_UNKNOWN)
return -EINVAL;
if (method == element->ipv4.method)
}
if (element->type == CONNMAN_ELEMENT_TYPE_DHCP)
- element->ipv4.method = CONNMAN_IPV4_METHOD_DHCP;
+ element->ipv4.method = CONNMAN_IPCONFIG_METHOD_DHCP;
element->parent = parent;
#include "connman.h"
-static GSList *ipconfig_list = NULL;
+struct connman_ipconfig {
+ gint refcount;
+ enum connman_ipconfig_method method;
+};
+
+/**
+ * connman_ipconfig_create:
+ *
+ * Allocate a new ipconfig structure.
+ *
+ * Returns: a newly-allocated #connman_ipconfig structure
+ */
+struct connman_ipconfig *connman_ipconfig_create(void)
+{
+ struct connman_ipconfig *ipconfig;
+
+ DBG("");
+
+ ipconfig = g_try_new0(struct connman_ipconfig, 1);
+ if (ipconfig == NULL)
+ return NULL;
+
+ DBG("ipconfig %p", ipconfig);
+
+ return ipconfig;
+}
+
+/**
+ * connman_ipconfig_ref:
+ * @ipconfig: ipconfig structure
+ *
+ * Increase reference counter of ipconfig
+ */
+struct connman_ipconfig *connman_ipconfig_ref(struct connman_ipconfig *ipconfig)
+{
+ g_atomic_int_inc(&ipconfig->refcount);
+
+ return ipconfig;
+}
+
+/**
+ * connman_ipconfig_unref:
+ * @ipconfig: ipconfig structure
+ *
+ * Decrease reference counter of ipconfig
+ */
+void connman_ipconfig_unref(struct connman_ipconfig *ipconfig)
+{
+ if (g_atomic_int_dec_and_test(&ipconfig->refcount) == TRUE) {
+ g_free(ipconfig);
+ }
+}
+
+static GSList *driver_list = NULL;
static gint compare_priority(gconstpointer a, gconstpointer b)
{
- const struct connman_ipconfig *ipconfig1 = a;
- const struct connman_ipconfig *ipconfig2 = b;
+ const struct connman_ipconfig_driver *driver1 = a;
+ const struct connman_ipconfig_driver *driver2 = b;
- return ipconfig2->priority - ipconfig1->priority;
+ return driver2->priority - driver1->priority;
}
/**
- * connman_ipconfig_register:
- * @ipconfig: IP configuration module
+ * connman_ipconfig_driver_register:
+ * @driver: IP configuration driver
*
- * Register a new IP configuration module
+ * Register a new IP configuration driver
*
* Returns: %0 on success
*/
-int connman_ipconfig_register(struct connman_ipconfig *ipconfig)
+int connman_ipconfig_driver_register(struct connman_ipconfig_driver *driver)
{
- DBG("ipconfig %p name %s", ipconfig, ipconfig->name);
+ DBG("driver %p name %s", driver, driver->name);
- ipconfig_list = g_slist_insert_sorted(ipconfig_list, ipconfig,
+ driver_list = g_slist_insert_sorted(driver_list, driver,
compare_priority);
return 0;
}
/**
- * connman_ipconfig_unregister:
- * @ipconfig: IP configuration module
+ * connman_ipconfig_driver_unregister:
+ * @driver: IP configuration driver
*
- * Remove a previously registered IP configuration module.
+ * Remove a previously registered IP configuration driver.
*/
-void connman_ipconfig_unregister(struct connman_ipconfig *ipconfig)
+void connman_ipconfig_driver_unregister(struct connman_ipconfig_driver *driver)
{
- DBG("ipconfig %p name %s", ipconfig, ipconfig->name);
+ DBG("driver %p name %s", driver, driver->name);
- ipconfig_list = g_slist_remove(ipconfig_list, ipconfig);
+ driver_list = g_slist_remove(driver_list, driver);
}
#include "connman.h"
struct connman_ipv4 {
- enum connman_ipv4_method method;
+ enum connman_ipconfig_method method;
struct in_addr address;
struct in_addr netmask;
struct in_addr broadcast;