Home | History | Annotate | Line # | Download | only in npfctl
npfctl.h revision 1.3
      1  1.3  rmind /*	$NetBSD: npfctl.h,v 1.3 2010/11/11 06:30:39 rmind Exp $	*/
      2  1.1  rmind 
      3  1.1  rmind /*-
      4  1.1  rmind  * Copyright (c) 2009-2010 The NetBSD Foundation, Inc.
      5  1.1  rmind  * All rights reserved.
      6  1.1  rmind  *
      7  1.1  rmind  * Redistribution and use in source and binary forms, with or without
      8  1.1  rmind  * modification, are permitted provided that the following conditions
      9  1.1  rmind  * are met:
     10  1.1  rmind  * 1. Redistributions of source code must retain the above copyright
     11  1.1  rmind  *    notice, this list of conditions and the following disclaimer.
     12  1.1  rmind  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  rmind  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  rmind  *    documentation and/or other materials provided with the distribution.
     15  1.1  rmind  *
     16  1.1  rmind  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17  1.1  rmind  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18  1.1  rmind  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  1.1  rmind  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20  1.1  rmind  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  1.1  rmind  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  1.1  rmind  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  1.1  rmind  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  1.1  rmind  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  1.1  rmind  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  1.1  rmind  * POSSIBILITY OF SUCH DAMAGE.
     27  1.1  rmind  */
     28  1.1  rmind 
     29  1.1  rmind #ifndef _NPFCTL_H_
     30  1.1  rmind #define _NPFCTL_H_
     31  1.1  rmind 
     32  1.1  rmind #include <sys/types.h>
     33  1.1  rmind #include <stdio.h>
     34  1.1  rmind #include <stdbool.h>
     35  1.1  rmind 
     36  1.1  rmind #ifndef _NPF_TESTING
     37  1.1  rmind #include <net/npf.h>
     38  1.1  rmind #include <net/npf_ncode.h>
     39  1.1  rmind #else
     40  1.1  rmind #include "npf.h"
     41  1.1  rmind #include "npf_ncode.h"
     42  1.1  rmind #endif
     43  1.1  rmind 
     44  1.1  rmind #ifdef DEBUG
     45  1.1  rmind #define	DPRINTF(x)	printf x
     46  1.1  rmind #else
     47  1.1  rmind #define	DPRINTF(x)
     48  1.1  rmind #endif
     49  1.1  rmind 
     50  1.1  rmind #define	NPF_DEV_PATH	"/dev/npf"
     51  1.1  rmind #define	NPF_CONF_PATH	"/etc/npf.conf"
     52  1.1  rmind 
     53  1.1  rmind typedef struct {
     54  1.1  rmind 	char *		e_data;
     55  1.1  rmind 	void *		e_next;
     56  1.1  rmind } element_t;
     57  1.1  rmind 
     58  1.1  rmind #define	VAR_SINGLE	1
     59  1.1  rmind #define	VAR_ARRAY	2
     60  1.1  rmind #define	VAR_TABLE	3
     61  1.1  rmind 
     62  1.1  rmind typedef struct {
     63  1.1  rmind 	char *		v_key;
     64  1.1  rmind 	element_t *	v_elements;
     65  1.1  rmind 	int		v_type;
     66  1.1  rmind 	int		v_count;
     67  1.1  rmind 	void *		v_next;
     68  1.1  rmind } var_t;
     69  1.1  rmind 
     70  1.1  rmind void *		zalloc(size_t);
     71  1.1  rmind char *		xstrdup(const char *);
     72  1.1  rmind 
     73  1.1  rmind void		npfctl_init_data(void);
     74  1.1  rmind int		npfctl_ioctl_send(int);
     75  1.1  rmind 
     76  1.1  rmind bool		npfctl_parse_v4mask(char *, in_addr_t *, in_addr_t *);
     77  1.1  rmind 
     78  1.1  rmind prop_dictionary_t npfctl_mk_rule(bool);
     79  1.1  rmind void		npfctl_add_rule(prop_dictionary_t, prop_dictionary_t);
     80  1.3  rmind void		npfctl_rule_setattr(prop_dictionary_t, int, char *,
     81  1.3  rmind 		    bool, int, int);
     82  1.2  rmind void		npfctl_rule_protodata(prop_dictionary_t, char *, char *,
     83  1.2  rmind 		    int, int, var_t *, var_t *, var_t *, var_t *);
     84  1.1  rmind void		npfctl_rule_icmpdata(prop_dictionary_t, var_t *, var_t *);
     85  1.1  rmind 
     86  1.1  rmind prop_dictionary_t npfctl_lookup_table(char *);
     87  1.1  rmind prop_dictionary_t npfctl_mk_table(void);
     88  1.1  rmind void		npfctl_table_setup(prop_dictionary_t, char *, char *);
     89  1.1  rmind void		npfctl_construct_table(prop_dictionary_t, char *);
     90  1.1  rmind void		npfctl_add_table(prop_dictionary_t);
     91  1.1  rmind 
     92  1.1  rmind prop_dictionary_t npfctl_mk_nat(void);
     93  1.1  rmind void		npfctl_add_nat(prop_dictionary_t);
     94  1.2  rmind void		npfctl_nat_setup(prop_dictionary_t, int, int,
     95  1.2  rmind 		    char *, char *, char *);
     96  1.1  rmind 
     97  1.1  rmind size_t		npfctl_calc_ncsize(int []);
     98  1.1  rmind size_t		npfctl_failure_offset(int []);
     99  1.1  rmind 
    100  1.1  rmind void		npfctl_gennc_ether(void **, int, uint16_t);
    101  1.1  rmind void		npfctl_gennc_v4cidr(void **, int,
    102  1.1  rmind 		    in_addr_t, in_addr_t, bool);
    103  1.1  rmind void		npfctl_gennc_icmp(void **, int, int, int);
    104  1.2  rmind void		npfctl_gennc_tcpfl(void **, int , uint8_t, uint8_t);
    105  1.1  rmind void		npfctl_gennc_ports(void **, int,
    106  1.1  rmind 		    in_port_t, in_port_t, bool, bool);
    107  1.1  rmind void		npfctl_gennc_tbl(void **, int, u_int , bool);
    108  1.1  rmind void		npfctl_gennc_complete(void **);
    109  1.1  rmind 
    110  1.1  rmind int		npf_parseline(char *);
    111  1.1  rmind 
    112  1.1  rmind #endif
    113