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