FD.io VPP
v20.01-48-g3e0dafb74
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
>
22
#include <
vnet/ethernet/arp_packet.h
>
23
24
typedef
enum
gbp_src_classify_type_t_
25
{
26
GBP_SRC_CLASSIFY_NULL
,
27
GBP_SRC_CLASSIFY_PORT
,
28
GBP_SRC_CLASSIFY_LPM
,
29
GBP_SRC_CLASSIFY_LPM_ANON
,
30
GBP_SRC_N_CLASSIFY
31
#define GBP_SRC_N_CLASSIFY GBP_SRC_N_CLASSIFY
32
}
gbp_src_classify_type_t
;
33
34
/**
35
* Grouping of global data for the GBP source EPG classification feature
36
*/
37
typedef
struct
gbp_src_classify_main_t_
38
{
39
/**
40
* Next nodes for L2 output features
41
*/
42
u32
l2_input_feat_next
[
GBP_SRC_N_CLASSIFY
][32];
43
}
gbp_src_classify_main_t
;
44
45
extern
gbp_src_classify_main_t
gbp_src_classify_main
;
46
47
enum
gbp_classify_get_ip_way
48
{
49
GBP_CLASSIFY_GET_IP_SRC
= 0,
50
GBP_CLASSIFY_GET_IP_DST
= 1
51
};
52
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)
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_LPM_ANON
Definition:
gbp_classify.h:29
gbp_src_classify_main
gbp_src_classify_main_t gbp_src_classify_main
Definition:
gbp_classify.c:22
GBP_CLASSIFY_GET_IP_SRC
Definition:
gbp_classify.h:49
gbp_src_classify_type_t_
gbp_src_classify_type_t_
Definition:
gbp_classify.h:24
gbp.h
static_always_inline
#define static_always_inline
Definition:
clib.h:99
DPO_PROTO_NONE
#define DPO_PROTO_NONE
Definition:
dpo.h:71
ethernet_vlan_header_t::type
u16 type
Definition:
packet.h:136
DPO_PROTO_IP4
Definition:
dpo.h:62
u32
unsigned int u32
Definition:
types.h:88
dpo_proto_t
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
ip4_address_t
Definition:
ip4_packet.h:49
ethernet_vlan_header_t
Definition:
packet.h:128
arp_packet.h
u16
unsigned short u16
Definition:
types.h:57
gbp_classify_get_ip_way
gbp_classify_get_ip_way
Definition:
gbp_classify.h:47
GBP_SRC_CLASSIFY_PORT
Definition:
gbp_classify.h:27
ethernet_header_t::type
u16 type
Definition:
packet.h:59
ip6
u8 ip6[16]
Definition:
one.api:477
gbp_src_classify_type_t
enum gbp_src_classify_type_t_ gbp_src_classify_type_t
DPO_PROTO_IP6
Definition:
dpo.h:63
gbp_src_classify_main_t_
Grouping of global data for the GBP source EPG classification feature.
Definition:
gbp_classify.h:37
GBP_SRC_CLASSIFY_NULL
Definition:
gbp_classify.h:26
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_header_t
Definition:
packet.h:52
GBP_CLASSIFY_GET_IP_DST
Definition:
gbp_classify.h:50
GBP_SRC_N_CLASSIFY
#define GBP_SRC_N_CLASSIFY
Definition:
gbp_classify.h:31
ip6_header_t
Definition:
ip6_packet.h:291
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.
ethernet_arp_header_t
Definition:
arp_packet.h:133
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
ip4
u32 ip4
Definition:
one.api:440
ip4_header_t
Definition:
ip4_packet.h:132
ip6_address_t
Definition:
ip6_packet.h:46
GBP_SRC_CLASSIFY_LPM
Definition:
gbp_classify.h:28
src
plugins
gbp
gbp_classify.h
Generated on Wed Sep 9 2020 00:03:32 for FD.io VPP by
1.8.13