]> git.proxmox.com Git - mirror_frr.git/blame_incremental - ldpd/ldp_debug.h
zebra: Convert socket interface to use `union sockunion`
[mirror_frr.git] / ldpd / ldp_debug.h
... / ...
CommitLineData
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
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
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};
46extern struct ldp_debug conf_ldp_debug;
47extern struct ldp_debug ldp_debug;
48
49#define CONF_DEBUG_ON(a, b) (conf_ldp_debug.a |= (b))
50#define CONF_DEBUG_OFF(a, b) (conf_ldp_debug.a &= ~(b))
51
52#define TERM_DEBUG_ON(a, b) (ldp_debug.a |= (b))
53#define TERM_DEBUG_OFF(a, b) (ldp_debug.a &= ~(b))
54
55#define DEBUG_ON(a, b) \
56 do { \
57 if (vty->node == CONFIG_NODE) { \
58 CONF_DEBUG_ON(a, b); \
59 TERM_DEBUG_ON(a, b); \
60 } else \
61 TERM_DEBUG_ON(a, b); \
62 } while (0)
63#define DEBUG_OFF(a, b) \
64 do { \
65 CONF_DEBUG_OFF(a, b); \
66 TERM_DEBUG_OFF(a, b); \
67 } while (0)
68
69#define LDP_DEBUG(a, b) (ldp_debug.a & b)
70#define CONF_LDP_DEBUG(a, b) (conf_ldp_debug.a & b)
71
72#define debug_hello_recv(emsg, ...) \
73do { \
74 if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_RECV)) \
75 log_debug("discovery[recv]: " emsg, __VA_ARGS__); \
76} while (0)
77
78#define debug_hello_send(emsg, ...) \
79do { \
80 if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_SEND)) \
81 log_debug("discovery[send]: " emsg, __VA_ARGS__); \
82} while (0)
83
84#define debug_err(emsg, ...) \
85do { \
86 if (LDP_DEBUG(errors, LDP_DEBUG_ERRORS)) \
87 log_debug("error: " emsg, __VA_ARGS__); \
88} while (0)
89
90#define debug_evt(emsg, ...) \
91do { \
92 if (LDP_DEBUG(event, LDP_DEBUG_EVENT)) \
93 log_debug("event: " emsg, __VA_ARGS__); \
94} while (0)
95
96#define debug_labels(emsg, ...) \
97do { \
98 if (LDP_DEBUG(labels, LDP_DEBUG_LABELS)) \
99 log_debug("labels: " emsg, __VA_ARGS__); \
100} while (0)
101
102#define debug_msg_recv(emsg, ...) \
103do { \
104 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV)) \
105 log_debug("msg[in]: " emsg, __VA_ARGS__); \
106} while (0)
107
108#define debug_msg_send(emsg, ...) \
109do { \
110 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND)) \
111 log_debug("msg[out]: " emsg, __VA_ARGS__); \
112} while (0)
113
114#define debug_msg(out, emsg, ...) \
115do { \
116 if (out) \
117 debug_msg_send(emsg, __VA_ARGS__); \
118 else \
119 debug_msg_recv(emsg, __VA_ARGS__); \
120} while (0)
121
122#define debug_kalive_recv(emsg, ...) \
123do { \
124 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV_ALL)) \
125 log_debug("kalive[in]: " emsg, __VA_ARGS__); \
126} while (0)
127
128#define debug_kalive_send(emsg, ...) \
129do { \
130 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND_ALL)) \
131 log_debug("kalive[out]: " emsg, __VA_ARGS__); \
132} while (0)
133
134#define debug_zebra_in(emsg, ...) \
135do { \
136 if (LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA)) \
137 log_debug("zebra[in]: " emsg, __VA_ARGS__); \
138} while (0)
139
140#define debug_zebra_out(emsg, ...) \
141do { \
142 if (LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA)) \
143 log_debug("zebra[out]: " emsg, __VA_ARGS__); \
144} while (0)
145
146#endif /* _LDP_DEBUG_H_ */