ofpbuf: Use ptrdiff_t for pointer delta.
[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 filterID;
24     UINT64 ipId;
25     /*
26      * To be filled
27      */
28 } OVS_VXLAN_VPORT, *POVS_VXLAN_VPORT;
29
30 /* VXLAN header. */
31 typedef struct VXLANHdr {
32     /* Flags. */
33     UINT32   flags1:2;
34     /* Packet needs replication to multicast group (used for multicast proxy). */
35     UINT32   locallyReplicate:1;
36     /* Instance ID flag, must be set to 1. */
37     UINT32   instanceID:1;
38     /* Flags. */
39     UINT32   flags2:4;
40     /* Reserved. */
41     UINT32  reserved1:24;
42     /* VXLAN ID. */
43     UINT32  vxlanID:24;
44     /* Reserved. */
45     UINT32   reserved2:8;
46 } VXLANHdr;
47
48 NTSTATUS OvsInitVxlanTunnel(PIRP irp,
49                             POVS_VPORT_ENTRY vport,
50                             UINT16 udpDestPort,
51                             PFNTunnelVportPendingOp callback,
52                             PVOID tunnelContext);
53
54 NTSTATUS OvsCleanupVxlanTunnel(PIRP irp,
55                                POVS_VPORT_ENTRY vport,
56                                PFNTunnelVportPendingOp callback,
57                                PVOID tunnelContext);
58
59 NDIS_STATUS OvsSlowPathDecapVxlan(const PNET_BUFFER_LIST packet,
60                                   OvsIPv4TunnelKey *tunnelKey);
61
62 NDIS_STATUS OvsEncapVxlan(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);
68
69 NDIS_STATUS OvsDecapVxlan(POVS_SWITCH_CONTEXT switchContext,
70                           PNET_BUFFER_LIST curNbl,
71                           OvsIPv4TunnelKey *tunKey,
72                           PNET_BUFFER_LIST *newNbl);
73
74 static __inline UINT32
75 OvsGetVxlanTunHdrSize(VOID)
76 {
77     /* XXX: Can L2 include VLAN at all? */
78     return sizeof (EthHdr) + sizeof (IPHdr) + sizeof (UDPHdr) +
79            sizeof (VXLANHdr);
80 }
81
82 #define VXLAN_UDP_PORT 4789
83 #define VXLAN_UDP_PORT_NBO 0xB512
84
85 #endif /* __VXLAN_H_ */