Annotation of embedaddon/quagga/ospf6d/ospf6_top.c, revision 1.1

1.1     ! misho       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 "log.h"
        !            25: #include "memory.h"
        !            26: #include "vty.h"
        !            27: #include "linklist.h"
        !            28: #include "prefix.h"
        !            29: #include "table.h"
        !            30: #include "thread.h"
        !            31: #include "command.h"
        !            32: 
        !            33: #include "ospf6_proto.h"
        !            34: #include "ospf6_message.h"
        !            35: #include "ospf6_lsa.h"
        !            36: #include "ospf6_lsdb.h"
        !            37: #include "ospf6_route.h"
        !            38: #include "ospf6_zebra.h"
        !            39: 
        !            40: #include "ospf6_top.h"
        !            41: #include "ospf6_area.h"
        !            42: #include "ospf6_interface.h"
        !            43: #include "ospf6_neighbor.h"
        !            44: 
        !            45: #include "ospf6_flood.h"
        !            46: #include "ospf6_asbr.h"
        !            47: #include "ospf6_abr.h"
        !            48: #include "ospf6_intra.h"
        !            49: #include "ospf6d.h"
        !            50: 
        !            51: /* global ospf6d variable */
        !            52: struct ospf6 *ospf6;
        !            53: 
        !            54: static void ospf6_disable (struct ospf6 *o);
        !            55: 
        !            56: static void
        !            57: ospf6_top_lsdb_hook_add (struct ospf6_lsa *lsa)
        !            58: {
        !            59:   switch (ntohs (lsa->header->type))
        !            60:     {
        !            61:       case OSPF6_LSTYPE_AS_EXTERNAL:
        !            62:         ospf6_asbr_lsa_add (lsa);
        !            63:         break;
        !            64: 
        !            65:       default:
        !            66:         break;
        !            67:     }
        !            68: }
        !            69: 
        !            70: static void
        !            71: ospf6_top_lsdb_hook_remove (struct ospf6_lsa *lsa)
        !            72: {
        !            73:   switch (ntohs (lsa->header->type))
        !            74:     {
        !            75:       case OSPF6_LSTYPE_AS_EXTERNAL:
        !            76:         ospf6_asbr_lsa_remove (lsa);
        !            77:         break;
        !            78: 
        !            79:       default:
        !            80:         break;
        !            81:     }
        !            82: }
        !            83: 
        !            84: static void
        !            85: ospf6_top_route_hook_add (struct ospf6_route *route)
        !            86: {
        !            87:   ospf6_abr_originate_summary (route);
        !            88:   ospf6_zebra_route_update_add (route);
        !            89: }
        !            90: 
        !            91: static void
        !            92: ospf6_top_route_hook_remove (struct ospf6_route *route)
        !            93: {
        !            94:   ospf6_abr_originate_summary (route);
        !            95:   ospf6_zebra_route_update_remove (route);
        !            96: }
        !            97: 
        !            98: static void
        !            99: ospf6_top_brouter_hook_add (struct ospf6_route *route)
        !           100: {
        !           101:   ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
        !           102:   ospf6_asbr_lsentry_add (route);
        !           103:   ospf6_abr_originate_summary (route);
        !           104: }
        !           105: 
        !           106: static void
        !           107: ospf6_top_brouter_hook_remove (struct ospf6_route *route)
        !           108: {
        !           109:   ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
        !           110:   ospf6_asbr_lsentry_remove (route);
        !           111:   ospf6_abr_originate_summary (route);
        !           112: }
        !           113: 
        !           114: static struct ospf6 *
        !           115: ospf6_create (void)
        !           116: {
        !           117:   struct ospf6 *o;
        !           118: 
        !           119:   o = XCALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6));
        !           120: 
        !           121:   /* initialize */
        !           122:   quagga_gettime (QUAGGA_CLK_MONOTONIC, &o->starttime);
        !           123:   o->area_list = list_new ();
        !           124:   o->area_list->cmp = ospf6_area_cmp;
        !           125:   o->lsdb = ospf6_lsdb_create (o);
        !           126:   o->lsdb_self = ospf6_lsdb_create (o);
        !           127:   o->lsdb->hook_add = ospf6_top_lsdb_hook_add;
        !           128:   o->lsdb->hook_remove = ospf6_top_lsdb_hook_remove;
        !           129: 
        !           130:   o->route_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, ROUTES);
        !           131:   o->route_table->scope = o;
        !           132:   o->route_table->hook_add = ospf6_top_route_hook_add;
        !           133:   o->route_table->hook_remove = ospf6_top_route_hook_remove;
        !           134: 
        !           135:   o->brouter_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, BORDER_ROUTERS);
        !           136:   o->brouter_table->scope = o;
        !           137:   o->brouter_table->hook_add = ospf6_top_brouter_hook_add;
        !           138:   o->brouter_table->hook_remove = ospf6_top_brouter_hook_remove;
        !           139: 
        !           140:   o->external_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, EXTERNAL_ROUTES);
        !           141:   o->external_table->scope = o;
        !           142: 
        !           143:   o->external_id_table = route_table_init ();
        !           144: 
        !           145:   return o;
        !           146: }
        !           147: 
        !           148: void
        !           149: ospf6_delete (struct ospf6 *o)
        !           150: {
        !           151:   struct listnode *node, *nnode;
        !           152:   struct ospf6_area *oa;
        !           153: 
        !           154:   ospf6_disable (ospf6);
        !           155: 
        !           156:   for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
        !           157:     ospf6_area_delete (oa);
        !           158:   list_delete (o->area_list);
        !           159: 
        !           160:   ospf6_lsdb_delete (o->lsdb);
        !           161:   ospf6_lsdb_delete (o->lsdb_self);
        !           162: 
        !           163:   ospf6_route_table_delete (o->route_table);
        !           164:   ospf6_route_table_delete (o->brouter_table);
        !           165: 
        !           166:   ospf6_route_table_delete (o->external_table);
        !           167:   route_table_finish (o->external_id_table);
        !           168: 
        !           169:   XFREE (MTYPE_OSPF6_TOP, o);
        !           170: }
        !           171: 
        !           172: static void
        !           173: ospf6_enable (struct ospf6 *o)
        !           174: {
        !           175:   struct listnode *node, *nnode;
        !           176:   struct ospf6_area *oa;
        !           177: 
        !           178:   if (CHECK_FLAG (o->flag, OSPF6_DISABLED))
        !           179:     {
        !           180:       UNSET_FLAG (o->flag, OSPF6_DISABLED);
        !           181:       for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
        !           182:         ospf6_area_enable (oa);
        !           183:     }
        !           184: }
        !           185: 
        !           186: static void
        !           187: ospf6_disable (struct ospf6 *o)
        !           188: {
        !           189:   struct listnode *node, *nnode;
        !           190:   struct ospf6_area *oa;
        !           191: 
        !           192:   if (! CHECK_FLAG (o->flag, OSPF6_DISABLED))
        !           193:     {
        !           194:       SET_FLAG (o->flag, OSPF6_DISABLED);
        !           195:       
        !           196:       for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
        !           197:         ospf6_area_disable (oa);
        !           198: 
        !           199:       ospf6_lsdb_remove_all (o->lsdb);
        !           200:       ospf6_route_remove_all (o->route_table);
        !           201:       ospf6_route_remove_all (o->brouter_table);
        !           202:     }
        !           203: }
        !           204: 
        !           205: static int
        !           206: ospf6_maxage_remover (struct thread *thread)
        !           207: {
        !           208:   struct ospf6 *o = (struct ospf6 *) THREAD_ARG (thread);
        !           209:   struct ospf6_area *oa;
        !           210:   struct ospf6_interface *oi;
        !           211:   struct ospf6_neighbor *on;
        !           212:   struct listnode *i, *j, *k;
        !           213: 
        !           214:   o->maxage_remover = (struct thread *) NULL;
        !           215: 
        !           216:   for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
        !           217:     {
        !           218:       for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
        !           219:         {
        !           220:           for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
        !           221:             {
        !           222:               if (on->state != OSPF6_NEIGHBOR_EXCHANGE &&
        !           223:                   on->state != OSPF6_NEIGHBOR_LOADING)
        !           224:                 continue;
        !           225: 
        !           226:               return 0;
        !           227:             }
        !           228:         }
        !           229:     }
        !           230: 
        !           231:   for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
        !           232:     {
        !           233:       for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
        !           234:         OSPF6_LSDB_MAXAGE_REMOVER (oi->lsdb);
        !           235:       
        !           236:       OSPF6_LSDB_MAXAGE_REMOVER (oa->lsdb);
        !           237:     }
        !           238:   OSPF6_LSDB_MAXAGE_REMOVER (o->lsdb);
        !           239: 
        !           240:   return 0;
        !           241: }
        !           242: 
        !           243: void
        !           244: ospf6_maxage_remove (struct ospf6 *o)
        !           245: {
        !           246:   if (o && ! o->maxage_remover)
        !           247:     o->maxage_remover = thread_add_event (master, ospf6_maxage_remover, o, 0);
        !           248: }
        !           249: 
        !           250: /* start ospf6 */
        !           251: DEFUN (router_ospf6,
        !           252:        router_ospf6_cmd,
        !           253:        "router ospf6",
        !           254:        ROUTER_STR
        !           255:        OSPF6_STR)
        !           256: {
        !           257:   if (ospf6 == NULL)
        !           258:     ospf6 = ospf6_create ();
        !           259:   if (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))
        !           260:     ospf6_enable (ospf6);
        !           261: 
        !           262:   /* set current ospf point. */
        !           263:   vty->node = OSPF6_NODE;
        !           264:   vty->index = ospf6;
        !           265: 
        !           266:   return CMD_SUCCESS;
        !           267: }
        !           268: 
        !           269: /* stop ospf6 */
        !           270: DEFUN (no_router_ospf6,
        !           271:        no_router_ospf6_cmd,
        !           272:        "no router ospf6",
        !           273:        NO_STR
        !           274:        OSPF6_ROUTER_STR)
        !           275: {
        !           276:   if (ospf6 == NULL || CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))
        !           277:     vty_out (vty, "OSPFv3 is not running%s", VNL);
        !           278:   else
        !           279:     ospf6_disable (ospf6);
        !           280: 
        !           281:   /* return to config node . */
        !           282:   vty->node = CONFIG_NODE;
        !           283:   vty->index = NULL;
        !           284: 
        !           285:   return CMD_SUCCESS;
        !           286: }
        !           287: 
        !           288: /* change Router_ID commands. */
        !           289: DEFUN (ospf6_router_id,
        !           290:        ospf6_router_id_cmd,
        !           291:        "router-id A.B.C.D",
        !           292:        "Configure OSPF Router-ID\n"
        !           293:        V4NOTATION_STR)
        !           294: {
        !           295:   int ret;
        !           296:   u_int32_t router_id;
        !           297:   struct ospf6 *o;
        !           298: 
        !           299:   o = (struct ospf6 *) vty->index;
        !           300: 
        !           301:   ret = inet_pton (AF_INET, argv[0], &router_id);
        !           302:   if (ret == 0)
        !           303:     {
        !           304:       vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[0], VNL);
        !           305:       return CMD_SUCCESS;
        !           306:     }
        !           307: 
        !           308:   o->router_id_static = router_id;
        !           309:   if (o->router_id  == 0)
        !           310:     o->router_id  = router_id;
        !           311: 
        !           312:   return CMD_SUCCESS;
        !           313: }
        !           314: 
        !           315: DEFUN (ospf6_interface_area,
        !           316:        ospf6_interface_area_cmd,
        !           317:        "interface IFNAME area A.B.C.D",
        !           318:        "Enable routing on an IPv6 interface\n"
        !           319:        IFNAME_STR
        !           320:        "Specify the OSPF6 area ID\n"
        !           321:        "OSPF6 area ID in IPv4 address notation\n"
        !           322:       )
        !           323: {
        !           324:   struct ospf6 *o;
        !           325:   struct ospf6_area *oa;
        !           326:   struct ospf6_interface *oi;
        !           327:   struct interface *ifp;
        !           328:   u_int32_t area_id;
        !           329: 
        !           330:   o = (struct ospf6 *) vty->index;
        !           331: 
        !           332:   /* find/create ospf6 interface */
        !           333:   ifp = if_get_by_name (argv[0]);
        !           334:   oi = (struct ospf6_interface *) ifp->info;
        !           335:   if (oi == NULL)
        !           336:     oi = ospf6_interface_create (ifp);
        !           337:   if (oi->area)
        !           338:     {
        !           339:       vty_out (vty, "%s already attached to Area %s%s",
        !           340:                oi->interface->name, oi->area->name, VNL);
        !           341:       return CMD_SUCCESS;
        !           342:     }
        !           343: 
        !           344:   /* parse Area-ID */
        !           345:   if (inet_pton (AF_INET, argv[1], &area_id) != 1)
        !           346:     {
        !           347:       vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
        !           348:       return CMD_SUCCESS;
        !           349:     }
        !           350: 
        !           351:   /* find/create ospf6 area */
        !           352:   oa = ospf6_area_lookup (area_id, o);
        !           353:   if (oa == NULL)
        !           354:     oa = ospf6_area_create (area_id, o);
        !           355: 
        !           356:   /* attach interface to area */
        !           357:   listnode_add (oa->if_list, oi); /* sort ?? */
        !           358:   oi->area = oa;
        !           359: 
        !           360:   SET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
        !           361: 
        !           362:   /* start up */
        !           363:   thread_add_event (master, interface_up, oi, 0);
        !           364: 
        !           365:   /* If the router is ABR, originate summary routes */
        !           366:   if (ospf6_is_router_abr (o))
        !           367:     ospf6_abr_enable_area (oa);
        !           368: 
        !           369:   return CMD_SUCCESS;
        !           370: }
        !           371: 
        !           372: DEFUN (no_ospf6_interface_area,
        !           373:        no_ospf6_interface_area_cmd,
        !           374:        "no interface IFNAME area A.B.C.D",
        !           375:        NO_STR
        !           376:        "Disable routing on an IPv6 interface\n"
        !           377:        IFNAME_STR
        !           378:        "Specify the OSPF6 area ID\n"
        !           379:        "OSPF6 area ID in IPv4 address notation\n"
        !           380:        )
        !           381: {
        !           382:   struct ospf6 *o;
        !           383:   struct ospf6_interface *oi;
        !           384:   struct ospf6_area *oa;
        !           385:   struct interface *ifp;
        !           386:   u_int32_t area_id;
        !           387: 
        !           388:   o = (struct ospf6 *) vty->index;
        !           389: 
        !           390:   ifp = if_lookup_by_name (argv[0]);
        !           391:   if (ifp == NULL)
        !           392:     {
        !           393:       vty_out (vty, "No such interface %s%s", argv[0], VNL);
        !           394:       return CMD_SUCCESS;
        !           395:     }
        !           396: 
        !           397:   oi = (struct ospf6_interface *) ifp->info;
        !           398:   if (oi == NULL)
        !           399:     {
        !           400:       vty_out (vty, "Interface %s not enabled%s", ifp->name, VNL);
        !           401:       return CMD_SUCCESS;
        !           402:     }
        !           403: 
        !           404:   /* parse Area-ID */
        !           405:   if (inet_pton (AF_INET, argv[1], &area_id) != 1)
        !           406:     {
        !           407:       vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
        !           408:       return CMD_SUCCESS;
        !           409:     }
        !           410: 
        !           411:   /* Verify Area */
        !           412:   if (oi->area == NULL)
        !           413:     {
        !           414:       vty_out (vty, "No such Area-ID: %s%s", argv[1], VNL);
        !           415:       return CMD_SUCCESS;
        !           416:     }
        !           417: 
        !           418:   if (oi->area->area_id != area_id)
        !           419:     {
        !           420:       vty_out (vty, "Wrong Area-ID: %s is attached to area %s%s",
        !           421:                oi->interface->name, oi->area->name, VNL);
        !           422:       return CMD_SUCCESS;
        !           423:     }
        !           424: 
        !           425:   thread_execute (master, interface_down, oi, 0);
        !           426: 
        !           427:   oa = oi->area;
        !           428:   listnode_delete (oi->area->if_list, oi);
        !           429:   oi->area = (struct ospf6_area *) NULL;
        !           430: 
        !           431:   /* Withdraw inter-area routes from this area, if necessary */
        !           432:   if (oa->if_list->count == 0)
        !           433:     {
        !           434:       UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
        !           435:       ospf6_abr_disable_area (oa);
        !           436:     }
        !           437: 
        !           438:   return CMD_SUCCESS;
        !           439: }
        !           440: 
        !           441: static void
        !           442: ospf6_show (struct vty *vty, struct ospf6 *o)
        !           443: {
        !           444:   struct listnode *n;
        !           445:   struct ospf6_area *oa;
        !           446:   char router_id[16], duration[32];
        !           447:   struct timeval now, running;
        !           448: 
        !           449:   /* process id, router id */
        !           450:   inet_ntop (AF_INET, &o->router_id, router_id, sizeof (router_id));
        !           451:   vty_out (vty, " OSPFv3 Routing Process (0) with Router-ID %s%s",
        !           452:            router_id, VNL);
        !           453: 
        !           454:   /* running time */
        !           455:   quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
        !           456:   timersub (&now, &o->starttime, &running);
        !           457:   timerstring (&running, duration, sizeof (duration));
        !           458:   vty_out (vty, " Running %s%s", duration, VNL);
        !           459: 
        !           460:   /* Redistribute configuration */
        !           461:   /* XXX */
        !           462: 
        !           463:   /* LSAs */
        !           464:   vty_out (vty, " Number of AS scoped LSAs is %u%s",
        !           465:            o->lsdb->count, VNL);
        !           466: 
        !           467:   /* Areas */
        !           468:   vty_out (vty, " Number of areas in this router is %u%s",
        !           469:            listcount (o->area_list), VNL);
        !           470: 
        !           471:   for (ALL_LIST_ELEMENTS_RO (o->area_list, n, oa))
        !           472:     ospf6_area_show (vty, oa);
        !           473: }
        !           474: 
        !           475: /* show top level structures */
        !           476: DEFUN (show_ipv6_ospf6,
        !           477:        show_ipv6_ospf6_cmd,
        !           478:        "show ipv6 ospf6",
        !           479:        SHOW_STR
        !           480:        IP6_STR
        !           481:        OSPF6_STR)
        !           482: {
        !           483:   OSPF6_CMD_CHECK_RUNNING ();
        !           484: 
        !           485:   ospf6_show (vty, ospf6);
        !           486:   return CMD_SUCCESS;
        !           487: }
        !           488: 
        !           489: DEFUN (show_ipv6_ospf6_route,
        !           490:        show_ipv6_ospf6_route_cmd,
        !           491:        "show ipv6 ospf6 route",
        !           492:        SHOW_STR
        !           493:        IP6_STR
        !           494:        OSPF6_STR
        !           495:        ROUTE_STR
        !           496:        )
        !           497: {
        !           498:   ospf6_route_table_show (vty, argc, argv, ospf6->route_table);
        !           499:   return CMD_SUCCESS;
        !           500: }
        !           501: 
        !           502: ALIAS (show_ipv6_ospf6_route,
        !           503:        show_ipv6_ospf6_route_detail_cmd,
        !           504:        "show ipv6 ospf6 route (X:X::X:X|X:X::X:X/M|detail|summary)",
        !           505:        SHOW_STR
        !           506:        IP6_STR
        !           507:        OSPF6_STR
        !           508:        ROUTE_STR
        !           509:        "Specify IPv6 address\n"
        !           510:        "Specify IPv6 prefix\n"
        !           511:        "Detailed information\n"
        !           512:        "Summary of route table\n"
        !           513:        )
        !           514: 
        !           515: DEFUN (show_ipv6_ospf6_route_match,
        !           516:        show_ipv6_ospf6_route_match_cmd,
        !           517:        "show ipv6 ospf6 route X:X::X:X/M match",
        !           518:        SHOW_STR
        !           519:        IP6_STR
        !           520:        OSPF6_STR
        !           521:        ROUTE_STR
        !           522:        "Specify IPv6 prefix\n"
        !           523:        "Display routes which match the specified route\n"
        !           524:        )
        !           525: {
        !           526:   const char *sargv[CMD_ARGC_MAX];
        !           527:   int i, sargc;
        !           528: 
        !           529:   /* copy argv to sargv and then append "match" */
        !           530:   for (i = 0; i < argc; i++)
        !           531:     sargv[i] = argv[i];
        !           532:   sargc = argc;
        !           533:   sargv[sargc++] = "match";
        !           534:   sargv[sargc] = NULL;
        !           535: 
        !           536:   ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
        !           537:   return CMD_SUCCESS;
        !           538: }
        !           539: 
        !           540: DEFUN (show_ipv6_ospf6_route_match_detail,
        !           541:        show_ipv6_ospf6_route_match_detail_cmd,
        !           542:        "show ipv6 ospf6 route X:X::X:X/M match detail",
        !           543:        SHOW_STR
        !           544:        IP6_STR
        !           545:        OSPF6_STR
        !           546:        ROUTE_STR
        !           547:        "Specify IPv6 prefix\n"
        !           548:        "Display routes which match the specified route\n"
        !           549:        "Detailed information\n"
        !           550:        )
        !           551: {
        !           552:   const char *sargv[CMD_ARGC_MAX];
        !           553:   int i, sargc;
        !           554: 
        !           555:   /* copy argv to sargv and then append "match" and "detail" */
        !           556:   for (i = 0; i < argc; i++)
        !           557:     sargv[i] = argv[i];
        !           558:   sargc = argc;
        !           559:   sargv[sargc++] = "match";
        !           560:   sargv[sargc++] = "detail";
        !           561:   sargv[sargc] = NULL;
        !           562: 
        !           563:   ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
        !           564:   return CMD_SUCCESS;
        !           565: }
        !           566: 
        !           567: ALIAS (show_ipv6_ospf6_route_match,
        !           568:        show_ipv6_ospf6_route_longer_cmd,
        !           569:        "show ipv6 ospf6 route X:X::X:X/M longer",
        !           570:        SHOW_STR
        !           571:        IP6_STR
        !           572:        OSPF6_STR
        !           573:        ROUTE_STR
        !           574:        "Specify IPv6 prefix\n"
        !           575:        "Display routes longer than the specified route\n"
        !           576:        )
        !           577: 
        !           578: DEFUN (show_ipv6_ospf6_route_match_detail,
        !           579:        show_ipv6_ospf6_route_longer_detail_cmd,
        !           580:        "show ipv6 ospf6 route X:X::X:X/M longer detail",
        !           581:        SHOW_STR
        !           582:        IP6_STR
        !           583:        OSPF6_STR
        !           584:        ROUTE_STR
        !           585:        "Specify IPv6 prefix\n"
        !           586:        "Display routes longer than the specified route\n"
        !           587:        "Detailed information\n"
        !           588:        );
        !           589: 
        !           590: ALIAS (show_ipv6_ospf6_route,
        !           591:        show_ipv6_ospf6_route_type_cmd,
        !           592:        "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2)",
        !           593:        SHOW_STR
        !           594:        IP6_STR
        !           595:        OSPF6_STR
        !           596:        ROUTE_STR
        !           597:        "Display Intra-Area routes\n"
        !           598:        "Display Inter-Area routes\n"
        !           599:        "Display Type-1 External routes\n"
        !           600:        "Display Type-2 External routes\n"
        !           601:        )
        !           602: 
        !           603: DEFUN (show_ipv6_ospf6_route_type_detail,
        !           604:        show_ipv6_ospf6_route_type_detail_cmd,
        !           605:        "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2) detail",
        !           606:        SHOW_STR
        !           607:        IP6_STR
        !           608:        OSPF6_STR
        !           609:        ROUTE_STR
        !           610:        "Display Intra-Area routes\n"
        !           611:        "Display Inter-Area routes\n"
        !           612:        "Display Type-1 External routes\n"
        !           613:        "Display Type-2 External routes\n"
        !           614:        "Detailed information\n"
        !           615:        )
        !           616: {
        !           617:   const char *sargv[CMD_ARGC_MAX];
        !           618:   int i, sargc;
        !           619: 
        !           620:   /* copy argv to sargv and then append "detail" */
        !           621:   for (i = 0; i < argc; i++)
        !           622:     sargv[i] = argv[i];
        !           623:   sargc = argc;
        !           624:   sargv[sargc++] = "detail";
        !           625:   sargv[sargc] = NULL;
        !           626: 
        !           627:   ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
        !           628:   return CMD_SUCCESS;
        !           629: }
        !           630: 
        !           631: /* OSPF configuration write function. */
        !           632: static int
        !           633: config_write_ospf6 (struct vty *vty)
        !           634: {
        !           635:   char router_id[16];
        !           636:   struct listnode *j, *k;
        !           637:   struct ospf6_area *oa;
        !           638:   struct ospf6_interface *oi;
        !           639: 
        !           640:   /* OSPFv6 configuration. */
        !           641:   if (ospf6 == NULL)
        !           642:     return CMD_SUCCESS;
        !           643:   if (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))
        !           644:     return CMD_SUCCESS;
        !           645: 
        !           646:   inet_ntop (AF_INET, &ospf6->router_id_static, router_id, sizeof (router_id));
        !           647:   vty_out (vty, "router ospf6%s", VNL);
        !           648:   if (ospf6->router_id_static != 0)
        !           649:     vty_out (vty, " router-id %s%s", router_id, VNL);
        !           650: 
        !           651:   ospf6_redistribute_config_write (vty);
        !           652:   ospf6_area_config_write (vty);
        !           653: 
        !           654:   for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, j, oa))
        !           655:     {
        !           656:       for (ALL_LIST_ELEMENTS_RO (oa->if_list, k, oi))
        !           657:         vty_out (vty, " interface %s area %s%s",
        !           658:                  oi->interface->name, oa->name, VNL);
        !           659:     }
        !           660:   vty_out (vty, "!%s", VNL);
        !           661:   return 0;
        !           662: }
        !           663: 
        !           664: /* OSPF6 node structure. */
        !           665: static struct cmd_node ospf6_node =
        !           666: {
        !           667:   OSPF6_NODE,
        !           668:   "%s(config-ospf6)# ",
        !           669:   1 /* VTYSH */
        !           670: };
        !           671: 
        !           672: /* Install ospf related commands. */
        !           673: void
        !           674: ospf6_top_init (void)
        !           675: {
        !           676:   /* Install ospf6 top node. */
        !           677:   install_node (&ospf6_node, config_write_ospf6);
        !           678: 
        !           679:   install_element (VIEW_NODE, &show_ipv6_ospf6_cmd);
        !           680:   install_element (ENABLE_NODE, &show_ipv6_ospf6_cmd);
        !           681:   install_element (CONFIG_NODE, &router_ospf6_cmd);
        !           682:   install_element (CONFIG_NODE, &no_router_ospf6_cmd);
        !           683: 
        !           684:   install_element (VIEW_NODE, &show_ipv6_ospf6_route_cmd);
        !           685:   install_element (VIEW_NODE, &show_ipv6_ospf6_route_detail_cmd);
        !           686:   install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_cmd);
        !           687:   install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
        !           688:   install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_cmd);
        !           689:   install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_detail_cmd);
        !           690:   install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_cmd);
        !           691:   install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_detail_cmd);
        !           692:   install_element (ENABLE_NODE, &show_ipv6_ospf6_route_cmd);
        !           693:   install_element (ENABLE_NODE, &show_ipv6_ospf6_route_detail_cmd);
        !           694:   install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_cmd);
        !           695:   install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
        !           696:   install_element (ENABLE_NODE, &show_ipv6_ospf6_route_longer_cmd);
        !           697:   install_element (ENABLE_NODE, &show_ipv6_ospf6_route_longer_detail_cmd);
        !           698:   install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_cmd);
        !           699:   install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_detail_cmd);
        !           700: 
        !           701:   install_default (OSPF6_NODE);
        !           702:   install_element (OSPF6_NODE, &ospf6_router_id_cmd);
        !           703:   install_element (OSPF6_NODE, &ospf6_interface_area_cmd);
        !           704:   install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd);
        !           705: }
        !           706: 
        !           707: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>