Changeset View
Changeset View
Standalone View
Standalone View
sys/net/pfil.h
Show All 40 Lines | |||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/rmlock.h> | #include <sys/rmlock.h> | ||||
#include <net/vnet.h> | #include <net/vnet.h> | ||||
struct mbuf; | struct mbuf; | ||||
struct ifnet; | struct ifnet; | ||||
struct inpcb; | struct inpcb; | ||||
typedef int (*pfil_func_t)(void *, struct mbuf **, struct ifnet *, int, | typedef int (*pfil_func_t)(void *, struct mbuf **, struct ifnet *, int, int, | ||||
struct inpcb *); | struct inpcb *); | ||||
/* | /* | ||||
* The packet filter hooks are designed for anything to call them to | * The packet filter hooks are designed for anything to call them to | ||||
* possibly intercept the packet. Multiple filter hooks are chained | * possibly intercept the packet. Multiple filter hooks are chained | ||||
* together and after each other in the specified order. | * together and after each other in the specified order. | ||||
*/ | */ | ||||
struct packet_filter_hook { | struct packet_filter_hook { | ||||
TAILQ_ENTRY(packet_filter_hook) pfil_chain; | TAILQ_ENTRY(packet_filter_hook) pfil_chain; | ||||
pfil_func_t pfil_func; | pfil_func_t pfil_func; | ||||
void *pfil_arg; | void *pfil_arg; | ||||
}; | }; | ||||
#define PFIL_IN 0x00000001 | #define PFIL_IN 0x00000001 | ||||
#define PFIL_OUT 0x00000002 | #define PFIL_OUT 0x00000002 | ||||
#define PFIL_WAITOK 0x00000004 | #define PFIL_WAITOK 0x00000004 | ||||
#define PFIL_FWD 0x00000008 | |||||
#define PFIL_ALL (PFIL_IN|PFIL_OUT) | #define PFIL_ALL (PFIL_IN|PFIL_OUT) | ||||
typedef TAILQ_HEAD(pfil_chain, packet_filter_hook) pfil_chain_t; | typedef TAILQ_HEAD(pfil_chain, packet_filter_hook) pfil_chain_t; | ||||
#define PFIL_TYPE_AF 1 /* key is AF_* type */ | #define PFIL_TYPE_AF 1 /* key is AF_* type */ | ||||
#define PFIL_TYPE_IFNET 2 /* key is ifnet pointer */ | #define PFIL_TYPE_IFNET 2 /* key is ifnet pointer */ | ||||
#define PFIL_FLAG_PRIVATE_LOCK 0x01 /* Personal lock instead of global */ | #define PFIL_FLAG_PRIVATE_LOCK 0x01 /* Personal lock instead of global */ | ||||
Show All 28 Lines | |||||
/* Public functions for pfil hook management by packet filters. */ | /* Public functions for pfil hook management by packet filters. */ | ||||
struct pfil_head *pfil_head_get(int, u_long); | struct pfil_head *pfil_head_get(int, u_long); | ||||
int pfil_add_hook(pfil_func_t, void *, int, struct pfil_head *); | int pfil_add_hook(pfil_func_t, void *, int, struct pfil_head *); | ||||
int pfil_remove_hook(pfil_func_t, void *, int, struct pfil_head *); | int pfil_remove_hook(pfil_func_t, void *, int, struct pfil_head *); | ||||
#define PFIL_HOOKED(p) ((p)->ph_nhooks > 0) | #define PFIL_HOOKED(p) ((p)->ph_nhooks > 0) | ||||
/* Public functions to run the packet inspection by protocols. */ | /* Public functions to run the packet inspection by protocols. */ | ||||
int pfil_run_hooks(struct pfil_head *, struct mbuf **, struct ifnet *, | int pfil_run_hooks(struct pfil_head *, struct mbuf **, struct ifnet *, int, | ||||
int, struct inpcb *inp); | int, struct inpcb *inp); | ||||
/* Public functions for pfil head management by protocols. */ | /* Public functions for pfil head management by protocols. */ | ||||
int pfil_head_register(struct pfil_head *); | int pfil_head_register(struct pfil_head *); | ||||
int pfil_head_unregister(struct pfil_head *); | int pfil_head_unregister(struct pfil_head *); | ||||
/* Public pfil locking functions for self managed locks by packet filters. */ | /* Public pfil locking functions for self managed locks by packet filters. */ | ||||
int pfil_try_rlock(struct pfil_head *, struct rm_priotracker *); | int pfil_try_rlock(struct pfil_head *, struct rm_priotracker *); | ||||
void pfil_rlock(struct pfil_head *, struct rm_priotracker *); | void pfil_rlock(struct pfil_head *, struct rm_priotracker *); | ||||
void pfil_runlock(struct pfil_head *, struct rm_priotracker *); | void pfil_runlock(struct pfil_head *, struct rm_priotracker *); | ||||
void pfil_wlock(struct pfil_head *); | void pfil_wlock(struct pfil_head *); | ||||
void pfil_wunlock(struct pfil_head *); | void pfil_wunlock(struct pfil_head *); | ||||
int pfil_wowned(struct pfil_head *ph); | int pfil_wowned(struct pfil_head *ph); | ||||
#endif /* _NET_PFIL_H_ */ | #endif /* _NET_PFIL_H_ */ |