npfctl.h revision 1.5 1 1.5 rmind /* $NetBSD: npfctl.h,v 1.5 2011/01/18 20:33:45 rmind Exp $ */
2 1.1 rmind
3 1.1 rmind /*-
4 1.5 rmind * Copyright (c) 2009-2011 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.4 rmind #define NPF_SESSDB_PATH "/var/db/npf_sessions.db"
53 1.1 rmind
54 1.1 rmind typedef struct {
55 1.1 rmind char * e_data;
56 1.1 rmind void * e_next;
57 1.1 rmind } element_t;
58 1.1 rmind
59 1.1 rmind #define VAR_SINGLE 1
60 1.1 rmind #define VAR_ARRAY 2
61 1.1 rmind #define VAR_TABLE 3
62 1.1 rmind
63 1.1 rmind typedef struct {
64 1.1 rmind char * v_key;
65 1.1 rmind element_t * v_elements;
66 1.1 rmind int v_type;
67 1.1 rmind int v_count;
68 1.1 rmind void * v_next;
69 1.1 rmind } var_t;
70 1.1 rmind
71 1.1 rmind void * zalloc(size_t);
72 1.1 rmind char * xstrdup(const char *);
73 1.1 rmind
74 1.1 rmind void npfctl_init_data(void);
75 1.1 rmind int npfctl_ioctl_send(int);
76 1.4 rmind int npfctl_ioctl_recvse(int);
77 1.4 rmind int npfctl_ioctl_sendse(int);
78 1.5 rmind int npfctl_ioctl_flushse(int);
79 1.1 rmind
80 1.5 rmind struct ifaddrs *npfctl_getif(char *, unsigned int *, bool);
81 1.1 rmind bool npfctl_parse_v4mask(char *, in_addr_t *, in_addr_t *);
82 1.1 rmind
83 1.5 rmind prop_dictionary_t npfctl_mk_rule(bool, prop_dictionary_t);
84 1.5 rmind void npfctl_rule_setattr(prop_dictionary_t, int, u_int);
85 1.2 rmind void npfctl_rule_protodata(prop_dictionary_t, char *, char *,
86 1.2 rmind int, int, var_t *, var_t *, var_t *, var_t *);
87 1.1 rmind void npfctl_rule_icmpdata(prop_dictionary_t, var_t *, var_t *);
88 1.1 rmind
89 1.1 rmind prop_dictionary_t npfctl_lookup_table(char *);
90 1.5 rmind prop_dictionary_t npfctl_construct_table(int, int);
91 1.5 rmind void npfctl_fill_table(prop_dictionary_t, char *);
92 1.5 rmind
93 1.5 rmind prop_dictionary_t npfctl_mk_rproc(void);
94 1.5 rmind bool npfctl_find_rproc(prop_dictionary_t, char *);
95 1.1 rmind
96 1.1 rmind prop_dictionary_t npfctl_mk_nat(void);
97 1.2 rmind void npfctl_nat_setup(prop_dictionary_t, int, int,
98 1.5 rmind u_int, char *, char *);
99 1.1 rmind
100 1.1 rmind size_t npfctl_calc_ncsize(int []);
101 1.1 rmind size_t npfctl_failure_offset(int []);
102 1.1 rmind
103 1.1 rmind void npfctl_gennc_ether(void **, int, uint16_t);
104 1.1 rmind void npfctl_gennc_v4cidr(void **, int,
105 1.1 rmind in_addr_t, in_addr_t, bool);
106 1.1 rmind void npfctl_gennc_icmp(void **, int, int, int);
107 1.2 rmind void npfctl_gennc_tcpfl(void **, int , uint8_t, uint8_t);
108 1.1 rmind void npfctl_gennc_ports(void **, int,
109 1.1 rmind in_port_t, in_port_t, bool, bool);
110 1.1 rmind void npfctl_gennc_tbl(void **, int, u_int , bool);
111 1.1 rmind void npfctl_gennc_complete(void **);
112 1.1 rmind
113 1.1 rmind int npf_parseline(char *);
114 1.1 rmind
115 1.1 rmind #endif
116