]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* |
508e53e2 | 2 | * Copyright (C) 2003 Yasuhiro Ohara |
718e3744 | 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 | * | |
896014f4 DL |
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 | |
718e3744 | 19 | */ |
20 | ||
718e3744 | 21 | #include <zebra.h> |
22 | ||
23 | #include "log.h" | |
508e53e2 | 24 | #include "memory.h" |
718e3744 | 25 | #include "thread.h" |
26 | #include "linklist.h" | |
27 | #include "vty.h" | |
28 | #include "command.h" | |
29 | ||
508e53e2 | 30 | #include "ospf6_proto.h" |
718e3744 | 31 | #include "ospf6_lsa.h" |
508e53e2 | 32 | #include "ospf6_lsdb.h" |
718e3744 | 33 | #include "ospf6_message.h" |
508e53e2 | 34 | #include "ospf6_top.h" |
35 | #include "ospf6_area.h" | |
36 | #include "ospf6_interface.h" | |
718e3744 | 37 | #include "ospf6_neighbor.h" |
508e53e2 | 38 | #include "ospf6_intra.h" |
3b4cd3a9 | 39 | #include "ospf6_flood.h" |
049207c3 | 40 | #include "ospf6d.h" |
7f342629 | 41 | #include "ospf6_bfd.h" |
4dfd8aff DW |
42 | #include "ospf6_abr.h" |
43 | #include "ospf6_asbr.h" | |
44 | #include "ospf6_lsa.h" | |
45 | #include "ospf6_spf.h" | |
46 | #include "ospf6_zebra.h" | |
718e3744 | 47 | |
3012671f | 48 | DEFINE_HOOK(ospf6_neighbor_change, |
d62a17ae | 49 | (struct ospf6_neighbor * on, int state, int next_state), |
50 | (on, state, next_state)) | |
3012671f | 51 | |
508e53e2 | 52 | unsigned char conf_debug_ospf6_neighbor = 0; |
53 | ||
d62a17ae | 54 | const char *ospf6_neighbor_state_str[] = { |
55 | "None", "Down", "Attempt", "Init", "Twoway", | |
56 | "ExStart", "ExChange", "Loading", "Full", NULL}; | |
718e3744 | 57 | |
d62a17ae | 58 | int ospf6_neighbor_cmp(void *va, void *vb) |
718e3744 | 59 | { |
d62a17ae | 60 | struct ospf6_neighbor *ona = (struct ospf6_neighbor *)va; |
61 | struct ospf6_neighbor *onb = (struct ospf6_neighbor *)vb; | |
62 | return (ntohl(ona->router_id) < ntohl(onb->router_id) ? -1 : 1); | |
718e3744 | 63 | } |
64 | ||
d7c0a89a | 65 | struct ospf6_neighbor *ospf6_neighbor_lookup(uint32_t router_id, |
d62a17ae | 66 | struct ospf6_interface *oi) |
718e3744 | 67 | { |
d62a17ae | 68 | struct listnode *n; |
69 | struct ospf6_neighbor *on; | |
70 | ||
71 | for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, n, on)) | |
72 | if (on->router_id == router_id) | |
73 | return on; | |
74 | ||
75 | return (struct ospf6_neighbor *)NULL; | |
718e3744 | 76 | } |
77 | ||
508e53e2 | 78 | /* create ospf6_neighbor */ |
d7c0a89a | 79 | struct ospf6_neighbor *ospf6_neighbor_create(uint32_t router_id, |
d62a17ae | 80 | struct ospf6_interface *oi) |
718e3744 | 81 | { |
d62a17ae | 82 | struct ospf6_neighbor *on; |
83 | char buf[16]; | |
84 | ||
85 | on = (struct ospf6_neighbor *)XMALLOC(MTYPE_OSPF6_NEIGHBOR, | |
86 | sizeof(struct ospf6_neighbor)); | |
87 | if (on == NULL) { | |
88 | zlog_warn("neighbor: malloc failed"); | |
89 | return NULL; | |
90 | } | |
91 | ||
92 | memset(on, 0, sizeof(struct ospf6_neighbor)); | |
93 | inet_ntop(AF_INET, &router_id, buf, sizeof(buf)); | |
94 | snprintf(on->name, sizeof(on->name), "%s%%%s", buf, | |
95 | oi->interface->name); | |
96 | on->ospf6_if = oi; | |
97 | on->state = OSPF6_NEIGHBOR_DOWN; | |
98 | on->state_change = 0; | |
99 | monotime(&on->last_changed); | |
100 | on->router_id = router_id; | |
101 | ||
102 | on->summary_list = ospf6_lsdb_create(on); | |
103 | on->request_list = ospf6_lsdb_create(on); | |
104 | on->retrans_list = ospf6_lsdb_create(on); | |
105 | ||
106 | on->dbdesc_list = ospf6_lsdb_create(on); | |
107 | on->lsupdate_list = ospf6_lsdb_create(on); | |
108 | on->lsack_list = ospf6_lsdb_create(on); | |
109 | ||
110 | listnode_add_sort(oi->neighbor_list, on); | |
111 | ||
112 | ospf6_bfd_info_nbr_create(oi, on); | |
113 | return on; | |
718e3744 | 114 | } |
115 | ||
d62a17ae | 116 | void ospf6_neighbor_delete(struct ospf6_neighbor *on) |
718e3744 | 117 | { |
d62a17ae | 118 | struct ospf6_lsa *lsa; |
3b4cd3a9 | 119 | |
d62a17ae | 120 | ospf6_lsdb_remove_all(on->summary_list); |
121 | ospf6_lsdb_remove_all(on->request_list); | |
122 | for (ALL_LSDB(on->retrans_list, lsa)) { | |
123 | ospf6_decrement_retrans_count(lsa); | |
124 | ospf6_lsdb_remove(lsa, on->retrans_list); | |
125 | } | |
718e3744 | 126 | |
d62a17ae | 127 | ospf6_lsdb_remove_all(on->dbdesc_list); |
128 | ospf6_lsdb_remove_all(on->lsupdate_list); | |
129 | ospf6_lsdb_remove_all(on->lsack_list); | |
508e53e2 | 130 | |
d62a17ae | 131 | ospf6_lsdb_delete(on->summary_list); |
132 | ospf6_lsdb_delete(on->request_list); | |
133 | ospf6_lsdb_delete(on->retrans_list); | |
718e3744 | 134 | |
d62a17ae | 135 | ospf6_lsdb_delete(on->dbdesc_list); |
136 | ospf6_lsdb_delete(on->lsupdate_list); | |
137 | ospf6_lsdb_delete(on->lsack_list); | |
508e53e2 | 138 | |
d62a17ae | 139 | THREAD_OFF(on->inactivity_timer); |
508e53e2 | 140 | |
d62a17ae | 141 | THREAD_OFF(on->thread_send_dbdesc); |
142 | THREAD_OFF(on->thread_send_lsreq); | |
143 | THREAD_OFF(on->thread_send_lsupdate); | |
144 | THREAD_OFF(on->thread_send_lsack); | |
508e53e2 | 145 | |
d62a17ae | 146 | ospf6_bfd_reg_dereg_nbr(on, ZEBRA_BFD_DEST_DEREGISTER); |
147 | XFREE(MTYPE_OSPF6_NEIGHBOR, on); | |
718e3744 | 148 | } |
149 | ||
d7c0a89a | 150 | static void ospf6_neighbor_state_change(uint8_t next_state, |
d62a17ae | 151 | struct ospf6_neighbor *on, int event) |
718e3744 | 152 | { |
d7c0a89a | 153 | uint8_t prev_state; |
d62a17ae | 154 | |
155 | prev_state = on->state; | |
156 | on->state = next_state; | |
157 | ||
158 | if (prev_state == next_state) | |
159 | return; | |
160 | ||
161 | on->state_change++; | |
162 | monotime(&on->last_changed); | |
163 | ||
164 | /* log */ | |
165 | if (IS_OSPF6_DEBUG_NEIGHBOR(STATE)) { | |
166 | zlog_debug("Neighbor state change %s: [%s]->[%s] (%s)", | |
167 | on->name, ospf6_neighbor_state_str[prev_state], | |
168 | ospf6_neighbor_state_str[next_state], | |
169 | ospf6_neighbor_event_string(event)); | |
170 | } | |
171 | ||
172 | /* Optionally notify about adjacency changes */ | |
173 | if (CHECK_FLAG(on->ospf6_if->area->ospf6->config_flags, | |
174 | OSPF6_LOG_ADJACENCY_CHANGES) | |
175 | && (CHECK_FLAG(on->ospf6_if->area->ospf6->config_flags, | |
176 | OSPF6_LOG_ADJACENCY_DETAIL) | |
177 | || (next_state == OSPF6_NEIGHBOR_FULL) | |
178 | || (next_state < prev_state))) | |
179 | zlog_notice("AdjChg: Nbr %s: %s -> %s (%s)", on->name, | |
180 | ospf6_neighbor_state_str[prev_state], | |
181 | ospf6_neighbor_state_str[next_state], | |
182 | ospf6_neighbor_event_string(event)); | |
183 | ||
184 | if (prev_state == OSPF6_NEIGHBOR_FULL | |
185 | || next_state == OSPF6_NEIGHBOR_FULL) { | |
186 | OSPF6_ROUTER_LSA_SCHEDULE(on->ospf6_if->area); | |
187 | if (on->ospf6_if->state == OSPF6_INTERFACE_DR) { | |
188 | OSPF6_NETWORK_LSA_SCHEDULE(on->ospf6_if); | |
189 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(on->ospf6_if); | |
190 | } | |
690df177 CS |
191 | if (next_state == OSPF6_NEIGHBOR_FULL) |
192 | on->ospf6_if->area->intra_prefix_originate = 1; | |
193 | ||
d62a17ae | 194 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(on->ospf6_if->area); |
76249532 | 195 | |
6b1886f5 CS |
196 | if ((prev_state == OSPF6_NEIGHBOR_LOADING || |
197 | prev_state == OSPF6_NEIGHBOR_EXCHANGE) && | |
198 | next_state == OSPF6_NEIGHBOR_FULL) { | |
76249532 | 199 | OSPF6_AS_EXTERN_LSA_SCHEDULE(on->ospf6_if); |
d6927cf3 | 200 | on->ospf6_if->area->full_nbrs++; |
76249532 | 201 | } |
d6927cf3 CS |
202 | |
203 | if (prev_state == OSPF6_NEIGHBOR_FULL) | |
204 | on->ospf6_if->area->full_nbrs--; | |
d62a17ae | 205 | } |
206 | ||
207 | if ((prev_state == OSPF6_NEIGHBOR_EXCHANGE | |
208 | || prev_state == OSPF6_NEIGHBOR_LOADING) | |
209 | && (next_state != OSPF6_NEIGHBOR_EXCHANGE | |
210 | && next_state != OSPF6_NEIGHBOR_LOADING)) | |
211 | ospf6_maxage_remove(on->ospf6_if->area->ospf6); | |
212 | ||
213 | hook_call(ospf6_neighbor_change, on, next_state, prev_state); | |
214 | ospf6_bfd_trigger_event(on, prev_state, next_state); | |
718e3744 | 215 | } |
216 | ||
508e53e2 | 217 | /* RFC2328 section 10.4 */ |
d62a17ae | 218 | static int need_adjacency(struct ospf6_neighbor *on) |
718e3744 | 219 | { |
d62a17ae | 220 | if (on->ospf6_if->state == OSPF6_INTERFACE_POINTTOPOINT |
221 | || on->ospf6_if->state == OSPF6_INTERFACE_DR | |
222 | || on->ospf6_if->state == OSPF6_INTERFACE_BDR) | |
223 | return 1; | |
718e3744 | 224 | |
d62a17ae | 225 | if (on->ospf6_if->drouter == on->router_id |
226 | || on->ospf6_if->bdrouter == on->router_id) | |
227 | return 1; | |
508e53e2 | 228 | |
d62a17ae | 229 | return 0; |
718e3744 | 230 | } |
231 | ||
d62a17ae | 232 | int hello_received(struct thread *thread) |
718e3744 | 233 | { |
d62a17ae | 234 | struct ospf6_neighbor *on; |
718e3744 | 235 | |
d62a17ae | 236 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
237 | assert(on); | |
718e3744 | 238 | |
d62a17ae | 239 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
240 | zlog_debug("Neighbor Event %s: *HelloReceived*", on->name); | |
508e53e2 | 241 | |
d62a17ae | 242 | /* reset Inactivity Timer */ |
243 | THREAD_OFF(on->inactivity_timer); | |
244 | on->inactivity_timer = NULL; | |
245 | thread_add_timer(master, inactivity_timer, on, | |
246 | on->ospf6_if->dead_interval, &on->inactivity_timer); | |
508e53e2 | 247 | |
d62a17ae | 248 | if (on->state <= OSPF6_NEIGHBOR_DOWN) |
249 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_INIT, on, | |
250 | OSPF6_NEIGHBOR_EVENT_HELLO_RCVD); | |
508e53e2 | 251 | |
d62a17ae | 252 | return 0; |
718e3744 | 253 | } |
254 | ||
d62a17ae | 255 | int twoway_received(struct thread *thread) |
718e3744 | 256 | { |
d62a17ae | 257 | struct ospf6_neighbor *on; |
508e53e2 | 258 | |
d62a17ae | 259 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
260 | assert(on); | |
508e53e2 | 261 | |
d62a17ae | 262 | if (on->state > OSPF6_NEIGHBOR_INIT) |
263 | return 0; | |
508e53e2 | 264 | |
d62a17ae | 265 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
266 | zlog_debug("Neighbor Event %s: *2Way-Received*", on->name); | |
508e53e2 | 267 | |
d62a17ae | 268 | thread_add_event(master, neighbor_change, on->ospf6_if, 0, NULL); |
508e53e2 | 269 | |
d62a17ae | 270 | if (!need_adjacency(on)) { |
271 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_TWOWAY, on, | |
272 | OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD); | |
273 | return 0; | |
274 | } | |
718e3744 | 275 | |
d62a17ae | 276 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART, on, |
277 | OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD); | |
278 | SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT); | |
279 | SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT); | |
280 | SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT); | |
508e53e2 | 281 | |
d62a17ae | 282 | THREAD_OFF(on->thread_send_dbdesc); |
283 | on->thread_send_dbdesc = NULL; | |
284 | thread_add_event(master, ospf6_dbdesc_send, on, 0, | |
285 | &on->thread_send_dbdesc); | |
508e53e2 | 286 | |
d62a17ae | 287 | return 0; |
718e3744 | 288 | } |
289 | ||
d62a17ae | 290 | int negotiation_done(struct thread *thread) |
718e3744 | 291 | { |
d62a17ae | 292 | struct ospf6_neighbor *on; |
293 | struct ospf6_lsa *lsa; | |
294 | ||
295 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); | |
296 | assert(on); | |
297 | ||
298 | if (on->state != OSPF6_NEIGHBOR_EXSTART) | |
299 | return 0; | |
300 | ||
301 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) | |
302 | zlog_debug("Neighbor Event %s: *NegotiationDone*", on->name); | |
303 | ||
304 | /* clear ls-list */ | |
305 | ospf6_lsdb_remove_all(on->summary_list); | |
306 | ospf6_lsdb_remove_all(on->request_list); | |
307 | for (ALL_LSDB(on->retrans_list, lsa)) { | |
308 | ospf6_decrement_retrans_count(lsa); | |
309 | ospf6_lsdb_remove(lsa, on->retrans_list); | |
310 | } | |
311 | ||
312 | /* Interface scoped LSAs */ | |
313 | for (ALL_LSDB(on->ospf6_if->lsdb, lsa)) { | |
314 | if (OSPF6_LSA_IS_MAXAGE(lsa)) { | |
315 | ospf6_increment_retrans_count(lsa); | |
316 | ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->retrans_list); | |
317 | } else | |
318 | ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->summary_list); | |
319 | } | |
320 | ||
321 | /* Area scoped LSAs */ | |
322 | for (ALL_LSDB(on->ospf6_if->area->lsdb, lsa)) { | |
323 | if (OSPF6_LSA_IS_MAXAGE(lsa)) { | |
324 | ospf6_increment_retrans_count(lsa); | |
325 | ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->retrans_list); | |
326 | } else | |
327 | ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->summary_list); | |
328 | } | |
329 | ||
330 | /* AS scoped LSAs */ | |
331 | for (ALL_LSDB(on->ospf6_if->area->ospf6->lsdb, lsa)) { | |
332 | if (OSPF6_LSA_IS_MAXAGE(lsa)) { | |
333 | ospf6_increment_retrans_count(lsa); | |
334 | ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->retrans_list); | |
335 | } else | |
336 | ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->summary_list); | |
337 | } | |
338 | ||
339 | UNSET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT); | |
340 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXCHANGE, on, | |
341 | OSPF6_NEIGHBOR_EVENT_NEGOTIATION_DONE); | |
342 | ||
343 | return 0; | |
718e3744 | 344 | } |
345 | ||
d62a17ae | 346 | int exchange_done(struct thread *thread) |
718e3744 | 347 | { |
d62a17ae | 348 | struct ospf6_neighbor *on; |
718e3744 | 349 | |
d62a17ae | 350 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
351 | assert(on); | |
508e53e2 | 352 | |
d62a17ae | 353 | if (on->state != OSPF6_NEIGHBOR_EXCHANGE) |
354 | return 0; | |
508e53e2 | 355 | |
d62a17ae | 356 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
357 | zlog_debug("Neighbor Event %s: *ExchangeDone*", on->name); | |
508e53e2 | 358 | |
d62a17ae | 359 | THREAD_OFF(on->thread_send_dbdesc); |
360 | ospf6_lsdb_remove_all(on->dbdesc_list); | |
508e53e2 | 361 | |
d62a17ae | 362 | /* XXX |
363 | thread_add_timer (master, ospf6_neighbor_last_dbdesc_release, on, | |
364 | on->ospf6_if->dead_interval); | |
365 | */ | |
508e53e2 | 366 | |
d62a17ae | 367 | if (on->request_list->count == 0) |
368 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_FULL, on, | |
369 | OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE); | |
370 | else { | |
371 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_LOADING, on, | |
372 | OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE); | |
eb82e9ee | 373 | |
d62a17ae | 374 | thread_add_event(master, ospf6_lsreq_send, on, 0, |
375 | &on->thread_send_lsreq); | |
376 | } | |
508e53e2 | 377 | |
d62a17ae | 378 | return 0; |
508e53e2 | 379 | } |
380 | ||
eb82e9ee | 381 | /* Check loading state. */ |
d62a17ae | 382 | void ospf6_check_nbr_loading(struct ospf6_neighbor *on) |
eb82e9ee DD |
383 | { |
384 | ||
d62a17ae | 385 | /* RFC2328 Section 10.9: When the neighbor responds to these requests |
386 | with the proper Link State Update packet(s), the Link state request | |
387 | list is truncated and a new Link State Request packet is sent. | |
388 | */ | |
389 | if ((on->state == OSPF6_NEIGHBOR_LOADING) | |
390 | || (on->state == OSPF6_NEIGHBOR_EXCHANGE)) { | |
391 | if (on->request_list->count == 0) | |
392 | thread_add_event(master, loading_done, on, 0, NULL); | |
393 | else if (on->last_ls_req == NULL) { | |
394 | if (on->thread_send_lsreq != NULL) | |
395 | THREAD_OFF(on->thread_send_lsreq); | |
396 | on->thread_send_lsreq = NULL; | |
397 | thread_add_event(master, ospf6_lsreq_send, on, 0, | |
398 | &on->thread_send_lsreq); | |
399 | } | |
eb82e9ee | 400 | } |
eb82e9ee DD |
401 | } |
402 | ||
d62a17ae | 403 | int loading_done(struct thread *thread) |
508e53e2 | 404 | { |
d62a17ae | 405 | struct ospf6_neighbor *on; |
508e53e2 | 406 | |
d62a17ae | 407 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
408 | assert(on); | |
508e53e2 | 409 | |
d62a17ae | 410 | if (on->state != OSPF6_NEIGHBOR_LOADING) |
411 | return 0; | |
508e53e2 | 412 | |
d62a17ae | 413 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
414 | zlog_debug("Neighbor Event %s: *LoadingDone*", on->name); | |
508e53e2 | 415 | |
d62a17ae | 416 | assert(on->request_list->count == 0); |
508e53e2 | 417 | |
d62a17ae | 418 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_FULL, on, |
419 | OSPF6_NEIGHBOR_EVENT_LOADING_DONE); | |
508e53e2 | 420 | |
d62a17ae | 421 | return 0; |
508e53e2 | 422 | } |
423 | ||
d62a17ae | 424 | int adj_ok(struct thread *thread) |
508e53e2 | 425 | { |
d62a17ae | 426 | struct ospf6_neighbor *on; |
427 | struct ospf6_lsa *lsa; | |
428 | ||
429 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); | |
430 | assert(on); | |
431 | ||
432 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) | |
433 | zlog_debug("Neighbor Event %s: *AdjOK?*", on->name); | |
434 | ||
435 | if (on->state == OSPF6_NEIGHBOR_TWOWAY && need_adjacency(on)) { | |
436 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART, on, | |
437 | OSPF6_NEIGHBOR_EVENT_ADJ_OK); | |
438 | SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT); | |
439 | SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT); | |
440 | SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT); | |
441 | ||
442 | THREAD_OFF(on->thread_send_dbdesc); | |
443 | on->thread_send_dbdesc = NULL; | |
444 | thread_add_event(master, ospf6_dbdesc_send, on, 0, | |
445 | &on->thread_send_dbdesc); | |
446 | ||
447 | } else if (on->state >= OSPF6_NEIGHBOR_EXSTART && !need_adjacency(on)) { | |
448 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_TWOWAY, on, | |
449 | OSPF6_NEIGHBOR_EVENT_ADJ_OK); | |
450 | ospf6_lsdb_remove_all(on->summary_list); | |
451 | ospf6_lsdb_remove_all(on->request_list); | |
452 | for (ALL_LSDB(on->retrans_list, lsa)) { | |
453 | ospf6_decrement_retrans_count(lsa); | |
454 | ospf6_lsdb_remove(lsa, on->retrans_list); | |
455 | } | |
456 | } | |
457 | ||
458 | return 0; | |
508e53e2 | 459 | } |
718e3744 | 460 | |
d62a17ae | 461 | int seqnumber_mismatch(struct thread *thread) |
508e53e2 | 462 | { |
d62a17ae | 463 | struct ospf6_neighbor *on; |
464 | struct ospf6_lsa *lsa; | |
718e3744 | 465 | |
d62a17ae | 466 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
467 | assert(on); | |
718e3744 | 468 | |
d62a17ae | 469 | if (on->state < OSPF6_NEIGHBOR_EXCHANGE) |
470 | return 0; | |
718e3744 | 471 | |
d62a17ae | 472 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
473 | zlog_debug("Neighbor Event %s: *SeqNumberMismatch*", on->name); | |
718e3744 | 474 | |
d62a17ae | 475 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART, on, |
476 | OSPF6_NEIGHBOR_EVENT_SEQNUMBER_MISMATCH); | |
477 | SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT); | |
478 | SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT); | |
479 | SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT); | |
718e3744 | 480 | |
d62a17ae | 481 | ospf6_lsdb_remove_all(on->summary_list); |
482 | ospf6_lsdb_remove_all(on->request_list); | |
483 | for (ALL_LSDB(on->retrans_list, lsa)) { | |
484 | ospf6_decrement_retrans_count(lsa); | |
485 | ospf6_lsdb_remove(lsa, on->retrans_list); | |
486 | } | |
508e53e2 | 487 | |
d62a17ae | 488 | THREAD_OFF(on->thread_send_dbdesc); |
489 | on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */ | |
931b1b8c | 490 | |
d62a17ae | 491 | on->thread_send_dbdesc = NULL; |
492 | thread_add_event(master, ospf6_dbdesc_send, on, 0, | |
493 | &on->thread_send_dbdesc); | |
508e53e2 | 494 | |
d62a17ae | 495 | return 0; |
718e3744 | 496 | } |
497 | ||
d62a17ae | 498 | int bad_lsreq(struct thread *thread) |
718e3744 | 499 | { |
d62a17ae | 500 | struct ospf6_neighbor *on; |
501 | struct ospf6_lsa *lsa; | |
508e53e2 | 502 | |
d62a17ae | 503 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
504 | assert(on); | |
508e53e2 | 505 | |
d62a17ae | 506 | if (on->state < OSPF6_NEIGHBOR_EXCHANGE) |
507 | return 0; | |
718e3744 | 508 | |
d62a17ae | 509 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
510 | zlog_debug("Neighbor Event %s: *BadLSReq*", on->name); | |
718e3744 | 511 | |
d62a17ae | 512 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART, on, |
513 | OSPF6_NEIGHBOR_EVENT_BAD_LSREQ); | |
514 | SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT); | |
515 | SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT); | |
516 | SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT); | |
718e3744 | 517 | |
d62a17ae | 518 | ospf6_lsdb_remove_all(on->summary_list); |
519 | ospf6_lsdb_remove_all(on->request_list); | |
520 | for (ALL_LSDB(on->retrans_list, lsa)) { | |
521 | ospf6_decrement_retrans_count(lsa); | |
522 | ospf6_lsdb_remove(lsa, on->retrans_list); | |
523 | } | |
718e3744 | 524 | |
d62a17ae | 525 | THREAD_OFF(on->thread_send_dbdesc); |
526 | on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */ | |
931b1b8c | 527 | |
d62a17ae | 528 | on->thread_send_dbdesc = NULL; |
529 | thread_add_event(master, ospf6_dbdesc_send, on, 0, | |
530 | &on->thread_send_dbdesc); | |
508e53e2 | 531 | |
d62a17ae | 532 | return 0; |
718e3744 | 533 | } |
534 | ||
d62a17ae | 535 | int oneway_received(struct thread *thread) |
718e3744 | 536 | { |
d62a17ae | 537 | struct ospf6_neighbor *on; |
538 | struct ospf6_lsa *lsa; | |
718e3744 | 539 | |
d62a17ae | 540 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
541 | assert(on); | |
508e53e2 | 542 | |
d62a17ae | 543 | if (on->state < OSPF6_NEIGHBOR_TWOWAY) |
544 | return 0; | |
508e53e2 | 545 | |
d62a17ae | 546 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
547 | zlog_debug("Neighbor Event %s: *1Way-Received*", on->name); | |
508e53e2 | 548 | |
d62a17ae | 549 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_INIT, on, |
550 | OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD); | |
551 | thread_add_event(master, neighbor_change, on->ospf6_if, 0, NULL); | |
508e53e2 | 552 | |
d62a17ae | 553 | ospf6_lsdb_remove_all(on->summary_list); |
554 | ospf6_lsdb_remove_all(on->request_list); | |
555 | for (ALL_LSDB(on->retrans_list, lsa)) { | |
556 | ospf6_decrement_retrans_count(lsa); | |
557 | ospf6_lsdb_remove(lsa, on->retrans_list); | |
558 | } | |
508e53e2 | 559 | |
d62a17ae | 560 | THREAD_OFF(on->thread_send_dbdesc); |
561 | THREAD_OFF(on->thread_send_lsreq); | |
562 | THREAD_OFF(on->thread_send_lsupdate); | |
563 | THREAD_OFF(on->thread_send_lsack); | |
508e53e2 | 564 | |
d62a17ae | 565 | return 0; |
508e53e2 | 566 | } |
567 | ||
d62a17ae | 568 | int inactivity_timer(struct thread *thread) |
508e53e2 | 569 | { |
d62a17ae | 570 | struct ospf6_neighbor *on; |
508e53e2 | 571 | |
d62a17ae | 572 | on = (struct ospf6_neighbor *)THREAD_ARG(thread); |
573 | assert(on); | |
508e53e2 | 574 | |
d62a17ae | 575 | if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
576 | zlog_debug("Neighbor Event %s: *InactivityTimer*", on->name); | |
508e53e2 | 577 | |
d62a17ae | 578 | on->inactivity_timer = NULL; |
579 | on->drouter = on->prev_drouter = 0; | |
580 | on->bdrouter = on->prev_bdrouter = 0; | |
508e53e2 | 581 | |
d62a17ae | 582 | ospf6_neighbor_state_change(OSPF6_NEIGHBOR_DOWN, on, |
583 | OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER); | |
584 | thread_add_event(master, neighbor_change, on->ospf6_if, 0, NULL); | |
508e53e2 | 585 | |
d62a17ae | 586 | listnode_delete(on->ospf6_if->neighbor_list, on); |
587 | ospf6_neighbor_delete(on); | |
508e53e2 | 588 | |
d62a17ae | 589 | return 0; |
718e3744 | 590 | } |
591 | ||
508e53e2 | 592 | |
718e3744 | 593 | /* vty functions */ |
594 | /* show neighbor structure */ | |
d62a17ae | 595 | static void ospf6_neighbor_show(struct vty *vty, struct ospf6_neighbor *on) |
718e3744 | 596 | { |
d62a17ae | 597 | char router_id[16]; |
68bfcc05 | 598 | char duration[64]; |
d62a17ae | 599 | struct timeval res; |
600 | char nstate[16]; | |
68bfcc05 | 601 | char deadtime[64]; |
d62a17ae | 602 | long h, m, s; |
603 | ||
604 | /* Router-ID (Name) */ | |
605 | inet_ntop(AF_INET, &on->router_id, router_id, sizeof(router_id)); | |
508e53e2 | 606 | #ifdef HAVE_GETNAMEINFO |
d62a17ae | 607 | { |
608 | } | |
508e53e2 | 609 | #endif /*HAVE_GETNAMEINFO*/ |
610 | ||
d62a17ae | 611 | /* Dead time */ |
612 | h = m = s = 0; | |
613 | if (on->inactivity_timer) { | |
614 | s = monotime_until(&on->inactivity_timer->u.sands, NULL) | |
615 | / 1000000LL; | |
616 | h = s / 3600; | |
617 | s -= h * 3600; | |
618 | m = s / 60; | |
619 | s -= m * 60; | |
620 | } | |
621 | snprintf(deadtime, sizeof(deadtime), "%02ld:%02ld:%02ld", h, m, s); | |
622 | ||
623 | /* Neighbor State */ | |
624 | if (if_is_pointopoint(on->ospf6_if->interface)) | |
625 | snprintf(nstate, sizeof(nstate), "PointToPoint"); | |
626 | else { | |
627 | if (on->router_id == on->drouter) | |
628 | snprintf(nstate, sizeof(nstate), "DR"); | |
629 | else if (on->router_id == on->bdrouter) | |
630 | snprintf(nstate, sizeof(nstate), "BDR"); | |
631 | else | |
632 | snprintf(nstate, sizeof(nstate), "DROther"); | |
633 | } | |
634 | ||
635 | /* Duration */ | |
636 | monotime_since(&on->last_changed, &res); | |
637 | timerstring(&res, duration, sizeof(duration)); | |
638 | ||
639 | /* | |
640 | vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]\n", | |
641 | "Neighbor ID", "Pri", "DeadTime", "State", "", "Duration", | |
642 | "I/F", "State"); | |
643 | */ | |
644 | ||
645 | vty_out(vty, "%-15s %3d %11s %8s/%-12s %11s %s[%s]\n", router_id, | |
646 | on->priority, deadtime, ospf6_neighbor_state_str[on->state], | |
647 | nstate, duration, on->ospf6_if->interface->name, | |
648 | ospf6_interface_state_str[on->ospf6_if->state]); | |
508e53e2 | 649 | } |
650 | ||
d62a17ae | 651 | static void ospf6_neighbor_show_drchoice(struct vty *vty, |
652 | struct ospf6_neighbor *on) | |
508e53e2 | 653 | { |
d62a17ae | 654 | char router_id[16]; |
655 | char drouter[16], bdrouter[16]; | |
68bfcc05 | 656 | char duration[64]; |
d62a17ae | 657 | struct timeval now, res; |
658 | ||
659 | /* | |
660 | vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]\n", | |
661 | "RouterID", "State", "Duration", "DR", "BDR", "I/F", | |
662 | "State"); | |
663 | */ | |
664 | ||
665 | inet_ntop(AF_INET, &on->router_id, router_id, sizeof(router_id)); | |
666 | inet_ntop(AF_INET, &on->drouter, drouter, sizeof(drouter)); | |
667 | inet_ntop(AF_INET, &on->bdrouter, bdrouter, sizeof(bdrouter)); | |
668 | ||
669 | monotime(&now); | |
670 | timersub(&now, &on->last_changed, &res); | |
671 | timerstring(&res, duration, sizeof(duration)); | |
672 | ||
673 | vty_out(vty, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n", router_id, | |
674 | ospf6_neighbor_state_str[on->state], duration, drouter, | |
675 | bdrouter, on->ospf6_if->interface->name, | |
676 | ospf6_interface_state_str[on->ospf6_if->state]); | |
718e3744 | 677 | } |
678 | ||
d62a17ae | 679 | static void ospf6_neighbor_show_detail(struct vty *vty, |
680 | struct ospf6_neighbor *on) | |
718e3744 | 681 | { |
d62a17ae | 682 | char drouter[16], bdrouter[16]; |
683 | char linklocal_addr[64], duration[32]; | |
684 | struct timeval now, res; | |
685 | struct ospf6_lsa *lsa; | |
686 | ||
687 | inet_ntop(AF_INET6, &on->linklocal_addr, linklocal_addr, | |
688 | sizeof(linklocal_addr)); | |
689 | inet_ntop(AF_INET, &on->drouter, drouter, sizeof(drouter)); | |
690 | inet_ntop(AF_INET, &on->bdrouter, bdrouter, sizeof(bdrouter)); | |
691 | ||
692 | monotime(&now); | |
693 | timersub(&now, &on->last_changed, &res); | |
694 | timerstring(&res, duration, sizeof(duration)); | |
695 | ||
696 | vty_out(vty, " Neighbor %s\n", on->name); | |
697 | vty_out(vty, " Area %s via interface %s (ifindex %d)\n", | |
698 | on->ospf6_if->area->name, on->ospf6_if->interface->name, | |
699 | on->ospf6_if->interface->ifindex); | |
700 | vty_out(vty, " His IfIndex: %d Link-local address: %s\n", | |
701 | on->ifindex, linklocal_addr); | |
702 | vty_out(vty, " State %s for a duration of %s\n", | |
703 | ospf6_neighbor_state_str[on->state], duration); | |
704 | vty_out(vty, " His choice of DR/BDR %s/%s, Priority %d\n", drouter, | |
705 | bdrouter, on->priority); | |
706 | vty_out(vty, " DbDesc status: %s%s%s SeqNum: %#lx\n", | |
707 | (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT) ? "Initial " | |
708 | : ""), | |
709 | (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT) ? "More " : ""), | |
710 | (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT) ? "Master" | |
711 | : "Slave"), | |
d7c0a89a | 712 | (unsigned long)ntohl(on->dbdesc_seqnum)); |
d62a17ae | 713 | |
714 | vty_out(vty, " Summary-List: %d LSAs\n", on->summary_list->count); | |
715 | for (ALL_LSDB(on->summary_list, lsa)) | |
716 | vty_out(vty, " %s\n", lsa->name); | |
717 | ||
718 | vty_out(vty, " Request-List: %d LSAs\n", on->request_list->count); | |
719 | for (ALL_LSDB(on->request_list, lsa)) | |
720 | vty_out(vty, " %s\n", lsa->name); | |
721 | ||
722 | vty_out(vty, " Retrans-List: %d LSAs\n", on->retrans_list->count); | |
723 | for (ALL_LSDB(on->retrans_list, lsa)) | |
724 | vty_out(vty, " %s\n", lsa->name); | |
725 | ||
726 | timerclear(&res); | |
727 | if (on->thread_send_dbdesc) | |
728 | timersub(&on->thread_send_dbdesc->u.sands, &now, &res); | |
729 | timerstring(&res, duration, sizeof(duration)); | |
730 | vty_out(vty, " %d Pending LSAs for DbDesc in Time %s [thread %s]\n", | |
731 | on->dbdesc_list->count, duration, | |
732 | (on->thread_send_dbdesc ? "on" : "off")); | |
733 | for (ALL_LSDB(on->dbdesc_list, lsa)) | |
734 | vty_out(vty, " %s\n", lsa->name); | |
735 | ||
736 | timerclear(&res); | |
737 | if (on->thread_send_lsreq) | |
738 | timersub(&on->thread_send_lsreq->u.sands, &now, &res); | |
739 | timerstring(&res, duration, sizeof(duration)); | |
740 | vty_out(vty, " %d Pending LSAs for LSReq in Time %s [thread %s]\n", | |
741 | on->request_list->count, duration, | |
742 | (on->thread_send_lsreq ? "on" : "off")); | |
743 | for (ALL_LSDB(on->request_list, lsa)) | |
744 | vty_out(vty, " %s\n", lsa->name); | |
745 | ||
746 | timerclear(&res); | |
747 | if (on->thread_send_lsupdate) | |
748 | timersub(&on->thread_send_lsupdate->u.sands, &now, &res); | |
749 | timerstring(&res, duration, sizeof(duration)); | |
750 | vty_out(vty, | |
751 | " %d Pending LSAs for LSUpdate in Time %s [thread %s]\n", | |
752 | on->lsupdate_list->count, duration, | |
753 | (on->thread_send_lsupdate ? "on" : "off")); | |
754 | for (ALL_LSDB(on->lsupdate_list, lsa)) | |
755 | vty_out(vty, " %s\n", lsa->name); | |
756 | ||
757 | timerclear(&res); | |
758 | if (on->thread_send_lsack) | |
759 | timersub(&on->thread_send_lsack->u.sands, &now, &res); | |
760 | timerstring(&res, duration, sizeof(duration)); | |
761 | vty_out(vty, " %d Pending LSAs for LSAck in Time %s [thread %s]\n", | |
762 | on->lsack_list->count, duration, | |
763 | (on->thread_send_lsack ? "on" : "off")); | |
764 | for (ALL_LSDB(on->lsack_list, lsa)) | |
765 | vty_out(vty, " %s\n", lsa->name); | |
766 | ||
767 | ospf6_bfd_show_info(vty, on->bfd_info, 0); | |
718e3744 | 768 | } |
769 | ||
508e53e2 | 770 | DEFUN (show_ipv6_ospf6_neighbor, |
771 | show_ipv6_ospf6_neighbor_cmd, | |
6de69f83 | 772 | "show ipv6 ospf6 neighbor [<detail|drchoice>]", |
718e3744 | 773 | SHOW_STR |
774 | IP6_STR | |
775 | OSPF6_STR | |
776 | "Neighbor list\n" | |
1d68dbfe DW |
777 | "Display details\n" |
778 | "Display DR choices\n") | |
718e3744 | 779 | { |
d62a17ae | 780 | int idx_type = 4; |
781 | struct ospf6_neighbor *on; | |
782 | struct ospf6_interface *oi; | |
783 | struct ospf6_area *oa; | |
784 | struct listnode *i, *j, *k; | |
785 | void (*showfunc)(struct vty *, struct ospf6_neighbor *); | |
786 | ||
787 | OSPF6_CMD_CHECK_RUNNING(); | |
788 | showfunc = ospf6_neighbor_show; | |
789 | ||
790 | if (argc == 5) { | |
791 | if (!strncmp(argv[idx_type]->arg, "de", 2)) | |
792 | showfunc = ospf6_neighbor_show_detail; | |
793 | else if (!strncmp(argv[idx_type]->arg, "dr", 2)) | |
794 | showfunc = ospf6_neighbor_show_drchoice; | |
795 | } | |
796 | ||
797 | if (showfunc == ospf6_neighbor_show) | |
798 | vty_out(vty, "%-15s %3s %11s %8s/%-12s %11s %s[%s]\n", | |
799 | "Neighbor ID", "Pri", "DeadTime", "State", "IfState", | |
800 | "Duration", "I/F", "State"); | |
801 | else if (showfunc == ospf6_neighbor_show_drchoice) | |
802 | vty_out(vty, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n", "RouterID", | |
803 | "State", "Duration", "DR", "BDR", "I/F", "State"); | |
804 | ||
805 | for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) | |
806 | for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) | |
807 | for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, k, on)) | |
808 | (*showfunc)(vty, on); | |
809 | ||
810 | return CMD_SUCCESS; | |
718e3744 | 811 | } |
812 | ||
718e3744 | 813 | |
508e53e2 | 814 | DEFUN (show_ipv6_ospf6_neighbor_one, |
815 | show_ipv6_ospf6_neighbor_one_cmd, | |
816 | "show ipv6 ospf6 neighbor A.B.C.D", | |
718e3744 | 817 | SHOW_STR |
818 | IP6_STR | |
819 | OSPF6_STR | |
508e53e2 | 820 | "Neighbor list\n" |
821 | "Specify Router-ID as IPv4 address notation\n" | |
822 | ) | |
718e3744 | 823 | { |
d62a17ae | 824 | int idx_ipv4 = 4; |
825 | struct ospf6_neighbor *on; | |
826 | struct ospf6_interface *oi; | |
827 | struct ospf6_area *oa; | |
828 | struct listnode *i, *j, *k; | |
829 | void (*showfunc)(struct vty *, struct ospf6_neighbor *); | |
d7c0a89a | 830 | uint32_t router_id; |
d62a17ae | 831 | |
832 | OSPF6_CMD_CHECK_RUNNING(); | |
833 | showfunc = ospf6_neighbor_show_detail; | |
834 | ||
835 | if ((inet_pton(AF_INET, argv[idx_ipv4]->arg, &router_id)) != 1) { | |
836 | vty_out(vty, "Router-ID is not parsable: %s\n", | |
837 | argv[idx_ipv4]->arg); | |
838 | return CMD_SUCCESS; | |
839 | } | |
840 | ||
841 | for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) | |
842 | for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) | |
843 | for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, k, on)) | |
844 | (*showfunc)(vty, on); | |
845 | ||
846 | return CMD_SUCCESS; | |
718e3744 | 847 | } |
848 | ||
d62a17ae | 849 | void ospf6_neighbor_init(void) |
718e3744 | 850 | { |
d62a17ae | 851 | install_element(VIEW_NODE, &show_ipv6_ospf6_neighbor_cmd); |
852 | install_element(VIEW_NODE, &show_ipv6_ospf6_neighbor_one_cmd); | |
508e53e2 | 853 | } |
854 | ||
855 | DEFUN (debug_ospf6_neighbor, | |
856 | debug_ospf6_neighbor_cmd, | |
6de69f83 | 857 | "debug ospf6 neighbor [<state|event>]", |
508e53e2 | 858 | DEBUG_STR |
859 | OSPF6_STR | |
860 | "Debug OSPFv3 Neighbor\n" | |
1d68dbfe DW |
861 | "Debug OSPFv3 Neighbor State Change\n" |
862 | "Debug OSPFv3 Neighbor Event\n") | |
508e53e2 | 863 | { |
d62a17ae | 864 | int idx_type = 3; |
865 | unsigned char level = 0; | |
866 | ||
867 | if (argc == 4) { | |
868 | if (!strncmp(argv[idx_type]->arg, "s", 1)) | |
869 | level = OSPF6_DEBUG_NEIGHBOR_STATE; | |
870 | else if (!strncmp(argv[idx_type]->arg, "e", 1)) | |
871 | level = OSPF6_DEBUG_NEIGHBOR_EVENT; | |
872 | } else | |
873 | level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT; | |
874 | ||
875 | OSPF6_DEBUG_NEIGHBOR_ON(level); | |
876 | return CMD_SUCCESS; | |
718e3744 | 877 | } |
878 | ||
508e53e2 | 879 | |
880 | DEFUN (no_debug_ospf6_neighbor, | |
881 | no_debug_ospf6_neighbor_cmd, | |
6de69f83 | 882 | "no debug ospf6 neighbor [<state|event>]", |
508e53e2 | 883 | NO_STR |
884 | DEBUG_STR | |
885 | OSPF6_STR | |
886 | "Debug OSPFv3 Neighbor\n" | |
1d68dbfe DW |
887 | "Debug OSPFv3 Neighbor State Change\n" |
888 | "Debug OSPFv3 Neighbor Event\n") | |
508e53e2 | 889 | { |
d62a17ae | 890 | int idx_type = 4; |
891 | unsigned char level = 0; | |
892 | ||
893 | if (argc == 5) { | |
894 | if (!strncmp(argv[idx_type]->arg, "s", 1)) | |
895 | level = OSPF6_DEBUG_NEIGHBOR_STATE; | |
896 | if (!strncmp(argv[idx_type]->arg, "e", 1)) | |
897 | level = OSPF6_DEBUG_NEIGHBOR_EVENT; | |
898 | } else | |
899 | level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT; | |
900 | ||
901 | OSPF6_DEBUG_NEIGHBOR_OFF(level); | |
902 | return CMD_SUCCESS; | |
508e53e2 | 903 | } |
904 | ||
508e53e2 | 905 | |
4dfd8aff DW |
906 | DEFUN (no_debug_ospf6, |
907 | no_debug_ospf6_cmd, | |
908 | "no debug ospf6", | |
909 | NO_STR | |
910 | DEBUG_STR | |
911 | OSPF6_STR) | |
912 | { | |
d7c0a89a | 913 | unsigned int i; |
d62a17ae | 914 | struct ospf6_lsa_handler *handler = NULL; |
915 | ||
916 | OSPF6_DEBUG_ABR_OFF(); | |
917 | OSPF6_DEBUG_ASBR_OFF(); | |
918 | OSPF6_DEBUG_BROUTER_OFF(); | |
919 | OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF(); | |
920 | OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF(); | |
921 | OSPF6_DEBUG_FLOODING_OFF(); | |
922 | OSPF6_DEBUG_INTERFACE_OFF(); | |
923 | ||
924 | for (i = 0; i < vector_active(ospf6_lsa_handler_vector); i++) { | |
925 | handler = vector_slot(ospf6_lsa_handler_vector, i); | |
926 | ||
927 | if (handler != NULL) { | |
928 | UNSET_FLAG(handler->debug, OSPF6_LSA_DEBUG); | |
929 | } | |
930 | } | |
931 | ||
932 | for (i = 0; i < 6; i++) | |
933 | OSPF6_DEBUG_MESSAGE_OFF(i, | |
934 | OSPF6_DEBUG_NEIGHBOR_STATE | |
935 | | OSPF6_DEBUG_NEIGHBOR_EVENT); | |
936 | ||
937 | OSPF6_DEBUG_NEIGHBOR_OFF(OSPF6_DEBUG_NEIGHBOR_STATE | |
938 | | OSPF6_DEBUG_NEIGHBOR_EVENT); | |
939 | OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_TABLE); | |
940 | OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_INTRA); | |
941 | OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_INTER); | |
942 | OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_MEMORY); | |
943 | OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_PROCESS); | |
944 | OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_TIME); | |
945 | OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_DATABASE); | |
946 | OSPF6_DEBUG_ZEBRA_OFF(OSPF6_DEBUG_ZEBRA_SEND | OSPF6_DEBUG_ZEBRA_RECV); | |
947 | ||
948 | return CMD_SUCCESS; | |
4dfd8aff DW |
949 | } |
950 | ||
d62a17ae | 951 | int config_write_ospf6_debug_neighbor(struct vty *vty) |
508e53e2 | 952 | { |
d62a17ae | 953 | if (IS_OSPF6_DEBUG_NEIGHBOR(STATE) && IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) |
954 | vty_out(vty, "debug ospf6 neighbor\n"); | |
955 | else if (IS_OSPF6_DEBUG_NEIGHBOR(STATE)) | |
956 | vty_out(vty, "debug ospf6 neighbor state\n"); | |
957 | else if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT)) | |
958 | vty_out(vty, "debug ospf6 neighbor event\n"); | |
959 | return 0; | |
508e53e2 | 960 | } |
961 | ||
d62a17ae | 962 | void install_element_ospf6_debug_neighbor(void) |
508e53e2 | 963 | { |
d62a17ae | 964 | install_element(ENABLE_NODE, &debug_ospf6_neighbor_cmd); |
965 | install_element(ENABLE_NODE, &no_debug_ospf6_neighbor_cmd); | |
966 | install_element(ENABLE_NODE, &no_debug_ospf6_cmd); | |
967 | install_element(CONFIG_NODE, &debug_ospf6_neighbor_cmd); | |
968 | install_element(CONFIG_NODE, &no_debug_ospf6_neighbor_cmd); | |
969 | install_element(CONFIG_NODE, &no_debug_ospf6_cmd); | |
508e53e2 | 970 | } |