summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-09-01 20:07:39 +0200
committerMarcel Holtmann <marcel@holtmann.org>2008-09-01 20:07:39 +0200
commit7f4054b0b2d6c43c59caef670b4330895337d992 (patch)
treeabfe4fa39002865486be84fe3b307d47a0909f4a
parent074d489a01de3dfb1fa2b8e9ad48bf42fff1302b (diff)
downloadconnman-7f4054b0b2d6c43c59caef670b4330895337d992.tar.gz
connman-7f4054b0b2d6c43c59caef670b4330895337d992.tar.bz2
connman-7f4054b0b2d6c43c59caef670b4330895337d992.zip
Fixup due to element API changes
-rw-r--r--plugins/bluetooth.c2
-rw-r--r--plugins/ethernet.c62
-rw-r--r--plugins/wifi.c17
3 files changed, 50 insertions, 31 deletions
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 6d41fb25..2d0d7ad9 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -43,7 +43,7 @@ static void create_element(DBusConnection *conn, const char *path)
DBG("conn %p path %s", conn, path);
- element = connman_element_create();
+ element = connman_element_create(NULL);
element->name = g_path_get_basename(path);
element->type = CONNMAN_ELEMENT_TYPE_DEVICE;
diff --git a/plugins/ethernet.c b/plugins/ethernet.c
index 0f248bca..697149bb 100644
--- a/plugins/ethernet.c
+++ b/plugins/ethernet.c
@@ -35,6 +35,11 @@
#include <connman/driver.h>
#include <connman/log.h>
+struct ethernet_data {
+ int index;
+ short flags;
+};
+
static GStaticMutex ethernet_mutex = G_STATIC_MUTEX_INIT;
static GSList *ethernet_list = NULL;
@@ -45,11 +50,12 @@ static void create_element(struct connman_element *parent,
DBG("parent %p name %s", parent, parent->name);
- element = connman_element_create();
+ element = connman_element_create(NULL);
+ if (element == NULL)
+ return;
element->type = type;
- element->netdev.index = parent->netdev.index;
- element->netdev.name = g_strdup(parent->netdev.name);
+ element->index = parent->index;
connman_element_register(element, parent);
}
@@ -70,20 +76,22 @@ static void rtnl_link(struct nlmsghdr *hdr, const char *type)
for (list = ethernet_list; list; list = list->next) {
struct connman_element *element = list->data;
+ struct ethernet_data *ethernet;
- if (element->type != CONNMAN_ELEMENT_TYPE_DEVICE)
+ ethernet = connman_element_get_data(element);
+ if (ethernet == NULL)
continue;
- if (element->netdev.index != msg->ifi_index)
+ if (ethernet->index != msg->ifi_index)
continue;
- if ((element->netdev.flags & IFF_RUNNING) ==
- (msg->ifi_flags & IFF_RUNNING))
+ if ((ethernet->flags & IFF_RUNNING) ==
+ (msg->ifi_flags & IFF_RUNNING))
continue;
- element->netdev.flags = msg->ifi_flags;
+ ethernet->flags = msg->ifi_flags;
- if (msg->ifi_flags & IFF_RUNNING) {
+ if (ethernet->flags & IFF_RUNNING) {
DBG("carrier on");
create_element(element, CONNMAN_ELEMENT_TYPE_DHCP);
@@ -153,7 +161,7 @@ static gboolean rtnl_event(GIOChannel *chan, GIOCondition cond, gpointer data)
return TRUE;
}
-static GIOChannel *channel = NULL;
+static GIOChannel *channel;
static int rtnl_request(void)
{
@@ -184,19 +192,19 @@ static int rtnl_request(void)
(struct sockaddr *) &addr, sizeof(addr));
}
-static int iface_up(struct connman_element *element)
+static int iface_up(struct ethernet_data *ethernet)
{
struct ifreq ifr;
int sk, err;
- DBG("element %p", element);
+ DBG("index %d flags %d", ethernet->index, ethernet->flags);
sk = socket(PF_INET, SOCK_DGRAM, 0);
if (sk < 0)
return -errno;
memset(&ifr, 0, sizeof(ifr));
- ifr.ifr_ifindex = element->netdev.index;
+ ifr.ifr_ifindex = ethernet->index;
if (ioctl(sk, SIOCGIFNAME, &ifr) < 0) {
err = -errno;
@@ -228,19 +236,19 @@ done:
return err;
}
-static int iface_down(struct connman_element *element)
+static int iface_down(struct ethernet_data *ethernet)
{
struct ifreq ifr;
int sk, err;
- DBG("element %p", element);
+ DBG("index %d flags %d", ethernet->index, ethernet->flags);
sk = socket(PF_INET, SOCK_DGRAM, 0);
if (sk < 0)
return -errno;
memset(&ifr, 0, sizeof(ifr));
- ifr.ifr_ifindex = element->netdev.index;
+ ifr.ifr_ifindex = ethernet->index;
if (ioctl(sk, SIOCGIFNAME, &ifr) < 0) {
err = -errno;
@@ -272,13 +280,23 @@ done:
static int ethernet_probe(struct connman_element *element)
{
+ struct ethernet_data *ethernet;
+
DBG("element %p name %s", element, element->name);
+ ethernet = g_try_new0(struct ethernet_data, 1);
+ if (ethernet == NULL)
+ return -ENOMEM;
+
g_static_mutex_lock(&ethernet_mutex);
ethernet_list = g_slist_append(ethernet_list, element);
g_static_mutex_unlock(&ethernet_mutex);
- iface_up(element);
+ connman_element_set_data(element, ethernet);
+
+ ethernet->index = element->index;
+
+ iface_up(ethernet);
rtnl_request();
@@ -287,13 +305,19 @@ static int ethernet_probe(struct connman_element *element)
static void ethernet_remove(struct connman_element *element)
{
+ struct ethernet_data *ethernet = connman_element_get_data(element);
+
DBG("element %p name %s", element, element->name);
- iface_down(element);
+ connman_element_set_data(element, NULL);
+
+ iface_down(ethernet);
g_static_mutex_lock(&ethernet_mutex);
ethernet_list = g_slist_remove(ethernet_list, element);
g_static_mutex_unlock(&ethernet_mutex);
+
+ g_free(ethernet);
}
static struct connman_driver ethernet_driver = {
@@ -340,8 +364,6 @@ static void rtnl_cleanup(void)
g_io_channel_shutdown(channel, TRUE, NULL);
g_io_channel_unref(channel);
-
- channel = NULL;
}
static int ethernet_init(void)
diff --git a/plugins/wifi.c b/plugins/wifi.c
index 05611339..f4c33737 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -140,11 +140,10 @@ static void state_change(struct connman_element *parent,
if (state == STATE_COMPLETED) {
struct connman_element *dhcp;
- dhcp = connman_element_create();
+ dhcp = connman_element_create(NULL);
dhcp->type = CONNMAN_ELEMENT_TYPE_DHCP;
- dhcp->netdev.index = element->netdev.index;
- dhcp->netdev.name = g_strdup(element->netdev.name);
+ dhcp->index = element->index;
dhcp_element = dhcp;
@@ -191,26 +190,24 @@ static void scan_result(struct connman_element *parent,
element = find_element(data, network->identifier);
if (element == NULL) {
- element = connman_element_create();
+ element = connman_element_create(temp);
element->type = CONNMAN_ELEMENT_TYPE_NETWORK;
- element->name = temp;
+ element->index = parent->index;
element->network.identifier = g_strdup(network->identifier);
- element->netdev.index = parent->netdev.index;
- element->netdev.name = g_strdup(parent->netdev.name);
-
data->list = g_slist_append(data->list, element);
connman_element_add_static_property(element, "SSID",
DBUS_TYPE_STRING, &network->identifier);
connman_element_register(element, parent);
- } else
- g_free(temp);
+ }
g_static_mutex_unlock(&data->mutex);
+
+ g_free(temp);
}
static struct supplicant_callback wifi_callback = {