blob: 7f6c6c5cd811091c371dceee61f71fb82bfe6312 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
hasso508e53e2004-05-18 18:57:06 +00002 * Copyright (C) 2003 Yasuhiro Ohara
paul718e3742002-12-13 20:15:29 +00003 *
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
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
paul718e3742002-12-13 20:15:29 +000022#include <zebra.h>
23
24#include "log.h"
hasso508e53e2004-05-18 18:57:06 +000025#include "memory.h"
paul718e3742002-12-13 20:15:29 +000026#include "thread.h"
27#include "linklist.h"
28#include "vty.h"
29#include "command.h"
30
hasso508e53e2004-05-18 18:57:06 +000031#include "ospf6_proto.h"
paul718e3742002-12-13 20:15:29 +000032#include "ospf6_lsa.h"
33#include "ospf6_lsdb.h"
hasso508e53e2004-05-18 18:57:06 +000034#include "ospf6_message.h"
35#include "ospf6_top.h"
36#include "ospf6_area.h"
37#include "ospf6_interface.h"
38#include "ospf6_neighbor.h"
39#include "ospf6_intra.h"
hasso3b4cd3a2004-05-18 19:28:32 +000040#include "ospf6_flood.h"
hasso049207c2004-08-04 20:02:13 +000041#include "ospf6d.h"
paul718e3742002-12-13 20:15:29 +000042
hasso508e53e2004-05-18 18:57:06 +000043unsigned char conf_debug_ospf6_neighbor = 0;
44
paul0c083ee2004-10-10 12:54:58 +000045const char *ospf6_neighbor_state_str[] =
hasso508e53e2004-05-18 18:57:06 +000046{ "None", "Down", "Attempt", "Init", "Twoway", "ExStart", "ExChange",
47 "Loading", "Full", NULL };
paul718e3742002-12-13 20:15:29 +000048
49int
hasso508e53e2004-05-18 18:57:06 +000050ospf6_neighbor_cmp (void *va, void *vb)
paul718e3742002-12-13 20:15:29 +000051{
hasso508e53e2004-05-18 18:57:06 +000052 struct ospf6_neighbor *ona = (struct ospf6_neighbor *) va;
53 struct ospf6_neighbor *onb = (struct ospf6_neighbor *) vb;
hasso6452df02004-08-15 05:52:07 +000054 return (ntohl (ona->router_id) < ntohl (onb->router_id) ? -1 : 1);
paul718e3742002-12-13 20:15:29 +000055}
56
hasso508e53e2004-05-18 18:57:06 +000057struct ospf6_neighbor *
58ospf6_neighbor_lookup (u_int32_t router_id,
59 struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +000060{
hasso52dc7ee2004-09-23 19:18:23 +000061 struct listnode *n;
hasso508e53e2004-05-18 18:57:06 +000062 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +000063
paul1eb8ef22005-04-07 07:30:20 +000064 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, n, on))
65 if (on->router_id == router_id)
66 return on;
67
hasso508e53e2004-05-18 18:57:06 +000068 return (struct ospf6_neighbor *) NULL;
paul718e3742002-12-13 20:15:29 +000069}
70
71/* create ospf6_neighbor */
72struct ospf6_neighbor *
hasso508e53e2004-05-18 18:57:06 +000073ospf6_neighbor_create (u_int32_t router_id, struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +000074{
hasso508e53e2004-05-18 18:57:06 +000075 struct ospf6_neighbor *on;
76 char buf[16];
paul718e3742002-12-13 20:15:29 +000077
hasso508e53e2004-05-18 18:57:06 +000078 on = (struct ospf6_neighbor *)
paul718e3742002-12-13 20:15:29 +000079 XMALLOC (MTYPE_OSPF6_NEIGHBOR, sizeof (struct ospf6_neighbor));
hasso508e53e2004-05-18 18:57:06 +000080 if (on == NULL)
paul718e3742002-12-13 20:15:29 +000081 {
82 zlog_warn ("neighbor: malloc failed");
83 return NULL;
84 }
85
hasso508e53e2004-05-18 18:57:06 +000086 memset (on, 0, sizeof (struct ospf6_neighbor));
paul718e3742002-12-13 20:15:29 +000087 inet_ntop (AF_INET, &router_id, buf, sizeof (buf));
hasso508e53e2004-05-18 18:57:06 +000088 snprintf (on->name, sizeof (on->name), "%s%%%s",
89 buf, oi->interface->name);
90 on->ospf6_if = oi;
91 on->state = OSPF6_NEIGHBOR_DOWN;
Vincent Bernat061bc732012-05-31 20:21:15 +020092 on->state_change = 0;
Takashi Sogabe86f72dc2009-06-22 13:07:02 +090093 quagga_gettime (QUAGGA_CLK_MONOTONIC, &on->last_changed);
hasso508e53e2004-05-18 18:57:06 +000094 on->router_id = router_id;
paul718e3742002-12-13 20:15:29 +000095
hasso6452df02004-08-15 05:52:07 +000096 on->summary_list = ospf6_lsdb_create (on);
97 on->request_list = ospf6_lsdb_create (on);
98 on->retrans_list = ospf6_lsdb_create (on);
paul718e3742002-12-13 20:15:29 +000099
hasso6452df02004-08-15 05:52:07 +0000100 on->dbdesc_list = ospf6_lsdb_create (on);
hasso6452df02004-08-15 05:52:07 +0000101 on->lsupdate_list = ospf6_lsdb_create (on);
102 on->lsack_list = ospf6_lsdb_create (on);
paul718e3742002-12-13 20:15:29 +0000103
hasso508e53e2004-05-18 18:57:06 +0000104 listnode_add_sort (oi->neighbor_list, on);
105 return on;
paul718e3742002-12-13 20:15:29 +0000106}
107
108void
hasso508e53e2004-05-18 18:57:06 +0000109ospf6_neighbor_delete (struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000110{
hasso3b4cd3a2004-05-18 19:28:32 +0000111 struct ospf6_lsa *lsa;
112
hasso508e53e2004-05-18 18:57:06 +0000113 ospf6_lsdb_remove_all (on->summary_list);
114 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000115 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
116 lsa = ospf6_lsdb_next (lsa))
117 {
hasso6452df02004-08-15 05:52:07 +0000118 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000119 ospf6_lsdb_remove (lsa, on->retrans_list);
120 }
paul718e3742002-12-13 20:15:29 +0000121
hasso508e53e2004-05-18 18:57:06 +0000122 ospf6_lsdb_remove_all (on->dbdesc_list);
hasso508e53e2004-05-18 18:57:06 +0000123 ospf6_lsdb_remove_all (on->lsupdate_list);
124 ospf6_lsdb_remove_all (on->lsack_list);
paul718e3742002-12-13 20:15:29 +0000125
hasso508e53e2004-05-18 18:57:06 +0000126 ospf6_lsdb_delete (on->summary_list);
127 ospf6_lsdb_delete (on->request_list);
128 ospf6_lsdb_delete (on->retrans_list);
paul718e3742002-12-13 20:15:29 +0000129
hasso508e53e2004-05-18 18:57:06 +0000130 ospf6_lsdb_delete (on->dbdesc_list);
hasso508e53e2004-05-18 18:57:06 +0000131 ospf6_lsdb_delete (on->lsupdate_list);
132 ospf6_lsdb_delete (on->lsack_list);
paul718e3742002-12-13 20:15:29 +0000133
hasso508e53e2004-05-18 18:57:06 +0000134 THREAD_OFF (on->inactivity_timer);
135
136 THREAD_OFF (on->thread_send_dbdesc);
137 THREAD_OFF (on->thread_send_lsreq);
138 THREAD_OFF (on->thread_send_lsupdate);
139 THREAD_OFF (on->thread_send_lsack);
140
141 XFREE (MTYPE_OSPF6_NEIGHBOR, on);
paul718e3742002-12-13 20:15:29 +0000142}
143
hasso508e53e2004-05-18 18:57:06 +0000144static void
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000145ospf6_neighbor_state_change (u_char next_state, struct ospf6_neighbor *on, int event)
paul718e3742002-12-13 20:15:29 +0000146{
hasso508e53e2004-05-18 18:57:06 +0000147 u_char prev_state;
paul718e3742002-12-13 20:15:29 +0000148
hasso508e53e2004-05-18 18:57:06 +0000149 prev_state = on->state;
150 on->state = next_state;
151
152 if (prev_state == next_state)
153 return;
154
Vincent Bernat061bc732012-05-31 20:21:15 +0200155 on->state_change++;
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900156 quagga_gettime (QUAGGA_CLK_MONOTONIC, &on->last_changed);
hasso508e53e2004-05-18 18:57:06 +0000157
158 /* log */
159 if (IS_OSPF6_DEBUG_NEIGHBOR (STATE))
paul718e3742002-12-13 20:15:29 +0000160 {
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000161 zlog_debug ("Neighbor state change %s: [%s]->[%s] (%s)", on->name,
hassoc6487d62004-12-24 06:00:11 +0000162 ospf6_neighbor_state_str[prev_state],
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000163 ospf6_neighbor_state_str[next_state],
164 ospf6_neighbor_event_string(event));
paul718e3742002-12-13 20:15:29 +0000165 }
hasso508e53e2004-05-18 18:57:06 +0000166
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000167 /* Optionally notify about adjacency changes */
168 if (CHECK_FLAG(on->ospf6_if->area->ospf6->config_flags,
169 OSPF6_LOG_ADJACENCY_CHANGES) &&
170 (CHECK_FLAG(on->ospf6_if->area->ospf6->config_flags,
171 OSPF6_LOG_ADJACENCY_DETAIL) ||
172 (next_state == OSPF6_NEIGHBOR_FULL) || (next_state < prev_state)))
173 zlog_notice("AdjChg: Nbr %s: %s -> %s (%s)", on->name,
174 ospf6_neighbor_state_str[prev_state],
175 ospf6_neighbor_state_str[next_state],
176 ospf6_neighbor_event_string(event));
177
hasso508e53e2004-05-18 18:57:06 +0000178 if (prev_state == OSPF6_NEIGHBOR_FULL || next_state == OSPF6_NEIGHBOR_FULL)
179 {
180 OSPF6_ROUTER_LSA_SCHEDULE (on->ospf6_if->area);
181 if (on->ospf6_if->state == OSPF6_INTERFACE_DR)
182 {
183 OSPF6_NETWORK_LSA_SCHEDULE (on->ospf6_if);
184 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (on->ospf6_if);
hasso508e53e2004-05-18 18:57:06 +0000185 }
hasso4846ef62004-09-03 06:04:00 +0000186 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (on->ospf6_if->area);
hasso508e53e2004-05-18 18:57:06 +0000187 }
188
hasso508e53e2004-05-18 18:57:06 +0000189 if ((prev_state == OSPF6_NEIGHBOR_EXCHANGE ||
190 prev_state == OSPF6_NEIGHBOR_LOADING) &&
191 (next_state != OSPF6_NEIGHBOR_EXCHANGE &&
192 next_state != OSPF6_NEIGHBOR_LOADING))
Paul Jakma932bf192006-05-15 10:42:24 +0000193 ospf6_maxage_remove (on->ospf6_if->area->ospf6);
Vincent Bernatbf836662012-06-04 14:36:12 +0200194
195#ifdef HAVE_SNMP
196 /* Terminal state or regression */
197 if ((next_state == OSPF6_NEIGHBOR_FULL) ||
198 (next_state == OSPF6_NEIGHBOR_TWOWAY) ||
199 (next_state < prev_state))
200 ospf6TrapNbrStateChange (on);
201#endif
202
paul718e3742002-12-13 20:15:29 +0000203}
204
hasso508e53e2004-05-18 18:57:06 +0000205/* RFC2328 section 10.4 */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100206static int
hasso508e53e2004-05-18 18:57:06 +0000207need_adjacency (struct ospf6_neighbor *on)
208{
209 if (on->ospf6_if->state == OSPF6_INTERFACE_POINTTOPOINT ||
210 on->ospf6_if->state == OSPF6_INTERFACE_DR ||
211 on->ospf6_if->state == OSPF6_INTERFACE_BDR)
212 return 1;
213
214 if (on->ospf6_if->drouter == on->router_id ||
215 on->ospf6_if->bdrouter == on->router_id)
216 return 1;
217
218 return 0;
219}
220
221int
222hello_received (struct thread *thread)
223{
224 struct ospf6_neighbor *on;
225
226 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
227 assert (on);
228
229 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000230 zlog_debug ("Neighbor Event %s: *HelloReceived*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000231
232 /* reset Inactivity Timer */
233 THREAD_OFF (on->inactivity_timer);
234 on->inactivity_timer = thread_add_timer (master, inactivity_timer, on,
235 on->ospf6_if->dead_interval);
236
237 if (on->state <= OSPF6_NEIGHBOR_DOWN)
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000238 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on,
239 OSPF6_NEIGHBOR_EVENT_HELLO_RCVD);
hasso508e53e2004-05-18 18:57:06 +0000240
241 return 0;
242}
243
244int
245twoway_received (struct thread *thread)
246{
247 struct ospf6_neighbor *on;
248
249 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
250 assert (on);
251
252 if (on->state > OSPF6_NEIGHBOR_INIT)
253 return 0;
254
255 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000256 zlog_debug ("Neighbor Event %s: *2Way-Received*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000257
258 thread_add_event (master, neighbor_change, on->ospf6_if, 0);
259
260 if (! need_adjacency (on))
261 {
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000262 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY, on,
263 OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD);
hasso508e53e2004-05-18 18:57:06 +0000264 return 0;
265 }
266
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000267 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on,
268 OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD);
hasso508e53e2004-05-18 18:57:06 +0000269 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
270 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
271 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
272
273 THREAD_OFF (on->thread_send_dbdesc);
274 on->thread_send_dbdesc =
275 thread_add_event (master, ospf6_dbdesc_send, on, 0);
276
277 return 0;
278}
279
280int
281negotiation_done (struct thread *thread)
282{
283 struct ospf6_neighbor *on;
284 struct ospf6_lsa *lsa;
285
286 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
287 assert (on);
288
289 if (on->state != OSPF6_NEIGHBOR_EXSTART)
290 return 0;
291
292 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000293 zlog_debug ("Neighbor Event %s: *NegotiationDone*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000294
295 /* clear ls-list */
296 ospf6_lsdb_remove_all (on->summary_list);
297 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000298 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
299 lsa = ospf6_lsdb_next (lsa))
300 {
hasso6452df02004-08-15 05:52:07 +0000301 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000302 ospf6_lsdb_remove (lsa, on->retrans_list);
303 }
hasso508e53e2004-05-18 18:57:06 +0000304
305 /* Interface scoped LSAs */
306 for (lsa = ospf6_lsdb_head (on->ospf6_if->lsdb); lsa;
307 lsa = ospf6_lsdb_next (lsa))
308 {
hasso508e53e2004-05-18 18:57:06 +0000309 if (OSPF6_LSA_IS_MAXAGE (lsa))
hasso3b4cd3a2004-05-18 19:28:32 +0000310 {
hasso6452df02004-08-15 05:52:07 +0000311 ospf6_increment_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000312 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
313 }
hasso508e53e2004-05-18 18:57:06 +0000314 else
315 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->summary_list);
316 }
317
318 /* Area scoped LSAs */
319 for (lsa = ospf6_lsdb_head (on->ospf6_if->area->lsdb); lsa;
320 lsa = ospf6_lsdb_next (lsa))
321 {
hasso508e53e2004-05-18 18:57:06 +0000322 if (OSPF6_LSA_IS_MAXAGE (lsa))
hasso3b4cd3a2004-05-18 19:28:32 +0000323 {
hasso6452df02004-08-15 05:52:07 +0000324 ospf6_increment_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000325 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
326 }
hasso508e53e2004-05-18 18:57:06 +0000327 else
328 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->summary_list);
329 }
330
331 /* AS scoped LSAs */
332 for (lsa = ospf6_lsdb_head (on->ospf6_if->area->ospf6->lsdb); lsa;
333 lsa = ospf6_lsdb_next (lsa))
334 {
hasso508e53e2004-05-18 18:57:06 +0000335 if (OSPF6_LSA_IS_MAXAGE (lsa))
hasso3b4cd3a2004-05-18 19:28:32 +0000336 {
hasso6452df02004-08-15 05:52:07 +0000337 ospf6_increment_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000338 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
339 }
hasso508e53e2004-05-18 18:57:06 +0000340 else
341 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->summary_list);
342 }
343
344 UNSET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000345 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXCHANGE, on,
346 OSPF6_NEIGHBOR_EVENT_NEGOTIATION_DONE);
hasso508e53e2004-05-18 18:57:06 +0000347
348 return 0;
349}
350
351int
352exchange_done (struct thread *thread)
353{
354 struct ospf6_neighbor *on;
355
356 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
357 assert (on);
358
359 if (on->state != OSPF6_NEIGHBOR_EXCHANGE)
360 return 0;
361
362 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000363 zlog_debug ("Neighbor Event %s: *ExchangeDone*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000364
365 THREAD_OFF (on->thread_send_dbdesc);
366 ospf6_lsdb_remove_all (on->dbdesc_list);
367
368/* XXX
369 thread_add_timer (master, ospf6_neighbor_last_dbdesc_release, on,
370 on->ospf6_if->dead_interval);
371*/
372
373 if (on->request_list->count == 0)
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000374 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL, on,
375 OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE);
hasso508e53e2004-05-18 18:57:06 +0000376 else
Dinesh Dutteb82e9e2013-08-24 07:55:07 +0000377 {
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000378 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_LOADING, on,
379 OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE);
Dinesh Dutteb82e9e2013-08-24 07:55:07 +0000380
381 if (on->thread_send_lsreq == NULL)
382 on->thread_send_lsreq =
383 thread_add_event (master, ospf6_lsreq_send, on, 0);
384 }
hasso508e53e2004-05-18 18:57:06 +0000385
386 return 0;
387}
388
Dinesh Dutteb82e9e2013-08-24 07:55:07 +0000389/* Check loading state. */
390void
391ospf6_check_nbr_loading (struct ospf6_neighbor *on)
392{
393
394 /* RFC2328 Section 10.9: When the neighbor responds to these requests
395 with the proper Link State Update packet(s), the Link state request
396 list is truncated and a new Link State Request packet is sent.
397 */
398 if ((on->state == OSPF6_NEIGHBOR_LOADING) ||
399 (on->state == OSPF6_NEIGHBOR_EXCHANGE))
400 {
401 if (on->request_list->count == 0)
402 thread_add_event (master, loading_done, on, 0);
403 else if (on->last_ls_req == NULL)
404 {
405 if (on->thread_send_lsreq != NULL)
406 THREAD_OFF (on->thread_send_lsreq);
407 on->thread_send_lsreq =
408 thread_add_event (master, ospf6_lsreq_send, on, 0);
409 }
410 }
411}
412
hasso508e53e2004-05-18 18:57:06 +0000413int
414loading_done (struct thread *thread)
415{
416 struct ospf6_neighbor *on;
417
418 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
419 assert (on);
420
421 if (on->state != OSPF6_NEIGHBOR_LOADING)
422 return 0;
423
424 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000425 zlog_debug ("Neighbor Event %s: *LoadingDone*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000426
427 assert (on->request_list->count == 0);
428
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000429 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL, on,
430 OSPF6_NEIGHBOR_EVENT_LOADING_DONE);
hasso508e53e2004-05-18 18:57:06 +0000431
432 return 0;
433}
434
435int
436adj_ok (struct thread *thread)
437{
438 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000439 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000440
441 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
442 assert (on);
443
444 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000445 zlog_debug ("Neighbor Event %s: *AdjOK?*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000446
447 if (on->state == OSPF6_NEIGHBOR_TWOWAY && need_adjacency (on))
448 {
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000449 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on,
450 OSPF6_NEIGHBOR_EVENT_ADJ_OK);
hasso508e53e2004-05-18 18:57:06 +0000451 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
452 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
453 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
454
455 THREAD_OFF (on->thread_send_dbdesc);
456 on->thread_send_dbdesc =
457 thread_add_event (master, ospf6_dbdesc_send, on, 0);
458
459 }
460 else if (on->state >= OSPF6_NEIGHBOR_EXSTART &&
461 ! need_adjacency (on))
462 {
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000463 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY, on,
464 OSPF6_NEIGHBOR_EVENT_ADJ_OK);
hasso508e53e2004-05-18 18:57:06 +0000465 ospf6_lsdb_remove_all (on->summary_list);
466 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000467 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
468 lsa = ospf6_lsdb_next (lsa))
469 {
hasso6452df02004-08-15 05:52:07 +0000470 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000471 ospf6_lsdb_remove (lsa, on->retrans_list);
472 }
hasso508e53e2004-05-18 18:57:06 +0000473 }
474
475 return 0;
476}
477
478int
479seqnumber_mismatch (struct thread *thread)
480{
481 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000482 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000483
484 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
485 assert (on);
486
487 if (on->state < OSPF6_NEIGHBOR_EXCHANGE)
488 return 0;
489
490 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000491 zlog_debug ("Neighbor Event %s: *SeqNumberMismatch*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000492
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000493 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on,
494 OSPF6_NEIGHBOR_EVENT_SEQNUMBER_MISMATCH);
hasso508e53e2004-05-18 18:57:06 +0000495 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
496 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
497 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
498
499 ospf6_lsdb_remove_all (on->summary_list);
500 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000501 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
502 lsa = ospf6_lsdb_next (lsa))
503 {
hasso6452df02004-08-15 05:52:07 +0000504 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000505 ospf6_lsdb_remove (lsa, on->retrans_list);
506 }
hasso508e53e2004-05-18 18:57:06 +0000507
508 THREAD_OFF (on->thread_send_dbdesc);
Dinesh Dutt931b1b82013-08-25 03:03:15 +0000509 on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */
510
hasso508e53e2004-05-18 18:57:06 +0000511 on->thread_send_dbdesc =
512 thread_add_event (master, ospf6_dbdesc_send, on, 0);
513
514 return 0;
515}
516
517int
518bad_lsreq (struct thread *thread)
519{
520 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000521 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000522
523 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
524 assert (on);
525
526 if (on->state < OSPF6_NEIGHBOR_EXCHANGE)
527 return 0;
528
529 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000530 zlog_debug ("Neighbor Event %s: *BadLSReq*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000531
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000532 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on,
533 OSPF6_NEIGHBOR_EVENT_BAD_LSREQ);
hasso508e53e2004-05-18 18:57:06 +0000534 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
535 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
536 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
537
538 ospf6_lsdb_remove_all (on->summary_list);
539 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000540 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
541 lsa = ospf6_lsdb_next (lsa))
542 {
hasso6452df02004-08-15 05:52:07 +0000543 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000544 ospf6_lsdb_remove (lsa, on->retrans_list);
545 }
hasso508e53e2004-05-18 18:57:06 +0000546
547 THREAD_OFF (on->thread_send_dbdesc);
Dinesh Dutt931b1b82013-08-25 03:03:15 +0000548 on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */
549
hasso508e53e2004-05-18 18:57:06 +0000550 on->thread_send_dbdesc =
551 thread_add_event (master, ospf6_dbdesc_send, on, 0);
552
553 return 0;
554}
555
556int
557oneway_received (struct thread *thread)
558{
559 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000560 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000561
562 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
563 assert (on);
564
565 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
566 return 0;
567
568 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000569 zlog_debug ("Neighbor Event %s: *1Way-Received*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000570
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000571 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on,
572 OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD);
hasso508e53e2004-05-18 18:57:06 +0000573 thread_add_event (master, neighbor_change, on->ospf6_if, 0);
574
575 ospf6_lsdb_remove_all (on->summary_list);
576 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000577 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
578 lsa = ospf6_lsdb_next (lsa))
579 {
hasso6452df02004-08-15 05:52:07 +0000580 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000581 ospf6_lsdb_remove (lsa, on->retrans_list);
582 }
hasso508e53e2004-05-18 18:57:06 +0000583
584 THREAD_OFF (on->thread_send_dbdesc);
585 THREAD_OFF (on->thread_send_lsreq);
586 THREAD_OFF (on->thread_send_lsupdate);
587 THREAD_OFF (on->thread_send_lsack);
588
589 return 0;
590}
591
592int
593inactivity_timer (struct thread *thread)
594{
595 struct ospf6_neighbor *on;
596
597 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
598 assert (on);
599
600 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000601 zlog_debug ("Neighbor Event %s: *InactivityTimer*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000602
603 on->inactivity_timer = NULL;
604 on->drouter = on->prev_drouter = 0;
605 on->bdrouter = on->prev_bdrouter = 0;
606
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000607 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_DOWN, on,
608 OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER);
hasso508e53e2004-05-18 18:57:06 +0000609 thread_add_event (master, neighbor_change, on->ospf6_if, 0);
610
611 listnode_delete (on->ospf6_if->neighbor_list, on);
612 ospf6_neighbor_delete (on);
613
614 return 0;
615}
616
617
David Lamparter6b0655a2014-06-04 06:53:35 +0200618
paul718e3742002-12-13 20:15:29 +0000619/* vty functions */
620/* show neighbor structure */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100621static void
hasso508e53e2004-05-18 18:57:06 +0000622ospf6_neighbor_show (struct vty *vty, struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000623{
624 char router_id[16];
hasso508e53e2004-05-18 18:57:06 +0000625 char duration[16];
626 struct timeval now, res;
627 char nstate[16];
628 char deadtime[16];
629 long h, m, s;
630
631 /* Router-ID (Name) */
632 inet_ntop (AF_INET, &on->router_id, router_id, sizeof (router_id));
633#ifdef HAVE_GETNAMEINFO
634 {
635 }
636#endif /*HAVE_GETNAMEINFO*/
637
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900638 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
hasso508e53e2004-05-18 18:57:06 +0000639
640 /* Dead time */
641 h = m = s = 0;
642 if (on->inactivity_timer)
643 {
Paul Jakmac136d242007-03-08 17:50:01 +0000644 s = on->inactivity_timer->u.sands.tv_sec - recent_relative_time().tv_sec;
hasso508e53e2004-05-18 18:57:06 +0000645 h = s / 3600;
646 s -= h * 3600;
647 m = s / 60;
648 s -= m * 60;
649 }
650 snprintf (deadtime, sizeof (deadtime), "%02ld:%02ld:%02ld", h, m, s);
651
652 /* Neighbor State */
653 if (if_is_pointopoint (on->ospf6_if->interface))
654 snprintf (nstate, sizeof (nstate), "PointToPoint");
655 else
656 {
657 if (on->router_id == on->drouter)
658 snprintf (nstate, sizeof (nstate), "DR");
659 else if (on->router_id == on->bdrouter)
660 snprintf (nstate, sizeof (nstate), "BDR");
661 else
662 snprintf (nstate, sizeof (nstate), "DROther");
663 }
664
665 /* Duration */
666 timersub (&now, &on->last_changed, &res);
667 timerstring (&res, duration, sizeof (duration));
668
669 /*
670 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s",
671 "Neighbor ID", "Pri", "DeadTime", "State", "", "Duration",
hasso049207c2004-08-04 20:02:13 +0000672 "I/F", "State", VNL);
hasso508e53e2004-05-18 18:57:06 +0000673 */
674
675 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s",
676 router_id, on->priority, deadtime,
677 ospf6_neighbor_state_str[on->state], nstate, duration,
678 on->ospf6_if->interface->name,
hasso049207c2004-08-04 20:02:13 +0000679 ospf6_interface_state_str[on->ospf6_if->state], VNL);
hasso508e53e2004-05-18 18:57:06 +0000680}
681
Paul Jakma6ac29a52008-08-15 13:45:30 +0100682static void
hasso508e53e2004-05-18 18:57:06 +0000683ospf6_neighbor_show_drchoice (struct vty *vty, struct ospf6_neighbor *on)
684{
685 char router_id[16];
686 char drouter[16], bdrouter[16];
paul718e3742002-12-13 20:15:29 +0000687 char duration[16];
688 struct timeval now, res;
689
690/*
691 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
692 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
hasso049207c2004-08-04 20:02:13 +0000693 "State", VNL);
paul718e3742002-12-13 20:15:29 +0000694*/
695
hasso508e53e2004-05-18 18:57:06 +0000696 inet_ntop (AF_INET, &on->router_id, router_id, sizeof (router_id));
697 inet_ntop (AF_INET, &on->drouter, drouter, sizeof (drouter));
698 inet_ntop (AF_INET, &on->bdrouter, bdrouter, sizeof (bdrouter));
paul718e3742002-12-13 20:15:29 +0000699
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900700 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
hasso508e53e2004-05-18 18:57:06 +0000701 timersub (&now, &on->last_changed, &res);
702 timerstring (&res, duration, sizeof (duration));
paul718e3742002-12-13 20:15:29 +0000703
704 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
hasso508e53e2004-05-18 18:57:06 +0000705 router_id, ospf6_neighbor_state_str[on->state],
706 duration, drouter, bdrouter, on->ospf6_if->interface->name,
707 ospf6_interface_state_str[on->ospf6_if->state],
hasso049207c2004-08-04 20:02:13 +0000708 VNL);
paul718e3742002-12-13 20:15:29 +0000709}
710
Paul Jakma6ac29a52008-08-15 13:45:30 +0100711static void
hasso508e53e2004-05-18 18:57:06 +0000712ospf6_neighbor_show_detail (struct vty *vty, struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000713{
hasso508e53e2004-05-18 18:57:06 +0000714 char drouter[16], bdrouter[16];
715 char linklocal_addr[64], duration[32];
paul718e3742002-12-13 20:15:29 +0000716 struct timeval now, res;
hasso508e53e2004-05-18 18:57:06 +0000717 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000718
hasso508e53e2004-05-18 18:57:06 +0000719 inet_ntop (AF_INET6, &on->linklocal_addr, linklocal_addr,
720 sizeof (linklocal_addr));
721 inet_ntop (AF_INET, &on->drouter, drouter, sizeof (drouter));
722 inet_ntop (AF_INET, &on->bdrouter, bdrouter, sizeof (bdrouter));
paul718e3742002-12-13 20:15:29 +0000723
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900724 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
hasso508e53e2004-05-18 18:57:06 +0000725 timersub (&now, &on->last_changed, &res);
726 timerstring (&res, duration, sizeof (duration));
paul718e3742002-12-13 20:15:29 +0000727
hasso508e53e2004-05-18 18:57:06 +0000728 vty_out (vty, " Neighbor %s%s", on->name,
hasso049207c2004-08-04 20:02:13 +0000729 VNL);
hasso508e53e2004-05-18 18:57:06 +0000730 vty_out (vty, " Area %s via interface %s (ifindex %d)%s",
731 on->ospf6_if->area->name,
732 on->ospf6_if->interface->name,
733 on->ospf6_if->interface->ifindex,
hasso049207c2004-08-04 20:02:13 +0000734 VNL);
hasso508e53e2004-05-18 18:57:06 +0000735 vty_out (vty, " His IfIndex: %d Link-local address: %s%s",
736 on->ifindex, linklocal_addr,
hasso049207c2004-08-04 20:02:13 +0000737 VNL);
hasso508e53e2004-05-18 18:57:06 +0000738 vty_out (vty, " State %s for a duration of %s%s",
739 ospf6_neighbor_state_str[on->state], duration,
hasso049207c2004-08-04 20:02:13 +0000740 VNL);
hasso508e53e2004-05-18 18:57:06 +0000741 vty_out (vty, " His choice of DR/BDR %s/%s, Priority %d%s",
742 drouter, bdrouter, on->priority,
hasso049207c2004-08-04 20:02:13 +0000743 VNL);
hasso508e53e2004-05-18 18:57:06 +0000744 vty_out (vty, " DbDesc status: %s%s%s SeqNum: %#lx%s",
745 (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT) ? "Initial " : ""),
746 (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT) ? "More " : ""),
747 (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT) ?
748 "Master" : "Slave"), (u_long) ntohl (on->dbdesc_seqnum),
hasso049207c2004-08-04 20:02:13 +0000749 VNL);
paul718e3742002-12-13 20:15:29 +0000750
hasso508e53e2004-05-18 18:57:06 +0000751 vty_out (vty, " Summary-List: %d LSAs%s", on->summary_list->count,
hasso049207c2004-08-04 20:02:13 +0000752 VNL);
hasso508e53e2004-05-18 18:57:06 +0000753 for (lsa = ospf6_lsdb_head (on->summary_list); lsa;
754 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000755 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000756
hasso508e53e2004-05-18 18:57:06 +0000757 vty_out (vty, " Request-List: %d LSAs%s", on->request_list->count,
hasso049207c2004-08-04 20:02:13 +0000758 VNL);
hasso508e53e2004-05-18 18:57:06 +0000759 for (lsa = ospf6_lsdb_head (on->request_list); lsa;
760 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000761 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000762
763 vty_out (vty, " Retrans-List: %d LSAs%s", on->retrans_list->count,
hasso049207c2004-08-04 20:02:13 +0000764 VNL);
hasso508e53e2004-05-18 18:57:06 +0000765 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
766 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000767 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000768
769 timerclear (&res);
770 if (on->thread_send_dbdesc)
771 timersub (&on->thread_send_dbdesc->u.sands, &now, &res);
772 timerstring (&res, duration, sizeof (duration));
773 vty_out (vty, " %d Pending LSAs for DbDesc in Time %s [thread %s]%s",
774 on->dbdesc_list->count, duration,
775 (on->thread_send_dbdesc ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000776 VNL);
hasso508e53e2004-05-18 18:57:06 +0000777 for (lsa = ospf6_lsdb_head (on->dbdesc_list); lsa;
778 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000779 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000780
781 timerclear (&res);
782 if (on->thread_send_lsreq)
783 timersub (&on->thread_send_lsreq->u.sands, &now, &res);
784 timerstring (&res, duration, sizeof (duration));
785 vty_out (vty, " %d Pending LSAs for LSReq in Time %s [thread %s]%s",
Dinesh Dutteb82e9e2013-08-24 07:55:07 +0000786 on->request_list->count, duration,
hasso508e53e2004-05-18 18:57:06 +0000787 (on->thread_send_lsreq ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000788 VNL);
Dinesh Dutteb82e9e2013-08-24 07:55:07 +0000789 for (lsa = ospf6_lsdb_head (on->request_list); lsa;
hasso508e53e2004-05-18 18:57:06 +0000790 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000791 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000792
793 timerclear (&res);
794 if (on->thread_send_lsupdate)
795 timersub (&on->thread_send_lsupdate->u.sands, &now, &res);
796 timerstring (&res, duration, sizeof (duration));
797 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
798 on->lsupdate_list->count, duration,
799 (on->thread_send_lsupdate ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000800 VNL);
hasso508e53e2004-05-18 18:57:06 +0000801 for (lsa = ospf6_lsdb_head (on->lsupdate_list); lsa;
802 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000803 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000804
805 timerclear (&res);
806 if (on->thread_send_lsack)
807 timersub (&on->thread_send_lsack->u.sands, &now, &res);
808 timerstring (&res, duration, sizeof (duration));
809 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
810 on->lsack_list->count, duration,
811 (on->thread_send_lsack ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000812 VNL);
hasso508e53e2004-05-18 18:57:06 +0000813 for (lsa = ospf6_lsdb_head (on->lsack_list); lsa;
814 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000815 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000816
paul718e3742002-12-13 20:15:29 +0000817}
818
hasso508e53e2004-05-18 18:57:06 +0000819DEFUN (show_ipv6_ospf6_neighbor,
paul718e3742002-12-13 20:15:29 +0000820 show_ipv6_ospf6_neighbor_cmd,
821 "show ipv6 ospf6 neighbor",
822 SHOW_STR
823 IP6_STR
824 OSPF6_STR
825 "Neighbor list\n"
hasso508e53e2004-05-18 18:57:06 +0000826 )
paul718e3742002-12-13 20:15:29 +0000827{
hasso508e53e2004-05-18 18:57:06 +0000828 struct ospf6_neighbor *on;
829 struct ospf6_interface *oi;
830 struct ospf6_area *oa;
hasso52dc7ee2004-09-23 19:18:23 +0000831 struct listnode *i, *j, *k;
hasso508e53e2004-05-18 18:57:06 +0000832 void (*showfunc) (struct vty *, struct ospf6_neighbor *);
paul718e3742002-12-13 20:15:29 +0000833
834 OSPF6_CMD_CHECK_RUNNING ();
hasso508e53e2004-05-18 18:57:06 +0000835 showfunc = ospf6_neighbor_show;
836
837 if (argc)
838 {
839 if (! strncmp (argv[0], "de", 2))
840 showfunc = ospf6_neighbor_show_detail;
841 else if (! strncmp (argv[0], "dr", 2))
842 showfunc = ospf6_neighbor_show_drchoice;
843 }
844
845 if (showfunc == ospf6_neighbor_show)
846 vty_out (vty, "%-15s %3s %11s %6s/%-12s %11s %s[%s]%s",
847 "Neighbor ID", "Pri", "DeadTime", "State", "IfState", "Duration",
hasso049207c2004-08-04 20:02:13 +0000848 "I/F", "State", VNL);
hasso508e53e2004-05-18 18:57:06 +0000849 else if (showfunc == ospf6_neighbor_show_drchoice)
850 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
851 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
hasso049207c2004-08-04 20:02:13 +0000852 "State", VNL);
paul718e3742002-12-13 20:15:29 +0000853
paul1eb8ef22005-04-07 07:30:20 +0000854 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, i, oa))
855 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
856 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
857 (*showfunc) (vty, on);
858
hasso508e53e2004-05-18 18:57:06 +0000859 return CMD_SUCCESS;
860}
paul718e3742002-12-13 20:15:29 +0000861
hasso508e53e2004-05-18 18:57:06 +0000862ALIAS (show_ipv6_ospf6_neighbor,
863 show_ipv6_ospf6_neighbor_detail_cmd,
864 "show ipv6 ospf6 neighbor (detail|drchoice)",
865 SHOW_STR
866 IP6_STR
867 OSPF6_STR
868 "Neighbor list\n"
869 "Display details\n"
870 "Display DR choices\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100871 )
hasso508e53e2004-05-18 18:57:06 +0000872
873DEFUN (show_ipv6_ospf6_neighbor_one,
874 show_ipv6_ospf6_neighbor_one_cmd,
875 "show ipv6 ospf6 neighbor A.B.C.D",
876 SHOW_STR
877 IP6_STR
878 OSPF6_STR
879 "Neighbor list\n"
880 "Specify Router-ID as IPv4 address notation\n"
881 )
882{
883 struct ospf6_neighbor *on;
884 struct ospf6_interface *oi;
885 struct ospf6_area *oa;
hasso52dc7ee2004-09-23 19:18:23 +0000886 struct listnode *i, *j, *k;
hasso508e53e2004-05-18 18:57:06 +0000887 void (*showfunc) (struct vty *, struct ospf6_neighbor *);
888 u_int32_t router_id;
889
890 OSPF6_CMD_CHECK_RUNNING ();
891 showfunc = ospf6_neighbor_show_detail;
892
893 if ((inet_pton (AF_INET, argv[0], &router_id)) != 1)
894 {
895 vty_out (vty, "Router-ID is not parsable: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000896 VNL);
hasso508e53e2004-05-18 18:57:06 +0000897 return CMD_SUCCESS;
898 }
899
paul1eb8ef22005-04-07 07:30:20 +0000900 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, i, oa))
901 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
902 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
903 (*showfunc) (vty, on);
904
paul718e3742002-12-13 20:15:29 +0000905 return CMD_SUCCESS;
906}
907
908void
Paul Jakma6ac29a52008-08-15 13:45:30 +0100909ospf6_neighbor_init (void)
paul718e3742002-12-13 20:15:29 +0000910{
911 install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_cmd);
hasso508e53e2004-05-18 18:57:06 +0000912 install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000913 install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_cmd);
hasso508e53e2004-05-18 18:57:06 +0000914 install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000915}
916
hasso508e53e2004-05-18 18:57:06 +0000917DEFUN (debug_ospf6_neighbor,
918 debug_ospf6_neighbor_cmd,
919 "debug ospf6 neighbor",
920 DEBUG_STR
921 OSPF6_STR
922 "Debug OSPFv3 Neighbor\n"
923 )
924{
925 unsigned char level = 0;
926 if (argc)
927 {
928 if (! strncmp (argv[0], "s", 1))
929 level = OSPF6_DEBUG_NEIGHBOR_STATE;
930 if (! strncmp (argv[0], "e", 1))
931 level = OSPF6_DEBUG_NEIGHBOR_EVENT;
932 }
933 else
934 level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;
935
936 OSPF6_DEBUG_NEIGHBOR_ON (level);
937 return CMD_SUCCESS;
938}
939
940ALIAS (debug_ospf6_neighbor,
941 debug_ospf6_neighbor_detail_cmd,
942 "debug ospf6 neighbor (state|event)",
943 DEBUG_STR
944 OSPF6_STR
945 "Debug OSPFv3 Neighbor\n"
946 "Debug OSPFv3 Neighbor State Change\n"
947 "Debug OSPFv3 Neighbor Event\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100948 )
hasso508e53e2004-05-18 18:57:06 +0000949
950DEFUN (no_debug_ospf6_neighbor,
951 no_debug_ospf6_neighbor_cmd,
952 "no debug ospf6 neighbor",
953 NO_STR
954 DEBUG_STR
955 OSPF6_STR
956 "Debug OSPFv3 Neighbor\n"
957 )
958{
959 unsigned char level = 0;
960 if (argc)
961 {
962 if (! strncmp (argv[0], "s", 1))
963 level = OSPF6_DEBUG_NEIGHBOR_STATE;
964 if (! strncmp (argv[0], "e", 1))
965 level = OSPF6_DEBUG_NEIGHBOR_EVENT;
966 }
967 else
968 level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;
969
970 OSPF6_DEBUG_NEIGHBOR_OFF (level);
971 return CMD_SUCCESS;
972}
973
974ALIAS (no_debug_ospf6_neighbor,
975 no_debug_ospf6_neighbor_detail_cmd,
976 "no debug ospf6 neighbor (state|event)",
977 NO_STR
978 DEBUG_STR
979 OSPF6_STR
980 "Debug OSPFv3 Neighbor\n"
981 "Debug OSPFv3 Neighbor State Change\n"
982 "Debug OSPFv3 Neighbor Event\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100983 )
hasso508e53e2004-05-18 18:57:06 +0000984
985int
986config_write_ospf6_debug_neighbor (struct vty *vty)
987{
988 if (IS_OSPF6_DEBUG_NEIGHBOR (STATE) &&
989 IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hasso049207c2004-08-04 20:02:13 +0000990 vty_out (vty, "debug ospf6 neighbor%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000991 else if (IS_OSPF6_DEBUG_NEIGHBOR (STATE))
hasso049207c2004-08-04 20:02:13 +0000992 vty_out (vty, "debug ospf6 neighbor state%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000993 else if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hasso049207c2004-08-04 20:02:13 +0000994 vty_out (vty, "debug ospf6 neighbor event%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000995 return 0;
996}
997
998void
Paul Jakma6ac29a52008-08-15 13:45:30 +0100999install_element_ospf6_debug_neighbor (void)
hasso508e53e2004-05-18 18:57:06 +00001000{
1001 install_element (ENABLE_NODE, &debug_ospf6_neighbor_cmd);
1002 install_element (ENABLE_NODE, &debug_ospf6_neighbor_detail_cmd);
1003 install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_cmd);
1004 install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_detail_cmd);
1005 install_element (CONFIG_NODE, &debug_ospf6_neighbor_cmd);
1006 install_element (CONFIG_NODE, &debug_ospf6_neighbor_detail_cmd);
1007 install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_cmd);
1008 install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_detail_cmd);
1009}
1010
1011
paul718e3742002-12-13 20:15:29 +00001012