]> git.proxmox.com Git - mirror_frr.git/blob - ldpd/ldp_debug.h
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / ldpd / ldp_debug.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (C) 2016 by Open Source Routing.
4 */
5
6 #ifndef _LDP_DEBUG_H_
7 #define _LDP_DEBUG_H_
8
9 struct 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
20 int labels;
21 #define LDP_DEBUG_LABELS 0x01
22
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
31
32 int sync;
33 #define LDP_DEBUG_SYNC 0x01
34
35 };
36 extern struct ldp_debug conf_ldp_debug;
37 extern struct ldp_debug ldp_debug;
38
39 #define CONF_DEBUG_ON(a, b) (conf_ldp_debug.a |= (b))
40 #define CONF_DEBUG_OFF(a, b) (conf_ldp_debug.a &= ~(b))
41
42 #define TERM_DEBUG_ON(a, b) (ldp_debug.a |= (b))
43 #define TERM_DEBUG_OFF(a, b) (ldp_debug.a &= ~(b))
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
59 #define LDP_DEBUG(a, b) (ldp_debug.a & b)
60 #define CONF_LDP_DEBUG(a, b) (conf_ldp_debug.a & b)
61
62 #define debug_hello_recv(emsg, ...) \
63 do { \
64 if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_RECV)) \
65 log_debug("discovery[recv]: " emsg, __VA_ARGS__); \
66 } while (0)
67
68 #define debug_hello_send(emsg, ...) \
69 do { \
70 if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_SEND)) \
71 log_debug("discovery[send]: " emsg, __VA_ARGS__); \
72 } while (0)
73
74 #define debug_err(emsg, ...) \
75 do { \
76 if (LDP_DEBUG(errors, LDP_DEBUG_ERRORS)) \
77 log_debug("error: " emsg, __VA_ARGS__); \
78 } while (0)
79
80 #define debug_evt(emsg, ...) \
81 do { \
82 if (LDP_DEBUG(event, LDP_DEBUG_EVENT)) \
83 log_debug("event: " emsg, __VA_ARGS__); \
84 } while (0)
85
86 #define debug_labels(emsg, ...) \
87 do { \
88 if (LDP_DEBUG(labels, LDP_DEBUG_LABELS)) \
89 log_debug("labels: " emsg, __VA_ARGS__); \
90 } while (0)
91
92 #define debug_msg_recv(emsg, ...) \
93 do { \
94 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV)) \
95 log_debug("msg[in]: " emsg, __VA_ARGS__); \
96 } while (0)
97
98 #define debug_msg_send(emsg, ...) \
99 do { \
100 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND)) \
101 log_debug("msg[out]: " emsg, __VA_ARGS__); \
102 } while (0)
103
104 #define debug_msg(out, emsg, ...) \
105 do { \
106 if (out) \
107 debug_msg_send(emsg, __VA_ARGS__); \
108 else \
109 debug_msg_recv(emsg, __VA_ARGS__); \
110 } while (0)
111
112 #define debug_kalive_recv(emsg, ...) \
113 do { \
114 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV_ALL)) \
115 log_debug("kalive[in]: " emsg, __VA_ARGS__); \
116 } while (0)
117
118 #define debug_kalive_send(emsg, ...) \
119 do { \
120 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND_ALL)) \
121 log_debug("kalive[out]: " emsg, __VA_ARGS__); \
122 } while (0)
123
124 #define debug_zebra_in(emsg, ...) \
125 do { \
126 if (LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA)) \
127 log_debug("zebra[in]: " emsg, __VA_ARGS__); \
128 } while (0)
129
130 #define debug_zebra_out(emsg, ...) \
131 do { \
132 if (LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA)) \
133 log_debug("zebra[out]: " emsg, __VA_ARGS__); \
134 } while (0)
135
136 #define debug_evt_ldp_sync(emsg, ...) \
137 do { \
138 if (LDP_DEBUG(sync, LDP_DEBUG_SYNC)) \
139 log_debug("sync: " emsg, __VA_ARGS__); \
140 } while (0)
141
142 #endif /* _LDP_DEBUG_H_ */