datapath-windows: Update VXLAN header information
[cascardo/ovs.git] / datapath-windows / ovsext / Vxlan.h
1 /*
2  * Copyright (c) 2014 VMware, Inc.
3  *
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:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef __VXLAN_H_
18 #define __VXLAN_H_ 1
19
20 #include "NetProto.h"
21 typedef struct _OVS_VXLAN_VPORT {
22     UINT16 dstPort;
23     UINT64 inPkts;
24     UINT64 outPkts;
25     UINT64 slowInPkts;
26     UINT64 slowOutPkts;
27     UINT64 filterID;
28     UINT64 ipId;
29     /*
30      * To be filled
31      */
32 } OVS_VXLAN_VPORT, *POVS_VXLAN_VPORT;
33
34 /* VXLAN header. */
35 typedef struct VXLANHdr {
36     /* Flags. */
37     UINT32   flags1:2;
38     /* Packet needs replication to multicast group (used for multicast proxy). */
39     UINT32   locallyReplicate:1;
40     /* Instance ID flag, must be set to 1. */
41     UINT32   instanceID:1;
42     /* Flags. */
43     UINT32   flags2:4;
44     /* Reserved. */
45     UINT32  reserved1:24;
46     /* VXLAN ID. */
47     UINT32  vxlanID:24;
48     /* Reserved. */
49     UINT32   reserved2:8;
50 } VXLANHdr;
51
52 NTSTATUS OvsInitVxlanTunnel(PIRP irp,
53                             POVS_VPORT_ENTRY vport,
54                             UINT16 udpDestPort,
55                             PFNTunnelVportPendingOp callback,
56                             PVOID tunnelContext);
57
58 NTSTATUS OvsCleanupVxlanTunnel(PIRP irp,
59                                POVS_VPORT_ENTRY vport,
60                                PFNTunnelVportPendingOp callback,
61                                PVOID tunnelContext);
62
63 NDIS_STATUS OvsSlowPathDecapVxlan(const PNET_BUFFER_LIST packet,
64                                   OvsIPv4TunnelKey *tunnelKey);
65
66 NDIS_STATUS OvsEncapVxlan(POVS_VPORT_ENTRY vport,
67                           PNET_BUFFER_LIST curNbl,
68                           OvsIPv4TunnelKey *tunKey,
69                           POVS_SWITCH_CONTEXT switchContext,
70                           POVS_PACKET_HDR_INFO layers,
71                           PNET_BUFFER_LIST *newNbl);
72
73 NDIS_STATUS OvsDecapVxlan(POVS_SWITCH_CONTEXT switchContext,
74                           PNET_BUFFER_LIST curNbl,
75                           OvsIPv4TunnelKey *tunKey,
76                           PNET_BUFFER_LIST *newNbl);
77
78 static __inline UINT32
79 OvsGetVxlanTunHdrSize(VOID)
80 {
81     /* XXX: Can L2 include VLAN at all? */
82     return sizeof (EthHdr) + sizeof (IPHdr) + sizeof (UDPHdr) +
83            sizeof (VXLANHdr);
84 }
85
86 #define VXLAN_UDP_PORT 4789
87 #define VXLAN_UDP_PORT_NBO 0xB512
88
89 #endif /* __VXLAN_H_ */