Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netinet/in_var.h
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
#include <sys/queue.h> | #include <sys/queue.h> | ||||
#include <sys/fnv_hash.h> | #include <sys/fnv_hash.h> | ||||
#include <sys/tree.h> | #include <sys/tree.h> | ||||
struct igmp_ifsoftc; | struct igmp_ifsoftc; | ||||
struct in_multi; | struct in_multi; | ||||
struct lltable; | struct lltable; | ||||
SLIST_HEAD(in_multi_head, in_multi); | |||||
/* | /* | ||||
* IPv4 per-interface state. | * IPv4 per-interface state. | ||||
*/ | */ | ||||
struct in_ifinfo { | struct in_ifinfo { | ||||
struct lltable *ii_llt; /* ARP state */ | struct lltable *ii_llt; /* ARP state */ | ||||
struct igmp_ifsoftc *ii_igmp; /* IGMP state */ | struct igmp_ifsoftc *ii_igmp; /* IGMP state */ | ||||
struct in_multi *ii_allhosts; /* 224.0.0.1 membership */ | struct in_multi *ii_allhosts; /* 224.0.0.1 membership */ | ||||
▲ Show 20 Lines • Show All 258 Lines • ▼ Show 20 Lines | |||||
#endif | #endif | ||||
/* | /* | ||||
* Lock macros for IPv4 layer multicast address lists. IPv4 lock goes | * Lock macros for IPv4 layer multicast address lists. IPv4 lock goes | ||||
* before link layer multicast locks in the lock order. In most cases, | * before link layer multicast locks in the lock order. In most cases, | ||||
* consumers of IN_*_MULTI() macros should acquire the locks before | * consumers of IN_*_MULTI() macros should acquire the locks before | ||||
* calling them; users of the in_{add,del}multi() functions should not. | * calling them; users of the in_{add,del}multi() functions should not. | ||||
*/ | */ | ||||
extern struct mtx in_multi_mtx; | extern struct mtx in_multi_list_mtx; | ||||
#define IN_MULTI_LOCK() mtx_lock(&in_multi_mtx) | extern struct sx in_multi_sx; | ||||
#define IN_MULTI_UNLOCK() mtx_unlock(&in_multi_mtx) | |||||
#define IN_MULTI_LOCK_ASSERT() mtx_assert(&in_multi_mtx, MA_OWNED) | |||||
#define IN_MULTI_UNLOCK_ASSERT() mtx_assert(&in_multi_mtx, MA_NOTOWNED) | |||||
#define IN_MULTI_LIST_LOCK() mtx_lock(&in_multi_list_mtx) | |||||
#define IN_MULTI_LIST_UNLOCK() mtx_unlock(&in_multi_list_mtx) | |||||
#define IN_MULTI_LIST_LOCK_ASSERT() mtx_assert(&in_multi_list_mtx, MA_OWNED) | |||||
#define IN_MULTI_LIST_UNLOCK_ASSERT() mtx_assert(&in_multi_list_mtx, MA_NOTOWNED) | |||||
#define IN_MULTI_LOCK() sx_xlock(&in_multi_sx) | |||||
#define IN_MULTI_UNLOCK() sx_xunlock(&in_multi_sx) | |||||
#define IN_MULTI_LOCK_ASSERT() sx_assert(&in_multi_sx, SA_XLOCKED) | |||||
#define IN_MULTI_UNLOCK_ASSERT() sx_assert(&in_multi_sx, SA_XUNLOCKED) | |||||
/* Acquire an in_multi record. */ | /* Acquire an in_multi record. */ | ||||
static __inline void | static __inline void | ||||
inm_acquire_locked(struct in_multi *inm) | inm_acquire_locked(struct in_multi *inm) | ||||
{ | { | ||||
IN_MULTI_LOCK_ASSERT(); | IN_MULTI_LIST_LOCK_ASSERT(); | ||||
++inm->inm_refcount; | ++inm->inm_refcount; | ||||
} | } | ||||
static __inline void | |||||
inm_acquire(struct in_multi *inm) | |||||
{ | |||||
IN_MULTI_LIST_LOCK(); | |||||
inm_acquire_locked(inm); | |||||
IN_MULTI_LIST_UNLOCK(); | |||||
} | |||||
static __inline void | |||||
inm_rele_locked(struct in_multi_head *inmh, struct in_multi *inm) | |||||
{ | |||||
MPASS(inm->inm_refcount > 0); | |||||
IN_MULTI_LIST_LOCK_ASSERT(); | |||||
if (--inm->inm_refcount == 0) { | |||||
MPASS(inmh != NULL); | |||||
inm->inm_ifma->ifma_protospec = NULL; | |||||
SLIST_INSERT_HEAD(inmh, inm, inm_nrele); | |||||
} | |||||
} | |||||
/* | /* | ||||
* Return values for imo_multi_filter(). | * Return values for imo_multi_filter(). | ||||
*/ | */ | ||||
#define MCAST_PASS 0 /* Pass */ | #define MCAST_PASS 0 /* Pass */ | ||||
#define MCAST_NOTGMEMBER 1 /* This host not a member of group */ | #define MCAST_NOTGMEMBER 1 /* This host not a member of group */ | ||||
#define MCAST_NOTSMEMBER 2 /* This host excluded source */ | #define MCAST_NOTSMEMBER 2 /* This host excluded source */ | ||||
#define MCAST_MUTED 3 /* [deprecated] */ | #define MCAST_MUTED 3 /* [deprecated] */ | ||||
struct rtentry; | struct rtentry; | ||||
struct route; | struct route; | ||||
struct ip_moptions; | struct ip_moptions; | ||||
struct in_multi *inm_lookup_locked(struct ifnet *, const struct in_addr); | struct in_multi *inm_lookup_locked(struct ifnet *, const struct in_addr); | ||||
struct in_multi *inm_lookup(struct ifnet *, const struct in_addr); | struct in_multi *inm_lookup(struct ifnet *, const struct in_addr); | ||||
int imo_multi_filter(const struct ip_moptions *, const struct ifnet *, | int imo_multi_filter(const struct ip_moptions *, const struct ifnet *, | ||||
const struct sockaddr *, const struct sockaddr *); | const struct sockaddr *, const struct sockaddr *); | ||||
void inm_commit(struct in_multi *); | void inm_commit(struct in_multi *); | ||||
void inm_clear_recorded(struct in_multi *); | void inm_clear_recorded(struct in_multi *); | ||||
void inm_print(const struct in_multi *); | void inm_print(const struct in_multi *); | ||||
int inm_record_source(struct in_multi *inm, const in_addr_t); | int inm_record_source(struct in_multi *inm, const in_addr_t); | ||||
void inm_release(struct in_multi *); | void inm_release_deferred(struct in_multi *); | ||||
void inm_release_locked(struct in_multi *); | void inm_release_list_deferred(struct in_multi_head *); | ||||
struct in_multi * | struct in_multi * | ||||
in_addmulti(struct in_addr *, struct ifnet *); | in_addmulti(struct in_addr *, struct ifnet *); | ||||
void in_delmulti(struct in_multi *); | |||||
int in_joingroup(struct ifnet *, const struct in_addr *, | int in_joingroup(struct ifnet *, const struct in_addr *, | ||||
/*const*/ struct in_mfilter *, struct in_multi **); | /*const*/ struct in_mfilter *, struct in_multi **); | ||||
int in_joingroup_locked(struct ifnet *, const struct in_addr *, | int in_joingroup_locked(struct ifnet *, const struct in_addr *, | ||||
/*const*/ struct in_mfilter *, struct in_multi **); | /*const*/ struct in_mfilter *, struct in_multi **); | ||||
int in_leavegroup(struct in_multi *, /*const*/ struct in_mfilter *); | int in_leavegroup(struct in_multi *, /*const*/ struct in_mfilter *); | ||||
int in_leavegroup_locked(struct in_multi *, | int in_leavegroup_locked(struct in_multi *, | ||||
/*const*/ struct in_mfilter *); | /*const*/ struct in_mfilter *); | ||||
int in_control(struct socket *, u_long, caddr_t, struct ifnet *, | int in_control(struct socket *, u_long, caddr_t, struct ifnet *, | ||||
Show All 22 Lines |