1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * OSPF Neighbor functions.
4 * Copyright (C) 1999, 2000 Toshiaki Takada
7 #ifndef _ZEBRA_OSPF_NEIGHBOR_H
8 #define _ZEBRA_OSPF_NEIGHBOR_H
10 #include <ospfd/ospf_gr.h>
11 #include <ospfd/ospf_packet.h>
13 /* Neighbor Data Structure */
14 struct ospf_neighbor
{
15 /* This neighbor's parent ospf interface. */
16 struct ospf_interface
*oi
;
18 /* OSPF neighbor Information */
19 uint8_t state
; /* NSM status. */
20 uint8_t dd_flags
; /* DD bit flags. */
21 uint32_t dd_seqnum
; /* DD Sequence Number. */
23 /* Neighbor Information from Hello. */
24 struct prefix address
; /* Neighbor Interface Address. */
26 struct in_addr src
; /* Src address. */
27 struct in_addr router_id
; /* Router ID. */
28 uint8_t options
; /* Options. */
29 int priority
; /* Router Priority. */
30 struct in_addr d_router
; /* Designated Router. */
31 struct in_addr bd_router
; /* Backup Designated Router. */
33 /* Last sent Database Description packet. */
34 struct ospf_packet
*last_send
;
35 /* Timestemp when last Database Description packet was sent */
36 struct timeval last_send_ts
;
38 /* Last received Databse Description packet. */
46 struct ospf_lsdb ls_rxmt
;
47 struct ospf_lsdb db_sum
;
48 struct ospf_lsdb ls_req
;
49 struct ospf_lsa
*ls_req_last
;
51 uint32_t crypt_seqnum
; /* Cryptographic Sequence Number. */
54 uint32_t v_inactivity
;
60 struct thread
*t_inactivity
;
61 struct thread
*t_db_desc
;
62 struct thread
*t_ls_req
;
63 struct thread
*t_ls_upd
;
64 struct thread
*t_hello_reply
;
66 /* NBMA configured neighbour */
67 struct ospf_nbr_nbma
*nbr_nbma
;
70 struct timeval ts_last_progress
; /* last advance of NSM */
71 struct timeval ts_last_regress
; /* last regressive NSM change */
72 const char *last_regress_str
; /* Event which last regressed NSM */
73 uint32_t state_change
; /* NSM state change counter */
76 struct bfd_session_params
*bfd_session
;
78 /* ospf graceful restart HELPER info */
79 struct ospf_helper_info gr_helper_info
;
83 #define NBR_IS_DR(n) IPV4_ADDR_SAME (&n->address.u.prefix4, &n->d_router)
84 #define NBR_IS_BDR(n) IPV4_ADDR_SAME (&n->address.u.prefix4, &n->bd_router)
87 extern struct ospf_neighbor
*ospf_nbr_new(struct ospf_interface
*);
88 extern void ospf_nbr_free(struct ospf_neighbor
*);
89 extern void ospf_nbr_delete(struct ospf_neighbor
*);
90 extern int ospf_nbr_bidirectional(struct in_addr
*, struct in_addr
*, int);
91 extern void ospf_nbr_self_reset(struct ospf_interface
*, struct in_addr
);
92 extern void ospf_nbr_add_self(struct ospf_interface
*, struct in_addr
);
93 extern int ospf_nbr_count(struct ospf_interface
*, int);
94 extern int ospf_nbr_count_opaque_capable(struct ospf_interface
*);
95 extern struct ospf_neighbor
*ospf_nbr_get(struct ospf_interface
*,
96 struct ospf_header
*, struct ip
*,
98 extern struct ospf_neighbor
*ospf_nbr_lookup(struct ospf_interface
*,
99 struct ip
*, struct ospf_header
*);
100 extern struct ospf_neighbor
*ospf_nbr_lookup_by_addr(struct route_table
*,
102 extern struct ospf_neighbor
*ospf_nbr_lookup_by_routerid(struct route_table
*,
104 extern void ospf_renegotiate_optional_capabilities(struct ospf
*top
);
105 #endif /* _ZEBRA_OSPF_NEIGHBOR_H */