if_gre.h revision 1.2 1 1.2 hwr /* $NetBSD: if_gre.h,v 1.2 1998/09/30 05:59:28 hwr Exp $ */
2 1.1 hwr
3 1.1 hwr /*
4 1.1 hwr * (c) 1998 The NetBSD Foundation, Inc.
5 1.1 hwr * All rights reserved
6 1.1 hwr *
7 1.1 hwr * This code is derived from software contributed to The NetBSD Foundation
8 1.1 hwr * by Heiko W.Rupp <hwr (at) pilhuhn.de>
9 1.1 hwr *
10 1.1 hwr * Redistribution and use in source and binary forms, with or without
11 1.1 hwr * modification, are permitted provided that the following conditions
12 1.1 hwr * are met:
13 1.1 hwr * 1. Redistributions of source code must retain the above copyright
14 1.1 hwr * notice, this list of conditions and the following disclaimer.
15 1.1 hwr * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 hwr * notice, this list of conditions and the following disclaimer in the
17 1.1 hwr * documentation and/or other materials provided with the distribution.
18 1.1 hwr * 3. All advertising materials mentioning features or use of this software
19 1.1 hwr * must display the following acknowledgement:
20 1.1 hwr * This product includes software developed by the NetBSD
21 1.1 hwr * Foundation, Inc. and its contributors.
22 1.1 hwr * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 hwr * contributors may be used to endorse or promote products derived
24 1.1 hwr * from this software without specific prior written permission.
25 1.1 hwr *
26 1.1 hwr * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 hwr * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 hwr * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 hwr * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 hwr * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 hwr * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 hwr * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 hwr * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 hwr * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 hwr * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 hwr * POSSIBILITY OF SUCH DAMAGE.
37 1.1 hwr */
38 1.1 hwr
39 1.1 hwr #ifndef _NET_IF_GRE_H
40 1.1 hwr #define _NET_IF_GRE_H
41 1.1 hwr
42 1.1 hwr struct gre_softc {
43 1.1 hwr struct ifnet sc_if;
44 1.1 hwr int gre_unit;
45 1.1 hwr int gre_flags;
46 1.1 hwr struct in_addr g_src; /* source address of gre packets */
47 1.1 hwr struct in_addr g_dst; /* destination address of gre packets */
48 1.1 hwr caddr_t gre_bpf;
49 1.1 hwr struct route route; /* routing entry that determines, where a
50 1.1 hwr encapsulated packet should go */
51 1.1 hwr u_char g_proto; /* protocol of encapsulator */
52 1.1 hwr };
53 1.1 hwr
54 1.1 hwr
55 1.1 hwr struct gre_h {
56 1.1 hwr u_int16_t flags; /* GRE flags */
57 1.1 hwr u_int16_t ptype; /* protocol type of payload typically
58 1.1 hwr Ether protocol type*/
59 1.1 hwr /*
60 1.1 hwr * from here on: fields are optional, presence indicated by flags
61 1.1 hwr *
62 1.1 hwr u_int_16 checksum checksum (one-complements of GRE header
63 1.1 hwr and payload
64 1.1 hwr Present if (ck_pres | rt_pres == 1).
65 1.1 hwr Valid if (ck_pres == 1).
66 1.1 hwr u_int_16 offset offset from start of routing filed to
67 1.1 hwr first octet of active SRE (see below).
68 1.1 hwr Present if (ck_pres | rt_pres == 1).
69 1.1 hwr Valid if (rt_pres == 1).
70 1.1 hwr u_int_32 key inserted by encapsulator e.g. for
71 1.1 hwr authentication
72 1.1 hwr Present if (key_pres ==1 ).
73 1.1 hwr u_int_32 seq_num Sequence number to allow for packet order
74 1.1 hwr Present if (seq_pres ==1 ).
75 1.1 hwr
76 1.1 hwr struct gre_sre[] routing Routing fileds (see below)
77 1.1 hwr Present if (rt_pres == 1)
78 1.1 hwr */
79 1.1 hwr };
80 1.1 hwr
81 1.1 hwr struct greip {
82 1.1 hwr struct ip gi_i;
83 1.1 hwr struct gre_h gi_g;
84 1.1 hwr };
85 1.1 hwr
86 1.1 hwr #define gi_pr gi_i.ip_p
87 1.1 hwr #define gi_len gi_i.ip_len
88 1.1 hwr #define gi_src gi_i.ip_src
89 1.1 hwr #define gi_dst gi_i.ip_dst
90 1.1 hwr #define gi_ptype gi_g.ptype
91 1.1 hwr #define gi_flags gi_g.flags
92 1.1 hwr
93 1.1 hwr #define GRE_CP 0x8000 /* Checksum Present */
94 1.1 hwr #define GRE_RP 0x4000 /* Routing Present */
95 1.1 hwr #define GRE_KP 0x2000 /* Key Present */
96 1.1 hwr #define GRE_SP 0x1000 /* Sequence Present */
97 1.1 hwr #define GRE_SS 0x0800 /* Strict Source Route */
98 1.1 hwr
99 1.1 hwr /* gre_sre defines a Source route Entry. These are needed if packets
100 1.1 hwr * should be routed over more than one tunnel hop by hop
101 1.1 hwr */
102 1.1 hwr
103 1.1 hwr struct gre_sre {
104 1.1 hwr u_int16_t sre_family; /* adress family */
105 1.1 hwr u_char sre_offset; /* offset to first octet of active entry */
106 1.1 hwr u_char sre_length; /* number of octets in the SRE.
107 1.1 hwr sre_lengthl==0 -> last entry. */
108 1.1 hwr u_char *sre_rtinfo; /* the routing information */
109 1.1 hwr };
110 1.1 hwr
111 1.1 hwr
112 1.1 hwr void greattach __P((void));
113 1.1 hwr int gre_ioctl __P((struct ifnet *, u_long, caddr_t));
114 1.1 hwr int gre_output __P((struct ifnet *, struct mbuf *, struct sockaddr *,
115 1.1 hwr struct rtentry *rt));
116 1.1 hwr
117 1.1 hwr struct greioctl {
118 1.1 hwr int unit;
119 1.1 hwr struct in_addr addr;
120 1.1 hwr };
121 1.1 hwr
122 1.2 hwr /* for mobile encaps */
123 1.2 hwr
124 1.2 hwr struct mobile_h {
125 1.2 hwr u_int16_t proto; /* protocol and S-bit */
126 1.2 hwr u_int16_t hcrc; /* header checksum */
127 1.2 hwr u_int32_t odst; /* original destination address */
128 1.2 hwr u_int32_t osrc; /* original source addr, if S-bit set */
129 1.2 hwr };
130 1.2 hwr
131 1.2 hwr struct mobip_h {
132 1.2 hwr struct ip mi;
133 1.2 hwr struct mobile_h mh;
134 1.2 hwr };
135 1.2 hwr
136 1.2 hwr
137 1.2 hwr #define MOB_H_SIZ_S (sizeof(struct mobile_h) - sizeof(u_int32_t))
138 1.2 hwr #define MOB_H_SIZ_L (sizeof(struct mobile_h))
139 1.2 hwr #define MOB_H_SBIT 0x0080
140 1.2 hwr
141 1.2 hwr
142 1.2 hwr /*
143 1.2 hwr * ioctls needed to manipulate the interface
144 1.2 hwr */
145 1.2 hwr
146 1.1 hwr #define GRESADDRS _IOW('i', 101, struct ifreq)
147 1.1 hwr #define GRESADDRD _IOW('i', 102, struct ifreq)
148 1.1 hwr #define GREGADDRS _IOWR('i', 103, struct ifreq)
149 1.1 hwr #define GREGADDRD _IOWR('i', 104, struct ifreq)
150 1.1 hwr #define GRESPROTO _IOW('i' , 105, struct ifreq)
151 1.1 hwr #define GREGPROTO _IOWR('i', 106, struct ifreq)
152 1.2 hwr
153 1.2 hwr /*
154 1.2 hwr * do a checksum of a buffer - much like in_cksum, which operates on
155 1.2 hwr * mbufs.
156 1.2 hwr */
157 1.2 hwr
158 1.2 hwr u_short gre_in_cksum(u_short *p, u_int len);
159 1.1 hwr
160 1.1 hwr #endif
161