aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ll_map.c
diff options
context:
space:
mode:
authorshemminger <shemminger>2005-06-07 22:15:48 +0000
committershemminger <shemminger>2005-06-07 22:15:48 +0000
commit99f830de2f6006ccfd324548633c396d15b395a0 (patch)
tree79b7f0adb4ce29cd96d2ce0187c3fb6620f6d854 /lib/ll_map.c
parent9bec1a436335457f3067a17de6ddb913bd95a184 (diff)
downloadplatform_external_iproute2-99f830de2f6006ccfd324548633c396d15b395a0.tar.gz
platform_external_iproute2-99f830de2f6006ccfd324548633c396d15b395a0.tar.bz2
platform_external_iproute2-99f830de2f6006ccfd324548633c396d15b395a0.zip
Device indices are unsigned and use if_nametoindex as fallback
Diffstat (limited to 'lib/ll_map.c')
-rw-r--r--lib/ll_map.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/ll_map.c b/lib/ll_map.c
index 89c0d20a..1acbf8f8 100644
--- a/lib/ll_map.c
+++ b/lib/ll_map.c
@@ -17,6 +17,7 @@
#include <fcntl.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <net/if.h>
#include <string.h>
#include "libnetlink.h"
@@ -25,7 +26,7 @@
struct idxmap
{
struct idxmap * next;
- int index;
+ unsigned index;
int type;
int alen;
unsigned flags;
@@ -86,7 +87,7 @@ int ll_remember_index(const struct sockaddr_nl *who,
return 0;
}
-const char *ll_idx_n2a(int idx, char *buf)
+const char *ll_idx_n2a(unsigned idx, char *buf)
{
struct idxmap *im;
@@ -100,14 +101,14 @@ const char *ll_idx_n2a(int idx, char *buf)
}
-const char *ll_index_to_name(int idx)
+const char *ll_index_to_name(unsigned idx)
{
static char nbuf[16];
return ll_idx_n2a(idx, nbuf);
}
-int ll_index_to_type(int idx)
+int ll_index_to_type(unsigned idx)
{
struct idxmap *im;
@@ -119,7 +120,7 @@ int ll_index_to_type(int idx)
return -1;
}
-unsigned ll_index_to_flags(int idx)
+unsigned ll_index_to_flags(unsigned idx)
{
struct idxmap *im;
@@ -132,7 +133,7 @@ unsigned ll_index_to_flags(int idx)
return 0;
}
-int ll_name_to_index(const char *name)
+unsigned ll_name_to_index(const char *name)
{
static char ncache[16];
static int icache;
@@ -152,7 +153,8 @@ int ll_name_to_index(const char *name)
}
}
}
- return 0;
+
+ return if_nametoindex(name);
}
int ll_init_map(struct rtnl_handle *rth)