mirror of
https://github.com/opnsense/src.git
synced 2026-06-08 16:22:46 -04:00
Add two extra functions that basically give count of addresses
on interface. Such function could been implemented on top of the if_foreach_llm?addr(), but several drivers need counting, so avoid copy-n-paste inside the drivers.
This commit is contained in:
parent
826857c833
commit
fb3fc771f6
2 changed files with 36 additions and 0 deletions
34
sys/net/if.c
34
sys/net/if.c
|
|
@ -4268,6 +4268,23 @@ if_getmtu_family(if_t ifp, int family)
|
|||
* link level addresses. Driver shall not know 'struct ifaddr' neither
|
||||
* 'struct ifmultiaddr'.
|
||||
*/
|
||||
u_int
|
||||
if_lladdr_count(if_t ifp)
|
||||
{
|
||||
struct epoch_tracker et;
|
||||
struct ifaddr *ifa;
|
||||
u_int count;
|
||||
|
||||
count = 0;
|
||||
NET_EPOCH_ENTER(et);
|
||||
CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
|
||||
if (ifa->ifa_addr->sa_family == AF_LINK)
|
||||
count++;
|
||||
NET_EPOCH_EXIT(et);
|
||||
|
||||
return (count);
|
||||
}
|
||||
|
||||
u_int
|
||||
if_foreach_lladdr(if_t ifp, iflladdr_cb_t cb, void *cb_arg)
|
||||
{
|
||||
|
|
@ -4290,6 +4307,23 @@ if_foreach_lladdr(if_t ifp, iflladdr_cb_t cb, void *cb_arg)
|
|||
return (count);
|
||||
}
|
||||
|
||||
u_int
|
||||
if_llmaddr_count(if_t ifp)
|
||||
{
|
||||
struct epoch_tracker et;
|
||||
struct ifmultiaddr *ifma;
|
||||
int count;
|
||||
|
||||
count = 0;
|
||||
NET_EPOCH_ENTER(et);
|
||||
CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link)
|
||||
if (ifma->ifma_addr->sa_family == AF_LINK)
|
||||
count++;
|
||||
NET_EPOCH_EXIT(et);
|
||||
|
||||
return (count);
|
||||
}
|
||||
|
||||
u_int
|
||||
if_foreach_llmaddr(if_t ifp, iflladdr_cb_t cb, void *cb_arg)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -772,6 +772,8 @@ struct sockaddr_dl;
|
|||
typedef u_int iflladdr_cb_t(void *, struct sockaddr_dl *, u_int);
|
||||
u_int if_foreach_lladdr(if_t, iflladdr_cb_t, void *);
|
||||
u_int if_foreach_llmaddr(if_t, iflladdr_cb_t, void *);
|
||||
u_int if_lladdr_count(if_t);
|
||||
u_int if_llmaddr_count(if_t);
|
||||
int if_multiaddr_count(if_t ifp, int max);
|
||||
|
||||
/* Obsoleted multicast management functions. */
|
||||
|
|
|
|||
Loading…
Reference in a new issue