]>
Commit | Line | Data |
---|---|---|
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 | ||
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 | ||
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 | |
45 | }; | |
46 | extern struct ldp_debug conf_ldp_debug; | |
47 | extern struct ldp_debug ldp_debug; | |
48 | ||
77518251 DS |
49 | #define CONF_DEBUG_ON(a, b) (conf_ldp_debug.a |= (b)) |
50 | #define CONF_DEBUG_OFF(a, b) (conf_ldp_debug.a &= ~(b)) | |
eac6e3f0 | 51 | |
77518251 DS |
52 | #define TERM_DEBUG_ON(a, b) (ldp_debug.a |= (b)) |
53 | #define TERM_DEBUG_OFF(a, b) (ldp_debug.a &= ~(b)) | |
eac6e3f0 RW |
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 | ||
77518251 DS |
69 | #define LDP_DEBUG(a, b) (ldp_debug.a & b) |
70 | #define CONF_LDP_DEBUG(a, b) (conf_ldp_debug.a & b) | |
eac6e3f0 RW |
71 | |
72 | #define debug_hello_recv(emsg, ...) \ | |
73 | do { \ | |
77518251 | 74 | if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_RECV)) \ |
eac6e3f0 RW |
75 | log_debug("discovery[recv]: " emsg, __VA_ARGS__); \ |
76 | } while (0) | |
77 | ||
78 | #define debug_hello_send(emsg, ...) \ | |
79 | do { \ | |
77518251 | 80 | if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_SEND)) \ |
eac6e3f0 RW |
81 | log_debug("discovery[send]: " emsg, __VA_ARGS__); \ |
82 | } while (0) | |
83 | ||
84 | #define debug_err(emsg, ...) \ | |
85 | do { \ | |
77518251 | 86 | if (LDP_DEBUG(errors, LDP_DEBUG_ERRORS)) \ |
eac6e3f0 RW |
87 | log_debug("error: " emsg, __VA_ARGS__); \ |
88 | } while (0) | |
89 | ||
90 | #define debug_evt(emsg, ...) \ | |
91 | do { \ | |
77518251 | 92 | if (LDP_DEBUG(event, LDP_DEBUG_EVENT)) \ |
eac6e3f0 RW |
93 | log_debug("event: " emsg, __VA_ARGS__); \ |
94 | } while (0) | |
95 | ||
08e4b244 RW |
96 | #define debug_labels(emsg, ...) \ |
97 | do { \ | |
77518251 | 98 | if (LDP_DEBUG(labels, LDP_DEBUG_LABELS)) \ |
08e4b244 RW |
99 | log_debug("labels: " emsg, __VA_ARGS__); \ |
100 | } while (0) | |
101 | ||
eac6e3f0 RW |
102 | #define debug_msg_recv(emsg, ...) \ |
103 | do { \ | |
77518251 | 104 | if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV)) \ |
eac6e3f0 RW |
105 | log_debug("msg[in]: " emsg, __VA_ARGS__); \ |
106 | } while (0) | |
107 | ||
108 | #define debug_msg_send(emsg, ...) \ | |
109 | do { \ | |
77518251 | 110 | if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND)) \ |
eac6e3f0 RW |
111 | log_debug("msg[out]: " emsg, __VA_ARGS__); \ |
112 | } while (0) | |
113 | ||
faf75793 RW |
114 | #define debug_msg(out, emsg, ...) \ |
115 | do { \ | |
116 | if (out) \ | |
117 | debug_msg_send(emsg, __VA_ARGS__); \ | |
118 | else \ | |
119 | debug_msg_recv(emsg, __VA_ARGS__); \ | |
120 | } while (0) | |
121 | ||
eac6e3f0 RW |
122 | #define debug_kalive_recv(emsg, ...) \ |
123 | do { \ | |
77518251 | 124 | if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV_ALL)) \ |
eac6e3f0 RW |
125 | log_debug("kalive[in]: " emsg, __VA_ARGS__); \ |
126 | } while (0) | |
127 | ||
128 | #define debug_kalive_send(emsg, ...) \ | |
129 | do { \ | |
77518251 | 130 | if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND_ALL)) \ |
eac6e3f0 RW |
131 | log_debug("kalive[out]: " emsg, __VA_ARGS__); \ |
132 | } while (0) | |
133 | ||
134 | #define debug_zebra_in(emsg, ...) \ | |
135 | do { \ | |
77518251 | 136 | if (LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA)) \ |
eac6e3f0 RW |
137 | log_debug("zebra[in]: " emsg, __VA_ARGS__); \ |
138 | } while (0) | |
139 | ||
140 | #define debug_zebra_out(emsg, ...) \ | |
141 | do { \ | |
77518251 | 142 | if (LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA)) \ |
eac6e3f0 RW |
143 | log_debug("zebra[out]: " emsg, __VA_ARGS__); \ |
144 | } while (0) | |
145 | ||
146 | #endif /* _LDP_DEBUG_H_ */ |