Home | History | Annotate | Line # | Download | only in net
pfil.h revision 1.29.42.3
      1  1.29.42.2       tls /*	$NetBSD: pfil.h,v 1.29.42.3 2017/12/03 11:39:02 jdolecek 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.29.42.3  jdolecek struct ifaddr;
     37        1.1       mrg 
     38        1.1       mrg /*
     39        1.1       mrg  * The packet filter hooks are designed for anything to call them to
     40        1.1       mrg  * possibly intercept the packet.
     41        1.1       mrg  */
     42  1.29.42.2       tls typedef int (*pfil_func_t)(void *, struct mbuf **, struct ifnet *, int);
     43  1.29.42.3  jdolecek typedef void (*pfil_ifunc_t)(void *, unsigned long, void *);
     44        1.1       mrg 
     45        1.1       mrg #define PFIL_IN		0x00000001
     46        1.1       mrg #define PFIL_OUT	0x00000002
     47       1.23    itojun #define PFIL_ALL	(PFIL_IN|PFIL_OUT)
     48       1.23    itojun #define PFIL_IFADDR	0x00000008
     49       1.24      yamt #define PFIL_IFNET	0x00000010
     50       1.24      yamt 
     51       1.24      yamt /* events notified by PFIL_IFNET */
     52       1.24      yamt #define	PFIL_IFNET_ATTACH	0
     53       1.24      yamt #define	PFIL_IFNET_DETACH	1
     54        1.1       mrg 
     55       1.18   thorpej #define	PFIL_TYPE_AF		1	/* key is AF_* type */
     56  1.29.42.3  jdolecek #define	PFIL_TYPE_IFNET		2	/* key is ifnet or ifaddr pointer */
     57       1.18   thorpej 
     58  1.29.42.2       tls typedef struct pfil_head	pfil_head_t;
     59       1.10   darrenr 
     60       1.27     perry #ifdef _KERNEL
     61       1.27     perry 
     62  1.29.42.3  jdolecek void	pfil_init(void);
     63  1.29.42.2       tls int	pfil_run_hooks(pfil_head_t *, struct mbuf **, struct ifnet *, int);
     64  1.29.42.3  jdolecek void	pfil_run_addrhooks(pfil_head_t *, unsigned long, struct ifaddr *);
     65  1.29.42.3  jdolecek void	pfil_run_ifhooks(pfil_head_t *, unsigned long, struct ifnet *);
     66  1.29.42.3  jdolecek 
     67  1.29.42.2       tls int	pfil_add_hook(pfil_func_t, void *, int, pfil_head_t *);
     68  1.29.42.2       tls int	pfil_remove_hook(pfil_func_t, void *, int, pfil_head_t *);
     69  1.29.42.2       tls 
     70  1.29.42.3  jdolecek int	pfil_add_ihook(pfil_ifunc_t, void *, int, pfil_head_t *);
     71  1.29.42.3  jdolecek int	pfil_remove_ihook(pfil_ifunc_t, void *, int, pfil_head_t *);
     72  1.29.42.3  jdolecek 
     73  1.29.42.2       tls pfil_head_t *	pfil_head_create(int, void *);
     74  1.29.42.2       tls void		pfil_head_destroy(pfil_head_t *);
     75  1.29.42.2       tls pfil_head_t *	pfil_head_get(int, void *);
     76        1.4       mrg 
     77  1.29.42.2       tls /* Packet filtering hook for interfaces (in sys/net/if.c module). */
     78  1.29.42.2       tls extern pfil_head_t *if_pfil;
     79        1.1       mrg 
     80       1.27     perry #endif /* _KERNEL */
     81       1.23    itojun 
     82       1.25      elad #endif /* !_NET_PFIL_H_ */
     83