FD.io VPP  v18.10-32-g1161dda
Vector Packet Processing
vxlan_gbp_packet.h
Go to the documentation of this file.
1 /*
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:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15 #ifndef __included_vxlan_gbp_packet_h__
16 #define __included_vxlan_gbp_packet_h__ 1
17 
18 /*
19  * From draft-smith-vxlan-group-policy-04.txt
20  *
21  * 0 1 2 3
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  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
28  *
29  * G bit: Bit 0 of the initial word is defined as the G (Group Based
30  * Policy Extension) bit.
31  *
32  * I bit: where the I flag MUST be set to 1 for a valid
33  * VXLAN Network ID (VNI).
34  *
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.
38  *
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
41  * dropped.
42  *
43  * S bit: Bit 11 of the initial word is defined as the source policy
44  * applied bit.
45  *
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
48  * is set to 1.
49  *
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
52  * bit is set.
53  *
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.
59  *
60  * Group Policy ID: 16 bit identifier that indicates the source TSI
61  * Group membership being encapsulated by VXLAN. Its value is source
62  * class id.
63  *
64  */
65 
66 typedef struct
67 {
68  union
69  {
70  struct
71  {
72  union
73  {
74  struct
75  {
78  };
80  };
82  };
84  };
87 
88 #define VXLAN_GBP_FLAGS_G 0x80
89 #define VXLAN_GBP_FLAGS_I 0x08
90 
91 #define foreach_vxlan_gbp_gpflags \
92 _ (0x40, D) \
93 _ (0x20, E) \
94 _ (0x10, S) \
95 _ (0x08, A)
96 
97 typedef enum
98 {
99 #define _(n,f) VXLAN_GBP_GPFLAGS_##f = n,
101 #undef _
103 
104 static inline u32
106 {
107  u32 vni_reserved_host_byte_order;
108 
109  vni_reserved_host_byte_order = clib_net_to_host_u32 (h->vni_reserved);
110  return vni_reserved_host_byte_order >> 8;
111 }
112 
113 static inline u16
115 {
116  u16 sclass_host_byte_order;
117 
118  sclass_host_byte_order = clib_net_to_host_u16 (h->sclass);
119  return sclass_host_byte_order;
120 }
121 
122 static inline u8
124 {
125  return h->gpflags;
126 }
127 
128 static inline u8
130 {
131  return h->flag_g_i;
132 }
133 
134 static inline void
136 {
137  h->vni_reserved = clib_host_to_net_u32 (vni << 8);
138  h->flags_sclass_as_u32 = 0;
140 }
141 
142 #endif /* __included_vxlan_gbp_packet_h__ */
143 
144 /*
145  * fd.io coding-style-patch-verification: ON
146  *
147  * Local Variables:
148  * eval: (c-set-style "gnu")
149  * End:
150  */
static void vxlan_gbp_set_header(vxlan_gbp_header_t *h, u32 vni)
#define VXLAN_GBP_FLAGS_I
#define foreach_vxlan_gbp_gpflags
#define VXLAN_GBP_FLAGS_G
unsigned char u8
Definition: types.h:56
unsigned int u32
Definition: types.h:88
static u8 vxlan_gbp_get_flags(vxlan_gbp_header_t *h)
unsigned short u16
Definition: types.h:57
static u16 vxlan_gbp_get_sclass(vxlan_gbp_header_t *h)
static u32 vxlan_gbp_get_vni(vxlan_gbp_header_t *h)
vxlan_gbp_gpflag_t
static u8 vxlan_gbp_get_gpflags(vxlan_gbp_header_t *h)
u32 vni
Definition: vxlan_gbp.api:38