2 * Copyright (c) 2020 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 <cnat/cnat_session.h>
17 #include <cnat/cnat_client.h>
19 typedef enum cnat_scanner_cmd_t_
26 cnat_scanner_process (vlib_main_t * vm,
27 vlib_node_runtime_t * rt, vlib_frame_t * f)
29 uword event_type, *event_data = 0;
30 cnat_main_t *cm = &cnat_main;
32 int enabled = 1, i = 0;
37 vlib_process_wait_for_event_or_clock (vm, cm->scanner_timeout);
39 vlib_process_wait_for_event (vm);
41 event_type = vlib_process_get_events (vm, &event_data);
42 vec_reset_length (event_data);
44 start_time = vlib_time_now (vm);
51 case CNAT_SCANNER_OFF:
61 cnat_client_throttle_pool_process ();
62 i = cnat_session_scan (vm, start_time, i);
68 VLIB_REGISTER_NODE (cnat_scanner_process_node) = {
69 .function = cnat_scanner_process,
70 .type = VLIB_NODE_TYPE_PROCESS,
71 .name = "cnat-scanner-process",
76 cnat_scanner_cmd (vlib_main_t * vm,
77 unformat_input_t * input, vlib_cli_command_t * c)
79 cnat_scanner_cmd_t cmd;
81 cmd = CNAT_SCANNER_ON;
83 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
85 if (unformat (input, "on"))
86 cmd = CNAT_SCANNER_ON;
87 else if (unformat (input, "off"))
88 cmd = CNAT_SCANNER_OFF;
90 return (clib_error_return (0, "unknown input '%U'",
91 format_unformat_error, input));
94 vlib_process_signal_event (vm, cnat_scanner_process_node.index, cmd, 0);
100 VLIB_CLI_COMMAND (cnat_scanner_cmd_node, static) = {
101 .path = "test cnat scanner",
102 .function = cnat_scanner_cmd,
103 .short_help = "test cnat scanner",
108 * fd.io coding-style-patch-verification: ON
111 * eval: (c-set-style "gnu")