2 * gbp.h : Group Based Policy
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:
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef __GBP_CLASSIFY_H__
19 #define __GBP_CLASSIFY_H__
21 #include <plugins/gbp/gbp.h>
22 #include <vnet/ethernet/arp_packet.h>
24 typedef enum gbp_src_classify_type_t_
26 GBP_SRC_CLASSIFY_NULL,
27 GBP_SRC_CLASSIFY_PORT,
29 GBP_SRC_CLASSIFY_LPM_ANON,
31 #define GBP_SRC_N_CLASSIFY GBP_SRC_N_CLASSIFY
32 } gbp_src_classify_type_t;
35 * Grouping of global data for the GBP source EPG classification feature
37 typedef struct gbp_src_classify_main_t_
40 * Next nodes for L2 output features
42 u32 l2_input_feat_next[GBP_SRC_N_CLASSIFY][32];
43 } gbp_src_classify_main_t;
45 extern gbp_src_classify_main_t gbp_src_classify_main;
47 enum gbp_classify_get_ip_way
49 GBP_CLASSIFY_GET_IP_SRC = 0,
50 GBP_CLASSIFY_GET_IP_DST = 1
53 static_always_inline dpo_proto_t
54 gbp_classify_get_ip_address (const ethernet_header_t * eh0,
55 const ip4_address_t ** ip4,
56 const ip6_address_t ** ip6,
57 const enum gbp_classify_get_ip_way way)
59 u16 etype = clib_net_to_host_u16 (eh0->type);
60 const void *l3h0 = eh0 + 1;
62 if (ETHERNET_TYPE_VLAN == etype)
64 const ethernet_vlan_header_t *vh0 =
65 (ethernet_vlan_header_t *) (eh0 + 1);
66 etype = clib_net_to_host_u16 (vh0->type);
72 case ETHERNET_TYPE_IP4:
73 *ip4 = &(&((const ip4_header_t *) l3h0)->src_address)[way];
75 case ETHERNET_TYPE_IP6:
76 *ip6 = &(&((const ip6_header_t *) l3h0)->src_address)[way];
78 case ETHERNET_TYPE_ARP:
79 *ip4 = &((ethernet_arp_header_t *) l3h0)->ip4_over_ethernet[way].ip4;
83 return DPO_PROTO_NONE;
89 * fd.io coding-style-patch-verification: ON
92 * eval: (c-set-style "gnu")