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