paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 2 | * Copyright (C) 2003 Yasuhiro Ohara |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 22 | #include <zebra.h> |
| 23 | |
| 24 | #include "log.h" |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 25 | #include "memory.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 26 | #include "thread.h" |
| 27 | #include "linklist.h" |
| 28 | #include "vty.h" |
| 29 | #include "command.h" |
| 30 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 31 | #include "ospf6_proto.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 32 | #include "ospf6_lsa.h" |
| 33 | #include "ospf6_lsdb.h" |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 34 | #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" |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 40 | #include "ospf6_flood.h" |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 41 | #include "ospf6d.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 42 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 43 | unsigned char conf_debug_ospf6_neighbor = 0; |
| 44 | |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 45 | const char *ospf6_neighbor_state_str[] = |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 46 | { "None", "Down", "Attempt", "Init", "Twoway", "ExStart", "ExChange", |
| 47 | "Loading", "Full", NULL }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 48 | |
| 49 | int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 50 | ospf6_neighbor_cmp (void *va, void *vb) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 51 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 52 | struct ospf6_neighbor *ona = (struct ospf6_neighbor *) va; |
| 53 | struct ospf6_neighbor *onb = (struct ospf6_neighbor *) vb; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 54 | return (ntohl (ona->router_id) < ntohl (onb->router_id) ? -1 : 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 55 | } |
| 56 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 57 | struct ospf6_neighbor * |
| 58 | ospf6_neighbor_lookup (u_int32_t router_id, |
| 59 | struct ospf6_interface *oi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 60 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 61 | struct listnode *n; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 62 | struct ospf6_neighbor *on; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 63 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 64 | for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, n, on)) |
| 65 | if (on->router_id == router_id) |
| 66 | return on; |
| 67 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 68 | return (struct ospf6_neighbor *) NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | /* create ospf6_neighbor */ |
| 72 | struct ospf6_neighbor * |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 73 | ospf6_neighbor_create (u_int32_t router_id, struct ospf6_interface *oi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 74 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 75 | struct ospf6_neighbor *on; |
| 76 | char buf[16]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 77 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 78 | on = (struct ospf6_neighbor *) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 79 | XMALLOC (MTYPE_OSPF6_NEIGHBOR, sizeof (struct ospf6_neighbor)); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 80 | if (on == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 81 | { |
| 82 | zlog_warn ("neighbor: malloc failed"); |
| 83 | return NULL; |
| 84 | } |
| 85 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 86 | memset (on, 0, sizeof (struct ospf6_neighbor)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 87 | inet_ntop (AF_INET, &router_id, buf, sizeof (buf)); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 88 | 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 Bernat | 061bc73 | 2012-05-31 20:21:15 +0200 | [diff] [blame] | 92 | on->state_change = 0; |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 93 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &on->last_changed); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 94 | on->router_id = router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 95 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 96 | on->summary_list = ospf6_lsdb_create (on); |
| 97 | on->request_list = ospf6_lsdb_create (on); |
| 98 | on->retrans_list = ospf6_lsdb_create (on); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 99 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 100 | on->dbdesc_list = ospf6_lsdb_create (on); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 101 | on->lsupdate_list = ospf6_lsdb_create (on); |
| 102 | on->lsack_list = ospf6_lsdb_create (on); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 103 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 104 | listnode_add_sort (oi->neighbor_list, on); |
| 105 | return on; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 109 | ospf6_neighbor_delete (struct ospf6_neighbor *on) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 110 | { |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 111 | struct ospf6_lsa *lsa; |
| 112 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 113 | ospf6_lsdb_remove_all (on->summary_list); |
| 114 | ospf6_lsdb_remove_all (on->request_list); |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 115 | for (lsa = ospf6_lsdb_head (on->retrans_list); lsa; |
| 116 | lsa = ospf6_lsdb_next (lsa)) |
| 117 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 118 | ospf6_decrement_retrans_count (lsa); |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 119 | ospf6_lsdb_remove (lsa, on->retrans_list); |
| 120 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 121 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 122 | ospf6_lsdb_remove_all (on->dbdesc_list); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 123 | ospf6_lsdb_remove_all (on->lsupdate_list); |
| 124 | ospf6_lsdb_remove_all (on->lsack_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 125 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 126 | ospf6_lsdb_delete (on->summary_list); |
| 127 | ospf6_lsdb_delete (on->request_list); |
| 128 | ospf6_lsdb_delete (on->retrans_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 129 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 130 | ospf6_lsdb_delete (on->dbdesc_list); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 131 | ospf6_lsdb_delete (on->lsupdate_list); |
| 132 | ospf6_lsdb_delete (on->lsack_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 133 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 134 | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 142 | } |
| 143 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 144 | static void |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 145 | ospf6_neighbor_state_change (u_char next_state, struct ospf6_neighbor *on, int event) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 146 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 147 | u_char prev_state; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 148 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 149 | prev_state = on->state; |
| 150 | on->state = next_state; |
| 151 | |
| 152 | if (prev_state == next_state) |
| 153 | return; |
| 154 | |
Vincent Bernat | 061bc73 | 2012-05-31 20:21:15 +0200 | [diff] [blame] | 155 | on->state_change++; |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 156 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &on->last_changed); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 157 | |
| 158 | /* log */ |
| 159 | if (IS_OSPF6_DEBUG_NEIGHBOR (STATE)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 160 | { |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 161 | zlog_debug ("Neighbor state change %s: [%s]->[%s] (%s)", on->name, |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 162 | ospf6_neighbor_state_str[prev_state], |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 163 | ospf6_neighbor_state_str[next_state], |
| 164 | ospf6_neighbor_event_string(event)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 165 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 166 | |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 167 | /* 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 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 178 | 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); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 185 | } |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 186 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (on->ospf6_if->area); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 187 | } |
| 188 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 189 | 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 Jakma | 932bf19 | 2006-05-15 10:42:24 +0000 | [diff] [blame] | 193 | ospf6_maxage_remove (on->ospf6_if->area->ospf6); |
Vincent Bernat | bf83666 | 2012-06-04 14:36:12 +0200 | [diff] [blame] | 194 | |
| 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 203 | } |
| 204 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 205 | /* RFC2328 section 10.4 */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 206 | static int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 207 | need_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 | |
| 221 | int |
| 222 | hello_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)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 230 | zlog_debug ("Neighbor Event %s: *HelloReceived*", on->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 231 | |
| 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 Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 238 | ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on, |
| 239 | OSPF6_NEIGHBOR_EVENT_HELLO_RCVD); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 240 | |
| 241 | return 0; |
| 242 | } |
| 243 | |
| 244 | int |
| 245 | twoway_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)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 256 | zlog_debug ("Neighbor Event %s: *2Way-Received*", on->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 257 | |
| 258 | thread_add_event (master, neighbor_change, on->ospf6_if, 0); |
| 259 | |
| 260 | if (! need_adjacency (on)) |
| 261 | { |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 262 | ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY, on, |
| 263 | OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 264 | return 0; |
| 265 | } |
| 266 | |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 267 | ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on, |
| 268 | OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 269 | 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 | |
| 280 | int |
| 281 | negotiation_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)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 293 | zlog_debug ("Neighbor Event %s: *NegotiationDone*", on->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 294 | |
| 295 | /* clear ls-list */ |
| 296 | ospf6_lsdb_remove_all (on->summary_list); |
| 297 | ospf6_lsdb_remove_all (on->request_list); |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 298 | for (lsa = ospf6_lsdb_head (on->retrans_list); lsa; |
| 299 | lsa = ospf6_lsdb_next (lsa)) |
| 300 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 301 | ospf6_decrement_retrans_count (lsa); |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 302 | ospf6_lsdb_remove (lsa, on->retrans_list); |
| 303 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 304 | |
| 305 | /* Interface scoped LSAs */ |
| 306 | for (lsa = ospf6_lsdb_head (on->ospf6_if->lsdb); lsa; |
| 307 | lsa = ospf6_lsdb_next (lsa)) |
| 308 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 309 | if (OSPF6_LSA_IS_MAXAGE (lsa)) |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 310 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 311 | ospf6_increment_retrans_count (lsa); |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 312 | ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list); |
| 313 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 314 | 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 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 322 | if (OSPF6_LSA_IS_MAXAGE (lsa)) |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 323 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 324 | ospf6_increment_retrans_count (lsa); |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 325 | ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list); |
| 326 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 327 | 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 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 335 | if (OSPF6_LSA_IS_MAXAGE (lsa)) |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 336 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 337 | ospf6_increment_retrans_count (lsa); |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 338 | ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list); |
| 339 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 340 | else |
| 341 | ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->summary_list); |
| 342 | } |
| 343 | |
| 344 | UNSET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT); |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 345 | ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXCHANGE, on, |
| 346 | OSPF6_NEIGHBOR_EVENT_NEGOTIATION_DONE); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 347 | |
| 348 | return 0; |
| 349 | } |
| 350 | |
| 351 | int |
| 352 | exchange_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)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 363 | zlog_debug ("Neighbor Event %s: *ExchangeDone*", on->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 364 | |
| 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 Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 374 | ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL, on, |
| 375 | OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 376 | else |
Dinesh Dutt | eb82e9e | 2013-08-24 07:55:07 +0000 | [diff] [blame] | 377 | { |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 378 | ospf6_neighbor_state_change (OSPF6_NEIGHBOR_LOADING, on, |
| 379 | OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE); |
Dinesh Dutt | eb82e9e | 2013-08-24 07:55:07 +0000 | [diff] [blame] | 380 | |
| 381 | if (on->thread_send_lsreq == NULL) |
| 382 | on->thread_send_lsreq = |
| 383 | thread_add_event (master, ospf6_lsreq_send, on, 0); |
| 384 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 385 | |
| 386 | return 0; |
| 387 | } |
| 388 | |
Dinesh Dutt | eb82e9e | 2013-08-24 07:55:07 +0000 | [diff] [blame] | 389 | /* Check loading state. */ |
| 390 | void |
| 391 | ospf6_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 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 413 | int |
| 414 | loading_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)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 425 | zlog_debug ("Neighbor Event %s: *LoadingDone*", on->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 426 | |
| 427 | assert (on->request_list->count == 0); |
| 428 | |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 429 | ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL, on, |
| 430 | OSPF6_NEIGHBOR_EVENT_LOADING_DONE); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 431 | |
| 432 | return 0; |
| 433 | } |
| 434 | |
| 435 | int |
| 436 | adj_ok (struct thread *thread) |
| 437 | { |
| 438 | struct ospf6_neighbor *on; |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 439 | struct ospf6_lsa *lsa; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 440 | |
| 441 | on = (struct ospf6_neighbor *) THREAD_ARG (thread); |
| 442 | assert (on); |
| 443 | |
| 444 | if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 445 | zlog_debug ("Neighbor Event %s: *AdjOK?*", on->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 446 | |
| 447 | if (on->state == OSPF6_NEIGHBOR_TWOWAY && need_adjacency (on)) |
| 448 | { |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 449 | ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on, |
| 450 | OSPF6_NEIGHBOR_EVENT_ADJ_OK); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 451 | 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 Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 463 | ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY, on, |
| 464 | OSPF6_NEIGHBOR_EVENT_ADJ_OK); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 465 | ospf6_lsdb_remove_all (on->summary_list); |
| 466 | ospf6_lsdb_remove_all (on->request_list); |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 467 | for (lsa = ospf6_lsdb_head (on->retrans_list); lsa; |
| 468 | lsa = ospf6_lsdb_next (lsa)) |
| 469 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 470 | ospf6_decrement_retrans_count (lsa); |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 471 | ospf6_lsdb_remove (lsa, on->retrans_list); |
| 472 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 473 | } |
| 474 | |
| 475 | return 0; |
| 476 | } |
| 477 | |
| 478 | int |
| 479 | seqnumber_mismatch (struct thread *thread) |
| 480 | { |
| 481 | struct ospf6_neighbor *on; |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 482 | struct ospf6_lsa *lsa; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 483 | |
| 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)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 491 | zlog_debug ("Neighbor Event %s: *SeqNumberMismatch*", on->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 492 | |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 493 | ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on, |
| 494 | OSPF6_NEIGHBOR_EVENT_SEQNUMBER_MISMATCH); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 495 | 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); |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 501 | for (lsa = ospf6_lsdb_head (on->retrans_list); lsa; |
| 502 | lsa = ospf6_lsdb_next (lsa)) |
| 503 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 504 | ospf6_decrement_retrans_count (lsa); |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 505 | ospf6_lsdb_remove (lsa, on->retrans_list); |
| 506 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 507 | |
| 508 | THREAD_OFF (on->thread_send_dbdesc); |
Dinesh Dutt | 931b1b8 | 2013-08-25 03:03:15 +0000 | [diff] [blame] | 509 | on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */ |
| 510 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 511 | on->thread_send_dbdesc = |
| 512 | thread_add_event (master, ospf6_dbdesc_send, on, 0); |
| 513 | |
| 514 | return 0; |
| 515 | } |
| 516 | |
| 517 | int |
| 518 | bad_lsreq (struct thread *thread) |
| 519 | { |
| 520 | struct ospf6_neighbor *on; |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 521 | struct ospf6_lsa *lsa; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 522 | |
| 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)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 530 | zlog_debug ("Neighbor Event %s: *BadLSReq*", on->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 531 | |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 532 | ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on, |
| 533 | OSPF6_NEIGHBOR_EVENT_BAD_LSREQ); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 534 | 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); |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 540 | for (lsa = ospf6_lsdb_head (on->retrans_list); lsa; |
| 541 | lsa = ospf6_lsdb_next (lsa)) |
| 542 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 543 | ospf6_decrement_retrans_count (lsa); |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 544 | ospf6_lsdb_remove (lsa, on->retrans_list); |
| 545 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 546 | |
| 547 | THREAD_OFF (on->thread_send_dbdesc); |
Dinesh Dutt | 931b1b8 | 2013-08-25 03:03:15 +0000 | [diff] [blame] | 548 | on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */ |
| 549 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 550 | on->thread_send_dbdesc = |
| 551 | thread_add_event (master, ospf6_dbdesc_send, on, 0); |
| 552 | |
| 553 | return 0; |
| 554 | } |
| 555 | |
| 556 | int |
| 557 | oneway_received (struct thread *thread) |
| 558 | { |
| 559 | struct ospf6_neighbor *on; |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 560 | struct ospf6_lsa *lsa; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 561 | |
| 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)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 569 | zlog_debug ("Neighbor Event %s: *1Way-Received*", on->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 570 | |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 571 | ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on, |
| 572 | OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 573 | 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); |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 577 | for (lsa = ospf6_lsdb_head (on->retrans_list); lsa; |
| 578 | lsa = ospf6_lsdb_next (lsa)) |
| 579 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 580 | ospf6_decrement_retrans_count (lsa); |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 581 | ospf6_lsdb_remove (lsa, on->retrans_list); |
| 582 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 583 | |
| 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 | |
| 592 | int |
| 593 | inactivity_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)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 601 | zlog_debug ("Neighbor Event %s: *InactivityTimer*", on->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 602 | |
| 603 | on->inactivity_timer = NULL; |
| 604 | on->drouter = on->prev_drouter = 0; |
| 605 | on->bdrouter = on->prev_bdrouter = 0; |
| 606 | |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 607 | ospf6_neighbor_state_change (OSPF6_NEIGHBOR_DOWN, on, |
| 608 | OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 609 | 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 Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 618 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 619 | /* vty functions */ |
| 620 | /* show neighbor structure */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 621 | static void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 622 | ospf6_neighbor_show (struct vty *vty, struct ospf6_neighbor *on) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 623 | { |
| 624 | char router_id[16]; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 625 | 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 Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 638 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &now); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 639 | |
| 640 | /* Dead time */ |
| 641 | h = m = s = 0; |
| 642 | if (on->inactivity_timer) |
| 643 | { |
Paul Jakma | c136d24 | 2007-03-08 17:50:01 +0000 | [diff] [blame] | 644 | s = on->inactivity_timer->u.sands.tv_sec - recent_relative_time().tv_sec; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 645 | 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", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 672 | "I/F", "State", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 673 | */ |
| 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, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 679 | ospf6_interface_state_str[on->ospf6_if->state], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 680 | } |
| 681 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 682 | static void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 683 | ospf6_neighbor_show_drchoice (struct vty *vty, struct ospf6_neighbor *on) |
| 684 | { |
| 685 | char router_id[16]; |
| 686 | char drouter[16], bdrouter[16]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 687 | 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", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 693 | "State", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 694 | */ |
| 695 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 696 | 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)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 699 | |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 700 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &now); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 701 | timersub (&now, &on->last_changed, &res); |
| 702 | timerstring (&res, duration, sizeof (duration)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 703 | |
| 704 | vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s", |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 705 | 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], |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 708 | VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 709 | } |
| 710 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 711 | static void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 712 | ospf6_neighbor_show_detail (struct vty *vty, struct ospf6_neighbor *on) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 713 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 714 | char drouter[16], bdrouter[16]; |
| 715 | char linklocal_addr[64], duration[32]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 716 | struct timeval now, res; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 717 | struct ospf6_lsa *lsa; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 718 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 719 | 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)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 723 | |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 724 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &now); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 725 | timersub (&now, &on->last_changed, &res); |
| 726 | timerstring (&res, duration, sizeof (duration)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 727 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 728 | vty_out (vty, " Neighbor %s%s", on->name, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 729 | VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 730 | 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, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 734 | VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 735 | vty_out (vty, " His IfIndex: %d Link-local address: %s%s", |
| 736 | on->ifindex, linklocal_addr, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 737 | VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 738 | vty_out (vty, " State %s for a duration of %s%s", |
| 739 | ospf6_neighbor_state_str[on->state], duration, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 740 | VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 741 | vty_out (vty, " His choice of DR/BDR %s/%s, Priority %d%s", |
| 742 | drouter, bdrouter, on->priority, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 743 | VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 744 | 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), |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 749 | VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 750 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 751 | vty_out (vty, " Summary-List: %d LSAs%s", on->summary_list->count, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 752 | VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 753 | for (lsa = ospf6_lsdb_head (on->summary_list); lsa; |
| 754 | lsa = ospf6_lsdb_next (lsa)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 755 | vty_out (vty, " %s%s", lsa->name, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 756 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 757 | vty_out (vty, " Request-List: %d LSAs%s", on->request_list->count, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 758 | VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 759 | for (lsa = ospf6_lsdb_head (on->request_list); lsa; |
| 760 | lsa = ospf6_lsdb_next (lsa)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 761 | vty_out (vty, " %s%s", lsa->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 762 | |
| 763 | vty_out (vty, " Retrans-List: %d LSAs%s", on->retrans_list->count, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 764 | VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 765 | for (lsa = ospf6_lsdb_head (on->retrans_list); lsa; |
| 766 | lsa = ospf6_lsdb_next (lsa)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 767 | vty_out (vty, " %s%s", lsa->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 768 | |
| 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"), |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 776 | VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 777 | for (lsa = ospf6_lsdb_head (on->dbdesc_list); lsa; |
| 778 | lsa = ospf6_lsdb_next (lsa)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 779 | vty_out (vty, " %s%s", lsa->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 780 | |
| 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 Dutt | eb82e9e | 2013-08-24 07:55:07 +0000 | [diff] [blame] | 786 | on->request_list->count, duration, |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 787 | (on->thread_send_lsreq ? "on" : "off"), |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 788 | VNL); |
Dinesh Dutt | eb82e9e | 2013-08-24 07:55:07 +0000 | [diff] [blame] | 789 | for (lsa = ospf6_lsdb_head (on->request_list); lsa; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 790 | lsa = ospf6_lsdb_next (lsa)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 791 | vty_out (vty, " %s%s", lsa->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 792 | |
| 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"), |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 800 | VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 801 | for (lsa = ospf6_lsdb_head (on->lsupdate_list); lsa; |
| 802 | lsa = ospf6_lsdb_next (lsa)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 803 | vty_out (vty, " %s%s", lsa->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 804 | |
| 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"), |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 812 | VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 813 | for (lsa = ospf6_lsdb_head (on->lsack_list); lsa; |
| 814 | lsa = ospf6_lsdb_next (lsa)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 815 | vty_out (vty, " %s%s", lsa->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 816 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 817 | } |
| 818 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 819 | DEFUN (show_ipv6_ospf6_neighbor, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 820 | show_ipv6_ospf6_neighbor_cmd, |
| 821 | "show ipv6 ospf6 neighbor", |
| 822 | SHOW_STR |
| 823 | IP6_STR |
| 824 | OSPF6_STR |
| 825 | "Neighbor list\n" |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 826 | ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 827 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 828 | struct ospf6_neighbor *on; |
| 829 | struct ospf6_interface *oi; |
| 830 | struct ospf6_area *oa; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 831 | struct listnode *i, *j, *k; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 832 | void (*showfunc) (struct vty *, struct ospf6_neighbor *); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 833 | |
| 834 | OSPF6_CMD_CHECK_RUNNING (); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 835 | 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", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 848 | "I/F", "State", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 849 | 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", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 852 | "State", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 853 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 854 | 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 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 859 | return CMD_SUCCESS; |
| 860 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 861 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 862 | ALIAS (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 Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 871 | ) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 872 | |
| 873 | DEFUN (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; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 886 | struct listnode *i, *j, *k; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 887 | 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], |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 896 | VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 897 | return CMD_SUCCESS; |
| 898 | } |
| 899 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 900 | 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 905 | return CMD_SUCCESS; |
| 906 | } |
| 907 | |
| 908 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 909 | ospf6_neighbor_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 910 | { |
| 911 | install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 912 | install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_detail_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 913 | install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 914 | install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_detail_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 915 | } |
| 916 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 917 | DEFUN (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 | |
| 940 | ALIAS (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 Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 948 | ) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 949 | |
| 950 | DEFUN (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 | |
| 974 | ALIAS (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 Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 983 | ) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 984 | |
| 985 | int |
| 986 | config_write_ospf6_debug_neighbor (struct vty *vty) |
| 987 | { |
| 988 | if (IS_OSPF6_DEBUG_NEIGHBOR (STATE) && |
| 989 | IS_OSPF6_DEBUG_NEIGHBOR (EVENT)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 990 | vty_out (vty, "debug ospf6 neighbor%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 991 | else if (IS_OSPF6_DEBUG_NEIGHBOR (STATE)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 992 | vty_out (vty, "debug ospf6 neighbor state%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 993 | else if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 994 | vty_out (vty, "debug ospf6 neighbor event%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 995 | return 0; |
| 996 | } |
| 997 | |
| 998 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 999 | install_element_ospf6_debug_neighbor (void) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1000 | { |
| 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1012 | |