mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-07 13:14:51 +00:00
Add in_localip_fib(), in6_localip_fib().
Check if given address/FIB exists locally. Reviewed by: melifaro Differential revision: https://reviews.freebsd.org/D32913
This commit is contained in:
parent
81674f121e
commit
9c89392f12
@ -137,6 +137,24 @@ in_localip(struct in_addr in)
|
||||
return (false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Like in_localip(), but FIB-aware.
|
||||
*/
|
||||
bool
|
||||
in_localip_fib(struct in_addr in, uint16_t fib)
|
||||
{
|
||||
struct in_ifaddr *ia;
|
||||
|
||||
NET_EPOCH_ASSERT();
|
||||
|
||||
CK_LIST_FOREACH(ia, INADDR_HASH(in.s_addr), ia_hash)
|
||||
if (IA_SIN(ia)->sin_addr.s_addr == in.s_addr &&
|
||||
ia->ia_ifa.ifa_ifp->if_fib == fib)
|
||||
return (true);
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return 1 if an internet address is configured on an interface.
|
||||
*/
|
||||
|
@ -662,6 +662,7 @@ int in_ifaddr_broadcast(struct in_addr, struct in_ifaddr *);
|
||||
int in_canforward(struct in_addr);
|
||||
int in_localaddr(struct in_addr);
|
||||
bool in_localip(struct in_addr);
|
||||
bool in_localip_fib(struct in_addr, uint16_t);
|
||||
int in_ifhasaddr(struct ifnet *, struct in_addr);
|
||||
struct in_ifaddr *in_findlocal(uint32_t, bool);
|
||||
int inet_aton(const char *, struct in_addr *); /* in libkern */
|
||||
|
@ -1753,6 +1753,27 @@ in6_localip(struct in6_addr *in6)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Like in6_localip(), but FIB-aware.
|
||||
*/
|
||||
bool
|
||||
in6_localip_fib(struct in6_addr *in6, uint16_t fib)
|
||||
{
|
||||
struct rm_priotracker in6_ifa_tracker;
|
||||
struct in6_ifaddr *ia;
|
||||
|
||||
IN6_IFADDR_RLOCK(&in6_ifa_tracker);
|
||||
CK_LIST_FOREACH(ia, IN6ADDR_HASH(in6), ia6_hash) {
|
||||
if (IN6_ARE_ADDR_EQUAL(in6, &ia->ia_addr.sin6_addr) &&
|
||||
ia->ia_ifa.ifa_ifp->if_fib == fib) {
|
||||
IN6_IFADDR_RUNLOCK(&in6_ifa_tracker);
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
IN6_IFADDR_RUNLOCK(&in6_ifa_tracker);
|
||||
return (false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return 1 if an internet address is configured on an interface.
|
||||
*/
|
||||
|
@ -674,6 +674,7 @@ int in6_cksum_partial(struct mbuf *, u_int8_t, u_int32_t, u_int32_t,
|
||||
u_int32_t);
|
||||
int in6_localaddr(struct in6_addr *);
|
||||
int in6_localip(struct in6_addr *);
|
||||
bool in6_localip_fib(struct in6_addr *, uint16_t);
|
||||
int in6_ifhasaddr(struct ifnet *, struct in6_addr *);
|
||||
int in6_addrscope(const struct in6_addr *);
|
||||
char *ip6_sprintf(char *, const struct in6_addr *);
|
||||
|
Loading…
Reference in New Issue
Block a user