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 #include <plugins/gbp/gbp_sclass.h>
17 #include <vnet/l2/l2_input.h>
18 #include <vnet/l2/l2_output.h>
20 gbp_sclass_main_t gbp_sclass_main;
23 gbp_sclass_enable_l2 (u32 sw_if_index)
25 l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_GBP_SCLASS_2_ID, 1);
26 l2output_intf_bitmap_enable (sw_if_index, L2OUTPUT_FEAT_GBP_ID_2_SCLASS, 1);
30 gbp_sclass_disable_l2 (u32 sw_if_index)
32 l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_GBP_SCLASS_2_ID, 0);
33 l2output_intf_bitmap_enable (sw_if_index, L2OUTPUT_FEAT_GBP_ID_2_SCLASS, 0);
37 gbp_sclass_enable_ip (u32 sw_if_index)
39 vnet_feature_enable_disable ("ip4-unicast",
40 "ip4-gbp-sclass-2-id", sw_if_index, 1, 0, 0);
41 vnet_feature_enable_disable ("ip6-unicast",
42 "ip6-gbp-sclass-2-id", sw_if_index, 1, 0, 0);
43 vnet_feature_enable_disable ("ip4-output",
44 "ip4-gbp-id-2-sclass", sw_if_index, 1, 0, 0);
45 vnet_feature_enable_disable ("ip6-output",
46 "ip6-gbp-id-2-sclass", sw_if_index, 1, 0, 0);
50 gbp_sclass_disable_ip (u32 sw_if_index)
52 vnet_feature_enable_disable ("ip4-unicast",
53 "ip4-gbp-sclass-2-id", sw_if_index, 0, 0, 0);
54 vnet_feature_enable_disable ("ip6-unicast",
55 "ip6-gbp-sclass-2-id", sw_if_index, 0, 0, 0);
56 vnet_feature_enable_disable ("ip4-output",
57 "ip4-gbp-id-2-sclass", sw_if_index, 0, 0, 0);
58 vnet_feature_enable_disable ("ip6-output",
59 "ip6-gbp-id-2-sclass", sw_if_index, 0, 0, 0);
63 gbp_sclass_init (vlib_main_t * vm)
65 gbp_sclass_main_t *glm = &gbp_sclass_main;
66 vlib_node_t *node = vlib_get_node_by_name (vm, (u8 *) "l2-gbp-sclass-2-id");
68 /* Initialize the feature next-node indices */
69 feat_bitmap_init_next_nodes (vm,
72 l2input_get_feat_names (),
73 glm->gel_l2_input_feat_next);
75 node = vlib_get_node_by_name (vm, (u8 *) "l2-gbp-id-2-sclass");
76 feat_bitmap_init_next_nodes (vm,
79 l2output_get_feat_names (),
80 glm->gel_l2_output_feat_next);
85 VLIB_INIT_FUNCTION (gbp_sclass_init);
89 * fd.io coding-style-patch-verification: ON
92 * eval: (c-set-style "gnu")