Home | History | Annotate | Line # | Download | only in net
pfil.h revision 1.31
      1  1.31    rmind /*	$NetBSD: pfil.h,v 1.31 2013/06/29 21:06:58 rmind Exp $	*/
      2   1.1      mrg 
      3   1.1      mrg /*
      4   1.1      mrg  * Copyright (c) 1996 Matthew R. Green
      5   1.1      mrg  * All rights reserved.
      6   1.1      mrg  *
      7   1.1      mrg  * Redistribution and use in source and binary forms, with or without
      8   1.1      mrg  * modification, are permitted provided that the following conditions
      9   1.1      mrg  * are met:
     10   1.1      mrg  * 1. Redistributions of source code must retain the above copyright
     11   1.1      mrg  *    notice, this list of conditions and the following disclaimer.
     12   1.1      mrg  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1      mrg  *    notice, this list of conditions and the following disclaimer in the
     14   1.1      mrg  *    documentation and/or other materials provided with the distribution.
     15   1.1      mrg  *
     16   1.1      mrg  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17   1.1      mrg  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18   1.1      mrg  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19   1.1      mrg  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20   1.1      mrg  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     21   1.1      mrg  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     22   1.1      mrg  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     23   1.1      mrg  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     24   1.1      mrg  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25   1.1      mrg  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26   1.1      mrg  * SUCH DAMAGE.
     27   1.1      mrg  */
     28   1.1      mrg 
     29   1.1      mrg #ifndef _NET_PFIL_H_
     30   1.1      mrg #define _NET_PFIL_H_
     31  1.21   martin 
     32  1.10  darrenr #include <sys/queue.h>
     33   1.1      mrg 
     34  1.10  darrenr struct mbuf;
     35  1.10  darrenr struct ifnet;
     36   1.1      mrg 
     37   1.1      mrg /*
     38   1.1      mrg  * The packet filter hooks are designed for anything to call them to
     39   1.1      mrg  * possibly intercept the packet.
     40   1.1      mrg  */
     41  1.31    rmind typedef int (*pfil_func_t)(void *, struct mbuf **, struct ifnet *, int);
     42   1.1      mrg 
     43   1.1      mrg #define PFIL_IN		0x00000001
     44   1.1      mrg #define PFIL_OUT	0x00000002
     45  1.23   itojun #define PFIL_ALL	(PFIL_IN|PFIL_OUT)
     46  1.23   itojun #define PFIL_IFADDR	0x00000008
     47  1.24     yamt #define PFIL_IFNET	0x00000010
     48  1.24     yamt 
     49  1.24     yamt /* events notified by PFIL_IFNET */
     50  1.24     yamt #define	PFIL_IFNET_ATTACH	0
     51  1.24     yamt #define	PFIL_IFNET_DETACH	1
     52   1.1      mrg 
     53  1.18  thorpej #define	PFIL_TYPE_AF		1	/* key is AF_* type */
     54  1.18  thorpej #define	PFIL_TYPE_IFNET		2	/* key is ifnet pointer */
     55  1.18  thorpej 
     56  1.31    rmind typedef struct pfil_head	pfil_head_t;
     57  1.10  darrenr 
     58  1.27    perry #ifdef _KERNEL
     59  1.27    perry 
     60  1.31    rmind int	pfil_run_hooks(pfil_head_t *, struct mbuf **, struct ifnet *, int);
     61  1.31    rmind int	pfil_add_hook(pfil_func_t, void *, int, pfil_head_t *);
     62  1.31    rmind int	pfil_remove_hook(pfil_func_t, void *, int, pfil_head_t *);
     63  1.31    rmind 
     64  1.31    rmind pfil_head_t *	pfil_head_create(int, void *);
     65  1.31    rmind void		pfil_head_destroy(pfil_head_t *);
     66  1.31    rmind pfil_head_t *	pfil_head_get(int, void *);
     67   1.4      mrg 
     68  1.31    rmind /* Packet filtering hook for interfaces (in sys/net/if.c module). */
     69  1.31    rmind extern pfil_head_t *if_pfil;
     70   1.1      mrg 
     71  1.27    perry #endif /* _KERNEL */
     72  1.23   itojun 
     73  1.25     elad #endif /* !_NET_PFIL_H_ */
     74