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