back to topotato report
topotato coverage report
Current view: top level - ripd - rip_debug.c (source / functions) Hit Total Coverage
Test: test_rip.py::RIPBasic Lines: 23 93 24.7 %
Date: 2023-02-24 18:39:46 Functions: 1 11 9.1 %

          Line data    Source code
       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 along
      17             :  * with this program; see the file COPYING; if not, write to the Free Software
      18             :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
      19             :  */
      20             : 
      21             : #include <zebra.h>
      22             : #include "command.h"
      23             : #include "ripd/rip_debug.h"
      24             : 
      25             : /* For debug statement. */
      26             : unsigned long rip_debug_event = 0;
      27             : unsigned long rip_debug_packet = 0;
      28             : unsigned long rip_debug_zebra = 0;
      29             : 
      30           0 : DEFUN_NOSH (show_debugging_rip,
      31             :             show_debugging_rip_cmd,
      32             :             "show debugging [rip]",
      33             :             SHOW_STR
      34             :             DEBUG_STR
      35             :             RIP_STR)
      36             : {
      37           0 :         vty_out(vty, "RIP debugging status:\n");
      38             : 
      39           0 :         if (IS_RIP_DEBUG_EVENT)
      40           0 :                 vty_out(vty, "  RIP event debugging is on\n");
      41             : 
      42           0 :         if (IS_RIP_DEBUG_PACKET) {
      43           0 :                 if (IS_RIP_DEBUG_SEND && IS_RIP_DEBUG_RECV) {
      44           0 :                         vty_out(vty, "  RIP packet debugging is on\n");
      45             :                 } else {
      46           0 :                         if (IS_RIP_DEBUG_SEND)
      47           0 :                                 vty_out(vty,
      48             :                                         "  RIP packet send debugging is on\n");
      49             :                         else
      50           0 :                                 vty_out(vty,
      51             :                                         "  RIP packet receive debugging is on\n");
      52             :                 }
      53             :         }
      54             : 
      55           0 :         if (IS_RIP_DEBUG_ZEBRA)
      56           0 :                 vty_out(vty, "  RIP zebra debugging is on\n");
      57             : 
      58           0 :         cmd_show_lib_debugs(vty);
      59             : 
      60           0 :         return CMD_SUCCESS;
      61             : }
      62             : 
      63           0 : DEFUN (debug_rip_events,
      64             :        debug_rip_events_cmd,
      65             :        "debug rip events",
      66             :        DEBUG_STR
      67             :        RIP_STR
      68             :        "RIP events\n")
      69             : {
      70           0 :         rip_debug_event = RIP_DEBUG_EVENT;
      71           0 :         return CMD_SUCCESS;
      72             : }
      73             : 
      74           0 : DEFUN (debug_rip_packet,
      75             :        debug_rip_packet_cmd,
      76             :        "debug rip packet",
      77             :        DEBUG_STR
      78             :        RIP_STR
      79             :        "RIP packet\n")
      80             : {
      81           0 :         rip_debug_packet = RIP_DEBUG_PACKET;
      82           0 :         rip_debug_packet |= RIP_DEBUG_SEND;
      83           0 :         rip_debug_packet |= RIP_DEBUG_RECV;
      84           0 :         return CMD_SUCCESS;
      85             : }
      86             : 
      87           0 : DEFUN (debug_rip_packet_direct,
      88             :        debug_rip_packet_direct_cmd,
      89             :        "debug rip packet <recv|send>",
      90             :        DEBUG_STR
      91             :        RIP_STR
      92             :        "RIP packet\n"
      93             :        "RIP receive packet\n"
      94             :        "RIP send packet\n")
      95             : {
      96           0 :         int idx_recv_send = 3;
      97           0 :         rip_debug_packet |= RIP_DEBUG_PACKET;
      98           0 :         if (strcmp("send", argv[idx_recv_send]->text) == 0)
      99           0 :                 rip_debug_packet |= RIP_DEBUG_SEND;
     100           0 :         if (strcmp("recv", argv[idx_recv_send]->text) == 0)
     101           0 :                 rip_debug_packet |= RIP_DEBUG_RECV;
     102           0 :         return CMD_SUCCESS;
     103             : }
     104             : 
     105           0 : DEFUN (debug_rip_zebra,
     106             :        debug_rip_zebra_cmd,
     107             :        "debug rip zebra",
     108             :        DEBUG_STR
     109             :        RIP_STR
     110             :        "RIP and ZEBRA communication\n")
     111             : {
     112           0 :         rip_debug_zebra = RIP_DEBUG_ZEBRA;
     113           0 :         return CMD_SUCCESS;
     114             : }
     115             : 
     116           0 : DEFUN (no_debug_rip_events,
     117             :        no_debug_rip_events_cmd,
     118             :        "no debug rip events",
     119             :        NO_STR
     120             :        DEBUG_STR
     121             :        RIP_STR
     122             :        "RIP events\n")
     123             : {
     124           0 :         rip_debug_event = 0;
     125           0 :         return CMD_SUCCESS;
     126             : }
     127             : 
     128           0 : DEFUN (no_debug_rip_packet,
     129             :        no_debug_rip_packet_cmd,
     130             :        "no debug rip packet",
     131             :        NO_STR
     132             :        DEBUG_STR
     133             :        RIP_STR
     134             :        "RIP packet\n")
     135             : {
     136           0 :         rip_debug_packet = 0;
     137           0 :         return CMD_SUCCESS;
     138             : }
     139             : 
     140           0 : DEFUN (no_debug_rip_packet_direct,
     141             :        no_debug_rip_packet_direct_cmd,
     142             :        "no debug rip packet <recv|send>",
     143             :        NO_STR
     144             :        DEBUG_STR
     145             :        RIP_STR
     146             :        "RIP packet\n"
     147             :        "RIP option set for receive packet\n"
     148             :        "RIP option set for send packet\n")
     149             : {
     150           0 :         int idx_recv_send = 4;
     151           0 :         if (strcmp("send", argv[idx_recv_send]->text) == 0) {
     152           0 :                 if (IS_RIP_DEBUG_RECV)
     153           0 :                         rip_debug_packet &= ~RIP_DEBUG_SEND;
     154             :                 else
     155           0 :                         rip_debug_packet = 0;
     156           0 :         } else if (strcmp("recv", argv[idx_recv_send]->text) == 0) {
     157           0 :                 if (IS_RIP_DEBUG_SEND)
     158           0 :                         rip_debug_packet &= ~RIP_DEBUG_RECV;
     159             :                 else
     160           0 :                         rip_debug_packet = 0;
     161             :         }
     162           0 :         return CMD_SUCCESS;
     163             : }
     164             : 
     165           0 : DEFUN (no_debug_rip_zebra,
     166             :        no_debug_rip_zebra_cmd,
     167             :        "no debug rip zebra",
     168             :        NO_STR
     169             :        DEBUG_STR
     170             :        RIP_STR
     171             :        "RIP and ZEBRA communication\n")
     172             : {
     173           0 :         rip_debug_zebra = 0;
     174           0 :         return CMD_SUCCESS;
     175             : }
     176             : 
     177             : static int config_write_debug(struct vty *vty);
     178             : /* Debug node. */
     179             : static struct cmd_node debug_node = {
     180             :         .name = "debug",
     181             :         .node = DEBUG_NODE,
     182             :         .prompt = "",
     183             :         .config_write = config_write_debug,
     184             : };
     185             : 
     186           0 : static int config_write_debug(struct vty *vty)
     187             : {
     188           0 :         int write = 0;
     189             : 
     190           0 :         if (IS_RIP_DEBUG_EVENT) {
     191           0 :                 vty_out(vty, "debug rip events\n");
     192           0 :                 write++;
     193             :         }
     194           0 :         if (IS_RIP_DEBUG_PACKET) {
     195           0 :                 if (IS_RIP_DEBUG_SEND && IS_RIP_DEBUG_RECV) {
     196           0 :                         vty_out(vty, "debug rip packet\n");
     197           0 :                         write++;
     198             :                 } else {
     199           0 :                         if (IS_RIP_DEBUG_SEND)
     200           0 :                                 vty_out(vty, "debug rip packet send\n");
     201             :                         else
     202           0 :                                 vty_out(vty, "debug rip packet recv\n");
     203           0 :                         write++;
     204             :                 }
     205             :         }
     206           0 :         if (IS_RIP_DEBUG_ZEBRA) {
     207           0 :                 vty_out(vty, "debug rip zebra\n");
     208           0 :                 write++;
     209             :         }
     210           0 :         return write;
     211             : }
     212             : 
     213           4 : void rip_debug_init(void)
     214             : {
     215           4 :         rip_debug_event = 0;
     216           4 :         rip_debug_packet = 0;
     217           4 :         rip_debug_zebra = 0;
     218             : 
     219           4 :         install_node(&debug_node);
     220             : 
     221           4 :         install_element(ENABLE_NODE, &show_debugging_rip_cmd);
     222           4 :         install_element(ENABLE_NODE, &debug_rip_events_cmd);
     223           4 :         install_element(ENABLE_NODE, &debug_rip_packet_cmd);
     224           4 :         install_element(ENABLE_NODE, &debug_rip_packet_direct_cmd);
     225           4 :         install_element(ENABLE_NODE, &debug_rip_zebra_cmd);
     226           4 :         install_element(ENABLE_NODE, &no_debug_rip_events_cmd);
     227           4 :         install_element(ENABLE_NODE, &no_debug_rip_packet_cmd);
     228           4 :         install_element(ENABLE_NODE, &no_debug_rip_packet_direct_cmd);
     229           4 :         install_element(ENABLE_NODE, &no_debug_rip_zebra_cmd);
     230             : 
     231           4 :         install_element(CONFIG_NODE, &debug_rip_events_cmd);
     232           4 :         install_element(CONFIG_NODE, &debug_rip_packet_cmd);
     233           4 :         install_element(CONFIG_NODE, &debug_rip_packet_direct_cmd);
     234           4 :         install_element(CONFIG_NODE, &debug_rip_zebra_cmd);
     235           4 :         install_element(CONFIG_NODE, &no_debug_rip_events_cmd);
     236           4 :         install_element(CONFIG_NODE, &no_debug_rip_packet_cmd);
     237           4 :         install_element(CONFIG_NODE, &no_debug_rip_packet_direct_cmd);
     238           4 :         install_element(CONFIG_NODE, &no_debug_rip_zebra_cmd);
     239           4 : }

Generated by: LCOV version v1.16-topotato