back to topotato report
topotato coverage report
Current view: top level - ospf6d - ospf6_interface.h (source / functions) Hit Total Coverage
Test: test_ospf_topo1.py::OSPFTopo1Test Lines: 3 3 100.0 %
Date: 2023-02-24 18:38:32 Functions: 0 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_INTERFACE_H
      22             : #define OSPF6_INTERFACE_H
      23             : 
      24             : #include "qobj.h"
      25             : #include "hook.h"
      26             : #include "if.h"
      27             : #include "ospf6d.h"
      28             : 
      29             : DECLARE_MTYPE(OSPF6_AUTH_MANUAL_KEY);
      30             : 
      31             : #include "lib/libospf.h"
      32             : #include "ospf6_neighbor.h"
      33             : 
      34             : /* Debug option */
      35             : extern unsigned char conf_debug_ospf6_interface;
      36             : #define OSPF6_DEBUG_INTERFACE_ON() (conf_debug_ospf6_interface = 1)
      37             : #define OSPF6_DEBUG_INTERFACE_OFF() (conf_debug_ospf6_interface = 0)
      38             : #define IS_OSPF6_DEBUG_INTERFACE (conf_debug_ospf6_interface)
      39             : 
      40             : struct ospf6_auth_data {
      41             :         /* config data */
      42             :         uint8_t hash_algo; /* hash algorithm type */
      43             :         uint16_t key_id;   /* key-id used as SA in auth packet */
      44             :         char *auth_key;    /* Auth key */
      45             :         char *keychain;    /* keychain name */
      46             : 
      47             :         /* operational data */
      48             :         uint8_t flags; /* Flags related to auth config */
      49             : 
      50             :         /* Counters and Statistics */
      51             :         uint32_t tx_drop; /* Pkt drop due to auth fail while sending */
      52             :         uint32_t rx_drop; /* Pkt drop due to auth fail while reading */
      53             : };
      54             : 
      55             : /* Interface structure */
      56             : struct ospf6_interface {
      57             :         /* IF info from zebra */
      58             :         struct interface *interface;
      59             : 
      60             :         /* back pointer */
      61             :         struct ospf6_area *area;
      62             : 
      63             :         uint32_t area_id;
      64             :         int area_id_format;
      65             : 
      66             :         /* list of ospf6 neighbor */
      67             :         struct list *neighbor_list;
      68             : 
      69             :         /* linklocal address of this I/F */
      70             :         struct in6_addr *linklocal_addr;
      71             : 
      72             :         /* Interface ID; use interface->ifindex */
      73             : 
      74             :         /* ospf6 instance id */
      75             :         uint8_t instance_id;
      76             : 
      77             :         /* I/F transmission delay */
      78             :         uint32_t transdelay;
      79             : 
      80             :         /* Packet send buffer. */
      81             :         struct ospf6_fifo *obuf; /* Output queue */
      82             : 
      83             :         /* Network Type */
      84             :         uint8_t type;
      85             :         bool type_cfg;
      86             : 
      87             :         /* P2P/P2MP behavior: */
      88             : 
      89             :         /* disable hellos on standard multicast? */
      90             :         bool p2xp_no_multicast_hello;
      91             :         /* only allow explicitly configured neighbors? */
      92             :         bool p2xp_only_cfg_neigh;
      93             :         /* override mode default for advertising connected prefixes.
      94             :          * both false by default (= do include for PtP, exclude for PtMP)
      95             :          */
      96             :         bool p2xp_connected_pfx_include;
      97             :         bool p2xp_connected_pfx_exclude;
      98             : 
      99             :         struct ospf6_if_p2xp_neighcfgs_head p2xp_neighs;
     100             : 
     101             :         /* Router Priority */
     102             :         uint8_t priority;
     103             : 
     104             :         /* Time Interval */
     105             :         uint16_t hello_interval;
     106             :         uint16_t dead_interval;
     107             :         uint32_t rxmt_interval;
     108             : 
     109             :         uint32_t state_change;
     110             : 
     111             :         /* Cost */
     112             :         uint32_t cost;
     113             : 
     114             :         /* I/F MTU */
     115             :         uint32_t ifmtu;
     116             : 
     117             :         /* Configured MTU */
     118             :         uint32_t c_ifmtu;
     119             : 
     120             :         /* Interface State */
     121             :         uint8_t state;
     122             : 
     123             :         /* Interface socket setting trial counter, resets on success */
     124             :         uint8_t sso_try_cnt;
     125             :         struct thread *thread_sso;
     126             : 
     127             :         /* OSPF6 Interface flag */
     128             :         char flag;
     129             : 
     130             :         /* MTU mismatch check */
     131             :         uint8_t mtu_ignore;
     132             : 
     133             :         /* Authentication trailer related config */
     134             :         struct ospf6_auth_data at_data;
     135             : 
     136             :         /* Decision of DR Election */
     137             :         in_addr_t drouter;
     138             :         in_addr_t bdrouter;
     139             :         in_addr_t prev_drouter;
     140             :         in_addr_t prev_bdrouter;
     141             : 
     142             :         /* Linklocal LSA Database: includes Link-LSA */
     143             :         struct ospf6_lsdb *lsdb;
     144             :         struct ospf6_lsdb *lsdb_self;
     145             : 
     146             :         struct ospf6_lsdb *lsupdate_list;
     147             :         struct ospf6_lsdb *lsack_list;
     148             : 
     149             :         /* Ongoing Tasks */
     150             :         struct thread *thread_send_hello;
     151             :         struct thread *thread_send_lsupdate;
     152             :         struct thread *thread_send_lsack;
     153             : 
     154             :         struct thread *thread_network_lsa;
     155             :         struct thread *thread_link_lsa;
     156             :         struct thread *thread_intra_prefix_lsa;
     157             :         struct thread *thread_as_extern_lsa;
     158             :         struct thread *thread_wait_timer;
     159             : 
     160             :         struct ospf6_route_table *route_connected;
     161             : 
     162             :         /* last hello sent */
     163             :         struct timeval last_hello;
     164             : 
     165             :         /* prefix-list name to filter connected prefix */
     166             :         char *plist_name;
     167             : 
     168             :         /* BFD information */
     169             :         struct {
     170             :                 bool enabled;
     171             :                 uint8_t detection_multiplier;
     172             :                 uint32_t min_rx;
     173             :                 uint32_t min_tx;
     174             :                 char *profile;
     175             :         } bfd_config;
     176             : 
     177             :         int on_write_q;
     178             : 
     179             :         /* Statistics Fields */
     180             :         uint32_t hello_in;
     181             :         uint32_t hello_out;
     182             :         uint32_t db_desc_in;
     183             :         uint32_t db_desc_out;
     184             :         uint32_t ls_req_in;
     185             :         uint32_t ls_req_out;
     186             :         uint32_t ls_upd_in;
     187             :         uint32_t ls_upd_out;
     188             :         uint32_t ls_ack_in;
     189             :         uint32_t ls_ack_out;
     190             :         uint32_t discarded;
     191             : 
     192             :         QOBJ_FIELDS;
     193             : };
     194             : DECLARE_QOBJ_TYPE(ospf6_interface);
     195             : 
     196             : /* interface state */
     197             : #define OSPF6_INTERFACE_NONE               0
     198             : #define OSPF6_INTERFACE_DOWN               1
     199             : #define OSPF6_INTERFACE_LOOPBACK           2
     200             : #define OSPF6_INTERFACE_WAITING            3
     201             : #define OSPF6_INTERFACE_POINTTOPOINT       4
     202             : #define OSPF6_INTERFACE_POINTTOMULTIPOINT  5
     203             : #define OSPF6_INTERFACE_VIRTUALLINK        6
     204             : #define OSPF6_INTERFACE_DROTHER            7
     205             : #define OSPF6_INTERFACE_BDR                8
     206             : #define OSPF6_INTERFACE_DR                 9
     207             : #define OSPF6_INTERFACE_MAX                10
     208             : 
     209             : extern const char *const ospf6_interface_state_str[];
     210             : 
     211             : /* flags */
     212             : #define OSPF6_INTERFACE_DISABLE      0x01
     213             : #define OSPF6_INTERFACE_PASSIVE      0x02
     214             : #define OSPF6_INTERFACE_NOAUTOCOST   0x04
     215             : 
     216             : /* default values */
     217             : #define OSPF6_INTERFACE_HELLO_INTERVAL 10
     218             : #define OSPF6_INTERFACE_DEAD_INTERVAL  40
     219             : #define OSPF6_INTERFACE_RXMT_INTERVAL  5
     220             : #define OSPF6_INTERFACE_COST           1
     221             : #define OSPF6_INTERFACE_PRIORITY       1
     222             : #define OSPF6_INTERFACE_TRANSDELAY     1
     223             : #define OSPF6_INTERFACE_INSTANCE_ID    0
     224             : #define OSPF6_INTERFACE_BANDWIDTH      10000   /* Mbps */
     225             : #define OSPF6_REFERENCE_BANDWIDTH      100000  /* Mbps */
     226             : #define OSPF6_INTERFACE_SSO_RETRY_INT  1
     227             : #define OSPF6_INTERFACE_SSO_RETRY_MAX  5
     228             : 
     229             : /* Function Prototypes */
     230             : 
     231             : extern void ospf6_interface_start(struct ospf6_interface *oi);
     232             : extern void ospf6_interface_stop(struct ospf6_interface *oi);
     233             : 
     234             : extern struct ospf6_interface *
     235             : ospf6_interface_lookup_by_ifindex(ifindex_t, vrf_id_t vrf_id);
     236             : extern struct ospf6_interface *ospf6_interface_create(struct interface *ifp);
     237             : extern void ospf6_interface_delete(struct ospf6_interface *oi);
     238             : 
     239             : /* "basic" interface = used for virtual links */
     240             : extern struct ospf6_interface *ospf6_interface_basic_create(struct interface *);
     241             : extern void ospf6_interface_basic_delete(struct ospf6_interface *oi);
     242             : 
     243             : extern void ospf6_interface_enable(struct ospf6_interface *oi);
     244             : extern void ospf6_interface_disable(struct ospf6_interface *oi);
     245             : 
     246             : extern void ospf6_interface_state_update(struct interface *ifp);
     247             : extern void ospf6_interface_connected_route_update(struct interface *ifp);
     248             : extern struct in6_addr *
     249             : ospf6_interface_get_global_address(struct interface *ifp);
     250             : extern bool ospf6_interface_addr_valid(struct ospf6_interface *oi,
     251             :                                        struct connected *c, bool debug);
     252             : 
     253             : /* interface event */
     254             : extern void interface_up(struct thread *thread);
     255             : extern void interface_down(struct thread *thread);
     256             : extern void wait_timer(struct thread *thread);
     257             : extern void backup_seen(struct thread *thread);
     258             : extern void neighbor_change(struct thread *thread);
     259             : 
     260             : extern void ospf6_interface_init(void);
     261             : extern void ospf6_interface_clear(struct interface *ifp);
     262             : 
     263             : extern void install_element_ospf6_clear_interface(void);
     264             : 
     265             : extern int config_write_ospf6_debug_interface(struct vty *vty);
     266             : extern void install_element_ospf6_debug_interface(void);
     267             : extern int ospf6_interface_neighbor_count(struct ospf6_interface *oi);
     268             : extern uint8_t dr_election(struct ospf6_interface *oi);
     269             : 
     270             : extern void ospf6_interface_auth_trailer_cmd_init(void);
     271             : extern void ospf6_auth_write_config(struct vty *vty,
     272             :                                     struct ospf6_auth_data *at_data);
     273             : 
     274           8 : static inline const char *ospf6_ifname(const struct ospf6_interface *oi)
     275             : {
     276           8 :         return oi->type == OSPF_IFTYPE_VIRTUALLINK ? "vlink"
     277           8 :                 : oi->interface->name;
     278             : }
     279             : 
     280             : DECLARE_HOOK(ospf6_interface_change,
     281             :              (struct ospf6_interface * oi, int state, int old_state),
     282             :              (oi, state, old_state));
     283             : 
     284             : #ifdef _FRR_ATTRIBUTE_PRINTFRR
     285             : #pragma FRR printfrr_ext "%pOI"  (struct ospf6_interface *)
     286             : #endif
     287             : 
     288             : #endif /* OSPF6_INTERFACE_H */

Generated by: LCOV version v1.16-topotato