Skip to content

Commit

Permalink
Introduce typedef for pfil hook callback function and replace all
Browse files Browse the repository at this point in the history
spelled out occurrences with it.

Reviewed by:	eri
  • Loading branch information
andreoppermann committed Aug 24, 2013
1 parent 7b3e1df commit 5630e57
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
10 changes: 3 additions & 7 deletions sys/net/pfil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
12 changes: 6 additions & 6 deletions sys/net/pfil.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 5630e57

Please sign in to comment.