]> git.proxmox.com Git - mirror_frr.git/blob - ldpd/ldp_debug.h
Merge branch 'stable/3.0' into tmp-3.0-master-merge
[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 msg;
35 #define LDP_DEBUG_MSG_RECV 0x01
36 #define LDP_DEBUG_MSG_RECV_ALL 0x02
37 #define LDP_DEBUG_MSG_SEND 0x04
38 #define LDP_DEBUG_MSG_SEND_ALL 0x08
39
40 int zebra;
41 #define LDP_DEBUG_ZEBRA 0x01
42 };
43 extern struct ldp_debug conf_ldp_debug;
44 extern struct ldp_debug ldp_debug;
45
46 #define CONF_DEBUG_ON(a, b) (conf_ldp_debug.a |= (LDP_DEBUG_ ## b))
47 #define CONF_DEBUG_OFF(a, b) (conf_ldp_debug.a &= ~(LDP_DEBUG_ ## b))
48
49 #define TERM_DEBUG_ON(a, b) (ldp_debug.a |= (LDP_DEBUG_ ## b))
50 #define TERM_DEBUG_OFF(a, b) (ldp_debug.a &= ~(LDP_DEBUG_ ## b))
51
52 #define DEBUG_ON(a, b) \
53 do { \
54 if (vty->node == CONFIG_NODE) { \
55 CONF_DEBUG_ON(a, b); \
56 TERM_DEBUG_ON(a, b); \
57 } else \
58 TERM_DEBUG_ON(a, b); \
59 } while (0)
60 #define DEBUG_OFF(a, b) \
61 do { \
62 CONF_DEBUG_OFF(a, b); \
63 TERM_DEBUG_OFF(a, b); \
64 } while (0)
65
66 #define LDP_DEBUG(a, b) (ldp_debug.a & LDP_DEBUG_ ## b)
67 #define CONF_LDP_DEBUG(a, b) (conf_ldp_debug.a & LDP_DEBUG_ ## b)
68
69 #define debug_hello_recv(emsg, ...) \
70 do { \
71 if (LDP_DEBUG(hello, HELLO_RECV)) \
72 log_debug("discovery[recv]: " emsg, __VA_ARGS__); \
73 } while (0)
74
75 #define debug_hello_send(emsg, ...) \
76 do { \
77 if (LDP_DEBUG(hello, HELLO_SEND)) \
78 log_debug("discovery[send]: " emsg, __VA_ARGS__); \
79 } while (0)
80
81 #define debug_err(emsg, ...) \
82 do { \
83 if (LDP_DEBUG(errors, ERRORS)) \
84 log_debug("error: " emsg, __VA_ARGS__); \
85 } while (0)
86
87 #define debug_evt(emsg, ...) \
88 do { \
89 if (LDP_DEBUG(event, EVENT)) \
90 log_debug("event: " emsg, __VA_ARGS__); \
91 } while (0)
92
93 #define debug_msg_recv(emsg, ...) \
94 do { \
95 if (LDP_DEBUG(msg, MSG_RECV)) \
96 log_debug("msg[in]: " emsg, __VA_ARGS__); \
97 } while (0)
98
99 #define debug_msg_send(emsg, ...) \
100 do { \
101 if (LDP_DEBUG(msg, MSG_SEND)) \
102 log_debug("msg[out]: " emsg, __VA_ARGS__); \
103 } while (0)
104
105 #define debug_msg(out, emsg, ...) \
106 do { \
107 if (out) \
108 debug_msg_send(emsg, __VA_ARGS__); \
109 else \
110 debug_msg_recv(emsg, __VA_ARGS__); \
111 } while (0)
112
113 #define debug_kalive_recv(emsg, ...) \
114 do { \
115 if (LDP_DEBUG(msg, MSG_RECV_ALL)) \
116 log_debug("kalive[in]: " emsg, __VA_ARGS__); \
117 } while (0)
118
119 #define debug_kalive_send(emsg, ...) \
120 do { \
121 if (LDP_DEBUG(msg, MSG_SEND_ALL)) \
122 log_debug("kalive[out]: " emsg, __VA_ARGS__); \
123 } while (0)
124
125 #define debug_zebra_in(emsg, ...) \
126 do { \
127 if (LDP_DEBUG(zebra, ZEBRA)) \
128 log_debug("zebra[in]: " emsg, __VA_ARGS__); \
129 } while (0)
130
131 #define debug_zebra_out(emsg, ...) \
132 do { \
133 if (LDP_DEBUG(zebra, ZEBRA)) \
134 log_debug("zebra[out]: " emsg, __VA_ARGS__); \
135 } while (0)
136
137 #endif /* _LDP_DEBUG_H_ */