paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 1999 Yasuhiro Ohara |
| 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 | |
| 22 | #include "ospf6d.h" |
| 23 | |
| 24 | #include <zebra.h> |
| 25 | |
| 26 | #include "log.h" |
| 27 | #include "thread.h" |
| 28 | #include "linklist.h" |
| 29 | #include "vty.h" |
| 30 | #include "command.h" |
| 31 | |
| 32 | #include "ospf6_lsa.h" |
| 33 | #include "ospf6_message.h" |
| 34 | #include "ospf6_neighbor.h" |
| 35 | #include "ospf6_nsm.h" |
| 36 | #include "ospf6_lsa.h" |
| 37 | #include "ospf6_lsdb.h" |
| 38 | |
| 39 | char *ospf6_neighbor_state_string[] = |
| 40 | { |
| 41 | "None", "Down", "Attempt", "Init", "Twoway", |
| 42 | "ExStart", "ExChange", "Loading", "Full", NULL |
| 43 | }; |
| 44 | |
| 45 | int |
| 46 | ospf6_neighbor_last_dbdesc_release (struct thread *thread) |
| 47 | { |
| 48 | struct ospf6_neighbor *o6n; |
| 49 | |
| 50 | o6n = (struct ospf6_neighbor *) THREAD_ARG (thread); |
| 51 | assert (o6n); |
| 52 | memset (&o6n->last_dd, 0, sizeof (struct ospf6_dbdesc)); |
| 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | |
| 57 | |
| 58 | void |
| 59 | ospf6_neighbor_thread_cancel_all (struct ospf6_neighbor *o6n) |
| 60 | { |
| 61 | if (o6n->inactivity_timer) |
| 62 | thread_cancel (o6n->inactivity_timer); |
| 63 | o6n->inactivity_timer = (struct thread *) NULL; |
| 64 | |
| 65 | if (o6n->send_update) |
| 66 | thread_cancel (o6n->send_update); |
| 67 | o6n->send_update = (struct thread *) NULL; |
| 68 | |
| 69 | if (o6n->thread_send_dbdesc) |
| 70 | thread_cancel (o6n->thread_send_dbdesc); |
| 71 | o6n->thread_send_dbdesc = (struct thread *) NULL; |
| 72 | if (o6n->thread_rxmt_dbdesc) |
| 73 | thread_cancel (o6n->thread_rxmt_dbdesc); |
| 74 | o6n->thread_rxmt_dbdesc = (struct thread *) NULL; |
| 75 | |
| 76 | if (o6n->thread_rxmt_lsreq) |
| 77 | thread_cancel (o6n->thread_rxmt_lsreq); |
| 78 | o6n->thread_rxmt_lsreq = (struct thread *) NULL; |
| 79 | } |
| 80 | |
| 81 | void |
| 82 | ospf6_neighbor_lslist_clear (struct ospf6_neighbor *nei) |
| 83 | { |
| 84 | ospf6_lsdb_remove_all (nei->summary_list); |
| 85 | ospf6_lsdb_remove_all (nei->request_list); |
| 86 | ospf6_lsdb_remove_all (nei->retrans_list); |
| 87 | ospf6_lsdb_remove_all (nei->dbdesc_list); |
| 88 | } |
| 89 | |
| 90 | void |
| 91 | ospf6_neighbor_summary_add (struct ospf6_lsa *lsa, |
| 92 | struct ospf6_neighbor *nei) |
| 93 | { |
| 94 | struct ospf6_lsa *summary; |
| 95 | |
| 96 | if (IS_OSPF6_DUMP_NEIGHBOR) |
| 97 | { |
| 98 | zlog_info ("Neighbor %s summary-list:", nei->str); |
| 99 | zlog_info (" Add %s", lsa->str); |
| 100 | } |
| 101 | |
| 102 | ospf6_lsa_age_current (lsa); |
| 103 | summary = ospf6_lsa_summary_create (lsa->header); |
| 104 | ospf6_lsdb_add (summary, nei->summary_list); |
| 105 | } |
| 106 | |
| 107 | void |
| 108 | ospf6_neighbor_summary_remove (struct ospf6_lsa *lsa, |
| 109 | struct ospf6_neighbor *nei) |
| 110 | { |
| 111 | struct ospf6_lsa *summary; |
| 112 | |
| 113 | if (IS_OSPF6_DUMP_NEIGHBOR) |
| 114 | { |
| 115 | zlog_info ("Neighbor %s summary-list:", nei->str); |
| 116 | zlog_info (" Remove %s", lsa->str); |
| 117 | } |
| 118 | |
| 119 | summary = ospf6_lsdb_lookup_lsdb (lsa->header->type, lsa->header->id, |
| 120 | lsa->header->adv_router, nei->summary_list); |
| 121 | ospf6_lsdb_remove (summary, nei->summary_list); |
| 122 | } |
| 123 | |
| 124 | void |
| 125 | ospf6_neighbor_request_add (struct ospf6_lsa *lsa, |
| 126 | struct ospf6_neighbor *nei) |
| 127 | { |
| 128 | struct ospf6_lsa *summary; |
| 129 | |
| 130 | if (IS_OSPF6_DUMP_NEIGHBOR) |
| 131 | { |
| 132 | zlog_info ("Neighbor %s request-list:", nei->str); |
| 133 | zlog_info (" Add %s", lsa->str); |
| 134 | } |
| 135 | |
| 136 | ospf6_lsa_age_current (lsa); |
| 137 | summary = ospf6_lsa_summary_create (lsa->header); |
| 138 | ospf6_lsdb_add (summary, nei->request_list); |
| 139 | } |
| 140 | |
| 141 | void |
| 142 | ospf6_neighbor_request_remove (struct ospf6_lsa *lsa, |
| 143 | struct ospf6_neighbor *nei) |
| 144 | { |
| 145 | struct ospf6_lsa *summary; |
| 146 | |
| 147 | if (IS_OSPF6_DUMP_NEIGHBOR) |
| 148 | { |
| 149 | zlog_info ("Neighbor %s request-list:", nei->str); |
| 150 | zlog_info (" Remove %s", lsa->str); |
| 151 | } |
| 152 | |
| 153 | summary = ospf6_lsdb_lookup_lsdb (lsa->header->type, lsa->header->id, |
| 154 | lsa->header->adv_router, nei->request_list); |
| 155 | ospf6_lsdb_remove (summary, nei->request_list); |
| 156 | } |
| 157 | |
| 158 | void |
| 159 | ospf6_neighbor_retrans_add (struct ospf6_lsa *lsa, |
| 160 | struct ospf6_neighbor *nei) |
| 161 | { |
| 162 | if (IS_OSPF6_DUMP_NEIGHBOR) |
| 163 | { |
| 164 | zlog_info ("Neighbor %s retrans-list:", nei->str); |
| 165 | zlog_info (" Add %s", lsa->str); |
| 166 | } |
| 167 | |
| 168 | ospf6_lsdb_add (lsa, nei->retrans_list); |
| 169 | } |
| 170 | |
| 171 | void |
| 172 | ospf6_neighbor_retrans_remove (struct ospf6_lsa *lsa, |
| 173 | struct ospf6_neighbor *nei) |
| 174 | { |
| 175 | if (IS_OSPF6_DUMP_NEIGHBOR) |
| 176 | { |
| 177 | zlog_info ("Neighbor %s retrans-list:", nei->str); |
| 178 | zlog_info (" Remove %s", lsa->str); |
| 179 | } |
| 180 | |
| 181 | ospf6_lsdb_remove (lsa, nei->retrans_list); |
| 182 | |
| 183 | if (nei->retrans_list->count == 0) |
| 184 | { |
| 185 | if (nei->send_update) |
| 186 | thread_cancel (nei->send_update); |
| 187 | nei->send_update = NULL; |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | void |
| 192 | ospf6_neighbor_dbdesc_add (struct ospf6_lsa *lsa, |
| 193 | struct ospf6_neighbor *nei) |
| 194 | { |
| 195 | if (IS_OSPF6_DUMP_NEIGHBOR) |
| 196 | { |
| 197 | zlog_info ("Neighbor %s dbdesc-list:", nei->str); |
| 198 | zlog_info (" Add %s", lsa->str); |
| 199 | } |
| 200 | |
| 201 | ospf6_lsdb_add (lsa, nei->dbdesc_list); |
| 202 | } |
| 203 | |
| 204 | void |
| 205 | ospf6_neighbor_dbdesc_remove (struct ospf6_lsa *lsa, |
| 206 | struct ospf6_neighbor *nei) |
| 207 | { |
| 208 | if (IS_OSPF6_DUMP_NEIGHBOR) |
| 209 | { |
| 210 | zlog_info ("Neighbor %s dbdesc-list:", nei->str); |
| 211 | zlog_info (" Remove %s", lsa->str); |
| 212 | } |
| 213 | |
| 214 | ospf6_lsdb_remove (lsa, nei->dbdesc_list); |
| 215 | } |
| 216 | |
| 217 | |
| 218 | /* prepare summary-list of his neighbor structure */ |
| 219 | void |
| 220 | ospf6_neighbor_dbex_init (struct ospf6_neighbor *nei) |
| 221 | { |
| 222 | struct ospf6_lsdb_node node; |
| 223 | |
| 224 | /* clear ls-list */ |
| 225 | ospf6_neighbor_lslist_clear (nei); |
| 226 | |
| 227 | /* AS scope LSAs */ |
| 228 | for (ospf6_lsdb_head (&node, nei->ospf6_interface->area->ospf6->lsdb); |
| 229 | ! ospf6_lsdb_is_end (&node); ospf6_lsdb_next (&node)) |
| 230 | { |
| 231 | if (IS_LSA_MAXAGE (node.lsa)) |
| 232 | ospf6_neighbor_retrans_add (node.lsa, nei); |
| 233 | else |
| 234 | ospf6_neighbor_summary_add (node.lsa, nei); |
| 235 | } |
| 236 | |
| 237 | /* AREA scope LSAs */ |
| 238 | for (ospf6_lsdb_head (&node, nei->ospf6_interface->area->lsdb); |
| 239 | ! ospf6_lsdb_is_end (&node); ospf6_lsdb_next (&node)) |
| 240 | { |
| 241 | if (IS_LSA_MAXAGE (node.lsa)) |
| 242 | ospf6_neighbor_retrans_add (node.lsa, nei); |
| 243 | else |
| 244 | ospf6_neighbor_summary_add (node.lsa, nei); |
| 245 | } |
| 246 | |
| 247 | /* INTERFACE scope LSAs */ |
| 248 | for (ospf6_lsdb_head (&node, nei->ospf6_interface->lsdb); |
| 249 | ! ospf6_lsdb_is_end (&node); ospf6_lsdb_next (&node)) |
| 250 | { |
| 251 | if (IS_LSA_MAXAGE (node.lsa)) |
| 252 | ospf6_neighbor_retrans_add (node.lsa, nei); |
| 253 | else |
| 254 | ospf6_neighbor_summary_add (node.lsa, nei); |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | /* create ospf6_neighbor */ |
| 259 | struct ospf6_neighbor * |
| 260 | ospf6_neighbor_create (u_int32_t router_id, struct ospf6_interface *o6i) |
| 261 | { |
| 262 | struct ospf6_neighbor *new; |
| 263 | char buf[32]; |
| 264 | |
| 265 | new = (struct ospf6_neighbor *) |
| 266 | XMALLOC (MTYPE_OSPF6_NEIGHBOR, sizeof (struct ospf6_neighbor)); |
| 267 | if (new == NULL) |
| 268 | { |
| 269 | zlog_warn ("neighbor: malloc failed"); |
| 270 | return NULL; |
| 271 | } |
| 272 | |
| 273 | memset (new, 0, sizeof (struct ospf6_neighbor)); |
| 274 | |
| 275 | new->state = OSPF6_NEIGHBOR_STATE_DOWN; |
| 276 | |
| 277 | new->router_id = router_id; |
| 278 | inet_ntop (AF_INET, &router_id, buf, sizeof (buf)); |
| 279 | snprintf (new->str, sizeof (new->str), "%s%%%s", buf, o6i->interface->name); |
| 280 | new->inactivity_timer = (struct thread *) NULL; |
| 281 | |
| 282 | new->summary_list = ospf6_lsdb_create (); |
| 283 | new->request_list = ospf6_lsdb_create (); |
| 284 | new->retrans_list = ospf6_lsdb_create (); |
| 285 | new->dbdesc_list = ospf6_lsdb_create (); |
| 286 | |
| 287 | listnode_add (o6i->neighbor_list, new); |
| 288 | new->ospf6_interface = o6i; |
| 289 | |
| 290 | CALL_ADD_HOOK (&neighbor_hook, new); |
| 291 | |
| 292 | return new; |
| 293 | } |
| 294 | |
| 295 | void |
| 296 | ospf6_neighbor_delete (struct ospf6_neighbor *o6n) |
| 297 | { |
| 298 | CALL_REMOVE_HOOK (&neighbor_hook, o6n); |
| 299 | |
| 300 | ospf6_neighbor_thread_cancel_all (o6n); |
| 301 | ospf6_neighbor_lslist_clear (o6n); |
| 302 | |
| 303 | list_free (o6n->dbdesc_lsa); |
| 304 | |
| 305 | ospf6_lsdb_delete (o6n->summary_list); |
| 306 | ospf6_lsdb_delete (o6n->request_list); |
| 307 | ospf6_lsdb_delete (o6n->retrans_list); |
| 308 | ospf6_lsdb_delete (o6n->dbdesc_list); |
| 309 | |
| 310 | XFREE (MTYPE_OSPF6_NEIGHBOR, o6n); |
| 311 | } |
| 312 | |
| 313 | struct ospf6_neighbor * |
| 314 | ospf6_neighbor_lookup (u_int32_t router_id, |
| 315 | struct ospf6_interface *o6i) |
| 316 | { |
| 317 | listnode n; |
| 318 | struct ospf6_neighbor *o6n; |
| 319 | |
| 320 | for (n = listhead (o6i->neighbor_list); n; nextnode (n)) |
| 321 | { |
| 322 | o6n = (struct ospf6_neighbor *) getdata (n); |
| 323 | if (o6n->router_id == router_id) |
| 324 | return o6n; |
| 325 | } |
| 326 | return (struct ospf6_neighbor *) NULL; |
| 327 | } |
| 328 | |
| 329 | |
| 330 | /* vty functions */ |
| 331 | /* show neighbor structure */ |
| 332 | void |
| 333 | ospf6_neighbor_show_summary (struct vty *vty, struct ospf6_neighbor *o6n) |
| 334 | { |
| 335 | char router_id[16]; |
| 336 | char dr[16], bdr[16]; |
| 337 | char duration[16]; |
| 338 | struct timeval now, res; |
| 339 | |
| 340 | /* |
| 341 | vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s", |
| 342 | "RouterID", "State", "Duration", "DR", "BDR", "I/F", |
| 343 | "State", VTY_NEWLINE); |
| 344 | */ |
| 345 | |
| 346 | inet_ntop (AF_INET, &o6n->router_id, router_id, sizeof (router_id)); |
| 347 | inet_ntop (AF_INET, &o6n->dr, dr, sizeof (dr)); |
| 348 | inet_ntop (AF_INET, &o6n->bdr, bdr, sizeof (bdr)); |
| 349 | |
| 350 | gettimeofday (&now, NULL); |
| 351 | ospf6_timeval_sub (&now, &o6n->last_changed, &res); |
| 352 | ospf6_timeval_string_summary (&res, duration, sizeof (duration)); |
| 353 | |
| 354 | vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s", |
| 355 | router_id, ospf6_neighbor_state_string[o6n->state], |
| 356 | duration, dr, bdr, o6n->ospf6_interface->interface->name, |
| 357 | ospf6_interface_state_string[o6n->ospf6_interface->state], |
| 358 | VTY_NEWLINE); |
| 359 | } |
| 360 | |
| 361 | void |
| 362 | ospf6_neighbor_show (struct vty *vty, struct ospf6_neighbor *o6n) |
| 363 | { |
| 364 | char hisaddr[64], timestring[32]; |
| 365 | struct timeval now, res; |
| 366 | |
| 367 | inet_ntop (AF_INET6, &o6n->hisaddr, hisaddr, sizeof (hisaddr)); |
| 368 | vty_out (vty, " Neighbor %s, interface address %s%s", |
| 369 | o6n->str, hisaddr, VTY_NEWLINE); |
| 370 | vty_out (vty, " Area %s via interface %s (ifindex %d)%s", |
| 371 | o6n->ospf6_interface->area->str, |
| 372 | o6n->ospf6_interface->interface->name, |
| 373 | o6n->ospf6_interface->interface->ifindex, |
| 374 | VTY_NEWLINE); |
| 375 | vty_out (vty, " Priority: %d, State: %s, %d state changes%s", |
| 376 | o6n->priority, ospf6_neighbor_state_string[o6n->state], |
| 377 | o6n->ospf6_stat_state_changed, VTY_NEWLINE); |
| 378 | |
| 379 | gettimeofday (&now, NULL); |
| 380 | ospf6_timeval_sub (&now, &o6n->last_changed, &res); |
| 381 | ospf6_timeval_string_summary (&res, timestring, sizeof (timestring)); |
| 382 | vty_out (vty, " Last state changed: %s ago%s", timestring, VTY_NEWLINE); |
| 383 | } |
| 384 | |
| 385 | void |
| 386 | ospf6_neighbor_show_detail (struct vty *vty, struct ospf6_neighbor *o6n) |
| 387 | { |
| 388 | char hisdr[16], hisbdr[16]; |
| 389 | |
| 390 | ospf6_neighbor_show (vty, o6n); |
| 391 | |
| 392 | inet_ntop (AF_INET, &o6n->dr, hisdr, sizeof (hisdr)); |
| 393 | inet_ntop (AF_INET, &o6n->bdr, hisbdr, sizeof (hisbdr)); |
| 394 | |
| 395 | vty_out (vty, " His Ifindex of myside: %d%s", |
| 396 | o6n->ifid, VTY_NEWLINE); |
| 397 | vty_out (vty, " His DR Election: DR %s, BDR %s%s", |
| 398 | hisdr, hisbdr, VTY_NEWLINE); |
| 399 | |
| 400 | vty_out (vty, " Last received DbDesc: opt:%s" |
| 401 | " ifmtu:%hu bit:%s%s%s seqnum:%ld%s", |
| 402 | "xxx", ntohs (o6n->last_dd.ifmtu), |
| 403 | (DD_IS_IBIT_SET (o6n->last_dd.bits) ? "I" : "-"), |
| 404 | (DD_IS_MBIT_SET (o6n->last_dd.bits) ? "M" : "-"), |
| 405 | (DD_IS_MSBIT_SET (o6n->last_dd.bits) ? "m" : "s"), |
| 406 | (u_long)ntohl (o6n->last_dd.seqnum), VTY_NEWLINE); |
| 407 | vty_out (vty, " My DbDesc bit for this neighbor: %s%s%s%s", |
| 408 | (DD_IS_IBIT_SET (o6n->dbdesc_bits) ? "I" : "-"), |
| 409 | (DD_IS_MBIT_SET (o6n->dbdesc_bits) ? "M" : "-"), |
| 410 | (DD_IS_MSBIT_SET (o6n->dbdesc_bits) ? "m" : "s"), |
| 411 | VTY_NEWLINE); |
| 412 | |
| 413 | vty_out (vty, " %-16s %5d times, %-16s %5d times%s", |
| 414 | "SeqnumMismatch", o6n->ospf6_stat_seqnum_mismatch, |
| 415 | "BadLSReq", o6n->ospf6_stat_bad_lsreq, VTY_NEWLINE); |
| 416 | vty_out (vty, " %-16s %5d times, %-16s %5d times%s", |
| 417 | "OnewayReceived", o6n->ospf6_stat_oneway_received, |
| 418 | "InactivityTimer", o6n->ospf6_stat_inactivity_timer, |
| 419 | VTY_NEWLINE); |
| 420 | vty_out (vty, " %-16s %5d times, %-16s %5d times%s", |
| 421 | "DbDescRetrans", o6n->ospf6_stat_retrans_dbdesc, |
| 422 | "LSReqRetrans", o6n->ospf6_stat_retrans_lsreq, |
| 423 | VTY_NEWLINE); |
| 424 | vty_out (vty, " %-16s %5d times%s", |
| 425 | "LSUpdateRetrans", o6n->ospf6_stat_retrans_lsupdate, |
| 426 | VTY_NEWLINE); |
| 427 | vty_out (vty, " %-16s %5d times, %-16s %5d times%s", |
| 428 | "LSAReceived", o6n->ospf6_stat_received_lsa, |
| 429 | "LSUpdateReceived", o6n->ospf6_stat_received_lsupdate, |
| 430 | VTY_NEWLINE); |
| 431 | |
| 432 | vty_out (vty, " %-12s %-12s %-12s%s", |
| 433 | "Message", "DbDesc", "LSReq", VTY_NEWLINE); |
| 434 | vty_out (vty, " %-12s %12d %12d%s", "LSA Send", |
| 435 | o6n->lsa_send[OSPF6_MESSAGE_TYPE_DBDESC], |
| 436 | o6n->lsa_send[OSPF6_MESSAGE_TYPE_LSREQ], VTY_NEWLINE); |
| 437 | vty_out (vty, " %-12s %12d %12d%s", "LSA Receive", |
| 438 | o6n->lsa_receive[OSPF6_MESSAGE_TYPE_DBDESC], |
| 439 | o6n->lsa_receive[OSPF6_MESSAGE_TYPE_LSREQ], VTY_NEWLINE); |
| 440 | vty_out (vty, "%s", VTY_NEWLINE); |
| 441 | } |
| 442 | |
| 443 | void |
| 444 | ospf6_neighbor_timestamp_hello (struct ospf6_neighbor *o6n) |
| 445 | { |
| 446 | struct timeval now, interval; |
| 447 | gettimeofday (&now, (struct timezone *) NULL); |
| 448 | if (o6n->tv_last_hello_received.tv_sec) |
| 449 | { |
| 450 | ospf6_timeval_sub (&now, &o6n->tv_last_hello_received, &interval); |
| 451 | zlog_info ("Hello Interval %s : %ld msec", |
| 452 | o6n->str, interval.tv_sec * 1000 + interval.tv_usec % 1000); |
| 453 | } |
| 454 | o6n->tv_last_hello_received.tv_sec = now.tv_sec; |
| 455 | o6n->tv_last_hello_received.tv_usec = now.tv_usec; |
| 456 | } |
| 457 | |
| 458 | DEFUN (show_ipv6_ospf6_neighbor_routerid, |
| 459 | show_ipv6_ospf6_neighbor_routerid_cmd, |
| 460 | "show ipv6 ospf6 neighbor A.B.C.D", |
| 461 | SHOW_STR |
| 462 | IP6_STR |
| 463 | OSPF6_STR |
| 464 | "Neighbor list\n" |
| 465 | "OSPF6 neighbor Router ID in IP address format\n" |
| 466 | ) |
| 467 | { |
| 468 | u_int32_t router_id; |
| 469 | struct ospf6_neighbor *o6n; |
| 470 | struct ospf6_interface *o6i; |
| 471 | struct ospf6_area *o6a; |
| 472 | listnode nodei, nodej, nodek; |
| 473 | |
| 474 | OSPF6_CMD_CHECK_RUNNING (); |
| 475 | |
| 476 | if (argc == 0) |
| 477 | vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s", |
| 478 | "RouterID", "State", "Duration", "DR", "BDR", "I/F", |
| 479 | "State", VTY_NEWLINE); |
| 480 | else if (inet_pton (AF_INET, argv[0], &router_id) != 1) |
| 481 | { |
| 482 | vty_out (vty, "Malformed Router-ID: %s%s", argv[0], VTY_NEWLINE); |
| 483 | return CMD_SUCCESS; |
| 484 | } |
| 485 | |
| 486 | for (nodei = listhead (ospf6->area_list); nodei; nextnode (nodei)) |
| 487 | { |
| 488 | o6a = getdata (nodei); |
| 489 | for (nodej = listhead (o6a->if_list); nodej; nextnode (nodej)) |
| 490 | { |
| 491 | o6i = getdata (nodej); |
| 492 | for (nodek = listhead (o6i->neighbor_list); nodek; nextnode (nodek)) |
| 493 | { |
| 494 | o6n = getdata (nodek); |
| 495 | if (argc == 0) |
| 496 | ospf6_neighbor_show_summary (vty, o6n); |
| 497 | else if (o6n->router_id == router_id) |
| 498 | ospf6_neighbor_show_detail (vty, o6n); |
| 499 | } |
| 500 | } |
| 501 | } |
| 502 | return CMD_SUCCESS; |
| 503 | } |
| 504 | |
| 505 | ALIAS (show_ipv6_ospf6_neighbor_routerid, |
| 506 | show_ipv6_ospf6_neighbor_cmd, |
| 507 | "show ipv6 ospf6 neighbor", |
| 508 | SHOW_STR |
| 509 | IP6_STR |
| 510 | OSPF6_STR |
| 511 | "Neighbor list\n" |
| 512 | ) |
| 513 | |
| 514 | DEFUN (show_ipv6_ospf6_neighborlist, |
| 515 | show_ipv6_ospf6_neighborlist_cmd, |
| 516 | "show ipv6 ospf6 (summary-list|request-list|retrans-list|dbdesc-list)", |
| 517 | SHOW_STR |
| 518 | IP6_STR |
| 519 | OSPF6_STR |
| 520 | "Link State summary list\n" |
| 521 | "Link State request list\n" |
| 522 | "Link State retransmission list\n" |
| 523 | "Link State Description list (Used to retrans DbDesc)\n" |
| 524 | ) |
| 525 | { |
| 526 | struct ospf6_area *o6a; |
| 527 | struct ospf6_interface *o6i; |
| 528 | struct ospf6_neighbor *o6n; |
| 529 | listnode i, j, k, l; |
| 530 | struct ospf6_lsa *lsa; |
| 531 | struct ospf6_lsdb *lsdb = NULL; |
| 532 | char type[16], id[16], adv_router[16]; |
| 533 | struct ospf6_lsdb_node node; |
| 534 | u_int16_t age, cksum, len; |
| 535 | u_int32_t seqnum; |
| 536 | |
| 537 | OSPF6_CMD_CHECK_RUNNING (); |
| 538 | i = j = k = l = NULL; |
| 539 | |
| 540 | for (i = listhead (ospf6->area_list); i; nextnode (i)) |
| 541 | { |
| 542 | o6a = (struct ospf6_area *) getdata (i); |
| 543 | for (j = listhead (o6a->if_list); j; nextnode (j)) |
| 544 | { |
| 545 | o6i = (struct ospf6_interface *) getdata (j); |
| 546 | for (k = listhead (o6i->neighbor_list); k; nextnode (k)) |
| 547 | { |
| 548 | o6n = (struct ospf6_neighbor *) getdata (k); |
| 549 | |
| 550 | if (strncmp (argv[0], "sum", 3) == 0) |
| 551 | lsdb = o6n->summary_list; |
| 552 | else if (strncmp (argv[0], "req", 3) == 0) |
| 553 | lsdb = o6n->request_list; |
| 554 | else if (strncmp (argv[0], "ret", 3) == 0) |
| 555 | lsdb = o6n->retrans_list; |
| 556 | else if (strncmp (argv[0], "dbd", 3) == 0) |
| 557 | lsdb = o6n->dbdesc_list; |
| 558 | |
| 559 | vty_out (vty, "neighbor %s on interface %s: %d%s", o6n->str, |
| 560 | o6i->interface->name, lsdb->count, |
| 561 | VTY_NEWLINE); |
| 562 | for (ospf6_lsdb_head (&node, lsdb); ! ospf6_lsdb_is_end (&node); |
| 563 | ospf6_lsdb_next (&node)) |
| 564 | { |
| 565 | lsa = node.lsa; |
| 566 | ospf6_lsa_age_current (lsa); |
| 567 | |
| 568 | ospf6_lsa_type_string (lsa->header->type, type, |
| 569 | sizeof (type)); |
| 570 | inet_ntop (AF_INET, &lsa->header->id, id, sizeof (id)); |
| 571 | inet_ntop (AF_INET, &lsa->header->adv_router, adv_router, |
| 572 | sizeof (adv_router)); |
| 573 | age = ntohs (lsa->header->age); |
| 574 | seqnum = ntohl (lsa->header->seqnum); |
| 575 | cksum = ntohs (lsa->header->checksum); |
| 576 | len = ntohs (lsa->header->length); |
| 577 | |
| 578 | vty_out (vty, " %s-LSA ID=%s Adv=%s%s", |
| 579 | type, id, adv_router, VTY_NEWLINE); |
| 580 | vty_out (vty, " Age: %hu SeqNum: %#x Cksum: %hx Len: %hu%s", |
| 581 | age, seqnum, cksum, len, VTY_NEWLINE); |
| 582 | } |
| 583 | } |
| 584 | } |
| 585 | } |
| 586 | |
| 587 | return CMD_SUCCESS; |
| 588 | } |
| 589 | |
| 590 | void |
| 591 | ospf6_neighbor_init () |
| 592 | { |
| 593 | install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_cmd); |
| 594 | install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_routerid_cmd); |
| 595 | install_element (VIEW_NODE, &show_ipv6_ospf6_neighborlist_cmd); |
| 596 | |
| 597 | install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_cmd); |
| 598 | install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_routerid_cmd); |
| 599 | install_element (ENABLE_NODE, &show_ipv6_ospf6_neighborlist_cmd); |
| 600 | } |
| 601 | |
| 602 | |