Line | Count | Source |
1 | | // SPDX-License-Identifier: GPL-2.0-or-later |
2 | | /* |
3 | | * Debugging utilities. |
4 | | * Copyright (C) 2018 Cumulus Networks, Inc. |
5 | | * Quentin Young |
6 | | */ |
7 | | #include <zebra.h> |
8 | | #include "typesafe.h" |
9 | | #include "debug.h" |
10 | | #include "command.h" |
11 | | |
12 | | static struct debug_cb_list_head cb_head; |
13 | | |
14 | | DECLARE_LIST(debug_cb_list, struct debug_callbacks, item); |
15 | | |
16 | | /* All code in this section should be reentrant and MT-safe */ |
17 | | |
18 | | DEFUN_NOSH(debug_all, debug_all_cmd, "[no] debug all", |
19 | | NO_STR DEBUG_STR "Toggle all debugging output\n") |
20 | 0 | { |
21 | 0 | struct debug_callbacks *cb; |
22 | |
|
23 | 0 | bool set = !strmatch(argv[0]->text, "no"); |
24 | 0 | uint32_t mode = DEBUG_NODE2MODE(vty->node); |
25 | |
|
26 | 0 | frr_each (debug_cb_list, &cb_head, cb) |
27 | 0 | cb->debug_set_all(mode, set); |
28 | |
|
29 | 0 | return CMD_SUCCESS; |
30 | 0 | } |
31 | | |
32 | | /* ------------------------------------------------------------------------- */ |
33 | | |
34 | | void debug_init(struct debug_callbacks *cb) |
35 | 0 | { |
36 | 0 | static bool inited = false; |
37 | |
|
38 | 0 | if (!inited) { |
39 | 0 | inited = true; |
40 | 0 | debug_cb_list_init(&cb_head); |
41 | 0 | } |
42 | |
|
43 | 0 | debug_cb_list_add_head(&cb_head, cb); |
44 | 0 | } |
45 | | |
46 | | void debug_init_cli(void) |
47 | 0 | { |
48 | 0 | install_element(ENABLE_NODE, &debug_all_cmd); |
49 | 0 | install_element(CONFIG_NODE, &debug_all_cmd); |
50 | 0 | } |