aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib/cli_funcs.h
blob: 78aef73ba2db0bbf9ffb19b00f3f10a835aa1773 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * Copyright (c) 2015 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 * cli_funcs.h: VLIB CLI related functions/inlines
 *
 * Copyright (c) 2008 Eliot Dresselhaus
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#ifndef included_vlib_cli_funcs_h
#define included_vlib_cli_funcs_h

always_inline void *
vlib_cli_get_parse_rule_result (vlib_main_t * vm, uword index)
{
  vlib_cli_main_t *cm = &vm->cli_main;
  return vec_elt (cm->parse_rule_data, index);
}

#endif /* included_vlib_cli_funcs_h */

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */
pan class="o">= data[1]; ed->data[2] = data[2]; ed->data[3] = data[3]; } static inline void elog_four_int_track_sample (u32 * data) { ELOG_TYPE_DECLARE (e) = { .format = "four_int_track: first %d second %d third %d fourth %d",.format_args = "i4i4i4i4",}; struct { u32 data[4]; } *ed; ELOG_TRACK (sample_track); ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, sample_track); ed->data[0] = data[0]; ed->data[1] = data[1]; ed->data[2] = data[2]; ed->data[3] = data[3]; } static inline void elog_enum_sample (u8 which) { ELOG_TYPE_DECLARE (e) = { .format = "my enum: %s",.format_args = "t1",.n_enum_strings = 2,.enum_strings = { "string 1", "string 2",},}; struct { u8 which; } *ed; ed = ELOG_DATA (&vlib_global_main.elog_main, e); ed->which = which; } static inline void elog_one_datum_sample (u32 data) { ELOG_TYPE_DECLARE (e) = { .format = "one datum: %d",.format_args = "i4",}; elog (&vlib_global_main.elog_main, &e, data); } static clib_error_t * test_elog_command_fn (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { int i; u32 samples[4]; for (i = 0; i < 10; i++) { samples[0] = i; samples[1] = i + 1; samples[2] = i + 2; samples[3] = i + 3; elog_four_int_sample (samples); elog_four_int_track_sample (samples); elog_enum_sample (0); elog_enum_sample (1); elog_one_datum_sample (i); } return 0; } /* *INDENT-OFF* */ VLIB_CLI_COMMAND (test_elog_command, static) = { .path = "test elog sample", .short_help = "test elog sample", .function = test_elog_command_fn, }; /* *INDENT-ON* */ /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */