Introduce typedef for pfil hook callback function and replace all

spelled out occurrences with it.

Reviewed by:	eri
This commit is contained in:
andre 2013-08-24 10:13:59 +00:00
parent 7b3e1df40a
commit 5630e57e48
2 changed files with 9 additions and 13 deletions

View File

@ -225,8 +225,7 @@ pfil_head_get(int type, u_long val)
* PFIL_WAITOK OK to call malloc with M_WAITOK.
*/
int
pfil_add_hook(int (*func)(void *, struct mbuf **, struct ifnet *, int,
struct inpcb *), void *arg, int flags, struct pfil_head *ph)
pfil_add_hook(pfil_func_t func, void *arg, int flags, struct pfil_head *ph)
{
struct packet_filter_hook *pfh1 = NULL;
struct packet_filter_hook *pfh2 = NULL;
@ -285,8 +284,7 @@ pfil_add_hook(int (*func)(void *, struct mbuf **, struct ifnet *, int,
* list.
*/
int
pfil_remove_hook(int (*func)(void *, struct mbuf **, struct ifnet *, int,
struct inpcb *), void *arg, int flags, struct pfil_head *ph)
pfil_remove_hook(pfil_func_t func, void *arg, int flags, struct pfil_head *ph)
{
int err = 0;
@ -334,9 +332,7 @@ pfil_list_add(pfil_list_t *list, struct packet_filter_hook *pfh1, int flags)
* specified list.
*/
static int
pfil_list_remove(pfil_list_t *list,
int (*func)(void *, struct mbuf **, struct ifnet *, int, struct inpcb *),
void *arg)
pfil_list_remove(pfil_list_t *list, pfil_func_t func, void *arg)
{
struct packet_filter_hook *pfh;

View File

@ -43,14 +43,16 @@ struct mbuf;
struct ifnet;
struct inpcb;
typedef int (*pfil_func_t)(void *, struct mbuf **, struct ifnet *, int,
struct inpcb *);
/*
* The packet filter hooks are designed for anything to call them to
* possibly intercept the packet.
*/
struct packet_filter_hook {
TAILQ_ENTRY(packet_filter_hook) pfil_link;
int (*pfil_func)(void *, struct mbuf **, struct ifnet *, int,
struct inpcb *);
pfil_func_t pfil_func;
void *pfil_arg;
};
@ -87,10 +89,8 @@ 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_add_hook(pfil_func_t, void *, int, struct pfil_head *);
int pfil_remove_hook(pfil_func_t, void *, int, struct pfil_head *);
int pfil_run_hooks(struct pfil_head *, struct mbuf **, struct ifnet *,
int, struct inpcb *inp);