Home | History | Annotate | Line # | Download | only in pfctl
pfctl.h revision 1.4
      1 /*	$NetBSD: pfctl.h,v 1.4 2005/07/01 12:43:50 peter Exp $	*/
      2 /*	$OpenBSD: pfctl.h,v 1.37 2005/01/05 18:23:10 mcbride Exp $ */
      3 
      4 /*
      5  * Copyright (c) 2001 Daniel Hartmeier
      6  * All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  *
     12  *    - Redistributions of source code must retain the above copyright
     13  *      notice, this list of conditions and the following disclaimer.
     14  *    - Redistributions in binary form must reproduce the above
     15  *      copyright notice, this list of conditions and the following
     16  *      disclaimer in the documentation and/or other materials provided
     17  *      with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     23  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
     24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     26  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
     27  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
     29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30  * POSSIBILITY OF SUCH DAMAGE.
     31  *
     32  */
     33 
     34 #ifndef _PFCTL_H_
     35 #define _PFCTL_H_
     36 
     37 enum {	PFRB_TABLES = 1, PFRB_TSTATS, PFRB_ADDRS, PFRB_ASTATS,
     38 	PFRB_IFACES, PFRB_TRANS, PFRB_MAX };
     39 struct pfr_buffer {
     40 	int	 pfrb_type;	/* type of content, see enum above */
     41 	int	 pfrb_size;	/* number of objects in buffer */
     42 	int	 pfrb_msize;	/* maximum number of objects in buffer */
     43 	void	*pfrb_caddr;	/* malloc'ated memory area */
     44 };
     45 #define PFRB_FOREACH(var, buf)				\
     46 	for ((var) = pfr_buf_next((buf), NULL);		\
     47 	    (var) != NULL;				\
     48 	    (var) = pfr_buf_next((buf), (var)))
     49 
     50 void	 pfr_set_fd(int);
     51 int	 pfr_get_fd(void);
     52 int	 pfr_clr_tables(struct pfr_table *, int *, int);
     53 int	 pfr_add_tables(struct pfr_table *, int, int *, int);
     54 int	 pfr_del_tables(struct pfr_table *, int, int *, int);
     55 int	 pfr_get_tables(struct pfr_table *, struct pfr_table *, int *, int);
     56 int	 pfr_get_tstats(struct pfr_table *, struct pfr_tstats *, int *, int);
     57 int	 pfr_clr_tstats(struct pfr_table *, int, int *, int);
     58 int	 pfr_clr_addrs(struct pfr_table *, int *, int);
     59 int	 pfr_add_addrs(struct pfr_table *, struct pfr_addr *, int, int *, int);
     60 int	 pfr_del_addrs(struct pfr_table *, struct pfr_addr *, int, int *, int);
     61 int	 pfr_set_addrs(struct pfr_table *, struct pfr_addr *, int, int *,
     62 	    int *, int *, int *, int);
     63 int	 pfr_get_addrs(struct pfr_table *, struct pfr_addr *, int *, int);
     64 int	 pfr_get_astats(struct pfr_table *, struct pfr_astats *, int *, int);
     65 int	 pfr_clr_astats(struct pfr_table *, struct pfr_addr *, int, int *, int);
     66 int	 pfr_tst_addrs(struct pfr_table *, struct pfr_addr *, int, int *, int);
     67 int	 pfr_set_tflags(struct pfr_table *, int, int, int, int *, int *, int);
     68 int	 pfr_ina_define(struct pfr_table *, struct pfr_addr *, int, int *,
     69 	    int *, int, int);
     70 void	 pfr_buf_clear(struct pfr_buffer *);
     71 int	 pfr_buf_add(struct pfr_buffer *, const void *);
     72 void	*pfr_buf_next(struct pfr_buffer *, const void *);
     73 int	 pfr_buf_grow(struct pfr_buffer *, int);
     74 int	 pfr_buf_load(struct pfr_buffer *, char *, int,
     75 	    int (*)(struct pfr_buffer *, char *, int));
     76 char	*pfr_strerror(int);
     77 int	 pfi_get_ifaces(const char *, struct pfi_if *, int *, int);
     78 int	 pfi_clr_istats(const char *, int *, int);
     79 
     80 void	 pfctl_print_title(char *);
     81 int	 pfctl_clear_tables(const char *, int);
     82 int	 pfctl_show_tables(const char *, int);
     83 int	 pfctl_command_tables(int, char *[], char *, const char *, char *,
     84 	    const char *, int);
     85 int	 pfctl_show_altq(int, const char *, int, int);
     86 void	 warn_namespace_collision(const char *);
     87 int	 pfctl_show_ifaces(const char *, int);
     88 FILE	*pfctl_fopen(const char *, const char *);
     89 
     90 #ifndef DEFAULT_PRIORITY
     91 #define DEFAULT_PRIORITY	1
     92 #endif
     93 
     94 #ifndef DEFAULT_QLIMIT
     95 #define DEFAULT_QLIMIT		50
     96 #endif
     97 
     98 /*
     99  * generalized service curve used for admission control
    100  */
    101 struct segment {
    102 	LIST_ENTRY(segment)	_next;
    103 	double			x, y, d, m;
    104 };
    105 
    106 extern	int loadopt;
    107 
    108 int		 check_commit_altq(int, int);
    109 void		 pfaltq_store(struct pf_altq *);
    110 void		 pfaltq_free(struct pf_altq *);
    111 struct pf_altq	*pfaltq_lookup(const char *);
    112 char		*rate2str(double);
    113 
    114 void	 print_addr(struct pf_addr_wrap *, sa_family_t, int);
    115 void	 print_host(struct pf_state_host *, sa_family_t, int);
    116 void	 print_seq(struct pf_state_peer *);
    117 void	 print_state(struct pf_state *, int);
    118 int	 unmask(struct pf_addr *, sa_family_t);
    119 
    120 int	 pfctl_cmdline_symset(char *);
    121 int	 pfctl_add_trans(struct pfr_buffer *, int, const char *);
    122 u_int32_t
    123 	 pfctl_get_ticket(struct pfr_buffer *, int, const char *);
    124 int	 pfctl_trans(int, struct pfr_buffer *, u_long, int);
    125 
    126 #endif /* _PFCTL_H_ */
    127