Provide unique identifier along with the interface callbacks
authorMarcel Holtmann <marcel@holtmann.org>
Thu, 15 Jul 2010 20:58:22 +0000 (13:58 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 15 Jul 2010 20:58:22 +0000 (13:58 -0700)
include/technology.h
src/connman.h
src/rtnl.c
src/technology.c

index 256a2eb..e45474d 100644 (file)
@@ -43,7 +43,8 @@ struct connman_technology_driver {
        int (*probe) (struct connman_technology *technology);
        void (*remove) (struct connman_technology *technology);
        void (*add_interface) (struct connman_technology *technology,
-                                               int index, const char *name);
+                                               int index, const char *name,
+                                                       const char *ident);
        void (*remove_interface) (struct connman_technology *technology,
                                                                int index);
        int (*set_tethering) (struct connman_technology *technology,
index 5f23172..d2696d9 100644 (file)
@@ -302,9 +302,9 @@ int __connman_technology_update_rfkill(unsigned int index,
 int __connman_technology_remove_rfkill(unsigned int index);
 
 void __connman_technology_add_interface(enum connman_service_type type,
-                                               int index, const char *name);
+                               int index, const char *name, const char *ident);
 void __connman_technology_remove_interface(enum connman_service_type type,
-                                               int index, const char *name);
+                               int index, const char *name, const char *ident);
 int __connman_technology_enable_tethering(void);
 int __connman_technology_disable_tethering(void);
 
index 1f5c6c3..7e8d3b6 100644 (file)
@@ -59,6 +59,7 @@ static guint update_timeout = 0;
 struct interface_data {
        int index;
        char *name;
+       char *ident;
        enum connman_service_type type;
 };
 
@@ -69,8 +70,9 @@ static void free_interface(gpointer data)
        struct interface_data *interface = data;
 
        __connman_technology_remove_interface(interface->type,
-                                       interface->index, interface->name);
+                       interface->index, interface->name, interface->ident);
 
+       g_free(interface->ident);
        g_free(interface->name);
        g_free(interface);
 }
@@ -371,12 +373,20 @@ static void process_newlink(unsigned short type, int index, unsigned flags,
        unsigned char operstate = 0xff;
        const char *ifname = NULL;
        unsigned int mtu = 0;
-       char str[18];
+       char ident[13], str[18];
        GSList *list;
 
        memset(&stats, 0, sizeof(stats));
        extract_link(msg, bytes, &address, &ifname, &mtu, &operstate, &stats);
 
+       snprintf(ident, 13, "%02x%02x%02x%02x%02x%02x",
+                                               address.ether_addr_octet[0],
+                                               address.ether_addr_octet[1],
+                                               address.ether_addr_octet[2],
+                                               address.ether_addr_octet[3],
+                                               address.ether_addr_octet[4],
+                                               address.ether_addr_octet[5]);
+
        snprintf(str, 18, "%02X:%02X:%02X:%02X:%02X:%02X",
                                                address.ether_addr_octet[0],
                                                address.ether_addr_octet[1],
@@ -410,6 +420,7 @@ static void process_newlink(unsigned short type, int index, unsigned flags,
                interface = g_new0(struct interface_data, 1);
                interface->index = index;
                interface->name = g_strdup(ifname);
+               interface->ident = g_strdup(ident);
 
                g_hash_table_insert(interface_list,
                                        GINT_TO_POINTER(index), interface);
@@ -418,7 +429,7 @@ static void process_newlink(unsigned short type, int index, unsigned flags,
                        read_uevent(interface);
 
                __connman_technology_add_interface(interface->type,
-                                       interface->index, interface->name);
+                       interface->index, interface->name, interface->ident);
        }
 
        for (list = rtnl_list; list; list = list->next) {
index 34c50be..8d1be5c 100644 (file)
@@ -101,7 +101,7 @@ void connman_technology_driver_unregister(struct connman_technology_driver *driv
 }
 
 void __connman_technology_add_interface(enum connman_service_type type,
-                                               int index, const char *name)
+                               int index, const char *name, const char *ident)
 {
        GSList *list;
 
@@ -133,12 +133,12 @@ void __connman_technology_add_interface(enum connman_service_type type,
 
                if (technology->driver->add_interface)
                        technology->driver->add_interface(technology,
-                                                               index, name);
+                                                       index, name, ident);
        }
 }
 
 void __connman_technology_remove_interface(enum connman_service_type type,
-                                               int index, const char *name)
+                               int index, const char *name, const char *ident)
 {
        GSList *list;