2023-02-08 13:17:09 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-02-28 22:14:45 +01:00
|
|
|
/*
|
|
|
|
* Debugging utilities.
|
|
|
|
* Copyright (C) 2018 Cumulus Networks, Inc.
|
|
|
|
* Quentin Young
|
|
|
|
*/
|
|
|
|
#include <zebra.h>
|
2019-05-25 02:09:01 +02:00
|
|
|
#include "typesafe.h"
|
2018-02-28 22:14:45 +01:00
|
|
|
#include "debug.h"
|
|
|
|
#include "command.h"
|
|
|
|
|
2019-05-25 02:09:01 +02:00
|
|
|
static struct debug_cb_list_head cb_head;
|
|
|
|
|
|
|
|
DECLARE_LIST(debug_cb_list, struct debug_callbacks, item);
|
2018-02-28 22:14:45 +01:00
|
|
|
|
|
|
|
/* All code in this section should be reentrant and MT-safe */
|
|
|
|
|
|
|
|
DEFUN_NOSH(debug_all, debug_all_cmd, "[no] debug all",
|
|
|
|
NO_STR DEBUG_STR "Toggle all debugging output\n")
|
|
|
|
{
|
2019-05-25 02:09:01 +02:00
|
|
|
struct debug_callbacks *cb;
|
|
|
|
|
2019-04-12 23:00:05 +02:00
|
|
|
bool set = !strmatch(argv[0]->text, "no");
|
2018-02-28 22:14:45 +01:00
|
|
|
uint32_t mode = DEBUG_NODE2MODE(vty->node);
|
|
|
|
|
2019-05-25 02:09:01 +02:00
|
|
|
frr_each (debug_cb_list, &cb_head, cb)
|
|
|
|
cb->debug_set_all(mode, set);
|
|
|
|
|
2018-02-28 22:14:45 +01:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2019-05-25 02:09:01 +02:00
|
|
|
void debug_init(struct debug_callbacks *cb)
|
2018-02-28 22:14:45 +01:00
|
|
|
{
|
2019-05-25 02:09:01 +02:00
|
|
|
static bool inited = false;
|
|
|
|
|
|
|
|
if (!inited) {
|
|
|
|
inited = true;
|
|
|
|
debug_cb_list_init(&cb_head);
|
|
|
|
}
|
|
|
|
|
|
|
|
debug_cb_list_add_head(&cb_head, cb);
|
2019-05-25 02:15:31 +02:00
|
|
|
}
|
2019-05-25 02:09:01 +02:00
|
|
|
|
2019-05-25 02:15:31 +02:00
|
|
|
void debug_init_cli(void)
|
|
|
|
{
|
2018-02-28 22:14:45 +01:00
|
|
|
install_element(ENABLE_NODE, &debug_all_cmd);
|
|
|
|
install_element(CONFIG_NODE, &debug_all_cmd);
|
|
|
|
}
|