1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2003 Yasuhiro Ohara
6 #ifndef OSPF6_NEIGHBOR_H
7 #define OSPF6_NEIGHBOR_H
11 /* Forward declaration(s). */
15 extern unsigned char conf_debug_ospf6_neighbor
;
16 #define OSPF6_DEBUG_NEIGHBOR_STATE 0x01
17 #define OSPF6_DEBUG_NEIGHBOR_EVENT 0x02
18 #define OSPF6_DEBUG_NEIGHBOR_ON(level) (conf_debug_ospf6_neighbor |= (level))
19 #define OSPF6_DEBUG_NEIGHBOR_OFF(level) (conf_debug_ospf6_neighbor &= ~(level))
20 #define IS_OSPF6_DEBUG_NEIGHBOR(level) \
21 (conf_debug_ospf6_neighbor & OSPF6_DEBUG_NEIGHBOR_##level)
23 struct ospf6_helper_info
{
25 /* Grace interval received from
28 uint32_t recvd_grace_period
;
30 /* Grace interval used for grace
33 uint32_t actual_grace_period
;
35 /* Grace timer,This Router acts as
36 * helper until this timer until
39 struct thread
*t_grace_timer
;
42 uint32_t gr_helper_status
;
44 /* Helper exit reason*/
45 uint32_t helper_exit_reason
;
47 /* Planned/Unplanned restart*/
48 uint32_t gr_restart_reason
;
51 /* Helper rejected reason */
52 uint32_t rejected_reason
;
55 /* Neighbor structure */
56 struct ospf6_neighbor
{
57 /* Neighbor Router ID String */
60 /* OSPFv3 Interface this neighbor belongs to */
61 struct ospf6_interface
*ospf6_if
;
66 /* timestamp of last changing state */
67 uint32_t state_change
;
68 struct timeval last_changed
;
70 /* last received hello */
71 struct timeval last_hello
;
74 /* Neighbor Router ID */
77 /* Neighbor Interface ID */
80 /* Router Priority of this neighbor */
85 in_addr_t prev_drouter
;
86 in_addr_t prev_bdrouter
;
88 /* Options field (Capability) */
91 /* IPaddr of I/F on neighbour's link */
92 struct in6_addr linklocal_addr
;
94 /* For Database Exchange */
96 uint32_t dbdesc_seqnum
;
97 /* Last received Database Description packet */
98 struct ospf6_dbdesc dbdesc_last
;
101 struct ospf6_lsdb
*summary_list
;
102 struct ospf6_lsdb
*request_list
;
103 struct ospf6_lsdb
*retrans_list
;
105 /* LSA list for message transmission */
106 struct ospf6_lsdb
*dbdesc_list
;
107 struct ospf6_lsdb
*lsreq_list
;
108 struct ospf6_lsdb
*lsupdate_list
;
109 struct ospf6_lsdb
*lsack_list
;
111 struct ospf6_lsa
*last_ls_req
;
113 /* Inactivity timer */
114 struct thread
*inactivity_timer
;
116 /* Timer to release the last dbdesc packet */
117 struct thread
*last_dbdesc_release_timer
;
119 /* Thread for sending message */
120 struct thread
*thread_send_dbdesc
;
121 struct thread
*thread_send_lsreq
;
122 struct thread
*thread_send_lsupdate
;
123 struct thread
*thread_send_lsack
;
124 struct thread
*thread_exchange_done
;
125 struct thread
*thread_adj_ok
;
127 /* BFD information */
128 struct bfd_session_params
*bfd_session
;
130 /* ospf6 graceful restart HELPER info */
131 struct ospf6_helper_info gr_helper_info
;
133 /* seqnum_h/l is used to compare sequence
134 * number in received packet Auth header
136 uint32_t seqnum_h
[OSPF6_MESSAGE_TYPE_MAX
];
137 uint32_t seqnum_l
[OSPF6_MESSAGE_TYPE_MAX
];
143 #define OSPF6_NEIGHBOR_DOWN 1
144 #define OSPF6_NEIGHBOR_ATTEMPT 2
145 #define OSPF6_NEIGHBOR_INIT 3
146 #define OSPF6_NEIGHBOR_TWOWAY 4
147 #define OSPF6_NEIGHBOR_EXSTART 5
148 #define OSPF6_NEIGHBOR_EXCHANGE 6
149 #define OSPF6_NEIGHBOR_LOADING 7
150 #define OSPF6_NEIGHBOR_FULL 8
152 /* Neighbor Events */
153 #define OSPF6_NEIGHBOR_EVENT_NO_EVENT 0
154 #define OSPF6_NEIGHBOR_EVENT_HELLO_RCVD 1
155 #define OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD 2
156 #define OSPF6_NEIGHBOR_EVENT_NEGOTIATION_DONE 3
157 #define OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE 4
158 #define OSPF6_NEIGHBOR_EVENT_LOADING_DONE 5
159 #define OSPF6_NEIGHBOR_EVENT_ADJ_OK 6
160 #define OSPF6_NEIGHBOR_EVENT_SEQNUMBER_MISMATCH 7
161 #define OSPF6_NEIGHBOR_EVENT_BAD_LSREQ 8
162 #define OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD 9
163 #define OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER 10
164 #define OSPF6_NEIGHBOR_EVENT_MAX_EVENT 11
166 extern const char *const ospf6_neighbor_event_str
[];
168 static inline const char *ospf6_neighbor_event_string(int event
)
170 #define OSPF6_NEIGHBOR_UNKNOWN_EVENT_STRING "UnknownEvent"
172 if (event
< OSPF6_NEIGHBOR_EVENT_MAX_EVENT
)
173 return ospf6_neighbor_event_str
[event
];
174 return OSPF6_NEIGHBOR_UNKNOWN_EVENT_STRING
;
177 extern const char *const ospf6_neighbor_state_str
[];
180 /* Function Prototypes */
181 int ospf6_neighbor_cmp(void *va
, void *vb
);
182 void ospf6_neighbor_dbex_init(struct ospf6_neighbor
*on
);
184 struct ospf6_neighbor
*ospf6_neighbor_lookup(uint32_t router_id
,
185 struct ospf6_interface
*oi
);
186 struct ospf6_neighbor
*ospf6_area_neighbor_lookup(struct ospf6_area
*area
,
188 struct ospf6_neighbor
*ospf6_neighbor_create(uint32_t router_id
,
189 struct ospf6_interface
*oi
);
190 void ospf6_neighbor_delete(struct ospf6_neighbor
*on
);
193 extern void hello_received(struct thread
*thread
);
194 extern void twoway_received(struct thread
*thread
);
195 extern void negotiation_done(struct thread
*thread
);
196 extern void exchange_done(struct thread
*thread
);
197 extern void loading_done(struct thread
*thread
);
198 extern void adj_ok(struct thread
*thread
);
199 extern void seqnumber_mismatch(struct thread
*thread
);
200 extern void bad_lsreq(struct thread
*thread
);
201 extern void oneway_received(struct thread
*thread
);
202 extern void inactivity_timer(struct thread
*thread
);
203 extern void ospf6_check_nbr_loading(struct ospf6_neighbor
*on
);
205 extern void ospf6_neighbor_init(void);
206 extern int config_write_ospf6_debug_neighbor(struct vty
*vty
);
207 extern void install_element_ospf6_debug_neighbor(void);
209 DECLARE_HOOK(ospf6_neighbor_change
,
210 (struct ospf6_neighbor
* on
, int state
, int next_state
),
211 (on
, state
, next_state
));
213 #endif /* OSPF6_NEIGHBOR_H */