]> git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_neighbor.c
lib: add [XXXXX-XXXXX] log prefix & config
[mirror_frr.git] / ospf6d / ospf6_neighbor.c
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 #include <zebra.h>
22
23 #include "log.h"
24 #include "memory.h"
25 #include "thread.h"
26 #include "linklist.h"
27 #include "vty.h"
28 #include "command.h"
29
30 #include "ospf6_proto.h"
31 #include "ospf6_lsa.h"
32 #include "ospf6_lsdb.h"
33 #include "ospf6_message.h"
34 #include "ospf6_top.h"
35 #include "ospf6_area.h"
36 #include "ospf6_interface.h"
37 #include "ospf6_neighbor.h"
38 #include "ospf6_intra.h"
39 #include "ospf6_flood.h"
40 #include "ospf6d.h"
41 #include "ospf6_bfd.h"
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"
47 #include "lib/json.h"
48
49 DEFINE_HOOK(ospf6_neighbor_change,
50 (struct ospf6_neighbor * on, int state, int next_state),
51 (on, state, next_state));
52
53 unsigned char conf_debug_ospf6_neighbor = 0;
54
55 const char *const ospf6_neighbor_state_str[] = {
56 "None", "Down", "Attempt", "Init", "Twoway",
57 "ExStart", "ExChange", "Loading", "Full", NULL};
58
59 const char *const ospf6_neighbor_event_str[] = {
60 "NoEvent", "HelloReceived", "2-WayReceived", "NegotiationDone",
61 "ExchangeDone", "LoadingDone", "AdjOK?", "SeqNumberMismatch",
62 "BadLSReq", "1-WayReceived", "InactivityTimer",
63 };
64
65 int ospf6_neighbor_cmp(void *va, void *vb)
66 {
67 struct ospf6_neighbor *ona = (struct ospf6_neighbor *)va;
68 struct ospf6_neighbor *onb = (struct ospf6_neighbor *)vb;
69
70 if (ona->router_id == onb->router_id)
71 return 0;
72
73 return (ntohl(ona->router_id) < ntohl(onb->router_id)) ? -1 : 1;
74 }
75
76 struct ospf6_neighbor *ospf6_neighbor_lookup(uint32_t router_id,
77 struct ospf6_interface *oi)
78 {
79 struct listnode *n;
80 struct ospf6_neighbor *on;
81
82 for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, n, on))
83 if (on->router_id == router_id)
84 return on;
85
86 return (struct ospf6_neighbor *)NULL;
87 }
88
89 /* create ospf6_neighbor */
90 struct ospf6_neighbor *ospf6_neighbor_create(uint32_t router_id,
91 struct ospf6_interface *oi)
92 {
93 struct ospf6_neighbor *on;
94 char buf[16];
95
96 on = XCALLOC(MTYPE_OSPF6_NEIGHBOR, sizeof(struct ospf6_neighbor));
97 inet_ntop(AF_INET, &router_id, buf, sizeof(buf));
98 snprintf(on->name, sizeof(on->name), "%s%%%s", buf,
99 oi->interface->name);
100 on->ospf6_if = oi;
101 on->state = OSPF6_NEIGHBOR_DOWN;
102 on->state_change = 0;
103 monotime(&on->last_changed);
104 on->router_id = router_id;
105
106 on->summary_list = ospf6_lsdb_create(on);
107 on->request_list = ospf6_lsdb_create(on);
108 on->retrans_list = ospf6_lsdb_create(on);
109
110 on->dbdesc_list = ospf6_lsdb_create(on);
111 on->lsupdate_list = ospf6_lsdb_create(on);
112 on->lsack_list = ospf6_lsdb_create(on);
113
114 listnode_add_sort(oi->neighbor_list, on);
115
116 ospf6_bfd_info_nbr_create(oi, on);
117 return on;
118 }
119
120 void ospf6_neighbor_delete(struct ospf6_neighbor *on)
121 {
122 struct ospf6_lsa *lsa, *lsanext;
123
124 ospf6_lsdb_remove_all(on->summary_list);
125 ospf6_lsdb_remove_all(on->request_list);
126 for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
127 ospf6_decrement_retrans_count(lsa);
128 ospf6_lsdb_remove(lsa, on->retrans_list);
129 }
130
131 ospf6_lsdb_remove_all(on->dbdesc_list);
132 ospf6_lsdb_remove_all(on->lsupdate_list);
133 ospf6_lsdb_remove_all(on->lsack_list);
134
135 ospf6_lsdb_delete(on->summary_list);
136 ospf6_lsdb_delete(on->request_list);
137 ospf6_lsdb_delete(on->retrans_list);
138
139 ospf6_lsdb_delete(on->dbdesc_list);
140 ospf6_lsdb_delete(on->lsupdate_list);
141 ospf6_lsdb_delete(on->lsack_list);
142
143 THREAD_OFF(on->inactivity_timer);
144
145 THREAD_OFF(on->thread_send_dbdesc);
146 THREAD_OFF(on->thread_send_lsreq);
147 THREAD_OFF(on->thread_send_lsupdate);
148 THREAD_OFF(on->thread_send_lsack);
149
150 ospf6_bfd_reg_dereg_nbr(on, ZEBRA_BFD_DEST_DEREGISTER);
151 XFREE(MTYPE_OSPF6_NEIGHBOR, on);
152 }
153
154 static void ospf6_neighbor_state_change(uint8_t next_state,
155 struct ospf6_neighbor *on, int event)
156 {
157 uint8_t prev_state;
158
159 prev_state = on->state;
160 on->state = next_state;
161
162 if (prev_state == next_state)
163 return;
164
165 on->state_change++;
166 monotime(&on->last_changed);
167
168 /* log */
169 if (IS_OSPF6_DEBUG_NEIGHBOR(STATE)) {
170 zlog_debug("Neighbor state change %s: [%s]->[%s] (%s)",
171 on->name, ospf6_neighbor_state_str[prev_state],
172 ospf6_neighbor_state_str[next_state],
173 ospf6_neighbor_event_string(event));
174 }
175
176 /* Optionally notify about adjacency changes */
177 if (CHECK_FLAG(on->ospf6_if->area->ospf6->config_flags,
178 OSPF6_LOG_ADJACENCY_CHANGES)
179 && (CHECK_FLAG(on->ospf6_if->area->ospf6->config_flags,
180 OSPF6_LOG_ADJACENCY_DETAIL)
181 || (next_state == OSPF6_NEIGHBOR_FULL)
182 || (next_state < prev_state)))
183 zlog_notice("AdjChg: Nbr %s: %s -> %s (%s)", on->name,
184 ospf6_neighbor_state_str[prev_state],
185 ospf6_neighbor_state_str[next_state],
186 ospf6_neighbor_event_string(event));
187
188 if (prev_state == OSPF6_NEIGHBOR_FULL
189 || next_state == OSPF6_NEIGHBOR_FULL) {
190 OSPF6_ROUTER_LSA_SCHEDULE(on->ospf6_if->area);
191 if (on->ospf6_if->state == OSPF6_INTERFACE_DR) {
192 OSPF6_NETWORK_LSA_SCHEDULE(on->ospf6_if);
193 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(on->ospf6_if);
194 }
195 if (next_state == OSPF6_NEIGHBOR_FULL)
196 on->ospf6_if->area->intra_prefix_originate = 1;
197
198 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(on->ospf6_if->area);
199
200 if ((prev_state == OSPF6_NEIGHBOR_LOADING ||
201 prev_state == OSPF6_NEIGHBOR_EXCHANGE) &&
202 next_state == OSPF6_NEIGHBOR_FULL) {
203 OSPF6_AS_EXTERN_LSA_SCHEDULE(on->ospf6_if);
204 on->ospf6_if->area->full_nbrs++;
205 }
206
207 if (prev_state == OSPF6_NEIGHBOR_FULL)
208 on->ospf6_if->area->full_nbrs--;
209 }
210
211 if ((prev_state == OSPF6_NEIGHBOR_EXCHANGE
212 || prev_state == OSPF6_NEIGHBOR_LOADING)
213 && (next_state != OSPF6_NEIGHBOR_EXCHANGE
214 && next_state != OSPF6_NEIGHBOR_LOADING))
215 ospf6_maxage_remove(on->ospf6_if->area->ospf6);
216
217 hook_call(ospf6_neighbor_change, on, next_state, prev_state);
218 ospf6_bfd_trigger_event(on, prev_state, next_state);
219 }
220
221 /* RFC2328 section 10.4 */
222 static int need_adjacency(struct ospf6_neighbor *on)
223 {
224 if (on->ospf6_if->state == OSPF6_INTERFACE_POINTTOPOINT
225 || on->ospf6_if->state == OSPF6_INTERFACE_DR
226 || on->ospf6_if->state == OSPF6_INTERFACE_BDR)
227 return 1;
228
229 if (on->ospf6_if->drouter == on->router_id
230 || on->ospf6_if->bdrouter == on->router_id)
231 return 1;
232
233 return 0;
234 }
235
236 int hello_received(struct thread *thread)
237 {
238 struct ospf6_neighbor *on;
239
240 on = (struct ospf6_neighbor *)THREAD_ARG(thread);
241 assert(on);
242
243 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
244 zlog_debug("Neighbor Event %s: *HelloReceived*", on->name);
245
246 /* reset Inactivity Timer */
247 THREAD_OFF(on->inactivity_timer);
248 on->inactivity_timer = NULL;
249 thread_add_timer(master, inactivity_timer, on,
250 on->ospf6_if->dead_interval, &on->inactivity_timer);
251
252 if (on->state <= OSPF6_NEIGHBOR_DOWN)
253 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_INIT, on,
254 OSPF6_NEIGHBOR_EVENT_HELLO_RCVD);
255
256 return 0;
257 }
258
259 int twoway_received(struct thread *thread)
260 {
261 struct ospf6_neighbor *on;
262
263 on = (struct ospf6_neighbor *)THREAD_ARG(thread);
264 assert(on);
265
266 if (on->state > OSPF6_NEIGHBOR_INIT)
267 return 0;
268
269 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
270 zlog_debug("Neighbor Event %s: *2Way-Received*", on->name);
271
272 thread_add_event(master, neighbor_change, on->ospf6_if, 0, NULL);
273
274 if (!need_adjacency(on)) {
275 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_TWOWAY, on,
276 OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD);
277 return 0;
278 }
279
280 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART, on,
281 OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD);
282 SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
283 SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT);
284 SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT);
285
286 THREAD_OFF(on->thread_send_dbdesc);
287 on->thread_send_dbdesc = NULL;
288 thread_add_event(master, ospf6_dbdesc_send, on, 0,
289 &on->thread_send_dbdesc);
290
291 return 0;
292 }
293
294 int negotiation_done(struct thread *thread)
295 {
296 struct ospf6_neighbor *on;
297 struct ospf6_lsa *lsa, *lsanext;
298
299 on = (struct ospf6_neighbor *)THREAD_ARG(thread);
300 assert(on);
301
302 if (on->state != OSPF6_NEIGHBOR_EXSTART)
303 return 0;
304
305 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
306 zlog_debug("Neighbor Event %s: *NegotiationDone*", on->name);
307
308 /* clear ls-list */
309 ospf6_lsdb_remove_all(on->summary_list);
310 ospf6_lsdb_remove_all(on->request_list);
311 for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
312 ospf6_decrement_retrans_count(lsa);
313 ospf6_lsdb_remove(lsa, on->retrans_list);
314 }
315
316 /* Interface scoped LSAs */
317 for (ALL_LSDB(on->ospf6_if->lsdb, lsa, lsanext)) {
318 if (OSPF6_LSA_IS_MAXAGE(lsa)) {
319 ospf6_increment_retrans_count(lsa);
320 ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->retrans_list);
321 } else
322 ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->summary_list);
323 }
324
325 /* Area scoped LSAs */
326 for (ALL_LSDB(on->ospf6_if->area->lsdb, lsa, lsanext)) {
327 if (OSPF6_LSA_IS_MAXAGE(lsa)) {
328 ospf6_increment_retrans_count(lsa);
329 ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->retrans_list);
330 } else
331 ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->summary_list);
332 }
333
334 /* AS scoped LSAs */
335 for (ALL_LSDB(on->ospf6_if->area->ospf6->lsdb, lsa, lsanext)) {
336 if (OSPF6_LSA_IS_MAXAGE(lsa)) {
337 ospf6_increment_retrans_count(lsa);
338 ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->retrans_list);
339 } else
340 ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->summary_list);
341 }
342
343 UNSET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT);
344 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXCHANGE, on,
345 OSPF6_NEIGHBOR_EVENT_NEGOTIATION_DONE);
346
347 return 0;
348 }
349
350 int exchange_done(struct thread *thread)
351 {
352 struct ospf6_neighbor *on;
353
354 on = (struct ospf6_neighbor *)THREAD_ARG(thread);
355 assert(on);
356
357 if (on->state != OSPF6_NEIGHBOR_EXCHANGE)
358 return 0;
359
360 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
361 zlog_debug("Neighbor Event %s: *ExchangeDone*", on->name);
362
363 THREAD_OFF(on->thread_send_dbdesc);
364 ospf6_lsdb_remove_all(on->dbdesc_list);
365
366 /* XXX
367 thread_add_timer (master, ospf6_neighbor_last_dbdesc_release, on,
368 on->ospf6_if->dead_interval);
369 */
370
371 if (on->request_list->count == 0)
372 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_FULL, on,
373 OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE);
374 else {
375 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_LOADING, on,
376 OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE);
377
378 thread_add_event(master, ospf6_lsreq_send, on, 0,
379 &on->thread_send_lsreq);
380 }
381
382 return 0;
383 }
384
385 /* Check loading state. */
386 void ospf6_check_nbr_loading(struct ospf6_neighbor *on)
387 {
388
389 /* RFC2328 Section 10.9: When the neighbor responds to these requests
390 with the proper Link State Update packet(s), the Link state request
391 list is truncated and a new Link State Request packet is sent.
392 */
393 if ((on->state == OSPF6_NEIGHBOR_LOADING)
394 || (on->state == OSPF6_NEIGHBOR_EXCHANGE)) {
395 if (on->request_list->count == 0)
396 thread_add_event(master, loading_done, on, 0, NULL);
397 else if (on->last_ls_req == NULL) {
398 if (on->thread_send_lsreq != NULL)
399 THREAD_OFF(on->thread_send_lsreq);
400 on->thread_send_lsreq = NULL;
401 thread_add_event(master, ospf6_lsreq_send, on, 0,
402 &on->thread_send_lsreq);
403 }
404 }
405 }
406
407 int loading_done(struct thread *thread)
408 {
409 struct ospf6_neighbor *on;
410
411 on = (struct ospf6_neighbor *)THREAD_ARG(thread);
412 assert(on);
413
414 if (on->state != OSPF6_NEIGHBOR_LOADING)
415 return 0;
416
417 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
418 zlog_debug("Neighbor Event %s: *LoadingDone*", on->name);
419
420 assert(on->request_list->count == 0);
421
422 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_FULL, on,
423 OSPF6_NEIGHBOR_EVENT_LOADING_DONE);
424
425 return 0;
426 }
427
428 int adj_ok(struct thread *thread)
429 {
430 struct ospf6_neighbor *on;
431 struct ospf6_lsa *lsa, *lsanext;
432
433 on = (struct ospf6_neighbor *)THREAD_ARG(thread);
434 assert(on);
435
436 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
437 zlog_debug("Neighbor Event %s: *AdjOK?*", on->name);
438
439 if (on->state == OSPF6_NEIGHBOR_TWOWAY && need_adjacency(on)) {
440 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART, on,
441 OSPF6_NEIGHBOR_EVENT_ADJ_OK);
442 SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
443 SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT);
444 SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT);
445
446 THREAD_OFF(on->thread_send_dbdesc);
447 on->thread_send_dbdesc = NULL;
448 thread_add_event(master, ospf6_dbdesc_send, on, 0,
449 &on->thread_send_dbdesc);
450
451 } else if (on->state >= OSPF6_NEIGHBOR_EXSTART && !need_adjacency(on)) {
452 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_TWOWAY, on,
453 OSPF6_NEIGHBOR_EVENT_ADJ_OK);
454 ospf6_lsdb_remove_all(on->summary_list);
455 ospf6_lsdb_remove_all(on->request_list);
456 for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
457 ospf6_decrement_retrans_count(lsa);
458 ospf6_lsdb_remove(lsa, on->retrans_list);
459 }
460 }
461
462 return 0;
463 }
464
465 int seqnumber_mismatch(struct thread *thread)
466 {
467 struct ospf6_neighbor *on;
468 struct ospf6_lsa *lsa, *lsanext;
469
470 on = (struct ospf6_neighbor *)THREAD_ARG(thread);
471 assert(on);
472
473 if (on->state < OSPF6_NEIGHBOR_EXCHANGE)
474 return 0;
475
476 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
477 zlog_debug("Neighbor Event %s: *SeqNumberMismatch*", on->name);
478
479 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART, on,
480 OSPF6_NEIGHBOR_EVENT_SEQNUMBER_MISMATCH);
481 SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
482 SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT);
483 SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT);
484
485 ospf6_lsdb_remove_all(on->summary_list);
486 ospf6_lsdb_remove_all(on->request_list);
487 for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
488 ospf6_decrement_retrans_count(lsa);
489 ospf6_lsdb_remove(lsa, on->retrans_list);
490 }
491
492 THREAD_OFF(on->thread_send_dbdesc);
493 on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */
494
495 on->thread_send_dbdesc = NULL;
496 thread_add_event(master, ospf6_dbdesc_send, on, 0,
497 &on->thread_send_dbdesc);
498
499 return 0;
500 }
501
502 int bad_lsreq(struct thread *thread)
503 {
504 struct ospf6_neighbor *on;
505 struct ospf6_lsa *lsa, *lsanext;
506
507 on = (struct ospf6_neighbor *)THREAD_ARG(thread);
508 assert(on);
509
510 if (on->state < OSPF6_NEIGHBOR_EXCHANGE)
511 return 0;
512
513 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
514 zlog_debug("Neighbor Event %s: *BadLSReq*", on->name);
515
516 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART, on,
517 OSPF6_NEIGHBOR_EVENT_BAD_LSREQ);
518 SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
519 SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT);
520 SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT);
521
522 ospf6_lsdb_remove_all(on->summary_list);
523 ospf6_lsdb_remove_all(on->request_list);
524 for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
525 ospf6_decrement_retrans_count(lsa);
526 ospf6_lsdb_remove(lsa, on->retrans_list);
527 }
528
529 THREAD_OFF(on->thread_send_dbdesc);
530 on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */
531
532 on->thread_send_dbdesc = NULL;
533 thread_add_event(master, ospf6_dbdesc_send, on, 0,
534 &on->thread_send_dbdesc);
535
536 return 0;
537 }
538
539 int oneway_received(struct thread *thread)
540 {
541 struct ospf6_neighbor *on;
542 struct ospf6_lsa *lsa, *lsanext;
543
544 on = (struct ospf6_neighbor *)THREAD_ARG(thread);
545 assert(on);
546
547 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
548 return 0;
549
550 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
551 zlog_debug("Neighbor Event %s: *1Way-Received*", on->name);
552
553 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_INIT, on,
554 OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD);
555 thread_add_event(master, neighbor_change, on->ospf6_if, 0, NULL);
556
557 ospf6_lsdb_remove_all(on->summary_list);
558 ospf6_lsdb_remove_all(on->request_list);
559 for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
560 ospf6_decrement_retrans_count(lsa);
561 ospf6_lsdb_remove(lsa, on->retrans_list);
562 }
563
564 THREAD_OFF(on->thread_send_dbdesc);
565 THREAD_OFF(on->thread_send_lsreq);
566 THREAD_OFF(on->thread_send_lsupdate);
567 THREAD_OFF(on->thread_send_lsack);
568
569 return 0;
570 }
571
572 int inactivity_timer(struct thread *thread)
573 {
574 struct ospf6_neighbor *on;
575
576 on = (struct ospf6_neighbor *)THREAD_ARG(thread);
577 assert(on);
578
579 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
580 zlog_debug("Neighbor Event %s: *InactivityTimer*", on->name);
581
582 on->inactivity_timer = NULL;
583 on->drouter = on->prev_drouter = 0;
584 on->bdrouter = on->prev_bdrouter = 0;
585
586 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_DOWN, on,
587 OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER);
588 thread_add_event(master, neighbor_change, on->ospf6_if, 0, NULL);
589
590 listnode_delete(on->ospf6_if->neighbor_list, on);
591 ospf6_neighbor_delete(on);
592
593 return 0;
594 }
595
596
597 /* vty functions */
598 /* show neighbor structure */
599 static void ospf6_neighbor_show(struct vty *vty, struct ospf6_neighbor *on,
600 json_object *json_array, bool use_json)
601 {
602 char router_id[16];
603 char duration[64];
604 struct timeval res;
605 char nstate[16];
606 char deadtime[64];
607 long h, m, s;
608 json_object *json_route;
609
610 /* Router-ID (Name) */
611 inet_ntop(AF_INET, &on->router_id, router_id, sizeof(router_id));
612 #ifdef HAVE_GETNAMEINFO
613 {
614 }
615 #endif /*HAVE_GETNAMEINFO*/
616
617 /* Dead time */
618 h = m = s = 0;
619 if (on->inactivity_timer) {
620 s = monotime_until(&on->inactivity_timer->u.sands, NULL)
621 / 1000000LL;
622 h = s / 3600;
623 s -= h * 3600;
624 m = s / 60;
625 s -= m * 60;
626 }
627 snprintf(deadtime, sizeof(deadtime), "%02ld:%02ld:%02ld", h, m, s);
628
629 /* Neighbor State */
630 if (on->ospf6_if->type == OSPF_IFTYPE_POINTOPOINT)
631 snprintf(nstate, sizeof(nstate), "PointToPoint");
632 else {
633 if (on->router_id == on->drouter)
634 snprintf(nstate, sizeof(nstate), "DR");
635 else if (on->router_id == on->bdrouter)
636 snprintf(nstate, sizeof(nstate), "BDR");
637 else
638 snprintf(nstate, sizeof(nstate), "DROther");
639 }
640
641 /* Duration */
642 monotime_since(&on->last_changed, &res);
643 timerstring(&res, duration, sizeof(duration));
644
645 /*
646 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]\n",
647 "Neighbor ID", "Pri", "DeadTime", "State", "IfState",
648 "Duration", "I/F", "State");
649 */
650 if (use_json) {
651 json_route = json_object_new_object();
652
653 json_object_string_add(json_route, "neighborId", router_id);
654 json_object_int_add(json_route, "priority", on->priority);
655 json_object_string_add(json_route, "deadTime", deadtime);
656 json_object_string_add(json_route, "state",
657 ospf6_neighbor_state_str[on->state]);
658 json_object_string_add(json_route, "ifState", nstate);
659 json_object_string_add(json_route, "duration", duration);
660 json_object_string_add(json_route, "interfaceName",
661 on->ospf6_if->interface->name);
662 json_object_string_add(
663 json_route, "interfaceState",
664 ospf6_interface_state_str[on->ospf6_if->state]);
665
666 json_object_array_add(json_array, json_route);
667 } else
668 vty_out(vty, "%-15s %3d %11s %8s/%-12s %11s %s[%s]\n",
669 router_id, on->priority, deadtime,
670 ospf6_neighbor_state_str[on->state], nstate, duration,
671 on->ospf6_if->interface->name,
672 ospf6_interface_state_str[on->ospf6_if->state]);
673 }
674
675 static void ospf6_neighbor_show_drchoice(struct vty *vty,
676 struct ospf6_neighbor *on,
677 json_object *json_array, bool use_json)
678 {
679 char router_id[16];
680 char drouter[16], bdrouter[16];
681 char duration[64];
682 struct timeval now, res;
683 json_object *json_route;
684
685 /*
686 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]\n",
687 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
688 "State");
689 */
690
691 inet_ntop(AF_INET, &on->router_id, router_id, sizeof(router_id));
692 inet_ntop(AF_INET, &on->drouter, drouter, sizeof(drouter));
693 inet_ntop(AF_INET, &on->bdrouter, bdrouter, sizeof(bdrouter));
694
695 monotime(&now);
696 timersub(&now, &on->last_changed, &res);
697 timerstring(&res, duration, sizeof(duration));
698
699 if (use_json) {
700 json_route = json_object_new_object();
701 json_object_string_add(json_route, "routerId", router_id);
702 json_object_string_add(json_route, "state",
703 ospf6_neighbor_state_str[on->state]);
704 json_object_string_add(json_route, "duration", duration);
705 json_object_string_add(json_route, "dRouter", drouter);
706 json_object_string_add(json_route, "bdRouter", bdrouter);
707 json_object_string_add(json_route, "interfaceName",
708 on->ospf6_if->interface->name);
709 json_object_string_add(
710 json_route, "interfaceState",
711 ospf6_interface_state_str[on->ospf6_if->state]);
712
713 json_object_array_add(json_array, json_route);
714 } else
715 vty_out(vty, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n", router_id,
716 ospf6_neighbor_state_str[on->state], duration, drouter,
717 bdrouter, on->ospf6_if->interface->name,
718 ospf6_interface_state_str[on->ospf6_if->state]);
719 }
720
721 static void ospf6_neighbor_show_detail(struct vty *vty,
722 struct ospf6_neighbor *on,
723 json_object *json, bool use_json)
724 {
725 char drouter[16], bdrouter[16];
726 char linklocal_addr[64], duration[32];
727 struct timeval now, res;
728 struct ospf6_lsa *lsa, *lsanext;
729 json_object *json_neighbor;
730 json_object *json_array;
731 char db_desc_str[20];
732
733 inet_ntop(AF_INET6, &on->linklocal_addr, linklocal_addr,
734 sizeof(linklocal_addr));
735 inet_ntop(AF_INET, &on->drouter, drouter, sizeof(drouter));
736 inet_ntop(AF_INET, &on->bdrouter, bdrouter, sizeof(bdrouter));
737
738 monotime(&now);
739 timersub(&now, &on->last_changed, &res);
740 timerstring(&res, duration, sizeof(duration));
741
742 if (use_json) {
743 json_neighbor = json_object_new_object();
744 json_object_string_add(json_neighbor, "area",
745 on->ospf6_if->area->name);
746 json_object_string_add(json_neighbor, "interface",
747 on->ospf6_if->interface->name);
748 json_object_int_add(json_neighbor, "interfaceIndex",
749 on->ospf6_if->interface->ifindex);
750 json_object_int_add(json_neighbor, "neighborInterfaceIndex",
751 on->ifindex);
752 json_object_string_add(json_neighbor, "linkLocalAddress",
753 linklocal_addr);
754 json_object_string_add(json_neighbor, "neighborState",
755 ospf6_neighbor_state_str[on->state]);
756 json_object_string_add(json_neighbor, "neighborStateDuration",
757 duration);
758 json_object_string_add(json_neighbor, "neighborDRouter",
759 drouter);
760 json_object_string_add(json_neighbor, "neighborBdRouter",
761 bdrouter);
762 snprintf(db_desc_str, sizeof(db_desc_str), "%s%s%s",
763 (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT)
764 ? "Initial "
765 : ""),
766 (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT)
767 ? "More"
768 : ""),
769 (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT)
770 ? "Master"
771 : "Slave"));
772 json_object_string_add(json_neighbor, "dbDescStatus",
773 db_desc_str);
774
775 json_object_int_add(json_neighbor, "dbDescSeqNumber",
776 (unsigned long)ntohl(on->dbdesc_seqnum));
777
778 json_array = json_object_new_array();
779 json_object_int_add(json_neighbor, "summaryListCount",
780 on->summary_list->count);
781 for (ALL_LSDB(on->summary_list, lsa, lsanext))
782 json_object_array_add(
783 json_array, json_object_new_string(lsa->name));
784 json_object_object_add(json_neighbor, "summaryListLsa",
785 json_array);
786
787 json_array = json_object_new_array();
788 json_object_int_add(json_neighbor, "requestListCount",
789 on->request_list->count);
790 for (ALL_LSDB(on->request_list, lsa, lsanext))
791 json_object_array_add(
792 json_array, json_object_new_string(lsa->name));
793 json_object_object_add(json_neighbor, "requestListLsa",
794 json_array);
795
796 json_array = json_object_new_array();
797 json_object_int_add(json_neighbor, "reTransListCount",
798 on->retrans_list->count);
799 for (ALL_LSDB(on->retrans_list, lsa, lsanext))
800 json_object_array_add(
801 json_array, json_object_new_string(lsa->name));
802 json_object_object_add(json_neighbor, "reTransListLsa",
803 json_array);
804
805
806 timerclear(&res);
807 if (on->thread_send_dbdesc)
808 timersub(&on->thread_send_dbdesc->u.sands, &now, &res);
809 timerstring(&res, duration, sizeof(duration));
810 json_object_int_add(json_neighbor, "pendingLsaDbDescCount",
811 on->dbdesc_list->count);
812 json_object_string_add(json_neighbor, "pendingLsaDbDescTime",
813 duration);
814 json_object_string_add(json_neighbor, "dbDescSendThread",
815 (on->thread_send_dbdesc ? "on" : "off"));
816 json_array = json_object_new_array();
817 for (ALL_LSDB(on->dbdesc_list, lsa, lsanext))
818 json_object_array_add(
819 json_array, json_object_new_string(lsa->name));
820 json_object_object_add(json_neighbor, "pendingLsaDbDesc",
821 json_array);
822
823 timerclear(&res);
824 if (on->thread_send_lsreq)
825 timersub(&on->thread_send_lsreq->u.sands, &now, &res);
826 timerstring(&res, duration, sizeof(duration));
827 json_object_int_add(json_neighbor, "pendingLsaLsReqCount",
828 on->request_list->count);
829 json_object_string_add(json_neighbor, "pendingLsaLsReqTime",
830 duration);
831 json_object_string_add(json_neighbor, "lsReqSendThread",
832 (on->thread_send_lsreq ? "on" : "off"));
833 json_array = json_object_new_array();
834 for (ALL_LSDB(on->request_list, lsa, lsanext))
835 json_object_array_add(
836 json_array, json_object_new_string(lsa->name));
837 json_object_object_add(json_neighbor, "pendingLsaLsReq",
838 json_array);
839
840
841 timerclear(&res);
842 if (on->thread_send_lsupdate)
843 timersub(&on->thread_send_lsupdate->u.sands, &now,
844 &res);
845 timerstring(&res, duration, sizeof(duration));
846 json_object_int_add(json_neighbor, "pendingLsaLsUpdateCount",
847 on->lsupdate_list->count);
848 json_object_string_add(json_neighbor, "pendingLsaLsUpdateTime",
849 duration);
850 json_object_string_add(
851 json_neighbor, "lsUpdateSendThread",
852 (on->thread_send_lsupdate ? "on" : "off"));
853 json_array = json_object_new_array();
854 for (ALL_LSDB(on->lsupdate_list, lsa, lsanext))
855 json_object_array_add(
856 json_array, json_object_new_string(lsa->name));
857 json_object_object_add(json_neighbor, "pendingLsaLsUpdate",
858 json_array);
859
860 timerclear(&res);
861 if (on->thread_send_lsack)
862 timersub(&on->thread_send_lsack->u.sands, &now, &res);
863 timerstring(&res, duration, sizeof(duration));
864 json_object_int_add(json_neighbor, "pendingLsaLsAckCount",
865 on->lsack_list->count);
866 json_object_string_add(json_neighbor, "pendingLsaLsAckTime",
867 duration);
868 json_object_string_add(json_neighbor, "lsAckSendThread",
869 (on->thread_send_lsack ? "on" : "off"));
870 json_array = json_object_new_array();
871 for (ALL_LSDB(on->lsack_list, lsa, lsanext))
872 json_object_array_add(
873 json_array, json_object_new_string(lsa->name));
874 json_object_object_add(json_neighbor, "pendingLsaLsAck",
875 json_array);
876
877 ospf6_bfd_show_info(vty, on->bfd_info, 0, json_neighbor,
878 use_json);
879
880 json_object_object_add(json, on->name, json_neighbor);
881
882
883 } else {
884 vty_out(vty, " Neighbor %s\n", on->name);
885 vty_out(vty, " Area %s via interface %s (ifindex %d)\n",
886 on->ospf6_if->area->name, on->ospf6_if->interface->name,
887 on->ospf6_if->interface->ifindex);
888 vty_out(vty, " His IfIndex: %d Link-local address: %s\n",
889 on->ifindex, linklocal_addr);
890 vty_out(vty, " State %s for a duration of %s\n",
891 ospf6_neighbor_state_str[on->state], duration);
892 vty_out(vty, " His choice of DR/BDR %s/%s, Priority %d\n",
893 drouter, bdrouter, on->priority);
894 vty_out(vty, " DbDesc status: %s%s%s SeqNum: %#lx\n",
895 (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT)
896 ? "Initial "
897 : ""),
898 (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT)
899 ? "More "
900 : ""),
901 (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT)
902 ? "Master"
903 : "Slave"),
904 (unsigned long)ntohl(on->dbdesc_seqnum));
905
906 vty_out(vty, " Summary-List: %d LSAs\n",
907 on->summary_list->count);
908 for (ALL_LSDB(on->summary_list, lsa, lsanext))
909 vty_out(vty, " %s\n", lsa->name);
910
911 vty_out(vty, " Request-List: %d LSAs\n",
912 on->request_list->count);
913 for (ALL_LSDB(on->request_list, lsa, lsanext))
914 vty_out(vty, " %s\n", lsa->name);
915
916 vty_out(vty, " Retrans-List: %d LSAs\n",
917 on->retrans_list->count);
918 for (ALL_LSDB(on->retrans_list, lsa, lsanext))
919 vty_out(vty, " %s\n", lsa->name);
920
921 timerclear(&res);
922 if (on->thread_send_dbdesc)
923 timersub(&on->thread_send_dbdesc->u.sands, &now, &res);
924 timerstring(&res, duration, sizeof(duration));
925 vty_out(vty,
926 " %d Pending LSAs for DbDesc in Time %s [thread %s]\n",
927 on->dbdesc_list->count, duration,
928 (on->thread_send_dbdesc ? "on" : "off"));
929 for (ALL_LSDB(on->dbdesc_list, lsa, lsanext))
930 vty_out(vty, " %s\n", lsa->name);
931
932 timerclear(&res);
933 if (on->thread_send_lsreq)
934 timersub(&on->thread_send_lsreq->u.sands, &now, &res);
935 timerstring(&res, duration, sizeof(duration));
936 vty_out(vty,
937 " %d Pending LSAs for LSReq in Time %s [thread %s]\n",
938 on->request_list->count, duration,
939 (on->thread_send_lsreq ? "on" : "off"));
940 for (ALL_LSDB(on->request_list, lsa, lsanext))
941 vty_out(vty, " %s\n", lsa->name);
942
943 timerclear(&res);
944 if (on->thread_send_lsupdate)
945 timersub(&on->thread_send_lsupdate->u.sands, &now,
946 &res);
947 timerstring(&res, duration, sizeof(duration));
948 vty_out(vty,
949 " %d Pending LSAs for LSUpdate in Time %s [thread %s]\n",
950 on->lsupdate_list->count, duration,
951 (on->thread_send_lsupdate ? "on" : "off"));
952 for (ALL_LSDB(on->lsupdate_list, lsa, lsanext))
953 vty_out(vty, " %s\n", lsa->name);
954
955 timerclear(&res);
956 if (on->thread_send_lsack)
957 timersub(&on->thread_send_lsack->u.sands, &now, &res);
958 timerstring(&res, duration, sizeof(duration));
959 vty_out(vty,
960 " %d Pending LSAs for LSAck in Time %s [thread %s]\n",
961 on->lsack_list->count, duration,
962 (on->thread_send_lsack ? "on" : "off"));
963 for (ALL_LSDB(on->lsack_list, lsa, lsanext))
964 vty_out(vty, " %s\n", lsa->name);
965
966 ospf6_bfd_show_info(vty, on->bfd_info, 0, NULL, use_json);
967 }
968 }
969
970 DEFUN (show_ipv6_ospf6_neighbor,
971 show_ipv6_ospf6_neighbor_cmd,
972 "show ipv6 ospf6 neighbor [<detail|drchoice>] [json]",
973 SHOW_STR
974 IP6_STR
975 OSPF6_STR
976 "Neighbor list\n"
977 "Display details\n"
978 "Display DR choices\n"
979 JSON_STR)
980 {
981 int idx_type = 4;
982 struct ospf6_neighbor *on;
983 struct ospf6_interface *oi;
984 struct ospf6_area *oa;
985 struct listnode *i, *j, *k;
986 struct ospf6 *ospf6;
987 json_object *json = NULL;
988 json_object *json_array = NULL;
989 bool uj = use_json(argc, argv);
990 void (*showfunc)(struct vty *, struct ospf6_neighbor *,
991 json_object *json, bool use_json);
992
993 ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
994
995 OSPF6_CMD_CHECK_RUNNING(ospf6);
996 showfunc = ospf6_neighbor_show;
997
998 if ((uj && argc == 6) || (!uj && argc == 5)) {
999 if (!strncmp(argv[idx_type]->arg, "de", 2))
1000 showfunc = ospf6_neighbor_show_detail;
1001 else if (!strncmp(argv[idx_type]->arg, "dr", 2))
1002 showfunc = ospf6_neighbor_show_drchoice;
1003 }
1004
1005 if (uj) {
1006 json = json_object_new_object();
1007 json_array = json_object_new_array();
1008 } else {
1009 if (showfunc == ospf6_neighbor_show)
1010 vty_out(vty, "%-15s %3s %11s %8s/%-12s %11s %s[%s]\n",
1011 "Neighbor ID", "Pri", "DeadTime", "State",
1012 "IfState", "Duration", "I/F", "State");
1013 else if (showfunc == ospf6_neighbor_show_drchoice)
1014 vty_out(vty, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n",
1015 "RouterID", "State", "Duration", "DR", "BDR",
1016 "I/F", "State");
1017 }
1018
1019 for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa))
1020 for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi))
1021 for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, k, on)) {
1022 if (showfunc == ospf6_neighbor_show_detail)
1023 (*showfunc)(vty, on, json, uj);
1024 else
1025 (*showfunc)(vty, on, json_array, uj);
1026 }
1027
1028 if (uj) {
1029 if (showfunc != ospf6_neighbor_show_detail)
1030 json_object_object_add(json, "neighbors", json_array);
1031 else
1032 json_object_free(json_array);
1033 vty_out(vty, "%s\n",
1034 json_object_to_json_string_ext(
1035 json, JSON_C_TO_STRING_PRETTY));
1036 json_object_free(json);
1037 }
1038 return CMD_SUCCESS;
1039 }
1040
1041
1042 DEFUN (show_ipv6_ospf6_neighbor_one,
1043 show_ipv6_ospf6_neighbor_one_cmd,
1044 "show ipv6 ospf6 neighbor A.B.C.D [json]",
1045 SHOW_STR
1046 IP6_STR
1047 OSPF6_STR
1048 "Neighbor list\n"
1049 "Specify Router-ID as IPv4 address notation\n"
1050 JSON_STR)
1051 {
1052 int idx_ipv4 = 4;
1053 struct ospf6_neighbor *on;
1054 struct ospf6_interface *oi;
1055 struct ospf6_area *oa;
1056 struct listnode *i, *j, *k;
1057 void (*showfunc)(struct vty *, struct ospf6_neighbor *,
1058 json_object *json, bool use_json);
1059 uint32_t router_id;
1060 struct ospf6 *ospf6;
1061 json_object *json = NULL;
1062 bool uj = use_json(argc, argv);
1063
1064 ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
1065 OSPF6_CMD_CHECK_RUNNING(ospf6);
1066 showfunc = ospf6_neighbor_show_detail;
1067 if (uj)
1068 json = json_object_new_object();
1069
1070 if ((inet_pton(AF_INET, argv[idx_ipv4]->arg, &router_id)) != 1) {
1071 vty_out(vty, "Router-ID is not parsable: %s\n",
1072 argv[idx_ipv4]->arg);
1073 return CMD_SUCCESS;
1074 }
1075
1076 for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa))
1077 for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi))
1078 for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, k, on)) {
1079 if (router_id == on->router_id)
1080 (*showfunc)(vty, on, json, uj);
1081 }
1082
1083 if (uj) {
1084 vty_out(vty, "%s\n",
1085 json_object_to_json_string_ext(
1086 json, JSON_C_TO_STRING_PRETTY));
1087 json_object_free(json);
1088 }
1089 return CMD_SUCCESS;
1090 }
1091
1092 void ospf6_neighbor_init(void)
1093 {
1094 install_element(VIEW_NODE, &show_ipv6_ospf6_neighbor_cmd);
1095 install_element(VIEW_NODE, &show_ipv6_ospf6_neighbor_one_cmd);
1096 }
1097
1098 DEFUN (debug_ospf6_neighbor,
1099 debug_ospf6_neighbor_cmd,
1100 "debug ospf6 neighbor [<state|event>]",
1101 DEBUG_STR
1102 OSPF6_STR
1103 "Debug OSPFv3 Neighbor\n"
1104 "Debug OSPFv3 Neighbor State Change\n"
1105 "Debug OSPFv3 Neighbor Event\n")
1106 {
1107 int idx_type = 3;
1108 unsigned char level = 0;
1109
1110 if (argc == 4) {
1111 if (!strncmp(argv[idx_type]->arg, "s", 1))
1112 level = OSPF6_DEBUG_NEIGHBOR_STATE;
1113 else if (!strncmp(argv[idx_type]->arg, "e", 1))
1114 level = OSPF6_DEBUG_NEIGHBOR_EVENT;
1115 } else
1116 level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;
1117
1118 OSPF6_DEBUG_NEIGHBOR_ON(level);
1119 return CMD_SUCCESS;
1120 }
1121
1122
1123 DEFUN (no_debug_ospf6_neighbor,
1124 no_debug_ospf6_neighbor_cmd,
1125 "no debug ospf6 neighbor [<state|event>]",
1126 NO_STR
1127 DEBUG_STR
1128 OSPF6_STR
1129 "Debug OSPFv3 Neighbor\n"
1130 "Debug OSPFv3 Neighbor State Change\n"
1131 "Debug OSPFv3 Neighbor Event\n")
1132 {
1133 int idx_type = 4;
1134 unsigned char level = 0;
1135
1136 if (argc == 5) {
1137 if (!strncmp(argv[idx_type]->arg, "s", 1))
1138 level = OSPF6_DEBUG_NEIGHBOR_STATE;
1139 if (!strncmp(argv[idx_type]->arg, "e", 1))
1140 level = OSPF6_DEBUG_NEIGHBOR_EVENT;
1141 } else
1142 level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;
1143
1144 OSPF6_DEBUG_NEIGHBOR_OFF(level);
1145 return CMD_SUCCESS;
1146 }
1147
1148
1149 DEFUN (no_debug_ospf6,
1150 no_debug_ospf6_cmd,
1151 "no debug ospf6",
1152 NO_STR
1153 DEBUG_STR
1154 OSPF6_STR)
1155 {
1156 unsigned int i;
1157 struct ospf6_lsa_handler *handler = NULL;
1158
1159 OSPF6_DEBUG_ABR_OFF();
1160 OSPF6_DEBUG_ASBR_OFF();
1161 OSPF6_DEBUG_BROUTER_OFF();
1162 OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF();
1163 OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF();
1164 OSPF6_DEBUG_FLOODING_OFF();
1165 OSPF6_DEBUG_INTERFACE_OFF();
1166
1167 for (i = 0; i < vector_active(ospf6_lsa_handler_vector); i++) {
1168 handler = vector_slot(ospf6_lsa_handler_vector, i);
1169
1170 if (handler != NULL) {
1171 UNSET_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG);
1172 }
1173 }
1174
1175 for (i = 0; i < 6; i++)
1176 OSPF6_DEBUG_MESSAGE_OFF(i,
1177 OSPF6_DEBUG_NEIGHBOR_STATE
1178 | OSPF6_DEBUG_NEIGHBOR_EVENT);
1179
1180 OSPF6_DEBUG_NEIGHBOR_OFF(OSPF6_DEBUG_NEIGHBOR_STATE
1181 | OSPF6_DEBUG_NEIGHBOR_EVENT);
1182 OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_TABLE);
1183 OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_INTRA);
1184 OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_INTER);
1185 OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_MEMORY);
1186 OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_PROCESS);
1187 OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_TIME);
1188 OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_DATABASE);
1189 OSPF6_DEBUG_ZEBRA_OFF(OSPF6_DEBUG_ZEBRA_SEND | OSPF6_DEBUG_ZEBRA_RECV);
1190
1191 return CMD_SUCCESS;
1192 }
1193
1194 int config_write_ospf6_debug_neighbor(struct vty *vty)
1195 {
1196 if (IS_OSPF6_DEBUG_NEIGHBOR(STATE) && IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
1197 vty_out(vty, "debug ospf6 neighbor\n");
1198 else if (IS_OSPF6_DEBUG_NEIGHBOR(STATE))
1199 vty_out(vty, "debug ospf6 neighbor state\n");
1200 else if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
1201 vty_out(vty, "debug ospf6 neighbor event\n");
1202 return 0;
1203 }
1204
1205 void install_element_ospf6_debug_neighbor(void)
1206 {
1207 install_element(ENABLE_NODE, &debug_ospf6_neighbor_cmd);
1208 install_element(ENABLE_NODE, &no_debug_ospf6_neighbor_cmd);
1209 install_element(ENABLE_NODE, &no_debug_ospf6_cmd);
1210 install_element(CONFIG_NODE, &debug_ospf6_neighbor_cmd);
1211 install_element(CONFIG_NODE, &no_debug_ospf6_neighbor_cmd);
1212 install_element(CONFIG_NODE, &no_debug_ospf6_cmd);
1213 }