back to topotato report
topotato coverage report
Current view: top level - ripngd - ripng_debug.c (source / functions) Hit Total Coverage
Test: aggregated run ( view descriptions ) Lines: 29 93 31.2 %
Date: 2023-02-24 14:41:08 Functions: 3 11 27.3 %

          Line data    Source code
       1             : /*
       2             :  * RIPng debug output routines
       3             :  * Copyright (C) 1998 Kunihiro Ishiguro
       4             :  *
       5             :  * This file is part of GNU Zebra.
       6             :  *
       7             :  * GNU Zebra is free software; you can redistribute it and/or modify it
       8             :  * under the terms of the GNU General Public License as published by the
       9             :  * Free Software Foundation; either version 2, or (at your option) any
      10             :  * later version.
      11             :  *
      12             :  * GNU Zebra is distributed in the hope that it will be useful, but
      13             :  * WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15             :  * General Public License for more details.
      16             :  *
      17             :  * You should have received a copy of the GNU General Public License along
      18             :  * with this program; see the file COPYING; if not, write to the Free Software
      19             :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
      20             :  */
      21             : 
      22             : #include <zebra.h>
      23             : #include "command.h"
      24             : #include "ripngd/ripng_debug.h"
      25             : 
      26             : /* For debug statement. */
      27             : unsigned long ripng_debug_event = 0;
      28             : unsigned long ripng_debug_packet = 0;
      29             : unsigned long ripng_debug_zebra = 0;
      30             : 
      31           0 : DEFUN_NOSH (show_debugging_ripng,
      32             :             show_debugging_ripng_cmd,
      33             :             "show debugging [ripng]",
      34             :             SHOW_STR
      35             :             DEBUG_STR
      36             :             "RIPng configuration\n")
      37             : {
      38           0 :         vty_out(vty, "RIPng debugging status:\n");
      39             : 
      40           0 :         if (IS_RIPNG_DEBUG_EVENT)
      41           0 :                 vty_out(vty, "  RIPng event debugging is on\n");
      42             : 
      43           0 :         if (IS_RIPNG_DEBUG_PACKET) {
      44           0 :                 if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV) {
      45           0 :                         vty_out(vty, "  RIPng packet debugging is on\n");
      46             :                 } else {
      47           0 :                         if (IS_RIPNG_DEBUG_SEND)
      48           0 :                                 vty_out(vty,
      49             :                                         "  RIPng packet send debugging is on\n");
      50             :                         else
      51           0 :                                 vty_out(vty,
      52             :                                         "  RIPng packet receive debugging is on\n");
      53             :                 }
      54             :         }
      55             : 
      56           0 :         if (IS_RIPNG_DEBUG_ZEBRA)
      57           0 :                 vty_out(vty, "  RIPng zebra debugging is on\n");
      58             : 
      59           0 :         cmd_show_lib_debugs(vty);
      60             : 
      61           0 :         return CMD_SUCCESS;
      62             : }
      63             : 
      64           1 : DEFUN (debug_ripng_events,
      65             :        debug_ripng_events_cmd,
      66             :        "debug ripng events",
      67             :        DEBUG_STR
      68             :        "RIPng configuration\n"
      69             :        "Debug option set for ripng events\n")
      70             : {
      71           1 :         ripng_debug_event = RIPNG_DEBUG_EVENT;
      72           1 :         return CMD_SUCCESS;
      73             : }
      74             : 
      75           0 : DEFUN (debug_ripng_packet,
      76             :        debug_ripng_packet_cmd,
      77             :        "debug ripng packet",
      78             :        DEBUG_STR
      79             :        "RIPng configuration\n"
      80             :        "Debug option set for ripng packet\n")
      81             : {
      82           0 :         ripng_debug_packet = RIPNG_DEBUG_PACKET;
      83           0 :         ripng_debug_packet |= RIPNG_DEBUG_SEND;
      84           0 :         ripng_debug_packet |= RIPNG_DEBUG_RECV;
      85           0 :         return CMD_SUCCESS;
      86             : }
      87             : 
      88           0 : DEFUN (debug_ripng_packet_direct,
      89             :        debug_ripng_packet_direct_cmd,
      90             :        "debug ripng packet <recv|send>",
      91             :        DEBUG_STR
      92             :        "RIPng configuration\n"
      93             :        "Debug option set for ripng packet\n"
      94             :        "Debug option set for receive packet\n"
      95             :        "Debug option set for send packet\n")
      96             : {
      97           0 :         int idx_recv_send = 3;
      98           0 :         ripng_debug_packet |= RIPNG_DEBUG_PACKET;
      99           0 :         if (strcmp("send", argv[idx_recv_send]->text) == 0)
     100           0 :                 ripng_debug_packet |= RIPNG_DEBUG_SEND;
     101           0 :         if (strcmp("recv", argv[idx_recv_send]->text) == 0)
     102           0 :                 ripng_debug_packet |= RIPNG_DEBUG_RECV;
     103             : 
     104           0 :         return CMD_SUCCESS;
     105             : }
     106             : 
     107           1 : DEFUN (debug_ripng_zebra,
     108             :        debug_ripng_zebra_cmd,
     109             :        "debug ripng zebra",
     110             :        DEBUG_STR
     111             :        "RIPng configuration\n"
     112             :        "Debug option set for ripng and zebra communication\n")
     113             : {
     114           1 :         ripng_debug_zebra = RIPNG_DEBUG_ZEBRA;
     115           1 :         return CMD_SUCCESS;
     116             : }
     117             : 
     118           0 : DEFUN (no_debug_ripng_events,
     119             :        no_debug_ripng_events_cmd,
     120             :        "no debug ripng events",
     121             :        NO_STR
     122             :        DEBUG_STR
     123             :        "RIPng configuration\n"
     124             :        "Debug option set for ripng events\n")
     125             : {
     126           0 :         ripng_debug_event = 0;
     127           0 :         return CMD_SUCCESS;
     128             : }
     129             : 
     130           0 : DEFUN (no_debug_ripng_packet,
     131             :        no_debug_ripng_packet_cmd,
     132             :        "no debug ripng packet",
     133             :        NO_STR
     134             :        DEBUG_STR
     135             :        "RIPng configuration\n"
     136             :        "Debug option set for ripng packet\n")
     137             : {
     138           0 :         ripng_debug_packet = 0;
     139           0 :         return CMD_SUCCESS;
     140             : }
     141             : 
     142           0 : DEFUN (no_debug_ripng_packet_direct,
     143             :        no_debug_ripng_packet_direct_cmd,
     144             :        "no debug ripng packet <recv|send>",
     145             :        NO_STR
     146             :        DEBUG_STR
     147             :        "RIPng configuration\n"
     148             :        "Debug option set for ripng packet\n"
     149             :        "Debug option set for receive packet\n"
     150             :        "Debug option set for send packet\n")
     151             : {
     152           0 :         int idx_recv_send = 4;
     153           0 :         if (strcmp("send", argv[idx_recv_send]->text) == 0) {
     154           0 :                 if (IS_RIPNG_DEBUG_RECV)
     155           0 :                         ripng_debug_packet &= ~RIPNG_DEBUG_SEND;
     156             :                 else
     157           0 :                         ripng_debug_packet = 0;
     158           0 :         } else if (strcmp("recv", argv[idx_recv_send]->text) == 0) {
     159           0 :                 if (IS_RIPNG_DEBUG_SEND)
     160           0 :                         ripng_debug_packet &= ~RIPNG_DEBUG_RECV;
     161             :                 else
     162           0 :                         ripng_debug_packet = 0;
     163             :         }
     164           0 :         return CMD_SUCCESS;
     165             : }
     166             : 
     167           0 : DEFUN (no_debug_ripng_zebra,
     168             :        no_debug_ripng_zebra_cmd,
     169             :        "no debug ripng zebra",
     170             :        NO_STR
     171             :        DEBUG_STR
     172             :        "RIPng configuration\n"
     173             :        "Debug option set for ripng and zebra communication\n")
     174             : {
     175           0 :         ripng_debug_zebra = 0;
     176           0 :         return CMD_SUCCESS;
     177             : }
     178             : 
     179             : static int config_write_debug(struct vty *vty);
     180             : /* Debug node. */
     181             : static struct cmd_node debug_node = {
     182             :         .name = "debug",
     183             :         .node = DEBUG_NODE,
     184             :         .prompt = "",
     185             :         .config_write = config_write_debug,
     186             : };
     187             : 
     188           0 : static int config_write_debug(struct vty *vty)
     189             : {
     190           0 :         int write = 0;
     191             : 
     192           0 :         if (IS_RIPNG_DEBUG_EVENT) {
     193           0 :                 vty_out(vty, "debug ripng events\n");
     194           0 :                 write++;
     195             :         }
     196           0 :         if (IS_RIPNG_DEBUG_PACKET) {
     197           0 :                 if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV) {
     198           0 :                         vty_out(vty, "debug ripng packet\n");
     199           0 :                         write++;
     200             :                 } else {
     201           0 :                         if (IS_RIPNG_DEBUG_SEND)
     202           0 :                                 vty_out(vty, "debug ripng packet send\n");
     203             :                         else
     204           0 :                                 vty_out(vty, "debug ripng packet recv\n");
     205           0 :                         write++;
     206             :                 }
     207             :         }
     208           0 :         if (IS_RIPNG_DEBUG_ZEBRA) {
     209           0 :                 vty_out(vty, "debug ripng zebra\n");
     210           0 :                 write++;
     211             :         }
     212           0 :         return write;
     213             : }
     214             : 
     215           1 : void ripng_debug_init(void)
     216             : {
     217           1 :         ripng_debug_event = 0;
     218           1 :         ripng_debug_packet = 0;
     219           1 :         ripng_debug_zebra = 0;
     220             : 
     221           1 :         install_node(&debug_node);
     222             : 
     223           1 :         install_element(ENABLE_NODE, &show_debugging_ripng_cmd);
     224             : 
     225           1 :         install_element(ENABLE_NODE, &debug_ripng_events_cmd);
     226           1 :         install_element(ENABLE_NODE, &debug_ripng_packet_cmd);
     227           1 :         install_element(ENABLE_NODE, &debug_ripng_packet_direct_cmd);
     228           1 :         install_element(ENABLE_NODE, &debug_ripng_zebra_cmd);
     229           1 :         install_element(ENABLE_NODE, &no_debug_ripng_events_cmd);
     230           1 :         install_element(ENABLE_NODE, &no_debug_ripng_packet_cmd);
     231           1 :         install_element(ENABLE_NODE, &no_debug_ripng_packet_direct_cmd);
     232           1 :         install_element(ENABLE_NODE, &no_debug_ripng_zebra_cmd);
     233             : 
     234           1 :         install_element(CONFIG_NODE, &debug_ripng_events_cmd);
     235           1 :         install_element(CONFIG_NODE, &debug_ripng_packet_cmd);
     236           1 :         install_element(CONFIG_NODE, &debug_ripng_packet_direct_cmd);
     237           1 :         install_element(CONFIG_NODE, &debug_ripng_zebra_cmd);
     238           1 :         install_element(CONFIG_NODE, &no_debug_ripng_events_cmd);
     239           1 :         install_element(CONFIG_NODE, &no_debug_ripng_packet_cmd);
     240           1 :         install_element(CONFIG_NODE, &no_debug_ripng_packet_direct_cmd);
     241           1 :         install_element(CONFIG_NODE, &no_debug_ripng_zebra_cmd);
     242           1 : }

Generated by: LCOV version v1.16-topotato