aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ll_map.c
diff options
context:
space:
mode:
authorDavid Ward <david.ward@ll.mit.edu>2009-10-15 14:53:13 -0400
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-12-01 15:54:16 -0800
commitee7ba9875d2b1662fc13a96d082a31cc4258465f (patch)
tree29f5b6044aecbef9a4dc4242a9e7c58c107ed9c1 /lib/ll_map.c
parent71e5815105fb0b86af7df9c719f7c106f05f29c0 (diff)
downloadplatform_external_iproute2-ee7ba9875d2b1662fc13a96d082a31cc4258465f.tar.gz
platform_external_iproute2-ee7ba9875d2b1662fc13a96d082a31cc4258465f.tar.bz2
platform_external_iproute2-ee7ba9875d2b1662fc13a96d082a31cc4258465f.zip
iproute2: Add ll_index_to_addr function
After calling ll_init_map, all of the information stored in the link-layer map can be retrieved by function calls (ll_index_to_*), except for the link-layer address. This patch fills the gap by adding a ll_index_to_addr function. Changes welcome. Signed-off-by: David Ward <david.ward@ll.mit.edu>
Diffstat (limited to 'lib/ll_map.c')
-rw-r--r--lib/ll_map.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/ll_map.c b/lib/ll_map.c
index a96c59ea..5addf4a4 100644
--- a/lib/ll_map.c
+++ b/lib/ll_map.c
@@ -134,6 +134,27 @@ unsigned ll_index_to_flags(unsigned idx)
return 0;
}
+unsigned ll_index_to_addr(unsigned idx, unsigned char *addr,
+ unsigned alen)
+{
+ struct idxmap *im;
+
+ if (idx == 0)
+ return 0;
+
+ for (im = idxmap[idx&0xF]; im; im = im->next) {
+ if (im->index == idx) {
+ if (alen > sizeof(im->addr))
+ alen = sizeof(im->addr);
+ if (alen > im->alen)
+ alen = im->alen;
+ memcpy(addr, im->addr, alen);
+ return alen;
+ }
+ }
+ return 0;
+}
+
unsigned ll_name_to_index(const char *name)
{
static char ncache[16];