]> git.proxmox.com Git - mirror_frr.git/blob - ldpd/ldp_debug.h
doc: Add `show ipv6 rpf X:X::X:X` command to docs
[mirror_frr.git] / ldpd / ldp_debug.h
1 /*
2 * Copyright (C) 2016 by Open Source Routing.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; see the file COPYING; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
17 * MA 02110-1301 USA
18 */
19
20 #ifndef _LDP_DEBUG_H_
21 #define _LDP_DEBUG_H_
22
23 struct ldp_debug {
24 int hello;
25 #define LDP_DEBUG_HELLO_RECV 0x01
26 #define LDP_DEBUG_HELLO_SEND 0x02
27
28 int errors;
29 #define LDP_DEBUG_ERRORS 0x01
30
31 int event;
32 #define LDP_DEBUG_EVENT 0x01
33
34 int labels;
35 #define LDP_DEBUG_LABELS 0x01
36
37 int msg;
38 #define LDP_DEBUG_MSG_RECV 0x01
39 #define LDP_DEBUG_MSG_RECV_ALL 0x02
40 #define LDP_DEBUG_MSG_SEND 0x04
41 #define LDP_DEBUG_MSG_SEND_ALL 0x08
42
43 int zebra;
44 #define LDP_DEBUG_ZEBRA 0x01
45
46 int sync;
47 #define LDP_DEBUG_SYNC 0x01
48
49 };
50 extern struct ldp_debug conf_ldp_debug;
51 extern struct ldp_debug ldp_debug;
52
53 #define CONF_DEBUG_ON(a, b) (conf_ldp_debug.a |= (b))
54 #define CONF_DEBUG_OFF(a, b) (conf_ldp_debug.a &= ~(b))
55
56 #define TERM_DEBUG_ON(a, b) (ldp_debug.a |= (b))
57 #define TERM_DEBUG_OFF(a, b) (ldp_debug.a &= ~(b))
58
59 #define DEBUG_ON(a, b) \
60 do { \
61 if (vty->node == CONFIG_NODE) { \
62 CONF_DEBUG_ON(a, b); \
63 TERM_DEBUG_ON(a, b); \
64 } else \
65 TERM_DEBUG_ON(a, b); \
66 } while (0)
67 #define DEBUG_OFF(a, b) \
68 do { \
69 CONF_DEBUG_OFF(a, b); \
70 TERM_DEBUG_OFF(a, b); \
71 } while (0)
72
73 #define LDP_DEBUG(a, b) (ldp_debug.a & b)
74 #define CONF_LDP_DEBUG(a, b) (conf_ldp_debug.a & b)
75
76 #define debug_hello_recv(emsg, ...) \
77 do { \
78 if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_RECV)) \
79 log_debug("discovery[recv]: " emsg, __VA_ARGS__); \
80 } while (0)
81
82 #define debug_hello_send(emsg, ...) \
83 do { \
84 if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_SEND)) \
85 log_debug("discovery[send]: " emsg, __VA_ARGS__); \
86 } while (0)
87
88 #define debug_err(emsg, ...) \
89 do { \
90 if (LDP_DEBUG(errors, LDP_DEBUG_ERRORS)) \
91 log_debug("error: " emsg, __VA_ARGS__); \
92 } while (0)
93
94 #define debug_evt(emsg, ...) \
95 do { \
96 if (LDP_DEBUG(event, LDP_DEBUG_EVENT)) \
97 log_debug("event: " emsg, __VA_ARGS__); \
98 } while (0)
99
100 #define debug_labels(emsg, ...) \
101 do { \
102 if (LDP_DEBUG(labels, LDP_DEBUG_LABELS)) \
103 log_debug("labels: " emsg, __VA_ARGS__); \
104 } while (0)
105
106 #define debug_msg_recv(emsg, ...) \
107 do { \
108 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV)) \
109 log_debug("msg[in]: " emsg, __VA_ARGS__); \
110 } while (0)
111
112 #define debug_msg_send(emsg, ...) \
113 do { \
114 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND)) \
115 log_debug("msg[out]: " emsg, __VA_ARGS__); \
116 } while (0)
117
118 #define debug_msg(out, emsg, ...) \
119 do { \
120 if (out) \
121 debug_msg_send(emsg, __VA_ARGS__); \
122 else \
123 debug_msg_recv(emsg, __VA_ARGS__); \
124 } while (0)
125
126 #define debug_kalive_recv(emsg, ...) \
127 do { \
128 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV_ALL)) \
129 log_debug("kalive[in]: " emsg, __VA_ARGS__); \
130 } while (0)
131
132 #define debug_kalive_send(emsg, ...) \
133 do { \
134 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND_ALL)) \
135 log_debug("kalive[out]: " emsg, __VA_ARGS__); \
136 } while (0)
137
138 #define debug_zebra_in(emsg, ...) \
139 do { \
140 if (LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA)) \
141 log_debug("zebra[in]: " emsg, __VA_ARGS__); \
142 } while (0)
143
144 #define debug_zebra_out(emsg, ...) \
145 do { \
146 if (LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA)) \
147 log_debug("zebra[out]: " emsg, __VA_ARGS__); \
148 } while (0)
149
150 #define debug_evt_ldp_sync(emsg, ...) \
151 do { \
152 if (LDP_DEBUG(sync, LDP_DEBUG_SYNC)) \
153 log_debug("sync: " emsg, __VA_ARGS__); \
154 } while (0)
155
156 #endif /* _LDP_DEBUG_H_ */