]> git.proxmox.com Git - mirror_frr.git/blob - ldpd/ldp_debug.h
Merge branch 'frr/pull/250' ("bgpd, zebra: Add ifindex to NEXTHOP_TYPE_IPV4")
[mirror_frr.git] / ldpd / ldp_debug.h
1 /*
2 * Copyright (C) 2016 by Open Source Routing.
3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra 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
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 * 02111-1307, USA.
20 */
21
22 #ifndef _LDP_DEBUG_H_
23 #define _LDP_DEBUG_H_
24
25 struct ldp_debug {
26 int hello;
27 #define LDP_DEBUG_HELLO_RECV 0x01
28 #define LDP_DEBUG_HELLO_SEND 0x02
29
30 int errors;
31 #define LDP_DEBUG_ERRORS 0x01
32
33 int event;
34 #define LDP_DEBUG_EVENT 0x01
35
36 int msg;
37 #define LDP_DEBUG_MSG_RECV 0x01
38 #define LDP_DEBUG_MSG_RECV_ALL 0x02
39 #define LDP_DEBUG_MSG_SEND 0x04
40 #define LDP_DEBUG_MSG_SEND_ALL 0x08
41
42 int zebra;
43 #define LDP_DEBUG_ZEBRA 0x01
44 };
45 extern struct ldp_debug conf_ldp_debug;
46 extern struct ldp_debug ldp_debug;
47
48 #define CONF_DEBUG_ON(a, b) (conf_ldp_debug.a |= (LDP_DEBUG_ ## b))
49 #define CONF_DEBUG_OFF(a, b) (conf_ldp_debug.a &= ~(LDP_DEBUG_ ## b))
50
51 #define TERM_DEBUG_ON(a, b) (ldp_debug.a |= (LDP_DEBUG_ ## b))
52 #define TERM_DEBUG_OFF(a, b) (ldp_debug.a &= ~(LDP_DEBUG_ ## b))
53
54 #define DEBUG_ON(a, b) \
55 do { \
56 if (vty->node == CONFIG_NODE) { \
57 CONF_DEBUG_ON(a, b); \
58 TERM_DEBUG_ON(a, b); \
59 } else \
60 TERM_DEBUG_ON(a, b); \
61 } while (0)
62 #define DEBUG_OFF(a, b) \
63 do { \
64 CONF_DEBUG_OFF(a, b); \
65 TERM_DEBUG_OFF(a, b); \
66 } while (0)
67
68 #define LDP_DEBUG(a, b) (ldp_debug.a & LDP_DEBUG_ ## b)
69 #define CONF_LDP_DEBUG(a, b) (conf_ldp_debug.a & LDP_DEBUG_ ## b)
70
71 #define debug_hello_recv(emsg, ...) \
72 do { \
73 if (LDP_DEBUG(hello, HELLO_RECV)) \
74 log_debug("discovery[recv]: " emsg, __VA_ARGS__); \
75 } while (0)
76
77 #define debug_hello_send(emsg, ...) \
78 do { \
79 if (LDP_DEBUG(hello, HELLO_SEND)) \
80 log_debug("discovery[send]: " emsg, __VA_ARGS__); \
81 } while (0)
82
83 #define debug_err(emsg, ...) \
84 do { \
85 if (LDP_DEBUG(errors, ERRORS)) \
86 log_debug("error: " emsg, __VA_ARGS__); \
87 } while (0)
88
89 #define debug_evt(emsg, ...) \
90 do { \
91 if (LDP_DEBUG(event, EVENT)) \
92 log_debug("event: " emsg, __VA_ARGS__); \
93 } while (0)
94
95 #define debug_msg_recv(emsg, ...) \
96 do { \
97 if (LDP_DEBUG(msg, MSG_RECV)) \
98 log_debug("msg[in]: " emsg, __VA_ARGS__); \
99 } while (0)
100
101 #define debug_msg_send(emsg, ...) \
102 do { \
103 if (LDP_DEBUG(msg, MSG_SEND)) \
104 log_debug("msg[out]: " emsg, __VA_ARGS__); \
105 } while (0)
106
107 #define debug_msg(out, emsg, ...) \
108 do { \
109 if (out) \
110 debug_msg_send(emsg, __VA_ARGS__); \
111 else \
112 debug_msg_recv(emsg, __VA_ARGS__); \
113 } while (0)
114
115 #define debug_kalive_recv(emsg, ...) \
116 do { \
117 if (LDP_DEBUG(msg, MSG_RECV_ALL)) \
118 log_debug("kalive[in]: " emsg, __VA_ARGS__); \
119 } while (0)
120
121 #define debug_kalive_send(emsg, ...) \
122 do { \
123 if (LDP_DEBUG(msg, MSG_SEND_ALL)) \
124 log_debug("kalive[out]: " emsg, __VA_ARGS__); \
125 } while (0)
126
127 #define debug_zebra_in(emsg, ...) \
128 do { \
129 if (LDP_DEBUG(zebra, ZEBRA)) \
130 log_debug("zebra[in]: " emsg, __VA_ARGS__); \
131 } while (0)
132
133 #define debug_zebra_out(emsg, ...) \
134 do { \
135 if (LDP_DEBUG(zebra, ZEBRA)) \
136 log_debug("zebra[out]: " emsg, __VA_ARGS__); \
137 } while (0)
138
139 #endif /* _LDP_DEBUG_H_ */