back to topotato report
topotato coverage report
Current view: top level - ospf6d - ospf6_spf.h (source / functions) Hit Total Coverage
Test: aggregated run ( view descriptions ) Lines: 30 30 100.0 %
Date: 2023-02-24 14:41:08 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (C) 2003 Yasuhiro Ohara
       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             : #ifndef OSPF6_SPF_H
      22             : #define OSPF6_SPF_H
      23             : 
      24             : #include "typesafe.h"
      25             : #include "ospf6_top.h"
      26             : #include "lib/json.h"
      27             : 
      28             : /* Debug option */
      29             : extern unsigned char conf_debug_ospf6_spf;
      30             : #define OSPF6_DEBUG_SPF_PROCESS   0x01
      31             : #define OSPF6_DEBUG_SPF_TIME      0x02
      32             : #define OSPF6_DEBUG_SPF_DATABASE  0x04
      33             : #define OSPF6_DEBUG_SPF_ON(level) (conf_debug_ospf6_spf |= (level))
      34             : #define OSPF6_DEBUG_SPF_OFF(level) (conf_debug_ospf6_spf &= ~(level))
      35             : #define IS_OSPF6_DEBUG_SPF(level)                                              \
      36             :         (conf_debug_ospf6_spf & OSPF6_DEBUG_SPF_##level)
      37             : 
      38             : #define OSPF6_ASE_CALC_INTERVAL 1
      39             : 
      40             : PREDECL_SKIPLIST_NONUNIQ(vertex_pqueue);
      41             : /* Transit Vertex */
      42             : struct ospf6_vertex {
      43             :         /* type of this vertex */
      44             :         uint8_t type;
      45             : 
      46             :         /* Vertex Identifier */
      47             :         struct prefix vertex_id;
      48             : 
      49             :         struct vertex_pqueue_item pqi;
      50             : 
      51             :         /* Identifier String */
      52             :         char name[128];
      53             : 
      54             :         /* Associated Area */
      55             :         struct ospf6_area *area;
      56             : 
      57             :         /* Associated LSA */
      58             :         struct ospf6_lsa *lsa;
      59             : 
      60             :         /* Distance from Root (i.e. Cost) */
      61             :         uint32_t cost;
      62             : 
      63             :         /* Router hops to this node */
      64             :         uint8_t hops;
      65             : 
      66             :         /* capability bits */
      67             :         uint8_t capability;
      68             : 
      69             :         /* Optional capabilities */
      70             :         uint8_t options[3];
      71             : 
      72             :         /* For tree display */
      73             :         struct ospf6_vertex *parent;
      74             :         struct list *child_list;
      75             : 
      76             :         /* nexthops to this node */
      77             :         struct list *nh_list;
      78             :         uint32_t link_id;
      79             : };
      80             : 
      81             : #define OSPF6_VERTEX_TYPE_ROUTER  0x01
      82             : #define OSPF6_VERTEX_TYPE_NETWORK 0x02
      83             : #define VERTEX_IS_TYPE(t, v) ((v)->type == OSPF6_VERTEX_TYPE_##t ? 1 : 0)
      84             : 
      85             : /* What triggered the SPF? */
      86             : #define OSPF6_SPF_FLAGS_ROUTER_LSA_ADDED         (1 << 0)
      87             : #define OSPF6_SPF_FLAGS_ROUTER_LSA_REMOVED       (1 << 1)
      88             : #define OSPF6_SPF_FLAGS_NETWORK_LSA_ADDED        (1 << 2)
      89             : #define OSPF6_SPF_FLAGS_NETWORK_LSA_REMOVED      (1 << 3)
      90             : #define OSPF6_SPF_FLAGS_LINK_LSA_ADDED           (1 << 4)
      91             : #define OSPF6_SPF_FLAGS_LINK_LSA_REMOVED         (1 << 5)
      92             : #define OSPF6_SPF_FLAGS_ROUTER_LSA_ORIGINATED    (1 << 6)
      93             : #define OSPF6_SPF_FLAGS_NETWORK_LSA_ORIGINATED   (1 << 7)
      94             : #define OSPF6_SPF_FLAGS_CONFIG_CHANGE            (1 << 8)
      95             : #define OSPF6_SPF_FLAGS_ASBR_STATUS_CHANGE       (1 << 9)
      96             : #define OSPF6_SPF_FLAGS_GR_FINISH                (1 << 10)
      97             : 
      98         625 : static inline void ospf6_set_spf_reason(struct ospf6 *ospf, unsigned int reason)
      99             : {
     100         625 :         ospf->spf_reason |= reason;
     101             : }
     102             : 
     103         137 : static inline void ospf6_reset_spf_reason(struct ospf6 *ospf)
     104             : {
     105         137 :         ospf->spf_reason = 0;
     106             : }
     107             : 
     108         271 : static inline unsigned int ospf6_lsadd_to_spf_reason(struct ospf6_lsa *lsa)
     109             : {
     110         271 :         unsigned int reason = 0;
     111             : 
     112         271 :         switch (ntohs(lsa->header->type)) {
     113         158 :         case OSPF6_LSTYPE_ROUTER:
     114         158 :                 reason = OSPF6_SPF_FLAGS_ROUTER_LSA_ADDED;
     115         158 :                 break;
     116          43 :         case OSPF6_LSTYPE_NETWORK:
     117          43 :                 reason = OSPF6_SPF_FLAGS_NETWORK_LSA_ADDED;
     118          43 :                 break;
     119          70 :         case OSPF6_LSTYPE_LINK:
     120          70 :                 reason = OSPF6_SPF_FLAGS_LINK_LSA_ADDED;
     121          70 :                 break;
     122             :         default:
     123             :                 break;
     124             :         }
     125         271 :         return (reason);
     126             : }
     127             : 
     128         333 : static inline unsigned int ospf6_lsremove_to_spf_reason(struct ospf6_lsa *lsa)
     129             : {
     130         333 :         unsigned int reason = 0;
     131             : 
     132         333 :         switch (ntohs(lsa->header->type)) {
     133         178 :         case OSPF6_LSTYPE_ROUTER:
     134         178 :                 reason = OSPF6_SPF_FLAGS_ROUTER_LSA_REMOVED;
     135         178 :                 break;
     136          61 :         case OSPF6_LSTYPE_NETWORK:
     137          61 :                 reason = OSPF6_SPF_FLAGS_NETWORK_LSA_REMOVED;
     138          61 :                 break;
     139          94 :         case OSPF6_LSTYPE_LINK:
     140          94 :                 reason = OSPF6_SPF_FLAGS_LINK_LSA_REMOVED;
     141          94 :                 break;
     142             :         default:
     143             :                 break;
     144             :         }
     145         333 :         return (reason);
     146             : }
     147             : 
     148             : extern void ospf6_spf_table_finish(struct ospf6_route_table *result_table);
     149             : extern void ospf6_spf_calculation(uint32_t router_id,
     150             :                                   struct ospf6_route_table *result_table,
     151             :                                   struct ospf6_area *oa);
     152             : extern void ospf6_spf_schedule(struct ospf6 *ospf, unsigned int reason);
     153             : 
     154             : extern void ospf6_spf_display_subtree(struct vty *vty, const char *prefix,
     155             :                                       int rest, struct ospf6_vertex *v,
     156             :                                       json_object *json_obj, bool use_json);
     157             : 
     158             : extern void ospf6_spf_config_write(struct vty *vty, struct ospf6 *ospf6);
     159             : extern int config_write_ospf6_debug_spf(struct vty *vty);
     160             : extern void install_element_ospf6_debug_spf(void);
     161             : extern void ospf6_spf_init(void);
     162             : extern void ospf6_spf_reason_string(unsigned int reason, char *buf, int size);
     163             : extern struct ospf6_lsa *ospf6_create_single_router_lsa(struct ospf6_area *area,
     164             :                                                         struct ospf6_lsdb *lsdb,
     165             :                                                         uint32_t adv_router);
     166             : extern void ospf6_remove_temp_router_lsa(struct ospf6_area *area);
     167             : extern void ospf6_ase_calculate_timer_add(struct ospf6 *ospf6);
     168             : extern int ospf6_ase_calculate_route(struct ospf6 *ospf6, struct ospf6_lsa *lsa,
     169             :                                      struct ospf6_area *area);
     170             : #endif /* OSPF6_SPF_H */

Generated by: LCOV version v1.16-topotato