FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
gbp_classify.h
Go to the documentation of this file.
1 /*
2  * gbp.h : Group Based Policy
3  *
4  * Copyright (c) 2018 Cisco and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef __GBP_CLASSIFY_H__
19 #define __GBP_CLASSIFY_H__
20 
21 #include <plugins/gbp/gbp.h>
23 
25 {
31 #define GBP_SRC_N_CLASSIFY GBP_SRC_N_CLASSIFY
33 
34 /**
35  * Grouping of global data for the GBP source EPG classification feature
36  */
38 {
39  /**
40  * Next nodes for L2 output features
41  */
44 
46 
48 {
51 };
52 
55  const ip4_address_t ** ip4,
56  const ip6_address_t ** ip6,
57  const enum gbp_classify_get_ip_way way)
58 {
59  u16 etype = clib_net_to_host_u16 (eh0->type);
60  const void *l3h0 = eh0 + 1;
61 
62  if (ETHERNET_TYPE_VLAN == etype)
63  {
64  const ethernet_vlan_header_t *vh0 =
65  (ethernet_vlan_header_t *) (eh0 + 1);
66  etype = clib_net_to_host_u16 (vh0->type);
67  l3h0 = vh0 + 1;
68  }
69 
70  switch (etype)
71  {
72  case ETHERNET_TYPE_IP4:
73  *ip4 = &(&((const ip4_header_t *) l3h0)->src_address)[way];
74  return DPO_PROTO_IP4;
75  case ETHERNET_TYPE_IP6:
76  *ip6 = &(&((const ip6_header_t *) l3h0)->src_address)[way];
77  return DPO_PROTO_IP6;
78  case ETHERNET_TYPE_ARP:
79  *ip4 = &((ethernet_arp_header_t *) l3h0)->ip4_over_ethernet[way].ip4;
80  return DPO_PROTO_IP4;
81  }
82 
83  return DPO_PROTO_NONE;
84 }
85 
86 #endif
87 
88 /*
89  * fd.io coding-style-patch-verification: ON
90  *
91  * Local Variables:
92  * eval: (c-set-style "gnu")
93  * End:
94  */
ip4
vl_api_ip4_address_t ip4
Definition: one.api:376
dpo_proto_t
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
gbp_src_classify_main
gbp_src_classify_main_t gbp_src_classify_main
Definition: gbp_classify.c:22
ethernet_vlan_header_t
Definition: packet.h:128
gbp_src_classify_main_t
struct gbp_src_classify_main_t_ gbp_src_classify_main_t
Grouping of global data for the GBP source EPG classification feature.
GBP_CLASSIFY_GET_IP_DST
@ GBP_CLASSIFY_GET_IP_DST
Definition: gbp_classify.h:50
gbp.h
u16
unsigned short u16
Definition: types.h:57
ethernet_header_t::type
u16 type
Definition: packet.h:59
gbp_src_classify_type_t_
gbp_src_classify_type_t_
Definition: gbp_classify.h:24
ip4_header_t
Definition: ip4_packet.h:87
gbp_classify_get_ip_way
gbp_classify_get_ip_way
Definition: gbp_classify.h:47
ethernet_arp_header_t
Definition: arp_packet.h:133
GBP_SRC_CLASSIFY_LPM
@ GBP_SRC_CLASSIFY_LPM
Definition: gbp_classify.h:28
GBP_SRC_CLASSIFY_NULL
@ GBP_SRC_CLASSIFY_NULL
Definition: gbp_classify.h:26
gbp_src_classify_type_t
enum gbp_src_classify_type_t_ gbp_src_classify_type_t
GBP_SRC_CLASSIFY_PORT
@ GBP_SRC_CLASSIFY_PORT
Definition: gbp_classify.h:27
static_always_inline
#define static_always_inline
Definition: clib.h:112
ethernet_header_t
Definition: packet.h:52
GBP_SRC_CLASSIFY_LPM_ANON
@ GBP_SRC_CLASSIFY_LPM_ANON
Definition: gbp_classify.h:29
ip4_address_t
Definition: ip4_packet.h:50
DPO_PROTO_IP6
@ DPO_PROTO_IP6
Definition: dpo.h:65
u32
unsigned int u32
Definition: types.h:88
ip6
vl_api_ip6_address_t ip6
Definition: one.api:424
gbp_src_classify_main_t_
Grouping of global data for the GBP source EPG classification feature.
Definition: gbp_classify.h:37
DPO_PROTO_NONE
#define DPO_PROTO_NONE
Definition: dpo.h:73
ip6_header_t
Definition: ip6_packet.h:294
arp_packet.h
gbp_src_classify_main_t_::l2_input_feat_next
u32 l2_input_feat_next[GBP_SRC_N_CLASSIFY][32]
Next nodes for L2 output features.
Definition: gbp_classify.h:42
ethernet_vlan_header_t::type
u16 type
Definition: packet.h:136
DPO_PROTO_IP4
@ DPO_PROTO_IP4
Definition: dpo.h:64
GBP_SRC_N_CLASSIFY
#define GBP_SRC_N_CLASSIFY
Definition: gbp_classify.h:31
gbp_classify_get_ip_address
static_always_inline dpo_proto_t gbp_classify_get_ip_address(const ethernet_header_t *eh0, const ip4_address_t **ip4, const ip6_address_t **ip6, const enum gbp_classify_get_ip_way way)
Definition: gbp_classify.h:54
GBP_CLASSIFY_GET_IP_SRC
@ GBP_CLASSIFY_GET_IP_SRC
Definition: gbp_classify.h:49