back to topotato report
topotato coverage report
Current view: top level - ospfd - ospf_dump_api.c (source / functions) Hit Total Coverage
Test: aggregated run ( view descriptions ) Lines: 4 16 25.0 %
Date: 2023-02-24 19:38:44 Functions: 1 2 50.0 %

          Line data    Source code
       1             : /*
       2             :  * OSPFd dump routine (parts used by ospfclient).
       3             :  * Copyright (C) 1999, 2000 Toshiaki Takada
       4             :  *
       5             :  * This file is part of FRRouting (FRR).
       6             :  *
       7             :  * FRR is free software; you can redistribute it and/or modify it under the
       8             :  * terms of the GNU General Public License as published by the Free Software
       9             :  * Foundation; either version 2, or (at your option) any later version.
      10             :  *
      11             :  * FRR is distributed in the hope that it will be useful, but WITHOUT ANY
      12             :  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      13             :  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
      14             :  * 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             : 
      23             : #include "log.h"
      24             : #include "prefix.h"
      25             : 
      26             : #include "ospf_dump_api.h"
      27             : #include "ospfd.h"
      28             : #include "ospf_asbr.h"
      29             : #include "ospf_lsa.h"
      30             : #include "ospf_nsm.h"
      31             : #include "ospf_ism.h"
      32             : 
      33             : const struct message ospf_ism_state_msg[] = {
      34             :         {ISM_DependUpon, "DependUpon"},
      35             :         {ISM_Down, "Down"},
      36             :         {ISM_Loopback, "Loopback"},
      37             :         {ISM_Waiting, "Waiting"},
      38             :         {ISM_PointToPoint, "Point-To-Point"},
      39             :         {ISM_DROther, "DROther"},
      40             :         {ISM_Backup, "Backup"},
      41             :         {ISM_DR, "DR"},
      42             :         {0}};
      43             : 
      44             : const struct message ospf_nsm_state_msg[] = {{NSM_DependUpon, "DependUpon"},
      45             :                                              {NSM_Deleted, "Deleted"},
      46             :                                              {NSM_Down, "Down"},
      47             :                                              {NSM_Attempt, "Attempt"},
      48             :                                              {NSM_Init, "Init"},
      49             :                                              {NSM_TwoWay, "2-Way"},
      50             :                                              {NSM_ExStart, "ExStart"},
      51             :                                              {NSM_Exchange, "Exchange"},
      52             :                                              {NSM_Loading, "Loading"},
      53             :                                              {NSM_Full, "Full"},
      54             :                                              {0}};
      55             : 
      56             : const struct message ospf_lsa_type_msg[] = {
      57             :         {OSPF_UNKNOWN_LSA, "unknown"},
      58             :         {OSPF_ROUTER_LSA, "router-LSA"},
      59             :         {OSPF_NETWORK_LSA, "network-LSA"},
      60             :         {OSPF_SUMMARY_LSA, "summary-LSA"},
      61             :         {OSPF_ASBR_SUMMARY_LSA, "summary-LSA"},
      62             :         {OSPF_AS_EXTERNAL_LSA, "AS-external-LSA"},
      63             :         {OSPF_GROUP_MEMBER_LSA, "GROUP MEMBER LSA"},
      64             :         {OSPF_AS_NSSA_LSA, "NSSA-LSA"},
      65             :         {8, "Type-8 LSA"},
      66             :         {OSPF_OPAQUE_LINK_LSA, "Link-Local Opaque-LSA"},
      67             :         {OSPF_OPAQUE_AREA_LSA, "Area-Local Opaque-LSA"},
      68             :         {OSPF_OPAQUE_AS_LSA, "AS-external Opaque-LSA"},
      69             :         {0}};
      70             : 
      71             : const struct message ospf_link_state_id_type_msg[] = {
      72             :         {OSPF_UNKNOWN_LSA, "(unknown)"},
      73             :         {OSPF_ROUTER_LSA, ""},
      74             :         {OSPF_NETWORK_LSA, "(address of Designated Router)"},
      75             :         {OSPF_SUMMARY_LSA, "(summary Network Number)"},
      76             :         {OSPF_ASBR_SUMMARY_LSA, "(AS Boundary Router address)"},
      77             :         {OSPF_AS_EXTERNAL_LSA, "(External Network Number)"},
      78             :         {OSPF_GROUP_MEMBER_LSA, "(Group membership information)"},
      79             :         {OSPF_AS_NSSA_LSA, "(External Network Number for NSSA)"},
      80             :         {8, "(Type-8 LSID)"},
      81             :         {OSPF_OPAQUE_LINK_LSA, "(Link-Local Opaque-Type/ID)"},
      82             :         {OSPF_OPAQUE_AREA_LSA, "(Area-Local Opaque-Type/ID)"},
      83             :         {OSPF_OPAQUE_AS_LSA, "(AS-external Opaque-Type/ID)"},
      84             :         {0}};
      85             : 
      86             : const struct message ospf_network_type_msg[] = {
      87             :         {OSPF_IFTYPE_NONE, "NONE"},
      88             :         {OSPF_IFTYPE_POINTOPOINT, "Point-to-Point"},
      89             :         {OSPF_IFTYPE_BROADCAST, "Broadcast"},
      90             :         {OSPF_IFTYPE_NBMA, "NBMA"},
      91             :         {OSPF_IFTYPE_POINTOMULTIPOINT, "Point-to-MultiPoint"},
      92             :         {OSPF_IFTYPE_VIRTUALLINK, "Virtual-Link"},
      93             :         {0}};
      94             : 
      95             : /* AuType */
      96             : const struct message ospf_auth_type_str[] = {
      97             :         {OSPF_AUTH_NULL, "Null"},
      98             :         {OSPF_AUTH_SIMPLE, "Simple"},
      99             :         {OSPF_AUTH_CRYPTOGRAPHIC, "Cryptographic"},
     100             :         {0}};
     101             : 
     102             : #define OSPF_OPTION_STR_MAXLEN          24
     103             : 
     104          94 : char *ospf_options_dump(uint8_t options)
     105             : {
     106          94 :         static char buf[OSPF_OPTION_STR_MAXLEN];
     107             : 
     108         564 :         snprintf(buf, sizeof(buf), "*|%s|%s|%s|%s|%s|%s|%s",
     109             :                  (options & OSPF_OPTION_O) ? "O" : "-",
     110             :                  (options & OSPF_OPTION_DC) ? "DC" : "-",
     111             :                  (options & OSPF_OPTION_EA) ? "EA" : "-",
     112             :                  (options & OSPF_OPTION_NP) ? "N/P" : "-",
     113             :                  (options & OSPF_OPTION_MC) ? "MC" : "-",
     114             :                  (options & OSPF_OPTION_E) ? "E" : "-",
     115             :                  (options & OSPF_OPTION_MT) ? "M/T" : "-");
     116             : 
     117          94 :         return buf;
     118             : }
     119             : 
     120           0 : void ospf_lsa_header_dump(struct lsa_header *lsah)
     121             : {
     122           0 :         const char *lsah_type = lookup_msg(ospf_lsa_type_msg, lsah->type, NULL);
     123             : 
     124           0 :         zlog_debug("  LSA Header");
     125           0 :         zlog_debug("    LS age %d", ntohs(lsah->ls_age));
     126           0 :         zlog_debug("    Options %d (%s)", lsah->options,
     127             :                    ospf_options_dump(lsah->options));
     128           0 :         zlog_debug("    LS type %d (%s)", lsah->type,
     129             :                    (lsah->type ? lsah_type : "unknown type"));
     130           0 :         zlog_debug("    Link State ID %pI4", &lsah->id);
     131           0 :         zlog_debug("    Advertising Router %pI4", &lsah->adv_router);
     132           0 :         zlog_debug("    LS sequence number 0x%lx",
     133             :                    (unsigned long)ntohl(lsah->ls_seqnum));
     134           0 :         zlog_debug("    LS checksum 0x%x", ntohs(lsah->checksum));
     135           0 :         zlog_debug("    length %d", ntohs(lsah->length));
     136           0 : }

Generated by: LCOV version v1.16-topotato