This email list is read-only. Emails sent to this list will be discarded
----------------------------------
include/element.h | 1 +
plugins/inet.c | 48 +++++++++
plugins/inet.h | 1 +
plugins/rtnllink.c | 8 +-
plugins/wifi.c | 8 +-
src/element.c | 9 ++-
src/iface-inet.c | 299 ----------------------------------------------------
7 files changed, 67 insertions(+), 307 deletions(-)
New commits:
commit 05534b145e751387994ae35dc9f344a306540122
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Thu Dec 11 16:58:46 2008 +0100
Remove deprecated INET helper functions
commit 63c934f2f9daeb743416c0f7a440adf72690a3fc
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Thu Dec 11 16:57:42 2008 +0100
Create unique device name and object path
commit 6fc878f74ce6d37260f29c782cd65a47483083e4
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Thu Dec 11 16:57:12 2008 +0100
Add common index to ident conversion helper
commit da8e11efb0472f8d21cd4afff152036701e531a9
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Thu Dec 11 16:56:43 2008 +0100
Add devname attribute for device filtering
Diff in this email is a maximum of 400 lines.
diff --git a/include/element.h b/include/element.h
index aaf389d..e56f669 100644
--- a/include/element.h
+++ b/include/element.h
@@ -95,6 +95,7 @@ struct connman_element {
gboolean available;
gboolean remember;
guint16 priority;
+ gchar *devname;
struct connman_element *parent;
diff --git a/plugins/inet.c b/plugins/inet.c
index e14d33e..ab0fcdc 100644
--- a/plugins/inet.c
+++ b/plugins/inet.c
@@ -26,10 +26,12 @@
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
+#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
+#include <net/ethernet.h>
#include "inet.h"
@@ -57,3 +59,49 @@ char *inet_index2name(int index)
return strdup(ifr.ifr_name);
}
+
+char *inet_index2ident(int index, const char *prefix)
+{
+ struct ifreq ifr;
+ struct ether_addr *eth;
+ char *str;
+ int sk, err, len;
+
+ if (index < 0)
+ return NULL;
+
+ sk = socket(PF_INET, SOCK_DGRAM, 0);
+ if (sk < 0)
+ return NULL;
+
+ memset(&ifr, 0, sizeof(ifr));
+ ifr.ifr_ifindex = index;
+
+ err = ioctl(sk, SIOCGIFNAME, &ifr);
+
+ if (err == 0)
+ err = ioctl(sk, SIOCGIFHWADDR, &ifr);
+
+ close(sk);
+
+ if (err < 0)
+ return NULL;
+
+ len = prefix ? strlen(prefix) + 18 : 18;
+
+ str = malloc(len);
+ if (!str)
+ return NULL;
+
+ eth = (void *) &ifr.ifr_hwaddr.sa_data;
+ snprintf(str, len, "%s%02X_%02X_%02X_%02X_%02X_%02X",
+ prefix ? prefix : "",
+ eth->ether_addr_octet[0],
+ eth->ether_addr_octet[1],
+ eth->ether_addr_octet[2],
+ eth->ether_addr_octet[3],
+ eth->ether_addr_octet[4],
+ eth->ether_addr_octet[5]);
+
+ return str;
+}
diff --git a/plugins/inet.h b/plugins/inet.h
index aafd55b..afa8025 100644
--- a/plugins/inet.h
+++ b/plugins/inet.h
@@ -20,3 +20,4 @@
*/
char *inet_index2name(int index);
+char *inet_index2ident(int index, const char *prefix);
diff --git a/plugins/rtnllink.c b/plugins/rtnllink.c
index da5a588..3fbcedb 100644
--- a/plugins/rtnllink.c
+++ b/plugins/rtnllink.c
@@ -48,7 +48,7 @@ static void rtnllink_newlink(unsigned short type, int index,
struct connman_element *device;
GSList *list;
gboolean exists = FALSE;
- gchar *name;
+ gchar *name, *devname;
DBG("index %d", index);
@@ -64,7 +64,8 @@ static void rtnllink_newlink(unsigned short type, int index,
if (exists == TRUE)
return;
- name = inet_index2name(index);
+ name = inet_index2ident(index, "dev_");
+ devname = inet_index2name(index);
if (type == ARPHRD_ETHER) {
char bridge_path[PATH_MAX], wimax_path[PATH_MAX];
@@ -78,7 +79,7 @@ static void rtnllink_newlink(unsigned short type, int index,
"/sys/class/net/%s/wimax", name);
memset(&iwr, 0, sizeof(iwr));
- strncpy(iwr.ifr_ifrn.ifrn_name, name, IFNAMSIZ);
+ strncpy(iwr.ifr_ifrn.ifrn_name, devname, IFNAMSIZ);
sk = socket(PF_INET, SOCK_DGRAM, 0);
@@ -107,6 +108,7 @@ static void rtnllink_newlink(unsigned short type, int index,
device->index = index;
device->name = name;
+ device->devname = devname;
connman_element_register(device, NULL);
device_list = g_slist_append(device_list, device);
diff --git a/plugins/wifi.c b/plugins/wifi.c
index b0ee4ae..93312ca 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -356,7 +356,7 @@ static void wifi_newlink(unsigned short type, int index,
struct connman_element *device;
GSList *list;
gboolean exists = FALSE;
- gchar *name;
+ gchar *name, *devname;
struct iwreq iwr;
int sk;
@@ -365,10 +365,11 @@ static void wifi_newlink(unsigned short type, int index,
if (type != ARPHRD_ETHER)
return;
- name = inet_index2name(index);
+ name = inet_index2ident(index, "dev_");
+ devname = inet_index2name(index);
memset(&iwr, 0, sizeof(iwr));
- strncpy(iwr.ifr_ifrn.ifrn_name, name, IFNAMSIZ);
+ strncpy(iwr.ifr_ifrn.ifrn_name, devname, IFNAMSIZ);
sk = socket(PF_INET, SOCK_DGRAM, 0);
@@ -400,6 +401,7 @@ static void wifi_newlink(unsigned short type, int index,
device->index = index;
device->name = name;
+ device->devname = devname;
connman_element_register(device, NULL);
device_list = g_slist_append(device_list, device);
diff --git a/src/element.c b/src/element.c
index a8eee21..7361eb2 100644
--- a/src/element.c
+++ b/src/element.c
@@ -1154,6 +1154,7 @@ void connman_element_unref(struct connman_element
*element)
g_free(element->ipv4.network);
g_free(element->ipv4.broadcast);
g_free(element->ipv4.nameserver);
+ g_free(element->devname);
g_free(element->path);
g_free(element->name);
g_free(element);
@@ -1846,10 +1847,14 @@ int connman_element_register(struct connman_element
*element,
{
DBG("element %p name %s parent %p", element, element->name, parent);
+ if (element->devname == NULL)
+ element->devname = g_strdup(element->name);
+
if (device_filter && element->type == CONNMAN_ELEMENT_TYPE_DEVICE) {
if (g_pattern_match_simple(device_filter,
- element->name) == FALSE) {
- DBG("ignoring %s device", element->name);
+ element->devname) == FALSE) {
+ DBG("ignoring %s [%s] device", element->name,
+ element->devname);
return -EPERM;
}
}
diff --git a/src/iface-inet.c b/src/iface-inet.c
deleted file mode 100644
index cd21c13..0000000
--- a/src/iface-inet.c
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- *
- * Connection Manager
- *
- * Copyright (C) 2007-2008 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
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <net/ethernet.h>
-
-#include "connman.h"
-
-int __connman_iface_create_identifier(struct connman_iface *iface)
-{
- struct ifreq ifr;
- struct ether_addr *eth;
- int sk, err;
-
- DBG("iface %p", iface);
-
- sk = socket(PF_INET, SOCK_DGRAM, 0);
- if (sk < 0)
- return -EIO;
-
- memset(&ifr, 0, sizeof(ifr));
- ifr.ifr_ifindex = iface->index;
-
- err = ioctl(sk, SIOCGIFNAME, &ifr);
-
- if (err == 0)
- err = ioctl(sk, SIOCGIFHWADDR, &ifr);
-
- close(sk);
-
- if (err < 0)
- return -EIO;
-
- iface->identifier = malloc(18);
- if (iface->identifier == NULL)
- return -ENOMEM;
-
- eth = (void *) &ifr.ifr_hwaddr.sa_data;
- sprintf(iface->identifier, "%02X-%02X-%02X-%02X-%02X-%02X",
- eth->ether_addr_octet[0],
- eth->ether_addr_octet[1],
- eth->ether_addr_octet[2],
- eth->ether_addr_octet[3],
- eth->ether_addr_octet[4],
- eth->ether_addr_octet[5]);
-
- return 0;
-}
-
-int __connman_iface_init_via_inet(struct connman_iface *iface)
-{
- struct ifreq ifr;
- int sk, err;
-
- DBG("iface %p", iface);
-
- sk = socket(PF_INET, SOCK_DGRAM, 0);
- if (sk < 0)
- return -EIO;
-
- memset(&ifr, 0, sizeof(ifr));
- ifr.ifr_ifindex = iface->index;
-
- err = ioctl(sk, SIOCGIFNAME, &ifr);
-
- if (err == 0)
- err = ioctl(sk, SIOCGIFFLAGS, &ifr);
-
- close(sk);
-
- if (err < 0)
- return -EIO;
-
- if (ifr.ifr_flags & IFF_UP)
- iface->state = CONNMAN_IFACE_STATE_ENABLED;
- else
- iface->state = CONNMAN_IFACE_STATE_OFF;
-
- if (ifr.ifr_flags & IFF_RUNNING) {
- if (!(iface->flags & CONNMAN_IFACE_FLAG_NOCARRIER))
- iface->state = CONNMAN_IFACE_STATE_CARRIER;
- }
-
- return 0;
-}
-
-static int __connman_iface_up(struct connman_iface *iface)
-{
- struct ifreq ifr;
- int sk, err;
-
- DBG("iface %p", iface);
-
- sk = socket(PF_INET, SOCK_DGRAM, 0);
- if (sk < 0)
- return -errno;
-
- memset(&ifr, 0, sizeof(ifr));
- ifr.ifr_ifindex = iface->index;
-
- if (ioctl(sk, SIOCGIFNAME, &ifr) < 0) {
- err = -errno;
- goto done;
- }
-
- if (ioctl(sk, SIOCGIFFLAGS, &ifr) < 0) {
- err = -errno;
- goto done;
- }
-
- if (ifr.ifr_flags & IFF_UP) {
- err = -EALREADY;
- goto done;
- }
-
- ifr.ifr_flags |= IFF_UP;
-
- if (ioctl(sk, SIOCSIFFLAGS, &ifr) < 0) {
- err = -errno;
- goto done;
- }
-
- err = 0;
-
-done:
- close(sk);
-
- return err;
-}
-
-static int __connman_iface_down(struct connman_iface *iface)
-{
- struct ifreq ifr;
- int sk, err;
-
- DBG("iface %p", iface);
-
- sk = socket(PF_INET, SOCK_DGRAM, 0);
- if (sk < 0)
- return -errno;
-
- memset(&ifr, 0, sizeof(ifr));
- ifr.ifr_ifindex = iface->index;
-
- if (ioctl(sk, SIOCGIFNAME, &ifr) < 0) {
- err = -errno;
- goto done;
- }
-
- if (ioctl(sk, SIOCGIFFLAGS, &ifr) < 0) {
- err = -errno;
- goto done;
- }
-
- if (!(ifr.ifr_flags & IFF_UP)) {
- err = -EALREADY;
- goto done;
- }
-
- ifr.ifr_flags &= ~IFF_UP;
-
- if (ioctl(sk, SIOCSIFFLAGS, &ifr) < 0)
- err = -errno;
- else
- err = 0;
-
-done:
- close(sk);
-
- return err;
-}
-
-int __connman_iface_start(struct connman_iface *iface)
-{
_______________________________________________
Commits mailing list
[email protected]
https://lists.moblin.org/mailman/listinfo/commits