AMD64 - Move fdisk and nextboot up one level and remove src/sbin/i386.
[dragonfly.git] / sys / net / gre / if_gre.h
blobb67480b359972251eda0e97bcb9adcd5485d3595
1 /* $NetBSD: if_gre.h,v 1.10 2002/02/24 17:22:20 martin Exp $ */
2 /* $FreeBSD: src/sys/net/if_gre.h,v 1.6.2.2 2002/12/03 01:17:52 peter Exp $ */
3 /* $DragonFly: src/sys/net/gre/if_gre.h,v 1.2 2003/06/17 04:28:48 dillon Exp $ */
5 /*
6 * Copyright (c) 1998 The NetBSD Foundation, Inc.
7 * All rights reserved
9 * This code is derived from software contributed to The NetBSD Foundation
10 * by Heiko W.Rupp <hwr@pilhuhn.de>
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
22 * This product includes software developed by the NetBSD
23 * Foundation, Inc. and its contributors.
24 * 4. Neither the name of The NetBSD Foundation nor the names of its
25 * contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
29 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
32 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
41 #ifndef _NET_IF_GRE_H
42 #define _NET_IF_GRE_H
44 #include <sys/ioccom.h>
45 #ifdef _KERNEL
46 #include <sys/queue.h>
48 struct gre_softc {
49 struct ifnet sc_if;
50 LIST_ENTRY(gre_softc) sc_list;
51 int gre_unit;
52 int gre_flags;
53 struct in_addr g_src; /* source address of gre packets */
54 struct in_addr g_dst; /* destination address of gre packets */
55 struct route route; /* routing entry that determines, where a
56 encapsulated packet should go */
57 u_char g_proto; /* protocol of encapsulator */
59 const struct encaptab *encap; /* encapsulation cookie */
61 int called; /* infinite recursion preventer */
63 struct resource *r_unit;/* resource allocated for this unit */
64 };
67 struct gre_h {
68 u_int16_t flags; /* GRE flags */
69 u_int16_t ptype; /* protocol type of payload typically
70 Ether protocol type*/
71 /*
72 * from here on: fields are optional, presence indicated by flags
74 u_int_16 checksum checksum (one-complements of GRE header
75 and payload
76 Present if (ck_pres | rt_pres == 1).
77 Valid if (ck_pres == 1).
78 u_int_16 offset offset from start of routing filed to
79 first octet of active SRE (see below).
80 Present if (ck_pres | rt_pres == 1).
81 Valid if (rt_pres == 1).
82 u_int_32 key inserted by encapsulator e.g. for
83 authentication
84 Present if (key_pres ==1 ).
85 u_int_32 seq_num Sequence number to allow for packet order
86 Present if (seq_pres ==1 ).
87 struct gre_sre[] routing Routing fileds (see below)
88 Present if (rt_pres == 1)
90 } __attribute__((__packed__));
92 struct greip {
93 struct ip gi_i;
94 struct gre_h gi_g;
95 } __attribute__((__packed__));
97 #define gi_pr gi_i.ip_p
98 #define gi_len gi_i.ip_len
99 #define gi_src gi_i.ip_src
100 #define gi_dst gi_i.ip_dst
101 #define gi_ptype gi_g.ptype
102 #define gi_flags gi_g.flags
104 #define GRE_CP 0x8000 /* Checksum Present */
105 #define GRE_RP 0x4000 /* Routing Present */
106 #define GRE_KP 0x2000 /* Key Present */
107 #define GRE_SP 0x1000 /* Sequence Present */
108 #define GRE_SS 0x0800 /* Strict Source Route */
111 * CISCO uses special type for GRE tunnel created as part of WCCP
112 * connection, while in fact those packets are just IPv4 encapsulated
113 * into GRE.
115 #define WCCP_PROTOCOL_TYPE 0x883E
118 * gre_sre defines a Source route Entry. These are needed if packets
119 * should be routed over more than one tunnel hop by hop
121 struct gre_sre {
122 u_int16_t sre_family; /* adress family */
123 u_char sre_offset; /* offset to first octet of active entry */
124 u_char sre_length; /* number of octets in the SRE.
125 sre_lengthl==0 -> last entry. */
126 u_char *sre_rtinfo; /* the routing information */
129 struct greioctl {
130 int unit;
131 struct in_addr addr;
134 /* for mobile encaps */
136 struct mobile_h {
137 u_int16_t proto; /* protocol and S-bit */
138 u_int16_t hcrc; /* header checksum */
139 u_int32_t odst; /* original destination address */
140 u_int32_t osrc; /* original source addr, if S-bit set */
141 } __attribute__((__packed__));
143 struct mobip_h {
144 struct ip mi;
145 struct mobile_h mh;
146 } __attribute__((__packed__));
149 #define MOB_H_SIZ_S (sizeof(struct mobile_h) - sizeof(u_int32_t))
150 #define MOB_H_SIZ_L (sizeof(struct mobile_h))
151 #define MOB_H_SBIT 0x0080
153 #define GRE_TTL 30
155 #endif /* _KERNEL */
158 * ioctls needed to manipulate the interface
161 #define GRESADDRS _IOW('i', 101, struct ifreq)
162 #define GRESADDRD _IOW('i', 102, struct ifreq)
163 #define GREGADDRS _IOWR('i', 103, struct ifreq)
164 #define GREGADDRD _IOWR('i', 104, struct ifreq)
165 #define GRESPROTO _IOW('i' , 105, struct ifreq)
166 #define GREGPROTO _IOWR('i', 106, struct ifreq)
168 #ifdef _KERNEL
169 LIST_HEAD(gre_softc_head, gre_softc);
170 extern struct gre_softc_head gre_softc_list;
172 u_short gre_in_cksum(u_short *p, u_int len);
173 #endif /* _KERNEL */
175 #endif