3 * Copyright (C) 2018 Cumulus Networks, Inc.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #ifndef VTYSH_EXTRACT_PL
27 #include "pbrd/pbr_debug_clippy.c"
29 #include "pbrd/pbr_debug.h"
31 struct debug pbr_dbg_map
= {0, "PBR map"};
32 struct debug pbr_dbg_zebra
= {0, "PBR Zebra communications"};
33 struct debug pbr_dbg_nht
= {0, "PBR nexthop tracking"};
34 struct debug pbr_dbg_event
= {0, "PBR events"};
36 struct debug
*pbr_debugs
[] = {&pbr_dbg_map
, &pbr_dbg_zebra
, &pbr_dbg_nht
,
39 const char *pbr_debugs_conflines
[] = {
46 void pbr_debug_set_all(uint32_t flags
, bool set
)
48 for (unsigned int i
= 0; i
< array_size(pbr_debugs
); i
++) {
49 DEBUG_FLAGS_SET(pbr_debugs
[i
], flags
, set
);
51 /* if all modes have been turned off, don't preserve options */
52 if (!DEBUG_MODE_CHECK(pbr_debugs
[i
], DEBUG_MODE_ALL
))
53 DEBUG_CLEAR(pbr_debugs
[i
]);
57 int pbr_debug_config_write_helper(struct vty
*vty
, bool config
)
59 uint32_t mode
= DEBUG_MODE_ALL
;
62 mode
= DEBUG_MODE_CONF
;
64 for (unsigned int i
= 0; i
< array_size(pbr_debugs
); i
++)
65 if (DEBUG_MODE_CHECK(pbr_debugs
[i
], mode
))
66 vty_out(vty
, "%s\n", pbr_debugs_conflines
[i
]);
70 int pbr_debug_config_write(struct vty
*vty
)
72 return pbr_debug_config_write_helper(vty
, true);
75 struct debug_callbacks pbr_dbg_cbs
= {.debug_set_all
= pbr_debug_set_all
};
77 void pbr_debug_init(void)
79 debug_init(&pbr_dbg_cbs
);