]> git.proxmox.com Git - mirror_frr.git/blame - ldpd/ldp_debug.h
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / ldpd / ldp_debug.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
eac6e3f0
RW
2/*
3 * Copyright (C) 2016 by Open Source Routing.
eac6e3f0
RW
4 */
5
6#ifndef _LDP_DEBUG_H_
7#define _LDP_DEBUG_H_
8
9struct ldp_debug {
10 int hello;
11#define LDP_DEBUG_HELLO_RECV 0x01
12#define LDP_DEBUG_HELLO_SEND 0x02
13
14 int errors;
15#define LDP_DEBUG_ERRORS 0x01
16
17 int event;
18#define LDP_DEBUG_EVENT 0x01
19
08e4b244
RW
20 int labels;
21#define LDP_DEBUG_LABELS 0x01
22
eac6e3f0
RW
23 int msg;
24#define LDP_DEBUG_MSG_RECV 0x01
25#define LDP_DEBUG_MSG_RECV_ALL 0x02
26#define LDP_DEBUG_MSG_SEND 0x04
27#define LDP_DEBUG_MSG_SEND_ALL 0x08
28
29 int zebra;
30#define LDP_DEBUG_ZEBRA 0x01
e1894ff7
KS
31
32 int sync;
33#define LDP_DEBUG_SYNC 0x01
34
eac6e3f0
RW
35};
36extern struct ldp_debug conf_ldp_debug;
37extern struct ldp_debug ldp_debug;
38
77518251
DS
39#define CONF_DEBUG_ON(a, b) (conf_ldp_debug.a |= (b))
40#define CONF_DEBUG_OFF(a, b) (conf_ldp_debug.a &= ~(b))
eac6e3f0 41
77518251
DS
42#define TERM_DEBUG_ON(a, b) (ldp_debug.a |= (b))
43#define TERM_DEBUG_OFF(a, b) (ldp_debug.a &= ~(b))
eac6e3f0
RW
44
45#define DEBUG_ON(a, b) \
46 do { \
47 if (vty->node == CONFIG_NODE) { \
48 CONF_DEBUG_ON(a, b); \
49 TERM_DEBUG_ON(a, b); \
50 } else \
51 TERM_DEBUG_ON(a, b); \
52 } while (0)
53#define DEBUG_OFF(a, b) \
54 do { \
55 CONF_DEBUG_OFF(a, b); \
56 TERM_DEBUG_OFF(a, b); \
57 } while (0)
58
77518251
DS
59#define LDP_DEBUG(a, b) (ldp_debug.a & b)
60#define CONF_LDP_DEBUG(a, b) (conf_ldp_debug.a & b)
eac6e3f0
RW
61
62#define debug_hello_recv(emsg, ...) \
63do { \
77518251 64 if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_RECV)) \
eac6e3f0
RW
65 log_debug("discovery[recv]: " emsg, __VA_ARGS__); \
66} while (0)
67
68#define debug_hello_send(emsg, ...) \
69do { \
77518251 70 if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_SEND)) \
eac6e3f0
RW
71 log_debug("discovery[send]: " emsg, __VA_ARGS__); \
72} while (0)
73
74#define debug_err(emsg, ...) \
75do { \
77518251 76 if (LDP_DEBUG(errors, LDP_DEBUG_ERRORS)) \
eac6e3f0
RW
77 log_debug("error: " emsg, __VA_ARGS__); \
78} while (0)
79
80#define debug_evt(emsg, ...) \
81do { \
77518251 82 if (LDP_DEBUG(event, LDP_DEBUG_EVENT)) \
eac6e3f0
RW
83 log_debug("event: " emsg, __VA_ARGS__); \
84} while (0)
85
08e4b244
RW
86#define debug_labels(emsg, ...) \
87do { \
77518251 88 if (LDP_DEBUG(labels, LDP_DEBUG_LABELS)) \
08e4b244
RW
89 log_debug("labels: " emsg, __VA_ARGS__); \
90} while (0)
91
eac6e3f0
RW
92#define debug_msg_recv(emsg, ...) \
93do { \
77518251 94 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV)) \
eac6e3f0
RW
95 log_debug("msg[in]: " emsg, __VA_ARGS__); \
96} while (0)
97
98#define debug_msg_send(emsg, ...) \
99do { \
77518251 100 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND)) \
eac6e3f0
RW
101 log_debug("msg[out]: " emsg, __VA_ARGS__); \
102} while (0)
103
faf75793
RW
104#define debug_msg(out, emsg, ...) \
105do { \
106 if (out) \
107 debug_msg_send(emsg, __VA_ARGS__); \
108 else \
109 debug_msg_recv(emsg, __VA_ARGS__); \
110} while (0)
111
eac6e3f0
RW
112#define debug_kalive_recv(emsg, ...) \
113do { \
77518251 114 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV_ALL)) \
eac6e3f0
RW
115 log_debug("kalive[in]: " emsg, __VA_ARGS__); \
116} while (0)
117
118#define debug_kalive_send(emsg, ...) \
119do { \
77518251 120 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND_ALL)) \
eac6e3f0
RW
121 log_debug("kalive[out]: " emsg, __VA_ARGS__); \
122} while (0)
123
124#define debug_zebra_in(emsg, ...) \
125do { \
77518251 126 if (LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA)) \
eac6e3f0
RW
127 log_debug("zebra[in]: " emsg, __VA_ARGS__); \
128} while (0)
129
130#define debug_zebra_out(emsg, ...) \
131do { \
77518251 132 if (LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA)) \
eac6e3f0
RW
133 log_debug("zebra[out]: " emsg, __VA_ARGS__); \
134} while (0)
135
e1894ff7
KS
136#define debug_evt_ldp_sync(emsg, ...) \
137do { \
138 if (LDP_DEBUG(sync, LDP_DEBUG_SYNC)) \
139 log_debug("sync: " emsg, __VA_ARGS__); \
140} while (0)
141
eac6e3f0 142#endif /* _LDP_DEBUG_H_ */