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 #include <plugins/gbp/gbp_scanner.h>
19 #include <plugins/gbp/gbp_endpoint.h>
20 #include <plugins/gbp/gbp_vxlan.h>
25 vlib_log_class_t gs_logger;
30 static bool gs_enabled;
32 #define GBP_SCANNER_DBG(...) \
33 vlib_log_debug (gs_logger, __VA_ARGS__);
36 gbp_scanner (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
38 uword event_type, *event_data = 0;
47 /* scan every 'inactive threshold' seconds */
48 vlib_process_wait_for_event_or_clock (vm, 2);
51 vlib_process_wait_for_event (vm);
53 event_type = vlib_process_get_events (vm, &event_data);
54 vec_reset_length (event_data);
63 case GBP_ENDPOINT_SCAN_START:
67 case GBP_ENDPOINT_SCAN_STOP:
71 case GBP_ENDPOINT_SCAN_SET_TIME:
80 GBP_SCANNER_DBG ("start");
81 gbp_endpoint_scan (vm);
82 GBP_SCANNER_DBG ("stop");
89 VLIB_REGISTER_NODE (gbp_scanner_node) = {
90 .function = gbp_scanner,
91 .type = VLIB_NODE_TYPE_PROCESS,
92 .name = "gbp-scanner",
97 gbp_scanner_cli (vlib_main_t * vm,
98 unformat_input_t * input, vlib_cli_command_t * cmd)
100 vlib_cli_output (vm, "GBP-scanner: enabled:%d interval:2", gs_enabled);
109 * @cliexstart{show gbp scanner}
113 VLIB_CLI_COMMAND (gbp_scanner_cli_node, static) = {
114 .path = "show gbp scanner",
115 .short_help = "show gbp scanner",
116 .function = gbp_scanner_cli,
120 static clib_error_t *
121 gbp_scanner_init (vlib_main_t * vm)
123 gs_logger = vlib_log_register_class ("gbp", "scan");
128 VLIB_INIT_FUNCTION (gbp_scanner_init);
131 * fd.io coding-style-patch-verification: ON
134 * eval: (c-set-style "gnu")