1/* RIP debug routines 2 * Copyright (C) 1999 Kunihiro Ishiguro <kunihiro@zebra.org> 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#ifdef FOX_RIP_DEBUG 23 24#include <zebra.h> 25#include "command.h" 26#include "ripd/rip_debug.h" 27 28/* For debug statement. */ 29unsigned long rip_debug_event = 0; 30unsigned long rip_debug_packet = 0; 31unsigned long rip_debug_zebra = 0; 32 33DEFUN (show_debugging_rip, 34 show_debugging_rip_cmd, 35 "show debugging rip", 36 SHOW_STR 37 DEBUG_STR 38 RIP_STR) 39{ 40 vty_out (vty, "Zebra debugging status:%s", VTY_NEWLINE); 41 42 if (IS_RIP_DEBUG_EVENT) 43 vty_out (vty, " RIP event debugging is on%s", VTY_NEWLINE); 44 45 if (IS_RIP_DEBUG_PACKET) 46 { 47 if (IS_RIP_DEBUG_SEND && IS_RIP_DEBUG_RECV) 48 { 49 vty_out (vty, " RIP packet%s debugging is on%s", 50 IS_RIP_DEBUG_DETAIL ? " detail" : "", 51 VTY_NEWLINE); 52 } 53 else 54 { 55 if (IS_RIP_DEBUG_SEND) 56 vty_out (vty, " RIP packet send%s debugging is on%s", 57 IS_RIP_DEBUG_DETAIL ? " detail" : "", 58 VTY_NEWLINE); 59 else 60 vty_out (vty, " RIP packet receive%s debugging is on%s", 61 IS_RIP_DEBUG_DETAIL ? " detail" : "", 62 VTY_NEWLINE); 63 } 64 } 65 66 if (IS_RIP_DEBUG_ZEBRA) 67 vty_out (vty, " RIP zebra debugging is on%s", VTY_NEWLINE); 68 69 return CMD_SUCCESS; 70} 71 72DEFUN (debug_rip_events, 73 debug_rip_events_cmd, 74 "debug rip events", 75 DEBUG_STR 76 RIP_STR 77 "RIP events\n") 78{ 79 rip_debug_event = RIP_DEBUG_EVENT; 80 return CMD_WARNING; 81} 82 83DEFUN (debug_rip_packet, 84 debug_rip_packet_cmd, 85 "debug rip packet", 86 DEBUG_STR 87 RIP_STR 88 "RIP packet\n") 89{ 90 rip_debug_packet = RIP_DEBUG_PACKET; 91 rip_debug_packet |= RIP_DEBUG_SEND; 92 rip_debug_packet |= RIP_DEBUG_RECV; 93 return CMD_SUCCESS; 94} 95 96DEFUN (debug_rip_packet_direct, 97 debug_rip_packet_direct_cmd, 98 "debug rip packet (recv|send)", 99 DEBUG_STR 100 RIP_STR 101 "RIP packet\n" 102 "RIP receive packet\n" 103 "RIP send packet\n") 104{ 105 rip_debug_packet |= RIP_DEBUG_PACKET; 106 if (strncmp ("send", argv[0], strlen (argv[0])) == 0) 107 rip_debug_packet |= RIP_DEBUG_SEND; 108 if (strncmp ("recv", argv[0], strlen (argv[0])) == 0) 109 rip_debug_packet |= RIP_DEBUG_RECV; 110 rip_debug_packet &= ~RIP_DEBUG_DETAIL; 111 return CMD_SUCCESS; 112} 113 114DEFUN (debug_rip_packet_detail, 115 debug_rip_packet_detail_cmd, 116 "debug rip packet (recv|send) detail", 117 DEBUG_STR 118 RIP_STR 119 "RIP packet\n" 120 "RIP receive packet\n" 121 "RIP send packet\n" 122 "Detailed information display\n") 123{ 124 rip_debug_packet |= RIP_DEBUG_PACKET; 125 if (strncmp ("send", argv[0], strlen (argv[0])) == 0) 126 rip_debug_packet |= RIP_DEBUG_SEND; 127 if (strncmp ("recv", argv[0], strlen (argv[0])) == 0) 128 rip_debug_packet |= RIP_DEBUG_RECV; 129 rip_debug_packet |= RIP_DEBUG_DETAIL; 130 return CMD_SUCCESS; 131} 132 133DEFUN (debug_rip_zebra, 134 debug_rip_zebra_cmd, 135 "debug rip zebra", 136 DEBUG_STR 137 RIP_STR 138 "RIP and ZEBRA communication\n") 139{ 140 rip_debug_zebra = RIP_DEBUG_ZEBRA; 141 return CMD_WARNING; 142} 143 144DEFUN (no_debug_rip_events, 145 no_debug_rip_events_cmd, 146 "no debug rip events", 147 NO_STR 148 DEBUG_STR 149 RIP_STR 150 "RIP events\n") 151{ 152 rip_debug_event = 0; 153 return CMD_SUCCESS; 154} 155 156DEFUN (no_debug_rip_packet, 157 no_debug_rip_packet_cmd, 158 "no debug rip packet", 159 NO_STR 160 DEBUG_STR 161 RIP_STR 162 "RIP packet\n") 163{ 164 rip_debug_packet = 0; 165 return CMD_SUCCESS; 166} 167 168DEFUN (no_debug_rip_packet_direct, 169 no_debug_rip_packet_direct_cmd, 170 "no debug rip packet (recv|send)", 171 NO_STR 172 DEBUG_STR 173 RIP_STR 174 "RIP packet\n" 175 "RIP option set for receive packet\n" 176 "RIP option set for send packet\n") 177{ 178 if (strncmp ("send", argv[0], strlen (argv[0])) == 0) 179 { 180 if (IS_RIP_DEBUG_RECV) 181 rip_debug_packet &= ~RIP_DEBUG_SEND; 182 else 183 rip_debug_packet = 0; 184 } 185 else if (strncmp ("recv", argv[0], strlen (argv[0])) == 0) 186 { 187 if (IS_RIP_DEBUG_SEND) 188 rip_debug_packet &= ~RIP_DEBUG_RECV; 189 else 190 rip_debug_packet = 0; 191 } 192 return CMD_SUCCESS; 193} 194 195DEFUN (no_debug_rip_zebra, 196 no_debug_rip_zebra_cmd, 197 "no debug rip zebra", 198 NO_STR 199 DEBUG_STR 200 RIP_STR 201 "RIP and ZEBRA communication\n") 202{ 203 rip_debug_zebra = 0; 204 return CMD_WARNING; 205} 206 207/* Debug node. */ 208struct cmd_node debug_node = 209{ 210 DEBUG_NODE, 211 "", /* Debug node has no interface. */ 212 1 213}; 214 215int 216config_write_debug (struct vty *vty) 217{ 218 int write = 0; 219 220 if (IS_RIP_DEBUG_EVENT) 221 { 222 vty_out (vty, "debug rip events%s", VTY_NEWLINE); 223 write++; 224 } 225 if (IS_RIP_DEBUG_PACKET) 226 { 227 if (IS_RIP_DEBUG_SEND && IS_RIP_DEBUG_RECV) 228 { 229 vty_out (vty, "debug rip packet%s%s", 230 IS_RIP_DEBUG_DETAIL ? " detail" : "", 231 VTY_NEWLINE); 232 write++; 233 } 234 else 235 { 236 if (IS_RIP_DEBUG_SEND) 237 vty_out (vty, "debug rip packet send%s%s", 238 IS_RIP_DEBUG_DETAIL ? " detail" : "", 239 VTY_NEWLINE); 240 else 241 vty_out (vty, "debug rip packet recv%s%s", 242 IS_RIP_DEBUG_DETAIL ? " detail" : "", 243 VTY_NEWLINE); 244 write++; 245 } 246 } 247 if (IS_RIP_DEBUG_ZEBRA) 248 { 249 vty_out (vty, "debug rip zebra%s", VTY_NEWLINE); 250 write++; 251 } 252 return write; 253} 254 255void 256rip_debug_reset () 257{ 258 rip_debug_event = 0; 259 rip_debug_packet = 0; 260 rip_debug_zebra = 0; 261} 262 263void 264rip_debug_init () 265{ 266 rip_debug_event = 0; 267 rip_debug_packet = 0; 268 rip_debug_zebra = 0; 269 270 install_node (&debug_node, config_write_debug); 271 272#ifdef FOX_CMD_SUPPORT 273 install_element (ENABLE_NODE, &show_debugging_rip_cmd); 274#endif /* FOX_CMD_SUPPORT */ 275 install_element (ENABLE_NODE, &debug_rip_events_cmd); 276 install_element (ENABLE_NODE, &debug_rip_packet_cmd); 277 install_element (ENABLE_NODE, &debug_rip_packet_direct_cmd); 278 install_element (ENABLE_NODE, &debug_rip_packet_detail_cmd); 279 install_element (ENABLE_NODE, &debug_rip_zebra_cmd); 280 install_element (ENABLE_NODE, &no_debug_rip_events_cmd); 281 install_element (ENABLE_NODE, &no_debug_rip_packet_cmd); 282 install_element (ENABLE_NODE, &no_debug_rip_packet_direct_cmd); 283 install_element (ENABLE_NODE, &no_debug_rip_zebra_cmd); 284 285 install_element (CONFIG_NODE, &debug_rip_events_cmd); 286 install_element (CONFIG_NODE, &debug_rip_packet_cmd); 287 install_element (CONFIG_NODE, &debug_rip_packet_direct_cmd); 288 install_element (CONFIG_NODE, &debug_rip_packet_detail_cmd); 289 install_element (CONFIG_NODE, &debug_rip_zebra_cmd); 290 install_element (CONFIG_NODE, &no_debug_rip_events_cmd); 291 install_element (CONFIG_NODE, &no_debug_rip_packet_cmd); 292 install_element (CONFIG_NODE, &no_debug_rip_packet_direct_cmd); 293 install_element (CONFIG_NODE, &no_debug_rip_zebra_cmd); 294} 295#endif /* FOX_RIP_DEBUG */ 296