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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef __GBP_POLICY_H__
17 #define __GBP_POLICY_H__
19 #include <plugins/gbp/gbp_contract.h>
22 * per-packet trace data
24 typedef struct gbp_policy_trace_t_
26 /* per-pkt trace data */
30 gbp_rule_action_t action;
36 /* packet trace format function */
37 u8 * format_gbp_policy_trace (u8 * s, va_list * args);
39 static_always_inline void
40 gbp_policy_trace(vlib_main_t * vm, vlib_node_runtime_t * node, vlib_buffer_t *b, const gbp_contract_key_t *key, gbp_rule_action_t action, u32 acl_match, u32 rule_match)
42 gbp_policy_trace_t *t;
44 if (PREDICT_TRUE (!(b->flags & VLIB_BUFFER_IS_TRACED)))
47 t = vlib_add_trace (vm, node, b, sizeof (*t));
48 t->sclass = key->gck_src;
49 t->dclass = key->gck_dst;
50 t->scope = key->gck_scope;
52 t->flags = vnet_buffer2 (b)->gbp.flags;
53 t->acl_match = acl_match;
54 t->rule_match = rule_match;
57 #endif /* __GBP_POLICY_H__ */