2 * Copyright (c) 2018 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
15 #ifndef __included_vxlan_gbp_packet_h__
16 #define __included_vxlan_gbp_packet_h__ 1
19 * From draft-smith-vxlan-group-policy-04.txt
22 * 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
23 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
24 * |G|R|R|R|I|R|R|R|R|D|E|S|A|R|R|R| Group Policy ID |
25 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
26 * | VXLAN Network Identifier (VNI) | Reserved |
27 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
29 * G bit: Bit 0 of the initial word is defined as the G (Group Based
30 * Policy Extension) bit.
32 * I bit: where the I flag MUST be set to 1 for a valid
33 * VXLAN Network ID (VNI).
35 * D bit: Bit 9 of the initial word is defined as the Don't Learn bit.
36 * When set, this bit indicates that the egress VTEP MUST NOT learn the
37 * source address of the encapsulated frame.
39 * E bit: Bit 10 of the initial word is defined as the bounce packet.
40 * When set, this bit indicates that packet is bounced and must be
43 * S bit: Bit 11 of the initial word is defined as the source policy
46 * A bit: Bit 12 of the initial word is defined as the A (Policy
47 * Applied) bit. This bit is only defined as the A bit when the G bit
50 * A = 1 indicates that the group policy has already been applied to
51 * this packet. Policies MUST NOT be applied by devices when the A
54 * A = 0 indicates that the group policy has not been applied to this
55 * packet. Group policies MUST be applied by devices when the A bit
56 * is set to 0 and the destination Group has been determined.
57 * Devices that apply the Group policy MUST set the A bit to 1 after
58 * the policy has been applied.
60 * Group Policy ID: 16 bit identifier that indicates the source TSI
61 * Group membership being encapsulated by VXLAN. Its value is source
83 u32 flags_sclass_as_u32;
88 #define VXLAN_GBP_FLAGS_G 0x80
89 #define VXLAN_GBP_FLAGS_I 0x08
91 #define foreach_vxlan_gbp_gpflags \
99 #define _(n,f) VXLAN_GBP_GPFLAGS_##f = n,
100 foreach_vxlan_gbp_gpflags
102 } vxlan_gbp_gpflag_t;
105 vxlan_gbp_get_vni (vxlan_gbp_header_t * h)
107 u32 vni_reserved_host_byte_order;
109 vni_reserved_host_byte_order = clib_net_to_host_u32 (h->vni_reserved);
110 return vni_reserved_host_byte_order >> 8;
114 vxlan_gbp_get_sclass (vxlan_gbp_header_t * h)
116 u16 sclass_host_byte_order;
118 sclass_host_byte_order = clib_net_to_host_u16 (h->sclass);
119 return sclass_host_byte_order;
123 vxlan_gbp_get_gpflags (vxlan_gbp_header_t * h)
129 vxlan_gbp_get_flags (vxlan_gbp_header_t * h)
135 vxlan_gbp_set_header (vxlan_gbp_header_t * h, u32 vni)
137 h->vni_reserved = clib_host_to_net_u32 (vni << 8);
138 h->flags_sclass_as_u32 = 0;
139 h->flag_g_i = VXLAN_GBP_FLAGS_I | VXLAN_GBP_FLAGS_G;
142 #endif /* __included_vxlan_gbp_packet_h__ */
145 * fd.io coding-style-patch-verification: ON
148 * eval: (c-set-style "gnu")