FreeBSD/Linux Kernel Cross Reference
sys/net/if_gre.h
1 /* $OpenBSD: if_gre.h,v 1.16 2021/03/10 10:21:48 jsg Exp $ */
2 /* $NetBSD: if_gre.h,v 1.5 1999/11/19 20:41:19 thorpej Exp $ */
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 struct gre_h {
37 u_int16_t flags; /* GRE flags */
38 u_int16_t ptype; /* protocol type of payload typically
39 Ether protocol type*/
40 /*
41 * from here on: fields are optional, presence indicated by flags
42 *
43 u_int_16 checksum checksum (one-complements of GRE header
44 and payload
45 Present if (ck_pres | rt_pres == 1).
46 Valid if (ck_pres == 1).
47 u_int_16 offset offset from start of routing filed to
48 first octet of active SRE (see below).
49 Present if (ck_pres | rt_pres == 1).
50 Valid if (rt_pres == 1).
51 u_int_32 key inserted by encapsulator e.g. for
52 authentication
53 Present if (key_pres ==1 ).
54 u_int_32 seq_num Sequence number to allow for packet order
55 Present if (seq_pres ==1 ).
56
57 struct gre_sre[] routing Routing fields (see below)
58 Present if (rt_pres == 1)
59 */
60 } __packed;
61
62 struct greip {
63 struct ip gi_i;
64 struct gre_h gi_g;
65 } __packed;
66
67 #define gi_pr gi_i.ip_p
68 #define gi_len gi_i.ip_len
69 #define gi_src gi_i.ip_src
70 #define gi_dst gi_i.ip_dst
71 #define gi_ptype gi_g.ptype
72 #define gi_flags gi_g.flags
73
74 #define GRE_CP 0x8000 /* Checksum Present */
75 #define GRE_RP 0x4000 /* Routing Present */
76 #define GRE_KP 0x2000 /* Key Present */
77 #define GRE_SP 0x1000 /* Sequence Present */
78 #define GRE_SS 0x0800 /* Strict Source Route */
79
80 /* gre_sre defines a Source route Entry. These are needed if packets
81 * should be routed over more than one tunnel hop by hop
82 */
83
84 struct gre_sre {
85 u_int16_t sre_family; /* address family */
86 u_char sre_offset; /* offset to first octet of active entry */
87 u_char sre_length; /* number of octets in the SRE.
88 sre_lengthl==0 -> last entry. */
89 u_char *sre_rtinfo; /* the routing information */
90 };
91
92 struct greioctl {
93 int unit;
94 struct in_addr addr;
95 };
96
97 /* for mobile encaps */
98
99 struct mobile_h {
100 u_int16_t proto; /* protocol and S-bit */
101 u_int16_t hcrc; /* header checksum */
102 u_int32_t odst; /* original destination address */
103 u_int32_t osrc; /* original source addr, if S-bit set */
104 } __packed;
105
106 struct mobip_h {
107 struct ip mi;
108 struct mobile_h mh;
109 } __packed;
110
111
112 #define MOB_H_SIZ_S (sizeof(struct mobile_h) - sizeof(u_int32_t))
113 #define MOB_H_SIZ_L (sizeof(struct mobile_h))
114 #define MOB_H_SBIT 0x0080
115
116 #ifdef _KERNEL
117 int gre_sysctl(int *, u_int, void *, size_t *, void *, size_t);
118 int gre_input(struct mbuf **, int *, int, int);
119 int gre_input6(struct mbuf **, int *, int, int);
120 #endif
121 #endif /* _NET_IF_GRE_H_ */
Cache object: aa2f387bc376bf97a5fde929bb67987f
|