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