ipv4: Use existing connman_inet_ifname() routine
authorSamuel Ortiz <sameo@linux.intel.com>
Tue, 23 Nov 2010 13:48:24 +0000 (14:48 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 23 Nov 2010 13:53:24 +0000 (14:53 +0100)
src/ipv4.c

index 416dab26392cc8ba19baef05f8d16c86f9143c20..91240153be0dc309c8f22dde1108dbc80e9d9dc4 100644 (file)
 
 #include "connman.h"
 
-static char *index2name(int index)
-{
-       struct ifreq ifr;
-       int sk, err;
-
-       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);
-
-       close(sk);
-
-       if (err < 0)
-               return NULL;
-
-       return strdup(ifr.ifr_name);
-}
-
 static int ipv4_probe(struct connman_element *element)
 {
        struct connman_service *service;
@@ -117,7 +92,7 @@ static int ipv4_probe(struct connman_element *element)
 
        connection->type    = CONNMAN_ELEMENT_TYPE_CONNECTION;
        connection->index   = element->index;
-       connection->devname = index2name(element->index);
+       connection->devname = connman_inet_ifname(element->index);
 
        ipconfig = __connman_service_get_ipconfig(service);
        if (ipconfig != NULL)