Annotation of embedaddon/quagga/ripd/rip_debug.c, revision 1.1

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>