Use the LLINDEX macro to access the link-level I/F index. This makes
it possible to work with a different type for the sdl_index field -- it only requires a recompile. Obtained from: Juniper Networks, Inc.
This commit is contained in:
parent
29d8e665ba
commit
cf0d539f8b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=235640
@ -70,7 +70,7 @@ if_indextoname(unsigned int ifindex, char *ifname)
|
||||
for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) {
|
||||
if (ifa->ifa_addr &&
|
||||
ifa->ifa_addr->sa_family == AF_LINK &&
|
||||
ifindex == ((struct sockaddr_dl*)ifa->ifa_addr)->sdl_index)
|
||||
ifindex == LLINDEX((struct sockaddr_dl*)ifa->ifa_addr))
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ if_nameindex(void)
|
||||
if (ifa->ifa_addr &&
|
||||
ifa->ifa_addr->sa_family == AF_LINK) {
|
||||
ifni2->if_index =
|
||||
((struct sockaddr_dl*)ifa->ifa_addr)->sdl_index;
|
||||
LLINDEX((struct sockaddr_dl*)ifa->ifa_addr);
|
||||
ifni2->if_name = cp;
|
||||
strcpy(cp, ifa->ifa_name);
|
||||
ifni2++;
|
||||
|
@ -90,7 +90,7 @@ if_nametoindex(const char *ifname)
|
||||
if (ifa->ifa_addr &&
|
||||
ifa->ifa_addr->sa_family == AF_LINK &&
|
||||
strcmp(ifa->ifa_name, ifname) == 0) {
|
||||
ni = ((struct sockaddr_dl*)ifa->ifa_addr)->sdl_index;
|
||||
ni = LLINDEX((struct sockaddr_dl*)ifa->ifa_addr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ __inaddr_to_index(in_addr_t ifaddr)
|
||||
psu = (sockunion_t *)ifa->ifa_addr;
|
||||
if (psu && psu->ss.ss_family == AF_LINK &&
|
||||
strcmp(ifa->ifa_name, ifname) == 0) {
|
||||
ifindex = psu->sdl.sdl_index;
|
||||
ifindex = LLINDEX(&psu->sdl);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ struct sockaddr_dl {
|
||||
};
|
||||
|
||||
#define LLADDR(s) ((caddr_t)((s)->sdl_data + (s)->sdl_nlen))
|
||||
#define LLINDEX(s) ((s)->sdl_index)
|
||||
|
||||
#ifndef _KERNEL
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user