2 * Copyright (c) 2015 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 <vnet/lawful-intercept/lawful_intercept.h>
19 set_li_command_fn (vlib_main_t * vm,
20 unformat_input_t * input,
21 vlib_cli_command_t * cmd)
23 li_main_t * lm = &li_main;
24 ip4_address_t collector;
33 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
34 if (unformat (input, "collector %U", unformat_ip4_address, &collector))
36 if (unformat (input, "src %U", unformat_ip4_address, &src))
38 else if (unformat (input, "udp-port %d", &tmp))
40 else if (unformat (input, "del"))
46 if (collector_set == 0)
47 return clib_error_return (0, "collector must be set...");
49 return clib_error_return (0, "src must be set...");
51 return clib_error_return (0, "udp-port must be set...");
55 for (i = 0; i < vec_len (lm->collectors); i++)
57 if (lm->collectors[i].as_u32 == collector.as_u32)
59 if (lm->ports[i] == udp_port)
60 return clib_error_return
61 (0, "collector %U:%d already configured",
62 &collector, udp_port);
64 return clib_error_return
65 (0, "collector %U already configured with port %d",
66 &collector, (int)(lm->ports[i]));
69 vec_add1 (lm->collectors, collector);
70 vec_add1 (lm->ports, udp_port);
71 vec_add1 (lm->src_addrs, src);
76 for (i = 0; i < vec_len (lm->collectors); i++)
78 if ((lm->collectors[i].as_u32 == collector.as_u32)
79 && lm->ports[i] == udp_port)
81 vec_delete (lm->collectors, 1, i);
82 vec_delete (lm->ports, 1, i);
83 vec_delete (lm->src_addrs, 1, i);
87 return clib_error_return (0, "collector %U:%d not configured",
88 &collector, udp_port);
93 VLIB_CLI_COMMAND (set_li_command, static) = {
96 "set li src <ip4-address> collector <ip4-address> udp-port <nnnn>",
97 .function = set_li_command_fn,
100 static clib_error_t *
101 li_init (vlib_main_t * vm)
103 li_main_t * lm = &li_main;
106 lm->vnet_main = vnet_get_main();
107 lm->hit_node_index = li_hit_node.index;
111 VLIB_INIT_FUNCTION(li_init);