OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [sys/] [linux/] [include/] [netinet6/] [ip6_fw.h] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/*      $FreeBSD: src/sys/netinet6/ip6_fw.h,v 1.12 2002/04/19 04:46:22 suz Exp $        */
2
/*      $KAME: ip6_fw.h,v 1.9 2001/08/01 04:29:57 sumikawa Exp $        */
3
 
4
/*
5
 * Copyright (C) 1998, 1999, 2000 and 2001 WIDE Project.
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
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice, this list of conditions and the following disclaimer.
13
 * 2. Redistributions in binary form must reproduce the above copyright
14
 *    notice, this list of conditions and the following disclaimer in the
15
 *    documentation and/or other materials provided with the distribution.
16
 * 3. Neither the name of the project nor the names of its contributors
17
 *    may be used to endorse or promote products derived from this software
18
 *    without specific prior written permission.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30
 * SUCH DAMAGE.
31
 */
32
 
33
/*
34
 * Copyright (c) 1993 Daniel Boulet
35
 * Copyright (c) 1994 Ugen J.S.Antsilevich
36
 *
37
 * Redistribution and use in source forms, with and without modification,
38
 * are permitted provided that this entire comment appears intact.
39
 *
40
 * Redistribution in binary form may occur without any restrictions.
41
 * Obviously, it would be nice if you gave credit where credit is due
42
 * but requiring it would be too onerous.
43
 *
44
 * This software is provided ``AS IS'' without any warranties of any kind.
45
 *
46
 */
47
 
48
#ifndef _IP6_FW_H
49
#define _IP6_FW_H
50
 
51
#include <net/if.h>
52
 
53
/*
54
 * This union structure identifies an interface, either explicitly
55
 * by name or implicitly by IP address. The flags IP_FW_F_IIFNAME
56
 * and IP_FW_F_OIFNAME say how to interpret this structure. An
57
 * interface unit number of -1 matches any unit number, while an
58
 * IP address of 0.0.0.0 indicates matches any interface.
59
 *
60
 * The receive and transmit interfaces are only compared against the
61
 * the packet if the corresponding bit (IP_FW_F_IIFACE or IP_FW_F_OIFACE)
62
 * is set. Note some packets lack a receive or transmit interface
63
 * (in which case the missing "interface" never matches).
64
 */
65
 
66
union ip6_fw_if {
67
    struct in6_addr fu_via_ip6; /* Specified by IPv6 address */
68
    struct {                    /* Specified by interface name */
69
#define IP6FW_IFNLEN     IFNAMSIZ
70
            char  name[IP6FW_IFNLEN];
71
            short unit;         /* -1 means match any unit */
72
    } fu_via_if;
73
};
74
 
75
/*
76
 * Format of an IP firewall descriptor
77
 *
78
 * fw_src, fw_dst, fw_smsk, fw_dmsk are always stored in network byte order.
79
 * fw_flg and fw_n*p are stored in host byte order (of course).
80
 * Port numbers are stored in HOST byte order.
81
 * Warning: setsockopt() will fail if sizeof(struct ip_fw) > MLEN (108)
82
 */
83
 
84
struct ip6_fw {
85
    u_long fw_pcnt,fw_bcnt;             /* Packet and byte counters */
86
    struct in6_addr fw_src, fw_dst;     /* Source and destination IPv6 addr */
87
    struct in6_addr fw_smsk, fw_dmsk;   /* Mask for src and dest IPv6 addr */
88
    u_short fw_number;                  /* Rule number */
89
    u_short fw_flg;                     /* Flags word */
90
#define IPV6_FW_MAX_PORTS       10      /* A reasonable maximum */
91
    u_int fw_ipflg;                     /* IP flags word */
92
    u_short fw_pts[IPV6_FW_MAX_PORTS];  /* Array of port numbers to match */
93
    u_char fw_ip6opt,fw_ip6nopt;        /* IPv6 options set/unset */
94
    u_char fw_tcpf,fw_tcpnf;            /* TCP flags set/unset */
95
#define IPV6_FW_ICMPTYPES_DIM (256 / (sizeof(unsigned) * 8))
96
    unsigned fw_icmp6types[IPV6_FW_ICMPTYPES_DIM]; /* ICMP types bitmap */
97
    long timestamp;                     /* timestamp (tv_sec) of last match */
98
    union ip6_fw_if fw_in_if, fw_out_if;/* Incoming and outgoing interfaces */
99
    union {
100
        u_short fu_divert_port;         /* Divert/tee port (options IP6DIVERT) */
101
        u_short fu_skipto_rule;         /* SKIPTO command rule number */
102
        u_short fu_reject_code;         /* REJECT response code */
103
    } fw_un;
104
    u_char fw_prot;                     /* IPv6 protocol */
105
    u_char fw_nports;                   /* N'of src ports and # of dst ports */
106
                                        /* in ports array (dst ports follow */
107
                                        /* src ports; max of 10 ports in all; */
108
                                        /* count of 0 means match all ports) */
109
};
110
 
111
#define IPV6_FW_GETNSRCP(rule)          ((rule)->fw_nports & 0x0f)
112
#define IPV6_FW_SETNSRCP(rule, n)               do {                            \
113
                                          (rule)->fw_nports &= ~0x0f;   \
114
                                          (rule)->fw_nports |= (n);     \
115
                                        } while (0)
116
#define IPV6_FW_GETNDSTP(rule)          ((rule)->fw_nports >> 4)
117
#define IPV6_FW_SETNDSTP(rule, n)               do {                            \
118
                                          (rule)->fw_nports &= ~0xf0;   \
119
                                          (rule)->fw_nports |= (n) << 4;\
120
                                        } while (0)
121
 
122
#define fw_divert_port  fw_un.fu_divert_port
123
#define fw_skipto_rule  fw_un.fu_skipto_rule
124
#define fw_reject_code  fw_un.fu_reject_code
125
 
126
struct ip6_fw_chain {
127
        LIST_ENTRY(ip6_fw_chain) chain;
128
        struct ip6_fw    *rule;
129
};
130
 
131
/*
132
 * Values for "flags" field .
133
 */
134
#define IPV6_FW_F_IN    0x0001  /* Check inbound packets                */
135
#define IPV6_FW_F_OUT   0x0002  /* Check outbound packets               */
136
#define IPV6_FW_F_IIFACE        0x0004  /* Apply inbound interface test         */
137
#define IPV6_FW_F_OIFACE        0x0008  /* Apply outbound interface test        */
138
 
139
#define IPV6_FW_F_COMMAND 0x0070        /* Mask for type of chain entry:        */
140
#define IPV6_FW_F_DENY  0x0000  /* This is a deny rule                  */
141
#define IPV6_FW_F_REJECT        0x0010  /* Deny and send a response packet      */
142
#define IPV6_FW_F_ACCEPT        0x0020  /* This is an accept rule               */
143
#define IPV6_FW_F_COUNT 0x0030  /* This is a count rule                 */
144
#define IPV6_FW_F_DIVERT        0x0040  /* This is a divert rule                */
145
#define IPV6_FW_F_TEE   0x0050  /* This is a tee rule                   */
146
#define IPV6_FW_F_SKIPTO        0x0060  /* This is a skipto rule                */
147
 
148
#define IPV6_FW_F_PRN   0x0080  /* Print if this rule matches           */
149
 
150
#define IPV6_FW_F_SRNG  0x0100  /* The first two src ports are a min    *
151
                                 * and max range (stored in host byte   *
152
                                 * order).                              */
153
 
154
#define IPV6_FW_F_DRNG  0x0200  /* The first two dst ports are a min    *
155
                                 * and max range (stored in host byte   *
156
                                 * order).                              */
157
 
158
#define IPV6_FW_F_IIFNAME       0x0400  /* In interface by name/unit (not IP)   */
159
#define IPV6_FW_F_OIFNAME       0x0800  /* Out interface by name/unit (not IP)  */
160
 
161
#define IPV6_FW_F_INVSRC        0x1000  /* Invert sense of src check            */
162
#define IPV6_FW_F_INVDST        0x2000  /* Invert sense of dst check            */
163
 
164
#define IPV6_FW_F_FRAG  0x4000  /* Fragment                             */
165
 
166
#define IPV6_FW_F_ICMPBIT 0x8000        /* ICMP type bitmap is valid            */
167
 
168
#define IPV6_FW_F_MASK  0xFFFF  /* All possible flag bits mask          */
169
 
170
/*
171
 * Flags for the 'fw_ipflg' field, for comparing values of ip and its protocols. */
172
#define IPV6_FW_IF_TCPEST 0x00000020    /* established TCP connection   */
173
#define IPV6_FW_IF_TCPMSK 0x00000020    /* mask of all TCP values */
174
 
175
/*
176
 * For backwards compatibility with rules specifying "via iface" but
177
 * not restricted to only "in" or "out" packets, we define this combination
178
 * of bits to represent this configuration.
179
 */
180
 
181
#define IF6_FW_F_VIAHACK        (IPV6_FW_F_IN|IPV6_FW_F_OUT|IPV6_FW_F_IIFACE|IPV6_FW_F_OIFACE)
182
 
183
/*
184
 * Definitions for REJECT response codes.
185
 * Values less than 256 correspond to ICMP unreachable codes.
186
 */
187
#define IPV6_FW_REJECT_RST      0x0100          /* TCP packets: send RST */
188
 
189
/*
190
 * Definitions for IPv6 option names.
191
 */
192
#define IPV6_FW_IP6OPT_HOPOPT   0x01
193
#define IPV6_FW_IP6OPT_ROUTE    0x02
194
#define IPV6_FW_IP6OPT_FRAG     0x04
195
#define IPV6_FW_IP6OPT_ESP      0x08
196
#define IPV6_FW_IP6OPT_AH       0x10
197
#define IPV6_FW_IP6OPT_NONXT    0x20
198
#define IPV6_FW_IP6OPT_OPTS     0x40
199
 
200
/*
201
 * Definitions for TCP flags.
202
 */
203
#define IPV6_FW_TCPF_FIN        TH_FIN
204
#define IPV6_FW_TCPF_SYN        TH_SYN
205
#define IPV6_FW_TCPF_RST        TH_RST
206
#define IPV6_FW_TCPF_PSH        TH_PUSH
207
#define IPV6_FW_TCPF_ACK        TH_ACK
208
#define IPV6_FW_TCPF_URG        TH_URG
209
 
210
/*
211
 * Main firewall chains definitions and global var's definitions.
212
 */
213
#ifdef _KERNEL
214
 
215
/*
216
 * Function definitions.
217
 */
218
void ip6_fw_init(void);
219
 
220
/* Firewall hooks */
221
struct ip6_hdr;
222
typedef int ip6_fw_chk_t __P((struct ip6_hdr**, struct ifnet*,
223
                                u_short *, struct mbuf**));
224
typedef int ip6_fw_ctl_t __P((int, struct mbuf**));
225
extern  ip6_fw_chk_t *ip6_fw_chk_ptr;
226
extern  ip6_fw_ctl_t *ip6_fw_ctl_ptr;
227
extern  int ip6_fw_enable;
228
 
229
#endif /* _KERNEL */
230
 
231
#endif /* _IP6_FW_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.