Deleted Added
full compact
if_gre.h (204522) if_gre.h (223223)
1/* $NetBSD: if_gre.h,v 1.13 2003/11/10 08:51:52 wiz Exp $ */
1/* $NetBSD: if_gre.h,v 1.13 2003/11/10 08:51:52 wiz Exp $ */
2/* $FreeBSD: head/sys/net/if_gre.h 204522 2010-03-01 17:05:46Z joel $ */
2/* $FreeBSD: head/sys/net/if_gre.h 223223 2011-06-18 09:34:03Z bz $ */
3
4/*-
5 * Copyright (c) 1998 The NetBSD Foundation, Inc.
6 * All rights reserved
7 *
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Heiko W.Rupp <hwr@pilhuhn.de>
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#ifndef _NET_IF_GRE_H
34#define _NET_IF_GRE_H
35
36#include <sys/ioccom.h>
37#ifdef _KERNEL
38#include <sys/queue.h>
39
40/*
41 * Version of the WCCP, need to be configured manually since
42 * header for version 2 is the same but IP payload is prepended
43 * with additional 4-bytes field.
44 */
45typedef enum {
46 WCCP_V1 = 0,
47 WCCP_V2
48} wccp_ver_t;
49
50struct gre_softc {
51 struct ifnet *sc_ifp;
52 LIST_ENTRY(gre_softc) sc_list;
53 int gre_unit;
54 int gre_flags;
55 u_int gre_fibnum; /* use this fib for envelopes */
56 struct in_addr g_src; /* source address of gre packets */
57 struct in_addr g_dst; /* destination address of gre packets */
58 struct route route; /* routing entry that determines, where a
59 encapsulated packet should go */
60 u_char g_proto; /* protocol of encapsulator */
61
62 const struct encaptab *encap; /* encapsulation cookie */
63
3
4/*-
5 * Copyright (c) 1998 The NetBSD Foundation, Inc.
6 * All rights reserved
7 *
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Heiko W.Rupp <hwr@pilhuhn.de>
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#ifndef _NET_IF_GRE_H
34#define _NET_IF_GRE_H
35
36#include <sys/ioccom.h>
37#ifdef _KERNEL
38#include <sys/queue.h>
39
40/*
41 * Version of the WCCP, need to be configured manually since
42 * header for version 2 is the same but IP payload is prepended
43 * with additional 4-bytes field.
44 */
45typedef enum {
46 WCCP_V1 = 0,
47 WCCP_V2
48} wccp_ver_t;
49
50struct gre_softc {
51 struct ifnet *sc_ifp;
52 LIST_ENTRY(gre_softc) sc_list;
53 int gre_unit;
54 int gre_flags;
55 u_int gre_fibnum; /* use this fib for envelopes */
56 struct in_addr g_src; /* source address of gre packets */
57 struct in_addr g_dst; /* destination address of gre packets */
58 struct route route; /* routing entry that determines, where a
59 encapsulated packet should go */
60 u_char g_proto; /* protocol of encapsulator */
61
62 const struct encaptab *encap; /* encapsulation cookie */
63
64 int called; /* infinite recursion preventer */
65
66 uint32_t key; /* key included in outgoing GRE packets */
67 /* zero means none */
68
69 wccp_ver_t wccp_ver; /* version of the WCCP */
70};
71#define GRE2IFP(sc) ((sc)->sc_ifp)
72
73
74struct gre_h {
75 u_int16_t flags; /* GRE flags */
76 u_int16_t ptype; /* protocol type of payload typically
77 Ether protocol type*/
78 uint32_t options[0]; /* optional options */
79/*
80 * from here on: fields are optional, presence indicated by flags
81 *
82 u_int_16 checksum checksum (one-complements of GRE header
83 and payload
84 Present if (ck_pres | rt_pres == 1).
85 Valid if (ck_pres == 1).
86 u_int_16 offset offset from start of routing filed to
87 first octet of active SRE (see below).
88 Present if (ck_pres | rt_pres == 1).
89 Valid if (rt_pres == 1).
90 u_int_32 key inserted by encapsulator e.g. for
91 authentication
92 Present if (key_pres ==1 ).
93 u_int_32 seq_num Sequence number to allow for packet order
94 Present if (seq_pres ==1 ).
95 struct gre_sre[] routing Routing fileds (see below)
96 Present if (rt_pres == 1)
97 */
98} __packed;
99
100struct greip {
101 struct ip gi_i;
102 struct gre_h gi_g;
103} __packed;
104
105#define gi_pr gi_i.ip_p
106#define gi_len gi_i.ip_len
107#define gi_src gi_i.ip_src
108#define gi_dst gi_i.ip_dst
109#define gi_ptype gi_g.ptype
110#define gi_flags gi_g.flags
111#define gi_options gi_g.options
112
113#define GRE_CP 0x8000 /* Checksum Present */
114#define GRE_RP 0x4000 /* Routing Present */
115#define GRE_KP 0x2000 /* Key Present */
116#define GRE_SP 0x1000 /* Sequence Present */
117#define GRE_SS 0x0800 /* Strict Source Route */
118
119/*
120 * CISCO uses special type for GRE tunnel created as part of WCCP
121 * connection, while in fact those packets are just IPv4 encapsulated
122 * into GRE.
123 */
124#define WCCP_PROTOCOL_TYPE 0x883E
125
126/*
127 * gre_sre defines a Source route Entry. These are needed if packets
128 * should be routed over more than one tunnel hop by hop
129 */
130struct gre_sre {
131 u_int16_t sre_family; /* address family */
132 u_char sre_offset; /* offset to first octet of active entry */
133 u_char sre_length; /* number of octets in the SRE.
134 sre_lengthl==0 -> last entry. */
135 u_char *sre_rtinfo; /* the routing information */
136};
137
138struct greioctl {
139 int unit;
140 struct in_addr addr;
141};
142
143/* for mobile encaps */
144
145struct mobile_h {
146 u_int16_t proto; /* protocol and S-bit */
147 u_int16_t hcrc; /* header checksum */
148 u_int32_t odst; /* original destination address */
149 u_int32_t osrc; /* original source addr, if S-bit set */
150} __packed;
151
152struct mobip_h {
153 struct ip mi;
154 struct mobile_h mh;
155} __packed;
156
157
158#define MOB_H_SIZ_S (sizeof(struct mobile_h) - sizeof(u_int32_t))
159#define MOB_H_SIZ_L (sizeof(struct mobile_h))
160#define MOB_H_SBIT 0x0080
161
162#define GRE_TTL 30
163
164#endif /* _KERNEL */
165
166/*
167 * ioctls needed to manipulate the interface
168 */
169
170#define GRESADDRS _IOW('i', 101, struct ifreq)
171#define GRESADDRD _IOW('i', 102, struct ifreq)
172#define GREGADDRS _IOWR('i', 103, struct ifreq)
173#define GREGADDRD _IOWR('i', 104, struct ifreq)
174#define GRESPROTO _IOW('i' , 105, struct ifreq)
175#define GREGPROTO _IOWR('i', 106, struct ifreq)
176#define GREGKEY _IOWR('i', 107, struct ifreq)
177#define GRESKEY _IOW('i', 108, struct ifreq)
178
179#ifdef _KERNEL
180LIST_HEAD(gre_softc_head, gre_softc);
181extern struct mtx gre_mtx;
182extern struct gre_softc_head gre_softc_list;
183
184u_int16_t gre_in_cksum(u_int16_t *, u_int);
185#endif /* _KERNEL */
186
187#endif
64 uint32_t key; /* key included in outgoing GRE packets */
65 /* zero means none */
66
67 wccp_ver_t wccp_ver; /* version of the WCCP */
68};
69#define GRE2IFP(sc) ((sc)->sc_ifp)
70
71
72struct gre_h {
73 u_int16_t flags; /* GRE flags */
74 u_int16_t ptype; /* protocol type of payload typically
75 Ether protocol type*/
76 uint32_t options[0]; /* optional options */
77/*
78 * from here on: fields are optional, presence indicated by flags
79 *
80 u_int_16 checksum checksum (one-complements of GRE header
81 and payload
82 Present if (ck_pres | rt_pres == 1).
83 Valid if (ck_pres == 1).
84 u_int_16 offset offset from start of routing filed to
85 first octet of active SRE (see below).
86 Present if (ck_pres | rt_pres == 1).
87 Valid if (rt_pres == 1).
88 u_int_32 key inserted by encapsulator e.g. for
89 authentication
90 Present if (key_pres ==1 ).
91 u_int_32 seq_num Sequence number to allow for packet order
92 Present if (seq_pres ==1 ).
93 struct gre_sre[] routing Routing fileds (see below)
94 Present if (rt_pres == 1)
95 */
96} __packed;
97
98struct greip {
99 struct ip gi_i;
100 struct gre_h gi_g;
101} __packed;
102
103#define gi_pr gi_i.ip_p
104#define gi_len gi_i.ip_len
105#define gi_src gi_i.ip_src
106#define gi_dst gi_i.ip_dst
107#define gi_ptype gi_g.ptype
108#define gi_flags gi_g.flags
109#define gi_options gi_g.options
110
111#define GRE_CP 0x8000 /* Checksum Present */
112#define GRE_RP 0x4000 /* Routing Present */
113#define GRE_KP 0x2000 /* Key Present */
114#define GRE_SP 0x1000 /* Sequence Present */
115#define GRE_SS 0x0800 /* Strict Source Route */
116
117/*
118 * CISCO uses special type for GRE tunnel created as part of WCCP
119 * connection, while in fact those packets are just IPv4 encapsulated
120 * into GRE.
121 */
122#define WCCP_PROTOCOL_TYPE 0x883E
123
124/*
125 * gre_sre defines a Source route Entry. These are needed if packets
126 * should be routed over more than one tunnel hop by hop
127 */
128struct gre_sre {
129 u_int16_t sre_family; /* address family */
130 u_char sre_offset; /* offset to first octet of active entry */
131 u_char sre_length; /* number of octets in the SRE.
132 sre_lengthl==0 -> last entry. */
133 u_char *sre_rtinfo; /* the routing information */
134};
135
136struct greioctl {
137 int unit;
138 struct in_addr addr;
139};
140
141/* for mobile encaps */
142
143struct mobile_h {
144 u_int16_t proto; /* protocol and S-bit */
145 u_int16_t hcrc; /* header checksum */
146 u_int32_t odst; /* original destination address */
147 u_int32_t osrc; /* original source addr, if S-bit set */
148} __packed;
149
150struct mobip_h {
151 struct ip mi;
152 struct mobile_h mh;
153} __packed;
154
155
156#define MOB_H_SIZ_S (sizeof(struct mobile_h) - sizeof(u_int32_t))
157#define MOB_H_SIZ_L (sizeof(struct mobile_h))
158#define MOB_H_SBIT 0x0080
159
160#define GRE_TTL 30
161
162#endif /* _KERNEL */
163
164/*
165 * ioctls needed to manipulate the interface
166 */
167
168#define GRESADDRS _IOW('i', 101, struct ifreq)
169#define GRESADDRD _IOW('i', 102, struct ifreq)
170#define GREGADDRS _IOWR('i', 103, struct ifreq)
171#define GREGADDRD _IOWR('i', 104, struct ifreq)
172#define GRESPROTO _IOW('i' , 105, struct ifreq)
173#define GREGPROTO _IOWR('i', 106, struct ifreq)
174#define GREGKEY _IOWR('i', 107, struct ifreq)
175#define GRESKEY _IOW('i', 108, struct ifreq)
176
177#ifdef _KERNEL
178LIST_HEAD(gre_softc_head, gre_softc);
179extern struct mtx gre_mtx;
180extern struct gre_softc_head gre_softc_list;
181
182u_int16_t gre_in_cksum(u_int16_t *, u_int);
183#endif /* _KERNEL */
184
185#endif