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