1 /*
2  * Copyright (C) 2003 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 <zebra.h>
23 
24 #include "thread.h"
25 #include "linklist.h"
26 #include "vty.h"
27 #include "command.h"
28 
29 #include "ospf6_proto.h"
30 #include "ospf6_network.h"
31 #include "ospf6_lsa.h"
32 #include "ospf6_lsdb.h"
33 #include "ospf6_message.h"
34 #include "ospf6_route.h"
35 #include "ospf6_zebra.h"
36 #include "ospf6_spf.h"
37 #include "ospf6_top.h"
38 #include "ospf6_area.h"
39 #include "ospf6_interface.h"
40 #include "ospf6_neighbor.h"
41 #include "ospf6_intra.h"
42 #include "ospf6_asbr.h"
43 #include "ospf6_abr.h"
44 #include "ospf6_flood.h"
45 #include "ospf6d.h"
46 
47 #ifdef HAVE_SNMP
48 #include "ospf6_snmp.h"
49 #endif /*HAVE_SNMP*/
50 
51 char ospf6_daemon_version[] = OSPF6_DAEMON_VERSION;
52 
53 struct route_node *
route_prev(struct route_node * node)54 route_prev (struct route_node *node)
55 {
56   struct route_node *end;
57   struct route_node *prev = NULL;
58 
59   end = node;
60   node = node->parent;
61   if (node)
62     route_lock_node (node);
63   while (node)
64     {
65       prev = node;
66       node = route_next (node);
67       if (node == end)
68         {
69           route_unlock_node (node);
70           node = NULL;
71         }
72     }
73   route_unlock_node (end);
74   if (prev)
75     route_lock_node (prev);
76 
77   return prev;
78 }
79 
80 
81 /* show database functions */
82 DEFUN (show_version_ospf6,
83        show_version_ospf6_cmd,
84        "show version ospf6",
85        SHOW_STR
86        "Displays ospf6d version\n"
87       )
88 {
89   vty_out (vty, "Zebra OSPF6d Version: %s%s",
90            ospf6_daemon_version, VNL);
91 
92   return CMD_SUCCESS;
93 }
94 
95 static struct cmd_node debug_node =
96 {
97   DEBUG_NODE,
98   "",
99   1 /* VTYSH */
100 };
101 
102 static int
config_write_ospf6_debug(struct vty * vty)103 config_write_ospf6_debug (struct vty *vty)
104 {
105   config_write_ospf6_debug_message (vty);
106   config_write_ospf6_debug_lsa (vty);
107   config_write_ospf6_debug_zebra (vty);
108   config_write_ospf6_debug_interface (vty);
109   config_write_ospf6_debug_neighbor (vty);
110   config_write_ospf6_debug_spf (vty);
111   config_write_ospf6_debug_route (vty);
112   config_write_ospf6_debug_brouter (vty);
113   config_write_ospf6_debug_asbr (vty);
114   config_write_ospf6_debug_abr (vty);
115   config_write_ospf6_debug_flood (vty);
116   vty_out (vty, "!%s", VNL);
117   return 0;
118 }
119 
120 #define AREA_LSDB_TITLE_FORMAT \
121   "%s        Area Scoped Link State Database (Area %s)%s%s"
122 #define IF_LSDB_TITLE_FORMAT \
123   "%s        I/F Scoped Link State Database (I/F %s in Area %s)%s%s"
124 #define AS_LSDB_TITLE_FORMAT \
125   "%s        AS Scoped Link State Database%s%s"
126 
127 static int
parse_show_level(int argc,const char * argv[])128 parse_show_level (int argc, const char *argv[])
129 {
130   int level = 0;
131   if (argc)
132     {
133       if (! strncmp (argv[0], "de", 2))
134         level = OSPF6_LSDB_SHOW_LEVEL_DETAIL;
135       else if (! strncmp (argv[0], "du", 2))
136         level = OSPF6_LSDB_SHOW_LEVEL_DUMP;
137       else if (! strncmp (argv[0], "in", 2))
138         level = OSPF6_LSDB_SHOW_LEVEL_INTERNAL;
139     }
140   else
141     level = OSPF6_LSDB_SHOW_LEVEL_NORMAL;
142   return level;
143 }
144 
145 static u_int16_t
parse_type_spec(int argc,const char * argv[])146 parse_type_spec (int argc, const char *argv[])
147 {
148   u_int16_t type = 0;
149   assert (argc);
150   if (! strcmp (argv[0], "router"))
151     type = htons (OSPF6_LSTYPE_ROUTER);
152   else if (! strcmp (argv[0], "network"))
153     type = htons (OSPF6_LSTYPE_NETWORK);
154   else if (! strcmp (argv[0], "as-external"))
155     type = htons (OSPF6_LSTYPE_AS_EXTERNAL);
156   else if (! strcmp (argv[0], "intra-prefix"))
157     type = htons (OSPF6_LSTYPE_INTRA_PREFIX);
158   else if (! strcmp (argv[0], "inter-router"))
159     type = htons (OSPF6_LSTYPE_INTER_ROUTER);
160   else if (! strcmp (argv[0], "inter-prefix"))
161     type = htons (OSPF6_LSTYPE_INTER_PREFIX);
162   else if (! strcmp (argv[0], "link"))
163     type = htons (OSPF6_LSTYPE_LINK);
164   return type;
165 }
166 
167 DEFUN (show_ipv6_ospf6_database,
168        show_ipv6_ospf6_database_cmd,
169        "show ipv6 ospf6 database",
170        SHOW_STR
171        IPV6_STR
172        OSPF6_STR
173        "Display Link state database\n"
174       )
175 {
176   int level;
177   struct listnode *i, *j;
178   struct ospf6 *o = ospf6;
179   struct ospf6_area *oa;
180   struct ospf6_interface *oi;
181 
182   OSPF6_CMD_CHECK_RUNNING ();
183 
184   level = parse_show_level (argc, argv);
185 
186   for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
187     {
188       vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
189       ospf6_lsdb_show (vty, level, NULL, NULL, NULL, oa->lsdb);
190     }
191 
192   for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
193     {
194       for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
195         {
196           vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
197                    oi->interface->name, oa->name, VNL, VNL);
198           ospf6_lsdb_show (vty, level, NULL, NULL, NULL, oi->lsdb);
199         }
200     }
201 
202   vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL);
203   ospf6_lsdb_show (vty, level, NULL, NULL, NULL, o->lsdb);
204 
205   vty_out (vty, "%s", VNL);
206   return CMD_SUCCESS;
207 }
208 
209 ALIAS (show_ipv6_ospf6_database,
210        show_ipv6_ospf6_database_detail_cmd,
211        "show ipv6 ospf6 database (detail|dump|internal)",
212        SHOW_STR
213        IPV6_STR
214        OSPF6_STR
215        "Display Link state database\n"
216        "Display details of LSAs\n"
217        "Dump LSAs\n"
218        "Display LSA's internal information\n"
219       )
220 
221 DEFUN (show_ipv6_ospf6_database_type,
222        show_ipv6_ospf6_database_type_cmd,
223        "show ipv6 ospf6 database "
224        "(router|network|inter-prefix|inter-router|as-external|"
225        "group-membership|type-7|link|intra-prefix)",
226        SHOW_STR
227        IPV6_STR
228        OSPF6_STR
229        "Display Link state database\n"
230        "Display Router LSAs\n"
231        "Display Network LSAs\n"
232        "Display Inter-Area-Prefix LSAs\n"
233        "Display Inter-Area-Router LSAs\n"
234        "Display As-External LSAs\n"
235        "Display Group-Membership LSAs\n"
236        "Display Type-7 LSAs\n"
237        "Display Link LSAs\n"
238        "Display Intra-Area-Prefix LSAs\n"
239       )
240 {
241   int level;
242   struct listnode *i, *j;
243   struct ospf6 *o = ospf6;
244   struct ospf6_area *oa;
245   struct ospf6_interface *oi;
246   u_int16_t type = 0;
247 
248   OSPF6_CMD_CHECK_RUNNING ();
249 
250   type = parse_type_spec (argc, argv);
251   argc--;
252   argv++;
253   level = parse_show_level (argc, argv);
254 
255   switch (OSPF6_LSA_SCOPE (type))
256     {
257       case OSPF6_SCOPE_AREA:
258         for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
259           {
260             vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
261             ospf6_lsdb_show (vty, level, &type, NULL, NULL, oa->lsdb);
262           }
263         break;
264 
265       case OSPF6_SCOPE_LINKLOCAL:
266         for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
267           {
268             for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
269               {
270                 vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
271                          oi->interface->name, oa->name, VNL, VNL);
272                 ospf6_lsdb_show (vty, level, &type, NULL, NULL, oi->lsdb);
273               }
274           }
275         break;
276 
277       case OSPF6_SCOPE_AS:
278         vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL);
279         ospf6_lsdb_show (vty, level, &type, NULL, NULL, o->lsdb);
280         break;
281 
282       default:
283         assert (0);
284         break;
285     }
286 
287   vty_out (vty, "%s", VNL);
288   return CMD_SUCCESS;
289 }
290 
291 ALIAS (show_ipv6_ospf6_database_type,
292        show_ipv6_ospf6_database_type_detail_cmd,
293        "show ipv6 ospf6 database "
294        "(router|network|inter-prefix|inter-router|as-external|"
295        "group-membership|type-7|link|intra-prefix) "
296        "(detail|dump|internal)",
297        SHOW_STR
298        IPV6_STR
299        OSPF6_STR
300        "Display Link state database\n"
301        "Display Router LSAs\n"
302        "Display Network LSAs\n"
303        "Display Inter-Area-Prefix LSAs\n"
304        "Display Inter-Area-Router LSAs\n"
305        "Display As-External LSAs\n"
306        "Display Group-Membership LSAs\n"
307        "Display Type-7 LSAs\n"
308        "Display Link LSAs\n"
309        "Display Intra-Area-Prefix LSAs\n"
310        "Display details of LSAs\n"
311        "Dump LSAs\n"
312        "Display LSA's internal information\n"
313       )
314 
315 DEFUN (show_ipv6_ospf6_database_id,
316        show_ipv6_ospf6_database_id_cmd,
317        "show ipv6 ospf6 database * A.B.C.D",
318        SHOW_STR
319        IPV6_STR
320        OSPF6_STR
321        "Display Link state database\n"
322        "Any Link state Type\n"
323        "Specify Link state ID as IPv4 address notation\n"
324       )
325 {
326   int level;
327   struct listnode *i, *j;
328   struct ospf6 *o = ospf6;
329   struct ospf6_area *oa;
330   struct ospf6_interface *oi;
331   u_int32_t id = 0;
332 
333   OSPF6_CMD_CHECK_RUNNING ();
334 
335   if ((inet_pton (AF_INET, argv[0], &id)) != 1)
336     {
337       vty_out (vty, "Link State ID is not parsable: %s%s",
338                argv[0], VNL);
339       return CMD_SUCCESS;
340     }
341 
342   argc--;
343   argv++;
344   level = parse_show_level (argc, argv);
345 
346   for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
347     {
348       vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
349       ospf6_lsdb_show (vty, level, NULL, &id, NULL, oa->lsdb);
350     }
351 
352   for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
353     {
354       for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
355         {
356           vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
357                    oi->interface->name, oa->name, VNL, VNL);
358           ospf6_lsdb_show (vty, level, NULL, &id, NULL, oi->lsdb);
359         }
360     }
361 
362   vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL);
363   ospf6_lsdb_show (vty, level, NULL, &id, NULL, o->lsdb);
364 
365   vty_out (vty, "%s", VNL);
366   return CMD_SUCCESS;
367 }
368 
369 ALIAS (show_ipv6_ospf6_database_id,
370        show_ipv6_ospf6_database_id_detail_cmd,
371        "show ipv6 ospf6 database * A.B.C.D "
372        "(detail|dump|internal)",
373        SHOW_STR
374        IPV6_STR
375        OSPF6_STR
376        "Display Link state database\n"
377        "Any Link state Type\n"
378        "Specify Link state ID as IPv4 address notation\n"
379        "Display details of LSAs\n"
380        "Dump LSAs\n"
381        "Display LSA's internal information\n"
382       )
383 
384 ALIAS (show_ipv6_ospf6_database_id,
385        show_ipv6_ospf6_database_linkstate_id_cmd,
386        "show ipv6 ospf6 database linkstate-id A.B.C.D",
387        SHOW_STR
388        IPV6_STR
389        OSPF6_STR
390        "Display Link state database\n"
391        "Search by Link state ID\n"
392        "Specify Link state ID as IPv4 address notation\n"
393       )
394 
395 ALIAS (show_ipv6_ospf6_database_id,
396        show_ipv6_ospf6_database_linkstate_id_detail_cmd,
397        "show ipv6 ospf6 database linkstate-id A.B.C.D "
398        "(detail|dump|internal)",
399        SHOW_STR
400        IPV6_STR
401        OSPF6_STR
402        "Display Link state database\n"
403        "Search by Link state ID\n"
404        "Specify Link state ID as IPv4 address notation\n"
405        "Display details of LSAs\n"
406        "Dump LSAs\n"
407        "Display LSA's internal information\n"
408       )
409 
410 DEFUN (show_ipv6_ospf6_database_router,
411        show_ipv6_ospf6_database_router_cmd,
412        "show ipv6 ospf6 database * * A.B.C.D",
413        SHOW_STR
414        IPV6_STR
415        OSPF6_STR
416        "Display Link state database\n"
417        "Any Link state Type\n"
418        "Any Link state ID\n"
419        "Specify Advertising Router as IPv4 address notation\n"
420       )
421 {
422   int level;
423   struct listnode *i, *j;
424   struct ospf6 *o = ospf6;
425   struct ospf6_area *oa;
426   struct ospf6_interface *oi;
427   u_int32_t adv_router = 0;
428 
429   OSPF6_CMD_CHECK_RUNNING ();
430 
431   if ((inet_pton (AF_INET, argv[0], &adv_router)) != 1)
432     {
433       vty_out (vty, "Advertising Router is not parsable: %s%s",
434                argv[0], VNL);
435       return CMD_SUCCESS;
436     }
437 
438   argc--;
439   argv++;
440   level = parse_show_level (argc, argv);
441 
442   for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
443     {
444       vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
445       ospf6_lsdb_show (vty, level, NULL, NULL, &adv_router, oa->lsdb);
446     }
447 
448   for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
449     {
450       for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
451         {
452           vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
453                    oi->interface->name, oa->name, VNL, VNL);
454           ospf6_lsdb_show (vty, level, NULL, NULL, &adv_router, oi->lsdb);
455         }
456     }
457 
458   vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL);
459   ospf6_lsdb_show (vty, level, NULL, NULL, &adv_router, o->lsdb);
460 
461   vty_out (vty, "%s", VNL);
462   return CMD_SUCCESS;
463 }
464 
465 ALIAS (show_ipv6_ospf6_database_router,
466        show_ipv6_ospf6_database_router_detail_cmd,
467        "show ipv6 ospf6 database * * A.B.C.D "
468        "(detail|dump|internal)",
469        SHOW_STR
470        IPV6_STR
471        OSPF6_STR
472        "Display Link state database\n"
473        "Any Link state Type\n"
474        "Any Link state ID\n"
475        "Specify Advertising Router as IPv4 address notation\n"
476        "Display details of LSAs\n"
477        "Dump LSAs\n"
478        "Display LSA's internal information\n"
479       )
480 
481 ALIAS (show_ipv6_ospf6_database_router,
482        show_ipv6_ospf6_database_adv_router_cmd,
483        "show ipv6 ospf6 database adv-router A.B.C.D",
484        SHOW_STR
485        IPV6_STR
486        OSPF6_STR
487        "Display Link state database\n"
488        "Search by Advertising Router\n"
489        "Specify Advertising Router as IPv4 address notation\n"
490       )
491 
492 ALIAS (show_ipv6_ospf6_database_router,
493        show_ipv6_ospf6_database_adv_router_detail_cmd,
494        "show ipv6 ospf6 database adv-router A.B.C.D "
495        "(detail|dump|internal)",
496        SHOW_STR
497        IPV6_STR
498        OSPF6_STR
499        "Display Link state database\n"
500        "Search by Advertising Router\n"
501        "Specify Advertising Router as IPv4 address notation\n"
502        "Display details of LSAs\n"
503        "Dump LSAs\n"
504        "Display LSA's internal information\n"
505       )
506 
507 DEFUN (show_ipv6_ospf6_database_type_id,
508        show_ipv6_ospf6_database_type_id_cmd,
509        "show ipv6 ospf6 database "
510        "(router|network|inter-prefix|inter-router|as-external|"
511        "group-membership|type-7|link|intra-prefix) A.B.C.D",
512        SHOW_STR
513        IPV6_STR
514        OSPF6_STR
515        "Display Link state database\n"
516        "Display Router LSAs\n"
517        "Display Network LSAs\n"
518        "Display Inter-Area-Prefix LSAs\n"
519        "Display Inter-Area-Router LSAs\n"
520        "Display As-External LSAs\n"
521        "Display Group-Membership LSAs\n"
522        "Display Type-7 LSAs\n"
523        "Display Link LSAs\n"
524        "Display Intra-Area-Prefix LSAs\n"
525        "Specify Link state ID as IPv4 address notation\n"
526       )
527 {
528   int level;
529   struct listnode *i, *j;
530   struct ospf6 *o = ospf6;
531   struct ospf6_area *oa;
532   struct ospf6_interface *oi;
533   u_int16_t type = 0;
534   u_int32_t id = 0;
535 
536   OSPF6_CMD_CHECK_RUNNING ();
537 
538   type = parse_type_spec (argc, argv);
539   argc--;
540   argv++;
541 
542   if ((inet_pton (AF_INET, argv[0], &id)) != 1)
543     {
544       vty_out (vty, "Link state ID is not parsable: %s%s",
545                argv[0], VNL);
546       return CMD_SUCCESS;
547     }
548 
549   argc--;
550   argv++;
551   level = parse_show_level (argc, argv);
552 
553   switch (OSPF6_LSA_SCOPE (type))
554     {
555       case OSPF6_SCOPE_AREA:
556         for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
557           {
558             vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
559             ospf6_lsdb_show (vty, level, &type, &id, NULL, oa->lsdb);
560           }
561         break;
562 
563       case OSPF6_SCOPE_LINKLOCAL:
564         for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
565           {
566             for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
567               {
568                 vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
569                          oi->interface->name, oa->name, VNL, VNL);
570                 ospf6_lsdb_show (vty, level, &type, &id, NULL, oi->lsdb);
571               }
572           }
573         break;
574 
575       case OSPF6_SCOPE_AS:
576         vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL);
577         ospf6_lsdb_show (vty, level, &type, &id, NULL, o->lsdb);
578         break;
579 
580       default:
581         assert (0);
582         break;
583     }
584 
585   vty_out (vty, "%s", VNL);
586   return CMD_SUCCESS;
587 }
588 
589 ALIAS (show_ipv6_ospf6_database_type_id,
590        show_ipv6_ospf6_database_type_id_detail_cmd,
591        "show ipv6 ospf6 database "
592        "(router|network|inter-prefix|inter-router|as-external|"
593        "group-membership|type-7|link|intra-prefix) A.B.C.D "
594        "(detail|dump|internal)",
595        SHOW_STR
596        IPV6_STR
597        OSPF6_STR
598        "Display Link state database\n"
599        "Display Router LSAs\n"
600        "Display Network LSAs\n"
601        "Display Inter-Area-Prefix LSAs\n"
602        "Display Inter-Area-Router LSAs\n"
603        "Display As-External LSAs\n"
604        "Display Group-Membership LSAs\n"
605        "Display Type-7 LSAs\n"
606        "Display Link LSAs\n"
607        "Display Intra-Area-Prefix LSAs\n"
608        "Specify Link state ID as IPv4 address notation\n"
609        "Display details of LSAs\n"
610        "Dump LSAs\n"
611        "Display LSA's internal information\n"
612       )
613 
614 ALIAS (show_ipv6_ospf6_database_type_id,
615        show_ipv6_ospf6_database_type_linkstate_id_cmd,
616        "show ipv6 ospf6 database "
617        "(router|network|inter-prefix|inter-router|as-external|"
618        "group-membership|type-7|link|intra-prefix) linkstate-id A.B.C.D",
619        SHOW_STR
620        IPV6_STR
621        OSPF6_STR
622        "Display Link state database\n"
623        "Display Router LSAs\n"
624        "Display Network LSAs\n"
625        "Display Inter-Area-Prefix LSAs\n"
626        "Display Inter-Area-Router LSAs\n"
627        "Display As-External LSAs\n"
628        "Display Group-Membership LSAs\n"
629        "Display Type-7 LSAs\n"
630        "Display Link LSAs\n"
631        "Display Intra-Area-Prefix LSAs\n"
632        "Search by Link state ID\n"
633        "Specify Link state ID as IPv4 address notation\n"
634       )
635 
636 ALIAS (show_ipv6_ospf6_database_type_id,
637        show_ipv6_ospf6_database_type_linkstate_id_detail_cmd,
638        "show ipv6 ospf6 database "
639        "(router|network|inter-prefix|inter-router|as-external|"
640        "group-membership|type-7|link|intra-prefix) linkstate-id A.B.C.D "
641        "(detail|dump|internal)",
642        SHOW_STR
643        IPV6_STR
644        OSPF6_STR
645        "Display Link state database\n"
646        "Display Router LSAs\n"
647        "Display Network LSAs\n"
648        "Display Inter-Area-Prefix LSAs\n"
649        "Display Inter-Area-Router LSAs\n"
650        "Display As-External LSAs\n"
651        "Display Group-Membership LSAs\n"
652        "Display Type-7 LSAs\n"
653        "Display Link LSAs\n"
654        "Display Intra-Area-Prefix LSAs\n"
655        "Search by Link state ID\n"
656        "Specify Link state ID as IPv4 address notation\n"
657        "Display details of LSAs\n"
658        "Dump LSAs\n"
659        "Display LSA's internal information\n"
660       )
661 
662 DEFUN (show_ipv6_ospf6_database_type_router,
663        show_ipv6_ospf6_database_type_router_cmd,
664        "show ipv6 ospf6 database "
665        "(router|network|inter-prefix|inter-router|as-external|"
666        "group-membership|type-7|link|intra-prefix) * A.B.C.D",
667        SHOW_STR
668        IPV6_STR
669        OSPF6_STR
670        "Display Link state database\n"
671        "Display Router LSAs\n"
672        "Display Network LSAs\n"
673        "Display Inter-Area-Prefix LSAs\n"
674        "Display Inter-Area-Router LSAs\n"
675        "Display As-External LSAs\n"
676        "Display Group-Membership LSAs\n"
677        "Display Type-7 LSAs\n"
678        "Display Link LSAs\n"
679        "Display Intra-Area-Prefix LSAs\n"
680        "Any Link state ID\n"
681        "Specify Advertising Router as IPv4 address notation\n"
682       )
683 {
684   int level;
685   struct listnode *i, *j;
686   struct ospf6 *o = ospf6;
687   struct ospf6_area *oa;
688   struct ospf6_interface *oi;
689   u_int16_t type = 0;
690   u_int32_t adv_router = 0;
691 
692   OSPF6_CMD_CHECK_RUNNING ();
693 
694   type = parse_type_spec (argc, argv);
695   argc--;
696   argv++;
697 
698   if ((inet_pton (AF_INET, argv[0], &adv_router)) != 1)
699     {
700       vty_out (vty, "Advertising Router is not parsable: %s%s",
701                argv[0], VNL);
702       return CMD_SUCCESS;
703     }
704 
705   argc--;
706   argv++;
707   level = parse_show_level (argc, argv);
708 
709   switch (OSPF6_LSA_SCOPE (type))
710     {
711       case OSPF6_SCOPE_AREA:
712         for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
713           {
714             vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
715             ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, oa->lsdb);
716           }
717         break;
718 
719       case OSPF6_SCOPE_LINKLOCAL:
720         for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
721           {
722             for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
723               {
724                 vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
725                          oi->interface->name, oa->name, VNL, VNL);
726                 ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, oi->lsdb);
727               }
728           }
729         break;
730 
731       case OSPF6_SCOPE_AS:
732         vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL);
733         ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, o->lsdb);
734         break;
735 
736       default:
737         assert (0);
738         break;
739     }
740 
741   vty_out (vty, "%s", VNL);
742   return CMD_SUCCESS;
743 }
744 
745 ALIAS (show_ipv6_ospf6_database_type_router,
746        show_ipv6_ospf6_database_type_router_detail_cmd,
747        "show ipv6 ospf6 database "
748        "(router|network|inter-prefix|inter-router|as-external|"
749        "group-membership|type-7|link|intra-prefix) * A.B.C.D "
750        "(detail|dump|internal)",
751        SHOW_STR
752        IPV6_STR
753        OSPF6_STR
754        "Display Link state database\n"
755        "Display Router LSAs\n"
756        "Display Network LSAs\n"
757        "Display Inter-Area-Prefix LSAs\n"
758        "Display Inter-Area-Router LSAs\n"
759        "Display As-External LSAs\n"
760        "Display Group-Membership LSAs\n"
761        "Display Type-7 LSAs\n"
762        "Display Link LSAs\n"
763        "Display Intra-Area-Prefix LSAs\n"
764        "Any Link state ID\n"
765        "Specify Advertising Router as IPv4 address notation\n"
766        "Display details of LSAs\n"
767        "Dump LSAs\n"
768        "Display LSA's internal information\n"
769       )
770 
771 ALIAS (show_ipv6_ospf6_database_type_router,
772        show_ipv6_ospf6_database_type_adv_router_cmd,
773        "show ipv6 ospf6 database "
774        "(router|network|inter-prefix|inter-router|as-external|"
775        "group-membership|type-7|link|intra-prefix) adv-router A.B.C.D",
776        SHOW_STR
777        IPV6_STR
778        OSPF6_STR
779        "Display Link state database\n"
780        "Display Router LSAs\n"
781        "Display Network LSAs\n"
782        "Display Inter-Area-Prefix LSAs\n"
783        "Display Inter-Area-Router LSAs\n"
784        "Display As-External LSAs\n"
785        "Display Group-Membership LSAs\n"
786        "Display Type-7 LSAs\n"
787        "Display Link LSAs\n"
788        "Display Intra-Area-Prefix LSAs\n"
789        "Search by Advertising Router\n"
790        "Specify Advertising Router as IPv4 address notation\n"
791       )
792 
793 ALIAS (show_ipv6_ospf6_database_type_router,
794        show_ipv6_ospf6_database_type_adv_router_detail_cmd,
795        "show ipv6 ospf6 database "
796        "(router|network|inter-prefix|inter-router|as-external|"
797        "group-membership|type-7|link|intra-prefix) adv-router A.B.C.D "
798        "(detail|dump|internal)",
799        SHOW_STR
800        IPV6_STR
801        OSPF6_STR
802        "Display Link state database\n"
803        "Display Router LSAs\n"
804        "Display Network LSAs\n"
805        "Display Inter-Area-Prefix LSAs\n"
806        "Display Inter-Area-Router LSAs\n"
807        "Display As-External LSAs\n"
808        "Display Group-Membership LSAs\n"
809        "Display Type-7 LSAs\n"
810        "Display Link LSAs\n"
811        "Display Intra-Area-Prefix LSAs\n"
812        "Search by Advertising Router\n"
813        "Specify Advertising Router as IPv4 address notation\n"
814        "Display details of LSAs\n"
815        "Dump LSAs\n"
816        "Display LSA's internal information\n"
817       )
818 
819 DEFUN (show_ipv6_ospf6_database_id_router,
820        show_ipv6_ospf6_database_id_router_cmd,
821        "show ipv6 ospf6 database * A.B.C.D A.B.C.D",
822        SHOW_STR
823        IPV6_STR
824        OSPF6_STR
825        "Display Link state database\n"
826        "Any Link state Type\n"
827        "Specify Link state ID as IPv4 address notation\n"
828        "Specify Advertising Router as IPv4 address notation\n"
829       )
830 {
831   int level;
832   struct listnode *i, *j;
833   struct ospf6 *o = ospf6;
834   struct ospf6_area *oa;
835   struct ospf6_interface *oi;
836   u_int32_t id = 0;
837   u_int32_t adv_router = 0;
838 
839   OSPF6_CMD_CHECK_RUNNING ();
840 
841   if ((inet_pton (AF_INET, argv[0], &id)) != 1)
842     {
843       vty_out (vty, "Link state ID is not parsable: %s%s",
844                argv[0], VNL);
845       return CMD_SUCCESS;
846     }
847 
848   argc--;
849   argv++;
850 
851   if ((inet_pton (AF_INET, argv[0], &adv_router)) != 1)
852     {
853       vty_out (vty, "Advertising Router is not parsable: %s%s",
854                argv[0], VNL);
855       return CMD_SUCCESS;
856     }
857 
858   argc--;
859   argv++;
860   level = parse_show_level (argc, argv);
861 
862   for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
863     {
864       vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
865       ospf6_lsdb_show (vty, level, NULL, &id, &adv_router, oa->lsdb);
866     }
867 
868   for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
869     {
870       for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
871         {
872           vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
873                    oi->interface->name, oa->name, VNL, VNL);
874           ospf6_lsdb_show (vty, level, NULL, &id, &adv_router, oi->lsdb);
875         }
876     }
877 
878   vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL);
879   ospf6_lsdb_show (vty, level, NULL, &id, &adv_router, o->lsdb);
880 
881   vty_out (vty, "%s", VNL);
882   return CMD_SUCCESS;
883 }
884 
885 ALIAS (show_ipv6_ospf6_database_id_router,
886        show_ipv6_ospf6_database_id_router_detail_cmd,
887        "show ipv6 ospf6 database * A.B.C.D A.B.C.D "
888        "(detail|dump|internal)",
889        SHOW_STR
890        IPV6_STR
891        OSPF6_STR
892        "Display Link state database\n"
893        "Any Link state Type\n"
894        "Specify Link state ID as IPv4 address notation\n"
895        "Specify Advertising Router as IPv4 address notation\n"
896        "Display details of LSAs\n"
897        "Dump LSAs\n"
898        "Display LSA's internal information\n"
899       )
900 
901 DEFUN (show_ipv6_ospf6_database_adv_router_linkstate_id,
902        show_ipv6_ospf6_database_adv_router_linkstate_id_cmd,
903        "show ipv6 ospf6 database adv-router A.B.C.D linkstate-id A.B.C.D",
904        SHOW_STR
905        IPV6_STR
906        OSPF6_STR
907        "Display Link state database\n"
908        "Search by Advertising Router\n"
909        "Specify Advertising Router as IPv4 address notation\n"
910        "Search by Link state ID\n"
911        "Specify Link state ID as IPv4 address notation\n"
912       )
913 {
914   int level;
915   struct listnode *i, *j;
916   struct ospf6 *o = ospf6;
917   struct ospf6_area *oa;
918   struct ospf6_interface *oi;
919   u_int32_t id = 0;
920   u_int32_t adv_router = 0;
921 
922   OSPF6_CMD_CHECK_RUNNING ();
923 
924   if ((inet_pton (AF_INET, argv[0], &adv_router)) != 1)
925     {
926       vty_out (vty, "Advertising Router is not parsable: %s%s",
927                argv[0], VNL);
928       return CMD_SUCCESS;
929     }
930 
931   argc--;
932   argv++;
933 
934   if ((inet_pton (AF_INET, argv[0], &id)) != 1)
935     {
936       vty_out (vty, "Link state ID is not parsable: %s%s",
937                argv[0], VNL);
938       return CMD_SUCCESS;
939     }
940 
941   argc--;
942   argv++;
943   level = parse_show_level (argc, argv);
944 
945   for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
946     {
947       vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
948       ospf6_lsdb_show (vty, level, NULL, &id, &adv_router, oa->lsdb);
949     }
950 
951   for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
952     {
953       for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
954         {
955           vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
956                    oi->interface->name, oa->name, VNL, VNL);
957           ospf6_lsdb_show (vty, level, NULL, &id, &adv_router, oi->lsdb);
958         }
959     }
960 
961   vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL);
962   ospf6_lsdb_show (vty, level, NULL, &id, &adv_router, o->lsdb);
963 
964   vty_out (vty, "%s", VNL);
965   return CMD_SUCCESS;
966 }
967 
968 ALIAS (show_ipv6_ospf6_database_adv_router_linkstate_id,
969        show_ipv6_ospf6_database_adv_router_linkstate_id_detail_cmd,
970        "show ipv6 ospf6 database adv-router A.B.C.D linkstate-id A.B.C.D "
971        "(detail|dump|internal)",
972        SHOW_STR
973        IPV6_STR
974        OSPF6_STR
975        "Display Link state database\n"
976        "Search by Advertising Router\n"
977        "Specify Advertising Router as IPv4 address notation\n"
978        "Search by Link state ID\n"
979        "Specify Link state ID as IPv4 address notation\n"
980        "Display details of LSAs\n"
981        "Dump LSAs\n"
982        "Display LSA's internal information\n"
983       )
984 
985 DEFUN (show_ipv6_ospf6_database_type_id_router,
986        show_ipv6_ospf6_database_type_id_router_cmd,
987        "show ipv6 ospf6 database "
988        "(router|network|inter-prefix|inter-router|as-external|"
989        "group-membership|type-7|link|intra-prefix) A.B.C.D A.B.C.D",
990        SHOW_STR
991        IPV6_STR
992        OSPF6_STR
993        "Display Link state database\n"
994        "Display Router LSAs\n"
995        "Display Network LSAs\n"
996        "Display Inter-Area-Prefix LSAs\n"
997        "Display Inter-Area-Router LSAs\n"
998        "Display As-External LSAs\n"
999        "Display Group-Membership LSAs\n"
1000        "Display Type-7 LSAs\n"
1001        "Display Link LSAs\n"
1002        "Display Intra-Area-Prefix LSAs\n"
1003        "Specify Link state ID as IPv4 address notation\n"
1004        "Specify Advertising Router as IPv4 address notation\n"
1005       )
1006 {
1007   int level;
1008   struct listnode *i, *j;
1009   struct ospf6 *o = ospf6;
1010   struct ospf6_area *oa;
1011   struct ospf6_interface *oi;
1012   u_int16_t type = 0;
1013   u_int32_t id = 0;
1014   u_int32_t adv_router = 0;
1015 
1016   OSPF6_CMD_CHECK_RUNNING ();
1017 
1018   type = parse_type_spec (argc, argv);
1019   argc--;
1020   argv++;
1021 
1022   if ((inet_pton (AF_INET, argv[0], &id)) != 1)
1023     {
1024       vty_out (vty, "Link state ID is not parsable: %s%s",
1025                argv[0], VNL);
1026       return CMD_SUCCESS;
1027     }
1028 
1029   argc--;
1030   argv++;
1031 
1032   if ((inet_pton (AF_INET, argv[0], &adv_router)) != 1)
1033     {
1034       vty_out (vty, "Advertising Router is not parsable: %s%s",
1035                argv[0], VNL);
1036       return CMD_SUCCESS;
1037     }
1038 
1039   argc--;
1040   argv++;
1041   level = parse_show_level (argc, argv);
1042 
1043   switch (OSPF6_LSA_SCOPE (type))
1044     {
1045       case OSPF6_SCOPE_AREA:
1046         for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1047           {
1048             vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
1049             ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oa->lsdb);
1050           }
1051         break;
1052 
1053       case OSPF6_SCOPE_LINKLOCAL:
1054         for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1055           {
1056             for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
1057               {
1058                 vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
1059                          oi->interface->name, oa->name, VNL, VNL);
1060                 ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oi->lsdb);
1061               }
1062           }
1063         break;
1064 
1065       case OSPF6_SCOPE_AS:
1066         vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL);
1067         ospf6_lsdb_show (vty, level, &type, &id, &adv_router, o->lsdb);
1068         break;
1069 
1070       default:
1071         assert (0);
1072         break;
1073     }
1074 
1075   vty_out (vty, "%s", VNL);
1076   return CMD_SUCCESS;
1077 }
1078 
1079 ALIAS (show_ipv6_ospf6_database_type_id_router,
1080        show_ipv6_ospf6_database_type_id_router_detail_cmd,
1081        "show ipv6 ospf6 database "
1082        "(router|network|inter-prefix|inter-router|as-external|"
1083        "group-membership|type-7|link|intra-prefix) A.B.C.D A.B.C.D "
1084        "(dump|internal)",
1085        SHOW_STR
1086        IPV6_STR
1087        OSPF6_STR
1088        "Display Link state database\n"
1089        "Display Router LSAs\n"
1090        "Display Network LSAs\n"
1091        "Display Inter-Area-Prefix LSAs\n"
1092        "Display Inter-Area-Router LSAs\n"
1093        "Display As-External LSAs\n"
1094        "Display Group-Membership LSAs\n"
1095        "Display Type-7 LSAs\n"
1096        "Display Link LSAs\n"
1097        "Display Intra-Area-Prefix LSAs\n"
1098        "Specify Link state ID as IPv4 address notation\n"
1099        "Specify Advertising Router as IPv4 address notation\n"
1100        "Dump LSAs\n"
1101        "Display LSA's internal information\n"
1102       )
1103 
1104 DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id,
1105        show_ipv6_ospf6_database_type_adv_router_linkstate_id_cmd,
1106        "show ipv6 ospf6 database "
1107        "(router|network|inter-prefix|inter-router|as-external|"
1108        "group-membership|type-7|link|intra-prefix) "
1109        "adv-router A.B.C.D linkstate-id A.B.C.D",
1110        SHOW_STR
1111        IPV6_STR
1112        OSPF6_STR
1113        "Display Link state database\n"
1114        "Display Router LSAs\n"
1115        "Display Network LSAs\n"
1116        "Display Inter-Area-Prefix LSAs\n"
1117        "Display Inter-Area-Router LSAs\n"
1118        "Display As-External LSAs\n"
1119        "Display Group-Membership LSAs\n"
1120        "Display Type-7 LSAs\n"
1121        "Display Link LSAs\n"
1122        "Display Intra-Area-Prefix LSAs\n"
1123        "Search by Advertising Router\n"
1124        "Specify Advertising Router as IPv4 address notation\n"
1125        "Search by Link state ID\n"
1126        "Specify Link state ID as IPv4 address notation\n"
1127       )
1128 {
1129   int level;
1130   struct listnode *i, *j;
1131   struct ospf6 *o = ospf6;
1132   struct ospf6_area *oa;
1133   struct ospf6_interface *oi;
1134   u_int16_t type = 0;
1135   u_int32_t id = 0;
1136   u_int32_t adv_router = 0;
1137 
1138   OSPF6_CMD_CHECK_RUNNING ();
1139 
1140   type = parse_type_spec (argc, argv);
1141   argc--;
1142   argv++;
1143 
1144   if ((inet_pton (AF_INET, argv[0], &adv_router)) != 1)
1145     {
1146       vty_out (vty, "Advertising Router is not parsable: %s%s",
1147                argv[0], VNL);
1148       return CMD_SUCCESS;
1149     }
1150 
1151   argc--;
1152   argv++;
1153 
1154   if ((inet_pton (AF_INET, argv[0], &id)) != 1)
1155     {
1156       vty_out (vty, "Link state ID is not parsable: %s%s",
1157                argv[0], VNL);
1158       return CMD_SUCCESS;
1159     }
1160 
1161   argc--;
1162   argv++;
1163   level = parse_show_level (argc, argv);
1164 
1165   switch (OSPF6_LSA_SCOPE (type))
1166     {
1167       case OSPF6_SCOPE_AREA:
1168         for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1169           {
1170             vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
1171             ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oa->lsdb);
1172           }
1173         break;
1174 
1175       case OSPF6_SCOPE_LINKLOCAL:
1176         for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1177           {
1178             for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
1179               {
1180                 vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
1181                          oi->interface->name, oa->name, VNL, VNL);
1182                 ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oi->lsdb);
1183               }
1184           }
1185         break;
1186 
1187       case OSPF6_SCOPE_AS:
1188         vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL);
1189         ospf6_lsdb_show (vty, level, &type, &id, &adv_router, o->lsdb);
1190         break;
1191 
1192       default:
1193         assert (0);
1194         break;
1195     }
1196 
1197   vty_out (vty, "%s", VNL);
1198   return CMD_SUCCESS;
1199 }
1200 
1201 ALIAS (show_ipv6_ospf6_database_type_adv_router_linkstate_id,
1202        show_ipv6_ospf6_database_type_adv_router_linkstate_id_detail_cmd,
1203        "show ipv6 ospf6 database "
1204        "(router|network|inter-prefix|inter-router|as-external|"
1205        "group-membership|type-7|link|intra-prefix) "
1206        "adv-router A.B.C.D linkstate-id A.B.C.D "
1207        "(dump|internal)",
1208        SHOW_STR
1209        IPV6_STR
1210        OSPF6_STR
1211        "Display Link state database\n"
1212        "Display Router LSAs\n"
1213        "Display Network LSAs\n"
1214        "Display Inter-Area-Prefix LSAs\n"
1215        "Display Inter-Area-Router LSAs\n"
1216        "Display As-External LSAs\n"
1217        "Display Group-Membership LSAs\n"
1218        "Display Type-7 LSAs\n"
1219        "Display Link LSAs\n"
1220        "Display Intra-Area-Prefix LSAs\n"
1221        "Search by Advertising Router\n"
1222        "Specify Advertising Router as IPv4 address notation\n"
1223        "Search by Link state ID\n"
1224        "Specify Link state ID as IPv4 address notation\n"
1225        "Dump LSAs\n"
1226        "Display LSA's internal information\n"
1227       )
1228 
1229 DEFUN (show_ipv6_ospf6_database_self_originated,
1230        show_ipv6_ospf6_database_self_originated_cmd,
1231        "show ipv6 ospf6 database self-originated",
1232        SHOW_STR
1233        IPV6_STR
1234        OSPF6_STR
1235        "Display Self-originated LSAs\n"
1236       )
1237 {
1238   int level;
1239   struct listnode *i, *j;
1240   struct ospf6 *o = ospf6;
1241   struct ospf6_area *oa;
1242   struct ospf6_interface *oi;
1243   u_int32_t adv_router = 0;
1244 
1245   OSPF6_CMD_CHECK_RUNNING ();
1246 
1247   level = parse_show_level (argc, argv);
1248 
1249   adv_router = o->router_id;
1250 
1251   for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1252     {
1253       vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
1254       ospf6_lsdb_show (vty, level, NULL, NULL, &adv_router, oa->lsdb);
1255     }
1256 
1257   for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1258     {
1259       for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
1260         {
1261           vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
1262                    oi->interface->name, oa->name, VNL, VNL);
1263           ospf6_lsdb_show (vty, level, NULL, NULL, &adv_router, oi->lsdb);
1264         }
1265     }
1266 
1267   vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL);
1268   ospf6_lsdb_show (vty, level, NULL, NULL, &adv_router, o->lsdb);
1269 
1270   vty_out (vty, "%s", VNL);
1271   return CMD_SUCCESS;
1272 }
1273 
1274 ALIAS (show_ipv6_ospf6_database_self_originated,
1275        show_ipv6_ospf6_database_self_originated_detail_cmd,
1276        "show ipv6 ospf6 database self-originated "
1277        "(detail|dump|internal)",
1278        SHOW_STR
1279        IPV6_STR
1280        OSPF6_STR
1281        "Display Self-originated LSAs\n"
1282        "Display details of LSAs\n"
1283        "Dump LSAs\n"
1284        "Display LSA's internal information\n"
1285       )
1286 
1287 DEFUN (show_ipv6_ospf6_database_type_self_originated,
1288        show_ipv6_ospf6_database_type_self_originated_cmd,
1289        "show ipv6 ospf6 database "
1290        "(router|network|inter-prefix|inter-router|as-external|"
1291        "group-membership|type-7|link|intra-prefix) self-originated",
1292        SHOW_STR
1293        IPV6_STR
1294        OSPF6_STR
1295        "Display Link state database\n"
1296        "Display Router LSAs\n"
1297        "Display Network LSAs\n"
1298        "Display Inter-Area-Prefix LSAs\n"
1299        "Display Inter-Area-Router LSAs\n"
1300        "Display As-External LSAs\n"
1301        "Display Group-Membership LSAs\n"
1302        "Display Type-7 LSAs\n"
1303        "Display Link LSAs\n"
1304        "Display Intra-Area-Prefix LSAs\n"
1305        "Display Self-originated LSAs\n"
1306       )
1307 {
1308   int level;
1309   struct listnode *i, *j;
1310   struct ospf6 *o = ospf6;
1311   struct ospf6_area *oa;
1312   struct ospf6_interface *oi;
1313   u_int16_t type = 0;
1314   u_int32_t adv_router = 0;
1315 
1316   OSPF6_CMD_CHECK_RUNNING ();
1317 
1318   type = parse_type_spec (argc, argv);
1319   argc--;
1320   argv++;
1321   level = parse_show_level (argc, argv);
1322 
1323   adv_router = o->router_id;
1324 
1325   switch (OSPF6_LSA_SCOPE (type))
1326     {
1327       case OSPF6_SCOPE_AREA:
1328         for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1329           {
1330             vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
1331             ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, oa->lsdb);
1332           }
1333         break;
1334 
1335       case OSPF6_SCOPE_LINKLOCAL:
1336         for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1337           {
1338             for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
1339               {
1340                 vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
1341                          oi->interface->name, oa->name, VNL, VNL);
1342                 ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, oi->lsdb);
1343               }
1344           }
1345         break;
1346 
1347       case OSPF6_SCOPE_AS:
1348         vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL);
1349         ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, o->lsdb);
1350         break;
1351 
1352       default:
1353         assert (0);
1354         break;
1355     }
1356 
1357   vty_out (vty, "%s", VNL);
1358   return CMD_SUCCESS;
1359 }
1360 
1361 ALIAS (show_ipv6_ospf6_database_type_self_originated,
1362        show_ipv6_ospf6_database_type_self_originated_detail_cmd,
1363        "show ipv6 ospf6 database "
1364        "(router|network|inter-prefix|inter-router|as-external|"
1365        "group-membership|type-7|link|intra-prefix) self-originated "
1366        "(detail|dump|internal)",
1367        SHOW_STR
1368        IPV6_STR
1369        OSPF6_STR
1370        "Display Link state database\n"
1371        "Display Router LSAs\n"
1372        "Display Network LSAs\n"
1373        "Display Inter-Area-Prefix LSAs\n"
1374        "Display Inter-Area-Router LSAs\n"
1375        "Display As-External LSAs\n"
1376        "Display Group-Membership LSAs\n"
1377        "Display Type-7 LSAs\n"
1378        "Display Link LSAs\n"
1379        "Display Intra-Area-Prefix LSAs\n"
1380        "Display Self-originated LSAs\n"
1381        "Display details of LSAs\n"
1382        "Dump LSAs\n"
1383        "Display LSA's internal information\n"
1384       )
1385 
1386 DEFUN (show_ipv6_ospf6_database_type_self_originated_linkstate_id,
1387        show_ipv6_ospf6_database_type_self_originated_linkstate_id_cmd,
1388        "show ipv6 ospf6 database "
1389        "(router|network|inter-prefix|inter-router|as-external|"
1390        "group-membership|type-7|link|intra-prefix) self-originated "
1391        "linkstate-id A.B.C.D",
1392        SHOW_STR
1393        IPV6_STR
1394        OSPF6_STR
1395        "Display Link state database\n"
1396        "Display Router LSAs\n"
1397        "Display Network LSAs\n"
1398        "Display Inter-Area-Prefix LSAs\n"
1399        "Display Inter-Area-Router LSAs\n"
1400        "Display As-External LSAs\n"
1401        "Display Group-Membership LSAs\n"
1402        "Display Type-7 LSAs\n"
1403        "Display Link LSAs\n"
1404        "Display Intra-Area-Prefix LSAs\n"
1405        "Display Self-originated LSAs\n"
1406        "Search by Link state ID\n"
1407        "Specify Link state ID as IPv4 address notation\n"
1408       )
1409 {
1410   int level;
1411   struct listnode *i, *j;
1412   struct ospf6 *o = ospf6;
1413   struct ospf6_area *oa;
1414   struct ospf6_interface *oi;
1415   u_int16_t type = 0;
1416   u_int32_t adv_router = 0;
1417   u_int32_t id = 0;
1418 
1419   OSPF6_CMD_CHECK_RUNNING ();
1420 
1421   type = parse_type_spec (argc, argv);
1422   argc--;
1423   argv++;
1424 
1425   if ((inet_pton (AF_INET, argv[0], &id)) != 1)
1426     {
1427       vty_out (vty, "Link State ID is not parsable: %s%s",
1428                argv[0], VNL);
1429       return CMD_SUCCESS;
1430     }
1431 
1432   argc--;
1433   argv++;
1434   level = parse_show_level (argc, argv);
1435 
1436   adv_router = o->router_id;
1437 
1438   switch (OSPF6_LSA_SCOPE (type))
1439     {
1440       case OSPF6_SCOPE_AREA:
1441         for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1442           {
1443             vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
1444             ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oa->lsdb);
1445           }
1446         break;
1447 
1448       case OSPF6_SCOPE_LINKLOCAL:
1449         for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1450           {
1451             for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
1452               {
1453                 vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
1454                          oi->interface->name, oa->name, VNL, VNL);
1455                 ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oi->lsdb);
1456               }
1457           }
1458         break;
1459 
1460       case OSPF6_SCOPE_AS:
1461         vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL);
1462         ospf6_lsdb_show (vty, level, &type, &id, &adv_router, o->lsdb);
1463         break;
1464 
1465       default:
1466         assert (0);
1467         break;
1468     }
1469 
1470   vty_out (vty, "%s", VNL);
1471   return CMD_SUCCESS;
1472 }
1473 
1474 ALIAS (show_ipv6_ospf6_database_type_self_originated_linkstate_id,
1475        show_ipv6_ospf6_database_type_self_originated_linkstate_id_detail_cmd,
1476        "show ipv6 ospf6 database "
1477        "(router|network|inter-prefix|inter-router|as-external|"
1478        "group-membership|type-7|link|intra-prefix) self-originated "
1479        "linkstate-id A.B.C.D (detail|dump|internal)",
1480        SHOW_STR
1481        IPV6_STR
1482        OSPF6_STR
1483        "Display Link state database\n"
1484        "Display Router LSAs\n"
1485        "Display Network LSAs\n"
1486        "Display Inter-Area-Prefix LSAs\n"
1487        "Display Inter-Area-Router LSAs\n"
1488        "Display As-External LSAs\n"
1489        "Display Group-Membership LSAs\n"
1490        "Display Type-7 LSAs\n"
1491        "Display Link LSAs\n"
1492        "Display Intra-Area-Prefix LSAs\n"
1493        "Display Self-originated LSAs\n"
1494        "Search by Link state ID\n"
1495        "Specify Link state ID as IPv4 address notation\n"
1496        "Display details of LSAs\n"
1497        "Dump LSAs\n"
1498        "Display LSA's internal information\n"
1499       )
1500 
1501 DEFUN (show_ipv6_ospf6_database_type_id_self_originated,
1502        show_ipv6_ospf6_database_type_id_self_originated_cmd,
1503        "show ipv6 ospf6 database "
1504        "(router|network|inter-prefix|inter-router|as-external|"
1505        "group-membership|type-7|link|intra-prefix) A.B.C.D self-originated",
1506        SHOW_STR
1507        IPV6_STR
1508        OSPF6_STR
1509        "Display Link state database\n"
1510        "Display Router LSAs\n"
1511        "Display Network LSAs\n"
1512        "Display Inter-Area-Prefix LSAs\n"
1513        "Display Inter-Area-Router LSAs\n"
1514        "Display As-External LSAs\n"
1515        "Display Group-Membership LSAs\n"
1516        "Display Type-7 LSAs\n"
1517        "Display Link LSAs\n"
1518        "Display Intra-Area-Prefix LSAs\n"
1519        "Specify Link state ID as IPv4 address notation\n"
1520        "Display Self-originated LSAs\n"
1521       )
1522 {
1523   int level;
1524   struct listnode *i, *j;
1525   struct ospf6 *o = ospf6;
1526   struct ospf6_area *oa;
1527   struct ospf6_interface *oi;
1528   u_int16_t type = 0;
1529   u_int32_t adv_router = 0;
1530   u_int32_t id = 0;
1531 
1532   OSPF6_CMD_CHECK_RUNNING ();
1533 
1534   type = parse_type_spec (argc, argv);
1535   argc--;
1536   argv++;
1537 
1538   if ((inet_pton (AF_INET, argv[0], &id)) != 1)
1539     {
1540       vty_out (vty, "Link State ID is not parsable: %s%s",
1541                argv[0], VNL);
1542       return CMD_SUCCESS;
1543     }
1544 
1545   argc--;
1546   argv++;
1547   level = parse_show_level (argc, argv);
1548 
1549   adv_router = o->router_id;
1550 
1551   switch (OSPF6_LSA_SCOPE (type))
1552     {
1553       case OSPF6_SCOPE_AREA:
1554         for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1555           {
1556             vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
1557             ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oa->lsdb);
1558           }
1559         break;
1560 
1561       case OSPF6_SCOPE_LINKLOCAL:
1562         for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1563           {
1564             for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
1565               {
1566                 vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
1567                          oi->interface->name, oa->name, VNL, VNL);
1568                 ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oi->lsdb);
1569               }
1570           }
1571         break;
1572 
1573       case OSPF6_SCOPE_AS:
1574         vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL);
1575         ospf6_lsdb_show (vty, level, &type, &id, &adv_router, o->lsdb);
1576         break;
1577 
1578       default:
1579         assert (0);
1580         break;
1581     }
1582 
1583   vty_out (vty, "%s", VNL);
1584   return CMD_SUCCESS;
1585 }
1586 
1587 ALIAS (show_ipv6_ospf6_database_type_id_self_originated,
1588        show_ipv6_ospf6_database_type_id_self_originated_detail_cmd,
1589        "show ipv6 ospf6 database "
1590        "(router|network|inter-prefix|inter-router|as-external|"
1591        "group-membership|type-7|link|intra-prefix) A.B.C.D self-originated "
1592        "(detail|dump|internal)",
1593        SHOW_STR
1594        IPV6_STR
1595        OSPF6_STR
1596        "Display Link state database\n"
1597        "Display Router LSAs\n"
1598        "Display Network LSAs\n"
1599        "Display Inter-Area-Prefix LSAs\n"
1600        "Display Inter-Area-Router LSAs\n"
1601        "Display As-External LSAs\n"
1602        "Display Group-Membership LSAs\n"
1603        "Display Type-7 LSAs\n"
1604        "Display Link LSAs\n"
1605        "Display Intra-Area-Prefix LSAs\n"
1606        "Display Self-originated LSAs\n"
1607        "Search by Link state ID\n"
1608        "Specify Link state ID as IPv4 address notation\n"
1609        "Display details of LSAs\n"
1610        "Dump LSAs\n"
1611        "Display LSA's internal information\n"
1612       )
1613 
1614 
1615 DEFUN (show_ipv6_ospf6_border_routers,
1616        show_ipv6_ospf6_border_routers_cmd,
1617        "show ipv6 ospf6 border-routers",
1618        SHOW_STR
1619        IP6_STR
1620        OSPF6_STR
1621        "Display routing table for ABR and ASBR\n"
1622       )
1623 {
1624   u_int32_t adv_router;
1625   void (*showfunc) (struct vty *, struct ospf6_route *);
1626   struct ospf6_route *ro;
1627   struct prefix prefix;
1628 
1629   OSPF6_CMD_CHECK_RUNNING ();
1630 
1631   if (argc && ! strcmp ("detail", argv[0]))
1632     {
1633       showfunc = ospf6_route_show_detail;
1634       argc--;
1635       argv++;
1636     }
1637   else
1638     showfunc = ospf6_brouter_show;
1639 
1640   if (argc)
1641     {
1642       if ((inet_pton (AF_INET, argv[0], &adv_router)) != 1)
1643         {
1644           vty_out (vty, "Router ID is not parsable: %s%s", argv[0], VNL);
1645           return CMD_SUCCESS;
1646         }
1647 
1648       ospf6_linkstate_prefix (adv_router, 0, &prefix);
1649       ro = ospf6_route_lookup (&prefix, ospf6->brouter_table);
1650       if (!ro)
1651         {
1652           vty_out (vty, "No Route found for Router ID: %s%s", argv[0], VNL);
1653           return CMD_SUCCESS;
1654         }
1655 
1656       ospf6_route_show_detail (vty, ro);
1657       return CMD_SUCCESS;
1658     }
1659 
1660   if (showfunc == ospf6_brouter_show)
1661     ospf6_brouter_show_header (vty);
1662 
1663   for (ro = ospf6_route_head (ospf6->brouter_table); ro;
1664        ro = ospf6_route_next (ro))
1665     (*showfunc) (vty, ro);
1666 
1667   return CMD_SUCCESS;
1668 }
1669 
1670 ALIAS (show_ipv6_ospf6_border_routers,
1671        show_ipv6_ospf6_border_routers_detail_cmd,
1672        "show ipv6 ospf6 border-routers (A.B.C.D|detail)",
1673        SHOW_STR
1674        IP6_STR
1675        OSPF6_STR
1676        "Display routing table for ABR and ASBR\n"
1677        "Specify Router-ID\n"
1678        "Display Detail\n"
1679       )
1680 
1681 DEFUN (show_ipv6_ospf6_linkstate,
1682        show_ipv6_ospf6_linkstate_cmd,
1683        "show ipv6 ospf6 linkstate",
1684        SHOW_STR
1685        IP6_STR
1686        OSPF6_STR
1687        "Display linkstate routing table\n"
1688       )
1689 {
1690   struct listnode *node;
1691   struct ospf6_area *oa;
1692 
1693   OSPF6_CMD_CHECK_RUNNING ();
1694 
1695   for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
1696     {
1697       vty_out (vty, "%s        SPF Result in Area %s%s%s",
1698                VNL, oa->name, VNL, VNL);
1699       ospf6_linkstate_table_show (vty, argc, argv, oa->spf_table);
1700     }
1701 
1702   vty_out (vty, "%s", VNL);
1703   return CMD_SUCCESS;
1704 }
1705 
1706 ALIAS (show_ipv6_ospf6_linkstate,
1707        show_ipv6_ospf6_linkstate_router_cmd,
1708        "show ipv6 ospf6 linkstate router A.B.C.D",
1709        SHOW_STR
1710        IP6_STR
1711        OSPF6_STR
1712        "Display linkstate routing table\n"
1713        "Display Router Entry\n"
1714        "Specify Router ID as IPv4 address notation\n"
1715       )
1716 
1717 ALIAS (show_ipv6_ospf6_linkstate,
1718        show_ipv6_ospf6_linkstate_network_cmd,
1719        "show ipv6 ospf6 linkstate network A.B.C.D A.B.C.D",
1720        SHOW_STR
1721        IP6_STR
1722        OSPF6_STR
1723        "Display linkstate routing table\n"
1724        "Display Network Entry\n"
1725        "Specify Router ID as IPv4 address notation\n"
1726        "Specify Link state ID as IPv4 address notation\n"
1727       )
1728 
1729 DEFUN (show_ipv6_ospf6_linkstate_detail,
1730        show_ipv6_ospf6_linkstate_detail_cmd,
1731        "show ipv6 ospf6 linkstate detail",
1732        SHOW_STR
1733        IP6_STR
1734        OSPF6_STR
1735        "Display linkstate routing table\n"
1736       )
1737 {
1738   const char *sargv[CMD_ARGC_MAX];
1739   int i, sargc;
1740   struct listnode *node;
1741   struct ospf6_area *oa;
1742 
1743   OSPF6_CMD_CHECK_RUNNING ();
1744 
1745   /* copy argv to sargv and then append "detail" */
1746   for (i = 0; i < argc; i++)
1747     sargv[i] = argv[i];
1748   sargc = argc;
1749   sargv[sargc++] = "detail";
1750   sargv[sargc] = NULL;
1751 
1752   for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
1753     {
1754       vty_out (vty, "%s        SPF Result in Area %s%s%s",
1755                VNL, oa->name, VNL, VNL);
1756       ospf6_linkstate_table_show (vty, sargc, sargv, oa->spf_table);
1757     }
1758 
1759   vty_out (vty, "%s", VNL);
1760   return CMD_SUCCESS;
1761 }
1762 
1763 /* Install ospf related commands. */
1764 void
ospf6_init(void)1765 ospf6_init (void)
1766 {
1767   ospf6_top_init ();
1768   ospf6_area_init ();
1769   ospf6_interface_init ();
1770   ospf6_neighbor_init ();
1771   ospf6_zebra_init (master);
1772 
1773   ospf6_lsa_init ();
1774   ospf6_spf_init ();
1775   ospf6_intra_init ();
1776   ospf6_asbr_init ();
1777   ospf6_abr_init ();
1778 
1779 #ifdef HAVE_SNMP
1780   ospf6_snmp_init (master);
1781 #endif /*HAVE_SNMP*/
1782 
1783   install_node (&debug_node, config_write_ospf6_debug);
1784 
1785   install_element_ospf6_debug_message ();
1786   install_element_ospf6_debug_lsa ();
1787   install_element_ospf6_debug_interface ();
1788   install_element_ospf6_debug_neighbor ();
1789   install_element_ospf6_debug_zebra ();
1790   install_element_ospf6_debug_spf ();
1791   install_element_ospf6_debug_route ();
1792   install_element_ospf6_debug_brouter ();
1793   install_element_ospf6_debug_asbr ();
1794   install_element_ospf6_debug_abr ();
1795   install_element_ospf6_debug_flood ();
1796 
1797   install_element_ospf6_clear_interface ();
1798 
1799   install_element (VIEW_NODE, &show_version_ospf6_cmd);
1800 
1801   install_element (VIEW_NODE, &show_ipv6_ospf6_border_routers_cmd);
1802   install_element (VIEW_NODE, &show_ipv6_ospf6_border_routers_detail_cmd);
1803 
1804   install_element (VIEW_NODE, &show_ipv6_ospf6_linkstate_cmd);
1805   install_element (VIEW_NODE, &show_ipv6_ospf6_linkstate_router_cmd);
1806   install_element (VIEW_NODE, &show_ipv6_ospf6_linkstate_network_cmd);
1807   install_element (VIEW_NODE, &show_ipv6_ospf6_linkstate_detail_cmd);
1808 
1809 #define INSTALL(n,c) \
1810   install_element (n ## _NODE, &show_ipv6_ospf6_ ## c)
1811 
1812   INSTALL (VIEW, database_cmd);
1813   INSTALL (VIEW, database_detail_cmd);
1814   INSTALL (VIEW, database_type_cmd);
1815   INSTALL (VIEW, database_type_detail_cmd);
1816   INSTALL (VIEW, database_id_cmd);
1817   INSTALL (VIEW, database_id_detail_cmd);
1818   INSTALL (VIEW, database_linkstate_id_cmd);
1819   INSTALL (VIEW, database_linkstate_id_detail_cmd);
1820   INSTALL (VIEW, database_router_cmd);
1821   INSTALL (VIEW, database_router_detail_cmd);
1822   INSTALL (VIEW, database_adv_router_cmd);
1823   INSTALL (VIEW, database_adv_router_detail_cmd);
1824   INSTALL (VIEW, database_type_id_cmd);
1825   INSTALL (VIEW, database_type_id_detail_cmd);
1826   INSTALL (VIEW, database_type_linkstate_id_cmd);
1827   INSTALL (VIEW, database_type_linkstate_id_detail_cmd);
1828   INSTALL (VIEW, database_type_router_cmd);
1829   INSTALL (VIEW, database_type_router_detail_cmd);
1830   INSTALL (VIEW, database_type_adv_router_cmd);
1831   INSTALL (VIEW, database_type_adv_router_detail_cmd);
1832   INSTALL (VIEW, database_adv_router_linkstate_id_cmd);
1833   INSTALL (VIEW, database_adv_router_linkstate_id_detail_cmd);
1834   INSTALL (VIEW, database_id_router_cmd);
1835   INSTALL (VIEW, database_id_router_detail_cmd);
1836   INSTALL (VIEW, database_type_id_router_cmd);
1837   INSTALL (VIEW, database_type_id_router_detail_cmd);
1838   INSTALL (VIEW, database_type_adv_router_linkstate_id_cmd);
1839   INSTALL (VIEW, database_type_adv_router_linkstate_id_detail_cmd);
1840   INSTALL (VIEW, database_self_originated_cmd);
1841   INSTALL (VIEW, database_self_originated_detail_cmd);
1842   INSTALL (VIEW, database_type_self_originated_cmd);
1843   INSTALL (VIEW, database_type_self_originated_detail_cmd);
1844   INSTALL (VIEW, database_type_id_self_originated_cmd);
1845   INSTALL (VIEW, database_type_id_self_originated_detail_cmd);
1846   INSTALL (VIEW, database_type_self_originated_linkstate_id_cmd);
1847   INSTALL (VIEW, database_type_self_originated_linkstate_id_detail_cmd);
1848 
1849   /* Make ospf protocol socket. */
1850   ospf6_serv_sock ();
1851   thread_add_read (master, ospf6_receive, NULL, ospf6_sock);
1852 }
1853 
1854 void
ospf6_clean(void)1855 ospf6_clean (void)
1856 {
1857   if (!ospf6)
1858     return;
1859   if (ospf6->route_table)
1860     ospf6_route_remove_all (ospf6->route_table);
1861   if (ospf6->brouter_table)
1862     ospf6_route_remove_all (ospf6->brouter_table);
1863 }
1864