7f2465a5ee3c7d446f21826807f52d2655628d31
[openvswitch] / include / openvswitch / gre.h
1 /*
2  * Copyright (c) 2008, 2009 Nicira Networks.
3  *
4  * This file is offered under your choice of two licenses: Apache 2.0 or GNU
5  * GPL 2.0 or later.  The permission statements for each of these licenses is
6  * given below.  You may license your modifications to this file under either
7  * of these licenses or both.  If you wish to license your modifications under
8  * only one of these licenses, delete the permission text for the other
9  * license.
10  *
11  * ----------------------------------------------------------------------
12  * Licensed under the Apache License, Version 2.0 (the "License");
13  * you may not use this file except in compliance with the License.
14  * You may obtain a copy of the License at:
15  *
16  *     http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an "AS IS" BASIS,
20  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  * ----------------------------------------------------------------------
24  * This program is free software; you can redistribute it and/or modify
25  * it under the terms of the GNU General Public License as published by
26  * the Free Software Foundation; either version 2 of the License, or
27  * (at your option) any later version.
28  *
29  * This program is distributed in the hope that it will be useful,
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32  * GNU General Public License for more details.
33  *
34  * You should have received a copy of the GNU General Public License along
35  * with this program; if not, write to the Free Software Foundation, Inc.,
36  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
37  * ----------------------------------------------------------------------
38  */
39
40 #ifndef OPENVSWITCH_GRE_H
41 #define OPENVSWITCH_GRE_H 1
42
43 #include <linux/ip.h>
44 #include <linux/if_tunnel.h>
45 #include <linux/version.h>
46
47 #ifdef __KERNEL__
48 #include <linux/types.h>
49 #else
50 #include <sys/types.h>
51 #endif
52
53 /* New GRE config. */
54
55 #define GRE_F_IN_CSUM           (1 << 0) /* Require incoming packets to have checksums. */
56 #define GRE_F_OUT_CSUM          (1 << 1) /* Checksum outgoing packets. */
57 #define GRE_F_IN_KEY_MATCH      (1 << 2) /* Store the key in tun_id to match in flow table. */
58 #define GRE_F_OUT_KEY_ACTION    (1 << 3) /* Get the key from a SET_TUNNEL action. */
59 #define GRE_F_TOS_INHERIT       (1 << 4) /* Inherit the ToS from the inner packet. */
60 #define GRE_F_TTL_INHERIT       (1 << 5) /* Inherit the TTL from the inner packet. */
61 #define GRE_F_PMTUD             (1 << 6) /* Enable path MTU discovery. */
62
63 struct gre_port_config {
64         __u32   flags;
65         __be32  saddr;
66         __be32  daddr;
67         __be32  in_key;
68         __be32  out_key;
69         __u8    tos;
70         __u8    ttl;
71 };
72
73 /* Old GRE config. */
74
75 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
76 #define GRE_IOCTL_ONLY
77 #elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
78 enum
79 {
80         IFLA_GRE_UNSPEC,
81         IFLA_GRE_LINK,
82         IFLA_GRE_IFLAGS,
83         IFLA_GRE_OFLAGS,
84         IFLA_GRE_IKEY,
85         IFLA_GRE_OKEY,
86         IFLA_GRE_LOCAL,
87         IFLA_GRE_REMOTE,
88         IFLA_GRE_TTL,
89         IFLA_GRE_TOS,
90         IFLA_GRE_PMTUDISC,
91         __IFLA_GRE_MAX,
92 };
93
94 #define IFLA_GRE_MAX    (__IFLA_GRE_MAX - 1)
95 #endif
96
97 #define GRE_IOCTL_DEVICE "gre0"
98
99 #define SIOCGETGRETAP   SIOCGETTUNNEL
100 #define SIOCADDGRETAP   (SIOCDEVPRIVATE + 10)
101 #define SIOCDELGRETAP   SIOCDELTUNNEL
102 #define SIOCCHGGRETAP   (SIOCDEVPRIVATE + 11)
103
104 #endif /* openvswitch/gre.h */