2 * Copyright (c) 2015 Cloudbase Solutions Srl
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 typedef struct _OVS_GRE_VPORT {
28 } OVS_GRE_VPORT, *POVS_GRE_VPORT;
31 /* GRE RFC 2890 header based on http://tools.ietf.org/html/rfc2890
32 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
33 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
34 * |C| |K|S| Reserved0 | Ver | Protocol Type |
35 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 * | Checksum (optional) | Reserved1 (Optional) |
37 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 * | Sequence Number (Optional) |
41 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 typedef struct GREHdr {
49 /* Transparent Ethernet Bridging */
50 #define GRE_NET_TEB 0x5865
52 #define GRE_CSUM 0x0080
53 #define GRE_KEY 0x0020
55 NTSTATUS OvsInitGreTunnel(POVS_VPORT_ENTRY vport);
57 VOID OvsCleanupGreTunnel(POVS_VPORT_ENTRY vport);
60 void OvsCleanupGreTunnel(POVS_VPORT_ENTRY vport);
62 NDIS_STATUS OvsEncapGre(POVS_VPORT_ENTRY vport,
63 PNET_BUFFER_LIST curNbl,
64 OvsIPv4TunnelKey *tunKey,
65 POVS_SWITCH_CONTEXT switchContext,
66 POVS_PACKET_HDR_INFO layers,
67 PNET_BUFFER_LIST *newNbl);
69 NDIS_STATUS OvsDecapGre(POVS_SWITCH_CONTEXT switchContext,
70 PNET_BUFFER_LIST curNbl,
71 OvsIPv4TunnelKey *tunKey,
72 PNET_BUFFER_LIST *newNbl);
74 static __inline UINT16
75 OvsTunnelFlagsToGreFlags(UINT16 tunnelflags)
79 if (tunnelflags & OVS_TNL_F_CSUM)
82 if (tunnelflags & OVS_TNL_F_KEY)
88 static __inline UINT32
89 GreTunHdrSize(UINT16 flags)
91 UINT32 sum = sizeof(EthHdr) + sizeof(IPHdr) + sizeof(GREHdr);
92 sum += (flags & OVS_TNL_F_CSUM) ?
94 sum += (flags & OVS_TNL_F_KEY) ?