npfctl.h revision 1.6 1 1.6 rmind /* $NetBSD: npfctl.h,v 1.6 2011/02/02 02:20:25 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.6 rmind #include <net/npf_ncode.h>
37 1.1 rmind #include <net/npf.h>
38 1.6 rmind
39 1.6 rmind #define _NPF_PRIVATE
40 1.6 rmind #include <npf.h>
41 1.1 rmind
42 1.1 rmind #ifdef DEBUG
43 1.1 rmind #define DPRINTF(x) printf x
44 1.1 rmind #else
45 1.1 rmind #define DPRINTF(x)
46 1.1 rmind #endif
47 1.1 rmind
48 1.1 rmind #define NPF_DEV_PATH "/dev/npf"
49 1.1 rmind #define NPF_CONF_PATH "/etc/npf.conf"
50 1.4 rmind #define NPF_SESSDB_PATH "/var/db/npf_sessions.db"
51 1.1 rmind
52 1.1 rmind typedef struct {
53 1.1 rmind char * e_data;
54 1.1 rmind void * e_next;
55 1.1 rmind } element_t;
56 1.1 rmind
57 1.1 rmind #define VAR_SINGLE 1
58 1.1 rmind #define VAR_ARRAY 2
59 1.1 rmind #define VAR_TABLE 3
60 1.1 rmind
61 1.1 rmind typedef struct {
62 1.1 rmind char * v_key;
63 1.1 rmind element_t * v_elements;
64 1.1 rmind int v_type;
65 1.1 rmind int v_count;
66 1.1 rmind void * v_next;
67 1.1 rmind } var_t;
68 1.1 rmind
69 1.6 rmind extern nl_config_t * npf_conf;
70 1.6 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.1 rmind
77 1.5 rmind struct ifaddrs *npfctl_getif(char *, unsigned int *, bool);
78 1.1 rmind bool npfctl_parse_v4mask(char *, in_addr_t *, in_addr_t *);
79 1.6 rmind void npfctl_parse_cidr(char *, in_addr_t *, in_addr_t *);
80 1.6 rmind bool npfctl_parse_port(char *, bool *, in_port_t *, in_port_t *);
81 1.1 rmind
82 1.6 rmind void npfctl_fill_table(nl_table_t *, char *);
83 1.6 rmind
84 1.6 rmind void npfctl_rule_ncode(nl_rule_t *, char *, char *,
85 1.2 rmind int, int, var_t *, var_t *, var_t *, var_t *);
86 1.1 rmind
87 1.1 rmind size_t npfctl_calc_ncsize(int []);
88 1.1 rmind size_t npfctl_failure_offset(int []);
89 1.1 rmind
90 1.1 rmind void npfctl_gennc_ether(void **, int, uint16_t);
91 1.1 rmind void npfctl_gennc_v4cidr(void **, int,
92 1.1 rmind in_addr_t, in_addr_t, bool);
93 1.1 rmind void npfctl_gennc_icmp(void **, int, int, int);
94 1.2 rmind void npfctl_gennc_tcpfl(void **, int , uint8_t, uint8_t);
95 1.1 rmind void npfctl_gennc_ports(void **, int,
96 1.1 rmind in_port_t, in_port_t, bool, bool);
97 1.1 rmind void npfctl_gennc_tbl(void **, int, u_int , bool);
98 1.1 rmind void npfctl_gennc_complete(void **);
99 1.1 rmind
100 1.1 rmind int npf_parseline(char *);
101 1.1 rmind
102 1.1 rmind #endif
103