]>
Commit | Line | Data |
---|---|---|
1 | // SPDX-License-Identifier: GPL-2.0-or-later | |
2 | /* | |
3 | * Copyright (C) 2003 Yasuhiro Ohara | |
4 | */ | |
5 | ||
6 | #ifndef OSPF6_NEIGHBOR_H | |
7 | #define OSPF6_NEIGHBOR_H | |
8 | ||
9 | #include "hook.h" | |
10 | ||
11 | /* Forward declaration(s). */ | |
12 | struct ospf6_area; | |
13 | ||
14 | /* Debug option */ | |
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) | |
22 | ||
23 | struct ospf6_helper_info { | |
24 | ||
25 | /* Grace interval received from | |
26 | * Restarting Router. | |
27 | */ | |
28 | uint32_t recvd_grace_period; | |
29 | ||
30 | /* Grace interval used for grace | |
31 | * gracetimer. | |
32 | */ | |
33 | uint32_t actual_grace_period; | |
34 | ||
35 | /* Grace timer,This Router acts as | |
36 | * helper until this timer until | |
37 | * this timer expires. | |
38 | */ | |
39 | struct thread *t_grace_timer; | |
40 | ||
41 | /* Helper status */ | |
42 | uint32_t gr_helper_status; | |
43 | ||
44 | /* Helper exit reason*/ | |
45 | uint32_t helper_exit_reason; | |
46 | ||
47 | /* Planned/Unplanned restart*/ | |
48 | uint32_t gr_restart_reason; | |
49 | ||
50 | ||
51 | /* Helper rejected reason */ | |
52 | uint32_t rejected_reason; | |
53 | }; | |
54 | ||
55 | /* Neighbor structure */ | |
56 | struct ospf6_neighbor { | |
57 | /* Neighbor Router ID String */ | |
58 | char name[36]; | |
59 | ||
60 | /* OSPFv3 Interface this neighbor belongs to */ | |
61 | struct ospf6_interface *ospf6_if; | |
62 | ||
63 | /* Neighbor state */ | |
64 | uint8_t state; | |
65 | ||
66 | /* timestamp of last changing state */ | |
67 | uint32_t state_change; | |
68 | struct timeval last_changed; | |
69 | ||
70 | /* last received hello */ | |
71 | struct timeval last_hello; | |
72 | uint32_t hello_in; | |
73 | ||
74 | /* Neighbor Router ID */ | |
75 | in_addr_t router_id; | |
76 | ||
77 | /* Neighbor Interface ID */ | |
78 | ifindex_t ifindex; | |
79 | ||
80 | /* Router Priority of this neighbor */ | |
81 | uint8_t priority; | |
82 | ||
83 | in_addr_t drouter; | |
84 | in_addr_t bdrouter; | |
85 | in_addr_t prev_drouter; | |
86 | in_addr_t prev_bdrouter; | |
87 | ||
88 | /* Options field (Capability) */ | |
89 | char options[3]; | |
90 | ||
91 | /* IPaddr of I/F on neighbour's link */ | |
92 | struct in6_addr linklocal_addr; | |
93 | ||
94 | /* For Database Exchange */ | |
95 | uint8_t dbdesc_bits; | |
96 | uint32_t dbdesc_seqnum; | |
97 | /* Last received Database Description packet */ | |
98 | struct ospf6_dbdesc dbdesc_last; | |
99 | ||
100 | /* LS-list */ | |
101 | struct ospf6_lsdb *summary_list; | |
102 | struct ospf6_lsdb *request_list; | |
103 | struct ospf6_lsdb *retrans_list; | |
104 | ||
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; | |
110 | ||
111 | struct ospf6_lsa *last_ls_req; | |
112 | ||
113 | /* Inactivity timer */ | |
114 | struct thread *inactivity_timer; | |
115 | ||
116 | /* Timer to release the last dbdesc packet */ | |
117 | struct thread *last_dbdesc_release_timer; | |
118 | ||
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; | |
126 | ||
127 | /* BFD information */ | |
128 | struct bfd_session_params *bfd_session; | |
129 | ||
130 | /* ospf6 graceful restart HELPER info */ | |
131 | struct ospf6_helper_info gr_helper_info; | |
132 | ||
133 | /* seqnum_h/l is used to compare sequence | |
134 | * number in received packet Auth header | |
135 | */ | |
136 | uint32_t seqnum_h[OSPF6_MESSAGE_TYPE_MAX]; | |
137 | uint32_t seqnum_l[OSPF6_MESSAGE_TYPE_MAX]; | |
138 | bool auth_present; | |
139 | bool lls_present; | |
140 | }; | |
141 | ||
142 | /* Neighbor state */ | |
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 | |
151 | ||
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 | |
165 | ||
166 | extern const char *const ospf6_neighbor_event_str[]; | |
167 | ||
168 | static inline const char *ospf6_neighbor_event_string(int event) | |
169 | { | |
170 | #define OSPF6_NEIGHBOR_UNKNOWN_EVENT_STRING "UnknownEvent" | |
171 | ||
172 | if (event < OSPF6_NEIGHBOR_EVENT_MAX_EVENT) | |
173 | return ospf6_neighbor_event_str[event]; | |
174 | return OSPF6_NEIGHBOR_UNKNOWN_EVENT_STRING; | |
175 | } | |
176 | ||
177 | extern const char *const ospf6_neighbor_state_str[]; | |
178 | ||
179 | ||
180 | /* Function Prototypes */ | |
181 | int ospf6_neighbor_cmp(void *va, void *vb); | |
182 | void ospf6_neighbor_dbex_init(struct ospf6_neighbor *on); | |
183 | ||
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, | |
187 | uint32_t router_id); | |
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); | |
191 | ||
192 | /* Neighbor event */ | |
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); | |
204 | ||
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); | |
208 | ||
209 | DECLARE_HOOK(ospf6_neighbor_change, | |
210 | (struct ospf6_neighbor * on, int state, int next_state), | |
211 | (on, state, next_state)); | |
212 | ||
213 | #endif /* OSPF6_NEIGHBOR_H */ |