FD.io VPP  v19.08-27-gf4dcae4
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  */
gbp_src_classify_main_t gbp_src_classify_main
Definition: gbp_classify.c:22
gbp_src_classify_type_t_
Definition: gbp_classify.h:24
#define static_always_inline
Definition: clib.h:99
#define DPO_PROTO_NONE
Definition: dpo.h:71
unsigned int u32
Definition: types.h:88
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
unsigned short u16
Definition: types.h:57
gbp_classify_get_ip_way
Definition: gbp_classify.h:47
enum gbp_src_classify_type_t_ gbp_src_classify_type_t
Grouping of global data for the GBP source EPG classification feature.
Definition: gbp_classify.h:37
u32 l2_input_feat_next[GBP_SRC_N_CLASSIFY][32]
Next nodes for L2 output features.
Definition: gbp_classify.h:42
#define GBP_SRC_N_CLASSIFY
Definition: gbp_classify.h:31
struct gbp_src_classify_main_t_ gbp_src_classify_main_t
Grouping of global data for the GBP source EPG classification feature.
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