X-Git-Url: http://git.onelab.eu/?p=ipfw.git;a=blobdiff_plain;f=dummynet2%2Finclude%2Fnet%2Fpfil.h;fp=dummynet2%2Finclude%2Fnet%2Fpfil.h;h=af26a79e585581013178ff934fbee574a8713972;hp=19a3d9c9650a3c2c364e5096239b3d7d324603b7;hb=28a7fe9d930667786b902af6697c01eb87694173;hpb=2a8b6c544cf5ea3c84f763144c7ecfa79daea969 diff --git a/dummynet2/include/net/pfil.h b/dummynet2/include/net/pfil.h index 19a3d9c..af26a79 100644 --- a/dummynet2/include/net/pfil.h +++ b/dummynet2/include/net/pfil.h @@ -37,7 +37,7 @@ #include #include #include -#include +#include struct mbuf; struct ifnet; @@ -49,9 +49,9 @@ struct inpcb; */ struct packet_filter_hook { TAILQ_ENTRY(packet_filter_hook) pfil_link; - int (*pfil_func)(void *, struct mbuf **, struct ifnet *, int, struct inpcb *); + int (*pfil_func)(void *, struct mbuf **, struct ifnet *, int, + struct inpcb *); void *pfil_arg; - int pfil_flags; }; #define PFIL_IN 0x00000001 @@ -72,7 +72,7 @@ struct pfil_head { #if defined( __linux__ ) || defined( _WIN32 ) rwlock_t ph_mtx; #else - struct rwlock ph_mtx; + struct rmlock ph_lock; #endif union { u_long phu_val; @@ -83,30 +83,33 @@ struct pfil_head { LIST_ENTRY(pfil_head) ph_list; }; +int pfil_add_hook(int (*func)(void *, struct mbuf **, struct ifnet *, + int, struct inpcb *), void *, int, struct pfil_head *); +int pfil_remove_hook(int (*func)(void *, struct mbuf **, struct ifnet *, + int, struct inpcb *), void *, int, struct pfil_head *); int pfil_run_hooks(struct pfil_head *, struct mbuf **, struct ifnet *, int, struct inpcb *inp); -int pfil_add_hook(int (*func)(void *, struct mbuf **, - struct ifnet *, int, struct inpcb *), void *, int, struct pfil_head *); -int pfil_remove_hook(int (*func)(void *, struct mbuf **, - struct ifnet *, int, struct inpcb *), void *, int, struct pfil_head *); - int pfil_head_register(struct pfil_head *); int pfil_head_unregister(struct pfil_head *); struct pfil_head *pfil_head_get(int, u_long); #define PFIL_HOOKED(p) ((p)->ph_nhooks > 0) -#define PFIL_RLOCK(p) rw_rlock(&(p)->ph_mtx) -#define PFIL_WLOCK(p) rw_wlock(&(p)->ph_mtx) -#define PFIL_RUNLOCK(p) rw_runlock(&(p)->ph_mtx) -#define PFIL_WUNLOCK(p) rw_wunlock(&(p)->ph_mtx) +#define PFIL_LOCK_INIT(p) \ + rm_init_flags(&(p)->ph_lock, "PFil hook read/write mutex", RM_RECURSE) +#define PFIL_LOCK_DESTROY(p) rm_destroy(&(p)->ph_lock) +#define PFIL_RLOCK(p, t) rm_rlock(&(p)->ph_lock, (t)) +#define PFIL_WLOCK(p) rm_wlock(&(p)->ph_lock) +#define PFIL_RUNLOCK(p, t) rm_runlock(&(p)->ph_lock, (t)) +#define PFIL_WUNLOCK(p) rm_wunlock(&(p)->ph_lock) #define PFIL_LIST_LOCK() mtx_lock(&pfil_global_lock) #define PFIL_LIST_UNLOCK() mtx_unlock(&pfil_global_lock) static __inline struct packet_filter_hook * pfil_hook_get(int dir, struct pfil_head *ph) { + if (dir == PFIL_IN) return (TAILQ_FIRST(&ph->ph_in)); else if (dir == PFIL_OUT)