]> git.proxmox.com Git - mirror_frr.git/blame - ldpd/ldp_debug.h
tools: improve explanation of 'wrap' options
[mirror_frr.git] / ldpd / ldp_debug.h
CommitLineData
eac6e3f0
RW
1/*
2 * Copyright (C) 2016 by Open Source Routing.
3 *
180fc2cd
RW
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.
eac6e3f0 8 *
180fc2cd 9 * This program is distributed in the hope that it will be useful, but
eac6e3f0
RW
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 *
180fc2cd
RW
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
eac6e3f0
RW
18 */
19
20#ifndef _LDP_DEBUG_H_
21#define _LDP_DEBUG_H_
22
23struct 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
08e4b244
RW
34 int labels;
35#define LDP_DEBUG_LABELS 0x01
36
eac6e3f0
RW
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
e1894ff7
KS
45
46 int sync;
47#define LDP_DEBUG_SYNC 0x01
48
eac6e3f0
RW
49};
50extern struct ldp_debug conf_ldp_debug;
51extern struct ldp_debug ldp_debug;
52
77518251
DS
53#define CONF_DEBUG_ON(a, b) (conf_ldp_debug.a |= (b))
54#define CONF_DEBUG_OFF(a, b) (conf_ldp_debug.a &= ~(b))
eac6e3f0 55
77518251
DS
56#define TERM_DEBUG_ON(a, b) (ldp_debug.a |= (b))
57#define TERM_DEBUG_OFF(a, b) (ldp_debug.a &= ~(b))
eac6e3f0
RW
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
77518251
DS
73#define LDP_DEBUG(a, b) (ldp_debug.a & b)
74#define CONF_LDP_DEBUG(a, b) (conf_ldp_debug.a & b)
eac6e3f0
RW
75
76#define debug_hello_recv(emsg, ...) \
77do { \
77518251 78 if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_RECV)) \
eac6e3f0
RW
79 log_debug("discovery[recv]: " emsg, __VA_ARGS__); \
80} while (0)
81
82#define debug_hello_send(emsg, ...) \
83do { \
77518251 84 if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_SEND)) \
eac6e3f0
RW
85 log_debug("discovery[send]: " emsg, __VA_ARGS__); \
86} while (0)
87
88#define debug_err(emsg, ...) \
89do { \
77518251 90 if (LDP_DEBUG(errors, LDP_DEBUG_ERRORS)) \
eac6e3f0
RW
91 log_debug("error: " emsg, __VA_ARGS__); \
92} while (0)
93
94#define debug_evt(emsg, ...) \
95do { \
77518251 96 if (LDP_DEBUG(event, LDP_DEBUG_EVENT)) \
eac6e3f0
RW
97 log_debug("event: " emsg, __VA_ARGS__); \
98} while (0)
99
08e4b244
RW
100#define debug_labels(emsg, ...) \
101do { \
77518251 102 if (LDP_DEBUG(labels, LDP_DEBUG_LABELS)) \
08e4b244
RW
103 log_debug("labels: " emsg, __VA_ARGS__); \
104} while (0)
105
eac6e3f0
RW
106#define debug_msg_recv(emsg, ...) \
107do { \
77518251 108 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV)) \
eac6e3f0
RW
109 log_debug("msg[in]: " emsg, __VA_ARGS__); \
110} while (0)
111
112#define debug_msg_send(emsg, ...) \
113do { \
77518251 114 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND)) \
eac6e3f0
RW
115 log_debug("msg[out]: " emsg, __VA_ARGS__); \
116} while (0)
117
faf75793
RW
118#define debug_msg(out, emsg, ...) \
119do { \
120 if (out) \
121 debug_msg_send(emsg, __VA_ARGS__); \
122 else \
123 debug_msg_recv(emsg, __VA_ARGS__); \
124} while (0)
125
eac6e3f0
RW
126#define debug_kalive_recv(emsg, ...) \
127do { \
77518251 128 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV_ALL)) \
eac6e3f0
RW
129 log_debug("kalive[in]: " emsg, __VA_ARGS__); \
130} while (0)
131
132#define debug_kalive_send(emsg, ...) \
133do { \
77518251 134 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND_ALL)) \
eac6e3f0
RW
135 log_debug("kalive[out]: " emsg, __VA_ARGS__); \
136} while (0)
137
138#define debug_zebra_in(emsg, ...) \
139do { \
77518251 140 if (LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA)) \
eac6e3f0
RW
141 log_debug("zebra[in]: " emsg, __VA_ARGS__); \
142} while (0)
143
144#define debug_zebra_out(emsg, ...) \
145do { \
77518251 146 if (LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA)) \
eac6e3f0
RW
147 log_debug("zebra[out]: " emsg, __VA_ARGS__); \
148} while (0)
149
e1894ff7
KS
150#define debug_evt_ldp_sync(emsg, ...) \
151do { \
152 if (LDP_DEBUG(sync, LDP_DEBUG_SYNC)) \
153 log_debug("sync: " emsg, __VA_ARGS__); \
154} while (0)
155
eac6e3f0 156#endif /* _LDP_DEBUG_H_ */