Annotation of embedaddon/quagga/bgpd/bgp_route.c, revision 1.1.1.4

1.1       misho       1: /* BGP routing information
                      2:    Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro
                      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 Free
                     18: Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
                     19: 02111-1307, USA.  */
                     20: 
                     21: #include <zebra.h>
                     22: 
                     23: #include "prefix.h"
                     24: #include "linklist.h"
                     25: #include "memory.h"
                     26: #include "command.h"
                     27: #include "stream.h"
                     28: #include "filter.h"
                     29: #include "str.h"
                     30: #include "log.h"
                     31: #include "routemap.h"
                     32: #include "buffer.h"
                     33: #include "sockunion.h"
                     34: #include "plist.h"
                     35: #include "thread.h"
                     36: #include "workqueue.h"
                     37: 
                     38: #include "bgpd/bgpd.h"
                     39: #include "bgpd/bgp_table.h"
                     40: #include "bgpd/bgp_route.h"
                     41: #include "bgpd/bgp_attr.h"
                     42: #include "bgpd/bgp_debug.h"
                     43: #include "bgpd/bgp_aspath.h"
                     44: #include "bgpd/bgp_regex.h"
                     45: #include "bgpd/bgp_community.h"
                     46: #include "bgpd/bgp_ecommunity.h"
                     47: #include "bgpd/bgp_clist.h"
                     48: #include "bgpd/bgp_packet.h"
                     49: #include "bgpd/bgp_filter.h"
                     50: #include "bgpd/bgp_fsm.h"
                     51: #include "bgpd/bgp_mplsvpn.h"
                     52: #include "bgpd/bgp_nexthop.h"
                     53: #include "bgpd/bgp_damp.h"
                     54: #include "bgpd/bgp_advertise.h"
                     55: #include "bgpd/bgp_zebra.h"
                     56: #include "bgpd/bgp_vty.h"
1.1.1.2   misho      57: #include "bgpd/bgp_mpath.h"
1.1       misho      58: 
                     59: /* Extern from bgp_dump.c */
                     60: extern const char *bgp_origin_str[];
                     61: extern const char *bgp_origin_long_str[];
1.1.1.4 ! misho      62: 
1.1       misho      63: static struct bgp_node *
                     64: bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p,
                     65:                  struct prefix_rd *prd)
                     66: {
                     67:   struct bgp_node *rn;
                     68:   struct bgp_node *prn = NULL;
                     69:   
                     70:   assert (table);
                     71:   if (!table)
                     72:     return NULL;
                     73:   
1.1.1.4 ! misho      74:   if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
1.1       misho      75:     {
                     76:       prn = bgp_node_get (table, (struct prefix *) prd);
                     77: 
                     78:       if (prn->info == NULL)
                     79:        prn->info = bgp_table_init (afi, safi);
                     80:       else
                     81:        bgp_unlock_node (prn);
                     82:       table = prn->info;
                     83:     }
                     84: 
                     85:   rn = bgp_node_get (table, p);
                     86: 
1.1.1.4 ! misho      87:   if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
1.1       misho      88:     rn->prn = prn;
                     89: 
                     90:   return rn;
                     91: }
1.1.1.4 ! misho      92: 
1.1       misho      93: /* Allocate bgp_info_extra */
                     94: static struct bgp_info_extra *
                     95: bgp_info_extra_new (void)
                     96: {
                     97:   struct bgp_info_extra *new;
                     98:   new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA, sizeof (struct bgp_info_extra));
                     99:   return new;
                    100: }
                    101: 
                    102: static void
                    103: bgp_info_extra_free (struct bgp_info_extra **extra)
                    104: {
                    105:   if (extra && *extra)
                    106:     {
                    107:       if ((*extra)->damp_info)
                    108:         bgp_damp_info_free ((*extra)->damp_info, 0);
                    109:       
                    110:       (*extra)->damp_info = NULL;
                    111:       
                    112:       XFREE (MTYPE_BGP_ROUTE_EXTRA, *extra);
                    113:       
                    114:       *extra = NULL;
                    115:     }
                    116: }
                    117: 
                    118: /* Get bgp_info extra information for the given bgp_info, lazy allocated
                    119:  * if required.
                    120:  */
                    121: struct bgp_info_extra *
                    122: bgp_info_extra_get (struct bgp_info *ri)
                    123: {
                    124:   if (!ri->extra)
                    125:     ri->extra = bgp_info_extra_new();
                    126:   return ri->extra;
                    127: }
                    128: 
                    129: /* Allocate new bgp info structure. */
                    130: static struct bgp_info *
                    131: bgp_info_new (void)
                    132: {
                    133:   return XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info));
                    134: }
                    135: 
                    136: /* Free bgp route information. */
                    137: static void
                    138: bgp_info_free (struct bgp_info *binfo)
                    139: {
                    140:   if (binfo->attr)
                    141:     bgp_attr_unintern (&binfo->attr);
                    142:   
                    143:   bgp_info_extra_free (&binfo->extra);
1.1.1.2   misho     144:   bgp_info_mpath_free (&binfo->mpath);
1.1       misho     145: 
                    146:   peer_unlock (binfo->peer); /* bgp_info peer reference */
                    147: 
                    148:   XFREE (MTYPE_BGP_ROUTE, binfo);
                    149: }
                    150: 
                    151: struct bgp_info *
                    152: bgp_info_lock (struct bgp_info *binfo)
                    153: {
                    154:   binfo->lock++;
                    155:   return binfo;
                    156: }
                    157: 
                    158: struct bgp_info *
                    159: bgp_info_unlock (struct bgp_info *binfo)
                    160: {
                    161:   assert (binfo && binfo->lock > 0);
                    162:   binfo->lock--;
                    163:   
                    164:   if (binfo->lock == 0)
                    165:     {
                    166: #if 0
                    167:       zlog_debug ("%s: unlocked and freeing", __func__);
                    168:       zlog_backtrace (LOG_DEBUG);
                    169: #endif
                    170:       bgp_info_free (binfo);
                    171:       return NULL;
                    172:     }
                    173: 
                    174: #if 0
                    175:   if (binfo->lock == 1)
                    176:     {
                    177:       zlog_debug ("%s: unlocked to 1", __func__);
                    178:       zlog_backtrace (LOG_DEBUG);
                    179:     }
                    180: #endif
                    181:   
                    182:   return binfo;
                    183: }
                    184: 
                    185: void
                    186: bgp_info_add (struct bgp_node *rn, struct bgp_info *ri)
                    187: {
                    188:   struct bgp_info *top;
                    189: 
                    190:   top = rn->info;
                    191:   
                    192:   ri->next = rn->info;
                    193:   ri->prev = NULL;
                    194:   if (top)
                    195:     top->prev = ri;
                    196:   rn->info = ri;
                    197:   
                    198:   bgp_info_lock (ri);
                    199:   bgp_lock_node (rn);
                    200:   peer_lock (ri->peer); /* bgp_info peer reference */
                    201: }
                    202: 
                    203: /* Do the actual removal of info from RIB, for use by bgp_process 
                    204:    completion callback *only* */
                    205: static void
                    206: bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri)
                    207: {
                    208:   if (ri->next)
                    209:     ri->next->prev = ri->prev;
                    210:   if (ri->prev)
                    211:     ri->prev->next = ri->next;
                    212:   else
                    213:     rn->info = ri->next;
                    214:   
1.1.1.2   misho     215:   bgp_info_mpath_dequeue (ri);
1.1       misho     216:   bgp_info_unlock (ri);
                    217:   bgp_unlock_node (rn);
                    218: }
                    219: 
                    220: void
                    221: bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri)
                    222: {
                    223:   bgp_info_set_flag (rn, ri, BGP_INFO_REMOVED);
                    224:   /* set of previous already took care of pcount */
                    225:   UNSET_FLAG (ri->flags, BGP_INFO_VALID);
                    226: }
                    227: 
                    228: /* undo the effects of a previous call to bgp_info_delete; typically
                    229:    called when a route is deleted and then quickly re-added before the
                    230:    deletion has been processed */
                    231: static void
                    232: bgp_info_restore (struct bgp_node *rn, struct bgp_info *ri)
                    233: {
                    234:   bgp_info_unset_flag (rn, ri, BGP_INFO_REMOVED);
                    235:   /* unset of previous already took care of pcount */
                    236:   SET_FLAG (ri->flags, BGP_INFO_VALID);
                    237: }
                    238: 
                    239: /* Adjust pcount as required */   
                    240: static void
                    241: bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri)
                    242: {
1.1.1.3   misho     243:   struct bgp_table *table;
                    244: 
                    245:   assert (rn && bgp_node_table (rn));
1.1       misho     246:   assert (ri && ri->peer && ri->peer->bgp);
                    247: 
1.1.1.3   misho     248:   table = bgp_node_table (rn);
                    249: 
1.1       misho     250:   /* Ignore 'pcount' for RS-client tables */
1.1.1.3   misho     251:   if (table->type != BGP_TABLE_MAIN
1.1       misho     252:       || ri->peer == ri->peer->bgp->peer_self)
                    253:     return;
                    254:     
                    255:   if (BGP_INFO_HOLDDOWN (ri)
                    256:       && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
                    257:     {
                    258:           
                    259:       UNSET_FLAG (ri->flags, BGP_INFO_COUNTED);
                    260:       
                    261:       /* slight hack, but more robust against errors. */
1.1.1.3   misho     262:       if (ri->peer->pcount[table->afi][table->safi])
                    263:         ri->peer->pcount[table->afi][table->safi]--;
1.1       misho     264:       else
                    265:         {
                    266:           zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
                    267:                      __func__, ri->peer->host);
                    268:           zlog_backtrace (LOG_WARNING);
                    269:           zlog_warn ("%s: Please report to Quagga bugzilla", __func__);
                    270:         }      
                    271:     }
                    272:   else if (!BGP_INFO_HOLDDOWN (ri) 
                    273:            && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
                    274:     {
                    275:       SET_FLAG (ri->flags, BGP_INFO_COUNTED);
1.1.1.3   misho     276:       ri->peer->pcount[table->afi][table->safi]++;
1.1       misho     277:     }
                    278: }
                    279: 
                    280: 
                    281: /* Set/unset bgp_info flags, adjusting any other state as needed.
                    282:  * This is here primarily to keep prefix-count in check.
                    283:  */
                    284: void
                    285: bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag)
                    286: {
                    287:   SET_FLAG (ri->flags, flag);
                    288:   
                    289:   /* early bath if we know it's not a flag that changes useability state */
                    290:   if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE))
                    291:     return;
                    292:   
                    293:   bgp_pcount_adjust (rn, ri);
                    294: }
                    295: 
                    296: void
                    297: bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag)
                    298: {
                    299:   UNSET_FLAG (ri->flags, flag);
                    300:   
                    301:   /* early bath if we know it's not a flag that changes useability state */
                    302:   if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE))
                    303:     return;
                    304:   
                    305:   bgp_pcount_adjust (rn, ri);
                    306: }
                    307: 
                    308: /* Get MED value.  If MED value is missing and "bgp bestpath
                    309:    missing-as-worst" is specified, treat it as the worst value. */
                    310: static u_int32_t
                    311: bgp_med_value (struct attr *attr, struct bgp *bgp)
                    312: {
                    313:   if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
                    314:     return attr->med;
                    315:   else
                    316:     {
                    317:       if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST))
                    318:        return BGP_MED_MAX;
                    319:       else
                    320:        return 0;
                    321:     }
                    322: }
                    323: 
1.1.1.4 ! misho     324: /* Compare two bgp route entity.  Return -1 if new is preferred, 1 if exist
        !           325:  * is preferred, or 0 if they are the same (usually will only occur if
        !           326:  * multipath is enabled */
1.1       misho     327: static int
1.1.1.2   misho     328: bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
1.1.1.4 ! misho     329:               afi_t afi, safi_t safi)
1.1       misho     330: {
1.1.1.3   misho     331:   struct attr *newattr, *existattr;
                    332:   struct attr_extra *newattre, *existattre;
                    333:   bgp_peer_sort_t new_sort;
                    334:   bgp_peer_sort_t exist_sort;
1.1       misho     335:   u_int32_t new_pref;
                    336:   u_int32_t exist_pref;
                    337:   u_int32_t new_med;
                    338:   u_int32_t exist_med;
1.1.1.3   misho     339:   u_int32_t new_weight;
                    340:   u_int32_t exist_weight;
                    341:   uint32_t newm, existm;
1.1       misho     342:   struct in_addr new_id;
                    343:   struct in_addr exist_id;
                    344:   int new_cluster;
                    345:   int exist_cluster;
1.1.1.3   misho     346:   int internal_as_route;
                    347:   int confed_as_route;
1.1       misho     348:   int ret;
1.1.1.2   misho     349: 
1.1       misho     350:   /* 0. Null check. */
                    351:   if (new == NULL)
                    352:     return 1;
1.1.1.4 ! misho     353:   if (exist == NULL)
        !           354:     return -1;
1.1       misho     355: 
1.1.1.3   misho     356:   newattr = new->attr;
                    357:   existattr = exist->attr;
                    358:   newattre = newattr->extra;
                    359:   existattre = existattr->extra;
                    360: 
1.1       misho     361:   /* 1. Weight check. */
1.1.1.3   misho     362:   new_weight = exist_weight = 0;
                    363: 
                    364:   if (newattre)
                    365:     new_weight = newattre->weight;
                    366:   if (existattre)
                    367:     exist_weight = existattre->weight;
                    368: 
1.1       misho     369:   if (new_weight > exist_weight)
1.1.1.4 ! misho     370:     return -1;
1.1       misho     371:   if (new_weight < exist_weight)
1.1.1.4 ! misho     372:     return 1;
1.1       misho     373: 
                    374:   /* 2. Local preference check. */
1.1.1.3   misho     375:   new_pref = exist_pref = bgp->default_local_pref;
                    376: 
                    377:   if (newattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
                    378:     new_pref = newattr->local_pref;
                    379:   if (existattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
                    380:     exist_pref = existattr->local_pref;
1.1       misho     381: 
                    382:   if (new_pref > exist_pref)
1.1.1.4 ! misho     383:     return -1;
1.1       misho     384:   if (new_pref < exist_pref)
1.1.1.4 ! misho     385:     return 1;
1.1       misho     386: 
1.1.1.3   misho     387:   /* 3. Local route check. We prefer:
                    388:    *  - BGP_ROUTE_STATIC
                    389:    *  - BGP_ROUTE_AGGREGATE
                    390:    *  - BGP_ROUTE_REDISTRIBUTE
                    391:    */
                    392:   if (! (new->sub_type == BGP_ROUTE_NORMAL))
1.1.1.4 ! misho     393:      return -1;
1.1.1.3   misho     394:   if (! (exist->sub_type == BGP_ROUTE_NORMAL))
1.1.1.4 ! misho     395:      return 1;
1.1       misho     396: 
                    397:   /* 4. AS path length check. */
                    398:   if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE))
                    399:     {
1.1.1.3   misho     400:       int exist_hops = aspath_count_hops (existattr->aspath);
                    401:       int exist_confeds = aspath_count_confeds (existattr->aspath);
1.1       misho     402:       
                    403:       if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED))
                    404:        {
                    405:          int aspath_hops;
                    406:          
1.1.1.3   misho     407:          aspath_hops = aspath_count_hops (newattr->aspath);
                    408:           aspath_hops += aspath_count_confeds (newattr->aspath);
1.1       misho     409:           
                    410:          if ( aspath_hops < (exist_hops + exist_confeds))
1.1.1.4 ! misho     411:            return -1;
1.1       misho     412:          if ( aspath_hops > (exist_hops + exist_confeds))
1.1.1.4 ! misho     413:            return 1;
1.1       misho     414:        }
                    415:       else
                    416:        {
1.1.1.3   misho     417:          int newhops = aspath_count_hops (newattr->aspath);
1.1       misho     418:          
                    419:          if (newhops < exist_hops)
1.1.1.4 ! misho     420:            return -1;
1.1       misho     421:           if (newhops > exist_hops)
1.1.1.4 ! misho     422:            return 1;
1.1       misho     423:        }
                    424:     }
                    425: 
                    426:   /* 5. Origin check. */
1.1.1.3   misho     427:   if (newattr->origin < existattr->origin)
1.1.1.4 ! misho     428:     return -1;
1.1.1.3   misho     429:   if (newattr->origin > existattr->origin)
1.1.1.4 ! misho     430:     return 1;
1.1       misho     431: 
                    432:   /* 6. MED check. */
1.1.1.3   misho     433:   internal_as_route = (aspath_count_hops (newattr->aspath) == 0
                    434:                      && aspath_count_hops (existattr->aspath) == 0);
                    435:   confed_as_route = (aspath_count_confeds (newattr->aspath) > 0
                    436:                    && aspath_count_confeds (existattr->aspath) > 0
                    437:                    && aspath_count_hops (newattr->aspath) == 0
                    438:                    && aspath_count_hops (existattr->aspath) == 0);
1.1       misho     439:   
                    440:   if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED)
                    441:       || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED)
                    442:         && confed_as_route)
1.1.1.3   misho     443:       || aspath_cmp_left (newattr->aspath, existattr->aspath)
                    444:       || aspath_cmp_left_confed (newattr->aspath, existattr->aspath)
1.1       misho     445:       || internal_as_route)
                    446:     {
                    447:       new_med = bgp_med_value (new->attr, bgp);
                    448:       exist_med = bgp_med_value (exist->attr, bgp);
                    449: 
                    450:       if (new_med < exist_med)
1.1.1.4 ! misho     451:        return -1;
1.1       misho     452:       if (new_med > exist_med)
1.1.1.4 ! misho     453:        return 1;
1.1       misho     454:     }
                    455: 
                    456:   /* 7. Peer type check. */
1.1.1.3   misho     457:   new_sort = new->peer->sort;
                    458:   exist_sort = exist->peer->sort;
                    459: 
                    460:   if (new_sort == BGP_PEER_EBGP
                    461:       && (exist_sort == BGP_PEER_IBGP || exist_sort == BGP_PEER_CONFED))
1.1.1.4 ! misho     462:     return -1;
1.1.1.3   misho     463:   if (exist_sort == BGP_PEER_EBGP
                    464:       && (new_sort == BGP_PEER_IBGP || new_sort == BGP_PEER_CONFED))
1.1.1.4 ! misho     465:     return 1;
1.1       misho     466: 
                    467:   /* 8. IGP metric check. */
1.1.1.3   misho     468:   newm = existm = 0;
                    469: 
                    470:   if (new->extra)
                    471:     newm = new->extra->igpmetric;
                    472:   if (exist->extra)
                    473:     existm = exist->extra->igpmetric;
                    474: 
1.1.1.2   misho     475:   if (newm < existm)
1.1.1.4 ! misho     476:     return -1;
1.1.1.2   misho     477:   if (newm > existm)
1.1.1.4 ! misho     478:     return 1;
1.1       misho     479: 
                    480:   /* 9. Maximum path check. */
1.1.1.4 ! misho     481:   if (bgp_mpath_is_configured (bgp, afi, safi))
1.1.1.2   misho     482:     {
1.1.1.4 ! misho     483:       if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX))
        !           484:         {
        !           485:           /*
        !           486:            * For the two paths, all comparison steps till IGP metric
        !           487:            * have succeeded - including AS_PATH hop count. Since 'bgp
        !           488:            * bestpath as-path multipath-relax' knob is on, we don't need
        !           489:            * an exact match of AS_PATH. Thus, mark the paths are equal.
        !           490:            * That will trigger both these paths to get into the multipath
        !           491:            * array.
        !           492:            */
        !           493:           return 0;
        !           494:         }
        !           495:       else if (new->peer->sort == BGP_PEER_IBGP)
        !           496:         {
        !           497:           if (aspath_cmp (new->attr->aspath, exist->attr->aspath))
        !           498:             return 0;
        !           499:         }
1.1.1.2   misho     500:       else if (new->peer->as == exist->peer->as)
1.1.1.4 ! misho     501:         return 0;
1.1.1.2   misho     502:     }
1.1       misho     503: 
                    504:   /* 10. If both paths are external, prefer the path that was received
                    505:      first (the oldest one).  This step minimizes route-flap, since a
                    506:      newer path won't displace an older one, even if it was the
                    507:      preferred route based on the additional decision criteria below.  */
                    508:   if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID)
1.1.1.3   misho     509:       && new_sort == BGP_PEER_EBGP
                    510:       && exist_sort == BGP_PEER_EBGP)
1.1       misho     511:     {
                    512:       if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED))
1.1.1.4 ! misho     513:        return -1;
1.1       misho     514:       if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED))
1.1.1.4 ! misho     515:        return 1;
1.1       misho     516:     }
                    517: 
1.1.1.4 ! misho     518:   /* 11. Router-ID comparision. */
        !           519:   /* If one of the paths is "stale", the corresponding peer router-id will
        !           520:    * be 0 and would always win over the other path. If originator id is
        !           521:    * used for the comparision, it will decide which path is better.
        !           522:    */
1.1.1.3   misho     523:   if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
                    524:     new_id.s_addr = newattre->originator_id.s_addr;
1.1       misho     525:   else
                    526:     new_id.s_addr = new->peer->remote_id.s_addr;
1.1.1.3   misho     527:   if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
                    528:     exist_id.s_addr = existattre->originator_id.s_addr;
1.1       misho     529:   else
                    530:     exist_id.s_addr = exist->peer->remote_id.s_addr;
                    531: 
                    532:   if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr))
1.1.1.4 ! misho     533:     return -1;
1.1       misho     534:   if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr))
1.1.1.4 ! misho     535:     return 1;
1.1       misho     536: 
                    537:   /* 12. Cluster length comparision. */
1.1.1.3   misho     538:   new_cluster = exist_cluster = 0;
                    539: 
                    540:   if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
                    541:     new_cluster = newattre->cluster->length;
                    542:   if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
                    543:     exist_cluster = existattre->cluster->length;
1.1       misho     544: 
                    545:   if (new_cluster < exist_cluster)
1.1.1.4 ! misho     546:     return -1;
1.1       misho     547:   if (new_cluster > exist_cluster)
1.1.1.4 ! misho     548:     return 1;
1.1       misho     549: 
                    550:   /* 13. Neighbor address comparision. */
1.1.1.4 ! misho     551:   /* Do this only if neither path is "stale" as stale paths do not have
        !           552:    * valid peer information (as the connection may or may not be up).
        !           553:    */
        !           554:   if (CHECK_FLAG (exist->flags, BGP_INFO_STALE))
        !           555:     return -1;
        !           556:   if (CHECK_FLAG (new->flags, BGP_INFO_STALE))
        !           557:     return 1;
        !           558:   /* locally configured routes to advertise do not have su_remote */
        !           559:   if (new->peer->su_remote == NULL)
        !           560:     return 1;
        !           561:   if (exist->peer->su_remote == NULL)
        !           562:     return -1;
        !           563:   
1.1       misho     564:   ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote);
                    565: 
                    566:   if (ret == 1)
                    567:     return 1;
1.1.1.4 ! misho     568:   if (ret == -1)
        !           569:     return -1;
1.1       misho     570: 
1.1.1.4 ! misho     571:   return -1;
1.1       misho     572: }
                    573: 
                    574: static enum filter_type
                    575: bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr,
                    576:                  afi_t afi, safi_t safi)
                    577: {
                    578:   struct bgp_filter *filter;
                    579: 
                    580:   filter = &peer->filter[afi][safi];
                    581: 
                    582: #define FILTER_EXIST_WARN(F,f,filter) \
                    583:   if (BGP_DEBUG (update, UPDATE_IN) \
                    584:       && !(F ## _IN (filter))) \
                    585:     plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \
                    586:                peer->host, #f, F ## _IN_NAME(filter));
                    587:   
                    588:   if (DISTRIBUTE_IN_NAME (filter)) {
                    589:     FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter);
                    590:       
                    591:     if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY)
                    592:       return FILTER_DENY;
                    593:   }
                    594: 
                    595:   if (PREFIX_LIST_IN_NAME (filter)) {
                    596:     FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter);
                    597:     
                    598:     if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY)
                    599:       return FILTER_DENY;
                    600:   }
                    601:   
                    602:   if (FILTER_LIST_IN_NAME (filter)) {
                    603:     FILTER_EXIST_WARN(FILTER_LIST, as, filter);
                    604:     
                    605:     if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY)
                    606:       return FILTER_DENY;
                    607:   }
                    608:   
                    609:   return FILTER_PERMIT;
                    610: #undef FILTER_EXIST_WARN
                    611: }
                    612: 
                    613: static enum filter_type
                    614: bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr,
                    615:                   afi_t afi, safi_t safi)
                    616: {
                    617:   struct bgp_filter *filter;
                    618: 
                    619:   filter = &peer->filter[afi][safi];
                    620: 
                    621: #define FILTER_EXIST_WARN(F,f,filter) \
                    622:   if (BGP_DEBUG (update, UPDATE_OUT) \
                    623:       && !(F ## _OUT (filter))) \
                    624:     plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \
                    625:                peer->host, #f, F ## _OUT_NAME(filter));
                    626: 
                    627:   if (DISTRIBUTE_OUT_NAME (filter)) {
                    628:     FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter);
                    629:     
                    630:     if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY)
                    631:       return FILTER_DENY;
                    632:   }
                    633: 
                    634:   if (PREFIX_LIST_OUT_NAME (filter)) {
                    635:     FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter);
                    636:     
                    637:     if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY)
                    638:       return FILTER_DENY;
                    639:   }
                    640: 
                    641:   if (FILTER_LIST_OUT_NAME (filter)) {
                    642:     FILTER_EXIST_WARN(FILTER_LIST, as, filter);
                    643:     
                    644:     if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY)
                    645:       return FILTER_DENY;
                    646:   }
                    647: 
                    648:   return FILTER_PERMIT;
                    649: #undef FILTER_EXIST_WARN
                    650: }
                    651: 
                    652: /* If community attribute includes no_export then return 1. */
                    653: static int
                    654: bgp_community_filter (struct peer *peer, struct attr *attr)
                    655: {
                    656:   if (attr->community)
                    657:     {
                    658:       /* NO_ADVERTISE check. */
                    659:       if (community_include (attr->community, COMMUNITY_NO_ADVERTISE))
                    660:        return 1;
                    661: 
                    662:       /* NO_EXPORT check. */
1.1.1.3   misho     663:       if (peer->sort == BGP_PEER_EBGP &&
1.1       misho     664:          community_include (attr->community, COMMUNITY_NO_EXPORT))
                    665:        return 1;
                    666: 
                    667:       /* NO_EXPORT_SUBCONFED check. */
1.1.1.3   misho     668:       if (peer->sort == BGP_PEER_EBGP
                    669:          || peer->sort == BGP_PEER_CONFED)
1.1       misho     670:        if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED))
                    671:          return 1;
                    672:     }
                    673:   return 0;
                    674: }
                    675: 
                    676: /* Route reflection loop check.  */
                    677: static int
                    678: bgp_cluster_filter (struct peer *peer, struct attr *attr)
                    679: {
                    680:   struct in_addr cluster_id;
                    681: 
                    682:   if (attr->extra && attr->extra->cluster)
                    683:     {
                    684:       if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID)
                    685:        cluster_id = peer->bgp->cluster_id;
                    686:       else
                    687:        cluster_id = peer->bgp->router_id;
                    688:       
                    689:       if (cluster_loop_check (attr->extra->cluster, cluster_id))
                    690:        return 1;
                    691:     }
                    692:   return 0;
                    693: }
1.1.1.4 ! misho     694: 
1.1       misho     695: static int
                    696: bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr,
                    697:                    afi_t afi, safi_t safi)
                    698: {
                    699:   struct bgp_filter *filter;
                    700:   struct bgp_info info;
                    701:   route_map_result_t ret;
                    702: 
                    703:   filter = &peer->filter[afi][safi];
                    704: 
                    705:   /* Apply default weight value. */
                    706:   if (peer->weight)
                    707:     (bgp_attr_extra_get (attr))->weight = peer->weight;
                    708: 
                    709:   /* Route map apply. */
                    710:   if (ROUTE_MAP_IN_NAME (filter))
                    711:     {
                    712:       /* Duplicate current value to new strucutre for modification. */
                    713:       info.peer = peer;
                    714:       info.attr = attr;
                    715: 
                    716:       SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); 
                    717: 
                    718:       /* Apply BGP route map to the attribute. */
                    719:       ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info);
                    720: 
                    721:       peer->rmap_type = 0;
                    722: 
                    723:       if (ret == RMAP_DENYMATCH)
1.1.1.4 ! misho     724:        /* caller has multiple error paths with bgp_attr_flush() */
        !           725:        return RMAP_DENY;
1.1       misho     726:     }
                    727:   return RMAP_PERMIT;
                    728: }
1.1.1.4 ! misho     729: 
1.1       misho     730: static int
                    731: bgp_export_modifier (struct peer *rsclient, struct peer *peer,
                    732:         struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
                    733: {
                    734:   struct bgp_filter *filter;
                    735:   struct bgp_info info;
                    736:   route_map_result_t ret;
                    737: 
                    738:   filter = &peer->filter[afi][safi];
                    739: 
                    740:   /* Route map apply. */
                    741:   if (ROUTE_MAP_EXPORT_NAME (filter))
                    742:     {
                    743:       /* Duplicate current value to new strucutre for modification. */
                    744:       info.peer = rsclient;
                    745:       info.attr = attr;
                    746: 
                    747:       SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
                    748: 
                    749:       /* Apply BGP route map to the attribute. */
                    750:       ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info);
                    751: 
                    752:       rsclient->rmap_type = 0;
                    753: 
                    754:       if (ret == RMAP_DENYMATCH)
                    755:         {
                    756:           /* Free newly generated AS path and community by route-map. */
                    757:           bgp_attr_flush (attr);
                    758:           return RMAP_DENY;
                    759:         }
                    760:     }
                    761:   return RMAP_PERMIT;
                    762: }
                    763: 
                    764: static int
                    765: bgp_import_modifier (struct peer *rsclient, struct peer *peer,
                    766:         struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
                    767: {
                    768:   struct bgp_filter *filter;
                    769:   struct bgp_info info;
                    770:   route_map_result_t ret;
                    771: 
                    772:   filter = &rsclient->filter[afi][safi];
                    773: 
                    774:   /* Apply default weight value. */
                    775:   if (peer->weight)
                    776:     (bgp_attr_extra_get (attr))->weight = peer->weight;
                    777: 
                    778:   /* Route map apply. */
                    779:   if (ROUTE_MAP_IMPORT_NAME (filter))
                    780:     {
                    781:       /* Duplicate current value to new strucutre for modification. */
                    782:       info.peer = peer;
                    783:       info.attr = attr;
                    784: 
                    785:       SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT);
                    786: 
                    787:       /* Apply BGP route map to the attribute. */
                    788:       ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info);
                    789: 
                    790:       peer->rmap_type = 0;
                    791: 
                    792:       if (ret == RMAP_DENYMATCH)
                    793:         {
                    794:           /* Free newly generated AS path and community by route-map. */
                    795:           bgp_attr_flush (attr);
                    796:           return RMAP_DENY;
                    797:         }
                    798:     }
                    799:   return RMAP_PERMIT;
                    800: }
1.1.1.4 ! misho     801: 
1.1       misho     802: static int
                    803: bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p,
                    804:                    struct attr *attr, afi_t afi, safi_t safi)
                    805: {
                    806:   int ret;
                    807:   char buf[SU_ADDRSTRLEN];
                    808:   struct bgp_filter *filter;
                    809:   struct peer *from;
                    810:   struct bgp *bgp;
                    811:   int transparent;
                    812:   int reflect;
1.1.1.2   misho     813:   struct attr *riattr;
1.1       misho     814: 
                    815:   from = ri->peer;
                    816:   filter = &peer->filter[afi][safi];
                    817:   bgp = peer->bgp;
1.1.1.2   misho     818:   riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr;
1.1       misho     819:   
                    820:   if (DISABLE_BGP_ANNOUNCE)
                    821:     return 0;
                    822: 
                    823:   /* Do not send announces to RS-clients from the 'normal' bgp_table. */
                    824:   if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
                    825:     return 0;
                    826: 
                    827:   /* Do not send back route to sender. */
                    828:   if (from == peer)
                    829:     return 0;
                    830: 
                    831:   /* Aggregate-address suppress check. */
                    832:   if (ri->extra && ri->extra->suppress)
                    833:     if (! UNSUPPRESS_MAP_NAME (filter))
                    834:       return 0;
                    835: 
                    836:   /* Default route check.  */
                    837:   if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
                    838:     {
                    839:       if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
                    840:        return 0;
                    841:       else if (p->family == AF_INET6 && p->prefixlen == 0)
                    842:        return 0;
                    843:     }
                    844: 
                    845:   /* Transparency check. */
                    846:   if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)
                    847:       && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
                    848:     transparent = 1;
                    849:   else
                    850:     transparent = 0;
                    851: 
                    852:   /* If community is not disabled check the no-export and local. */
1.1.1.2   misho     853:   if (! transparent && bgp_community_filter (peer, riattr))
1.1       misho     854:     return 0;
                    855: 
                    856:   /* If the attribute has originator-id and it is same as remote
                    857:      peer's id. */
1.1.1.2   misho     858:   if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
1.1       misho     859:     {
1.1.1.2   misho     860:       if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id))
1.1       misho     861:        {
                    862:          if (BGP_DEBUG (filter, FILTER))  
                    863:            zlog (peer->log, LOG_DEBUG,
                    864:                  "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
                    865:                  peer->host,
                    866:                  inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
                    867:                  p->prefixlen);
                    868:          return 0;
                    869:        }
                    870:     }
                    871:  
                    872:   /* ORF prefix-list filter check */
                    873:   if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
                    874:       && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
                    875:          || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)))
                    876:     if (peer->orf_plist[afi][safi])
                    877:       {
                    878:        if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY)
                    879:           return 0;
                    880:       }
                    881: 
                    882:   /* Output filter check. */
1.1.1.2   misho     883:   if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY)
1.1       misho     884:     {
                    885:       if (BGP_DEBUG (filter, FILTER))
                    886:        zlog (peer->log, LOG_DEBUG,
                    887:              "%s [Update:SEND] %s/%d is filtered",
                    888:              peer->host,
                    889:              inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
                    890:              p->prefixlen);
                    891:       return 0;
                    892:     }
                    893: 
                    894: #ifdef BGP_SEND_ASPATH_CHECK
                    895:   /* AS path loop check. */
1.1.1.2   misho     896:   if (aspath_loop_check (riattr->aspath, peer->as))
1.1       misho     897:     {
                    898:       if (BGP_DEBUG (filter, FILTER))  
                    899:         zlog (peer->log, LOG_DEBUG, 
                    900:              "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
                    901:              peer->host, peer->as);
                    902:       return 0;
                    903:     }
                    904: #endif /* BGP_SEND_ASPATH_CHECK */
                    905: 
                    906:   /* If we're a CONFED we need to loop check the CONFED ID too */
                    907:   if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
                    908:     {
1.1.1.2   misho     909:       if (aspath_loop_check(riattr->aspath, bgp->confed_id))
1.1       misho     910:        {
                    911:          if (BGP_DEBUG (filter, FILTER))  
                    912:            zlog (peer->log, LOG_DEBUG, 
                    913:                  "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
                    914:                  peer->host,
                    915:                  bgp->confed_id);
                    916:          return 0;
                    917:        }      
                    918:     }
                    919: 
                    920:   /* Route-Reflect check. */
1.1.1.3   misho     921:   if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP)
1.1       misho     922:     reflect = 1;
                    923:   else
                    924:     reflect = 0;
                    925: 
                    926:   /* IBGP reflection check. */
                    927:   if (reflect)
                    928:     {
                    929:       /* A route from a Client peer. */
                    930:       if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
                    931:        {
                    932:          /* Reflect to all the Non-Client peers and also to the
                    933:              Client peers other than the originator.  Originator check
                    934:              is already done.  So there is noting to do. */
                    935:          /* no bgp client-to-client reflection check. */
                    936:          if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT))
                    937:            if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
                    938:              return 0;
                    939:        }
                    940:       else
                    941:        {
                    942:          /* A route from a Non-client peer. Reflect to all other
                    943:             clients. */
                    944:          if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
                    945:            return 0;
                    946:        }
                    947:     }
                    948:   
                    949:   /* For modify attribute, copy it to temporary structure. */
1.1.1.2   misho     950:   bgp_attr_dup (attr, riattr);
1.1       misho     951:   
                    952:   /* If local-preference is not set. */
1.1.1.3   misho     953:   if ((peer->sort == BGP_PEER_IBGP
                    954:        || peer->sort == BGP_PEER_CONFED)
1.1       misho     955:       && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))))
                    956:     {
                    957:       attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF);
                    958:       attr->local_pref = bgp->default_local_pref;
                    959:     }
                    960: 
1.1.1.4 ! misho     961:   /* If originator-id is not set and the route is to be reflected,
        !           962:      set the originator id */
        !           963:   if (peer && from && peer->sort == BGP_PEER_IBGP &&
        !           964:       from->sort == BGP_PEER_IBGP &&
        !           965:       (! (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))))
        !           966:     {
        !           967:       attr->extra = bgp_attr_extra_get(attr);
        !           968:       IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id));
        !           969:       SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID);
        !           970:     }
        !           971: 
1.1       misho     972:   /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
1.1.1.3   misho     973:   if (peer->sort == BGP_PEER_EBGP
1.1       misho     974:       && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
                    975:     {
                    976:       if (ri->peer != bgp->peer_self && ! transparent
                    977:          && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
                    978:        attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC));
                    979:     }
                    980: 
1.1.1.4 ! misho     981: 
        !           982: #define NEXTHOP_IS_V4 (\
        !           983:     (safi != SAFI_ENCAP && p->family == AF_INET) || \
        !           984:     (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 4))
        !           985: 
        !           986: #define NEXTHOP_IS_V6 (\
        !           987:     (safi != SAFI_ENCAP && p->family == AF_INET6) || \
        !           988:     (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16))
        !           989: 
1.1       misho     990:   /* next-hop-set */
1.1.1.4 ! misho     991:   if (transparent
        !           992:       || (reflect && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF_ALL))
1.1       misho     993:       || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)
1.1.1.4 ! misho     994:          && ((NEXTHOP_IS_V4 && attr->nexthop.s_addr)
        !           995:              || (NEXTHOP_IS_V6 &&
1.1       misho     996:                   ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
                    997:              )))
                    998:     {
                    999:       /* NEXT-HOP Unchanged. */
                   1000:     }
                   1001:   else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF)
1.1.1.4 ! misho    1002:           || (NEXTHOP_IS_V4 && attr->nexthop.s_addr == 0)
        !          1003:           || (NEXTHOP_IS_V6 &&
1.1       misho    1004:                IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
1.1.1.3   misho    1005:           || (peer->sort == BGP_PEER_EBGP
1.1       misho    1006:               && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0))
                   1007:     {
                   1008:       /* Set IPv4 nexthop. */
1.1.1.4 ! misho    1009:       if (NEXTHOP_IS_V4)
1.1       misho    1010:        {
1.1.1.4 ! misho    1011:          if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
1.1       misho    1012:            memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4,
                   1013:                    IPV4_MAX_BYTELEN);
                   1014:          else
                   1015:            memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
                   1016:        }
                   1017:       /* Set IPv6 nexthop. */
1.1.1.4 ! misho    1018:       if (NEXTHOP_IS_V6)
1.1       misho    1019:        {
                   1020:          /* IPv6 global nexthop must be included. */
                   1021:          memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, 
                   1022:                  IPV6_MAX_BYTELEN);
                   1023:          attr->extra->mp_nexthop_len = 16;
                   1024:        }
                   1025:     }
                   1026: 
1.1.1.4 ! misho    1027:   if (p->family == AF_INET6 && safi != SAFI_ENCAP)
1.1       misho    1028:     {
                   1029:       /* Left nexthop_local unchanged if so configured. */ 
                   1030:       if ( CHECK_FLAG (peer->af_flags[afi][safi], 
                   1031:            PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) )
                   1032:         {
                   1033:           if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) )
                   1034:             attr->extra->mp_nexthop_len=32;
                   1035:           else
                   1036:             attr->extra->mp_nexthop_len=16;
                   1037:         }
                   1038: 
                   1039:       /* Default nexthop_local treatment for non-RS-Clients */
                   1040:       else 
                   1041:         {
                   1042:       /* Link-local address should not be transit to different peer. */
                   1043:       attr->extra->mp_nexthop_len = 16;
                   1044: 
                   1045:       /* Set link-local address for shared network peer. */
                   1046:       if (peer->shared_network 
                   1047:          && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
                   1048:        {
                   1049:          memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, 
                   1050:                  IPV6_MAX_BYTELEN);
                   1051:          attr->extra->mp_nexthop_len = 32;
                   1052:        }
                   1053: 
                   1054:       /* If bgpd act as BGP-4+ route-reflector, do not send link-local
                   1055:         address.*/
                   1056:       if (reflect)
                   1057:        attr->extra->mp_nexthop_len = 16;
                   1058: 
                   1059:       /* If BGP-4+ link-local nexthop is not link-local nexthop. */
                   1060:       if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local))
                   1061:        attr->extra->mp_nexthop_len = 16;
                   1062:     }
                   1063: 
                   1064:     }
                   1065: 
                   1066:   /* If this is EBGP peer and remove-private-AS is set.  */
1.1.1.3   misho    1067:   if (peer->sort == BGP_PEER_EBGP
1.1       misho    1068:       && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
                   1069:       && aspath_private_as_check (attr->aspath))
                   1070:     attr->aspath = aspath_empty_get ();
                   1071: 
                   1072:   /* Route map & unsuppress-map apply. */
                   1073:   if (ROUTE_MAP_OUT_NAME (filter)
                   1074:       || (ri->extra && ri->extra->suppress) )
                   1075:     {
                   1076:       struct bgp_info info;
1.1.1.3   misho    1077:       struct attr dummy_attr;
                   1078:       struct attr_extra dummy_extra;
                   1079: 
                   1080:       dummy_attr.extra = &dummy_extra;
                   1081: 
1.1       misho    1082:       info.peer = peer;
                   1083:       info.attr = attr;
                   1084: 
                   1085:       /* The route reflector is not allowed to modify the attributes
                   1086:         of the reflected IBGP routes. */
1.1.1.3   misho    1087:       if (from->sort == BGP_PEER_IBGP
                   1088:          && peer->sort == BGP_PEER_IBGP)
1.1       misho    1089:        {
                   1090:          bgp_attr_dup (&dummy_attr, attr);
                   1091:          info.attr = &dummy_attr;
                   1092:        }
                   1093: 
                   1094:       SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); 
                   1095: 
                   1096:       if (ri->extra && ri->extra->suppress)
                   1097:        ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info);
                   1098:       else
                   1099:        ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info);
                   1100: 
                   1101:       peer->rmap_type = 0;
1.1.1.3   misho    1102: 
1.1       misho    1103:       if (ret == RMAP_DENYMATCH)
                   1104:        {
                   1105:          bgp_attr_flush (attr);
                   1106:          return 0;
                   1107:        }
                   1108:     }
                   1109:   return 1;
                   1110: }
                   1111: 
                   1112: static int
                   1113: bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient,
                   1114:         struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
                   1115: {
                   1116:   int ret;
                   1117:   char buf[SU_ADDRSTRLEN];
                   1118:   struct bgp_filter *filter;
                   1119:   struct bgp_info info;
                   1120:   struct peer *from;
1.1.1.2   misho    1121:   struct attr *riattr;
1.1       misho    1122: 
                   1123:   from = ri->peer;
                   1124:   filter = &rsclient->filter[afi][safi];
1.1.1.2   misho    1125:   riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr;
1.1       misho    1126: 
                   1127:   if (DISABLE_BGP_ANNOUNCE)
                   1128:     return 0;
                   1129: 
                   1130:   /* Do not send back route to sender. */
                   1131:   if (from == rsclient)
                   1132:     return 0;
                   1133: 
                   1134:   /* Aggregate-address suppress check. */
                   1135:   if (ri->extra && ri->extra->suppress)
                   1136:     if (! UNSUPPRESS_MAP_NAME (filter))
                   1137:       return 0;
                   1138: 
                   1139:   /* Default route check.  */
                   1140:   if (CHECK_FLAG (rsclient->af_sflags[afi][safi],
                   1141:           PEER_STATUS_DEFAULT_ORIGINATE))
                   1142:     {
                   1143:       if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
                   1144:         return 0;
                   1145:       else if (p->family == AF_INET6 && p->prefixlen == 0)
                   1146:         return 0;
                   1147:     }
                   1148: 
                   1149:   /* If the attribute has originator-id and it is same as remote
                   1150:      peer's id. */
1.1.1.2   misho    1151:   if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
1.1       misho    1152:     {
                   1153:       if (IPV4_ADDR_SAME (&rsclient->remote_id, 
1.1.1.2   misho    1154:                           &riattr->extra->originator_id))
1.1       misho    1155:         {
                   1156:          if (BGP_DEBUG (filter, FILTER))
                   1157:            zlog (rsclient->log, LOG_DEBUG,
                   1158:                  "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
                   1159:                  rsclient->host,
                   1160:                  inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
                   1161:                  p->prefixlen);
                   1162:          return 0;
                   1163:        }
                   1164:     }
                   1165: 
                   1166:   /* ORF prefix-list filter check */
                   1167:   if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
                   1168:       && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
                   1169:          || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)))
                   1170:     if (rsclient->orf_plist[afi][safi])
                   1171:       {
                   1172:        if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY)
                   1173:           return 0;
                   1174:       }
                   1175: 
                   1176:   /* Output filter check. */
1.1.1.2   misho    1177:   if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY)
1.1       misho    1178:     {
                   1179:       if (BGP_DEBUG (filter, FILTER))
                   1180:        zlog (rsclient->log, LOG_DEBUG,
                   1181:              "%s [Update:SEND] %s/%d is filtered",
                   1182:              rsclient->host,
                   1183:              inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
                   1184:              p->prefixlen);
                   1185:       return 0;
                   1186:     }
                   1187: 
                   1188: #ifdef BGP_SEND_ASPATH_CHECK
                   1189:   /* AS path loop check. */
1.1.1.2   misho    1190:   if (aspath_loop_check (riattr->aspath, rsclient->as))
1.1       misho    1191:     {
                   1192:       if (BGP_DEBUG (filter, FILTER))
                   1193:         zlog (rsclient->log, LOG_DEBUG,
                   1194:              "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
                   1195:              rsclient->host, rsclient->as);
                   1196:       return 0;
                   1197:     }
                   1198: #endif /* BGP_SEND_ASPATH_CHECK */
                   1199: 
                   1200:   /* For modify attribute, copy it to temporary structure. */
1.1.1.2   misho    1201:   bgp_attr_dup (attr, riattr);
1.1       misho    1202: 
                   1203:   /* next-hop-set */
                   1204:   if ((p->family == AF_INET && attr->nexthop.s_addr == 0)
                   1205:           || (p->family == AF_INET6 &&
                   1206:               IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
                   1207:      )
                   1208:   {
                   1209:     /* Set IPv4 nexthop. */
                   1210:     if (p->family == AF_INET)
                   1211:       {
1.1.1.4 ! misho    1212:         if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
1.1       misho    1213:           memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4,
                   1214:                   IPV4_MAX_BYTELEN);
                   1215:         else
                   1216:           memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN);
                   1217:       }
                   1218:     /* Set IPv6 nexthop. */
                   1219:     if (p->family == AF_INET6)
                   1220:       {
                   1221:         /* IPv6 global nexthop must be included. */
                   1222:         memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global,
                   1223:                 IPV6_MAX_BYTELEN);
                   1224:         attr->extra->mp_nexthop_len = 16;
                   1225:       }
                   1226:   }
                   1227: 
                   1228:   if (p->family == AF_INET6)
                   1229:     {
                   1230:       struct attr_extra *attre = attr->extra;
1.1.1.3   misho    1231: 
1.1       misho    1232:       /* Left nexthop_local unchanged if so configured. */
                   1233:       if ( CHECK_FLAG (rsclient->af_flags[afi][safi], 
                   1234:            PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) )
                   1235:         {
                   1236:           if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) )
                   1237:             attre->mp_nexthop_len=32;
                   1238:           else
                   1239:             attre->mp_nexthop_len=16;
                   1240:         }
                   1241:         
                   1242:       /* Default nexthop_local treatment for RS-Clients */
                   1243:       else 
                   1244:         { 
                   1245:           /* Announcer and RS-Client are both in the same network */      
                   1246:           if (rsclient->shared_network && from->shared_network &&
                   1247:               (rsclient->ifindex == from->ifindex))
                   1248:             {
                   1249:               if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) )
                   1250:                 attre->mp_nexthop_len=32;
                   1251:               else
                   1252:                 attre->mp_nexthop_len=16;
                   1253:             }
                   1254: 
                   1255:           /* Set link-local address for shared network peer. */
                   1256:           else if (rsclient->shared_network
                   1257:               && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local))
                   1258:             {
                   1259:               memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local,
                   1260:                       IPV6_MAX_BYTELEN);
                   1261:               attre->mp_nexthop_len = 32;
                   1262:             }
                   1263: 
                   1264:           else
                   1265:             attre->mp_nexthop_len = 16;
                   1266:         }
                   1267: 
                   1268:     }
                   1269: 
                   1270:   /* If this is EBGP peer and remove-private-AS is set.  */
1.1.1.3   misho    1271:   if (rsclient->sort == BGP_PEER_EBGP
1.1       misho    1272:       && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
                   1273:       && aspath_private_as_check (attr->aspath))
                   1274:     attr->aspath = aspath_empty_get ();
                   1275: 
                   1276:   /* Route map & unsuppress-map apply. */
                   1277:   if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) )
                   1278:     {
                   1279:       info.peer = rsclient;
                   1280:       info.attr = attr;
                   1281: 
                   1282:       SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT);
                   1283: 
                   1284:       if (ri->extra && ri->extra->suppress)
                   1285:         ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info);
                   1286:       else
                   1287:         ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info);
                   1288: 
                   1289:       rsclient->rmap_type = 0;
                   1290: 
                   1291:       if (ret == RMAP_DENYMATCH)
                   1292:        {
                   1293:          bgp_attr_flush (attr);
                   1294:          return 0;
                   1295:        }
                   1296:     }
                   1297: 
                   1298:   return 1;
                   1299: }
                   1300: 
                   1301: struct bgp_info_pair
                   1302: {
                   1303:   struct bgp_info *old;
                   1304:   struct bgp_info *new;
                   1305: };
                   1306: 
                   1307: static void
1.1.1.2   misho    1308: bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
1.1.1.4 ! misho    1309:                    struct bgp_info_pair *result,
        !          1310:                    afi_t afi, safi_t safi)
1.1       misho    1311: {
                   1312:   struct bgp_info *new_select;
                   1313:   struct bgp_info *old_select;
                   1314:   struct bgp_info *ri;
                   1315:   struct bgp_info *ri1;
                   1316:   struct bgp_info *ri2;
                   1317:   struct bgp_info *nextri = NULL;
1.1.1.4 ! misho    1318:   int cmpret, do_mpath;
1.1.1.2   misho    1319:   struct list mp_list;
1.1.1.4 ! misho    1320:     
        !          1321:   result->old = result->new = NULL;
        !          1322:   
        !          1323:   if (rn->info == NULL)
        !          1324:     {
        !          1325:       char buf[PREFIX_STRLEN];
        !          1326:       zlog_warn ("%s: Called for route_node %s with no routing entries!",
        !          1327:                  __func__,
        !          1328:                  prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf)));
        !          1329:       return;
        !          1330:     }
        !          1331:   
1.1.1.2   misho    1332:   bgp_mp_list_init (&mp_list);
1.1.1.4 ! misho    1333:   do_mpath = bgp_mpath_is_configured (bgp, afi, safi);
1.1.1.2   misho    1334: 
1.1       misho    1335:   /* bgp deterministic-med */
                   1336:   new_select = NULL;
                   1337:   if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
                   1338:     for (ri1 = rn->info; ri1; ri1 = ri1->next)
                   1339:       {
                   1340:        if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK))
                   1341:          continue;
                   1342:        if (BGP_INFO_HOLDDOWN (ri1))
                   1343:          continue;
1.1.1.4 ! misho    1344:         if (ri1->peer && ri1->peer != bgp->peer_self)
        !          1345:           if (ri1->peer->status != Established)
        !          1346:             continue;
1.1       misho    1347: 
                   1348:        new_select = ri1;
1.1.1.2   misho    1349:        if (do_mpath)
                   1350:          bgp_mp_list_add (&mp_list, ri1);
                   1351:        old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL;
1.1       misho    1352:        if (ri1->next)
                   1353:          for (ri2 = ri1->next; ri2; ri2 = ri2->next)
                   1354:            {
                   1355:              if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK))
                   1356:                continue;
                   1357:              if (BGP_INFO_HOLDDOWN (ri2))
                   1358:                continue;
1.1.1.4 ! misho    1359:               if (ri2->peer &&
        !          1360:                   ri2->peer != bgp->peer_self &&
        !          1361:                   !CHECK_FLAG (ri2->peer->sflags, PEER_STATUS_NSF_WAIT))
        !          1362:                 if (ri2->peer->status != Established)
        !          1363:                   continue;
1.1       misho    1364: 
                   1365:              if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath)
                   1366:                  || aspath_cmp_left_confed (ri1->attr->aspath,
                   1367:                                             ri2->attr->aspath))
                   1368:                {
1.1.1.2   misho    1369:                  if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED))
                   1370:                    old_select = ri2;
1.1.1.4 ! misho    1371:                  if ((cmpret = bgp_info_cmp (bgp, ri2, new_select, afi, safi))
        !          1372:                       == -1)
1.1       misho    1373:                    {
                   1374:                      bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED);
                   1375:                      new_select = ri2;
                   1376:                    }
                   1377: 
1.1.1.4 ! misho    1378:                  if (do_mpath)
        !          1379:                    {
        !          1380:                       if (cmpret != 0)
        !          1381:                         bgp_mp_list_clear (&mp_list);
        !          1382: 
        !          1383:                       if (cmpret == 0 || cmpret == -1)
        !          1384:                         bgp_mp_list_add (&mp_list, ri2);
        !          1385:                     }
1.1.1.2   misho    1386: 
1.1       misho    1387:                  bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK);
                   1388:                }
                   1389:            }
                   1390:        bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK);
                   1391:        bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED);
1.1.1.2   misho    1392: 
1.1.1.4 ! misho    1393:        bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi);
1.1.1.2   misho    1394:        bgp_mp_list_clear (&mp_list);
1.1       misho    1395:       }
                   1396: 
                   1397:   /* Check old selected route and new selected route. */
                   1398:   old_select = NULL;
                   1399:   new_select = NULL;
                   1400:   for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri)
                   1401:     {
                   1402:       if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
                   1403:        old_select = ri;
                   1404: 
                   1405:       if (BGP_INFO_HOLDDOWN (ri))
                   1406:         {
                   1407:           /* reap REMOVED routes, if needs be 
                   1408:            * selected route must stay for a while longer though
                   1409:            */
                   1410:           if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)
                   1411:               && (ri != old_select))
                   1412:               bgp_info_reap (rn, ri);
                   1413:           
                   1414:           continue;
                   1415:         }
                   1416: 
1.1.1.4 ! misho    1417:       if (ri->peer &&
        !          1418:           ri->peer != bgp->peer_self &&
        !          1419:           !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT))
        !          1420:         if (ri->peer->status != Established)
        !          1421:           continue;
        !          1422: 
1.1       misho    1423:       if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)
                   1424:           && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED)))
                   1425:        {
                   1426:          bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK);
                   1427:          continue;
                   1428:         }
                   1429:       bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK);
                   1430:       bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED);
                   1431: 
1.1.1.4 ! misho    1432:       if ((cmpret = bgp_info_cmp (bgp, ri, new_select, afi, safi)) == -1)
1.1.1.2   misho    1433:        {
                   1434:          if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
                   1435:            bgp_mp_dmed_deselect (new_select);
                   1436: 
                   1437:          new_select = ri;
                   1438:        }
1.1.1.4 ! misho    1439:       else if (cmpret == 1 && do_mpath
        !          1440:                && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
1.1.1.2   misho    1441:        bgp_mp_dmed_deselect (ri);
                   1442: 
1.1.1.4 ! misho    1443:       if (do_mpath)
        !          1444:         {
        !          1445:           if (cmpret != 0)
        !          1446:             bgp_mp_list_clear (&mp_list);
        !          1447: 
        !          1448:           if (cmpret == 0 || cmpret == -1)
        !          1449:             bgp_mp_list_add (&mp_list, ri);
        !          1450:         }
1.1       misho    1451:     }
                   1452: 
1.1.1.2   misho    1453:   if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
1.1.1.4 ! misho    1454:     bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi);
1.1.1.2   misho    1455: 
                   1456:   bgp_info_mpath_aggregate_update (new_select, old_select);
                   1457:   bgp_mp_list_clear (&mp_list);
                   1458: 
                   1459:   result->old = old_select;
                   1460:   result->new = new_select;
                   1461: 
                   1462:   return;
1.1       misho    1463: }
                   1464: 
                   1465: static int
                   1466: bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected,
                   1467:                                struct bgp_node *rn, afi_t afi, safi_t safi)
                   1468: {
                   1469:   struct prefix *p;
1.1.1.3   misho    1470:   struct attr attr;
                   1471:   struct attr_extra extra;
1.1       misho    1472: 
1.1.1.4 ! misho    1473:   memset (&attr, 0, sizeof(struct attr));
        !          1474:   memset (&extra, 0, sizeof(struct attr_extra));
        !          1475: 
1.1       misho    1476:   p = &rn->p;
                   1477: 
                   1478:   /* Announce route to Established peer. */
                   1479:   if (peer->status != Established)
                   1480:     return 0;
                   1481: 
                   1482:   /* Address family configuration check. */
                   1483:   if (! peer->afc_nego[afi][safi])
                   1484:     return 0;
                   1485: 
                   1486:   /* First update is deferred until ORF or ROUTE-REFRESH is received */
                   1487:   if (CHECK_FLAG (peer->af_sflags[afi][safi],
                   1488:       PEER_STATUS_ORF_WAIT_REFRESH))
                   1489:     return 0;
                   1490: 
1.1.1.3   misho    1491:   /* It's initialized in bgp_announce_[check|check_rsclient]() */
                   1492:   attr.extra = &extra;
                   1493: 
                   1494:   switch (bgp_node_table (rn)->type)
1.1       misho    1495:     {
                   1496:       case BGP_TABLE_MAIN:
                   1497:       /* Announcement to peer->conf.  If the route is filtered,
                   1498:          withdraw it. */
                   1499:         if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi))
                   1500:           bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected);
                   1501:         else
                   1502:           bgp_adj_out_unset (rn, peer, p, afi, safi);
                   1503:         break;
                   1504:       case BGP_TABLE_RSCLIENT:
                   1505:         /* Announcement to peer->conf.  If the route is filtered, 
                   1506:            withdraw it. */
                   1507:         if (selected && 
                   1508:             bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi))
                   1509:           bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected);
                   1510:         else
                   1511:          bgp_adj_out_unset (rn, peer, p, afi, safi);
                   1512:         break;
                   1513:     }
1.1.1.3   misho    1514: 
1.1.1.4 ! misho    1515:   bgp_attr_flush (&attr);
1.1       misho    1516:   return 0;
                   1517: }
                   1518: 
                   1519: struct bgp_process_queue 
                   1520: {
                   1521:   struct bgp *bgp;
                   1522:   struct bgp_node *rn;
                   1523:   afi_t afi;
                   1524:   safi_t safi;
                   1525: };
                   1526: 
                   1527: static wq_item_status
                   1528: bgp_process_rsclient (struct work_queue *wq, void *data)
                   1529: {
                   1530:   struct bgp_process_queue *pq = data;
                   1531:   struct bgp *bgp = pq->bgp;
                   1532:   struct bgp_node *rn = pq->rn;
                   1533:   afi_t afi = pq->afi;
                   1534:   safi_t safi = pq->safi;
                   1535:   struct bgp_info *new_select;
                   1536:   struct bgp_info *old_select;
                   1537:   struct bgp_info_pair old_and_new;
                   1538:   struct listnode *node, *nnode;
1.1.1.3   misho    1539:   struct peer *rsclient = bgp_node_table (rn)->owner;
1.1       misho    1540:   
                   1541:   /* Best path selection. */
1.1.1.4 ! misho    1542:   bgp_best_selection (bgp, rn, &old_and_new, afi, safi);
1.1       misho    1543:   new_select = old_and_new.new;
                   1544:   old_select = old_and_new.old;
                   1545: 
                   1546:   if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))
                   1547:     {
                   1548:       if (rsclient->group)
                   1549:         for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient))
                   1550:           {
                   1551:             /* Nothing to do. */
                   1552:             if (old_select && old_select == new_select)
                   1553:               if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
                   1554:                 continue;
                   1555: 
                   1556:             if (old_select)
                   1557:               bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
                   1558:             if (new_select)
                   1559:               {
                   1560:                 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
                   1561:                 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
1.1.1.2   misho    1562:                UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
                   1563:              }
1.1       misho    1564: 
                   1565:             bgp_process_announce_selected (rsclient, new_select, rn,
                   1566:                                            afi, safi);
                   1567:           }
                   1568:     }
                   1569:   else
                   1570:     {
                   1571:       if (old_select)
                   1572:        bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
                   1573:       if (new_select)
                   1574:        {
                   1575:          bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
                   1576:          bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
1.1.1.2   misho    1577:          UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
1.1       misho    1578:        }
                   1579:       bgp_process_announce_selected (rsclient, new_select, rn, afi, safi);
                   1580:     }
                   1581: 
                   1582:   if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED))
                   1583:     bgp_info_reap (rn, old_select);
                   1584:   
                   1585:   UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
                   1586:   return WQ_SUCCESS;
                   1587: }
                   1588: 
                   1589: static wq_item_status
                   1590: bgp_process_main (struct work_queue *wq, void *data)
                   1591: {
                   1592:   struct bgp_process_queue *pq = data;
                   1593:   struct bgp *bgp = pq->bgp;
                   1594:   struct bgp_node *rn = pq->rn;
                   1595:   afi_t afi = pq->afi;
                   1596:   safi_t safi = pq->safi;
                   1597:   struct prefix *p = &rn->p;
                   1598:   struct bgp_info *new_select;
                   1599:   struct bgp_info *old_select;
                   1600:   struct bgp_info_pair old_and_new;
                   1601:   struct listnode *node, *nnode;
                   1602:   struct peer *peer;
                   1603:   
                   1604:   /* Best path selection. */
1.1.1.4 ! misho    1605:   bgp_best_selection (bgp, rn, &old_and_new, afi, safi);
1.1       misho    1606:   old_select = old_and_new.old;
                   1607:   new_select = old_and_new.new;
                   1608: 
                   1609:   /* Nothing to do. */
                   1610:   if (old_select && old_select == new_select)
                   1611:     {
                   1612:       if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
                   1613:         {
1.1.1.2   misho    1614:           if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) ||
                   1615:              CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG))
                   1616:             bgp_zebra_announce (p, old_select, bgp, safi);
1.1       misho    1617:           
1.1.1.2   misho    1618:          UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG);
1.1       misho    1619:           UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
                   1620:           return WQ_SUCCESS;
                   1621:         }
                   1622:     }
                   1623: 
                   1624:   if (old_select)
                   1625:     bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
                   1626:   if (new_select)
                   1627:     {
                   1628:       bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
                   1629:       bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
1.1.1.2   misho    1630:       UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
1.1       misho    1631:     }
                   1632: 
                   1633: 
                   1634:   /* Check each BGP peer. */
                   1635:   for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
                   1636:     {
                   1637:       bgp_process_announce_selected (peer, new_select, rn, afi, safi);
                   1638:     }
                   1639: 
                   1640:   /* FIB update. */
1.1.1.2   misho    1641:   if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name &&
                   1642:       ! bgp_option_check (BGP_OPT_NO_FIB)))
1.1       misho    1643:     {
                   1644:       if (new_select 
                   1645:          && new_select->type == ZEBRA_ROUTE_BGP 
                   1646:          && new_select->sub_type == BGP_ROUTE_NORMAL)
1.1.1.2   misho    1647:        bgp_zebra_announce (p, new_select, bgp, safi);
1.1       misho    1648:       else
                   1649:        {
                   1650:          /* Withdraw the route from the kernel. */
                   1651:          if (old_select 
                   1652:              && old_select->type == ZEBRA_ROUTE_BGP
                   1653:              && old_select->sub_type == BGP_ROUTE_NORMAL)
1.1.1.2   misho    1654:            bgp_zebra_withdraw (p, old_select, safi);
1.1       misho    1655:        }
                   1656:     }
                   1657:     
1.1.1.4 ! misho    1658:   /* Reap old select bgp_info, if it has been removed */
1.1       misho    1659:   if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED))
                   1660:     bgp_info_reap (rn, old_select);
                   1661:   
                   1662:   UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
                   1663:   return WQ_SUCCESS;
                   1664: }
                   1665: 
                   1666: static void
                   1667: bgp_processq_del (struct work_queue *wq, void *data)
                   1668: {
                   1669:   struct bgp_process_queue *pq = data;
1.1.1.3   misho    1670:   struct bgp_table *table = bgp_node_table (pq->rn);
1.1       misho    1671:   
                   1672:   bgp_unlock (pq->bgp);
                   1673:   bgp_unlock_node (pq->rn);
                   1674:   bgp_table_unlock (table);
                   1675:   XFREE (MTYPE_BGP_PROCESS_QUEUE, pq);
                   1676: }
                   1677: 
                   1678: static void
                   1679: bgp_process_queue_init (void)
                   1680: {
                   1681:   bm->process_main_queue
                   1682:     = work_queue_new (bm->master, "process_main_queue");
                   1683:   bm->process_rsclient_queue
                   1684:     = work_queue_new (bm->master, "process_rsclient_queue");
                   1685:   
                   1686:   if ( !(bm->process_main_queue && bm->process_rsclient_queue) )
                   1687:     {
                   1688:       zlog_err ("%s: Failed to allocate work queue", __func__);
                   1689:       exit (1);
                   1690:     }
                   1691:   
                   1692:   bm->process_main_queue->spec.workfunc = &bgp_process_main;
                   1693:   bm->process_main_queue->spec.del_item_data = &bgp_processq_del;
                   1694:   bm->process_main_queue->spec.max_retries = 0;
                   1695:   bm->process_main_queue->spec.hold = 50;
                   1696:   
                   1697:   bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient;
1.1.1.4 ! misho    1698:   bm->process_rsclient_queue->spec.del_item_data = &bgp_processq_del;
        !          1699:   bm->process_rsclient_queue->spec.max_retries = 0;
        !          1700:   bm->process_rsclient_queue->spec.hold = 50;
1.1       misho    1701: }
                   1702: 
                   1703: void
                   1704: bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi)
                   1705: {
                   1706:   struct bgp_process_queue *pqnode;
                   1707:   
                   1708:   /* already scheduled for processing? */
                   1709:   if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED))
                   1710:     return;
                   1711:   
1.1.1.4 ! misho    1712:   if (rn->info == NULL)
        !          1713:     {
        !          1714:       /* XXX: Perhaps remove before next release, after we've flushed out
        !          1715:        * any obvious cases
        !          1716:        */
        !          1717:       assert (rn->info != NULL);
        !          1718:       char buf[PREFIX_STRLEN];
        !          1719:       zlog_warn ("%s: Called for route_node %s with no routing entries!",
        !          1720:                  __func__,
        !          1721:                  prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf)));
        !          1722:       return;
        !          1723:     }
        !          1724:   
1.1       misho    1725:   if ( (bm->process_main_queue == NULL) ||
                   1726:        (bm->process_rsclient_queue == NULL) )
                   1727:     bgp_process_queue_init ();
                   1728:   
                   1729:   pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, 
                   1730:                     sizeof (struct bgp_process_queue));
                   1731:   if (!pqnode)
                   1732:     return;
                   1733: 
                   1734:   /* all unlocked in bgp_processq_del */
1.1.1.3   misho    1735:   bgp_table_lock (bgp_node_table (rn));
1.1       misho    1736:   pqnode->rn = bgp_lock_node (rn);
                   1737:   pqnode->bgp = bgp;
                   1738:   bgp_lock (bgp);
                   1739:   pqnode->afi = afi;
                   1740:   pqnode->safi = safi;
                   1741:   
1.1.1.3   misho    1742:   switch (bgp_node_table (rn)->type)
1.1       misho    1743:     {
                   1744:       case BGP_TABLE_MAIN:
                   1745:         work_queue_add (bm->process_main_queue, pqnode);
                   1746:         break;
                   1747:       case BGP_TABLE_RSCLIENT:
                   1748:         work_queue_add (bm->process_rsclient_queue, pqnode);
                   1749:         break;
                   1750:     }
                   1751:   
1.1.1.3   misho    1752:   SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1.1       misho    1753:   return;
                   1754: }
                   1755: 
                   1756: static int
                   1757: bgp_maximum_prefix_restart_timer (struct thread *thread)
                   1758: {
                   1759:   struct peer *peer;
                   1760: 
                   1761:   peer = THREAD_ARG (thread);
                   1762:   peer->t_pmax_restart = NULL;
                   1763: 
                   1764:   if (BGP_DEBUG (events, EVENTS))
                   1765:     zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
                   1766:                peer->host);
                   1767: 
                   1768:   peer_clear (peer);
                   1769: 
                   1770:   return 0;
                   1771: }
                   1772: 
                   1773: int
                   1774: bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, 
                   1775:                              safi_t safi, int always)
                   1776: {
                   1777:   if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
                   1778:     return 0;
                   1779: 
                   1780:   if (peer->pcount[afi][safi] > peer->pmax[afi][safi])
                   1781:     {
                   1782:       if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT)
                   1783:          && ! always)
                   1784:        return 0;
                   1785: 
                   1786:       zlog (peer->log, LOG_INFO,
                   1787:            "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
                   1788:            "limit %ld", afi_safi_print (afi, safi), peer->host,
                   1789:            peer->pcount[afi][safi], peer->pmax[afi][safi]);
                   1790:       SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
                   1791: 
                   1792:       if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
                   1793:        return 0;
                   1794: 
                   1795:       {
                   1796:        u_int8_t ndata[7];
                   1797: 
                   1798:        if (safi == SAFI_MPLS_VPN)
1.1.1.2   misho    1799:          safi = SAFI_MPLS_LABELED_VPN;
1.1       misho    1800:          
                   1801:        ndata[0] = (afi >>  8);
                   1802:        ndata[1] = afi;
                   1803:        ndata[2] = safi;
                   1804:        ndata[3] = (peer->pmax[afi][safi] >> 24);
                   1805:        ndata[4] = (peer->pmax[afi][safi] >> 16);
                   1806:        ndata[5] = (peer->pmax[afi][safi] >> 8);
                   1807:        ndata[6] = (peer->pmax[afi][safi]);
                   1808: 
                   1809:        SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW);
                   1810:        bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE,
                   1811:                                   BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7);
                   1812:       }
                   1813: 
                   1814:       /* restart timer start */
                   1815:       if (peer->pmax_restart[afi][safi])
                   1816:        {
                   1817:          peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60;
                   1818: 
                   1819:          if (BGP_DEBUG (events, EVENTS))
                   1820:            zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
                   1821:                        peer->host, peer->v_pmax_restart);
                   1822: 
                   1823:          BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer,
                   1824:                        peer->v_pmax_restart);
                   1825:        }
                   1826: 
                   1827:       return 1;
                   1828:     }
                   1829:   else
                   1830:     UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
                   1831: 
                   1832:   if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100))
                   1833:     {
                   1834:       if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD)
                   1835:          && ! always)
                   1836:        return 0;
                   1837: 
                   1838:       zlog (peer->log, LOG_INFO,
                   1839:            "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
                   1840:            afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi],
                   1841:            peer->pmax[afi][safi]);
                   1842:       SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
                   1843:     }
                   1844:   else
                   1845:     UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
                   1846:   return 0;
                   1847: }
                   1848: 
                   1849: /* Unconditionally remove the route from the RIB, without taking
                   1850:  * damping into consideration (eg, because the session went down)
                   1851:  */
                   1852: static void
                   1853: bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
                   1854:                afi_t afi, safi_t safi)
                   1855: {
                   1856:   bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
                   1857:   
                   1858:   if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
                   1859:     bgp_info_delete (rn, ri); /* keep historical info */
                   1860:     
                   1861:   bgp_process (peer->bgp, rn, afi, safi);
                   1862: }
                   1863: 
                   1864: static void
                   1865: bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
1.1.1.4 ! misho    1866:                  afi_t afi, safi_t safi, struct prefix_rd *prd)
1.1       misho    1867: {
                   1868:   int status = BGP_DAMP_NONE;
                   1869: 
                   1870:   /* apply dampening, if result is suppressed, we'll be retaining 
                   1871:    * the bgp_info in the RIB for historical reference.
                   1872:    */
                   1873:   if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
1.1.1.3   misho    1874:       && peer->sort == BGP_PEER_EBGP)
1.1       misho    1875:     if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) 
                   1876:          == BGP_DAMP_SUPPRESSED)
                   1877:       {
                   1878:         bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
                   1879:         return;
                   1880:       }
                   1881:     
                   1882:   bgp_rib_remove (rn, ri, peer, afi, safi);
                   1883: }
                   1884: 
                   1885: static void
                   1886: bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
                   1887:       struct attr *attr, struct peer *peer, struct prefix *p, int type,
                   1888:       int sub_type, struct prefix_rd *prd, u_char *tag)
                   1889: {
                   1890:   struct bgp_node *rn;
                   1891:   struct bgp *bgp;
1.1.1.3   misho    1892:   struct attr new_attr;
                   1893:   struct attr_extra new_extra;
1.1       misho    1894:   struct attr *attr_new;
                   1895:   struct attr *attr_new2;
                   1896:   struct bgp_info *ri;
                   1897:   struct bgp_info *new;
                   1898:   const char *reason;
                   1899:   char buf[SU_ADDRSTRLEN];
                   1900: 
                   1901:   /* Do not insert announces from a rsclient into its own 'bgp_table'. */
                   1902:   if (peer == rsclient)
                   1903:     return;
                   1904: 
                   1905:   bgp = peer->bgp;
                   1906:   rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
                   1907: 
                   1908:   /* Check previously received route. */
                   1909:   for (ri = rn->info; ri; ri = ri->next)
                   1910:     if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
                   1911:       break;
                   1912: 
                   1913:   /* AS path loop check. */
1.1.1.4 ! misho    1914:   if (aspath_loop_check (attr->aspath, rsclient->as) > rsclient->allowas_in[afi][safi])
1.1       misho    1915:     {
                   1916:       reason = "as-path contains our own AS;";
                   1917:       goto filtered;
                   1918:     }
                   1919: 
                   1920:   /* Route reflector originator ID check.  */
                   1921:   if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
                   1922:       && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id))
                   1923:     {
                   1924:       reason = "originator is us;";
                   1925:       goto filtered;
                   1926:     }
                   1927:   
1.1.1.3   misho    1928:   new_attr.extra = &new_extra;
1.1       misho    1929:   bgp_attr_dup (&new_attr, attr);
                   1930: 
                   1931:   /* Apply export policy. */
                   1932:   if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) &&
                   1933:         bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
                   1934:     {
                   1935:       reason = "export-policy;";
                   1936:       goto filtered;
                   1937:     }
                   1938: 
                   1939:   attr_new2 = bgp_attr_intern (&new_attr);
                   1940:   
                   1941:   /* Apply import policy. */
                   1942:   if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
                   1943:     {
                   1944:       bgp_attr_unintern (&attr_new2);
                   1945: 
                   1946:       reason = "import-policy;";
                   1947:       goto filtered;
                   1948:     }
                   1949: 
                   1950:   attr_new = bgp_attr_intern (&new_attr);
                   1951:   bgp_attr_unintern (&attr_new2);
                   1952: 
                   1953:   /* IPv4 unicast next hop check.  */
1.1.1.2   misho    1954:   if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST))
1.1       misho    1955:     {
1.1.1.2   misho    1956:      /* Next hop must not be 0.0.0.0 nor Class D/E address. */
1.1       misho    1957:       if (new_attr.nexthop.s_addr == 0
1.1.1.2   misho    1958:          || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)))
1.1       misho    1959:        {
                   1960:          bgp_attr_unintern (&attr_new);
                   1961: 
                   1962:          reason = "martian next-hop;";
                   1963:          goto filtered;
                   1964:        }
                   1965:     }
1.1.1.3   misho    1966: 
1.1       misho    1967:   /* If the update is implicit withdraw. */
                   1968:   if (ri)
                   1969:     {
                   1970:       ri->uptime = bgp_clock ();
                   1971: 
                   1972:       /* Same attribute comes in. */
                   1973:       if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)
                   1974:           && attrhash_cmp (ri->attr, attr_new))
                   1975:         {
                   1976: 
                   1977:           bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
                   1978: 
                   1979:           if (BGP_DEBUG (update, UPDATE_IN))
                   1980:             zlog (peer->log, LOG_DEBUG,
                   1981:                     "%s rcvd %s/%d for RS-client %s...duplicate ignored",
                   1982:                     peer->host,
                   1983:                     inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
                   1984:                     p->prefixlen, rsclient->host);
                   1985: 
                   1986:           bgp_unlock_node (rn);
                   1987:           bgp_attr_unintern (&attr_new);
1.1.1.4 ! misho    1988:           bgp_attr_flush(&new_attr);
1.1       misho    1989:           return;
                   1990:         }
                   1991: 
                   1992:       /* Withdraw/Announce before we fully processed the withdraw */
                   1993:       if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
                   1994:         bgp_info_restore (rn, ri);
                   1995:       
                   1996:       /* Received Logging. */
                   1997:       if (BGP_DEBUG (update, UPDATE_IN))
                   1998:         zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
                   1999:                 peer->host,
                   2000:                 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
                   2001:                 p->prefixlen, rsclient->host);
                   2002: 
                   2003:       /* The attribute is changed. */
                   2004:       bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
                   2005: 
                   2006:       /* Update to new attribute.  */
                   2007:       bgp_attr_unintern (&ri->attr);
                   2008:       ri->attr = attr_new;
                   2009: 
                   2010:       /* Update MPLS tag.  */
                   2011:       if (safi == SAFI_MPLS_VPN)
                   2012:         memcpy ((bgp_info_extra_get (ri))->tag, tag, 3);
                   2013: 
                   2014:       bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
                   2015: 
                   2016:       /* Process change. */
                   2017:       bgp_process (bgp, rn, afi, safi);
                   2018:       bgp_unlock_node (rn);
                   2019: 
                   2020:       return;
                   2021:     }
                   2022: 
                   2023:   /* Received Logging. */
                   2024:   if (BGP_DEBUG (update, UPDATE_IN))
                   2025:     {
                   2026:       zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
                   2027:               peer->host,
                   2028:               inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
                   2029:               p->prefixlen, rsclient->host);
                   2030:     }
                   2031: 
                   2032:   /* Make new BGP info. */
                   2033:   new = bgp_info_new ();
                   2034:   new->type = type;
                   2035:   new->sub_type = sub_type;
                   2036:   new->peer = peer;
                   2037:   new->attr = attr_new;
                   2038:   new->uptime = bgp_clock ();
                   2039: 
                   2040:   /* Update MPLS tag. */
                   2041:   if (safi == SAFI_MPLS_VPN)
                   2042:     memcpy ((bgp_info_extra_get (new))->tag, tag, 3);
                   2043: 
                   2044:   bgp_info_set_flag (rn, new, BGP_INFO_VALID);
                   2045: 
                   2046:   /* Register new BGP information. */
                   2047:   bgp_info_add (rn, new);
                   2048:   
                   2049:   /* route_node_get lock */
                   2050:   bgp_unlock_node (rn);
                   2051:   
                   2052:   /* Process change. */
                   2053:   bgp_process (bgp, rn, afi, safi);
1.1.1.3   misho    2054: 
1.1       misho    2055:   return;
                   2056: 
                   2057:  filtered: 
                   2058: 
                   2059:   /* This BGP update is filtered.  Log the reason then update BGP entry.  */
                   2060:   if (BGP_DEBUG (update, UPDATE_IN))
                   2061:         zlog (peer->log, LOG_DEBUG,
                   2062:         "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
                   2063:         peer->host,
                   2064:         inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
                   2065:         p->prefixlen, rsclient->host, reason);
                   2066: 
                   2067:   if (ri)
                   2068:     bgp_rib_remove (rn, ri, peer, afi, safi);
                   2069: 
                   2070:   bgp_unlock_node (rn);
1.1.1.3   misho    2071: 
1.1       misho    2072:   return;
                   2073: }
                   2074: 
                   2075: static void
                   2076: bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
                   2077:       struct peer *peer, struct prefix *p, int type, int sub_type,
                   2078:       struct prefix_rd *prd, u_char *tag)
                   2079: {
                   2080:   struct bgp_node *rn;
                   2081:   struct bgp_info *ri;
                   2082:   char buf[SU_ADDRSTRLEN];
                   2083: 
                   2084:   if (rsclient == peer)
                   2085:     return;
                   2086: 
                   2087:   rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
                   2088: 
                   2089:   /* Lookup withdrawn route. */
                   2090:   for (ri = rn->info; ri; ri = ri->next)
                   2091:     if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
                   2092:       break;
                   2093: 
                   2094:   /* Withdraw specified route from routing table. */
                   2095:   if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
1.1.1.4 ! misho    2096:     bgp_rib_withdraw (rn, ri, peer, afi, safi, prd);
1.1       misho    2097:   else if (BGP_DEBUG (update, UPDATE_IN))
                   2098:     zlog (peer->log, LOG_DEBUG,
                   2099:           "%s Can't find the route %s/%d", peer->host,
                   2100:           inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
                   2101:           p->prefixlen);
                   2102: 
                   2103:   /* Unlock bgp_node_get() lock. */
                   2104:   bgp_unlock_node (rn);
                   2105: }
                   2106: 
                   2107: static int
                   2108: bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr,
                   2109:            afi_t afi, safi_t safi, int type, int sub_type,
                   2110:            struct prefix_rd *prd, u_char *tag, int soft_reconfig)
                   2111: {
                   2112:   int ret;
                   2113:   int aspath_loop_count = 0;
                   2114:   struct bgp_node *rn;
                   2115:   struct bgp *bgp;
1.1.1.3   misho    2116:   struct attr new_attr;
                   2117:   struct attr_extra new_extra;
1.1       misho    2118:   struct attr *attr_new;
                   2119:   struct bgp_info *ri;
                   2120:   struct bgp_info *new;
                   2121:   const char *reason;
                   2122:   char buf[SU_ADDRSTRLEN];
                   2123: 
1.1.1.4 ! misho    2124:   memset (&new_attr, 0, sizeof(struct attr));
        !          2125:   memset (&new_extra, 0, sizeof(struct attr_extra));
        !          2126: 
1.1       misho    2127:   bgp = peer->bgp;
                   2128:   rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
                   2129:   
                   2130:   /* When peer's soft reconfiguration enabled.  Record input packet in
                   2131:      Adj-RIBs-In.  */
1.1.1.3   misho    2132:   if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
                   2133:       && peer != bgp->peer_self)
1.1       misho    2134:     bgp_adj_in_set (rn, peer, attr);
                   2135: 
                   2136:   /* Check previously received route. */
                   2137:   for (ri = rn->info; ri; ri = ri->next)
                   2138:     if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
                   2139:       break;
                   2140: 
                   2141:   /* AS path local-as loop check. */
                   2142:   if (peer->change_local_as)
                   2143:     {
                   2144:       if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND))
                   2145:        aspath_loop_count = 1;
                   2146: 
                   2147:       if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) 
                   2148:        {
                   2149:          reason = "as-path contains our own AS;";
                   2150:          goto filtered;
                   2151:        }
                   2152:     }
                   2153: 
                   2154:   /* AS path loop check. */
                   2155:   if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi]
                   2156:       || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)
                   2157:          && aspath_loop_check(attr->aspath, bgp->confed_id)
                   2158:          > peer->allowas_in[afi][safi]))
                   2159:     {
                   2160:       reason = "as-path contains our own AS;";
                   2161:       goto filtered;
                   2162:     }
                   2163: 
                   2164:   /* Route reflector originator ID check.  */
                   2165:   if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
                   2166:       && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id))
                   2167:     {
                   2168:       reason = "originator is us;";
                   2169:       goto filtered;
                   2170:     }
                   2171: 
                   2172:   /* Route reflector cluster ID check.  */
                   2173:   if (bgp_cluster_filter (peer, attr))
                   2174:     {
                   2175:       reason = "reflected from the same cluster;";
                   2176:       goto  filtered;
                   2177:     }
                   2178: 
                   2179:   /* Apply incoming filter.  */
                   2180:   if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY)
                   2181:     {
                   2182:       reason = "filter;";
                   2183:       goto filtered;
                   2184:     }
                   2185: 
1.1.1.3   misho    2186:   new_attr.extra = &new_extra;
1.1       misho    2187:   bgp_attr_dup (&new_attr, attr);
                   2188: 
1.1.1.4 ! misho    2189:   /* Apply incoming route-map.
        !          2190:    * NB: new_attr may now contain newly allocated values from route-map "set"
        !          2191:    * commands, so we need bgp_attr_flush in the error paths, until we intern
        !          2192:    * the attr (which takes over the memory references) */
1.1       misho    2193:   if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY)
                   2194:     {
                   2195:       reason = "route-map;";
1.1.1.4 ! misho    2196:       bgp_attr_flush (&new_attr);
1.1       misho    2197:       goto filtered;
                   2198:     }
                   2199: 
                   2200:   /* IPv4 unicast next hop check.  */
                   2201:   if (afi == AFI_IP && safi == SAFI_UNICAST)
                   2202:     {
                   2203:       /* If the peer is EBGP and nexthop is not on connected route,
                   2204:         discard it.  */
1.1.1.3   misho    2205:       if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1
1.1.1.2   misho    2206:          && ! bgp_nexthop_onlink (afi, &new_attr)
1.1       misho    2207:          && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
                   2208:        {
                   2209:          reason = "non-connected next-hop;";
1.1.1.4 ! misho    2210:          bgp_attr_flush (&new_attr);
1.1       misho    2211:          goto filtered;
                   2212:        }
                   2213: 
1.1.1.2   misho    2214:       /* Next hop must not be 0.0.0.0 nor Class D/E address. Next hop
1.1       misho    2215:         must not be my own address.  */
1.1.1.3   misho    2216:       if (new_attr.nexthop.s_addr == 0
                   2217:          || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))
                   2218:          || bgp_nexthop_self (&new_attr))
1.1       misho    2219:        {
                   2220:          reason = "martian next-hop;";
1.1.1.4 ! misho    2221:          bgp_attr_flush (&new_attr);
1.1       misho    2222:          goto filtered;
                   2223:        }
                   2224:     }
                   2225: 
                   2226:   attr_new = bgp_attr_intern (&new_attr);
                   2227: 
                   2228:   /* If the update is implicit withdraw. */
                   2229:   if (ri)
                   2230:     {
                   2231:       ri->uptime = bgp_clock ();
                   2232: 
                   2233:       /* Same attribute comes in. */
                   2234:       if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) 
                   2235:           && attrhash_cmp (ri->attr, attr_new))
                   2236:        {
                   2237:          bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
                   2238: 
                   2239:          if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
1.1.1.3   misho    2240:              && peer->sort == BGP_PEER_EBGP
1.1       misho    2241:              && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
                   2242:            {
                   2243:              if (BGP_DEBUG (update, UPDATE_IN))  
                   2244:                  zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
                   2245:                  peer->host,
                   2246:                  inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
                   2247:                  p->prefixlen);
                   2248: 
                   2249:              if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED)
                   2250:                {
                   2251:                   bgp_aggregate_increment (bgp, p, ri, afi, safi);
                   2252:                   bgp_process (bgp, rn, afi, safi);
                   2253:                 }
                   2254:            }
                   2255:           else /* Duplicate - odd */
                   2256:            {
                   2257:              if (BGP_DEBUG (update, UPDATE_IN))  
                   2258:                zlog (peer->log, LOG_DEBUG,
                   2259:                "%s rcvd %s/%d...duplicate ignored",
                   2260:                peer->host,
                   2261:                inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
                   2262:                p->prefixlen);
                   2263: 
                   2264:              /* graceful restart STALE flag unset. */
                   2265:              if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
                   2266:                {
                   2267:                  bgp_info_unset_flag (rn, ri, BGP_INFO_STALE);
                   2268:                  bgp_process (bgp, rn, afi, safi);
                   2269:                }
                   2270:            }
                   2271: 
                   2272:          bgp_unlock_node (rn);
                   2273:          bgp_attr_unintern (&attr_new);
1.1.1.4 ! misho    2274:           bgp_attr_flush (&new_attr);
1.1.1.3   misho    2275: 
1.1       misho    2276:          return 0;
                   2277:        }
                   2278: 
                   2279:       /* Withdraw/Announce before we fully processed the withdraw */
                   2280:       if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
                   2281:         {
                   2282:           if (BGP_DEBUG (update, UPDATE_IN))
                   2283:             zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing",
                   2284:             peer->host,
                   2285:             inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
                   2286:             p->prefixlen);
                   2287:           bgp_info_restore (rn, ri);
                   2288:         }
                   2289: 
                   2290:       /* Received Logging. */
                   2291:       if (BGP_DEBUG (update, UPDATE_IN))  
                   2292:        zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
                   2293:              peer->host,
                   2294:              inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
                   2295:              p->prefixlen);
                   2296: 
                   2297:       /* graceful restart STALE flag unset. */
                   2298:       if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
                   2299:        bgp_info_unset_flag (rn, ri, BGP_INFO_STALE);
                   2300: 
                   2301:       /* The attribute is changed. */
                   2302:       bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
                   2303:       
                   2304:       /* implicit withdraw, decrement aggregate and pcount here.
                   2305:        * only if update is accepted, they'll increment below.
                   2306:        */
                   2307:       bgp_aggregate_decrement (bgp, p, ri, afi, safi);
                   2308:       
                   2309:       /* Update bgp route dampening information.  */
                   2310:       if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
1.1.1.3   misho    2311:          && peer->sort == BGP_PEER_EBGP)
1.1       misho    2312:        {
                   2313:          /* This is implicit withdraw so we should update dampening
                   2314:             information.  */
                   2315:          if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
                   2316:            bgp_damp_withdraw (ri, rn, afi, safi, 1);  
                   2317:        }
                   2318:        
                   2319:       /* Update to new attribute.  */
                   2320:       bgp_attr_unintern (&ri->attr);
                   2321:       ri->attr = attr_new;
                   2322: 
                   2323:       /* Update MPLS tag.  */
                   2324:       if (safi == SAFI_MPLS_VPN)
                   2325:         memcpy ((bgp_info_extra_get (ri))->tag, tag, 3);
                   2326: 
1.1.1.4 ! misho    2327:       bgp_attr_flush (&new_attr);
        !          2328: 
1.1       misho    2329:       /* Update bgp route dampening information.  */
                   2330:       if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
1.1.1.3   misho    2331:          && peer->sort == BGP_PEER_EBGP)
1.1       misho    2332:        {
                   2333:          /* Now we do normal update dampening.  */
                   2334:          ret = bgp_damp_update (ri, rn, afi, safi);
                   2335:          if (ret == BGP_DAMP_SUPPRESSED)
                   2336:            {
                   2337:              bgp_unlock_node (rn);
                   2338:              return 0;
                   2339:            }
                   2340:        }
                   2341: 
                   2342:       /* Nexthop reachability check. */
                   2343:       if ((afi == AFI_IP || afi == AFI_IP6)
                   2344:          && safi == SAFI_UNICAST 
1.1.1.3   misho    2345:          && (peer->sort == BGP_PEER_IBGP
                   2346:               || peer->sort == BGP_PEER_CONFED
                   2347:              || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1)
1.1       misho    2348:              || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)))
                   2349:        {
                   2350:          if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL))
                   2351:            bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
                   2352:          else
                   2353:            bgp_info_unset_flag (rn, ri, BGP_INFO_VALID);
                   2354:        }
                   2355:       else
                   2356:         bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
                   2357: 
1.1.1.4 ! misho    2358:       bgp_attr_flush (&new_attr);
        !          2359: 
1.1       misho    2360:       /* Process change. */
                   2361:       bgp_aggregate_increment (bgp, p, ri, afi, safi);
                   2362: 
                   2363:       bgp_process (bgp, rn, afi, safi);
                   2364:       bgp_unlock_node (rn);
1.1.1.3   misho    2365: 
1.1       misho    2366:       return 0;
                   2367:     }
                   2368: 
                   2369:   /* Received Logging. */
                   2370:   if (BGP_DEBUG (update, UPDATE_IN))  
                   2371:     {
                   2372:       zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
                   2373:            peer->host,
                   2374:            inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
                   2375:            p->prefixlen);
                   2376:     }
                   2377: 
                   2378:   /* Make new BGP info. */
                   2379:   new = bgp_info_new ();
                   2380:   new->type = type;
                   2381:   new->sub_type = sub_type;
                   2382:   new->peer = peer;
                   2383:   new->attr = attr_new;
                   2384:   new->uptime = bgp_clock ();
                   2385: 
                   2386:   /* Update MPLS tag. */
                   2387:   if (safi == SAFI_MPLS_VPN)
                   2388:     memcpy ((bgp_info_extra_get (new))->tag, tag, 3);
                   2389: 
                   2390:   /* Nexthop reachability check. */
                   2391:   if ((afi == AFI_IP || afi == AFI_IP6)
                   2392:       && safi == SAFI_UNICAST
1.1.1.3   misho    2393:       && (peer->sort == BGP_PEER_IBGP
                   2394:           || peer->sort == BGP_PEER_CONFED
                   2395:          || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1)
1.1       misho    2396:          || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)))
                   2397:     {
                   2398:       if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL))
                   2399:        bgp_info_set_flag (rn, new, BGP_INFO_VALID);
                   2400:       else
                   2401:         bgp_info_unset_flag (rn, new, BGP_INFO_VALID);
                   2402:     }
                   2403:   else
                   2404:     bgp_info_set_flag (rn, new, BGP_INFO_VALID);
                   2405: 
                   2406:   /* Increment prefix */
                   2407:   bgp_aggregate_increment (bgp, p, new, afi, safi);
                   2408:   
                   2409:   /* Register new BGP information. */
                   2410:   bgp_info_add (rn, new);
                   2411:   
                   2412:   /* route_node_get lock */
                   2413:   bgp_unlock_node (rn);
1.1.1.3   misho    2414: 
1.1.1.4 ! misho    2415:   bgp_attr_flush (&new_attr);
        !          2416: 
1.1       misho    2417:   /* If maximum prefix count is configured and current prefix
                   2418:      count exeed it. */
                   2419:   if (bgp_maximum_prefix_overflow (peer, afi, safi, 0))
                   2420:     return -1;
                   2421: 
                   2422:   /* Process change. */
                   2423:   bgp_process (bgp, rn, afi, safi);
                   2424: 
                   2425:   return 0;
                   2426: 
                   2427:   /* This BGP update is filtered.  Log the reason then update BGP
                   2428:      entry.  */
                   2429:  filtered:
                   2430:   if (BGP_DEBUG (update, UPDATE_IN))
                   2431:     zlog (peer->log, LOG_DEBUG,
                   2432:          "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
                   2433:          peer->host,
                   2434:          inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
                   2435:          p->prefixlen, reason);
                   2436: 
                   2437:   if (ri)
                   2438:     bgp_rib_remove (rn, ri, peer, afi, safi);
                   2439: 
                   2440:   bgp_unlock_node (rn);
1.1.1.4 ! misho    2441:   bgp_attr_flush (&new_attr);
1.1.1.3   misho    2442: 
1.1       misho    2443:   return 0;
                   2444: }
                   2445: 
                   2446: int
                   2447: bgp_update (struct peer *peer, struct prefix *p, struct attr *attr,
                   2448:             afi_t afi, safi_t safi, int type, int sub_type,
                   2449:             struct prefix_rd *prd, u_char *tag, int soft_reconfig)
                   2450: {
                   2451:   struct peer *rsclient;
                   2452:   struct listnode *node, *nnode;
                   2453:   struct bgp *bgp;
                   2454:   int ret;
                   2455: 
                   2456:   ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag,
                   2457:           soft_reconfig);
                   2458: 
                   2459:   bgp = peer->bgp;
                   2460: 
                   2461:   /* Process the update for each RS-client. */
                   2462:   for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
                   2463:     {
                   2464:       if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
                   2465:         bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type,
                   2466:                 sub_type, prd, tag);
                   2467:     }
                   2468: 
                   2469:   return ret;
                   2470: }
                   2471: 
                   2472: int
                   2473: bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, 
                   2474:             afi_t afi, safi_t safi, int type, int sub_type, 
                   2475:             struct prefix_rd *prd, u_char *tag)
                   2476: {
                   2477:   struct bgp *bgp;
                   2478:   char buf[SU_ADDRSTRLEN];
                   2479:   struct bgp_node *rn;
                   2480:   struct bgp_info *ri;
                   2481:   struct peer *rsclient;
                   2482:   struct listnode *node, *nnode;
                   2483: 
                   2484:   bgp = peer->bgp;
                   2485: 
1.1.1.4 ! misho    2486:   /* Lookup node. */
        !          2487:   rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
        !          2488: 
        !          2489:   /* Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all
        !          2490:    * routes that are filtered.  This tanks out Quagga RS pretty badly due to
        !          2491:    * the iteration over all RS clients.
        !          2492:    * Since we need to remove the entry from adj_in anyway, do that first and
        !          2493:    * if there was no entry, we don't need to do anything more. */
        !          2494:   if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
        !          2495:       && peer != bgp->peer_self)
        !          2496:     if (!bgp_adj_in_unset (rn, peer))
        !          2497:       {
        !          2498:         if (BGP_DEBUG (update, UPDATE_IN))
        !          2499:           zlog (peer->log, LOG_DEBUG, "%s withdrawing route %s/%d "
        !          2500:                 "not in adj-in", peer->host,
        !          2501:                 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
        !          2502:                 p->prefixlen);
        !          2503:         bgp_unlock_node (rn);
        !          2504:         return 0;
        !          2505:       }
        !          2506: 
1.1       misho    2507:   /* Process the withdraw for each RS-client. */
                   2508:   for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
                   2509:     {
                   2510:       if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
                   2511:         bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag);
                   2512:     }
                   2513: 
                   2514:   /* Logging. */
                   2515:   if (BGP_DEBUG (update, UPDATE_IN))  
                   2516:     zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn",
                   2517:          peer->host,
                   2518:          inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
                   2519:          p->prefixlen);
                   2520: 
                   2521:   /* Lookup withdrawn route. */
                   2522:   for (ri = rn->info; ri; ri = ri->next)
                   2523:     if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
                   2524:       break;
                   2525: 
                   2526:   /* Withdraw specified route from routing table. */
                   2527:   if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
1.1.1.4 ! misho    2528:     bgp_rib_withdraw (rn, ri, peer, afi, safi, prd);
1.1       misho    2529:   else if (BGP_DEBUG (update, UPDATE_IN))
                   2530:     zlog (peer->log, LOG_DEBUG, 
                   2531:          "%s Can't find the route %s/%d", peer->host,
                   2532:          inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
                   2533:          p->prefixlen);
                   2534: 
                   2535:   /* Unlock bgp_node_get() lock. */
                   2536:   bgp_unlock_node (rn);
                   2537: 
                   2538:   return 0;
                   2539: }
1.1.1.4 ! misho    2540: 
1.1       misho    2541: void
                   2542: bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw)
                   2543: {
                   2544:   struct bgp *bgp;
1.1.1.3   misho    2545:   struct attr attr;
                   2546:   struct aspath *aspath;
1.1       misho    2547:   struct prefix p;
                   2548:   struct peer *from;
1.1.1.3   misho    2549:   struct bgp_node *rn;
                   2550:   struct bgp_info *ri;
1.1       misho    2551:   int ret = RMAP_DENYMATCH;
                   2552:   
                   2553:   if (!(afi == AFI_IP || afi == AFI_IP6))
                   2554:     return;
                   2555:   
                   2556:   bgp = peer->bgp;
                   2557:   from = bgp->peer_self;
                   2558:   
                   2559:   bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
                   2560:   aspath = attr.aspath;
                   2561:   attr.local_pref = bgp->default_local_pref;
                   2562:   memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
                   2563: 
                   2564:   if (afi == AFI_IP)
                   2565:     str2prefix ("0.0.0.0/0", &p);
                   2566:   else if (afi == AFI_IP6)
                   2567:     {
1.1.1.3   misho    2568:       struct attr_extra *ae = attr.extra;
                   2569: 
1.1       misho    2570:       str2prefix ("::/0", &p);
                   2571: 
                   2572:       /* IPv6 global nexthop must be included. */
                   2573:       memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, 
                   2574:              IPV6_MAX_BYTELEN);
                   2575:              ae->mp_nexthop_len = 16;
                   2576:  
                   2577:       /* If the peer is on shared nextwork and we have link-local
                   2578:         nexthop set it. */
                   2579:       if (peer->shared_network 
                   2580:          && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
                   2581:        {
                   2582:          memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, 
                   2583:                  IPV6_MAX_BYTELEN);
                   2584:          ae->mp_nexthop_len = 32;
                   2585:        }
                   2586:     }
                   2587: 
                   2588:   if (peer->default_rmap[afi][safi].name)
                   2589:     {
                   2590:       SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT);
1.1.1.3   misho    2591:       for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn))
                   2592:         {
                   2593:           for (ri = rn->info; ri; ri = ri->next)
                   2594:             {
                   2595:               struct attr dummy_attr;
                   2596:               struct attr_extra dummy_extra;
                   2597:               struct bgp_info info;
                   2598: 
                   2599:               /* Provide dummy so the route-map can't modify the attributes */
                   2600:               dummy_attr.extra = &dummy_extra;
                   2601:               bgp_attr_dup(&dummy_attr, ri->attr);
                   2602:               info.peer = ri->peer;
                   2603:               info.attr = &dummy_attr;
                   2604: 
                   2605:               ret = route_map_apply(peer->default_rmap[afi][safi].map, &rn->p,
                   2606:                                     RMAP_BGP, &info);
                   2607: 
                   2608:               /* The route map might have set attributes. If we don't flush them
                   2609:                * here, they will be leaked. */
                   2610:               bgp_attr_flush(&dummy_attr);
                   2611:               if (ret != RMAP_DENYMATCH)
                   2612:                 break;
                   2613:             }
                   2614:           if (ret != RMAP_DENYMATCH)
                   2615:             break;
                   2616:         }
1.1       misho    2617:       bgp->peer_self->rmap_type = 0;
                   2618: 
                   2619:       if (ret == RMAP_DENYMATCH)
1.1.1.3   misho    2620:         withdraw = 1;
1.1       misho    2621:     }
                   2622: 
                   2623:   if (withdraw)
                   2624:     {
                   2625:       if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
                   2626:        bgp_default_withdraw_send (peer, afi, safi);
                   2627:       UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
                   2628:     }
                   2629:   else
                   2630:     {
1.1.1.3   misho    2631:       if (! CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
                   2632:         {
                   2633:           SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
                   2634:           bgp_default_update_send (peer, &attr, afi, safi, from);
                   2635:         }
1.1       misho    2636:     }
                   2637:   
                   2638:   bgp_attr_extra_free (&attr);
                   2639:   aspath_unintern (&aspath);
                   2640: }
1.1.1.4 ! misho    2641: 
1.1       misho    2642: static void
                   2643: bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi,
                   2644:                    struct bgp_table *table, int rsclient)
                   2645: {
                   2646:   struct bgp_node *rn;
                   2647:   struct bgp_info *ri;
1.1.1.3   misho    2648:   struct attr attr;
                   2649:   struct attr_extra extra;
                   2650: 
1.1.1.4 ! misho    2651:   memset(&extra, 0, sizeof(extra));
        !          2652: 
1.1       misho    2653:   if (! table)
                   2654:     table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi];
                   2655: 
1.1.1.4 ! misho    2656:   if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)
1.1       misho    2657:       && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
                   2658:     bgp_default_originate (peer, afi, safi, 0);
                   2659: 
1.1.1.3   misho    2660:   /* It's initialized in bgp_announce_[check|check_rsclient]() */
                   2661:   attr.extra = &extra;
                   2662: 
1.1       misho    2663:   for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn))
                   2664:     for (ri = rn->info; ri; ri = ri->next)
                   2665:       if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer)
                   2666:        {
                   2667:          if ( (rsclient) ?
                   2668:               (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi))
                   2669:               : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi)))
                   2670:            bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri);
                   2671:          else
                   2672:            bgp_adj_out_unset (rn, peer, &rn->p, afi, safi);
                   2673:        }
1.1.1.4 ! misho    2674: 
        !          2675:   bgp_attr_flush_encap(&attr);
1.1       misho    2676: }
                   2677: 
                   2678: void
                   2679: bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi)
                   2680: {
                   2681:   struct bgp_node *rn;
                   2682:   struct bgp_table *table;
                   2683: 
                   2684:   if (peer->status != Established)
                   2685:     return;
                   2686: 
                   2687:   if (! peer->afc_nego[afi][safi])
                   2688:     return;
                   2689: 
                   2690:   /* First update is deferred until ORF or ROUTE-REFRESH is received */
                   2691:   if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
                   2692:     return;
                   2693: 
1.1.1.4 ! misho    2694:   if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
1.1       misho    2695:     bgp_announce_table (peer, afi, safi, NULL, 0);
                   2696:   else
                   2697:     for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
                   2698:         rn = bgp_route_next(rn))
                   2699:       if ((table = (rn->info)) != NULL)
                   2700:        bgp_announce_table (peer, afi, safi, table, 0);
                   2701: 
                   2702:   if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
                   2703:     bgp_announce_table (peer, afi, safi, NULL, 1);
                   2704: }
                   2705: 
                   2706: void
                   2707: bgp_announce_route_all (struct peer *peer)
                   2708: {
                   2709:   afi_t afi;
                   2710:   safi_t safi;
                   2711:   
                   2712:   for (afi = AFI_IP; afi < AFI_MAX; afi++)
                   2713:     for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
                   2714:       bgp_announce_route (peer, afi, safi);
                   2715: }
1.1.1.4 ! misho    2716: 
1.1       misho    2717: static void
                   2718: bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi,
1.1.1.3   misho    2719:         safi_t safi, struct bgp_table *table, struct prefix_rd *prd)
1.1       misho    2720: {
                   2721:   struct bgp_node *rn;
                   2722:   struct bgp_adj_in *ain;
                   2723: 
                   2724:   if (! table)
                   2725:     table = rsclient->bgp->rib[afi][safi];
                   2726: 
                   2727:   for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
                   2728:     for (ain = rn->adj_in; ain; ain = ain->next)
                   2729:       {
1.1.1.3   misho    2730:         struct bgp_info *ri = rn->info;
                   2731:         u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL;
                   2732: 
1.1       misho    2733:         bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer,
1.1.1.3   misho    2734:                 &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag);
1.1       misho    2735:       }
                   2736: }
                   2737: 
                   2738: void
                   2739: bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
                   2740: {
                   2741:   struct bgp_table *table;
                   2742:   struct bgp_node *rn;
                   2743:   
1.1.1.4 ! misho    2744:   if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
1.1.1.3   misho    2745:     bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL);
1.1       misho    2746: 
                   2747:   else
                   2748:     for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn;
                   2749:             rn = bgp_route_next (rn))
                   2750:       if ((table = rn->info) != NULL)
1.1.1.3   misho    2751:         {
                   2752:           struct prefix_rd prd;
                   2753:           prd.family = AF_UNSPEC;
                   2754:           prd.prefixlen = 64;
                   2755:           memcpy(&prd.val, rn->p.u.val, 8);
                   2756: 
                   2757:           bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd);
                   2758:         }
1.1       misho    2759: }
1.1.1.4 ! misho    2760: 
1.1       misho    2761: static void
                   2762: bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi,
1.1.1.3   misho    2763:                         struct bgp_table *table, struct prefix_rd *prd)
1.1       misho    2764: {
                   2765:   int ret;
                   2766:   struct bgp_node *rn;
                   2767:   struct bgp_adj_in *ain;
                   2768: 
                   2769:   if (! table)
                   2770:     table = peer->bgp->rib[afi][safi];
                   2771: 
                   2772:   for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
                   2773:     for (ain = rn->adj_in; ain; ain = ain->next)
                   2774:       {
                   2775:        if (ain->peer == peer)
                   2776:          {
1.1.1.3   misho    2777:            struct bgp_info *ri = rn->info;
                   2778:            u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL;
                   2779: 
1.1       misho    2780:            ret = bgp_update (peer, &rn->p, ain->attr, afi, safi,
                   2781:                              ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
1.1.1.3   misho    2782:                              prd, tag, 1);
                   2783: 
1.1       misho    2784:            if (ret < 0)
                   2785:              {
                   2786:                bgp_unlock_node (rn);
                   2787:                return;
                   2788:              }
                   2789:            continue;
                   2790:          }
                   2791:       }
                   2792: }
                   2793: 
                   2794: void
                   2795: bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi)
                   2796: {
                   2797:   struct bgp_node *rn;
                   2798:   struct bgp_table *table;
                   2799: 
                   2800:   if (peer->status != Established)
                   2801:     return;
                   2802: 
1.1.1.4 ! misho    2803:   if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
1.1.1.3   misho    2804:     bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL);
1.1       misho    2805:   else
                   2806:     for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
                   2807:         rn = bgp_route_next (rn))
                   2808:       if ((table = rn->info) != NULL)
1.1.1.3   misho    2809:         {
                   2810:           struct prefix_rd prd;
                   2811:           prd.family = AF_UNSPEC;
                   2812:           prd.prefixlen = 64;
                   2813:           memcpy(&prd.val, rn->p.u.val, 8);
                   2814: 
                   2815:           bgp_soft_reconfig_table (peer, afi, safi, table, &prd);
                   2816:         }
1.1       misho    2817: }
1.1.1.4 ! misho    2818: 
1.1       misho    2819: 
                   2820: struct bgp_clear_node_queue
                   2821: {
                   2822:   struct bgp_node *rn;
                   2823:   enum bgp_clear_route_type purpose;
                   2824: };
                   2825: 
                   2826: static wq_item_status
                   2827: bgp_clear_route_node (struct work_queue *wq, void *data)
                   2828: {
                   2829:   struct bgp_clear_node_queue *cnq = data;
                   2830:   struct bgp_node *rn = cnq->rn;
                   2831:   struct peer *peer = wq->spec.data;
                   2832:   struct bgp_info *ri;
1.1.1.3   misho    2833:   afi_t afi = bgp_node_table (rn)->afi;
                   2834:   safi_t safi = bgp_node_table (rn)->safi;
1.1       misho    2835:   
                   2836:   assert (rn && peer);
                   2837:   
                   2838:   for (ri = rn->info; ri; ri = ri->next)
                   2839:     if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
                   2840:       {
                   2841:         /* graceful restart STALE flag set. */
                   2842:         if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT)
                   2843:             && peer->nsf[afi][safi]
                   2844:             && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE)
                   2845:             && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
                   2846:           bgp_info_set_flag (rn, ri, BGP_INFO_STALE);
                   2847:         else
                   2848:           bgp_rib_remove (rn, ri, peer, afi, safi);
                   2849:         break;
                   2850:       }
                   2851:   return WQ_SUCCESS;
                   2852: }
                   2853: 
                   2854: static void
                   2855: bgp_clear_node_queue_del (struct work_queue *wq, void *data)
                   2856: {
                   2857:   struct bgp_clear_node_queue *cnq = data;
                   2858:   struct bgp_node *rn = cnq->rn;
1.1.1.3   misho    2859:   struct bgp_table *table = bgp_node_table (rn);
1.1       misho    2860:   
                   2861:   bgp_unlock_node (rn); 
                   2862:   bgp_table_unlock (table);
                   2863:   XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq);
                   2864: }
                   2865: 
                   2866: static void
                   2867: bgp_clear_node_complete (struct work_queue *wq)
                   2868: {
                   2869:   struct peer *peer = wq->spec.data;
                   2870:   
                   2871:   /* Tickle FSM to start moving again */
                   2872:   BGP_EVENT_ADD (peer, Clearing_Completed);
                   2873: 
                   2874:   peer_unlock (peer); /* bgp_clear_route */
                   2875: }
                   2876: 
                   2877: static void
                   2878: bgp_clear_node_queue_init (struct peer *peer)
                   2879: {
                   2880:   char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
                   2881:   
                   2882:   snprintf (wname, sizeof(wname), "clear %s", peer->host);
                   2883: #undef CLEAR_QUEUE_NAME_LEN
                   2884: 
                   2885:   if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL)
                   2886:     {
                   2887:       zlog_err ("%s: Failed to allocate work queue", __func__);
                   2888:       exit (1);
                   2889:     }
                   2890:   peer->clear_node_queue->spec.hold = 10;
                   2891:   peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node;
                   2892:   peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del;
                   2893:   peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete;
                   2894:   peer->clear_node_queue->spec.max_retries = 0;
                   2895:   
                   2896:   /* we only 'lock' this peer reference when the queue is actually active */
                   2897:   peer->clear_node_queue->spec.data = peer;
                   2898: }
                   2899: 
                   2900: static void
                   2901: bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi,
                   2902:                        struct bgp_table *table, struct peer *rsclient,
                   2903:                        enum bgp_clear_route_type purpose)
                   2904: {
                   2905:   struct bgp_node *rn;
                   2906:   
                   2907:   
                   2908:   if (! table)
                   2909:     table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi];
                   2910:   
                   2911:   /* If still no table => afi/safi isn't configured at all or smth. */
                   2912:   if (! table)
                   2913:     return;
                   2914:   
                   2915:   for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
                   2916:     {
                   2917:       struct bgp_info *ri;
                   2918:       struct bgp_adj_in *ain;
                   2919:       struct bgp_adj_out *aout;
                   2920: 
                   2921:       /* XXX:TODO: This is suboptimal, every non-empty route_node is
                   2922:        * queued for every clearing peer, regardless of whether it is
                   2923:        * relevant to the peer at hand.
                   2924:        *
                   2925:        * Overview: There are 3 different indices which need to be
                   2926:        * scrubbed, potentially, when a peer is removed:
                   2927:        *
                   2928:        * 1 peer's routes visible via the RIB (ie accepted routes)
                   2929:        * 2 peer's routes visible by the (optional) peer's adj-in index
                   2930:        * 3 other routes visible by the peer's adj-out index
                   2931:        *
                   2932:        * 3 there is no hurry in scrubbing, once the struct peer is
                   2933:        * removed from bgp->peer, we could just GC such deleted peer's
                   2934:        * adj-outs at our leisure.
                   2935:        *
                   2936:        * 1 and 2 must be 'scrubbed' in some way, at least made
                   2937:        * invisible via RIB index before peer session is allowed to be
                   2938:        * brought back up. So one needs to know when such a 'search' is
                   2939:        * complete.
                   2940:        *
                   2941:        * Ideally:
                   2942:        *
                   2943:        * - there'd be a single global queue or a single RIB walker
                   2944:        * - rather than tracking which route_nodes still need to be
                   2945:        *   examined on a peer basis, we'd track which peers still
                   2946:        *   aren't cleared
                   2947:        *
                   2948:        * Given that our per-peer prefix-counts now should be reliable,
                   2949:        * this may actually be achievable. It doesn't seem to be a huge
                   2950:        * problem at this time,
                   2951:        */
                   2952:       for (ain = rn->adj_in; ain; ain = ain->next)
                   2953:         if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
                   2954:           {
                   2955:             bgp_adj_in_remove (rn, ain);
                   2956:             bgp_unlock_node (rn);
                   2957:             break;
                   2958:           }
                   2959:       for (aout = rn->adj_out; aout; aout = aout->next)
                   2960:         if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
                   2961:           {
                   2962:             bgp_adj_out_remove (rn, aout, peer, afi, safi);
                   2963:             bgp_unlock_node (rn);
                   2964:             break;
                   2965:           }
1.1.1.3   misho    2966: 
                   2967:       for (ri = rn->info; ri; ri = ri->next)
                   2968:         if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
                   2969:           {
                   2970:             struct bgp_clear_node_queue *cnq;
                   2971: 
                   2972:             /* both unlocked in bgp_clear_node_queue_del */
                   2973:             bgp_table_lock (bgp_node_table (rn));
                   2974:             bgp_lock_node (rn);
                   2975:             cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE,
                   2976:                            sizeof (struct bgp_clear_node_queue));
                   2977:             cnq->rn = rn;
                   2978:             cnq->purpose = purpose;
                   2979:             work_queue_add (peer->clear_node_queue, cnq);
                   2980:             break;
                   2981:           }
1.1       misho    2982:     }
                   2983:   return;
                   2984: }
                   2985: 
                   2986: void
                   2987: bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi,
                   2988:                  enum bgp_clear_route_type purpose)
                   2989: {
                   2990:   struct bgp_node *rn;
                   2991:   struct bgp_table *table;
                   2992:   struct peer *rsclient;
                   2993:   struct listnode *node, *nnode;
                   2994: 
                   2995:   if (peer->clear_node_queue == NULL)
                   2996:     bgp_clear_node_queue_init (peer);
                   2997:   
                   2998:   /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
                   2999:    * Idle until it receives a Clearing_Completed event. This protects
                   3000:    * against peers which flap faster than we can we clear, which could
                   3001:    * lead to:
                   3002:    *
                   3003:    * a) race with routes from the new session being installed before
                   3004:    *    clear_route_node visits the node (to delete the route of that
                   3005:    *    peer)
                   3006:    * b) resource exhaustion, clear_route_node likely leads to an entry
                   3007:    *    on the process_main queue. Fast-flapping could cause that queue
                   3008:    *    to grow and grow.
                   3009:    */
1.1.1.4 ! misho    3010: 
        !          3011:   /* lock peer in assumption that clear-node-queue will get nodes; if so,
        !          3012:    * the unlock will happen upon work-queue completion; other wise, the
        !          3013:    * unlock happens at the end of this function.
        !          3014:    */
1.1       misho    3015:   if (!peer->clear_node_queue->thread)
                   3016:     peer_lock (peer); /* bgp_clear_node_complete */
                   3017:   switch (purpose)
                   3018:     {
                   3019:     case BGP_CLEAR_ROUTE_NORMAL:
1.1.1.4 ! misho    3020:       if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
1.1       misho    3021:         bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose);
                   3022:       else
                   3023:         for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
                   3024:              rn = bgp_route_next (rn))
                   3025:           if ((table = rn->info) != NULL)
                   3026:             bgp_clear_route_table (peer, afi, safi, table, NULL, purpose);
                   3027: 
                   3028:       for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient))
                   3029:         if (CHECK_FLAG(rsclient->af_flags[afi][safi],
                   3030:                        PEER_FLAG_RSERVER_CLIENT))
                   3031:           bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose);
                   3032:       break;
                   3033: 
                   3034:     case BGP_CLEAR_ROUTE_MY_RSCLIENT:
1.1.1.4 ! misho    3035:       /*
        !          3036:        * gpz 091009: TBD why don't we have special handling for
        !          3037:        * SAFI_MPLS_VPN here in the original quagga code?
        !          3038:        * (and, by extension, for SAFI_ENCAP)
        !          3039:        */
1.1       misho    3040:       bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose);
                   3041:       break;
                   3042: 
                   3043:     default:
                   3044:       assert (0);
                   3045:       break;
                   3046:     }
1.1.1.4 ! misho    3047: 
        !          3048:   /* unlock if no nodes got added to the clear-node-queue. */
1.1       misho    3049:   if (!peer->clear_node_queue->thread)
1.1.1.4 ! misho    3050:     peer_unlock (peer);
        !          3051: 
1.1       misho    3052: }
                   3053:   
                   3054: void
                   3055: bgp_clear_route_all (struct peer *peer)
                   3056: {
                   3057:   afi_t afi;
                   3058:   safi_t safi;
                   3059: 
                   3060:   for (afi = AFI_IP; afi < AFI_MAX; afi++)
                   3061:     for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
                   3062:       bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL);
                   3063: }
                   3064: 
1.1.1.4 ! misho    3065: /*
        !          3066:  * Finish freeing things when exiting
        !          3067:  */
        !          3068: static void
        !          3069: bgp_drain_workqueue_immediate (struct work_queue *wq)
        !          3070: {
        !          3071:   if (!wq)
        !          3072:     return;
        !          3073: 
        !          3074:   if (!wq->thread)
        !          3075:     {
        !          3076:       /*
        !          3077:        * no thread implies no queued items
        !          3078:        */
        !          3079:       assert(!wq->items->count);
        !          3080:       return;
        !          3081:     }
        !          3082: 
        !          3083:    while (wq->items->count)
        !          3084:      {
        !          3085:        if (wq->thread)
        !          3086:          thread_cancel(wq->thread);
        !          3087:        work_queue_run(wq->thread);
        !          3088:      }
        !          3089: }
        !          3090: 
        !          3091: /*
        !          3092:  * Special function to process clear node queue when bgpd is exiting
        !          3093:  * and the thread scheduler is no longer running.
        !          3094:  */
        !          3095: void
        !          3096: bgp_peer_clear_node_queue_drain_immediate(struct peer *peer)
        !          3097: {
        !          3098:   if (!peer)
        !          3099:     return;
        !          3100: 
        !          3101:   bgp_drain_workqueue_immediate(peer->clear_node_queue);
        !          3102: }
        !          3103: 
        !          3104: /*
        !          3105:  * The work queues are not specific to a BGP instance, but the
        !          3106:  * items in them refer to BGP instances, so this should be called
        !          3107:  * before each BGP instance is deleted.
        !          3108:  */
        !          3109: void
        !          3110: bgp_process_queues_drain_immediate(void)
        !          3111: {
        !          3112:   bgp_drain_workqueue_immediate(bm->process_main_queue);
        !          3113:   bgp_drain_workqueue_immediate(bm->process_rsclient_queue);
        !          3114: }
        !          3115: 
1.1       misho    3116: void
                   3117: bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi)
                   3118: {
                   3119:   struct bgp_table *table;
                   3120:   struct bgp_node *rn;
                   3121:   struct bgp_adj_in *ain;
                   3122: 
                   3123:   table = peer->bgp->rib[afi][safi];
                   3124: 
                   3125:   for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
                   3126:     for (ain = rn->adj_in; ain ; ain = ain->next)
                   3127:       if (ain->peer == peer)
                   3128:        {
                   3129:           bgp_adj_in_remove (rn, ain);
                   3130:           bgp_unlock_node (rn);
                   3131:           break;
                   3132:        }
                   3133: }
                   3134: 
                   3135: void
                   3136: bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi)
                   3137: {
                   3138:   struct bgp_node *rn;
                   3139:   struct bgp_info *ri;
                   3140:   struct bgp_table *table;
                   3141: 
                   3142:   table = peer->bgp->rib[afi][safi];
                   3143: 
                   3144:   for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
                   3145:     {
                   3146:       for (ri = rn->info; ri; ri = ri->next)
                   3147:        if (ri->peer == peer)
                   3148:          {
                   3149:            if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
                   3150:              bgp_rib_remove (rn, ri, peer, afi, safi);
                   3151:            break;
                   3152:          }
                   3153:     }
                   3154: }
1.1.1.4 ! misho    3155: 
        !          3156: static void
        !          3157: bgp_cleanup_table(struct bgp_table *table, safi_t safi)
        !          3158: {
        !          3159:   struct bgp_node *rn;
        !          3160:   struct bgp_info *ri;
        !          3161:   struct bgp_info *next;
        !          3162: 
        !          3163:   for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
        !          3164:     for (ri = rn->info; ri; ri = next)
        !          3165:       {
        !          3166:         next = ri->next;
        !          3167:         if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)
        !          3168:             && ri->type == ZEBRA_ROUTE_BGP
        !          3169:             && ri->sub_type == BGP_ROUTE_NORMAL)
        !          3170:           bgp_zebra_withdraw (&rn->p, ri, safi);
        !          3171:       }
        !          3172: }
        !          3173: 
1.1       misho    3174: /* Delete all kernel routes. */
                   3175: void
                   3176: bgp_cleanup_routes (void)
                   3177: {
                   3178:   struct bgp *bgp;
                   3179:   struct listnode *node, *nnode;
1.1.1.4 ! misho    3180:   afi_t afi;
1.1       misho    3181: 
                   3182:   for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
                   3183:     {
1.1.1.4 ! misho    3184:       for (afi = AFI_IP; afi < AFI_MAX; ++afi)
        !          3185:        {
        !          3186:          struct bgp_node *rn;
1.1       misho    3187: 
1.1.1.4 ! misho    3188:          bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST);
1.1       misho    3189: 
1.1.1.4 ! misho    3190:          /*
        !          3191:           * VPN and ENCAP tables are two-level (RD is top level)
        !          3192:           */
        !          3193:          for (rn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn;
        !          3194:                rn = bgp_route_next (rn))
        !          3195:            {
        !          3196:              if (rn->info)
        !          3197:                 {
        !          3198:                  bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_MPLS_VPN);
        !          3199:                  bgp_table_finish ((struct bgp_table **)&(rn->info));
        !          3200:                  rn->info = NULL;
        !          3201:                  bgp_unlock_node(rn);
        !          3202:                 }
        !          3203:            }
1.1       misho    3204: 
1.1.1.4 ! misho    3205:          for (rn = bgp_table_top(bgp->rib[afi][SAFI_ENCAP]); rn;
        !          3206:                rn = bgp_route_next (rn))
        !          3207:            {
        !          3208:              if (rn->info)
        !          3209:                {
        !          3210:                  bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_ENCAP);
        !          3211:                  bgp_table_finish ((struct bgp_table **)&(rn->info));
        !          3212:                  rn->info = NULL;
        !          3213:                  bgp_unlock_node(rn);
        !          3214:                }
        !          3215:            }
        !          3216:        }
1.1       misho    3217:     }
                   3218: }
                   3219: 
                   3220: void
                   3221: bgp_reset (void)
                   3222: {
                   3223:   vty_reset ();
                   3224:   bgp_zclient_reset ();
                   3225:   access_list_reset ();
                   3226:   prefix_list_reset ();
                   3227: }
1.1.1.4 ! misho    3228: 
1.1       misho    3229: /* Parse NLRI stream.  Withdraw NLRI is recognized by NULL attr
                   3230:    value. */
                   3231: int
1.1.1.4 ! misho    3232: bgp_nlri_parse_ip (struct peer *peer, struct attr *attr,
        !          3233:                    struct bgp_nlri *packet)
1.1       misho    3234: {
                   3235:   u_char *pnt;
                   3236:   u_char *lim;
                   3237:   struct prefix p;
                   3238:   int psize;
                   3239:   int ret;
                   3240: 
                   3241:   /* Check peer status. */
                   3242:   if (peer->status != Established)
                   3243:     return 0;
                   3244:   
                   3245:   pnt = packet->nlri;
                   3246:   lim = pnt + packet->length;
                   3247: 
1.1.1.4 ! misho    3248:   /* RFC4771 6.3 The NLRI field in the UPDATE message is checked for
        !          3249:      syntactic validity.  If the field is syntactically incorrect,
        !          3250:      then the Error Subcode is set to Invalid Network Field. */
1.1       misho    3251:   for (; pnt < lim; pnt += psize)
                   3252:     {
                   3253:       /* Clear prefix structure. */
                   3254:       memset (&p, 0, sizeof (struct prefix));
                   3255: 
                   3256:       /* Fetch prefix length. */
                   3257:       p.prefixlen = *pnt++;
1.1.1.4 ! misho    3258:       /* afi/safi validity already verified by caller, bgp_update_receive */
1.1       misho    3259:       p.family = afi2family (packet->afi);
                   3260:       
1.1.1.4 ! misho    3261:       /* Prefix length check. */
        !          3262:       if (p.prefixlen > prefix_blen (&p) * 8)
        !          3263:         {
        !          3264:           plog_err (peer->log,
        !          3265:                     "%s [Error] Update packet error"
        !          3266:                     " (wrong prefix length %u for afi %u)",
        !          3267:                     peer->host, p.prefixlen, packet->afi);
        !          3268:           return -1;
        !          3269:         }
        !          3270:       
1.1       misho    3271:       /* Packet size overflow check. */
                   3272:       psize = PSIZE (p.prefixlen);
                   3273: 
                   3274:       /* When packet overflow occur return immediately. */
                   3275:       if (pnt + psize > lim)
1.1.1.4 ! misho    3276:         {
        !          3277:           plog_err (peer->log,
        !          3278:                     "%s [Error] Update packet error"
        !          3279:                     " (prefix length %u overflows packet)",
        !          3280:                     peer->host, p.prefixlen);
        !          3281:           return -1;
        !          3282:         }
        !          3283:       
        !          3284:       /* Defensive coding, double-check the psize fits in a struct prefix */  
        !          3285:       if (psize > (ssize_t) sizeof(p.u))
        !          3286:         {
        !          3287:           plog_err (peer->log,
        !          3288:                     "%s [Error] Update packet error"
        !          3289:                     " (prefix length %u too large for prefix storage %zu!?!!",
        !          3290:                     peer->host, p.prefixlen, sizeof(p.u));
        !          3291:           return -1;
        !          3292:         }
1.1       misho    3293: 
                   3294:       /* Fetch prefix from NLRI packet. */
                   3295:       memcpy (&p.u.prefix, pnt, psize);
                   3296: 
                   3297:       /* Check address. */
                   3298:       if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST)
                   3299:        {
                   3300:          if (IN_CLASSD (ntohl (p.u.prefix4.s_addr)))
                   3301:            {
                   3302:             /* 
1.1.1.4 ! misho    3303:              * From RFC4271 Section 6.3: 
        !          3304:              * 
        !          3305:              * If a prefix in the NLRI field is semantically incorrect
        !          3306:              * (e.g., an unexpected multicast IP address), an error SHOULD
        !          3307:              * be logged locally, and the prefix SHOULD be ignored.
1.1       misho    3308:              */
                   3309:              zlog (peer->log, LOG_ERR, 
1.1.1.4 ! misho    3310:                    "%s: IPv4 unicast NLRI is multicast address %s, ignoring",
        !          3311:                    peer->host, inet_ntoa (p.u.prefix4));
        !          3312:              continue;
1.1       misho    3313:            }
                   3314:        }
                   3315: 
                   3316:       /* Check address. */
                   3317:       if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST)
                   3318:        {
                   3319:          if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
                   3320:            {
                   3321:              char buf[BUFSIZ];
                   3322: 
1.1.1.4 ! misho    3323:              zlog (peer->log, LOG_ERR, 
        !          3324:                    "%s: IPv6 unicast NLRI is link-local address %s, ignoring",
        !          3325:                    peer->host,
1.1       misho    3326:                    inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
1.1.1.4 ! misho    3327:              continue;
        !          3328:            }
        !          3329:          if (IN6_IS_ADDR_MULTICAST (&p.u.prefix6))
        !          3330:            {
        !          3331:              char buf[BUFSIZ];
1.1       misho    3332: 
1.1.1.4 ! misho    3333:              zlog (peer->log, LOG_ERR, 
        !          3334:                    "%s: IPv6 unicast NLRI is multicast address %s, ignoring",
        !          3335:                    peer->host,
        !          3336:                    inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
1.1       misho    3337:              continue;
                   3338:            }
1.1.1.4 ! misho    3339:         }
1.1       misho    3340: 
                   3341:       /* Normal process. */
                   3342:       if (attr)
                   3343:        ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, 
                   3344:                          ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0);
                   3345:       else
                   3346:        ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, 
                   3347:                            ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL);
                   3348: 
                   3349:       /* Address family configuration mismatch or maximum-prefix count
                   3350:          overflow. */
                   3351:       if (ret < 0)
                   3352:        return -1;
                   3353:     }
                   3354: 
                   3355:   /* Packet length consistency check. */
                   3356:   if (pnt != lim)
1.1.1.4 ! misho    3357:     {
        !          3358:       plog_err (peer->log,
        !          3359:                 "%s [Error] Update packet error"
        !          3360:                 " (prefix length mismatch with total length)",
        !          3361:                 peer->host);
        !          3362:       return -1;
        !          3363:     }
        !          3364:   
1.1       misho    3365:   return 0;
                   3366: }
                   3367: 
1.1.1.4 ! misho    3368: static struct bgp_static *
        !          3369: bgp_static_new (void)
1.1       misho    3370: {
1.1.1.4 ! misho    3371:   return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static));
        !          3372: }
1.1       misho    3373: 
                   3374: static void
                   3375: bgp_static_free (struct bgp_static *bgp_static)
                   3376: {
                   3377:   if (bgp_static->rmap.name)
                   3378:     free (bgp_static->rmap.name);
                   3379:   XFREE (MTYPE_BGP_STATIC, bgp_static);
                   3380: }
                   3381: 
                   3382: static void
                   3383: bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient,
                   3384:         struct prefix *p, afi_t afi, safi_t safi)
                   3385: {
                   3386:   struct bgp_node *rn;
                   3387:   struct bgp_info *ri;
                   3388: 
                   3389:   rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
                   3390: 
                   3391:   /* Check selected route and self inserted route. */
                   3392:   for (ri = rn->info; ri; ri = ri->next)
                   3393:     if (ri->peer == bgp->peer_self
                   3394:        && ri->type == ZEBRA_ROUTE_BGP
                   3395:        && ri->sub_type == BGP_ROUTE_STATIC)
                   3396:       break;
                   3397: 
                   3398:   /* Withdraw static BGP route from routing table. */
                   3399:   if (ri)
                   3400:     {
                   3401:       bgp_info_delete (rn, ri);
                   3402:       bgp_process (bgp, rn, afi, safi);
                   3403:     }
                   3404: 
                   3405:   /* Unlock bgp_node_lookup. */
                   3406:   bgp_unlock_node (rn);
                   3407: }
                   3408: 
                   3409: static void
                   3410: bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p,
                   3411:                             struct bgp_static *bgp_static,
                   3412:                             afi_t afi, safi_t safi)
                   3413: {
                   3414:   struct bgp_node *rn;
                   3415:   struct bgp_info *ri;
                   3416:   struct bgp_info *new;
                   3417:   struct bgp_info info;
                   3418:   struct attr *attr_new;
1.1.1.3   misho    3419:   struct attr attr;
                   3420:   struct attr new_attr;
                   3421:   struct attr_extra new_extra;
1.1       misho    3422:   struct bgp *bgp;
                   3423:   int ret;
                   3424:   char buf[SU_ADDRSTRLEN];
                   3425: 
                   3426:   bgp = rsclient->bgp;
                   3427: 
                   3428:   assert (bgp_static);
                   3429:   if (!bgp_static)
                   3430:     return;
                   3431: 
                   3432:   rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
                   3433: 
                   3434:   bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
                   3435: 
                   3436:   attr.nexthop = bgp_static->igpnexthop;
                   3437:   attr.med = bgp_static->igpmetric;
                   3438:   attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
                   3439:   
                   3440:   if (bgp_static->atomic)
                   3441:     attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
                   3442:   
                   3443:   /* Apply network route-map for export to this rsclient. */
                   3444:   if (bgp_static->rmap.name)
                   3445:     {
                   3446:       struct attr attr_tmp = attr;
                   3447:       info.peer = rsclient;
                   3448:       info.attr = &attr_tmp;
                   3449:       
                   3450:       SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
                   3451:       SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK);
                   3452: 
                   3453:       ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
                   3454: 
                   3455:       rsclient->rmap_type = 0;
                   3456: 
                   3457:       if (ret == RMAP_DENYMATCH)
                   3458:         {
                   3459:           /* Free uninterned attribute. */
                   3460:           bgp_attr_flush (&attr_tmp);
                   3461: 
                   3462:           /* Unintern original. */
                   3463:           aspath_unintern (&attr.aspath);
                   3464:           bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
                   3465:           bgp_attr_extra_free (&attr);
                   3466:           
                   3467:           return;
                   3468:         }
                   3469:       attr_new = bgp_attr_intern (&attr_tmp);
                   3470:     }
                   3471:   else
                   3472:     attr_new = bgp_attr_intern (&attr);
1.1.1.3   misho    3473: 
                   3474:   new_attr.extra = &new_extra;
1.1       misho    3475:   bgp_attr_dup(&new_attr, attr_new);
                   3476:   
                   3477:   SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
                   3478: 
                   3479:   if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) 
                   3480:         == RMAP_DENY)
                   3481:     {
                   3482:       /* This BGP update is filtered.  Log the reason then update BGP entry.  */
                   3483:       if (BGP_DEBUG (update, UPDATE_IN))
                   3484:               zlog (rsclient->log, LOG_DEBUG,
                   3485:               "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
                   3486:               inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
                   3487:               p->prefixlen, rsclient->host);
                   3488: 
                   3489:       bgp->peer_self->rmap_type = 0;
                   3490: 
                   3491:       bgp_attr_unintern (&attr_new);
                   3492:       aspath_unintern (&attr.aspath);
                   3493:       bgp_attr_extra_free (&attr);
                   3494: 
                   3495:       bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
                   3496:       
                   3497:       return;
                   3498:     }
                   3499: 
                   3500:   bgp->peer_self->rmap_type = 0;
                   3501: 
                   3502:   bgp_attr_unintern (&attr_new);
                   3503:   attr_new = bgp_attr_intern (&new_attr);
                   3504: 
                   3505:   for (ri = rn->info; ri; ri = ri->next)
                   3506:     if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
                   3507:             && ri->sub_type == BGP_ROUTE_STATIC)
                   3508:       break;
                   3509: 
                   3510:   if (ri)
                   3511:        {
                   3512:       if (attrhash_cmp (ri->attr, attr_new) &&
                   3513:          !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
                   3514:         {
                   3515:           bgp_unlock_node (rn);
                   3516:           bgp_attr_unintern (&attr_new);
                   3517:           aspath_unintern (&attr.aspath);
                   3518:           bgp_attr_extra_free (&attr);
                   3519:           return;
                   3520:        }
                   3521:       else
                   3522:         {
                   3523:           /* The attribute is changed. */
                   3524:           bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
                   3525: 
                   3526:           /* Rewrite BGP route information. */
                   3527:          if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
                   3528:            bgp_info_restore(rn, ri);
                   3529:           bgp_attr_unintern (&ri->attr);
                   3530:           ri->attr = attr_new;
                   3531:           ri->uptime = bgp_clock ();
                   3532: 
                   3533:           /* Process change. */
                   3534:           bgp_process (bgp, rn, afi, safi);
                   3535:           bgp_unlock_node (rn);
                   3536:           aspath_unintern (&attr.aspath);
                   3537:           bgp_attr_extra_free (&attr);
                   3538:           return;
                   3539:         }
                   3540:     }
                   3541:   
                   3542:   /* Make new BGP info. */
                   3543:   new = bgp_info_new ();
                   3544:   new->type = ZEBRA_ROUTE_BGP;
                   3545:   new->sub_type = BGP_ROUTE_STATIC;
                   3546:   new->peer = bgp->peer_self;
                   3547:   SET_FLAG (new->flags, BGP_INFO_VALID);
                   3548:   new->attr = attr_new;
                   3549:   new->uptime = bgp_clock ();
                   3550: 
                   3551:   /* Register new BGP information. */
                   3552:   bgp_info_add (rn, new);
                   3553:   
                   3554:   /* route_node_get lock */
                   3555:   bgp_unlock_node (rn);
                   3556:   
                   3557:   /* Process change. */
                   3558:   bgp_process (bgp, rn, afi, safi);
                   3559: 
                   3560:   /* Unintern original. */
                   3561:   aspath_unintern (&attr.aspath);
                   3562:   bgp_attr_extra_free (&attr);
                   3563: }
                   3564: 
                   3565: static void
                   3566: bgp_static_update_main (struct bgp *bgp, struct prefix *p,
                   3567:                   struct bgp_static *bgp_static, afi_t afi, safi_t safi)
                   3568: {
                   3569:   struct bgp_node *rn;
                   3570:   struct bgp_info *ri;
                   3571:   struct bgp_info *new;
                   3572:   struct bgp_info info;
1.1.1.3   misho    3573:   struct attr attr;
1.1       misho    3574:   struct attr *attr_new;
                   3575:   int ret;
                   3576: 
                   3577:   assert (bgp_static);
                   3578:   if (!bgp_static)
                   3579:     return;
                   3580: 
                   3581:   rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
                   3582: 
                   3583:   bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
                   3584:   
                   3585:   attr.nexthop = bgp_static->igpnexthop;
                   3586:   attr.med = bgp_static->igpmetric;
                   3587:   attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
                   3588: 
                   3589:   if (bgp_static->atomic)
                   3590:     attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
                   3591: 
                   3592:   /* Apply route-map. */
                   3593:   if (bgp_static->rmap.name)
                   3594:     {
                   3595:       struct attr attr_tmp = attr;
                   3596:       info.peer = bgp->peer_self;
                   3597:       info.attr = &attr_tmp;
                   3598: 
                   3599:       SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
                   3600: 
                   3601:       ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
                   3602: 
                   3603:       bgp->peer_self->rmap_type = 0;
                   3604: 
                   3605:       if (ret == RMAP_DENYMATCH)
                   3606:        {    
                   3607:          /* Free uninterned attribute. */
                   3608:          bgp_attr_flush (&attr_tmp);
                   3609: 
                   3610:          /* Unintern original. */
                   3611:          aspath_unintern (&attr.aspath);
                   3612:          bgp_attr_extra_free (&attr);
                   3613:          bgp_static_withdraw (bgp, p, afi, safi);
                   3614:          return;
                   3615:        }
                   3616:       attr_new = bgp_attr_intern (&attr_tmp);
                   3617:     }
                   3618:   else
                   3619:     attr_new = bgp_attr_intern (&attr);
                   3620: 
                   3621:   for (ri = rn->info; ri; ri = ri->next)
                   3622:     if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
                   3623:        && ri->sub_type == BGP_ROUTE_STATIC)
                   3624:       break;
                   3625: 
                   3626:   if (ri)
                   3627:     {
                   3628:       if (attrhash_cmp (ri->attr, attr_new) &&
                   3629:          !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
                   3630:        {
                   3631:          bgp_unlock_node (rn);
                   3632:          bgp_attr_unintern (&attr_new);
                   3633:          aspath_unintern (&attr.aspath);
                   3634:          bgp_attr_extra_free (&attr);
                   3635:          return;
                   3636:        }
                   3637:       else
                   3638:        {
                   3639:          /* The attribute is changed. */
                   3640:          bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
                   3641: 
                   3642:          /* Rewrite BGP route information. */
                   3643:          if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
                   3644:            bgp_info_restore(rn, ri);
                   3645:          else
                   3646:            bgp_aggregate_decrement (bgp, p, ri, afi, safi);
                   3647:          bgp_attr_unintern (&ri->attr);
                   3648:          ri->attr = attr_new;
                   3649:          ri->uptime = bgp_clock ();
                   3650: 
                   3651:          /* Process change. */
                   3652:          bgp_aggregate_increment (bgp, p, ri, afi, safi);
                   3653:          bgp_process (bgp, rn, afi, safi);
                   3654:          bgp_unlock_node (rn);
                   3655:          aspath_unintern (&attr.aspath);
                   3656:          bgp_attr_extra_free (&attr);
                   3657:          return;
                   3658:        }
                   3659:     }
                   3660: 
                   3661:   /* Make new BGP info. */
                   3662:   new = bgp_info_new ();
                   3663:   new->type = ZEBRA_ROUTE_BGP;
                   3664:   new->sub_type = BGP_ROUTE_STATIC;
                   3665:   new->peer = bgp->peer_self;
                   3666:   SET_FLAG (new->flags, BGP_INFO_VALID);
                   3667:   new->attr = attr_new;
                   3668:   new->uptime = bgp_clock ();
                   3669: 
                   3670:   /* Aggregate address increment. */
                   3671:   bgp_aggregate_increment (bgp, p, new, afi, safi);
                   3672:   
                   3673:   /* Register new BGP information. */
                   3674:   bgp_info_add (rn, new);
                   3675:   
                   3676:   /* route_node_get lock */
                   3677:   bgp_unlock_node (rn);
                   3678:   
                   3679:   /* Process change. */
                   3680:   bgp_process (bgp, rn, afi, safi);
                   3681: 
                   3682:   /* Unintern original. */
                   3683:   aspath_unintern (&attr.aspath);
                   3684:   bgp_attr_extra_free (&attr);
                   3685: }
                   3686: 
                   3687: void
                   3688: bgp_static_update (struct bgp *bgp, struct prefix *p,
                   3689:                   struct bgp_static *bgp_static, afi_t afi, safi_t safi)
                   3690: {
                   3691:   struct peer *rsclient;
                   3692:   struct listnode *node, *nnode;
                   3693: 
                   3694:   bgp_static_update_main (bgp, p, bgp_static, afi, safi);
                   3695: 
                   3696:   for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
                   3697:     {
                   3698:       if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
                   3699:         bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi);
                   3700:     }
                   3701: }
                   3702: 
                   3703: void
                   3704: bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi,
                   3705:                     safi_t safi)
                   3706: {
                   3707:   struct bgp_node *rn;
                   3708:   struct bgp_info *ri;
                   3709: 
                   3710:   rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
                   3711: 
                   3712:   /* Check selected route and self inserted route. */
                   3713:   for (ri = rn->info; ri; ri = ri->next)
                   3714:     if (ri->peer == bgp->peer_self 
                   3715:        && ri->type == ZEBRA_ROUTE_BGP
                   3716:        && ri->sub_type == BGP_ROUTE_STATIC)
                   3717:       break;
                   3718: 
                   3719:   /* Withdraw static BGP route from routing table. */
                   3720:   if (ri)
                   3721:     {
                   3722:       bgp_aggregate_decrement (bgp, p, ri, afi, safi);
                   3723:       bgp_info_delete (rn, ri);
                   3724:       bgp_process (bgp, rn, afi, safi);
                   3725:     }
                   3726: 
                   3727:   /* Unlock bgp_node_lookup. */
                   3728:   bgp_unlock_node (rn);
                   3729: }
                   3730: 
                   3731: void
                   3732: bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
                   3733: {
                   3734:   struct bgp_static *bgp_static;
                   3735:   struct bgp *bgp;
                   3736:   struct bgp_node *rn;
                   3737:   struct prefix *p;
                   3738: 
                   3739:   bgp = rsclient->bgp;
                   3740: 
                   3741:   for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
                   3742:     if ((bgp_static = rn->info) != NULL)
                   3743:       {
                   3744:         p = &rn->p;
                   3745: 
                   3746:         bgp_static_update_rsclient (rsclient, p, bgp_static,
                   3747:                 afi, safi);
                   3748:       }
                   3749: }
                   3750: 
1.1.1.4 ! misho    3751: /*
        !          3752:  * Used for SAFI_MPLS_VPN and SAFI_ENCAP
        !          3753:  */
1.1       misho    3754: static void
1.1.1.4 ! misho    3755: bgp_static_withdraw_safi (struct bgp *bgp, struct prefix *p, afi_t afi,
        !          3756:                           safi_t safi, struct prefix_rd *prd, u_char *tag)
1.1       misho    3757: {
                   3758:   struct bgp_node *rn;
                   3759:   struct bgp_info *ri;
                   3760: 
                   3761:   rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
                   3762: 
                   3763:   /* Check selected route and self inserted route. */
                   3764:   for (ri = rn->info; ri; ri = ri->next)
                   3765:     if (ri->peer == bgp->peer_self 
                   3766:        && ri->type == ZEBRA_ROUTE_BGP
                   3767:        && ri->sub_type == BGP_ROUTE_STATIC)
                   3768:       break;
                   3769: 
                   3770:   /* Withdraw static BGP route from routing table. */
                   3771:   if (ri)
                   3772:     {
                   3773:       bgp_aggregate_decrement (bgp, p, ri, afi, safi);
                   3774:       bgp_info_delete (rn, ri);
                   3775:       bgp_process (bgp, rn, afi, safi);
                   3776:     }
                   3777: 
                   3778:   /* Unlock bgp_node_lookup. */
                   3779:   bgp_unlock_node (rn);
                   3780: }
                   3781: 
1.1.1.4 ! misho    3782: static void
        !          3783: bgp_static_update_safi (struct bgp *bgp, struct prefix *p,
        !          3784:                         struct bgp_static *bgp_static, afi_t afi, safi_t safi)
        !          3785: {
        !          3786:   struct bgp_node *rn;
        !          3787:   struct bgp_info *new;
        !          3788:   struct attr *attr_new;
        !          3789:   struct attr attr = { 0 };
        !          3790:   struct bgp_info *ri;
        !          3791: 
        !          3792:   assert (bgp_static);
        !          3793: 
        !          3794:   rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, &bgp_static->prd);
        !          3795: 
        !          3796:   bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
        !          3797: 
        !          3798:   attr.nexthop = bgp_static->igpnexthop;
        !          3799:   attr.med = bgp_static->igpmetric;
        !          3800:   attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
        !          3801: 
        !          3802:   /* Apply route-map. */
        !          3803:   if (bgp_static->rmap.name)
        !          3804:     {
        !          3805:       struct attr attr_tmp = attr;
        !          3806:       struct bgp_info info;
        !          3807:       int ret;
        !          3808: 
        !          3809:       info.peer = bgp->peer_self;
        !          3810:       info.attr = &attr_tmp;
        !          3811: 
        !          3812:       SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
        !          3813: 
        !          3814:       ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
        !          3815: 
        !          3816:       bgp->peer_self->rmap_type = 0;
        !          3817: 
        !          3818:       if (ret == RMAP_DENYMATCH)
        !          3819:         {
        !          3820:           /* Free uninterned attribute. */
        !          3821:           bgp_attr_flush (&attr_tmp);
        !          3822: 
        !          3823:           /* Unintern original. */
        !          3824:           aspath_unintern (&attr.aspath);
        !          3825:           bgp_attr_extra_free (&attr);
        !          3826:           bgp_static_withdraw_safi (bgp, p, afi, safi, &bgp_static->prd,
        !          3827:                                     bgp_static->tag);
        !          3828:           return;
        !          3829:         }
        !          3830: 
        !          3831:       attr_new = bgp_attr_intern (&attr_tmp);
        !          3832:     }
        !          3833:   else
        !          3834:     {
        !          3835:       attr_new = bgp_attr_intern (&attr);
        !          3836:     }
        !          3837: 
        !          3838:   for (ri = rn->info; ri; ri = ri->next)
        !          3839:     if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
        !          3840:         && ri->sub_type == BGP_ROUTE_STATIC)
        !          3841:       break;
        !          3842: 
        !          3843:   if (ri)
        !          3844:     {
        !          3845:       if (attrhash_cmp (ri->attr, attr_new) &&
        !          3846:           !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
        !          3847:         {
        !          3848:           bgp_unlock_node (rn);
        !          3849:           bgp_attr_unintern (&attr_new);
        !          3850:           aspath_unintern (&attr.aspath);
        !          3851:           bgp_attr_extra_free (&attr);
        !          3852:           return;
        !          3853:         }
        !          3854:       else
        !          3855:         {
        !          3856:           /* The attribute is changed. */
        !          3857:           bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
        !          3858: 
        !          3859:           /* Rewrite BGP route information. */
        !          3860:           if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
        !          3861:             bgp_info_restore(rn, ri);
        !          3862:           else
        !          3863:             bgp_aggregate_decrement (bgp, p, ri, afi, safi);
        !          3864:           bgp_attr_unintern (&ri->attr);
        !          3865:           ri->attr = attr_new;
        !          3866:           ri->uptime = bgp_clock ();
        !          3867: 
        !          3868:           /* Process change. */
        !          3869:           bgp_aggregate_increment (bgp, p, ri, afi, safi);
        !          3870:           bgp_process (bgp, rn, afi, safi);
        !          3871:           bgp_unlock_node (rn);
        !          3872:           aspath_unintern (&attr.aspath);
        !          3873:           bgp_attr_extra_free (&attr);
        !          3874:           return;
        !          3875:         }
        !          3876:     }
        !          3877: 
        !          3878: 
        !          3879:   /* Make new BGP info. */
        !          3880:   new = bgp_info_new ();
        !          3881:   new->type = ZEBRA_ROUTE_BGP;
        !          3882:   new->sub_type = BGP_ROUTE_STATIC;
        !          3883:   new->peer = bgp->peer_self;
        !          3884:   new->attr = attr_new;
        !          3885:   SET_FLAG (new->flags, BGP_INFO_VALID);
        !          3886:   new->uptime = bgp_clock ();
        !          3887:   new->extra = bgp_info_extra_new();
        !          3888:   memcpy (new->extra->tag, bgp_static->tag, 3);
        !          3889: 
        !          3890:   /* Aggregate address increment. */
        !          3891:   bgp_aggregate_increment (bgp, p, new, afi, safi);
        !          3892: 
        !          3893:   /* Register new BGP information. */
        !          3894:   bgp_info_add (rn, new);
        !          3895: 
        !          3896:   /* route_node_get lock */
        !          3897:   bgp_unlock_node (rn);
        !          3898: 
        !          3899:   /* Process change. */
        !          3900:   bgp_process (bgp, rn, afi, safi);
        !          3901: 
        !          3902:   /* Unintern original. */
        !          3903:   aspath_unintern (&attr.aspath);
        !          3904:   bgp_attr_extra_free (&attr);
        !          3905: }
        !          3906: 
1.1       misho    3907: /* Configure static BGP network.  When user don't run zebra, static
                   3908:    route should be installed as valid.  */
                   3909: static int
                   3910: bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, 
                   3911:                 afi_t afi, safi_t safi, const char *rmap, int backdoor)
                   3912: {
                   3913:   int ret;
                   3914:   struct prefix p;
                   3915:   struct bgp_static *bgp_static;
                   3916:   struct bgp_node *rn;
                   3917:   u_char need_update = 0;
                   3918: 
                   3919:   /* Convert IP prefix string to struct prefix. */
                   3920:   ret = str2prefix (ip_str, &p);
                   3921:   if (! ret)
                   3922:     {
                   3923:       vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
                   3924:       return CMD_WARNING;
                   3925:     }
                   3926:   if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
                   3927:     {
                   3928:       vty_out (vty, "%% Malformed prefix (link-local address)%s",
                   3929:               VTY_NEWLINE);
                   3930:       return CMD_WARNING;
                   3931:     }
                   3932: 
                   3933:   apply_mask (&p);
                   3934: 
                   3935:   /* Set BGP static route configuration. */
                   3936:   rn = bgp_node_get (bgp->route[afi][safi], &p);
                   3937: 
                   3938:   if (rn->info)
                   3939:     {
                   3940:       /* Configuration change. */
                   3941:       bgp_static = rn->info;
                   3942: 
                   3943:       /* Check previous routes are installed into BGP.  */
                   3944:       if (bgp_static->valid && bgp_static->backdoor != backdoor)
                   3945:         need_update = 1;
                   3946:       
                   3947:       bgp_static->backdoor = backdoor;
                   3948:       
                   3949:       if (rmap)
                   3950:        {
                   3951:          if (bgp_static->rmap.name)
                   3952:            free (bgp_static->rmap.name);
                   3953:          bgp_static->rmap.name = strdup (rmap);
                   3954:          bgp_static->rmap.map = route_map_lookup_by_name (rmap);
                   3955:        }
                   3956:       else
                   3957:        {
                   3958:          if (bgp_static->rmap.name)
                   3959:            free (bgp_static->rmap.name);
                   3960:          bgp_static->rmap.name = NULL;
                   3961:          bgp_static->rmap.map = NULL;
                   3962:          bgp_static->valid = 0;
                   3963:        }
                   3964:       bgp_unlock_node (rn);
                   3965:     }
                   3966:   else
                   3967:     {
                   3968:       /* New configuration. */
                   3969:       bgp_static = bgp_static_new ();
                   3970:       bgp_static->backdoor = backdoor;
                   3971:       bgp_static->valid = 0;
                   3972:       bgp_static->igpmetric = 0;
                   3973:       bgp_static->igpnexthop.s_addr = 0;
                   3974:       
                   3975:       if (rmap)
                   3976:        {
                   3977:          if (bgp_static->rmap.name)
                   3978:            free (bgp_static->rmap.name);
                   3979:          bgp_static->rmap.name = strdup (rmap);
                   3980:          bgp_static->rmap.map = route_map_lookup_by_name (rmap);
                   3981:        }
                   3982:       rn->info = bgp_static;
                   3983:     }
                   3984: 
                   3985:   /* If BGP scan is not enabled, we should install this route here.  */
                   3986:   if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
                   3987:     {
                   3988:       bgp_static->valid = 1;
                   3989: 
                   3990:       if (need_update)
                   3991:        bgp_static_withdraw (bgp, &p, afi, safi);
                   3992: 
                   3993:       if (! bgp_static->backdoor)
                   3994:        bgp_static_update (bgp, &p, bgp_static, afi, safi);
                   3995:     }
                   3996: 
                   3997:   return CMD_SUCCESS;
                   3998: }
                   3999: 
                   4000: /* Configure static BGP network. */
                   4001: static int
                   4002: bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str,
                   4003:                  afi_t afi, safi_t safi)
                   4004: {
                   4005:   int ret;
                   4006:   struct prefix p;
                   4007:   struct bgp_static *bgp_static;
                   4008:   struct bgp_node *rn;
                   4009: 
                   4010:   /* Convert IP prefix string to struct prefix. */
                   4011:   ret = str2prefix (ip_str, &p);
                   4012:   if (! ret)
                   4013:     {
                   4014:       vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
                   4015:       return CMD_WARNING;
                   4016:     }
                   4017:   if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
                   4018:     {
                   4019:       vty_out (vty, "%% Malformed prefix (link-local address)%s",
                   4020:               VTY_NEWLINE);
                   4021:       return CMD_WARNING;
                   4022:     }
                   4023: 
                   4024:   apply_mask (&p);
                   4025: 
                   4026:   rn = bgp_node_lookup (bgp->route[afi][safi], &p);
                   4027:   if (! rn)
                   4028:     {
                   4029:       vty_out (vty, "%% Can't find specified static route configuration.%s",
                   4030:               VTY_NEWLINE);
                   4031:       return CMD_WARNING;
                   4032:     }
                   4033: 
                   4034:   bgp_static = rn->info;
                   4035:   
                   4036:   /* Update BGP RIB. */
                   4037:   if (! bgp_static->backdoor)
                   4038:     bgp_static_withdraw (bgp, &p, afi, safi);
                   4039: 
                   4040:   /* Clear configuration. */
                   4041:   bgp_static_free (bgp_static);
                   4042:   rn->info = NULL;
                   4043:   bgp_unlock_node (rn);
                   4044:   bgp_unlock_node (rn);
                   4045: 
                   4046:   return CMD_SUCCESS;
                   4047: }
                   4048: 
                   4049: /* Called from bgp_delete().  Delete all static routes from the BGP
                   4050:    instance. */
                   4051: void
                   4052: bgp_static_delete (struct bgp *bgp)
                   4053: {
                   4054:   afi_t afi;
                   4055:   safi_t safi;
                   4056:   struct bgp_node *rn;
                   4057:   struct bgp_node *rm;
                   4058:   struct bgp_table *table;
                   4059:   struct bgp_static *bgp_static;
                   4060: 
                   4061:   for (afi = AFI_IP; afi < AFI_MAX; afi++)
                   4062:     for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
                   4063:       for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
                   4064:        if (rn->info != NULL)
                   4065:          {      
1.1.1.4 ! misho    4066:            if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
1.1       misho    4067:              {
                   4068:                table = rn->info;
                   4069: 
                   4070:                for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
                   4071:                  {
                   4072:                    bgp_static = rn->info;
1.1.1.4 ! misho    4073:                    bgp_static_withdraw_safi (bgp, &rm->p,
        !          4074:                                               AFI_IP, safi,
1.1       misho    4075:                                               (struct prefix_rd *)&rn->p,
                   4076:                                               bgp_static->tag);
                   4077:                    bgp_static_free (bgp_static);
                   4078:                    rn->info = NULL;
                   4079:                    bgp_unlock_node (rn);
                   4080:                  }
                   4081:              }
                   4082:            else
                   4083:              {
                   4084:                bgp_static = rn->info;
                   4085:                bgp_static_withdraw (bgp, &rn->p, afi, safi);
                   4086:                bgp_static_free (bgp_static);
                   4087:                rn->info = NULL;
                   4088:                bgp_unlock_node (rn);
                   4089:              }
                   4090:          }
                   4091: }
                   4092: 
1.1.1.4 ! misho    4093: /*
        !          4094:  * gpz 110624
        !          4095:  * Currently this is used to set static routes for VPN and ENCAP.
        !          4096:  * I think it can probably be factored with bgp_static_set.
        !          4097:  */
1.1       misho    4098: int
1.1.1.4 ! misho    4099: bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str,
        !          4100:                      const char *rd_str, const char *tag_str,
        !          4101:                      const char *rmap_str)
1.1       misho    4102: {
                   4103:   int ret;
                   4104:   struct prefix p;
                   4105:   struct prefix_rd prd;
                   4106:   struct bgp *bgp;
                   4107:   struct bgp_node *prn;
                   4108:   struct bgp_node *rn;
                   4109:   struct bgp_table *table;
                   4110:   struct bgp_static *bgp_static;
                   4111:   u_char tag[3];
                   4112: 
                   4113:   bgp = vty->index;
                   4114: 
                   4115:   ret = str2prefix (ip_str, &p);
                   4116:   if (! ret)
                   4117:     {
                   4118:       vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
                   4119:       return CMD_WARNING;
                   4120:     }
                   4121:   apply_mask (&p);
                   4122: 
                   4123:   ret = str2prefix_rd (rd_str, &prd);
                   4124:   if (! ret)
                   4125:     {
                   4126:       vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
                   4127:       return CMD_WARNING;
                   4128:     }
                   4129: 
                   4130:   ret = str2tag (tag_str, tag);
                   4131:   if (! ret)
                   4132:     {
                   4133:       vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
                   4134:       return CMD_WARNING;
                   4135:     }
                   4136: 
1.1.1.4 ! misho    4137:   prn = bgp_node_get (bgp->route[AFI_IP][safi],
1.1       misho    4138:                        (struct prefix *)&prd);
                   4139:   if (prn->info == NULL)
1.1.1.4 ! misho    4140:     prn->info = bgp_table_init (AFI_IP, safi);
1.1       misho    4141:   else
                   4142:     bgp_unlock_node (prn);
                   4143:   table = prn->info;
                   4144: 
                   4145:   rn = bgp_node_get (table, &p);
                   4146: 
                   4147:   if (rn->info)
                   4148:     {
                   4149:       vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE);
                   4150:       bgp_unlock_node (rn);
                   4151:     }
                   4152:   else
                   4153:     {
                   4154:       /* New configuration. */
                   4155:       bgp_static = bgp_static_new ();
1.1.1.4 ! misho    4156:       bgp_static->backdoor = 0;
        !          4157:       bgp_static->valid = 0;
        !          4158:       bgp_static->igpmetric = 0;
        !          4159:       bgp_static->igpnexthop.s_addr = 0;
        !          4160:       memcpy(bgp_static->tag, tag, 3);
        !          4161:       bgp_static->prd = prd;
        !          4162: 
        !          4163:       if (rmap_str)
        !          4164:        {
        !          4165:          if (bgp_static->rmap.name)
        !          4166:            free (bgp_static->rmap.name);
        !          4167:          bgp_static->rmap.name = strdup (rmap_str);
        !          4168:          bgp_static->rmap.map = route_map_lookup_by_name (rmap_str);
        !          4169:        }
1.1       misho    4170:       rn->info = bgp_static;
                   4171: 
1.1.1.4 ! misho    4172:       bgp_static->valid = 1;
        !          4173:       bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi);
1.1       misho    4174:     }
                   4175: 
                   4176:   return CMD_SUCCESS;
                   4177: }
                   4178: 
                   4179: /* Configure static BGP network. */
                   4180: int
1.1.1.4 ! misho    4181: bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str,
        !          4182:                       const char *rd_str, const char *tag_str)
1.1       misho    4183: {
                   4184:   int ret;
                   4185:   struct bgp *bgp;
                   4186:   struct prefix p;
                   4187:   struct prefix_rd prd;
                   4188:   struct bgp_node *prn;
                   4189:   struct bgp_node *rn;
                   4190:   struct bgp_table *table;
                   4191:   struct bgp_static *bgp_static;
                   4192:   u_char tag[3];
                   4193: 
                   4194:   bgp = vty->index;
                   4195: 
                   4196:   /* Convert IP prefix string to struct prefix. */
                   4197:   ret = str2prefix (ip_str, &p);
                   4198:   if (! ret)
                   4199:     {
                   4200:       vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
                   4201:       return CMD_WARNING;
                   4202:     }
                   4203:   apply_mask (&p);
                   4204: 
                   4205:   ret = str2prefix_rd (rd_str, &prd);
                   4206:   if (! ret)
                   4207:     {
                   4208:       vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
                   4209:       return CMD_WARNING;
                   4210:     }
                   4211: 
                   4212:   ret = str2tag (tag_str, tag);
                   4213:   if (! ret)
                   4214:     {
                   4215:       vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
                   4216:       return CMD_WARNING;
                   4217:     }
                   4218: 
1.1.1.4 ! misho    4219:   prn = bgp_node_get (bgp->route[AFI_IP][safi],
1.1       misho    4220:                        (struct prefix *)&prd);
                   4221:   if (prn->info == NULL)
1.1.1.4 ! misho    4222:     prn->info = bgp_table_init (AFI_IP, safi);
1.1       misho    4223:   else
                   4224:     bgp_unlock_node (prn);
                   4225:   table = prn->info;
                   4226: 
                   4227:   rn = bgp_node_lookup (table, &p);
                   4228: 
                   4229:   if (rn)
                   4230:     {
1.1.1.4 ! misho    4231:       bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, tag);
1.1       misho    4232: 
                   4233:       bgp_static = rn->info;
                   4234:       bgp_static_free (bgp_static);
                   4235:       rn->info = NULL;
                   4236:       bgp_unlock_node (rn);
                   4237:       bgp_unlock_node (rn);
                   4238:     }
                   4239:   else
                   4240:     vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE);
                   4241: 
                   4242:   return CMD_SUCCESS;
                   4243: }
1.1.1.4 ! misho    4244: 
1.1       misho    4245: DEFUN (bgp_network,
                   4246:        bgp_network_cmd,
                   4247:        "network A.B.C.D/M",
                   4248:        "Specify a network to announce via BGP\n"
                   4249:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
                   4250: {
                   4251:   return bgp_static_set (vty, vty->index, argv[0],
                   4252:                         AFI_IP, bgp_node_safi (vty), NULL, 0);
                   4253: }
                   4254: 
                   4255: DEFUN (bgp_network_route_map,
                   4256:        bgp_network_route_map_cmd,
                   4257:        "network A.B.C.D/M route-map WORD",
                   4258:        "Specify a network to announce via BGP\n"
                   4259:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
                   4260:        "Route-map to modify the attributes\n"
                   4261:        "Name of the route map\n")
                   4262: {
                   4263:   return bgp_static_set (vty, vty->index, argv[0],
                   4264:                         AFI_IP, bgp_node_safi (vty), argv[1], 0);
                   4265: }
                   4266: 
                   4267: DEFUN (bgp_network_backdoor,
                   4268:        bgp_network_backdoor_cmd,
                   4269:        "network A.B.C.D/M backdoor",
                   4270:        "Specify a network to announce via BGP\n"
                   4271:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
                   4272:        "Specify a BGP backdoor route\n")
                   4273: {
                   4274:   return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST,
                   4275:                          NULL, 1);
                   4276: }
                   4277: 
                   4278: DEFUN (bgp_network_mask,
                   4279:        bgp_network_mask_cmd,
                   4280:        "network A.B.C.D mask A.B.C.D",
                   4281:        "Specify a network to announce via BGP\n"
                   4282:        "Network number\n"
                   4283:        "Network mask\n"
                   4284:        "Network mask\n")
                   4285: {
                   4286:   int ret;
                   4287:   char prefix_str[BUFSIZ];
                   4288:   
                   4289:   ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
                   4290:   if (! ret)
                   4291:     {
                   4292:       vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
                   4293:       return CMD_WARNING;
                   4294:     }
                   4295: 
                   4296:   return bgp_static_set (vty, vty->index, prefix_str,
                   4297:                         AFI_IP, bgp_node_safi (vty), NULL, 0);
                   4298: }
                   4299: 
                   4300: DEFUN (bgp_network_mask_route_map,
                   4301:        bgp_network_mask_route_map_cmd,
                   4302:        "network A.B.C.D mask A.B.C.D route-map WORD",
                   4303:        "Specify a network to announce via BGP\n"
                   4304:        "Network number\n"
                   4305:        "Network mask\n"
                   4306:        "Network mask\n"
                   4307:        "Route-map to modify the attributes\n"
                   4308:        "Name of the route map\n")
                   4309: {
                   4310:   int ret;
                   4311:   char prefix_str[BUFSIZ];
                   4312:   
                   4313:   ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
                   4314:   if (! ret)
                   4315:     {
                   4316:       vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
                   4317:       return CMD_WARNING;
                   4318:     }
                   4319: 
                   4320:   return bgp_static_set (vty, vty->index, prefix_str,
                   4321:                         AFI_IP, bgp_node_safi (vty), argv[2], 0);
                   4322: }
                   4323: 
                   4324: DEFUN (bgp_network_mask_backdoor,
                   4325:        bgp_network_mask_backdoor_cmd,
                   4326:        "network A.B.C.D mask A.B.C.D backdoor",
                   4327:        "Specify a network to announce via BGP\n"
                   4328:        "Network number\n"
                   4329:        "Network mask\n"
                   4330:        "Network mask\n"
                   4331:        "Specify a BGP backdoor route\n")
                   4332: {
                   4333:   int ret;
                   4334:   char prefix_str[BUFSIZ];
                   4335:   
                   4336:   ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
                   4337:   if (! ret)
                   4338:     {
                   4339:       vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
                   4340:       return CMD_WARNING;
                   4341:     }
                   4342: 
                   4343:   return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
                   4344:                          NULL, 1);
                   4345: }
                   4346: 
                   4347: DEFUN (bgp_network_mask_natural,
                   4348:        bgp_network_mask_natural_cmd,
                   4349:        "network A.B.C.D",
                   4350:        "Specify a network to announce via BGP\n"
                   4351:        "Network number\n")
                   4352: {
                   4353:   int ret;
                   4354:   char prefix_str[BUFSIZ];
                   4355: 
                   4356:   ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
                   4357:   if (! ret)
                   4358:     {
                   4359:       vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
                   4360:       return CMD_WARNING;
                   4361:     }
                   4362: 
                   4363:   return bgp_static_set (vty, vty->index, prefix_str,
                   4364:                         AFI_IP, bgp_node_safi (vty), NULL, 0);
                   4365: }
                   4366: 
                   4367: DEFUN (bgp_network_mask_natural_route_map,
                   4368:        bgp_network_mask_natural_route_map_cmd,
                   4369:        "network A.B.C.D route-map WORD",
                   4370:        "Specify a network to announce via BGP\n"
                   4371:        "Network number\n"
                   4372:        "Route-map to modify the attributes\n"
                   4373:        "Name of the route map\n")
                   4374: {
                   4375:   int ret;
                   4376:   char prefix_str[BUFSIZ];
                   4377: 
                   4378:   ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
                   4379:   if (! ret)
                   4380:     {
                   4381:       vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
                   4382:       return CMD_WARNING;
                   4383:     }
                   4384: 
                   4385:   return bgp_static_set (vty, vty->index, prefix_str,
                   4386:                         AFI_IP, bgp_node_safi (vty), argv[1], 0);
                   4387: }
                   4388: 
                   4389: DEFUN (bgp_network_mask_natural_backdoor,
                   4390:        bgp_network_mask_natural_backdoor_cmd,
                   4391:        "network A.B.C.D backdoor",
                   4392:        "Specify a network to announce via BGP\n"
                   4393:        "Network number\n"
                   4394:        "Specify a BGP backdoor route\n")
                   4395: {
                   4396:   int ret;
                   4397:   char prefix_str[BUFSIZ];
                   4398: 
                   4399:   ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
                   4400:   if (! ret)
                   4401:     {
                   4402:       vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
                   4403:       return CMD_WARNING;
                   4404:     }
                   4405: 
                   4406:   return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
                   4407:                          NULL, 1);
                   4408: }
                   4409: 
                   4410: DEFUN (no_bgp_network,
                   4411:        no_bgp_network_cmd,
                   4412:        "no network A.B.C.D/M",
                   4413:        NO_STR
                   4414:        "Specify a network to announce via BGP\n"
                   4415:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
                   4416: {
                   4417:   return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, 
                   4418:                           bgp_node_safi (vty));
                   4419: }
                   4420: 
                   4421: ALIAS (no_bgp_network,
                   4422:        no_bgp_network_route_map_cmd,
                   4423:        "no network A.B.C.D/M route-map WORD",
                   4424:        NO_STR
                   4425:        "Specify a network to announce via BGP\n"
                   4426:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
                   4427:        "Route-map to modify the attributes\n"
                   4428:        "Name of the route map\n")
                   4429: 
                   4430: ALIAS (no_bgp_network,
                   4431:        no_bgp_network_backdoor_cmd,
                   4432:        "no network A.B.C.D/M backdoor",
                   4433:        NO_STR
                   4434:        "Specify a network to announce via BGP\n"
                   4435:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
                   4436:        "Specify a BGP backdoor route\n")
                   4437: 
                   4438: DEFUN (no_bgp_network_mask,
                   4439:        no_bgp_network_mask_cmd,
                   4440:        "no network A.B.C.D mask A.B.C.D",
                   4441:        NO_STR
                   4442:        "Specify a network to announce via BGP\n"
                   4443:        "Network number\n"
                   4444:        "Network mask\n"
                   4445:        "Network mask\n")
                   4446: {
                   4447:   int ret;
                   4448:   char prefix_str[BUFSIZ];
                   4449: 
                   4450:   ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
                   4451:   if (! ret)
                   4452:     {
                   4453:       vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
                   4454:       return CMD_WARNING;
                   4455:     }
                   4456: 
                   4457:   return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, 
                   4458:                           bgp_node_safi (vty));
                   4459: }
                   4460: 
                   4461: ALIAS (no_bgp_network_mask,
                   4462:        no_bgp_network_mask_route_map_cmd,
                   4463:        "no network A.B.C.D mask A.B.C.D route-map WORD",
                   4464:        NO_STR
                   4465:        "Specify a network to announce via BGP\n"
                   4466:        "Network number\n"
                   4467:        "Network mask\n"
                   4468:        "Network mask\n"
                   4469:        "Route-map to modify the attributes\n"
                   4470:        "Name of the route map\n")
                   4471: 
                   4472: ALIAS (no_bgp_network_mask,
                   4473:        no_bgp_network_mask_backdoor_cmd,
                   4474:        "no network A.B.C.D mask A.B.C.D backdoor",
                   4475:        NO_STR
                   4476:        "Specify a network to announce via BGP\n"
                   4477:        "Network number\n"
                   4478:        "Network mask\n"
                   4479:        "Network mask\n"
                   4480:        "Specify a BGP backdoor route\n")
                   4481: 
                   4482: DEFUN (no_bgp_network_mask_natural,
                   4483:        no_bgp_network_mask_natural_cmd,
                   4484:        "no network A.B.C.D",
                   4485:        NO_STR
                   4486:        "Specify a network to announce via BGP\n"
                   4487:        "Network number\n")
                   4488: {
                   4489:   int ret;
                   4490:   char prefix_str[BUFSIZ];
                   4491: 
                   4492:   ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
                   4493:   if (! ret)
                   4494:     {
                   4495:       vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
                   4496:       return CMD_WARNING;
                   4497:     }
                   4498: 
                   4499:   return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, 
                   4500:                           bgp_node_safi (vty));
                   4501: }
                   4502: 
                   4503: ALIAS (no_bgp_network_mask_natural,
                   4504:        no_bgp_network_mask_natural_route_map_cmd,
                   4505:        "no network A.B.C.D route-map WORD",
                   4506:        NO_STR
                   4507:        "Specify a network to announce via BGP\n"
                   4508:        "Network number\n"
                   4509:        "Route-map to modify the attributes\n"
                   4510:        "Name of the route map\n")
                   4511: 
                   4512: ALIAS (no_bgp_network_mask_natural,
                   4513:        no_bgp_network_mask_natural_backdoor_cmd,
                   4514:        "no network A.B.C.D backdoor",
                   4515:        NO_STR
                   4516:        "Specify a network to announce via BGP\n"
                   4517:        "Network number\n"
                   4518:        "Specify a BGP backdoor route\n")
                   4519: 
                   4520: DEFUN (ipv6_bgp_network,
                   4521:        ipv6_bgp_network_cmd,
                   4522:        "network X:X::X:X/M",
                   4523:        "Specify a network to announce via BGP\n"
                   4524:        "IPv6 prefix <network>/<length>\n")
                   4525: {
1.1.1.2   misho    4526:   return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty),
1.1       misho    4527:                          NULL, 0);
                   4528: }
                   4529: 
                   4530: DEFUN (ipv6_bgp_network_route_map,
                   4531:        ipv6_bgp_network_route_map_cmd,
                   4532:        "network X:X::X:X/M route-map WORD",
                   4533:        "Specify a network to announce via BGP\n"
                   4534:        "IPv6 prefix <network>/<length>\n"
                   4535:        "Route-map to modify the attributes\n"
                   4536:        "Name of the route map\n")
                   4537: {
                   4538:   return bgp_static_set (vty, vty->index, argv[0], AFI_IP6,
                   4539:                         bgp_node_safi (vty), argv[1], 0);
                   4540: }
                   4541: 
                   4542: DEFUN (no_ipv6_bgp_network,
                   4543:        no_ipv6_bgp_network_cmd,
                   4544:        "no network X:X::X:X/M",
                   4545:        NO_STR
                   4546:        "Specify a network to announce via BGP\n"
                   4547:        "IPv6 prefix <network>/<length>\n")
                   4548: {
1.1.1.2   misho    4549:   return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty));
1.1       misho    4550: }
                   4551: 
                   4552: ALIAS (no_ipv6_bgp_network,
                   4553:        no_ipv6_bgp_network_route_map_cmd,
                   4554:        "no network X:X::X:X/M route-map WORD",
                   4555:        NO_STR
                   4556:        "Specify a network to announce via BGP\n"
                   4557:        "IPv6 prefix <network>/<length>\n"
                   4558:        "Route-map to modify the attributes\n"
                   4559:        "Name of the route map\n")
                   4560: 
                   4561: ALIAS (ipv6_bgp_network,
                   4562:        old_ipv6_bgp_network_cmd,
                   4563:        "ipv6 bgp network X:X::X:X/M",
                   4564:        IPV6_STR
                   4565:        BGP_STR
                   4566:        "Specify a network to announce via BGP\n"
                   4567:        "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
                   4568: 
                   4569: ALIAS (no_ipv6_bgp_network,
                   4570:        old_no_ipv6_bgp_network_cmd,
                   4571:        "no ipv6 bgp network X:X::X:X/M",
                   4572:        NO_STR
                   4573:        IPV6_STR
                   4574:        BGP_STR
                   4575:        "Specify a network to announce via BGP\n"
                   4576:        "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
                   4577: 
                   4578: /* stubs for removed AS-Pathlimit commands, kept for config compatibility */
                   4579: ALIAS_DEPRECATED (bgp_network,
                   4580:        bgp_network_ttl_cmd,
                   4581:        "network A.B.C.D/M pathlimit <0-255>",
                   4582:        "Specify a network to announce via BGP\n"
                   4583:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
                   4584:        "AS-Path hopcount limit attribute\n"
                   4585:        "AS-Pathlimit TTL, in number of AS-Path hops\n")
                   4586: ALIAS_DEPRECATED (bgp_network_backdoor,
                   4587:        bgp_network_backdoor_ttl_cmd,
                   4588:        "network A.B.C.D/M backdoor pathlimit <0-255>",
                   4589:        "Specify a network to announce via BGP\n"
                   4590:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
                   4591:        "Specify a BGP backdoor route\n"
                   4592:        "AS-Path hopcount limit attribute\n"
                   4593:        "AS-Pathlimit TTL, in number of AS-Path hops\n")
                   4594: ALIAS_DEPRECATED (bgp_network_mask,
                   4595:        bgp_network_mask_ttl_cmd,
                   4596:        "network A.B.C.D mask A.B.C.D pathlimit <0-255>",
                   4597:        "Specify a network to announce via BGP\n"
                   4598:        "Network number\n"
                   4599:        "Network mask\n"
                   4600:        "Network mask\n"
                   4601:        "AS-Path hopcount limit attribute\n"
                   4602:        "AS-Pathlimit TTL, in number of AS-Path hops\n")
                   4603: ALIAS_DEPRECATED (bgp_network_mask_backdoor,
                   4604:        bgp_network_mask_backdoor_ttl_cmd,
                   4605:        "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
                   4606:        "Specify a network to announce via BGP\n"
                   4607:        "Network number\n"
                   4608:        "Network mask\n"
                   4609:        "Network mask\n"
                   4610:        "Specify a BGP backdoor route\n"
                   4611:        "AS-Path hopcount limit attribute\n"
                   4612:        "AS-Pathlimit TTL, in number of AS-Path hops\n")
                   4613: ALIAS_DEPRECATED (bgp_network_mask_natural,
                   4614:        bgp_network_mask_natural_ttl_cmd,
                   4615:        "network A.B.C.D pathlimit <0-255>",
                   4616:        "Specify a network to announce via BGP\n"
                   4617:        "Network number\n"
                   4618:        "AS-Path hopcount limit attribute\n"
                   4619:        "AS-Pathlimit TTL, in number of AS-Path hops\n")
                   4620: ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor,
                   4621:        bgp_network_mask_natural_backdoor_ttl_cmd,
1.1.1.4 ! misho    4622:        "network A.B.C.D backdoor pathlimit <1-255>",
1.1       misho    4623:        "Specify a network to announce via BGP\n"
                   4624:        "Network number\n"
                   4625:        "Specify a BGP backdoor route\n"
                   4626:        "AS-Path hopcount limit attribute\n"
                   4627:        "AS-Pathlimit TTL, in number of AS-Path hops\n")
                   4628: ALIAS_DEPRECATED (no_bgp_network,
                   4629:        no_bgp_network_ttl_cmd,
                   4630:        "no network A.B.C.D/M pathlimit <0-255>",
                   4631:        NO_STR
                   4632:        "Specify a network to announce via BGP\n"
                   4633:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
                   4634:        "AS-Path hopcount limit attribute\n"
                   4635:        "AS-Pathlimit TTL, in number of AS-Path hops\n")
                   4636: ALIAS_DEPRECATED (no_bgp_network,
                   4637:        no_bgp_network_backdoor_ttl_cmd,
                   4638:        "no network A.B.C.D/M backdoor pathlimit <0-255>",
                   4639:        NO_STR
                   4640:        "Specify a network to announce via BGP\n"
                   4641:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
                   4642:        "Specify a BGP backdoor route\n"
                   4643:        "AS-Path hopcount limit attribute\n"
                   4644:        "AS-Pathlimit TTL, in number of AS-Path hops\n")
                   4645: ALIAS_DEPRECATED (no_bgp_network,
                   4646:        no_bgp_network_mask_ttl_cmd,
                   4647:        "no network A.B.C.D mask A.B.C.D pathlimit <0-255>",
                   4648:        NO_STR
                   4649:        "Specify a network to announce via BGP\n"
                   4650:        "Network number\n"
                   4651:        "Network mask\n"
                   4652:        "Network mask\n"
                   4653:        "AS-Path hopcount limit attribute\n"
                   4654:        "AS-Pathlimit TTL, in number of AS-Path hops\n")
                   4655: ALIAS_DEPRECATED (no_bgp_network_mask,
                   4656:        no_bgp_network_mask_backdoor_ttl_cmd,
                   4657:        "no network A.B.C.D mask A.B.C.D  backdoor pathlimit <0-255>",
                   4658:        NO_STR
                   4659:        "Specify a network to announce via BGP\n"
                   4660:        "Network number\n"
                   4661:        "Network mask\n"
                   4662:        "Network mask\n"
                   4663:        "Specify a BGP backdoor route\n"
                   4664:        "AS-Path hopcount limit attribute\n"
                   4665:        "AS-Pathlimit TTL, in number of AS-Path hops\n")
                   4666: ALIAS_DEPRECATED (no_bgp_network_mask_natural,
                   4667:        no_bgp_network_mask_natural_ttl_cmd,
                   4668:        "no network A.B.C.D pathlimit <0-255>",
                   4669:        NO_STR
                   4670:        "Specify a network to announce via BGP\n"
                   4671:        "Network number\n"
                   4672:        "AS-Path hopcount limit attribute\n"
                   4673:        "AS-Pathlimit TTL, in number of AS-Path hops\n")
                   4674: ALIAS_DEPRECATED (no_bgp_network_mask_natural,
                   4675:        no_bgp_network_mask_natural_backdoor_ttl_cmd,
                   4676:        "no network A.B.C.D backdoor pathlimit <0-255>",
                   4677:        NO_STR
                   4678:        "Specify a network to announce via BGP\n"
                   4679:        "Network number\n"
                   4680:        "Specify a BGP backdoor route\n"
                   4681:        "AS-Path hopcount limit attribute\n"
                   4682:        "AS-Pathlimit TTL, in number of AS-Path hops\n")
                   4683: ALIAS_DEPRECATED (ipv6_bgp_network,
                   4684:        ipv6_bgp_network_ttl_cmd,
                   4685:        "network X:X::X:X/M pathlimit <0-255>",
                   4686:        "Specify a network to announce via BGP\n"
                   4687:        "IPv6 prefix <network>/<length>\n"
                   4688:        "AS-Path hopcount limit attribute\n"
                   4689:        "AS-Pathlimit TTL, in number of AS-Path hops\n")
                   4690: ALIAS_DEPRECATED (no_ipv6_bgp_network,
                   4691:        no_ipv6_bgp_network_ttl_cmd,
                   4692:        "no network X:X::X:X/M pathlimit <0-255>",
                   4693:        NO_STR
                   4694:        "Specify a network to announce via BGP\n"
                   4695:        "IPv6 prefix <network>/<length>\n"
                   4696:        "AS-Path hopcount limit attribute\n"
                   4697:        "AS-Pathlimit TTL, in number of AS-Path hops\n")
1.1.1.4 ! misho    4698: 
1.1       misho    4699: /* Aggreagete address:
                   4700: 
                   4701:   advertise-map  Set condition to advertise attribute
                   4702:   as-set         Generate AS set path information
                   4703:   attribute-map  Set attributes of aggregate
                   4704:   route-map      Set parameters of aggregate
                   4705:   summary-only   Filter more specific routes from updates
                   4706:   suppress-map   Conditionally filter more specific routes from updates
                   4707:   <cr>
                   4708:  */
                   4709: struct bgp_aggregate
                   4710: {
                   4711:   /* Summary-only flag. */
                   4712:   u_char summary_only;
                   4713: 
                   4714:   /* AS set generation. */
                   4715:   u_char as_set;
                   4716: 
                   4717:   /* Route-map for aggregated route. */
                   4718:   struct route_map *map;
                   4719: 
                   4720:   /* Suppress-count. */
                   4721:   unsigned long count;
                   4722: 
                   4723:   /* SAFI configuration. */
                   4724:   safi_t safi;
                   4725: };
                   4726: 
                   4727: static struct bgp_aggregate *
                   4728: bgp_aggregate_new (void)
                   4729: {
                   4730:   return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate));
                   4731: }
                   4732: 
                   4733: static void
                   4734: bgp_aggregate_free (struct bgp_aggregate *aggregate)
                   4735: {
                   4736:   XFREE (MTYPE_BGP_AGGREGATE, aggregate);
                   4737: }     
                   4738: 
                   4739: static void
                   4740: bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew,
                   4741:                     afi_t afi, safi_t safi, struct bgp_info *del, 
                   4742:                     struct bgp_aggregate *aggregate)
                   4743: {
                   4744:   struct bgp_table *table;
                   4745:   struct bgp_node *top;
                   4746:   struct bgp_node *rn;
                   4747:   u_char origin;
                   4748:   struct aspath *aspath = NULL;
                   4749:   struct aspath *asmerge = NULL;
                   4750:   struct community *community = NULL;
                   4751:   struct community *commerge = NULL;
                   4752:   struct bgp_info *ri;
                   4753:   struct bgp_info *new;
                   4754:   int first = 1;
                   4755:   unsigned long match = 0;
                   4756: 
                   4757:   /* ORIGIN attribute: If at least one route among routes that are
                   4758:      aggregated has ORIGIN with the value INCOMPLETE, then the
                   4759:      aggregated route must have the ORIGIN attribute with the value
                   4760:      INCOMPLETE. Otherwise, if at least one route among routes that
                   4761:      are aggregated has ORIGIN with the value EGP, then the aggregated
                   4762:      route must have the origin attribute with the value EGP. In all
                   4763:      other case the value of the ORIGIN attribute of the aggregated
                   4764:      route is INTERNAL. */
                   4765:   origin = BGP_ORIGIN_IGP;
                   4766: 
                   4767:   table = bgp->rib[afi][safi];
                   4768: 
                   4769:   top = bgp_node_get (table, p);
                   4770:   for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
                   4771:     if (rn->p.prefixlen > p->prefixlen)
                   4772:       {
                   4773:        match = 0;
                   4774: 
                   4775:        for (ri = rn->info; ri; ri = ri->next)
                   4776:          {
                   4777:            if (BGP_INFO_HOLDDOWN (ri))
                   4778:              continue;
                   4779: 
                   4780:            if (del && ri == del)
                   4781:              continue;
                   4782: 
                   4783:            if (! rinew && first)
1.1.1.4 ! misho    4784:               first = 0;
1.1       misho    4785: 
                   4786: #ifdef AGGREGATE_NEXTHOP_CHECK
                   4787:            if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop)
                   4788:                || ri->attr->med != med)
                   4789:              {
                   4790:                if (aspath)
                   4791:                  aspath_free (aspath);
                   4792:                if (community)
                   4793:                  community_free (community);
                   4794:                bgp_unlock_node (rn);
                   4795:                bgp_unlock_node (top);
                   4796:                return;
                   4797:              }
                   4798: #endif /* AGGREGATE_NEXTHOP_CHECK */
                   4799: 
                   4800:            if (ri->sub_type != BGP_ROUTE_AGGREGATE)
                   4801:              {
                   4802:                if (aggregate->summary_only)
                   4803:                  {
                   4804:                    (bgp_info_extra_get (ri))->suppress++;
                   4805:                    bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
                   4806:                    match++;
                   4807:                  }
                   4808: 
                   4809:                aggregate->count++;
                   4810: 
                   4811:                if (aggregate->as_set)
                   4812:                  {
                   4813:                    if (origin < ri->attr->origin)
                   4814:                      origin = ri->attr->origin;
                   4815: 
                   4816:                    if (aspath)
                   4817:                      {
                   4818:                        asmerge = aspath_aggregate (aspath, ri->attr->aspath);
                   4819:                        aspath_free (aspath);
                   4820:                        aspath = asmerge;
                   4821:                      }
                   4822:                    else
                   4823:                      aspath = aspath_dup (ri->attr->aspath);
                   4824: 
                   4825:                    if (ri->attr->community)
                   4826:                      {
                   4827:                        if (community)
                   4828:                          {
                   4829:                            commerge = community_merge (community,
                   4830:                                                        ri->attr->community);
                   4831:                            community = community_uniq_sort (commerge);
                   4832:                            community_free (commerge);
                   4833:                          }
                   4834:                        else
                   4835:                          community = community_dup (ri->attr->community);
                   4836:                      }
                   4837:                  }
                   4838:              }
                   4839:          }
                   4840:        if (match)
                   4841:          bgp_process (bgp, rn, afi, safi);
                   4842:       }
                   4843:   bgp_unlock_node (top);
                   4844: 
                   4845:   if (rinew)
                   4846:     {
                   4847:       aggregate->count++;
                   4848:       
                   4849:       if (aggregate->summary_only)
                   4850:         (bgp_info_extra_get (rinew))->suppress++;
                   4851: 
                   4852:       if (aggregate->as_set)
                   4853:        {
                   4854:          if (origin < rinew->attr->origin)
                   4855:            origin = rinew->attr->origin;
                   4856: 
                   4857:          if (aspath)
                   4858:            {
                   4859:              asmerge = aspath_aggregate (aspath, rinew->attr->aspath);
                   4860:              aspath_free (aspath);
                   4861:              aspath = asmerge;
                   4862:            }
                   4863:          else
                   4864:            aspath = aspath_dup (rinew->attr->aspath);
                   4865: 
                   4866:          if (rinew->attr->community)
                   4867:            {
                   4868:              if (community)
                   4869:                {
                   4870:                  commerge = community_merge (community,
                   4871:                                              rinew->attr->community);
                   4872:                  community = community_uniq_sort (commerge);
                   4873:                  community_free (commerge);
                   4874:                }
                   4875:              else
                   4876:                community = community_dup (rinew->attr->community);
                   4877:            }
                   4878:        }
                   4879:     }
                   4880: 
                   4881:   if (aggregate->count > 0)
                   4882:     {
                   4883:       rn = bgp_node_get (table, p);
                   4884:       new = bgp_info_new ();
                   4885:       new->type = ZEBRA_ROUTE_BGP;
                   4886:       new->sub_type = BGP_ROUTE_AGGREGATE;
                   4887:       new->peer = bgp->peer_self;
                   4888:       SET_FLAG (new->flags, BGP_INFO_VALID);
                   4889:       new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
                   4890:       new->uptime = bgp_clock ();
                   4891: 
                   4892:       bgp_info_add (rn, new);
                   4893:       bgp_unlock_node (rn);
                   4894:       bgp_process (bgp, rn, afi, safi);
                   4895:     }
                   4896:   else
                   4897:     {
                   4898:       if (aspath)
                   4899:        aspath_free (aspath);
                   4900:       if (community)
                   4901:        community_free (community);
                   4902:     }
                   4903: }
                   4904: 
                   4905: void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t,
                   4906:                           struct bgp_aggregate *);
                   4907: 
                   4908: void
                   4909: bgp_aggregate_increment (struct bgp *bgp, struct prefix *p,
                   4910:                         struct bgp_info *ri, afi_t afi, safi_t safi)
                   4911: {
                   4912:   struct bgp_node *child;
                   4913:   struct bgp_node *rn;
                   4914:   struct bgp_aggregate *aggregate;
1.1.1.3   misho    4915:   struct bgp_table *table;
1.1       misho    4916: 
                   4917:   /* MPLS-VPN aggregation is not yet supported. */
1.1.1.4 ! misho    4918:   if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
1.1       misho    4919:     return;
                   4920: 
1.1.1.3   misho    4921:   table = bgp->aggregate[afi][safi];
                   4922: 
                   4923:   /* No aggregates configured. */
                   4924:   if (bgp_table_top_nolock (table) == NULL)
                   4925:     return;
                   4926: 
1.1       misho    4927:   if (p->prefixlen == 0)
                   4928:     return;
                   4929: 
                   4930:   if (BGP_INFO_HOLDDOWN (ri))
                   4931:     return;
                   4932: 
1.1.1.3   misho    4933:   child = bgp_node_get (table, p);
1.1       misho    4934: 
                   4935:   /* Aggregate address configuration check. */
1.1.1.3   misho    4936:   for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
1.1       misho    4937:     if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
                   4938:       {
                   4939:        bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
                   4940:        bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate);
                   4941:       }
                   4942:   bgp_unlock_node (child);
                   4943: }
                   4944: 
                   4945: void
                   4946: bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, 
                   4947:                         struct bgp_info *del, afi_t afi, safi_t safi)
                   4948: {
                   4949:   struct bgp_node *child;
                   4950:   struct bgp_node *rn;
                   4951:   struct bgp_aggregate *aggregate;
1.1.1.3   misho    4952:   struct bgp_table *table;
1.1       misho    4953: 
                   4954:   /* MPLS-VPN aggregation is not yet supported. */
1.1.1.4 ! misho    4955:   if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
1.1       misho    4956:     return;
                   4957: 
1.1.1.3   misho    4958:   table = bgp->aggregate[afi][safi];
                   4959: 
                   4960:   /* No aggregates configured. */
                   4961:   if (bgp_table_top_nolock (table) == NULL)
                   4962:     return;
                   4963: 
1.1       misho    4964:   if (p->prefixlen == 0)
                   4965:     return;
                   4966: 
1.1.1.3   misho    4967:   child = bgp_node_get (table, p);
1.1       misho    4968: 
                   4969:   /* Aggregate address configuration check. */
1.1.1.3   misho    4970:   for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
1.1       misho    4971:     if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
                   4972:       {
                   4973:        bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
                   4974:        bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate);
                   4975:       }
                   4976:   bgp_unlock_node (child);
                   4977: }
                   4978: 
                   4979: static void
                   4980: bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi,
                   4981:                   struct bgp_aggregate *aggregate)
                   4982: {
                   4983:   struct bgp_table *table;
                   4984:   struct bgp_node *top;
                   4985:   struct bgp_node *rn;
                   4986:   struct bgp_info *new;
                   4987:   struct bgp_info *ri;
                   4988:   unsigned long match;
                   4989:   u_char origin = BGP_ORIGIN_IGP;
                   4990:   struct aspath *aspath = NULL;
                   4991:   struct aspath *asmerge = NULL;
                   4992:   struct community *community = NULL;
                   4993:   struct community *commerge = NULL;
                   4994: 
                   4995:   table = bgp->rib[afi][safi];
                   4996: 
                   4997:   /* Sanity check. */
                   4998:   if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
                   4999:     return;
                   5000:   if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
                   5001:     return;
                   5002:     
                   5003:   /* If routes exists below this node, generate aggregate routes. */
                   5004:   top = bgp_node_get (table, p);
                   5005:   for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
                   5006:     if (rn->p.prefixlen > p->prefixlen)
                   5007:       {
                   5008:        match = 0;
                   5009: 
                   5010:        for (ri = rn->info; ri; ri = ri->next)
                   5011:          {
                   5012:            if (BGP_INFO_HOLDDOWN (ri))
                   5013:              continue;
                   5014: 
                   5015:            if (ri->sub_type != BGP_ROUTE_AGGREGATE)
                   5016:              {
                   5017:                /* summary-only aggregate route suppress aggregated
                   5018:                   route announcement.  */
                   5019:                if (aggregate->summary_only)
                   5020:                  {
                   5021:                    (bgp_info_extra_get (ri))->suppress++;
                   5022:                    bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
                   5023:                    match++;
                   5024:                  }
                   5025:                /* as-set aggregate route generate origin, as path,
                   5026:                   community aggregation.  */
                   5027:                if (aggregate->as_set)
                   5028:                  {
                   5029:                    if (origin < ri->attr->origin)
                   5030:                      origin = ri->attr->origin;
                   5031: 
                   5032:                    if (aspath)
                   5033:                      {
                   5034:                        asmerge = aspath_aggregate (aspath, ri->attr->aspath);
                   5035:                        aspath_free (aspath);
                   5036:                        aspath = asmerge;
                   5037:                      }
                   5038:                    else
                   5039:                      aspath = aspath_dup (ri->attr->aspath);
                   5040: 
                   5041:                    if (ri->attr->community)
                   5042:                      {
                   5043:                        if (community)
                   5044:                          {
                   5045:                            commerge = community_merge (community,
                   5046:                                                        ri->attr->community);
                   5047:                            community = community_uniq_sort (commerge);
                   5048:                            community_free (commerge);
                   5049:                          }
                   5050:                        else
                   5051:                          community = community_dup (ri->attr->community);
                   5052:                      }
                   5053:                  }
                   5054:                aggregate->count++;
                   5055:              }
                   5056:          }
                   5057:        
                   5058:        /* If this node is suppressed, process the change. */
                   5059:        if (match)
                   5060:          bgp_process (bgp, rn, afi, safi);
                   5061:       }
                   5062:   bgp_unlock_node (top);
                   5063: 
                   5064:   /* Add aggregate route to BGP table. */
                   5065:   if (aggregate->count)
                   5066:     {
                   5067:       rn = bgp_node_get (table, p);
                   5068: 
                   5069:       new = bgp_info_new ();
                   5070:       new->type = ZEBRA_ROUTE_BGP;
                   5071:       new->sub_type = BGP_ROUTE_AGGREGATE;
                   5072:       new->peer = bgp->peer_self;
                   5073:       SET_FLAG (new->flags, BGP_INFO_VALID);
                   5074:       new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
                   5075:       new->uptime = bgp_clock ();
                   5076: 
                   5077:       bgp_info_add (rn, new);
                   5078:       bgp_unlock_node (rn);
                   5079:       
                   5080:       /* Process change. */
                   5081:       bgp_process (bgp, rn, afi, safi);
                   5082:     }
1.1.1.4 ! misho    5083:   else
        !          5084:     {
        !          5085:       if (aspath)
        !          5086:        aspath_free (aspath);
        !          5087:       if (community)
        !          5088:        community_free (community);
        !          5089:     }
1.1       misho    5090: }
                   5091: 
                   5092: void
                   5093: bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, 
                   5094:                      safi_t safi, struct bgp_aggregate *aggregate)
                   5095: {
                   5096:   struct bgp_table *table;
                   5097:   struct bgp_node *top;
                   5098:   struct bgp_node *rn;
                   5099:   struct bgp_info *ri;
                   5100:   unsigned long match;
                   5101: 
                   5102:   table = bgp->rib[afi][safi];
                   5103: 
                   5104:   if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
                   5105:     return;
                   5106:   if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
                   5107:     return;
                   5108: 
                   5109:   /* If routes exists below this node, generate aggregate routes. */
                   5110:   top = bgp_node_get (table, p);
                   5111:   for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
                   5112:     if (rn->p.prefixlen > p->prefixlen)
                   5113:       {
                   5114:        match = 0;
                   5115: 
                   5116:        for (ri = rn->info; ri; ri = ri->next)
                   5117:          {
                   5118:            if (BGP_INFO_HOLDDOWN (ri))
                   5119:              continue;
                   5120: 
                   5121:            if (ri->sub_type != BGP_ROUTE_AGGREGATE)
                   5122:              {
                   5123:                if (aggregate->summary_only && ri->extra)
                   5124:                  {
                   5125:                    ri->extra->suppress--;
                   5126: 
                   5127:                    if (ri->extra->suppress == 0)
                   5128:                      {
                   5129:                        bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
                   5130:                        match++;
                   5131:                      }
                   5132:                  }
                   5133:                aggregate->count--;
                   5134:              }
                   5135:          }
                   5136: 
                   5137:        /* If this node was suppressed, process the change. */
                   5138:        if (match)
                   5139:          bgp_process (bgp, rn, afi, safi);
                   5140:       }
                   5141:   bgp_unlock_node (top);
                   5142: 
                   5143:   /* Delete aggregate route from BGP table. */
                   5144:   rn = bgp_node_get (table, p);
                   5145: 
                   5146:   for (ri = rn->info; ri; ri = ri->next)
                   5147:     if (ri->peer == bgp->peer_self 
                   5148:        && ri->type == ZEBRA_ROUTE_BGP
                   5149:        && ri->sub_type == BGP_ROUTE_AGGREGATE)
                   5150:       break;
                   5151: 
                   5152:   /* Withdraw static BGP route from routing table. */
                   5153:   if (ri)
                   5154:     {
                   5155:       bgp_info_delete (rn, ri);
                   5156:       bgp_process (bgp, rn, afi, safi);
                   5157:     }
                   5158: 
                   5159:   /* Unlock bgp_node_lookup. */
                   5160:   bgp_unlock_node (rn);
                   5161: }
                   5162: 
                   5163: /* Aggregate route attribute. */
                   5164: #define AGGREGATE_SUMMARY_ONLY 1
                   5165: #define AGGREGATE_AS_SET       1
                   5166: 
                   5167: static int
                   5168: bgp_aggregate_unset (struct vty *vty, const char *prefix_str,
                   5169:                      afi_t afi, safi_t safi)
                   5170: {
                   5171:   int ret;
                   5172:   struct prefix p;
                   5173:   struct bgp_node *rn;
                   5174:   struct bgp *bgp;
                   5175:   struct bgp_aggregate *aggregate;
                   5176: 
                   5177:   /* Convert string to prefix structure. */
                   5178:   ret = str2prefix (prefix_str, &p);
                   5179:   if (!ret)
                   5180:     {
                   5181:       vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
                   5182:       return CMD_WARNING;
                   5183:     }
                   5184:   apply_mask (&p);
                   5185: 
                   5186:   /* Get BGP structure. */
                   5187:   bgp = vty->index;
                   5188: 
                   5189:   /* Old configuration check. */
                   5190:   rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p);
                   5191:   if (! rn)
                   5192:     {
                   5193:       vty_out (vty, "%% There is no aggregate-address configuration.%s",
                   5194:                VTY_NEWLINE);
                   5195:       return CMD_WARNING;
                   5196:     }
                   5197: 
                   5198:   aggregate = rn->info;
                   5199:   if (aggregate->safi & SAFI_UNICAST)
                   5200:     bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate);
                   5201:   if (aggregate->safi & SAFI_MULTICAST)
                   5202:     bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate);
                   5203: 
                   5204:   /* Unlock aggregate address configuration. */
                   5205:   rn->info = NULL;
                   5206:   bgp_aggregate_free (aggregate);
                   5207:   bgp_unlock_node (rn);
                   5208:   bgp_unlock_node (rn);
                   5209: 
                   5210:   return CMD_SUCCESS;
                   5211: }
                   5212: 
                   5213: static int
                   5214: bgp_aggregate_set (struct vty *vty, const char *prefix_str,
                   5215:                    afi_t afi, safi_t safi,
                   5216:                   u_char summary_only, u_char as_set)
                   5217: {
                   5218:   int ret;
                   5219:   struct prefix p;
                   5220:   struct bgp_node *rn;
                   5221:   struct bgp *bgp;
                   5222:   struct bgp_aggregate *aggregate;
                   5223: 
                   5224:   /* Convert string to prefix structure. */
                   5225:   ret = str2prefix (prefix_str, &p);
                   5226:   if (!ret)
                   5227:     {
                   5228:       vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
                   5229:       return CMD_WARNING;
                   5230:     }
                   5231:   apply_mask (&p);
                   5232: 
                   5233:   /* Get BGP structure. */
                   5234:   bgp = vty->index;
                   5235: 
                   5236:   /* Old configuration check. */
                   5237:   rn = bgp_node_get (bgp->aggregate[afi][safi], &p);
                   5238: 
                   5239:   if (rn->info)
                   5240:     {
                   5241:       vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE);
                   5242:       /* try to remove the old entry */
                   5243:       ret = bgp_aggregate_unset (vty, prefix_str, afi, safi);
                   5244:       if (ret)
                   5245:         {
                   5246:           vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE);
                   5247:          bgp_unlock_node (rn);
                   5248:          return CMD_WARNING;
                   5249:         }
                   5250:     }
                   5251: 
                   5252:   /* Make aggregate address structure. */
                   5253:   aggregate = bgp_aggregate_new ();
                   5254:   aggregate->summary_only = summary_only;
                   5255:   aggregate->as_set = as_set;
                   5256:   aggregate->safi = safi;
                   5257:   rn->info = aggregate;
                   5258: 
                   5259:   /* Aggregate address insert into BGP routing table. */
                   5260:   if (safi & SAFI_UNICAST)
                   5261:     bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate);
                   5262:   if (safi & SAFI_MULTICAST)
                   5263:     bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate);
                   5264: 
                   5265:   return CMD_SUCCESS;
                   5266: }
                   5267: 
                   5268: DEFUN (aggregate_address,
                   5269:        aggregate_address_cmd,
                   5270:        "aggregate-address A.B.C.D/M",
                   5271:        "Configure BGP aggregate entries\n"
                   5272:        "Aggregate prefix\n")
                   5273: {
                   5274:   return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0);
                   5275: }
                   5276: 
                   5277: DEFUN (aggregate_address_mask,
                   5278:        aggregate_address_mask_cmd,
                   5279:        "aggregate-address A.B.C.D A.B.C.D",
                   5280:        "Configure BGP aggregate entries\n"
                   5281:        "Aggregate address\n"
                   5282:        "Aggregate mask\n")
                   5283: {
                   5284:   int ret;
                   5285:   char prefix_str[BUFSIZ];
                   5286: 
                   5287:   ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
                   5288: 
                   5289:   if (! ret)
                   5290:     {
                   5291:       vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
                   5292:       return CMD_WARNING;
                   5293:     }
                   5294: 
                   5295:   return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
                   5296:                            0, 0);
                   5297: }
                   5298: 
                   5299: DEFUN (aggregate_address_summary_only,
                   5300:        aggregate_address_summary_only_cmd,
                   5301:        "aggregate-address A.B.C.D/M summary-only",
                   5302:        "Configure BGP aggregate entries\n"
                   5303:        "Aggregate prefix\n"
                   5304:        "Filter more specific routes from updates\n")
                   5305: {
                   5306:   return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
                   5307:                            AGGREGATE_SUMMARY_ONLY, 0);
                   5308: }
                   5309: 
                   5310: DEFUN (aggregate_address_mask_summary_only,
                   5311:        aggregate_address_mask_summary_only_cmd,
                   5312:        "aggregate-address A.B.C.D A.B.C.D summary-only",
                   5313:        "Configure BGP aggregate entries\n"
                   5314:        "Aggregate address\n"
                   5315:        "Aggregate mask\n"
                   5316:        "Filter more specific routes from updates\n")
                   5317: {
                   5318:   int ret;
                   5319:   char prefix_str[BUFSIZ];
                   5320: 
                   5321:   ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
                   5322: 
                   5323:   if (! ret)
                   5324:     {
                   5325:       vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
                   5326:       return CMD_WARNING;
                   5327:     }
                   5328: 
                   5329:   return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
                   5330:                            AGGREGATE_SUMMARY_ONLY, 0);
                   5331: }
                   5332: 
                   5333: DEFUN (aggregate_address_as_set,
                   5334:        aggregate_address_as_set_cmd,
                   5335:        "aggregate-address A.B.C.D/M as-set",
                   5336:        "Configure BGP aggregate entries\n"
                   5337:        "Aggregate prefix\n"
                   5338:        "Generate AS set path information\n")
                   5339: {
                   5340:   return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
                   5341:                            0, AGGREGATE_AS_SET);
                   5342: }
                   5343: 
                   5344: DEFUN (aggregate_address_mask_as_set,
                   5345:        aggregate_address_mask_as_set_cmd,
                   5346:        "aggregate-address A.B.C.D A.B.C.D as-set",
                   5347:        "Configure BGP aggregate entries\n"
                   5348:        "Aggregate address\n"
                   5349:        "Aggregate mask\n"
                   5350:        "Generate AS set path information\n")
                   5351: {
                   5352:   int ret;
                   5353:   char prefix_str[BUFSIZ];
                   5354: 
                   5355:   ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
                   5356: 
                   5357:   if (! ret)
                   5358:     {
                   5359:       vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
                   5360:       return CMD_WARNING;
                   5361:     }
                   5362: 
                   5363:   return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
                   5364:                            0, AGGREGATE_AS_SET);
                   5365: }
                   5366: 
                   5367: 
                   5368: DEFUN (aggregate_address_as_set_summary,
                   5369:        aggregate_address_as_set_summary_cmd,
                   5370:        "aggregate-address A.B.C.D/M as-set summary-only",
                   5371:        "Configure BGP aggregate entries\n"
                   5372:        "Aggregate prefix\n"
                   5373:        "Generate AS set path information\n"
                   5374:        "Filter more specific routes from updates\n")
                   5375: {
                   5376:   return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
                   5377:                            AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
                   5378: }
                   5379: 
                   5380: ALIAS (aggregate_address_as_set_summary,
                   5381:        aggregate_address_summary_as_set_cmd,
                   5382:        "aggregate-address A.B.C.D/M summary-only as-set",
                   5383:        "Configure BGP aggregate entries\n"
                   5384:        "Aggregate prefix\n"
                   5385:        "Filter more specific routes from updates\n"
                   5386:        "Generate AS set path information\n")
                   5387: 
                   5388: DEFUN (aggregate_address_mask_as_set_summary,
                   5389:        aggregate_address_mask_as_set_summary_cmd,
                   5390:        "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
                   5391:        "Configure BGP aggregate entries\n"
                   5392:        "Aggregate address\n"
                   5393:        "Aggregate mask\n"
                   5394:        "Generate AS set path information\n"
                   5395:        "Filter more specific routes from updates\n")
                   5396: {
                   5397:   int ret;
                   5398:   char prefix_str[BUFSIZ];
                   5399: 
                   5400:   ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
                   5401: 
                   5402:   if (! ret)
                   5403:     {
                   5404:       vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
                   5405:       return CMD_WARNING;
                   5406:     }
                   5407: 
                   5408:   return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
                   5409:                            AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
                   5410: }
                   5411: 
                   5412: ALIAS (aggregate_address_mask_as_set_summary,
                   5413:        aggregate_address_mask_summary_as_set_cmd,
                   5414:        "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
                   5415:        "Configure BGP aggregate entries\n"
                   5416:        "Aggregate address\n"
                   5417:        "Aggregate mask\n"
                   5418:        "Filter more specific routes from updates\n"
                   5419:        "Generate AS set path information\n")
                   5420: 
                   5421: DEFUN (no_aggregate_address,
                   5422:        no_aggregate_address_cmd,
                   5423:        "no aggregate-address A.B.C.D/M",
                   5424:        NO_STR
                   5425:        "Configure BGP aggregate entries\n"
                   5426:        "Aggregate prefix\n")
                   5427: {
                   5428:   return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty));
                   5429: }
                   5430: 
                   5431: ALIAS (no_aggregate_address,
                   5432:        no_aggregate_address_summary_only_cmd,
                   5433:        "no aggregate-address A.B.C.D/M summary-only",
                   5434:        NO_STR
                   5435:        "Configure BGP aggregate entries\n"
                   5436:        "Aggregate prefix\n"
                   5437:        "Filter more specific routes from updates\n")
                   5438: 
                   5439: ALIAS (no_aggregate_address,
                   5440:        no_aggregate_address_as_set_cmd,
                   5441:        "no aggregate-address A.B.C.D/M as-set",
                   5442:        NO_STR
                   5443:        "Configure BGP aggregate entries\n"
                   5444:        "Aggregate prefix\n"
                   5445:        "Generate AS set path information\n")
                   5446: 
                   5447: ALIAS (no_aggregate_address,
                   5448:        no_aggregate_address_as_set_summary_cmd,
                   5449:        "no aggregate-address A.B.C.D/M as-set summary-only",
                   5450:        NO_STR
                   5451:        "Configure BGP aggregate entries\n"
                   5452:        "Aggregate prefix\n"
                   5453:        "Generate AS set path information\n"
                   5454:        "Filter more specific routes from updates\n")
                   5455: 
                   5456: ALIAS (no_aggregate_address,
                   5457:        no_aggregate_address_summary_as_set_cmd,
                   5458:        "no aggregate-address A.B.C.D/M summary-only as-set",
                   5459:        NO_STR
                   5460:        "Configure BGP aggregate entries\n"
                   5461:        "Aggregate prefix\n"
                   5462:        "Filter more specific routes from updates\n"
                   5463:        "Generate AS set path information\n")
                   5464: 
                   5465: DEFUN (no_aggregate_address_mask,
                   5466:        no_aggregate_address_mask_cmd,
                   5467:        "no aggregate-address A.B.C.D A.B.C.D",
                   5468:        NO_STR
                   5469:        "Configure BGP aggregate entries\n"
                   5470:        "Aggregate address\n"
                   5471:        "Aggregate mask\n")
                   5472: {
                   5473:   int ret;
                   5474:   char prefix_str[BUFSIZ];
                   5475: 
                   5476:   ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
                   5477: 
                   5478:   if (! ret)
                   5479:     {
                   5480:       vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
                   5481:       return CMD_WARNING;
                   5482:     }
                   5483: 
                   5484:   return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty));
                   5485: }
                   5486: 
                   5487: ALIAS (no_aggregate_address_mask,
                   5488:        no_aggregate_address_mask_summary_only_cmd,
                   5489:        "no aggregate-address A.B.C.D A.B.C.D summary-only",
                   5490:        NO_STR
                   5491:        "Configure BGP aggregate entries\n"
                   5492:        "Aggregate address\n"
                   5493:        "Aggregate mask\n"
                   5494:        "Filter more specific routes from updates\n")
                   5495: 
                   5496: ALIAS (no_aggregate_address_mask,
                   5497:        no_aggregate_address_mask_as_set_cmd,
                   5498:        "no aggregate-address A.B.C.D A.B.C.D as-set",
                   5499:        NO_STR
                   5500:        "Configure BGP aggregate entries\n"
                   5501:        "Aggregate address\n"
                   5502:        "Aggregate mask\n"
                   5503:        "Generate AS set path information\n")
                   5504: 
                   5505: ALIAS (no_aggregate_address_mask,
                   5506:        no_aggregate_address_mask_as_set_summary_cmd,
                   5507:        "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
                   5508:        NO_STR
                   5509:        "Configure BGP aggregate entries\n"
                   5510:        "Aggregate address\n"
                   5511:        "Aggregate mask\n"
                   5512:        "Generate AS set path information\n"
                   5513:        "Filter more specific routes from updates\n")
                   5514: 
                   5515: ALIAS (no_aggregate_address_mask,
                   5516:        no_aggregate_address_mask_summary_as_set_cmd,
                   5517:        "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
                   5518:        NO_STR
                   5519:        "Configure BGP aggregate entries\n"
                   5520:        "Aggregate address\n"
                   5521:        "Aggregate mask\n"
                   5522:        "Filter more specific routes from updates\n"
                   5523:        "Generate AS set path information\n")
                   5524: 
                   5525: DEFUN (ipv6_aggregate_address,
                   5526:        ipv6_aggregate_address_cmd,
                   5527:        "aggregate-address X:X::X:X/M",
                   5528:        "Configure BGP aggregate entries\n"
                   5529:        "Aggregate prefix\n")
                   5530: {
                   5531:   return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0);
                   5532: }
                   5533: 
                   5534: DEFUN (ipv6_aggregate_address_summary_only,
                   5535:        ipv6_aggregate_address_summary_only_cmd,
                   5536:        "aggregate-address X:X::X:X/M summary-only",
                   5537:        "Configure BGP aggregate entries\n"
                   5538:        "Aggregate prefix\n"
                   5539:        "Filter more specific routes from updates\n")
                   5540: {
                   5541:   return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 
                   5542:                            AGGREGATE_SUMMARY_ONLY, 0);
                   5543: }
                   5544: 
                   5545: DEFUN (no_ipv6_aggregate_address,
                   5546:        no_ipv6_aggregate_address_cmd,
                   5547:        "no aggregate-address X:X::X:X/M",
                   5548:        NO_STR
                   5549:        "Configure BGP aggregate entries\n"
                   5550:        "Aggregate prefix\n")
                   5551: {
                   5552:   return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
                   5553: }
                   5554: 
                   5555: DEFUN (no_ipv6_aggregate_address_summary_only,
                   5556:        no_ipv6_aggregate_address_summary_only_cmd,
                   5557:        "no aggregate-address X:X::X:X/M summary-only",
                   5558:        NO_STR
                   5559:        "Configure BGP aggregate entries\n"
                   5560:        "Aggregate prefix\n"
                   5561:        "Filter more specific routes from updates\n")
                   5562: {
                   5563:   return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
                   5564: }
                   5565: 
                   5566: ALIAS (ipv6_aggregate_address,
                   5567:        old_ipv6_aggregate_address_cmd,
                   5568:        "ipv6 bgp aggregate-address X:X::X:X/M",
                   5569:        IPV6_STR
                   5570:        BGP_STR
                   5571:        "Configure BGP aggregate entries\n"
                   5572:        "Aggregate prefix\n")
                   5573: 
                   5574: ALIAS (ipv6_aggregate_address_summary_only,
                   5575:        old_ipv6_aggregate_address_summary_only_cmd,
                   5576:        "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
                   5577:        IPV6_STR
                   5578:        BGP_STR
                   5579:        "Configure BGP aggregate entries\n"
                   5580:        "Aggregate prefix\n"
                   5581:        "Filter more specific routes from updates\n")
                   5582: 
                   5583: ALIAS (no_ipv6_aggregate_address,
                   5584:        old_no_ipv6_aggregate_address_cmd,
                   5585:        "no ipv6 bgp aggregate-address X:X::X:X/M",
                   5586:        NO_STR
                   5587:        IPV6_STR
                   5588:        BGP_STR
                   5589:        "Configure BGP aggregate entries\n"
                   5590:        "Aggregate prefix\n")
                   5591: 
                   5592: ALIAS (no_ipv6_aggregate_address_summary_only,
                   5593:        old_no_ipv6_aggregate_address_summary_only_cmd,
                   5594:        "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
                   5595:        NO_STR
                   5596:        IPV6_STR
                   5597:        BGP_STR
                   5598:        "Configure BGP aggregate entries\n"
                   5599:        "Aggregate prefix\n"
                   5600:        "Filter more specific routes from updates\n")
1.1.1.4 ! misho    5601: 
1.1       misho    5602: /* Redistribute route treatment. */
                   5603: void
1.1.1.2   misho    5604: bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop,
                   5605:                      const struct in6_addr *nexthop6,
1.1       misho    5606:                      u_int32_t metric, u_char type)
                   5607: {
                   5608:   struct bgp *bgp;
                   5609:   struct listnode *node, *nnode;
                   5610:   struct bgp_info *new;
                   5611:   struct bgp_info *bi;
                   5612:   struct bgp_info info;
                   5613:   struct bgp_node *bn;
1.1.1.3   misho    5614:   struct attr attr;
1.1       misho    5615:   struct attr *new_attr;
                   5616:   afi_t afi;
                   5617:   int ret;
                   5618: 
                   5619:   /* Make default attribute. */
                   5620:   bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE);
                   5621:   if (nexthop)
                   5622:     attr.nexthop = *nexthop;
                   5623: 
1.1.1.2   misho    5624:   if (nexthop6)
                   5625:     {
                   5626:       struct attr_extra *extra = bgp_attr_extra_get(&attr);
                   5627:       extra->mp_nexthop_global = *nexthop6;
                   5628:       extra->mp_nexthop_len = 16;
                   5629:     }
                   5630: 
1.1       misho    5631:   attr.med = metric;
                   5632:   attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
                   5633: 
                   5634:   for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
                   5635:     {
                   5636:       afi = family2afi (p->family);
                   5637: 
                   5638:       if (bgp->redist[afi][type])
                   5639:        {
1.1.1.3   misho    5640:          struct attr attr_new;
                   5641:          struct attr_extra extra_new;
                   5642: 
1.1       misho    5643:          /* Copy attribute for modification. */
1.1.1.3   misho    5644:          attr_new.extra = &extra_new;
1.1       misho    5645:          bgp_attr_dup (&attr_new, &attr);
                   5646: 
                   5647:          if (bgp->redist_metric_flag[afi][type])
                   5648:            attr_new.med = bgp->redist_metric[afi][type];
                   5649: 
                   5650:          /* Apply route-map. */
1.1.1.4 ! misho    5651:          if (bgp->rmap[afi][type].name)
1.1       misho    5652:            {
                   5653:              info.peer = bgp->peer_self;
                   5654:              info.attr = &attr_new;
                   5655: 
                   5656:               SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE);
                   5657: 
                   5658:              ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP,
                   5659:                                     &info);
                   5660: 
                   5661:               bgp->peer_self->rmap_type = 0;
                   5662: 
                   5663:              if (ret == RMAP_DENYMATCH)
                   5664:                {
                   5665:                  /* Free uninterned attribute. */
                   5666:                  bgp_attr_flush (&attr_new);
1.1.1.3   misho    5667: 
1.1       misho    5668:                  /* Unintern original. */
                   5669:                  aspath_unintern (&attr.aspath);
                   5670:                  bgp_attr_extra_free (&attr);
                   5671:                  bgp_redistribute_delete (p, type);
                   5672:                  return;
                   5673:                }
                   5674:            }
                   5675: 
                   5676:           bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], 
                   5677:                                  afi, SAFI_UNICAST, p, NULL);
                   5678:           
                   5679:          new_attr = bgp_attr_intern (&attr_new);
1.1.1.3   misho    5680: 
1.1       misho    5681:          for (bi = bn->info; bi; bi = bi->next)
                   5682:            if (bi->peer == bgp->peer_self
                   5683:                && bi->sub_type == BGP_ROUTE_REDISTRIBUTE)
                   5684:              break;
                   5685:  
                   5686:          if (bi)
                   5687:            {
                   5688:              if (attrhash_cmp (bi->attr, new_attr) &&
                   5689:                  !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
                   5690:                {
                   5691:                  bgp_attr_unintern (&new_attr);
                   5692:                  aspath_unintern (&attr.aspath);
                   5693:                  bgp_attr_extra_free (&attr);
                   5694:                  bgp_unlock_node (bn);
                   5695:                  return;
                   5696:                }
                   5697:              else
                   5698:                {
                   5699:                  /* The attribute is changed. */
                   5700:                  bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED);
                   5701:  
                   5702:                  /* Rewrite BGP route information. */
                   5703:                  if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
                   5704:                    bgp_info_restore(bn, bi);
                   5705:                  else
                   5706:                    bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST);
                   5707:                  bgp_attr_unintern (&bi->attr);
                   5708:                  bi->attr = new_attr;
                   5709:                  bi->uptime = bgp_clock ();
                   5710:  
                   5711:                  /* Process change. */
                   5712:                  bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST);
                   5713:                  bgp_process (bgp, bn, afi, SAFI_UNICAST);
                   5714:                  bgp_unlock_node (bn);
                   5715:                  aspath_unintern (&attr.aspath);
                   5716:                  bgp_attr_extra_free (&attr);
                   5717:                  return;
                   5718:                } 
                   5719:            }
                   5720: 
                   5721:          new = bgp_info_new ();
                   5722:          new->type = type;
                   5723:          new->sub_type = BGP_ROUTE_REDISTRIBUTE;
                   5724:          new->peer = bgp->peer_self;
                   5725:          SET_FLAG (new->flags, BGP_INFO_VALID);
                   5726:          new->attr = new_attr;
                   5727:          new->uptime = bgp_clock ();
                   5728: 
                   5729:          bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST);
                   5730:          bgp_info_add (bn, new);
                   5731:          bgp_unlock_node (bn);
                   5732:          bgp_process (bgp, bn, afi, SAFI_UNICAST);
                   5733:        }
                   5734:     }
                   5735: 
                   5736:   /* Unintern original. */
                   5737:   aspath_unintern (&attr.aspath);
                   5738:   bgp_attr_extra_free (&attr);
                   5739: }
                   5740: 
                   5741: void
                   5742: bgp_redistribute_delete (struct prefix *p, u_char type)
                   5743: {
                   5744:   struct bgp *bgp;
                   5745:   struct listnode *node, *nnode;
                   5746:   afi_t afi;
                   5747:   struct bgp_node *rn;
                   5748:   struct bgp_info *ri;
                   5749: 
                   5750:   for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
                   5751:     {
                   5752:       afi = family2afi (p->family);
                   5753: 
                   5754:       if (bgp->redist[afi][type])
                   5755:        {
                   5756:          rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL);
                   5757: 
                   5758:          for (ri = rn->info; ri; ri = ri->next)
                   5759:            if (ri->peer == bgp->peer_self
                   5760:                && ri->type == type)
                   5761:              break;
                   5762: 
                   5763:          if (ri)
                   5764:            {
                   5765:              bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST);
                   5766:              bgp_info_delete (rn, ri);
                   5767:              bgp_process (bgp, rn, afi, SAFI_UNICAST);
                   5768:            }
                   5769:          bgp_unlock_node (rn);
                   5770:        }
                   5771:     }
                   5772: }
                   5773: 
                   5774: /* Withdraw specified route type's route. */
                   5775: void
                   5776: bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type)
                   5777: {
                   5778:   struct bgp_node *rn;
                   5779:   struct bgp_info *ri;
                   5780:   struct bgp_table *table;
                   5781: 
                   5782:   table = bgp->rib[afi][SAFI_UNICAST];
                   5783: 
                   5784:   for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
                   5785:     {
                   5786:       for (ri = rn->info; ri; ri = ri->next)
                   5787:        if (ri->peer == bgp->peer_self
                   5788:            && ri->type == type)
                   5789:          break;
                   5790: 
                   5791:       if (ri)
                   5792:        {
                   5793:          bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST);
                   5794:          bgp_info_delete (rn, ri);
                   5795:          bgp_process (bgp, rn, afi, SAFI_UNICAST);
                   5796:        }
                   5797:     }
                   5798: }
1.1.1.4 ! misho    5799: 
1.1       misho    5800: /* Static function to display route. */
                   5801: static void
                   5802: route_vty_out_route (struct prefix *p, struct vty *vty)
                   5803: {
                   5804:   int len;
                   5805:   u_int32_t destination; 
                   5806:   char buf[BUFSIZ];
                   5807: 
                   5808:   if (p->family == AF_INET)
                   5809:     {
                   5810:       len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ));
                   5811:       destination = ntohl (p->u.prefix4.s_addr);
                   5812: 
                   5813:       if ((IN_CLASSC (destination) && p->prefixlen == 24)
                   5814:          || (IN_CLASSB (destination) && p->prefixlen == 16)
                   5815:          || (IN_CLASSA (destination) && p->prefixlen == 8)
                   5816:          || p->u.prefix4.s_addr == 0)
                   5817:        {
                   5818:          /* When mask is natural, mask is not displayed. */
                   5819:        }
                   5820:       else
                   5821:        len += vty_out (vty, "/%d", p->prefixlen);
                   5822:     }
                   5823:   else
                   5824:     len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
                   5825:                   p->prefixlen);
                   5826: 
                   5827:   len = 17 - len;
                   5828:   if (len < 1)
                   5829:     vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " ");
                   5830:   else
                   5831:     vty_out (vty, "%*s", len, " ");
                   5832: }
                   5833: 
                   5834: enum bgp_display_type
                   5835: {
                   5836:   normal_list,
                   5837: };
                   5838: 
                   5839: /* Print the short form route status for a bgp_info */
                   5840: static void
                   5841: route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo)
                   5842: {
                   5843:  /* Route status display. */
                   5844:   if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
                   5845:     vty_out (vty, "R");
                   5846:   else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
                   5847:     vty_out (vty, "S");
                   5848:   else if (binfo->extra && binfo->extra->suppress)
                   5849:     vty_out (vty, "s");
                   5850:   else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
                   5851:     vty_out (vty, "*");
                   5852:   else
                   5853:     vty_out (vty, " ");
                   5854: 
                   5855:   /* Selected */
                   5856:   if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
                   5857:     vty_out (vty, "h");
                   5858:   else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
                   5859:     vty_out (vty, "d");
                   5860:   else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
                   5861:     vty_out (vty, ">");
1.1.1.4 ! misho    5862:   else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH))
        !          5863:     vty_out (vty, "=");
1.1       misho    5864:   else
                   5865:     vty_out (vty, " ");
                   5866: 
                   5867:   /* Internal route. */
                   5868:     if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as))
                   5869:       vty_out (vty, "i");
                   5870:     else
                   5871:       vty_out (vty, " "); 
                   5872: }
                   5873: 
                   5874: /* called from terminal list command */
                   5875: void
1.1.1.4 ! misho    5876: route_vty_out(
        !          5877:     struct vty *vty,
        !          5878:     struct prefix *p,
        !          5879:     struct bgp_info *binfo,
        !          5880:     int display,
        !          5881:     safi_t safi)
1.1       misho    5882: {
                   5883:   struct attr *attr;
                   5884:   
                   5885:   /* short status lead text */ 
                   5886:   route_vty_short_status_out (vty, binfo);
                   5887:   
                   5888:   /* print prefix and mask */
1.1.1.4 ! misho    5889:   if (!display)
1.1       misho    5890:     route_vty_out_route (p, vty);
                   5891:   else
                   5892:     vty_out (vty, "%*s", 17, " ");
                   5893: 
                   5894:   /* Print attribute */
                   5895:   attr = binfo->attr;
                   5896:   if (attr) 
                   5897:     {
                   5898: 
1.1.1.4 ! misho    5899:       /*
        !          5900:        * NEXTHOP start
        !          5901:        */
        !          5902: 
        !          5903:       /*
        !          5904:        * For ENCAP routes, nexthop address family is not
        !          5905:        * neccessarily the same as the prefix address family.
        !          5906:        * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field
        !          5907:        */
        !          5908:       if ((safi == SAFI_ENCAP) || (safi == SAFI_MPLS_VPN)) {
        !          5909:        if (attr->extra) {
        !          5910:            char        buf[BUFSIZ];
        !          5911:            int         af = NEXTHOP_FAMILY(attr->extra->mp_nexthop_len);
        !          5912: 
        !          5913:            switch (af) {
        !          5914:                case AF_INET:
        !          5915:                    vty_out (vty, "%s", inet_ntop(af,
        !          5916:                        &attr->extra->mp_nexthop_global_in, buf, BUFSIZ));
        !          5917:                    break;
        !          5918:                case AF_INET6:
        !          5919:                    vty_out (vty, "%s", inet_ntop(af,
        !          5920:                        &attr->extra->mp_nexthop_global, buf, BUFSIZ));
        !          5921:                    break;
        !          5922:                default:
        !          5923:                    vty_out(vty, "?");
        !          5924:            }
        !          5925:        } else {
        !          5926:            vty_out(vty, "?");
1.1       misho    5927:        }
1.1.1.4 ! misho    5928:       } else {
        !          5929: 
        !          5930:          if (p->family == AF_INET)
        !          5931:            {
        !          5932:                vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
        !          5933:            }
        !          5934:          else if (p->family == AF_INET6)
        !          5935:            {
        !          5936:              int len;
        !          5937:              char buf[BUFSIZ];
        !          5938: 
        !          5939:              len = vty_out (vty, "%s",
        !          5940:                             inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
        !          5941:                             buf, BUFSIZ));
        !          5942:              len = 16 - len;
        !          5943:              if (len < 1)
        !          5944:                vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
        !          5945:              else
        !          5946:                vty_out (vty, "%*s", len, " ");
        !          5947:            }
        !          5948:          else
        !          5949:           {
        !          5950:             vty_out(vty, "?");
        !          5951:           }
        !          5952:       }
        !          5953: 
        !          5954:       /*
        !          5955:        * NEXTHOP end
        !          5956:        */
        !          5957: 
1.1       misho    5958: 
                   5959:       if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
1.1.1.4 ! misho    5960:        vty_out (vty, "%10u ", attr->med);
1.1       misho    5961:       else
1.1.1.4 ! misho    5962:          vty_out (vty, "          ");
1.1       misho    5963: 
                   5964:       if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
1.1.1.4 ! misho    5965:        vty_out (vty, "%7u ", attr->local_pref);
1.1       misho    5966:       else
1.1.1.4 ! misho    5967:          vty_out (vty, "       ");
1.1       misho    5968: 
                   5969:       vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
                   5970:     
                   5971:       /* Print aspath */
                   5972:       if (attr->aspath)
                   5973:         aspath_print_vty (vty, "%s", attr->aspath, " ");
                   5974: 
                   5975:       /* Print origin */
                   5976:       vty_out (vty, "%s", bgp_origin_str[attr->origin]);
                   5977:     }
                   5978:   vty_out (vty, "%s", VTY_NEWLINE);
                   5979: }  
                   5980: 
                   5981: /* called from terminal list command */
                   5982: void
                   5983: route_vty_out_tmp (struct vty *vty, struct prefix *p,
                   5984:                   struct attr *attr, safi_t safi)
                   5985: {
                   5986:   /* Route status display. */
                   5987:   vty_out (vty, "*");
                   5988:   vty_out (vty, ">");
                   5989:   vty_out (vty, " ");
                   5990: 
                   5991:   /* print prefix and mask */
                   5992:   route_vty_out_route (p, vty);
                   5993: 
                   5994:   /* Print attribute */
                   5995:   if (attr) 
                   5996:     {
                   5997:       if (p->family == AF_INET)
                   5998:        {
1.1.1.4 ! misho    5999:          if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
1.1       misho    6000:            vty_out (vty, "%-16s",
                   6001:                      inet_ntoa (attr->extra->mp_nexthop_global_in));
                   6002:          else
                   6003:            vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
                   6004:        }
                   6005:       else if (p->family == AF_INET6)
                   6006:         {
                   6007:           int len;
                   6008:           char buf[BUFSIZ];
                   6009:           
                   6010:           assert (attr->extra);
                   6011: 
                   6012:           len = vty_out (vty, "%s",
                   6013:                          inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
                   6014:                          buf, BUFSIZ));
                   6015:           len = 16 - len;
                   6016:           if (len < 1)
                   6017:             vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
                   6018:           else
                   6019:             vty_out (vty, "%*s", len, " ");
                   6020:         }
                   6021: 
                   6022:       if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
1.1.1.4 ! misho    6023:        vty_out (vty, "%10u ", attr->med);
1.1       misho    6024:       else
                   6025:        vty_out (vty, "          ");
                   6026: 
                   6027:       if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
1.1.1.4 ! misho    6028:        vty_out (vty, "%7u ", attr->local_pref);
1.1       misho    6029:       else
                   6030:        vty_out (vty, "       ");
                   6031:       
                   6032:       vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
                   6033:       
                   6034:       /* Print aspath */
                   6035:       if (attr->aspath)
                   6036:         aspath_print_vty (vty, "%s", attr->aspath, " ");
                   6037: 
                   6038:       /* Print origin */
                   6039:       vty_out (vty, "%s", bgp_origin_str[attr->origin]);
                   6040:     }
                   6041: 
                   6042:   vty_out (vty, "%s", VTY_NEWLINE);
                   6043: }  
                   6044: 
                   6045: void
                   6046: route_vty_out_tag (struct vty *vty, struct prefix *p,
                   6047:                   struct bgp_info *binfo, int display, safi_t safi)
                   6048: {
                   6049:   struct attr *attr;
                   6050:   u_int32_t label = 0;
                   6051:   
                   6052:   if (!binfo->extra)
                   6053:     return;
                   6054:   
                   6055:   /* short status lead text */ 
                   6056:   route_vty_short_status_out (vty, binfo);
                   6057:     
                   6058:   /* print prefix and mask */
                   6059:   if (! display)
                   6060:     route_vty_out_route (p, vty);
                   6061:   else
                   6062:     vty_out (vty, "%*s", 17, " ");
                   6063: 
                   6064:   /* Print attribute */
                   6065:   attr = binfo->attr;
                   6066:   if (attr) 
                   6067:     {
                   6068:       if (p->family == AF_INET)
                   6069:        {
1.1.1.4 ! misho    6070:          if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
1.1       misho    6071:            vty_out (vty, "%-16s",
                   6072:                      inet_ntoa (attr->extra->mp_nexthop_global_in));
                   6073:          else
                   6074:            vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
                   6075:        }
                   6076:       else if (p->family == AF_INET6)
                   6077:        {
                   6078:          assert (attr->extra);
                   6079:          char buf[BUFSIZ];
                   6080:          char buf1[BUFSIZ];
                   6081:          if (attr->extra->mp_nexthop_len == 16)
                   6082:            vty_out (vty, "%s", 
                   6083:                     inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
                   6084:                      buf, BUFSIZ));
                   6085:          else if (attr->extra->mp_nexthop_len == 32)
                   6086:            vty_out (vty, "%s(%s)",
                   6087:                     inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
                   6088:                                buf, BUFSIZ),
                   6089:                     inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
                   6090:                                buf1, BUFSIZ));
                   6091:          
                   6092:        }
                   6093:     }
                   6094: 
                   6095:   label = decode_label (binfo->extra->tag);
                   6096: 
                   6097:   vty_out (vty, "notag/%d", label);
                   6098: 
                   6099:   vty_out (vty, "%s", VTY_NEWLINE);
                   6100: }  
                   6101: 
                   6102: /* dampening route */
                   6103: static void
                   6104: damp_route_vty_out (struct vty *vty, struct prefix *p,
                   6105:                    struct bgp_info *binfo, int display, safi_t safi)
                   6106: {
                   6107:   struct attr *attr;
                   6108:   int len;
                   6109:   char timebuf[BGP_UPTIME_LEN];
                   6110: 
                   6111:   /* short status lead text */ 
                   6112:   route_vty_short_status_out (vty, binfo);
                   6113:   
                   6114:   /* print prefix and mask */
                   6115:   if (! display)
                   6116:     route_vty_out_route (p, vty);
                   6117:   else
                   6118:     vty_out (vty, "%*s", 17, " ");
                   6119: 
                   6120:   len = vty_out (vty, "%s", binfo->peer->host);
                   6121:   len = 17 - len;
                   6122:   if (len < 1)
                   6123:     vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " ");
                   6124:   else
                   6125:     vty_out (vty, "%*s", len, " ");
                   6126: 
                   6127:   vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
                   6128: 
                   6129:   /* Print attribute */
                   6130:   attr = binfo->attr;
                   6131:   if (attr)
                   6132:     {
                   6133:       /* Print aspath */
                   6134:       if (attr->aspath)
                   6135:        aspath_print_vty (vty, "%s", attr->aspath, " ");
                   6136: 
                   6137:       /* Print origin */
                   6138:       vty_out (vty, "%s", bgp_origin_str[attr->origin]);
                   6139:     }
                   6140:   vty_out (vty, "%s", VTY_NEWLINE);
                   6141: }
                   6142: 
                   6143: /* flap route */
                   6144: static void
                   6145: flap_route_vty_out (struct vty *vty, struct prefix *p,
                   6146:                    struct bgp_info *binfo, int display, safi_t safi)
                   6147: {
                   6148:   struct attr *attr;
                   6149:   struct bgp_damp_info *bdi;
                   6150:   char timebuf[BGP_UPTIME_LEN];
                   6151:   int len;
                   6152:   
                   6153:   if (!binfo->extra)
                   6154:     return;
                   6155:   
                   6156:   bdi = binfo->extra->damp_info;
                   6157: 
                   6158:   /* short status lead text */
                   6159:   route_vty_short_status_out (vty, binfo);
                   6160:   
                   6161:   /* print prefix and mask */
                   6162:   if (! display)
                   6163:     route_vty_out_route (p, vty);
                   6164:   else
                   6165:     vty_out (vty, "%*s", 17, " ");
                   6166: 
                   6167:   len = vty_out (vty, "%s", binfo->peer->host);
                   6168:   len = 16 - len;
                   6169:   if (len < 1)
                   6170:     vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " ");
                   6171:   else
                   6172:     vty_out (vty, "%*s", len, " ");
                   6173: 
                   6174:   len = vty_out (vty, "%d", bdi->flap);
                   6175:   len = 5 - len;
                   6176:   if (len < 1)
                   6177:     vty_out (vty, " ");
                   6178:   else
                   6179:     vty_out (vty, "%*s ", len, " ");
                   6180:     
                   6181:   vty_out (vty, "%s ", peer_uptime (bdi->start_time,
                   6182:           timebuf, BGP_UPTIME_LEN));
                   6183: 
                   6184:   if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)
                   6185:       && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
                   6186:     vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
                   6187:   else
                   6188:     vty_out (vty, "%*s ", 8, " ");
                   6189: 
                   6190:   /* Print attribute */
                   6191:   attr = binfo->attr;
                   6192:   if (attr)
                   6193:     {
                   6194:       /* Print aspath */
                   6195:       if (attr->aspath)
                   6196:        aspath_print_vty (vty, "%s", attr->aspath, " ");
                   6197: 
                   6198:       /* Print origin */
                   6199:       vty_out (vty, "%s", bgp_origin_str[attr->origin]);
                   6200:     }
                   6201:   vty_out (vty, "%s", VTY_NEWLINE);
                   6202: }
                   6203: 
                   6204: static void
                   6205: route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, 
                   6206:                      struct bgp_info *binfo, afi_t afi, safi_t safi)
                   6207: {
                   6208:   char buf[INET6_ADDRSTRLEN];
                   6209:   char buf1[BUFSIZ];
                   6210:   struct attr *attr;
                   6211:   int sockunion_vty_out (struct vty *, union sockunion *);
                   6212: #ifdef HAVE_CLOCK_MONOTONIC
                   6213:   time_t tbuf;
                   6214: #endif
                   6215:        
                   6216:   attr = binfo->attr;
                   6217: 
                   6218:   if (attr)
                   6219:     {
                   6220:       /* Line1 display AS-path, Aggregator */
                   6221:       if (attr->aspath)
                   6222:        {
                   6223:          vty_out (vty, "  ");
                   6224:          if (aspath_count_hops (attr->aspath) == 0)
                   6225:            vty_out (vty, "Local");
                   6226:          else
                   6227:            aspath_print_vty (vty, "%s", attr->aspath, "");
                   6228:        }
                   6229: 
                   6230:       if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
                   6231:         vty_out (vty, ", (removed)");
                   6232:       if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
                   6233:        vty_out (vty, ", (stale)");
                   6234:       if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
                   6235:        vty_out (vty, ", (aggregated by %u %s)", 
                   6236:                 attr->extra->aggregator_as,
                   6237:                 inet_ntoa (attr->extra->aggregator_addr));
                   6238:       if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
                   6239:        vty_out (vty, ", (Received from a RR-client)");
                   6240:       if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
                   6241:        vty_out (vty, ", (Received from a RS-client)");
                   6242:       if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
                   6243:        vty_out (vty, ", (history entry)");
                   6244:       else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
                   6245:        vty_out (vty, ", (suppressed due to dampening)");
                   6246:       vty_out (vty, "%s", VTY_NEWLINE);
                   6247:          
                   6248:       /* Line2 display Next-hop, Neighbor, Router-id */
                   6249:       if (p->family == AF_INET)
                   6250:        {
1.1.1.4 ! misho    6251:          vty_out (vty, "    %s", ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) ?
1.1       misho    6252:                   inet_ntoa (attr->extra->mp_nexthop_global_in) :
                   6253:                   inet_ntoa (attr->nexthop));
                   6254:        }
                   6255:       else
                   6256:        {
                   6257:          assert (attr->extra);
                   6258:          vty_out (vty, "    %s",
                   6259:                   inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
                   6260:                              buf, INET6_ADDRSTRLEN));
                   6261:        }
                   6262: 
                   6263:       if (binfo->peer == bgp->peer_self)
                   6264:        {
                   6265:          vty_out (vty, " from %s ", 
                   6266:                   p->family == AF_INET ? "0.0.0.0" : "::");
                   6267:          vty_out (vty, "(%s)", inet_ntoa(bgp->router_id));
                   6268:        }
                   6269:       else
                   6270:        {
                   6271:          if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID))
                   6272:            vty_out (vty, " (inaccessible)"); 
                   6273:          else if (binfo->extra && binfo->extra->igpmetric)
1.1.1.3   misho    6274:            vty_out (vty, " (metric %u)", binfo->extra->igpmetric);
1.1.1.4 ! misho    6275:          if (!sockunion2str (&binfo->peer->su, buf, sizeof(buf))) {
        !          6276:            buf[0] = '?';
        !          6277:            buf[1] = 0;
        !          6278:          }
        !          6279:          vty_out (vty, " from %s", buf);
1.1       misho    6280:          if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
                   6281:            vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id));
                   6282:          else
                   6283:            vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ));
                   6284:        }
                   6285:       vty_out (vty, "%s", VTY_NEWLINE);
                   6286: 
                   6287:       /* display nexthop local */
                   6288:       if (attr->extra && attr->extra->mp_nexthop_len == 32)
                   6289:        {
                   6290:          vty_out (vty, "    (%s)%s",
                   6291:                   inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
                   6292:                              buf, INET6_ADDRSTRLEN),
                   6293:                   VTY_NEWLINE);
                   6294:        }
                   6295: 
                   6296:       /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
                   6297:       vty_out (vty, "      Origin %s", bgp_origin_long_str[attr->origin]);
                   6298:          
                   6299:       if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
                   6300:        vty_out (vty, ", metric %u", attr->med);
                   6301:          
                   6302:       if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
                   6303:        vty_out (vty, ", localpref %u", attr->local_pref);
                   6304:       else
                   6305:        vty_out (vty, ", localpref %u", bgp->default_local_pref);
                   6306: 
                   6307:       if (attr->extra && attr->extra->weight != 0)
                   6308:        vty_out (vty, ", weight %u", attr->extra->weight);
                   6309:        
                   6310:       if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
                   6311:        vty_out (vty, ", valid");
                   6312: 
                   6313:       if (binfo->peer != bgp->peer_self)
                   6314:        {
                   6315:          if (binfo->peer->as == binfo->peer->local_as)
                   6316:            vty_out (vty, ", internal");
                   6317:          else 
                   6318:            vty_out (vty, ", %s", 
                   6319:                     (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external"));
                   6320:        }
                   6321:       else if (binfo->sub_type == BGP_ROUTE_AGGREGATE)
                   6322:        vty_out (vty, ", aggregated, local");
                   6323:       else if (binfo->type != ZEBRA_ROUTE_BGP)
                   6324:        vty_out (vty, ", sourced");
                   6325:       else
                   6326:        vty_out (vty, ", sourced, local");
                   6327: 
                   6328:       if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
                   6329:        vty_out (vty, ", atomic-aggregate");
                   6330:          
1.1.1.2   misho    6331:       if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) ||
                   6332:          (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) &&
                   6333:           bgp_info_mpath_count (binfo)))
                   6334:        vty_out (vty, ", multipath");
                   6335: 
1.1       misho    6336:       if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
                   6337:        vty_out (vty, ", best");
                   6338: 
                   6339:       vty_out (vty, "%s", VTY_NEWLINE);
                   6340:          
                   6341:       /* Line 4 display Community */
                   6342:       if (attr->community)
                   6343:        vty_out (vty, "      Community: %s%s", attr->community->str,
                   6344:                 VTY_NEWLINE);
                   6345:          
                   6346:       /* Line 5 display Extended-community */
                   6347:       if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))
                   6348:        vty_out (vty, "      Extended Community: %s%s", 
                   6349:                 attr->extra->ecommunity->str, VTY_NEWLINE);
                   6350:          
                   6351:       /* Line 6 display Originator, Cluster-id */
                   6352:       if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) ||
                   6353:          (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)))
                   6354:        {
                   6355:          assert (attr->extra);
                   6356:          if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
                   6357:            vty_out (vty, "      Originator: %s", 
                   6358:                     inet_ntoa (attr->extra->originator_id));
                   6359: 
                   6360:          if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
                   6361:            {
                   6362:              int i;
                   6363:              vty_out (vty, ", Cluster list: ");
                   6364:              for (i = 0; i < attr->extra->cluster->length / 4; i++)
                   6365:                vty_out (vty, "%s ", 
                   6366:                         inet_ntoa (attr->extra->cluster->list[i]));
                   6367:            }
                   6368:          vty_out (vty, "%s", VTY_NEWLINE);
                   6369:        }
                   6370:       
                   6371:       if (binfo->extra && binfo->extra->damp_info)
                   6372:        bgp_damp_info_vty (vty, binfo);
                   6373: 
                   6374:       /* Line 7 display Uptime */
                   6375: #ifdef HAVE_CLOCK_MONOTONIC
                   6376:       tbuf = time(NULL) - (bgp_clock() - binfo->uptime);
                   6377:       vty_out (vty, "      Last update: %s", ctime(&tbuf));
                   6378: #else
                   6379:       vty_out (vty, "      Last update: %s", ctime(&binfo->uptime));
                   6380: #endif /* HAVE_CLOCK_MONOTONIC */
                   6381:     }
                   6382:   vty_out (vty, "%s", VTY_NEWLINE);
1.1.1.4 ! misho    6383: }
        !          6384: 
        !          6385: #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\
        !          6386:                              "h history, * valid, > best, = multipath,%s"\
        !          6387:                "              i internal, r RIB-failure, S Stale, R Removed%s"
1.1       misho    6388: #define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
                   6389: #define BGP_SHOW_HEADER "   Network          Next Hop            Metric LocPrf Weight Path%s"
                   6390: #define BGP_SHOW_DAMP_HEADER "   Network          From             Reuse    Path%s"
                   6391: #define BGP_SHOW_FLAP_HEADER "   Network          From            Flaps Duration Reuse    Path%s"
                   6392: 
                   6393: enum bgp_show_type
                   6394: {
                   6395:   bgp_show_type_normal,
                   6396:   bgp_show_type_regexp,
                   6397:   bgp_show_type_prefix_list,
                   6398:   bgp_show_type_filter_list,
                   6399:   bgp_show_type_route_map,
                   6400:   bgp_show_type_neighbor,
                   6401:   bgp_show_type_cidr_only,
                   6402:   bgp_show_type_prefix_longer,
                   6403:   bgp_show_type_community_all,
                   6404:   bgp_show_type_community,
                   6405:   bgp_show_type_community_exact,
                   6406:   bgp_show_type_community_list,
                   6407:   bgp_show_type_community_list_exact,
                   6408:   bgp_show_type_flap_statistics,
                   6409:   bgp_show_type_flap_address,
                   6410:   bgp_show_type_flap_prefix,
                   6411:   bgp_show_type_flap_cidr_only,
                   6412:   bgp_show_type_flap_regexp,
                   6413:   bgp_show_type_flap_filter_list,
                   6414:   bgp_show_type_flap_prefix_list,
                   6415:   bgp_show_type_flap_prefix_longer,
                   6416:   bgp_show_type_flap_route_map,
                   6417:   bgp_show_type_flap_neighbor,
                   6418:   bgp_show_type_dampend_paths,
                   6419:   bgp_show_type_damp_neighbor
                   6420: };
                   6421: 
                   6422: static int
                   6423: bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id,
                   6424:          enum bgp_show_type type, void *output_arg)
                   6425: {
                   6426:   struct bgp_info *ri;
                   6427:   struct bgp_node *rn;
                   6428:   int header = 1;
                   6429:   int display;
                   6430:   unsigned long output_count;
1.1.1.4 ! misho    6431:   unsigned long total_count;
1.1       misho    6432: 
                   6433:   /* This is first entry point, so reset total line. */
                   6434:   output_count = 0;
1.1.1.4 ! misho    6435:   total_count  = 0;
1.1       misho    6436: 
                   6437:   /* Start processing of routes. */
                   6438:   for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) 
                   6439:     if (rn->info != NULL)
                   6440:       {
                   6441:        display = 0;
                   6442: 
                   6443:        for (ri = rn->info; ri; ri = ri->next)
                   6444:          {
1.1.1.4 ! misho    6445:             total_count++;
1.1       misho    6446:            if (type == bgp_show_type_flap_statistics
                   6447:                || type == bgp_show_type_flap_address
                   6448:                || type == bgp_show_type_flap_prefix
                   6449:                || type == bgp_show_type_flap_cidr_only
                   6450:                || type == bgp_show_type_flap_regexp
                   6451:                || type == bgp_show_type_flap_filter_list
                   6452:                || type == bgp_show_type_flap_prefix_list
                   6453:                || type == bgp_show_type_flap_prefix_longer
                   6454:                || type == bgp_show_type_flap_route_map
                   6455:                || type == bgp_show_type_flap_neighbor
                   6456:                || type == bgp_show_type_dampend_paths
                   6457:                || type == bgp_show_type_damp_neighbor)
                   6458:              {
                   6459:                if (!(ri->extra && ri->extra->damp_info))
                   6460:                  continue;
                   6461:              }
                   6462:            if (type == bgp_show_type_regexp
                   6463:                || type == bgp_show_type_flap_regexp)
                   6464:              {
                   6465:                regex_t *regex = output_arg;
                   6466:                    
                   6467:                if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH)
                   6468:                  continue;
                   6469:              }
                   6470:            if (type == bgp_show_type_prefix_list
                   6471:                || type == bgp_show_type_flap_prefix_list)
                   6472:              {
                   6473:                struct prefix_list *plist = output_arg;
                   6474:                    
                   6475:                if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT)
                   6476:                  continue;
                   6477:              }
                   6478:            if (type == bgp_show_type_filter_list
                   6479:                || type == bgp_show_type_flap_filter_list)
                   6480:              {
                   6481:                struct as_list *as_list = output_arg;
                   6482: 
                   6483:                if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT)
                   6484:                  continue;
                   6485:              }
                   6486:            if (type == bgp_show_type_route_map
                   6487:                || type == bgp_show_type_flap_route_map)
                   6488:              {
                   6489:                struct route_map *rmap = output_arg;
                   6490:                struct bgp_info binfo;
1.1.1.3   misho    6491:                struct attr dummy_attr;
                   6492:                struct attr_extra dummy_extra;
1.1       misho    6493:                int ret;
                   6494: 
1.1.1.3   misho    6495:                dummy_attr.extra = &dummy_extra;
1.1       misho    6496:                bgp_attr_dup (&dummy_attr, ri->attr);
1.1.1.3   misho    6497: 
1.1       misho    6498:                binfo.peer = ri->peer;
                   6499:                binfo.attr = &dummy_attr;
                   6500: 
                   6501:                ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo);
                   6502:                if (ret == RMAP_DENYMATCH)
                   6503:                  continue;
                   6504:              }
                   6505:            if (type == bgp_show_type_neighbor
                   6506:                || type == bgp_show_type_flap_neighbor
                   6507:                || type == bgp_show_type_damp_neighbor)
                   6508:              {
                   6509:                union sockunion *su = output_arg;
                   6510: 
                   6511:                if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
                   6512:                  continue;
                   6513:              }
                   6514:            if (type == bgp_show_type_cidr_only
                   6515:                || type == bgp_show_type_flap_cidr_only)
                   6516:              {
                   6517:                u_int32_t destination;
                   6518: 
                   6519:                destination = ntohl (rn->p.u.prefix4.s_addr);
                   6520:                if (IN_CLASSC (destination) && rn->p.prefixlen == 24)
                   6521:                  continue;
                   6522:                if (IN_CLASSB (destination) && rn->p.prefixlen == 16)
                   6523:                  continue;
                   6524:                if (IN_CLASSA (destination) && rn->p.prefixlen == 8)
                   6525:                  continue;
                   6526:              }
                   6527:            if (type == bgp_show_type_prefix_longer
                   6528:                || type == bgp_show_type_flap_prefix_longer)
                   6529:              {
                   6530:                struct prefix *p = output_arg;
                   6531: 
                   6532:                if (! prefix_match (p, &rn->p))
                   6533:                  continue;
                   6534:              }
                   6535:            if (type == bgp_show_type_community_all)
                   6536:              {
                   6537:                if (! ri->attr->community)
                   6538:                  continue;
                   6539:              }
                   6540:            if (type == bgp_show_type_community)
                   6541:              {
                   6542:                struct community *com = output_arg;
                   6543: 
                   6544:                if (! ri->attr->community ||
                   6545:                    ! community_match (ri->attr->community, com))
                   6546:                  continue;
                   6547:              }
                   6548:            if (type == bgp_show_type_community_exact)
                   6549:              {
                   6550:                struct community *com = output_arg;
                   6551: 
                   6552:                if (! ri->attr->community ||
                   6553:                    ! community_cmp (ri->attr->community, com))
                   6554:                  continue;
                   6555:              }
                   6556:            if (type == bgp_show_type_community_list)
                   6557:              {
                   6558:                struct community_list *list = output_arg;
                   6559: 
                   6560:                if (! community_list_match (ri->attr->community, list))
                   6561:                  continue;
                   6562:              }
                   6563:            if (type == bgp_show_type_community_list_exact)
                   6564:              {
                   6565:                struct community_list *list = output_arg;
                   6566: 
                   6567:                if (! community_list_exact_match (ri->attr->community, list))
                   6568:                  continue;
                   6569:              }
                   6570:            if (type == bgp_show_type_flap_address
                   6571:                || type == bgp_show_type_flap_prefix)
                   6572:              {
                   6573:                struct prefix *p = output_arg;
                   6574: 
                   6575:                if (! prefix_match (&rn->p, p))
                   6576:                  continue;
                   6577: 
                   6578:                if (type == bgp_show_type_flap_prefix)
                   6579:                  if (p->prefixlen != rn->p.prefixlen)
                   6580:                    continue;
                   6581:              }
                   6582:            if (type == bgp_show_type_dampend_paths
                   6583:                || type == bgp_show_type_damp_neighbor)
                   6584:              {
                   6585:                if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)
                   6586:                    || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
                   6587:                  continue;
                   6588:              }
                   6589: 
                   6590:            if (header)
                   6591:              {
                   6592:                vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE);
                   6593:                vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
                   6594:                vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
                   6595:                if (type == bgp_show_type_dampend_paths
                   6596:                    || type == bgp_show_type_damp_neighbor)
                   6597:                  vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE);
                   6598:                else if (type == bgp_show_type_flap_statistics
                   6599:                         || type == bgp_show_type_flap_address
                   6600:                         || type == bgp_show_type_flap_prefix
                   6601:                         || type == bgp_show_type_flap_cidr_only
                   6602:                         || type == bgp_show_type_flap_regexp
                   6603:                         || type == bgp_show_type_flap_filter_list
                   6604:                         || type == bgp_show_type_flap_prefix_list
                   6605:                         || type == bgp_show_type_flap_prefix_longer
                   6606:                         || type == bgp_show_type_flap_route_map
                   6607:                         || type == bgp_show_type_flap_neighbor)
                   6608:                  vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE);
                   6609:                else
                   6610:                  vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
                   6611:                header = 0;
                   6612:              }
                   6613: 
                   6614:            if (type == bgp_show_type_dampend_paths
                   6615:                || type == bgp_show_type_damp_neighbor)
                   6616:              damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
                   6617:            else if (type == bgp_show_type_flap_statistics
                   6618:                     || type == bgp_show_type_flap_address
                   6619:                     || type == bgp_show_type_flap_prefix
                   6620:                     || type == bgp_show_type_flap_cidr_only
                   6621:                     || type == bgp_show_type_flap_regexp
                   6622:                     || type == bgp_show_type_flap_filter_list
                   6623:                     || type == bgp_show_type_flap_prefix_list
                   6624:                     || type == bgp_show_type_flap_prefix_longer
                   6625:                     || type == bgp_show_type_flap_route_map
                   6626:                     || type == bgp_show_type_flap_neighbor)
                   6627:              flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
                   6628:            else
                   6629:              route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
                   6630:            display++;
                   6631:          }
                   6632:        if (display)
                   6633:          output_count++;
                   6634:       }
                   6635: 
                   6636:   /* No route is displayed */
                   6637:   if (output_count == 0)
                   6638:     {
                   6639:       if (type == bgp_show_type_normal)
1.1.1.4 ! misho    6640:         vty_out (vty, "No BGP prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE);
1.1       misho    6641:     }
                   6642:   else
1.1.1.4 ! misho    6643:     vty_out (vty, "%sDisplayed  %ld out of %ld total prefixes%s",
        !          6644:             VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
1.1       misho    6645: 
                   6646:   return CMD_SUCCESS;
                   6647: }
                   6648: 
                   6649: static int
                   6650: bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
                   6651:          enum bgp_show_type type, void *output_arg)
                   6652: {
                   6653:   struct bgp_table *table;
                   6654: 
                   6655:   if (bgp == NULL) {
                   6656:     bgp = bgp_get_default ();
                   6657:   }
                   6658: 
                   6659:   if (bgp == NULL)
                   6660:     {
                   6661:       vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
                   6662:       return CMD_WARNING;
                   6663:     }
                   6664: 
                   6665: 
                   6666:   table = bgp->rib[afi][safi];
                   6667: 
                   6668:   return bgp_show_table (vty, table, &bgp->router_id, type, output_arg);
                   6669: }
                   6670: 
                   6671: /* Header of detailed BGP route information */
                   6672: static void
                   6673: route_vty_out_detail_header (struct vty *vty, struct bgp *bgp,
                   6674:                             struct bgp_node *rn,
                   6675:                              struct prefix_rd *prd, afi_t afi, safi_t safi)
                   6676: {
                   6677:   struct bgp_info *ri;
                   6678:   struct prefix *p;
                   6679:   struct peer *peer;
                   6680:   struct listnode *node, *nnode;
                   6681:   char buf1[INET6_ADDRSTRLEN];
                   6682:   char buf2[INET6_ADDRSTRLEN];
                   6683:   int count = 0;
                   6684:   int best = 0;
                   6685:   int suppress = 0;
                   6686:   int no_export = 0;
                   6687:   int no_advertise = 0;
                   6688:   int local_as = 0;
                   6689:   int first = 0;
1.1.1.4 ! misho    6690:   int printrd = ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP));
1.1       misho    6691: 
                   6692:   p = &rn->p;
                   6693:   vty_out (vty, "BGP routing table entry for %s%s%s/%d%s",
1.1.1.4 ! misho    6694:           (printrd ?  prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""),
        !          6695:           printrd ?  ":" : "",
1.1       misho    6696:           inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN),
                   6697:           p->prefixlen, VTY_NEWLINE);
                   6698: 
                   6699:   for (ri = rn->info; ri; ri = ri->next)
                   6700:     {
                   6701:       count++;
                   6702:       if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
                   6703:        {
                   6704:          best = count;
                   6705:          if (ri->extra && ri->extra->suppress)
                   6706:            suppress = 1;
                   6707:          if (ri->attr->community != NULL)
                   6708:            {
                   6709:              if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE))
                   6710:                no_advertise = 1;
                   6711:              if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT))
                   6712:                no_export = 1;
                   6713:              if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS))
                   6714:                local_as = 1;
                   6715:            }
                   6716:        }
                   6717:     }
                   6718: 
                   6719:   vty_out (vty, "Paths: (%d available", count);
                   6720:   if (best)
                   6721:     {
                   6722:       vty_out (vty, ", best #%d", best);
                   6723:       if (safi == SAFI_UNICAST)
                   6724:        vty_out (vty, ", table Default-IP-Routing-Table");
                   6725:     }
                   6726:   else
                   6727:     vty_out (vty, ", no best path");
                   6728:   if (no_advertise)
                   6729:     vty_out (vty, ", not advertised to any peer");
                   6730:   else if (no_export)
                   6731:     vty_out (vty, ", not advertised to EBGP peer");
                   6732:   else if (local_as)
                   6733:     vty_out (vty, ", not advertised outside local AS");
                   6734:   if (suppress)
                   6735:     vty_out (vty, ", Advertisements suppressed by an aggregate.");
                   6736:   vty_out (vty, ")%s", VTY_NEWLINE);
                   6737: 
                   6738:   /* advertised peer */
                   6739:   for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
                   6740:     {
                   6741:       if (bgp_adj_out_lookup (peer, p, afi, safi, rn))
                   6742:        {
                   6743:          if (! first)
                   6744:            vty_out (vty, "  Advertised to non peer-group peers:%s ", VTY_NEWLINE);
                   6745:          vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN));
                   6746:          first = 1;
                   6747:        }
                   6748:     }
                   6749:   if (! first)
                   6750:     vty_out (vty, "  Not advertised to any peer");
                   6751:   vty_out (vty, "%s", VTY_NEWLINE);
                   6752: }
                   6753: 
                   6754: /* Display specified route of BGP table. */
                   6755: static int
                   6756: bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, 
                   6757:                          struct bgp_table *rib, const char *ip_str,
                   6758:                          afi_t afi, safi_t safi, struct prefix_rd *prd,
                   6759:                          int prefix_check)
                   6760: {
                   6761:   int ret;
                   6762:   int header;
                   6763:   int display = 0;
                   6764:   struct prefix match;
                   6765:   struct bgp_node *rn;
                   6766:   struct bgp_node *rm;
                   6767:   struct bgp_info *ri;
                   6768:   struct bgp_table *table;
                   6769: 
1.1.1.4 ! misho    6770:   memset (&match, 0, sizeof (struct prefix)); /* keep valgrind happy */
1.1       misho    6771:   /* Check IP address argument. */
                   6772:   ret = str2prefix (ip_str, &match);
                   6773:   if (! ret)
                   6774:     {
                   6775:       vty_out (vty, "address is malformed%s", VTY_NEWLINE);
                   6776:       return CMD_WARNING;
                   6777:     }
                   6778: 
                   6779:   match.family = afi2family (afi);
                   6780: 
1.1.1.4 ! misho    6781:   if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
1.1       misho    6782:     {
                   6783:       for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
                   6784:         {
                   6785:           if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
                   6786:             continue;
                   6787: 
                   6788:           if ((table = rn->info) != NULL)
                   6789:             {
                   6790:               header = 1;
                   6791: 
                   6792:               if ((rm = bgp_node_match (table, &match)) != NULL)
                   6793:                 {
                   6794:                   if (prefix_check && rm->p.prefixlen != match.prefixlen)
                   6795:                     {
                   6796:                       bgp_unlock_node (rm);
                   6797:                       continue;
                   6798:                     }
                   6799: 
                   6800:                   for (ri = rm->info; ri; ri = ri->next)
                   6801:                     {
                   6802:                       if (header)
                   6803:                         {
                   6804:                           route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p,
1.1.1.4 ! misho    6805:                                                        AFI_IP, safi);
1.1       misho    6806: 
                   6807:                           header = 0;
                   6808:                         }
                   6809:                       display++;
1.1.1.4 ! misho    6810:                       route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, safi);
1.1       misho    6811:                     }
                   6812: 
                   6813:                   bgp_unlock_node (rm);
                   6814:                 }
                   6815:             }
                   6816:         }
                   6817:     }
                   6818:   else
                   6819:     {
                   6820:       header = 1;
                   6821: 
                   6822:       if ((rn = bgp_node_match (rib, &match)) != NULL)
                   6823:         {
                   6824:           if (! prefix_check || rn->p.prefixlen == match.prefixlen)
                   6825:             {
                   6826:               for (ri = rn->info; ri; ri = ri->next)
                   6827:                 {
                   6828:                   if (header)
                   6829:                     {
                   6830:                       route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi);
                   6831:                       header = 0;
                   6832:                     }
                   6833:                   display++;
                   6834:                   route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi);
                   6835:                 }
                   6836:             }
                   6837: 
                   6838:           bgp_unlock_node (rn);
                   6839:         }
                   6840:     }
                   6841: 
                   6842:   if (! display)
                   6843:     {
                   6844:       vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
                   6845:       return CMD_WARNING;
                   6846:     }
                   6847: 
                   6848:   return CMD_SUCCESS;
                   6849: }
                   6850: 
                   6851: /* Display specified route of Main RIB */
                   6852: static int
                   6853: bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str,
                   6854:                afi_t afi, safi_t safi, struct prefix_rd *prd,
                   6855:                int prefix_check)
                   6856: {
                   6857:   struct bgp *bgp;
                   6858: 
                   6859:   /* BGP structure lookup. */
                   6860:   if (view_name)
                   6861:     {
                   6862:       bgp = bgp_lookup_by_name (view_name);
                   6863:       if (bgp == NULL)
                   6864:        {
                   6865:          vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
                   6866:          return CMD_WARNING;
                   6867:        }
                   6868:     }
                   6869:   else
                   6870:     {
                   6871:       bgp = bgp_get_default ();
                   6872:       if (bgp == NULL)
                   6873:        {
                   6874:          vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
                   6875:          return CMD_WARNING;
                   6876:        }
                   6877:     }
                   6878:  
                   6879:   return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, 
                   6880:                                    afi, safi, prd, prefix_check);
                   6881: }
                   6882: 
                   6883: /* BGP route print out function. */
                   6884: DEFUN (show_ip_bgp,
                   6885:        show_ip_bgp_cmd,
                   6886:        "show ip bgp",
                   6887:        SHOW_STR
                   6888:        IP_STR
                   6889:        BGP_STR)
                   6890: {
                   6891:   return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
                   6892: }
                   6893: 
                   6894: DEFUN (show_ip_bgp_ipv4,
                   6895:        show_ip_bgp_ipv4_cmd,
                   6896:        "show ip bgp ipv4 (unicast|multicast)",
                   6897:        SHOW_STR
                   6898:        IP_STR
                   6899:        BGP_STR
                   6900:        "Address family\n"
                   6901:        "Address Family modifier\n"
                   6902:        "Address Family modifier\n")
                   6903: {
                   6904:   if (strncmp (argv[0], "m", 1) == 0)
                   6905:     return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
                   6906:                      NULL);
                   6907:  
                   6908:   return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
                   6909: }
                   6910: 
                   6911: DEFUN (show_ip_bgp_route,
                   6912:        show_ip_bgp_route_cmd,
                   6913:        "show ip bgp A.B.C.D",
                   6914:        SHOW_STR
                   6915:        IP_STR
                   6916:        BGP_STR
                   6917:        "Network in the BGP routing table to display\n")
                   6918: {
                   6919:   return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0);
                   6920: }
                   6921: 
                   6922: DEFUN (show_ip_bgp_ipv4_route,
                   6923:        show_ip_bgp_ipv4_route_cmd,
                   6924:        "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
                   6925:        SHOW_STR
                   6926:        IP_STR
                   6927:        BGP_STR
                   6928:        "Address family\n"
                   6929:        "Address Family modifier\n"
                   6930:        "Address Family modifier\n"
                   6931:        "Network in the BGP routing table to display\n")
                   6932: {
                   6933:   if (strncmp (argv[0], "m", 1) == 0)
                   6934:     return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0);
                   6935: 
                   6936:   return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
                   6937: }
                   6938: 
                   6939: DEFUN (show_ip_bgp_vpnv4_all_route,
                   6940:        show_ip_bgp_vpnv4_all_route_cmd,
                   6941:        "show ip bgp vpnv4 all A.B.C.D",
                   6942:        SHOW_STR
                   6943:        IP_STR
                   6944:        BGP_STR
                   6945:        "Display VPNv4 NLRI specific information\n"
                   6946:        "Display information about all VPNv4 NLRIs\n"
                   6947:        "Network in the BGP routing table to display\n")
                   6948: {
                   6949:   return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0);
                   6950: }
                   6951: 
                   6952: DEFUN (show_ip_bgp_vpnv4_rd_route,
                   6953:        show_ip_bgp_vpnv4_rd_route_cmd,
                   6954:        "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
                   6955:        SHOW_STR
                   6956:        IP_STR
                   6957:        BGP_STR
                   6958:        "Display VPNv4 NLRI specific information\n"
                   6959:        "Display information for a route distinguisher\n"
                   6960:        "VPN Route Distinguisher\n"
                   6961:        "Network in the BGP routing table to display\n")
                   6962: {
                   6963:   int ret;
                   6964:   struct prefix_rd prd;
                   6965: 
                   6966:   ret = str2prefix_rd (argv[0], &prd);
                   6967:   if (! ret)
                   6968:     {
                   6969:       vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
                   6970:       return CMD_WARNING;
                   6971:     }
                   6972:   return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0);
                   6973: }
                   6974: 
                   6975: DEFUN (show_ip_bgp_prefix,
                   6976:        show_ip_bgp_prefix_cmd,
                   6977:        "show ip bgp A.B.C.D/M",
                   6978:        SHOW_STR
                   6979:        IP_STR
                   6980:        BGP_STR
                   6981:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
                   6982: {
                   6983:   return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1);
                   6984: }
                   6985: 
                   6986: DEFUN (show_ip_bgp_ipv4_prefix,
                   6987:        show_ip_bgp_ipv4_prefix_cmd,
                   6988:        "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
                   6989:        SHOW_STR
                   6990:        IP_STR
                   6991:        BGP_STR
                   6992:        "Address family\n"
                   6993:        "Address Family modifier\n"
                   6994:        "Address Family modifier\n"
                   6995:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
                   6996: {
                   6997:   if (strncmp (argv[0], "m", 1) == 0)
                   6998:     return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1);
                   6999: 
                   7000:   return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
                   7001: }
                   7002: 
                   7003: DEFUN (show_ip_bgp_vpnv4_all_prefix,
                   7004:        show_ip_bgp_vpnv4_all_prefix_cmd,
                   7005:        "show ip bgp vpnv4 all A.B.C.D/M",
                   7006:        SHOW_STR
                   7007:        IP_STR
                   7008:        BGP_STR
                   7009:        "Display VPNv4 NLRI specific information\n"
                   7010:        "Display information about all VPNv4 NLRIs\n"
                   7011:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
                   7012: {
                   7013:   return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1);
                   7014: }
                   7015: 
                   7016: DEFUN (show_ip_bgp_vpnv4_rd_prefix,
                   7017:        show_ip_bgp_vpnv4_rd_prefix_cmd,
                   7018:        "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
                   7019:        SHOW_STR
                   7020:        IP_STR
                   7021:        BGP_STR
                   7022:        "Display VPNv4 NLRI specific information\n"
                   7023:        "Display information for a route distinguisher\n"
                   7024:        "VPN Route Distinguisher\n"
                   7025:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
                   7026: {
                   7027:   int ret;
                   7028:   struct prefix_rd prd;
                   7029: 
                   7030:   ret = str2prefix_rd (argv[0], &prd);
                   7031:   if (! ret)
                   7032:     {
                   7033:       vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
                   7034:       return CMD_WARNING;
                   7035:     }
                   7036:   return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1);
                   7037: }
                   7038: 
                   7039: DEFUN (show_ip_bgp_view,
                   7040:        show_ip_bgp_view_cmd,
                   7041:        "show ip bgp view WORD",
                   7042:        SHOW_STR
                   7043:        IP_STR
                   7044:        BGP_STR
                   7045:        "BGP view\n"
1.1.1.4 ! misho    7046:        "View name\n")
1.1       misho    7047: {
                   7048:   struct bgp *bgp;
                   7049: 
                   7050:   /* BGP structure lookup. */
                   7051:   bgp = bgp_lookup_by_name (argv[0]);
                   7052:   if (bgp == NULL)
                   7053:        {
                   7054:          vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
                   7055:          return CMD_WARNING;
                   7056:        }
                   7057: 
                   7058:   return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
                   7059: }
                   7060: 
                   7061: DEFUN (show_ip_bgp_view_route,
                   7062:        show_ip_bgp_view_route_cmd,
                   7063:        "show ip bgp view WORD A.B.C.D",
                   7064:        SHOW_STR
                   7065:        IP_STR
                   7066:        BGP_STR
                   7067:        "BGP view\n"
1.1.1.4 ! misho    7068:        "View name\n"
1.1       misho    7069:        "Network in the BGP routing table to display\n")
                   7070: {
                   7071:   return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
                   7072: }
                   7073: 
                   7074: DEFUN (show_ip_bgp_view_prefix,
                   7075:        show_ip_bgp_view_prefix_cmd,
                   7076:        "show ip bgp view WORD A.B.C.D/M",
                   7077:        SHOW_STR
                   7078:        IP_STR
                   7079:        BGP_STR
                   7080:        "BGP view\n"
1.1.1.4 ! misho    7081:        "View name\n"
1.1       misho    7082:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
                   7083: {
                   7084:   return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
                   7085: }
                   7086: 
                   7087: DEFUN (show_bgp,
                   7088:        show_bgp_cmd,
                   7089:        "show bgp",
                   7090:        SHOW_STR
                   7091:        BGP_STR)
                   7092: {
                   7093:   return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
                   7094:                    NULL);
                   7095: }
                   7096: 
                   7097: ALIAS (show_bgp,
                   7098:        show_bgp_ipv6_cmd,
                   7099:        "show bgp ipv6",
                   7100:        SHOW_STR
                   7101:        BGP_STR
                   7102:        "Address family\n")
                   7103: 
                   7104: /* old command */
                   7105: DEFUN (show_ipv6_bgp,
                   7106:        show_ipv6_bgp_cmd,
                   7107:        "show ipv6 bgp",
                   7108:        SHOW_STR
                   7109:        IP_STR
                   7110:        BGP_STR)
                   7111: {
                   7112:   return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
                   7113:                    NULL);
                   7114: }
                   7115: 
                   7116: DEFUN (show_bgp_route,
                   7117:        show_bgp_route_cmd,
                   7118:        "show bgp X:X::X:X",
                   7119:        SHOW_STR
                   7120:        BGP_STR
                   7121:        "Network in the BGP routing table to display\n")
                   7122: {
                   7123:   return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
                   7124: }
                   7125: 
1.1.1.4 ! misho    7126: DEFUN (show_bgp_ipv4_safi,
        !          7127:        show_bgp_ipv4_safi_cmd,
        !          7128:        "show bgp ipv4 (unicast|multicast)",
1.1       misho    7129:        SHOW_STR
                   7130:        BGP_STR
                   7131:        "Address family\n"
1.1.1.4 ! misho    7132:        "Address Family modifier\n"
        !          7133:        "Address Family modifier\n")
        !          7134: {
        !          7135:   if (strncmp (argv[0], "m", 1) == 0)
        !          7136:     return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
        !          7137:                      NULL);
        !          7138:  
        !          7139:   return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
        !          7140: }
1.1       misho    7141: 
1.1.1.4 ! misho    7142: DEFUN (show_bgp_ipv4_safi_route,
        !          7143:        show_bgp_ipv4_safi_route_cmd,
        !          7144:        "show bgp ipv4 (unicast|multicast) A.B.C.D",
1.1       misho    7145:        SHOW_STR
                   7146:        BGP_STR
                   7147:        "Address family\n"
                   7148:        "Address Family modifier\n"
                   7149:        "Address Family modifier\n"
                   7150:        "Network in the BGP routing table to display\n")
                   7151: {
                   7152:   if (strncmp (argv[0], "m", 1) == 0)
1.1.1.4 ! misho    7153:     return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0);
1.1       misho    7154: 
1.1.1.4 ! misho    7155:   return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
1.1       misho    7156: }
                   7157: 
1.1.1.4 ! misho    7158: DEFUN (show_bgp_ipv4_vpn_route,
        !          7159:        show_bgp_ipv4_vpn_route_cmd,
        !          7160:        "show bgp ipv4 vpn A.B.C.D",
1.1       misho    7161:        SHOW_STR
                   7162:        BGP_STR
1.1.1.4 ! misho    7163:        "Address Family\n"
        !          7164:        "Display VPN NLRI specific information\n"
1.1       misho    7165:        "Network in the BGP routing table to display\n")
                   7166: {
1.1.1.4 ! misho    7167:   return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0);
1.1       misho    7168: }
                   7169: 
1.1.1.4 ! misho    7170: DEFUN (show_bgp_ipv6_vpn_route,
        !          7171:        show_bgp_ipv6_vpn_route_cmd,
        !          7172:        "show bgp ipv6 vpn X:X::X:X",
1.1       misho    7173:        SHOW_STR
                   7174:        BGP_STR
1.1.1.4 ! misho    7175:        "Address Family\n"
        !          7176:        "Display VPN NLRI specific information\n"
        !          7177:        "Network in the BGP routing table to display\n")
1.1       misho    7178: {
1.1.1.4 ! misho    7179:   return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 0);
1.1       misho    7180: }
                   7181: 
1.1.1.4 ! misho    7182: DEFUN (show_bgp_ipv4_vpn_rd_route,
        !          7183:        show_bgp_ipv4_vpn_rd_route_cmd,
        !          7184:        "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D",
1.1       misho    7185:        SHOW_STR
                   7186:        BGP_STR
1.1.1.4 ! misho    7187:        IP_STR
        !          7188:        "Display VPN NLRI specific information\n"
        !          7189:        "Display information for a route distinguisher\n"
        !          7190:        "VPN Route Distinguisher\n"
        !          7191:        "Network in the BGP routing table to display\n")
        !          7192: {
        !          7193:   int ret;
        !          7194:   struct prefix_rd prd;
1.1       misho    7195: 
1.1.1.4 ! misho    7196:   ret = str2prefix_rd (argv[0], &prd);
        !          7197:   if (! ret)
        !          7198:     {
        !          7199:       vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
        !          7200:       return CMD_WARNING;
        !          7201:     }
        !          7202:   return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0);
        !          7203: }
        !          7204: 
        !          7205: DEFUN (show_bgp_ipv6_vpn_rd_route,
        !          7206:        show_bgp_ipv6_vpn_rd_route_cmd,
        !          7207:        "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn X:X::X:X",
1.1       misho    7208:        SHOW_STR
                   7209:        BGP_STR
1.1.1.4 ! misho    7210:        "Address Family\n"
        !          7211:        "Display VPN NLRI specific information\n"
        !          7212:        "Display information for a route distinguisher\n"
        !          7213:        "VPN Route Distinguisher\n"
        !          7214:        "Network in the BGP routing table to display\n")
1.1       misho    7215: {
1.1.1.4 ! misho    7216:   int ret;
        !          7217:   struct prefix_rd prd;
1.1       misho    7218: 
1.1.1.4 ! misho    7219:   ret = str2prefix_rd (argv[0], &prd);
        !          7220:   if (! ret)
        !          7221:     {
        !          7222:       vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
        !          7223:       return CMD_WARNING;
        !          7224:     }
        !          7225:   return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0);
1.1       misho    7226: }
                   7227: 
1.1.1.4 ! misho    7228: DEFUN (show_bgp_ipv4_encap_route,
        !          7229:        show_bgp_ipv4_encap_route_cmd,
        !          7230:        "show bgp ipv4 encap A.B.C.D",
1.1       misho    7231:        SHOW_STR
                   7232:        BGP_STR
1.1.1.4 ! misho    7233:        IP_STR
        !          7234:        "Display ENCAP NLRI specific information\n"
        !          7235:        "Network in the BGP routing table to display\n")
1.1       misho    7236: {
1.1.1.4 ! misho    7237:   return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 0);
1.1       misho    7238: }
                   7239: 
1.1.1.4 ! misho    7240: DEFUN (show_bgp_ipv6_encap_route,
        !          7241:        show_bgp_ipv6_encap_route_cmd,
        !          7242:        "show bgp ipv6 encap X:X::X:X",
1.1       misho    7243:        SHOW_STR
                   7244:        BGP_STR
1.1.1.4 ! misho    7245:        IP6_STR
        !          7246:        "Display ENCAP NLRI specific information\n"
        !          7247:        "Network in the BGP routing table to display\n")
1.1       misho    7248: {
1.1.1.4 ! misho    7249:   return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 0);
1.1       misho    7250: }
                   7251: 
1.1.1.4 ! misho    7252: DEFUN (show_bgp_ipv4_safi_rd_route,
        !          7253:        show_bgp_ipv4_safi_rd_route_cmd,
        !          7254:        "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D",
1.1       misho    7255:        SHOW_STR
                   7256:        BGP_STR
1.1.1.4 ! misho    7257:        "Address Family\n"
        !          7258:        "Address Family Modifier\n"
        !          7259:        "Address Family Modifier\n"
        !          7260:        "Display information for a route distinguisher\n"
        !          7261:        "ENCAP Route Distinguisher\n"
1.1       misho    7262:        "Network in the BGP routing table to display\n")
                   7263: {
1.1.1.4 ! misho    7264:   int ret;
        !          7265:   struct prefix_rd prd;
        !          7266:   safi_t       safi;
        !          7267: 
        !          7268:   if (bgp_parse_safi(argv[0], &safi)) {
        !          7269:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          7270:     return CMD_WARNING;
        !          7271:   }
        !          7272:   ret = str2prefix_rd (argv[1], &prd);
        !          7273:   if (! ret)
        !          7274:     {
        !          7275:       vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
        !          7276:       return CMD_WARNING;
        !          7277:     }
        !          7278:   return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 0);
1.1       misho    7279: }
                   7280: 
1.1.1.4 ! misho    7281: DEFUN (show_bgp_ipv6_safi_rd_route,
        !          7282:        show_bgp_ipv6_safi_rd_route_cmd,
        !          7283:        "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X",
1.1       misho    7284:        SHOW_STR
                   7285:        BGP_STR
1.1.1.4 ! misho    7286:        "Address Family\n"
        !          7287:        "Address Family Modifier\n"
        !          7288:        "Address Family Modifier\n"
        !          7289:        "Display information for a route distinguisher\n"
        !          7290:        "ENCAP Route Distinguisher\n"
1.1       misho    7291:        "Network in the BGP routing table to display\n")
1.1.1.4 ! misho    7292: {
        !          7293:   int ret;
        !          7294:   struct prefix_rd prd;
        !          7295:   safi_t       safi;
1.1       misho    7296: 
1.1.1.4 ! misho    7297:   if (bgp_parse_safi(argv[0], &safi)) {
        !          7298:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          7299:     return CMD_WARNING;
        !          7300:   }
        !          7301:   ret = str2prefix_rd (argv[1], &prd);
        !          7302:   if (! ret)
        !          7303:     {
        !          7304:       vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
        !          7305:       return CMD_WARNING;
        !          7306:     }
        !          7307:   return bgp_show_route (vty, NULL, argv[2], AFI_IP6, SAFI_ENCAP, &prd, 0);
        !          7308: }
        !          7309: 
        !          7310: DEFUN (show_bgp_ipv4_prefix,
        !          7311:        show_bgp_ipv4_prefix_cmd,
        !          7312:        "show bgp ipv4 A.B.C.D/M",
1.1       misho    7313:        SHOW_STR
                   7314:        BGP_STR
1.1.1.4 ! misho    7315:        IP_STR
        !          7316:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1.1       misho    7317: {
1.1.1.4 ! misho    7318:   return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1);
1.1       misho    7319: }
                   7320: 
1.1.1.4 ! misho    7321: DEFUN (show_bgp_ipv4_safi_prefix,
        !          7322:        show_bgp_ipv4_safi_prefix_cmd,
        !          7323:        "show bgp ipv4 (unicast|multicast) A.B.C.D/M",
1.1       misho    7324:        SHOW_STR
                   7325:        BGP_STR
                   7326:        "Address family\n"
1.1.1.4 ! misho    7327:        "Address Family modifier\n"
        !          7328:        "Address Family modifier\n"
        !          7329:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
        !          7330: {
        !          7331:   if (strncmp (argv[0], "m", 1) == 0)
        !          7332:     return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1);
1.1       misho    7333: 
1.1.1.4 ! misho    7334:   return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
        !          7335: }
        !          7336: 
        !          7337: DEFUN (show_bgp_ipv4_vpn_prefix,
        !          7338:        show_bgp_ipv4_vpn_prefix_cmd,
        !          7339:        "show bgp ipv4 vpn A.B.C.D/M",
1.1       misho    7340:        SHOW_STR
1.1.1.4 ! misho    7341:        BGP_STR
1.1       misho    7342:        IP_STR
1.1.1.4 ! misho    7343:        "Display VPN NLRI specific information\n"
        !          7344:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1.1       misho    7345: {
1.1.1.4 ! misho    7346:   return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1);
1.1       misho    7347: }
                   7348: 
1.1.1.4 ! misho    7349: DEFUN (show_bgp_ipv6_vpn_prefix,
        !          7350:        show_bgp_ipv6_vpn_prefix_cmd,
        !          7351:        "show bgp ipv6 vpn X:X::X:X/M",
1.1       misho    7352:        SHOW_STR
1.1.1.4 ! misho    7353:        BGP_STR
        !          7354:        "Address Family\n"
        !          7355:        "Display VPN NLRI specific information\n"
        !          7356:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
        !          7357: {
        !          7358:   return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 1);
        !          7359: }
        !          7360: 
        !          7361: DEFUN (show_bgp_ipv4_encap_prefix,
        !          7362:        show_bgp_ipv4_encap_prefix_cmd,
        !          7363:        "show bgp ipv4 encap A.B.C.D/M",
        !          7364:        SHOW_STR
        !          7365:        BGP_STR
1.1       misho    7366:        IP_STR
1.1.1.4 ! misho    7367:        "Display ENCAP NLRI specific information\n"
        !          7368:        "Display information about ENCAP NLRIs\n"
        !          7369:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1.1       misho    7370: {
1.1.1.4 ! misho    7371:   return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 1);
1.1       misho    7372: }
                   7373: 
1.1.1.4 ! misho    7374: DEFUN (show_bgp_ipv6_encap_prefix,
        !          7375:        show_bgp_ipv6_encap_prefix_cmd,
        !          7376:        "show bgp ipv6 encap X:X::X:X/M",
1.1       misho    7377:        SHOW_STR
1.1.1.4 ! misho    7378:        BGP_STR
1.1       misho    7379:        IP_STR
1.1.1.4 ! misho    7380:        "Display ENCAP NLRI specific information\n"
        !          7381:        "Display information about ENCAP NLRIs\n"
        !          7382:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1.1       misho    7383: {
1.1.1.4 ! misho    7384:   return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 1);
1.1       misho    7385: }
                   7386: 
1.1.1.4 ! misho    7387: DEFUN (show_bgp_ipv4_safi_rd_prefix,
        !          7388:        show_bgp_ipv4_safi_rd_prefix_cmd,
        !          7389:        "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M",
        !          7390:        SHOW_STR
        !          7391:        BGP_STR
        !          7392:        "Address Family\n"
        !          7393:        "Address Family Modifier\n"
        !          7394:        "Address Family Modifier\n"
        !          7395:        "Display information for a route distinguisher\n"
        !          7396:        "ENCAP Route Distinguisher\n"
        !          7397:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1.1       misho    7398: {
1.1.1.4 ! misho    7399:   int ret;
        !          7400:   struct prefix_rd prd;
        !          7401:   safi_t       safi;
1.1       misho    7402: 
1.1.1.4 ! misho    7403:   if (bgp_parse_safi(argv[0], &safi)) {
        !          7404:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          7405:     return CMD_WARNING;
        !          7406:   }
        !          7407: 
        !          7408:   ret = str2prefix_rd (argv[1], &prd);
        !          7409:   if (! ret)
        !          7410:     {
        !          7411:       vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
        !          7412:       return CMD_WARNING;
1.1       misho    7413:     }
1.1.1.4 ! misho    7414:   return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 1);
        !          7415: }
1.1       misho    7416: 
1.1.1.4 ! misho    7417: DEFUN (show_bgp_ipv6_safi_rd_prefix,
        !          7418:        show_bgp_ipv6_safi_rd_prefix_cmd,
        !          7419:        "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M",
        !          7420:        SHOW_STR
        !          7421:        BGP_STR
        !          7422:        "Address Family\n"
        !          7423:        "Address Family Modifier\n"
        !          7424:        "Address Family Modifier\n"
        !          7425:        "Display information for a route distinguisher\n"
        !          7426:        "ENCAP Route Distinguisher\n"
        !          7427:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
        !          7428: {
        !          7429:   int ret;
        !          7430:   struct prefix_rd prd;
        !          7431:   safi_t       safi;
1.1       misho    7432: 
1.1.1.4 ! misho    7433:   if (bgp_parse_safi(argv[0], &safi)) {
        !          7434:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          7435:     return CMD_WARNING;
        !          7436:   }
        !          7437: 
        !          7438:   ret = str2prefix_rd (argv[1], &prd);
        !          7439:   if (! ret)
1.1       misho    7440:     {
1.1.1.4 ! misho    7441:       vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
1.1       misho    7442:       return CMD_WARNING;
                   7443:     }
1.1.1.4 ! misho    7444:   return bgp_show_route (vty, NULL, argv[2], AFI_IP6, safi, &prd, 1);
        !          7445: }
1.1       misho    7446: 
1.1.1.4 ! misho    7447: DEFUN (show_bgp_afi_safi_view,
        !          7448:        show_bgp_afi_safi_view_cmd,
        !          7449:        "show bgp view WORD (ipv4|ipv6) (encap|mulicast|unicast|vpn)",
        !          7450:        SHOW_STR
        !          7451:        BGP_STR
        !          7452:        "BGP view\n"
        !          7453:        "BGP view name\n"
        !          7454:        "Address Family\n"
        !          7455:        "Address Family\n"
        !          7456:        "Address Family Modifier\n"
        !          7457:        "Address Family Modifier\n"
        !          7458:        "Address Family Modifier\n"
        !          7459:        "Address Family Modifier\n"
        !          7460:        )
        !          7461: {
        !          7462:   struct bgp *bgp;
        !          7463:   safi_t       safi;
        !          7464:   afi_t                afi;
        !          7465: 
        !          7466:   if (bgp_parse_afi(argv[1], &afi)) {
        !          7467:     vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
        !          7468:     return CMD_WARNING;
        !          7469:   }
        !          7470:   if (bgp_parse_safi(argv[2], &safi)) {
        !          7471:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
        !          7472:     return CMD_WARNING;
        !          7473:   }
        !          7474: 
        !          7475:   /* BGP structure lookup. */
        !          7476:   bgp = bgp_lookup_by_name (argv[0]);
        !          7477:   if (bgp == NULL)
        !          7478:        {
        !          7479:          vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
        !          7480:          return CMD_WARNING;
        !          7481:        }
        !          7482: 
        !          7483:   return bgp_show (vty, bgp, afi, safi, bgp_show_type_normal, NULL);
1.1       misho    7484: }
                   7485: 
1.1.1.4 ! misho    7486: DEFUN (show_bgp_view_afi_safi_route,
        !          7487:        show_bgp_view_afi_safi_route_cmd,
        !          7488:        "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D",
1.1       misho    7489:        SHOW_STR
                   7490:        BGP_STR
1.1.1.4 ! misho    7491:        "BGP view\n"
        !          7492:        "View name\n"
        !          7493:        "Address Family\n"
        !          7494:        "Address Family\n"
        !          7495:        "Address Family Modifier\n"
        !          7496:        "Address Family Modifier\n"
        !          7497:        "Address Family Modifier\n"
        !          7498:        "Address Family Modifier\n"
        !          7499:        "Network in the BGP routing table to display\n")
1.1       misho    7500: {
1.1.1.4 ! misho    7501:   safi_t       safi;
        !          7502:   afi_t                afi;
        !          7503: 
        !          7504:   if (bgp_parse_afi(argv[1], &afi)) {
        !          7505:     vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
        !          7506:     return CMD_WARNING;
        !          7507:   }
        !          7508:   if (bgp_parse_safi(argv[2], &safi)) {
        !          7509:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
        !          7510:     return CMD_WARNING;
        !          7511:   }
        !          7512:   return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 0);
1.1       misho    7513: }
                   7514: 
1.1.1.4 ! misho    7515: DEFUN (show_bgp_view_afi_safi_prefix,
        !          7516:        show_bgp_view_afi_safi_prefix_cmd,
        !          7517:        "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D/M",
1.1       misho    7518:        SHOW_STR
                   7519:        BGP_STR
1.1.1.4 ! misho    7520:        "BGP view\n"
        !          7521:        "View name\n"
        !          7522:        "Address Family\n"
        !          7523:        "Address Family\n"
        !          7524:        "Address Family Modifier\n"
        !          7525:        "Address Family Modifier\n"
        !          7526:        "Address Family Modifier\n"
        !          7527:        "Address Family Modifier\n"
        !          7528:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1.1       misho    7529: {
1.1.1.4 ! misho    7530:   safi_t       safi;
        !          7531:   afi_t                afi;
        !          7532: 
        !          7533:   if (bgp_parse_afi(argv[1], &afi)) {
        !          7534:     vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
        !          7535:     return CMD_WARNING;
        !          7536:   }
        !          7537:   if (bgp_parse_safi(argv[2], &safi)) {
        !          7538:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
        !          7539:     return CMD_WARNING;
        !          7540:   }
        !          7541:   return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 1);
1.1       misho    7542: }
                   7543: 
1.1.1.4 ! misho    7544: /* new001 */
        !          7545: DEFUN (show_bgp_afi,
        !          7546:        show_bgp_afi_cmd,
        !          7547:        "show bgp (ipv4|ipv6)",
1.1       misho    7548:        SHOW_STR
                   7549:        BGP_STR
                   7550:        "Address family\n"
1.1.1.4 ! misho    7551:        "Address family\n")
1.1       misho    7552: {
1.1.1.4 ! misho    7553:   afi_t        afi;
1.1       misho    7554: 
1.1.1.4 ! misho    7555:   if (bgp_parse_afi(argv[0], &afi)) {
        !          7556:     vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
        !          7557:     return CMD_WARNING;
        !          7558:   }
        !          7559:   return bgp_show (vty, NULL, afi, SAFI_UNICAST, bgp_show_type_normal,
        !          7560:                    NULL);
1.1       misho    7561: }
                   7562: 
1.1.1.4 ! misho    7563: DEFUN (show_bgp_ipv6_safi,
        !          7564:        show_bgp_ipv6_safi_cmd,
        !          7565:        "show bgp ipv6 (unicast|multicast)",
1.1       misho    7566:        SHOW_STR
                   7567:        BGP_STR
1.1.1.4 ! misho    7568:        "Address family\n"
        !          7569:        "Address Family modifier\n"
        !          7570:        "Address Family modifier\n")
1.1       misho    7571: {
1.1.1.4 ! misho    7572:   if (strncmp (argv[0], "m", 1) == 0)
        !          7573:     return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
        !          7574:                      NULL);
        !          7575: 
        !          7576:   return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
1.1       misho    7577: }
                   7578: 
1.1.1.4 ! misho    7579: DEFUN (show_bgp_ipv6_route,
        !          7580:        show_bgp_ipv6_route_cmd,
        !          7581:        "show bgp ipv6 X:X::X:X",
1.1       misho    7582:        SHOW_STR
                   7583:        BGP_STR
                   7584:        "Address family\n"
1.1.1.4 ! misho    7585:        "Network in the BGP routing table to display\n")
        !          7586: {
        !          7587:   return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
        !          7588: }
1.1       misho    7589: 
1.1.1.4 ! misho    7590: DEFUN (show_bgp_ipv6_safi_route,
        !          7591:        show_bgp_ipv6_safi_route_cmd,
        !          7592:        "show bgp ipv6 (unicast|multicast) X:X::X:X",
1.1       misho    7593:        SHOW_STR
                   7594:        BGP_STR
1.1.1.4 ! misho    7595:        "Address family\n"
        !          7596:        "Address Family modifier\n"
        !          7597:        "Address Family modifier\n"
        !          7598:        "Network in the BGP routing table to display\n")
1.1       misho    7599: {
1.1.1.4 ! misho    7600:   if (strncmp (argv[0], "m", 1) == 0)
        !          7601:     return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0);
        !          7602: 
        !          7603:   return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
1.1       misho    7604: }
                   7605: 
                   7606: /* old command */
1.1.1.4 ! misho    7607: DEFUN (show_ipv6_bgp_route,
        !          7608:        show_ipv6_bgp_route_cmd,
        !          7609:        "show ipv6 bgp X:X::X:X",
1.1       misho    7610:        SHOW_STR
                   7611:        IP_STR
                   7612:        BGP_STR
1.1.1.4 ! misho    7613:        "Network in the BGP routing table to display\n")
1.1       misho    7614: {
1.1.1.4 ! misho    7615:   return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
1.1       misho    7616: }
                   7617: 
1.1.1.4 ! misho    7618: DEFUN (show_bgp_prefix,
        !          7619:        show_bgp_prefix_cmd,
        !          7620:        "show bgp X:X::X:X/M",
1.1       misho    7621:        SHOW_STR
                   7622:        BGP_STR
1.1.1.4 ! misho    7623:        "IPv6 prefix <network>/<length>\n")
1.1       misho    7624: {
1.1.1.4 ! misho    7625:   return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
1.1       misho    7626: }
                   7627: 
1.1.1.4 ! misho    7628: 
        !          7629: /* new002 */
        !          7630: DEFUN (show_bgp_ipv6_prefix,
        !          7631:        show_bgp_ipv6_prefix_cmd,
        !          7632:        "show bgp ipv6 X:X::X:X/M",
1.1       misho    7633:        SHOW_STR
                   7634:        BGP_STR
1.1.1.4 ! misho    7635:        "Address family\n"
        !          7636:        "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
1.1       misho    7637: {
1.1.1.4 ! misho    7638:   return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
1.1       misho    7639: }
1.1.1.4 ! misho    7640: DEFUN (show_bgp_ipv6_safi_prefix,
        !          7641:        show_bgp_ipv6_safi_prefix_cmd,
        !          7642:        "show bgp ipv6 (unicast|multicast) X:X::X:X/M",
1.1       misho    7643:        SHOW_STR
                   7644:        BGP_STR
                   7645:        "Address family\n"
                   7646:        "Address Family modifier\n"
                   7647:        "Address Family modifier\n"
1.1.1.4 ! misho    7648:        "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
1.1       misho    7649: {
                   7650:   if (strncmp (argv[0], "m", 1) == 0)
1.1.1.4 ! misho    7651:     return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1);
1.1       misho    7652: 
1.1.1.4 ! misho    7653:   return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
1.1       misho    7654: }
                   7655: 
1.1.1.4 ! misho    7656: /* old command */
        !          7657: DEFUN (show_ipv6_bgp_prefix,
        !          7658:        show_ipv6_bgp_prefix_cmd,
        !          7659:        "show ipv6 bgp X:X::X:X/M",
1.1       misho    7660:        SHOW_STR
1.1.1.4 ! misho    7661:        IP_STR
1.1       misho    7662:        BGP_STR
1.1.1.4 ! misho    7663:        "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
1.1       misho    7664: {
1.1.1.4 ! misho    7665:   return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
1.1       misho    7666: }
                   7667: 
1.1.1.4 ! misho    7668: DEFUN (show_bgp_view,
        !          7669:        show_bgp_view_cmd,
        !          7670:        "show bgp view WORD",
1.1       misho    7671:        SHOW_STR
                   7672:        BGP_STR
1.1.1.4 ! misho    7673:        "BGP view\n"
        !          7674:        "View name\n")
1.1       misho    7675: {
1.1.1.4 ! misho    7676:   struct bgp *bgp;
        !          7677: 
        !          7678:   /* BGP structure lookup. */
        !          7679:   bgp = bgp_lookup_by_name (argv[0]);
        !          7680:   if (bgp == NULL)
        !          7681:        {
        !          7682:          vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
        !          7683:          return CMD_WARNING;
        !          7684:        }
        !          7685:   
        !          7686:   return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
1.1       misho    7687: }
                   7688: 
1.1.1.4 ! misho    7689: DEFUN (show_bgp_view_ipv6,
        !          7690:        show_bgp_view_ipv6_cmd,
        !          7691:        "show bgp view WORD ipv6",
1.1       misho    7692:        SHOW_STR
1.1.1.4 ! misho    7693:        BGP_STR             
        !          7694:        "BGP view\n"
        !          7695:        "View name\n"
        !          7696:        "Address family\n")
1.1       misho    7697: {
1.1.1.4 ! misho    7698:   struct bgp *bgp;
1.1       misho    7699: 
1.1.1.4 ! misho    7700:   /* BGP structure lookup. */
        !          7701:   bgp = bgp_lookup_by_name (argv[0]);
        !          7702:   if (bgp == NULL)
        !          7703:        {
        !          7704:          vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
        !          7705:          return CMD_WARNING;
        !          7706:        }
        !          7707:   
        !          7708:   return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
1.1       misho    7709: }
1.1.1.4 ! misho    7710:   
        !          7711: DEFUN (show_bgp_view_route,
        !          7712:        show_bgp_view_route_cmd,
        !          7713:        "show bgp view WORD X:X::X:X",
1.1       misho    7714:        SHOW_STR
                   7715:        BGP_STR
1.1.1.4 ! misho    7716:        "BGP view\n"
        !          7717:        "View name\n"
        !          7718:        "Network in the BGP routing table to display\n")
1.1       misho    7719: {
1.1.1.4 ! misho    7720:   return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
1.1       misho    7721: }
                   7722: 
1.1.1.4 ! misho    7723: DEFUN (show_bgp_view_ipv6_route,
        !          7724:        show_bgp_view_ipv6_route_cmd,
        !          7725:        "show bgp view WORD ipv6 X:X::X:X",
1.1       misho    7726:        SHOW_STR
                   7727:        BGP_STR
1.1.1.4 ! misho    7728:        "BGP view\n"
        !          7729:        "View name\n"
        !          7730:        "Address family\n"
        !          7731:        "Network in the BGP routing table to display\n")
1.1       misho    7732: {
1.1.1.4 ! misho    7733:   return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
1.1       misho    7734: }
                   7735: 
1.1.1.4 ! misho    7736: /* old command */
        !          7737: DEFUN (show_ipv6_mbgp,
        !          7738:        show_ipv6_mbgp_cmd,
        !          7739:        "show ipv6 mbgp",
1.1       misho    7740:        SHOW_STR
                   7741:        IP_STR
1.1.1.4 ! misho    7742:        MBGP_STR)
1.1       misho    7743: {
1.1.1.4 ! misho    7744:   return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
        !          7745:                    NULL);
1.1       misho    7746: }
                   7747: 
1.1.1.4 ! misho    7748: /* old command */
        !          7749: DEFUN (show_ipv6_mbgp_route,
        !          7750:        show_ipv6_mbgp_route_cmd,
        !          7751:        "show ipv6 mbgp X:X::X:X",
1.1       misho    7752:        SHOW_STR
1.1.1.4 ! misho    7753:        IP_STR
        !          7754:        MBGP_STR
        !          7755:        "Network in the MBGP routing table to display\n")
1.1       misho    7756: {
1.1.1.4 ! misho    7757:   return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0);
1.1       misho    7758: }
                   7759: 
1.1.1.4 ! misho    7760: /* old command */
        !          7761: DEFUN (show_ipv6_mbgp_prefix,
        !          7762:        show_ipv6_mbgp_prefix_cmd,
        !          7763:        "show ipv6 mbgp X:X::X:X/M",
1.1       misho    7764:        SHOW_STR
1.1.1.4 ! misho    7765:        IP_STR
        !          7766:        MBGP_STR
        !          7767:        "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
        !          7768: {
        !          7769:   return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1);
        !          7770: }
1.1       misho    7771: 
1.1.1.4 ! misho    7772: DEFUN (show_bgp_view_prefix,
        !          7773:        show_bgp_view_prefix_cmd,
        !          7774:        "show bgp view WORD X:X::X:X/M",
1.1       misho    7775:        SHOW_STR
                   7776:        BGP_STR
1.1.1.4 ! misho    7777:        "BGP view\n"
        !          7778:        "View name\n"       
        !          7779:        "IPv6 prefix <network>/<length>\n")
1.1       misho    7780: {
1.1.1.4 ! misho    7781:   return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); 
1.1       misho    7782: }
                   7783: 
1.1.1.4 ! misho    7784: DEFUN (show_bgp_view_ipv6_prefix,
        !          7785:        show_bgp_view_ipv6_prefix_cmd,
        !          7786:        "show bgp view WORD ipv6 X:X::X:X/M",
1.1       misho    7787:        SHOW_STR
1.1.1.4 ! misho    7788:        BGP_STR
        !          7789:        "BGP view\n"
        !          7790:        "View name\n"
        !          7791:        "Address family\n"
        !          7792:        "IPv6 prefix <network>/<length>\n")  
1.1       misho    7793: {
1.1.1.4 ! misho    7794:   return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); 
1.1       misho    7795: }
1.1.1.4 ! misho    7796: 
1.1       misho    7797: static int
1.1.1.4 ! misho    7798: bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi,
        !          7799:                 safi_t safi, enum bgp_show_type type)
1.1       misho    7800: {
1.1.1.4 ! misho    7801:   int i;
        !          7802:   struct buffer *b;
        !          7803:   char *regstr;
        !          7804:   int first;
        !          7805:   regex_t *regex;
        !          7806:   int rc;
        !          7807:   
        !          7808:   first = 0;
        !          7809:   b = buffer_new (1024);
        !          7810:   for (i = 0; i < argc; i++)
        !          7811:     {
        !          7812:       if (first)
        !          7813:        buffer_putc (b, ' ');
        !          7814:       else
        !          7815:        {
        !          7816:          if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
        !          7817:            continue;
        !          7818:          first = 1;
        !          7819:        }
1.1       misho    7820: 
1.1.1.4 ! misho    7821:       buffer_putstr (b, argv[i]);
        !          7822:     }
        !          7823:   buffer_putc (b, '\0');
        !          7824: 
        !          7825:   regstr = buffer_getstr (b);
        !          7826:   buffer_free (b);
        !          7827: 
        !          7828:   regex = bgp_regcomp (regstr);
        !          7829:   XFREE(MTYPE_TMP, regstr);
        !          7830:   if (! regex)
1.1       misho    7831:     {
1.1.1.4 ! misho    7832:       vty_out (vty, "Can't compile regexp %s%s", argv[0],
        !          7833:               VTY_NEWLINE);
1.1       misho    7834:       return CMD_WARNING;
                   7835:     }
                   7836: 
1.1.1.4 ! misho    7837:   rc = bgp_show (vty, NULL, afi, safi, type, regex);
        !          7838:   bgp_regex_free (regex);
        !          7839:   return rc;
1.1       misho    7840: }
                   7841: 
1.1.1.4 ! misho    7842: 
        !          7843: DEFUN (show_ip_bgp_regexp, 
        !          7844:        show_ip_bgp_regexp_cmd,
        !          7845:        "show ip bgp regexp .LINE",
1.1       misho    7846:        SHOW_STR
                   7847:        IP_STR
                   7848:        BGP_STR
1.1.1.4 ! misho    7849:        "Display routes matching the AS path regular expression\n"
        !          7850:        "A regular-expression to match the BGP AS paths\n")
1.1       misho    7851: {
1.1.1.4 ! misho    7852:   return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
        !          7853:                          bgp_show_type_regexp);
1.1       misho    7854: }
                   7855: 
1.1.1.4 ! misho    7856: DEFUN (show_ip_bgp_flap_regexp, 
        !          7857:        show_ip_bgp_flap_regexp_cmd,
        !          7858:        "show ip bgp flap-statistics regexp .LINE",
1.1       misho    7859:        SHOW_STR
                   7860:        IP_STR
                   7861:        BGP_STR
                   7862:        "Display flap statistics of routes\n"
1.1.1.4 ! misho    7863:        "Display routes matching the AS path regular expression\n"
        !          7864:        "A regular-expression to match the BGP AS paths\n")
1.1       misho    7865: {
1.1.1.4 ! misho    7866:   return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
        !          7867:                          bgp_show_type_flap_regexp);
1.1       misho    7868: }
                   7869: 
1.1.1.4 ! misho    7870: ALIAS (show_ip_bgp_flap_regexp,
        !          7871:        show_ip_bgp_damp_flap_regexp_cmd,
        !          7872:        "show ip bgp dampening flap-statistics regexp .LINE",
        !          7873:        SHOW_STR
        !          7874:        IP_STR
        !          7875:        BGP_STR
        !          7876:        "Display detailed information about dampening\n"
        !          7877:        "Display flap statistics of routes\n"
        !          7878:        "Display routes matching the AS path regular expression\n"
        !          7879:        "A regular-expression to match the BGP AS paths\n")
        !          7880: 
        !          7881: DEFUN (show_ip_bgp_ipv4_regexp, 
        !          7882:        show_ip_bgp_ipv4_regexp_cmd,
        !          7883:        "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
1.1       misho    7884:        SHOW_STR
                   7885:        IP_STR
                   7886:        BGP_STR
                   7887:        "Address family\n"
                   7888:        "Address Family modifier\n"
                   7889:        "Address Family modifier\n"
1.1.1.4 ! misho    7890:        "Display routes matching the AS path regular expression\n"
        !          7891:        "A regular-expression to match the BGP AS paths\n")
1.1       misho    7892: {
                   7893:   if (strncmp (argv[0], "m", 1) == 0)
1.1.1.4 ! misho    7894:     return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST,
        !          7895:                            bgp_show_type_regexp);
1.1       misho    7896: 
1.1.1.4 ! misho    7897:   return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
        !          7898:                          bgp_show_type_regexp);
1.1       misho    7899: }
                   7900: 
1.1.1.4 ! misho    7901: DEFUN (show_bgp_regexp, 
        !          7902:        show_bgp_regexp_cmd,
        !          7903:        "show bgp regexp .LINE",
1.1       misho    7904:        SHOW_STR
                   7905:        BGP_STR
1.1.1.4 ! misho    7906:        "Display routes matching the AS path regular expression\n"
        !          7907:        "A regular-expression to match the BGP AS paths\n")
1.1       misho    7908: {
1.1.1.4 ! misho    7909:   return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
        !          7910:                          bgp_show_type_regexp);
1.1       misho    7911: }
                   7912: 
1.1.1.4 ! misho    7913: /* old command */
        !          7914: DEFUN (show_ipv6_bgp_regexp, 
        !          7915:        show_ipv6_bgp_regexp_cmd,
        !          7916:        "show ipv6 bgp regexp .LINE",
1.1       misho    7917:        SHOW_STR
1.1.1.4 ! misho    7918:        IP_STR
1.1       misho    7919:        BGP_STR
1.1.1.4 ! misho    7920:        "Display routes matching the AS path regular expression\n"
        !          7921:        "A regular-expression to match the BGP AS paths\n")
        !          7922: {
        !          7923:   return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
        !          7924:                          bgp_show_type_regexp);
        !          7925: }
        !          7926: 
        !          7927: /* old command */
        !          7928: DEFUN (show_ipv6_mbgp_regexp, 
        !          7929:        show_ipv6_mbgp_regexp_cmd,
        !          7930:        "show ipv6 mbgp regexp .LINE",
1.1       misho    7931:        SHOW_STR
                   7932:        IP_STR
                   7933:        BGP_STR
1.1.1.4 ! misho    7934:        "Display routes matching the AS path regular expression\n"
        !          7935:        "A regular-expression to match the MBGP AS paths\n")
1.1       misho    7936: {
1.1.1.4 ! misho    7937:   return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST,
        !          7938:                          bgp_show_type_regexp);
1.1       misho    7939: }
                   7940: 
1.1.1.4 ! misho    7941: DEFUN (show_bgp_ipv4_safi_flap_regexp,
        !          7942:        show_bgp_ipv4_safi_flap_regexp_cmd,
        !          7943:        "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
1.1       misho    7944:        SHOW_STR
                   7945:        BGP_STR
1.1.1.4 ! misho    7946:        IP_STR
        !          7947:        "Address Family Modifier\n"
        !          7948:        "Address Family Modifier\n"
        !          7949:        "Address Family Modifier\n"
        !          7950:        "Address Family Modifier\n"
1.1       misho    7951:        "Display flap statistics of routes\n"
1.1.1.4 ! misho    7952:        "Display routes matching the AS path regular expression\n"
        !          7953:        "A regular-expression to match the BGP AS paths\n")
1.1       misho    7954: {
1.1.1.4 ! misho    7955:   safi_t       safi;
        !          7956: 
        !          7957:   if (bgp_parse_safi(argv[0], &safi)) {
        !          7958:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
        !          7959:     return CMD_WARNING;
        !          7960:   }
        !          7961:     return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
        !          7962:        bgp_show_type_flap_regexp);
1.1       misho    7963: }
                   7964: 
1.1.1.4 ! misho    7965: ALIAS (show_bgp_ipv4_safi_flap_regexp,
        !          7966:        show_bgp_ipv4_safi_damp_flap_regexp_cmd,
        !          7967:        "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
1.1       misho    7968:        SHOW_STR
1.1.1.4 ! misho    7969:        BGP_STR
1.1       misho    7970:        IP_STR
1.1.1.4 ! misho    7971:        "Address Family Modifier\n"
        !          7972:        "Address Family Modifier\n"
        !          7973:        "Address Family Modifier\n"
        !          7974:        "Address Family Modifier\n"
        !          7975:        "Display detailed information about dampening\n"
        !          7976:        "Display flap statistics of routes\n"
        !          7977:        "Display routes matching the AS path regular expression\n"
        !          7978:        "A regular-expression to match the BGP AS paths\n")
        !          7979: 
        !          7980: DEFUN (show_bgp_ipv6_safi_flap_regexp,
        !          7981:        show_bgp_ipv6_safi_flap_regexp_cmd,
        !          7982:        "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
        !          7983:        SHOW_STR
        !          7984:        BGP_STR
        !          7985:        IPV6_STR
        !          7986:        "Address Family Modifier\n"
        !          7987:        "Address Family Modifier\n"
        !          7988:        "Address Family Modifier\n"
        !          7989:        "Address Family Modifier\n"
        !          7990:        "Display flap statistics of routes\n"
        !          7991:        "Display routes matching the AS path regular expression\n"
        !          7992:        "A regular-expression to match the BGP AS paths\n")
        !          7993: {
        !          7994:   safi_t       safi;
        !          7995: 
        !          7996:   if (bgp_parse_safi(argv[0], &safi)) {
        !          7997:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
        !          7998:     return CMD_WARNING;
        !          7999:   }
        !          8000:     return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
        !          8001:        bgp_show_type_flap_regexp);
        !          8002: }
        !          8003: 
        !          8004: ALIAS (show_bgp_ipv6_safi_flap_regexp,
        !          8005:        show_bgp_ipv6_safi_damp_flap_regexp_cmd,
        !          8006:        "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
        !          8007:        SHOW_STR
        !          8008:        BGP_STR
        !          8009:        IPV6_STR
        !          8010:        "Address Family Modifier\n"
        !          8011:        "Address Family Modifier\n"
        !          8012:        "Address Family Modifier\n"
        !          8013:        "Address Family Modifier\n"
        !          8014:        "Display detailed information about dampening\n"
        !          8015:        "Display flap statistics of routes\n"
        !          8016:        "Display routes matching the AS path regular expression\n"
        !          8017:        "A regular-expression to match the BGP AS paths\n")
        !          8018: 
        !          8019: DEFUN (show_bgp_ipv4_safi_regexp, 
        !          8020:        show_bgp_ipv4_safi_regexp_cmd,
        !          8021:        "show bgp ipv4 (encap|multicast|unicast|vpn) regexp .LINE",
        !          8022:        SHOW_STR
1.1       misho    8023:        BGP_STR
                   8024:        "Address family\n"
                   8025:        "Address Family modifier\n"
                   8026:        "Address Family modifier\n"
1.1.1.4 ! misho    8027:        "Address Family modifier\n"
        !          8028:        "Address Family modifier\n"
        !          8029:        "Display routes matching the AS path regular expression\n"
        !          8030:        "A regular-expression to match the BGP AS paths\n")
1.1       misho    8031: {
1.1.1.4 ! misho    8032:   safi_t       safi;
        !          8033:   if (bgp_parse_safi(argv[0], &safi)) {
        !          8034:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          8035:     return CMD_WARNING;
        !          8036:   }
1.1       misho    8037: 
1.1.1.4 ! misho    8038:   return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
        !          8039:                          bgp_show_type_regexp);
1.1       misho    8040: }
1.1.1.4 ! misho    8041: 
        !          8042: DEFUN (show_bgp_ipv6_safi_regexp, 
        !          8043:        show_bgp_ipv6_safi_regexp_cmd,
        !          8044:        "show bgp ipv6 (encap|multicast|unicast|vpn) regexp .LINE",
        !          8045:        SHOW_STR
        !          8046:        BGP_STR
        !          8047:        "Address family\n"
        !          8048:        "Address Family modifier\n"
        !          8049:        "Address Family modifier\n"
        !          8050:        "Address Family modifier\n"
        !          8051:        "Address Family modifier\n"
        !          8052:        "Display routes matching the AS path regular expression\n"
        !          8053:        "A regular-expression to match the BGP AS paths\n")
        !          8054: {
        !          8055:   safi_t       safi;
        !          8056:   if (bgp_parse_safi(argv[0], &safi)) {
        !          8057:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          8058:     return CMD_WARNING;
        !          8059:   }
        !          8060: 
        !          8061:   return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
        !          8062:                          bgp_show_type_regexp);
        !          8063: }
        !          8064: 
        !          8065: DEFUN (show_bgp_ipv6_regexp, 
        !          8066:        show_bgp_ipv6_regexp_cmd,
        !          8067:        "show bgp ipv6 regexp .LINE",
        !          8068:        SHOW_STR
        !          8069:        BGP_STR
        !          8070:        "Address family\n"
        !          8071:        "Display routes matching the AS path regular expression\n"
        !          8072:        "A regular-expression to match the BGP AS paths\n")
        !          8073: {
        !          8074:   return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
        !          8075:                          bgp_show_type_regexp);
        !          8076: }
        !          8077: 
        !          8078: static int
        !          8079: bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi,
        !          8080:                      safi_t safi, enum bgp_show_type type)
        !          8081: {
        !          8082:   struct prefix_list *plist;
        !          8083: 
        !          8084:   plist = prefix_list_lookup (afi, prefix_list_str);
        !          8085:   if (plist == NULL)
        !          8086:     {
        !          8087:       vty_out (vty, "%% %s is not a valid prefix-list name%s",
        !          8088:                prefix_list_str, VTY_NEWLINE);      
        !          8089:       return CMD_WARNING;
        !          8090:     }
        !          8091: 
        !          8092:   return bgp_show (vty, NULL, afi, safi, type, plist);
        !          8093: }
        !          8094: DEFUN (show_ip_bgp_prefix_list, 
        !          8095:        show_ip_bgp_prefix_list_cmd,
        !          8096:        "show ip bgp prefix-list WORD",
1.1       misho    8097:        SHOW_STR
                   8098:        IP_STR
                   8099:        BGP_STR
1.1.1.4 ! misho    8100:        "Display routes conforming to the prefix-list\n"
        !          8101:        "IP prefix-list name\n")
1.1       misho    8102: {
1.1.1.4 ! misho    8103:   return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
        !          8104:                               bgp_show_type_prefix_list);
1.1       misho    8105: }
                   8106: 
1.1.1.4 ! misho    8107: DEFUN (show_ip_bgp_flap_prefix_list, 
        !          8108:        show_ip_bgp_flap_prefix_list_cmd,
        !          8109:        "show ip bgp flap-statistics prefix-list WORD",
        !          8110:        SHOW_STR
        !          8111:        IP_STR
        !          8112:        BGP_STR
        !          8113:        "Display flap statistics of routes\n"
        !          8114:        "Display routes conforming to the prefix-list\n"
        !          8115:        "IP prefix-list name\n")
        !          8116: {
        !          8117:   return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
        !          8118:                               bgp_show_type_flap_prefix_list);
        !          8119: }
        !          8120: 
        !          8121: ALIAS (show_ip_bgp_flap_prefix_list,
        !          8122:        show_ip_bgp_damp_flap_prefix_list_cmd,
        !          8123:        "show ip bgp dampening flap-statistics prefix-list WORD",
        !          8124:        SHOW_STR
        !          8125:        IP_STR
        !          8126:        BGP_STR
        !          8127:        "Display detailed information about dampening\n"
        !          8128:        "Display flap statistics of routes\n"
        !          8129:        "Display routes conforming to the prefix-list\n"
        !          8130:        "IP prefix-list name\n")
        !          8131: 
        !          8132: DEFUN (show_ip_bgp_ipv4_prefix_list, 
        !          8133:        show_ip_bgp_ipv4_prefix_list_cmd,
        !          8134:        "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
1.1       misho    8135:        SHOW_STR
                   8136:        IP_STR
                   8137:        BGP_STR
                   8138:        "Address family\n"
                   8139:        "Address Family modifier\n"
                   8140:        "Address Family modifier\n"
1.1.1.4 ! misho    8141:        "Display routes conforming to the prefix-list\n"
        !          8142:        "IP prefix-list name\n")
1.1       misho    8143: {
                   8144:   if (strncmp (argv[0], "m", 1) == 0)
1.1.1.4 ! misho    8145:     return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
        !          8146:                                 bgp_show_type_prefix_list);
        !          8147: 
        !          8148:   return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
        !          8149:                               bgp_show_type_prefix_list);
1.1       misho    8150: }
                   8151: 
1.1.1.4 ! misho    8152: DEFUN (show_bgp_prefix_list, 
        !          8153:        show_bgp_prefix_list_cmd,
        !          8154:        "show bgp prefix-list WORD",
1.1       misho    8155:        SHOW_STR
                   8156:        BGP_STR
1.1.1.4 ! misho    8157:        "Display routes conforming to the prefix-list\n"
        !          8158:        "IPv6 prefix-list name\n")
1.1       misho    8159: {
1.1.1.4 ! misho    8160:   return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
        !          8161:                               bgp_show_type_prefix_list);
1.1       misho    8162: }
                   8163: 
1.1.1.4 ! misho    8164: ALIAS (show_bgp_prefix_list, 
        !          8165:        show_bgp_ipv6_prefix_list_cmd,
        !          8166:        "show bgp ipv6 prefix-list WORD",
1.1       misho    8167:        SHOW_STR
                   8168:        BGP_STR
                   8169:        "Address family\n"
1.1.1.4 ! misho    8170:        "Display routes conforming to the prefix-list\n"
        !          8171:        "IPv6 prefix-list name\n")
1.1       misho    8172: 
                   8173: /* old command */
1.1.1.4 ! misho    8174: DEFUN (show_ipv6_bgp_prefix_list, 
        !          8175:        show_ipv6_bgp_prefix_list_cmd,
        !          8176:        "show ipv6 bgp prefix-list WORD",
1.1       misho    8177:        SHOW_STR
                   8178:        IPV6_STR
                   8179:        BGP_STR
1.1.1.4 ! misho    8180:        "Display routes matching the prefix-list\n"
        !          8181:        "IPv6 prefix-list name\n")
        !          8182: {
        !          8183:   return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
        !          8184:                               bgp_show_type_prefix_list);
1.1       misho    8185: }
                   8186: 
                   8187: /* old command */
1.1.1.4 ! misho    8188: DEFUN (show_ipv6_mbgp_prefix_list, 
        !          8189:        show_ipv6_mbgp_prefix_list_cmd,
        !          8190:        "show ipv6 mbgp prefix-list WORD",
1.1       misho    8191:        SHOW_STR
                   8192:        IPV6_STR
                   8193:        MBGP_STR
1.1.1.4 ! misho    8194:        "Display routes matching the prefix-list\n"
        !          8195:        "IPv6 prefix-list name\n")
1.1       misho    8196: {
1.1.1.4 ! misho    8197:   return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
        !          8198:                               bgp_show_type_prefix_list);
1.1       misho    8199: }
1.1.1.4 ! misho    8200: 
        !          8201: DEFUN (show_bgp_ipv4_prefix_list, 
        !          8202:        show_bgp_ipv4_prefix_list_cmd,
        !          8203:        "show bgp ipv4 prefix-list WORD",
        !          8204:        SHOW_STR
        !          8205:        BGP_STR
        !          8206:        IP_STR
        !          8207:        "Display routes conforming to the prefix-list\n"
        !          8208:        "IP prefix-list name\n")
1.1       misho    8209: {
1.1.1.4 ! misho    8210:   return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
        !          8211:                               bgp_show_type_prefix_list);
        !          8212: }
1.1       misho    8213: 
1.1.1.4 ! misho    8214: DEFUN (show_bgp_ipv4_safi_flap_prefix_list, 
        !          8215:        show_bgp_ipv4_safi_flap_prefix_list_cmd,
        !          8216:        "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
        !          8217:        SHOW_STR
        !          8218:        BGP_STR
        !          8219:        IP_STR
        !          8220:        "Address Family Modifier\n"
        !          8221:        "Address Family Modifier\n"
        !          8222:        "Address Family Modifier\n"
        !          8223:        "Address Family Modifier\n"
        !          8224:        "Display flap statistics of routes\n"
        !          8225:        "Display routes conforming to the prefix-list\n"
        !          8226:        "IP prefix-list name\n")
        !          8227: {
        !          8228:   safi_t       safi;
        !          8229:   if (bgp_parse_safi(argv[0], &safi)) {
        !          8230:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          8231:     return CMD_WARNING;
        !          8232:   }
        !          8233:   return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
        !          8234:                               bgp_show_type_flap_prefix_list);
        !          8235: }
1.1       misho    8236: 
1.1.1.4 ! misho    8237: ALIAS (show_bgp_ipv4_safi_flap_prefix_list, 
        !          8238:        show_bgp_ipv4_safi_damp_flap_prefix_list_cmd,
        !          8239:        "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
        !          8240:        SHOW_STR
        !          8241:        BGP_STR
        !          8242:        IP_STR
        !          8243:        "Address Family Modifier\n"
        !          8244:        "Address Family Modifier\n"
        !          8245:        "Address Family Modifier\n"
        !          8246:        "Address Family Modifier\n"
        !          8247:        "Display detailed information about dampening\n"
        !          8248:        "Display flap statistics of routes\n"
        !          8249:        "Display routes conforming to the prefix-list\n"
        !          8250:        "IP prefix-list name\n")
1.1       misho    8251: 
1.1.1.4 ! misho    8252: DEFUN (show_bgp_ipv6_safi_flap_prefix_list, 
        !          8253:        show_bgp_ipv6_safi_flap_prefix_list_cmd,
        !          8254:        "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
        !          8255:        SHOW_STR
        !          8256:        BGP_STR
        !          8257:        IPV6_STR
        !          8258:        "Address Family Modifier\n"
        !          8259:        "Address Family Modifier\n"
        !          8260:        "Address Family Modifier\n"
        !          8261:        "Address Family Modifier\n"
        !          8262:        "Display flap statistics of routes\n"
        !          8263:        "Display routes conforming to the prefix-list\n"
        !          8264:        "IP prefix-list name\n")
        !          8265: {
        !          8266:   safi_t       safi;
        !          8267:   if (bgp_parse_safi(argv[0], &safi)) {
        !          8268:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          8269:     return CMD_WARNING;
        !          8270:   }
        !          8271:   return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi,
        !          8272:                               bgp_show_type_flap_prefix_list);
        !          8273: }
        !          8274: ALIAS (show_bgp_ipv6_safi_flap_prefix_list, 
        !          8275:        show_bgp_ipv6_safi_damp_flap_prefix_list_cmd,
        !          8276:        "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
        !          8277:        SHOW_STR
        !          8278:        BGP_STR
        !          8279:        IPV6_STR
        !          8280:        "Address Family Modifier\n"
        !          8281:        "Address Family Modifier\n"
        !          8282:        "Address Family Modifier\n"
        !          8283:        "Address Family Modifier\n"
        !          8284:        "Display detailed information about dampening\n"
        !          8285:        "Display flap statistics of routes\n"
        !          8286:        "Display routes conforming to the prefix-list\n"
        !          8287:        "IP prefix-list name\n")
1.1       misho    8288: 
1.1.1.4 ! misho    8289: DEFUN (show_bgp_ipv4_safi_prefix_list, 
        !          8290:        show_bgp_ipv4_safi_prefix_list_cmd,
        !          8291:        "show bgp ipv4 (encap|multicast|unicast|vpn) prefix-list WORD",
        !          8292:        SHOW_STR
        !          8293:        BGP_STR
        !          8294:        "Address family\n"
        !          8295:        "Address Family modifier\n"
        !          8296:        "Address Family modifier\n"
        !          8297:        "Address Family modifier\n"
        !          8298:        "Address Family modifier\n"
        !          8299:        "Display routes conforming to the prefix-list\n"
        !          8300:        "IP prefix-list name\n")
        !          8301: {
        !          8302:   safi_t       safi;
        !          8303:   if (bgp_parse_safi(argv[0], &safi)) {
        !          8304:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          8305:     return CMD_WARNING;
        !          8306:   }
        !          8307:   return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
        !          8308:                               bgp_show_type_prefix_list);
        !          8309: }
        !          8310: 
        !          8311: DEFUN (show_bgp_ipv6_safi_prefix_list, 
        !          8312:        show_bgp_ipv6_safi_prefix_list_cmd,
        !          8313:        "show bgp ipv6 (encap|multicast|unicast|vpn) prefix-list WORD",
        !          8314:        SHOW_STR
        !          8315:        BGP_STR
        !          8316:        "Address family\n"
        !          8317:        "Address Family modifier\n"
        !          8318:        "Address Family modifier\n"
        !          8319:        "Address Family modifier\n"
        !          8320:        "Address Family modifier\n"
        !          8321:        "Display routes conforming to the prefix-list\n"
        !          8322:        "IP prefix-list name\n")
        !          8323: {
        !          8324:   safi_t       safi;
        !          8325:   if (bgp_parse_safi(argv[0], &safi)) {
        !          8326:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          8327:     return CMD_WARNING;
        !          8328:   }
        !          8329:   return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi,
        !          8330:                               bgp_show_type_prefix_list);
        !          8331: }
        !          8332: 
        !          8333: static int
        !          8334: bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi,
        !          8335:                      safi_t safi, enum bgp_show_type type)
        !          8336: {
        !          8337:   struct as_list *as_list;
        !          8338: 
        !          8339:   as_list = as_list_lookup (filter);
        !          8340:   if (as_list == NULL)
1.1       misho    8341:     {
1.1.1.4 ! misho    8342:       vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE);       
1.1       misho    8343:       return CMD_WARNING;
                   8344:     }
                   8345: 
1.1.1.4 ! misho    8346:   return bgp_show (vty, NULL, afi, safi, type, as_list);
1.1       misho    8347: }
                   8348: 
1.1.1.4 ! misho    8349: DEFUN (show_ip_bgp_filter_list, 
        !          8350:        show_ip_bgp_filter_list_cmd,
        !          8351:        "show ip bgp filter-list WORD",
1.1       misho    8352:        SHOW_STR
                   8353:        IP_STR
                   8354:        BGP_STR
1.1.1.4 ! misho    8355:        "Display routes conforming to the filter-list\n"
        !          8356:        "Regular expression access list name\n")
1.1       misho    8357: {
1.1.1.4 ! misho    8358:   return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
        !          8359:                               bgp_show_type_filter_list);
1.1       misho    8360: }
                   8361: 
1.1.1.4 ! misho    8362: DEFUN (show_ip_bgp_flap_filter_list, 
        !          8363:        show_ip_bgp_flap_filter_list_cmd,
        !          8364:        "show ip bgp flap-statistics filter-list WORD",
1.1       misho    8365:        SHOW_STR
                   8366:        IP_STR
                   8367:        BGP_STR
1.1.1.4 ! misho    8368:        "Display flap statistics of routes\n"
        !          8369:        "Display routes conforming to the filter-list\n"
        !          8370:        "Regular expression access list name\n")
        !          8371: {
        !          8372:   return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
        !          8373:                               bgp_show_type_flap_filter_list);
        !          8374: }
        !          8375: 
        !          8376: ALIAS (show_ip_bgp_flap_filter_list, 
        !          8377:        show_ip_bgp_damp_flap_filter_list_cmd,
        !          8378:        "show ip bgp dampening flap-statistics filter-list WORD",
1.1       misho    8379:        SHOW_STR
                   8380:        IP_STR
                   8381:        BGP_STR
1.1.1.4 ! misho    8382:        "Display detailed information about dampening\n"
        !          8383:        "Display flap statistics of routes\n"
        !          8384:        "Display routes conforming to the filter-list\n"
        !          8385:        "Regular expression access list name\n")
1.1       misho    8386: 
1.1.1.4 ! misho    8387: DEFUN (show_ip_bgp_ipv4_filter_list, 
        !          8388:        show_ip_bgp_ipv4_filter_list_cmd,
        !          8389:        "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
1.1       misho    8390:        SHOW_STR
                   8391:        IP_STR
                   8392:        BGP_STR
                   8393:        "Address family\n"
                   8394:        "Address Family modifier\n"
                   8395:        "Address Family modifier\n"
1.1.1.4 ! misho    8396:        "Display routes conforming to the filter-list\n"
        !          8397:        "Regular expression access list name\n")
1.1       misho    8398: {
                   8399:   if (strncmp (argv[0], "m", 1) == 0)
1.1.1.4 ! misho    8400:     return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
        !          8401:                                 bgp_show_type_filter_list);
        !          8402:   
        !          8403:   return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
        !          8404:                               bgp_show_type_filter_list);
        !          8405: }
        !          8406: 
        !          8407: DEFUN (show_bgp_filter_list, 
        !          8408:        show_bgp_filter_list_cmd,
        !          8409:        "show bgp filter-list WORD",
        !          8410:        SHOW_STR
        !          8411:        BGP_STR
        !          8412:        "Display routes conforming to the filter-list\n"
        !          8413:        "Regular expression access list name\n")
        !          8414: {
        !          8415:   return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
        !          8416:                               bgp_show_type_filter_list);
        !          8417: }
        !          8418: 
        !          8419: /* old command */
        !          8420: DEFUN (show_ipv6_bgp_filter_list, 
        !          8421:        show_ipv6_bgp_filter_list_cmd,
        !          8422:        "show ipv6 bgp filter-list WORD",
        !          8423:        SHOW_STR
        !          8424:        IPV6_STR
        !          8425:        BGP_STR
        !          8426:        "Display routes conforming to the filter-list\n"
        !          8427:        "Regular expression access list name\n")
        !          8428: {
        !          8429:   return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
        !          8430:                               bgp_show_type_filter_list);
        !          8431: }
        !          8432: 
        !          8433: /* old command */
        !          8434: DEFUN (show_ipv6_mbgp_filter_list, 
        !          8435:        show_ipv6_mbgp_filter_list_cmd,
        !          8436:        "show ipv6 mbgp filter-list WORD",
        !          8437:        SHOW_STR
        !          8438:        IPV6_STR
        !          8439:        MBGP_STR
        !          8440:        "Display routes conforming to the filter-list\n"
        !          8441:        "Regular expression access list name\n")
        !          8442: {
        !          8443:   return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
        !          8444:                               bgp_show_type_filter_list);
        !          8445: }
        !          8446: 
        !          8447: DEFUN (show_ip_bgp_dampening_info,
        !          8448:        show_ip_bgp_dampening_params_cmd,
        !          8449:        "show ip bgp dampening parameters",
1.1       misho    8450:        SHOW_STR
                   8451:        IP_STR
                   8452:        BGP_STR
1.1.1.4 ! misho    8453:        "Display detailed information about dampening\n"
        !          8454:        "Display detail of configured dampening parameters\n")
        !          8455: {
        !          8456:     return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST);
        !          8457: }
        !          8458: 
        !          8459: DEFUN (show_bgp_ipv4_filter_list, 
        !          8460:        show_bgp_ipv4_filter_list_cmd,
        !          8461:        "show bgp ipv4 filter-list WORD",
1.1       misho    8462:        SHOW_STR
1.1.1.4 ! misho    8463:        BGP_STR
1.1       misho    8464:        IP_STR
1.1.1.4 ! misho    8465:        "Display routes conforming to the filter-list\n"
        !          8466:        "Regular expression access list name\n")
        !          8467: {
        !          8468:   return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
        !          8469:                               bgp_show_type_filter_list);
        !          8470: }
        !          8471: 
        !          8472: DEFUN (show_bgp_ipv4_safi_flap_filter_list, 
        !          8473:        show_bgp_ipv4_safi_flap_filter_list_cmd,
        !          8474:        "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
        !          8475:        SHOW_STR
1.1       misho    8476:        BGP_STR
1.1.1.4 ! misho    8477:        IP_STR
1.1       misho    8478:        "Address Family modifier\n"
                   8479:        "Address Family modifier\n"
1.1.1.4 ! misho    8480:        "Address Family modifier\n"
        !          8481:        "Address Family modifier\n"
        !          8482:        "Display flap statistics of routes\n"
        !          8483:        "Display routes conforming to the filter-list\n"
        !          8484:        "Regular expression access list name\n")
        !          8485: {
        !          8486:   safi_t       safi;
        !          8487: 
        !          8488:   if (bgp_parse_safi(argv[0], &safi)) {
        !          8489:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          8490:     return CMD_WARNING;
        !          8491:   }
        !          8492:   return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
        !          8493:                               bgp_show_type_flap_filter_list);
        !          8494: }
        !          8495: 
        !          8496: ALIAS (show_bgp_ipv4_safi_flap_filter_list, 
        !          8497:        show_bgp_ipv4_safi_damp_flap_filter_list_cmd,
        !          8498:        "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
1.1       misho    8499:        SHOW_STR
                   8500:        BGP_STR
1.1.1.4 ! misho    8501:        IP_STR
1.1       misho    8502:        "Address Family modifier\n"
                   8503:        "Address Family modifier\n"
1.1.1.4 ! misho    8504:        "Address Family modifier\n"
        !          8505:        "Address Family modifier\n"
        !          8506:        "Display detailed information about dampening\n"
        !          8507:        "Display flap statistics of routes\n"
        !          8508:        "Display routes conforming to the filter-list\n"
        !          8509:        "Regular expression access list name\n")
1.1       misho    8510: 
1.1.1.4 ! misho    8511: DEFUN (show_bgp_ipv6_safi_flap_filter_list, 
        !          8512:        show_bgp_ipv6_safi_flap_filter_list_cmd,
        !          8513:        "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
1.1       misho    8514:        SHOW_STR
                   8515:        BGP_STR
1.1.1.4 ! misho    8516:        IPV6_STR
        !          8517:        "Address Family modifier\n"
1.1       misho    8518:        "Address Family modifier\n"
                   8519:        "Address Family modifier\n"
1.1.1.4 ! misho    8520:        "Address Family modifier\n"
        !          8521:        "Display flap statistics of routes\n"
        !          8522:        "Display routes conforming to the filter-list\n"
        !          8523:        "Regular expression access list name\n")
1.1       misho    8524: {
1.1.1.4 ! misho    8525:   safi_t       safi;
1.1       misho    8526: 
1.1.1.4 ! misho    8527:   if (bgp_parse_safi(argv[0], &safi)) {
        !          8528:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          8529:     return CMD_WARNING;
        !          8530:   }
        !          8531:   return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi,
        !          8532:                               bgp_show_type_flap_filter_list);
1.1       misho    8533: }
1.1.1.4 ! misho    8534: ALIAS (show_bgp_ipv6_safi_flap_filter_list, 
        !          8535:        show_bgp_ipv6_safi_damp_flap_filter_list_cmd,
        !          8536:        "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
        !          8537:        SHOW_STR
        !          8538:        BGP_STR
        !          8539:        IPV6_STR
        !          8540:        "Address Family modifier\n"
        !          8541:        "Address Family modifier\n"
        !          8542:        "Address Family modifier\n"
        !          8543:        "Address Family modifier\n"
        !          8544:        "Display detailed information about dampening\n"
        !          8545:        "Display flap statistics of routes\n"
        !          8546:        "Display routes conforming to the filter-list\n"
        !          8547:        "Regular expression access list name\n")
1.1       misho    8548: 
1.1.1.4 ! misho    8549: DEFUN (show_bgp_ipv4_safi_filter_list, 
        !          8550:        show_bgp_ipv4_safi_filter_list_cmd,
        !          8551:        "show bgp ipv4 (encap|multicast|unicast|vpn) filter-list WORD",
1.1       misho    8552:        SHOW_STR
                   8553:        BGP_STR
1.1.1.4 ! misho    8554:        "Address Family modifier\n"
        !          8555:        "Address Family modifier\n"
        !          8556:        "Address Family modifier\n"
        !          8557:        "Address Family modifier\n"
        !          8558:        "Display routes conforming to the filter-list\n"
        !          8559:        "Regular expression access list name\n")
1.1       misho    8560: {
1.1.1.4 ! misho    8561:   safi_t       safi;
1.1       misho    8562: 
1.1.1.4 ! misho    8563:   if (bgp_parse_safi(argv[0], &safi)) {
        !          8564:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          8565:     return CMD_WARNING;
        !          8566:   }
        !          8567:   return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
        !          8568:                                 bgp_show_type_filter_list);
1.1       misho    8569: }
                   8570: 
1.1.1.4 ! misho    8571: DEFUN (show_bgp_ipv6_safi_filter_list, 
        !          8572:        show_bgp_ipv6_safi_filter_list_cmd,
        !          8573:        "show bgp ipv6 (encap|multicast|unicast|vpn) filter-list WORD",
1.1       misho    8574:        SHOW_STR
                   8575:        BGP_STR
1.1.1.4 ! misho    8576:        "Address Family modifier\n"
        !          8577:        "Address Family modifier\n"
        !          8578:        "Address Family modifier\n"
        !          8579:        "Address Family modifier\n"
        !          8580:        "Display routes conforming to the filter-list\n"
        !          8581:        "Regular expression access list name\n")
        !          8582: {
        !          8583:   safi_t       safi;
1.1       misho    8584: 
1.1.1.4 ! misho    8585:   if (bgp_parse_safi(argv[0], &safi)) {
        !          8586:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          8587:     return CMD_WARNING;
        !          8588:   }
        !          8589:   return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi,
        !          8590:                                 bgp_show_type_filter_list);
        !          8591: }
        !          8592: 
        !          8593: DEFUN (show_bgp_ipv6_filter_list, 
        !          8594:        show_bgp_ipv6_filter_list_cmd,
        !          8595:        "show bgp ipv6 filter-list WORD",
1.1       misho    8596:        SHOW_STR
                   8597:        BGP_STR
                   8598:        "Address family\n"
1.1.1.4 ! misho    8599:        "Display routes conforming to the filter-list\n"
        !          8600:        "Regular expression access list name\n")
        !          8601: {
        !          8602:   return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
        !          8603:                               bgp_show_type_filter_list);
        !          8604: }
1.1       misho    8605: 
1.1.1.4 ! misho    8606: static int
        !          8607: bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi,
        !          8608:                    safi_t safi, enum bgp_show_type type)
        !          8609: {
        !          8610:   struct route_map *rmap;
        !          8611: 
        !          8612:   rmap = route_map_lookup_by_name (rmap_str);
        !          8613:   if (! rmap)
        !          8614:     {
        !          8615:       vty_out (vty, "%% %s is not a valid route-map name%s",
        !          8616:               rmap_str, VTY_NEWLINE);      
        !          8617:       return CMD_WARNING;
        !          8618:     }
        !          8619: 
        !          8620:   return bgp_show (vty, NULL, afi, safi, type, rmap);
        !          8621: }
        !          8622: 
        !          8623: DEFUN (show_ip_bgp_route_map, 
        !          8624:        show_ip_bgp_route_map_cmd,
        !          8625:        "show ip bgp route-map WORD",
1.1       misho    8626:        SHOW_STR
1.1.1.4 ! misho    8627:        IP_STR
1.1       misho    8628:        BGP_STR
1.1.1.4 ! misho    8629:        "Display routes matching the route-map\n"
        !          8630:        "A route-map to match on\n")
        !          8631: {
        !          8632:   return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
        !          8633:                             bgp_show_type_route_map);
        !          8634: }
1.1       misho    8635: 
1.1.1.4 ! misho    8636: DEFUN (show_ip_bgp_flap_route_map, 
        !          8637:        show_ip_bgp_flap_route_map_cmd,
        !          8638:        "show ip bgp flap-statistics route-map WORD",
1.1       misho    8639:        SHOW_STR
                   8640:        IP_STR
                   8641:        BGP_STR
1.1.1.4 ! misho    8642:        "Display flap statistics of routes\n"
        !          8643:        "Display routes matching the route-map\n"
        !          8644:        "A route-map to match on\n")
1.1       misho    8645: {
1.1.1.4 ! misho    8646:   return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
        !          8647:                             bgp_show_type_flap_route_map);
1.1       misho    8648: }
                   8649: 
1.1.1.4 ! misho    8650: ALIAS (show_ip_bgp_flap_route_map, 
        !          8651:        show_ip_bgp_damp_flap_route_map_cmd,
        !          8652:        "show ip bgp dampening flap-statistics route-map WORD",
1.1       misho    8653:        SHOW_STR
                   8654:        IP_STR
                   8655:        BGP_STR
1.1.1.4 ! misho    8656:        "Display detailed information about dampening\n"
        !          8657:        "Display flap statistics of routes\n"
        !          8658:        "Display routes matching the route-map\n"
        !          8659:        "A route-map to match on\n")
1.1       misho    8660: 
1.1.1.4 ! misho    8661: DEFUN (show_ip_bgp_ipv4_route_map, 
        !          8662:        show_ip_bgp_ipv4_route_map_cmd,
        !          8663:        "show ip bgp ipv4 (unicast|multicast) route-map WORD",
1.1       misho    8664:        SHOW_STR
                   8665:        IP_STR
                   8666:        BGP_STR
1.1.1.4 ! misho    8667:        "Address family\n"
        !          8668:        "Address Family modifier\n"
        !          8669:        "Address Family modifier\n"
        !          8670:        "Display routes matching the route-map\n"
        !          8671:        "A route-map to match on\n")
        !          8672: {
        !          8673:   if (strncmp (argv[0], "m", 1) == 0)
        !          8674:     return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST,
        !          8675:                               bgp_show_type_route_map);
1.1       misho    8676: 
1.1.1.4 ! misho    8677:   return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST,
        !          8678:                             bgp_show_type_route_map);
        !          8679: }
        !          8680: 
        !          8681: DEFUN (show_bgp_route_map, 
        !          8682:        show_bgp_route_map_cmd,
        !          8683:        "show bgp route-map WORD",
        !          8684:        SHOW_STR
        !          8685:        BGP_STR
        !          8686:        "Display routes matching the route-map\n"
        !          8687:        "A route-map to match on\n")
        !          8688: {
        !          8689:   return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
        !          8690:                             bgp_show_type_route_map);
        !          8691: }
        !          8692: 
        !          8693: DEFUN (show_ip_bgp_cidr_only,
        !          8694:        show_ip_bgp_cidr_only_cmd,
        !          8695:        "show ip bgp cidr-only",
1.1       misho    8696:        SHOW_STR
                   8697:        IP_STR
                   8698:        BGP_STR
1.1.1.4 ! misho    8699:        "Display only routes with non-natural netmasks\n")
        !          8700: {
        !          8701:     return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
        !          8702:                     bgp_show_type_cidr_only, NULL);
        !          8703: }
1.1       misho    8704: 
1.1.1.4 ! misho    8705: DEFUN (show_ip_bgp_flap_cidr_only,
        !          8706:        show_ip_bgp_flap_cidr_only_cmd,
        !          8707:        "show ip bgp flap-statistics cidr-only",
        !          8708:        SHOW_STR
        !          8709:        IP_STR
        !          8710:        BGP_STR
        !          8711:        "Display flap statistics of routes\n"
        !          8712:        "Display only routes with non-natural netmasks\n")
        !          8713: {
        !          8714:   return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
        !          8715:                   bgp_show_type_flap_cidr_only, NULL);
        !          8716: }
        !          8717: 
        !          8718: ALIAS (show_ip_bgp_flap_cidr_only,
        !          8719:        show_ip_bgp_damp_flap_cidr_only_cmd,
        !          8720:        "show ip bgp dampening flap-statistics cidr-only",
        !          8721:        SHOW_STR
        !          8722:        IP_STR
        !          8723:        BGP_STR
        !          8724:        "Display detailed information about dampening\n"
        !          8725:        "Display flap statistics of routes\n"
        !          8726:        "Display only routes with non-natural netmasks\n")
        !          8727: 
        !          8728: DEFUN (show_ip_bgp_ipv4_cidr_only,
        !          8729:        show_ip_bgp_ipv4_cidr_only_cmd,
        !          8730:        "show ip bgp ipv4 (unicast|multicast) cidr-only",
1.1       misho    8731:        SHOW_STR
                   8732:        IP_STR
                   8733:        BGP_STR
                   8734:        "Address family\n"
                   8735:        "Address Family modifier\n"
                   8736:        "Address Family modifier\n"
1.1.1.4 ! misho    8737:        "Display only routes with non-natural netmasks\n")
1.1       misho    8738: {
                   8739:   if (strncmp (argv[0], "m", 1) == 0)
1.1.1.4 ! misho    8740:     return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
        !          8741:                     bgp_show_type_cidr_only, NULL);
        !          8742: 
        !          8743:   return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
        !          8744:                     bgp_show_type_cidr_only, NULL);
1.1       misho    8745: }
                   8746: 
1.1.1.4 ! misho    8747: DEFUN (show_ip_bgp_community_all,
        !          8748:        show_ip_bgp_community_all_cmd,
        !          8749:        "show ip bgp community",
1.1       misho    8750:        SHOW_STR
                   8751:        IP_STR
                   8752:        BGP_STR
1.1.1.4 ! misho    8753:        "Display routes matching the communities\n")
        !          8754: {
        !          8755:   return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
        !          8756:                     bgp_show_type_community_all, NULL);
        !          8757: }
1.1       misho    8758: 
1.1.1.4 ! misho    8759: DEFUN (show_ip_bgp_ipv4_community_all,
        !          8760:        show_ip_bgp_ipv4_community_all_cmd,
        !          8761:        "show ip bgp ipv4 (unicast|multicast) community",
1.1       misho    8762:        SHOW_STR
                   8763:        IP_STR
                   8764:        BGP_STR
                   8765:        "Address family\n"
                   8766:        "Address Family modifier\n"
                   8767:        "Address Family modifier\n"
1.1.1.4 ! misho    8768:        "Display routes matching the communities\n")
        !          8769: {
        !          8770:   if (strncmp (argv[0], "m", 1) == 0)
        !          8771:     return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
        !          8772:                     bgp_show_type_community_all, NULL);
        !          8773:  
        !          8774:   return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
        !          8775:                   bgp_show_type_community_all, NULL);
        !          8776: }
1.1       misho    8777: 
1.1.1.4 ! misho    8778: DEFUN (show_bgp_community_all,
        !          8779:        show_bgp_community_all_cmd,
        !          8780:        "show bgp community",
1.1       misho    8781:        SHOW_STR
                   8782:        BGP_STR
1.1.1.4 ! misho    8783:        "Display routes matching the communities\n")
1.1       misho    8784: {
1.1.1.4 ! misho    8785:   return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
        !          8786:                   bgp_show_type_community_all, NULL);
1.1       misho    8787: }
                   8788: 
1.1.1.4 ! misho    8789: ALIAS (show_bgp_community_all,
        !          8790:        show_bgp_ipv6_community_all_cmd,
        !          8791:        "show bgp ipv6 community",
1.1       misho    8792:        SHOW_STR
                   8793:        BGP_STR
                   8794:        "Address family\n"
1.1.1.4 ! misho    8795:        "Display routes matching the communities\n")
1.1       misho    8796: 
1.1.1.4 ! misho    8797: /* old command */
        !          8798: DEFUN (show_ipv6_bgp_community_all,
        !          8799:        show_ipv6_bgp_community_all_cmd,
        !          8800:        "show ipv6 bgp community",
1.1       misho    8801:        SHOW_STR
1.1.1.4 ! misho    8802:        IPV6_STR
1.1       misho    8803:        BGP_STR
1.1.1.4 ! misho    8804:        "Display routes matching the communities\n")
        !          8805: {
        !          8806:   return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
        !          8807:                   bgp_show_type_community_all, NULL);
        !          8808: }
1.1       misho    8809: 
1.1.1.4 ! misho    8810: /* old command */
        !          8811: DEFUN (show_ipv6_mbgp_community_all,
        !          8812:        show_ipv6_mbgp_community_all_cmd,
        !          8813:        "show ipv6 mbgp community",
1.1       misho    8814:        SHOW_STR
1.1.1.4 ! misho    8815:        IPV6_STR
        !          8816:        MBGP_STR
        !          8817:        "Display routes matching the communities\n")
        !          8818: {
        !          8819:   return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST,
        !          8820:                   bgp_show_type_community_all, NULL);
        !          8821: }
1.1       misho    8822: 
1.1.1.4 ! misho    8823: DEFUN (show_bgp_ipv4_route_map, 
        !          8824:        show_bgp_ipv4_route_map_cmd,
        !          8825:        "show bgp ipv4 route-map WORD",
1.1       misho    8826:        SHOW_STR
                   8827:        BGP_STR
1.1.1.4 ! misho    8828:        IP_STR
        !          8829:        "Display routes matching the route-map\n"
        !          8830:        "A route-map to match on\n")
        !          8831: {
        !          8832:   return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
        !          8833:                             bgp_show_type_route_map);
        !          8834: }
1.1       misho    8835: 
1.1.1.4 ! misho    8836: DEFUN (show_bgp_ipv4_safi_flap_route_map, 
        !          8837:        show_bgp_ipv4_safi_flap_route_map_cmd,
        !          8838:        "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
1.1       misho    8839:        SHOW_STR
                   8840:        BGP_STR
1.1.1.4 ! misho    8841:        IP_STR
        !          8842:        "Address Family Modifier\n"
        !          8843:        "Address Family Modifier\n"
        !          8844:        "Address Family Modifier\n"
        !          8845:        "Address Family Modifier\n"
        !          8846:        "Display flap statistics of routes\n"
        !          8847:        "Display routes matching the route-map\n"
        !          8848:        "A route-map to match on\n")
        !          8849: {
        !          8850:   safi_t       safi;
        !          8851:   if (bgp_parse_safi(argv[0], &safi)) {
        !          8852:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          8853:     return CMD_WARNING;
        !          8854:   }
        !          8855:   return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
        !          8856:                             bgp_show_type_flap_route_map);
        !          8857: }
1.1       misho    8858: 
1.1.1.4 ! misho    8859: ALIAS (show_bgp_ipv4_safi_flap_route_map, 
        !          8860:        show_bgp_ipv4_safi_damp_flap_route_map_cmd,
        !          8861:        "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
1.1       misho    8862:        SHOW_STR
                   8863:        BGP_STR
1.1.1.4 ! misho    8864:        IP_STR
        !          8865:        "Address Family Modifier\n"
        !          8866:        "Address Family Modifier\n"
        !          8867:        "Address Family Modifier\n"
        !          8868:        "Address Family Modifier\n"
        !          8869:        "Display detailed information about dampening\n"
        !          8870:        "Display flap statistics of routes\n"
        !          8871:        "Display routes matching the route-map\n"
        !          8872:        "A route-map to match on\n")
1.1       misho    8873: 
1.1.1.4 ! misho    8874: DEFUN (show_bgp_ipv6_safi_flap_route_map, 
        !          8875:        show_bgp_ipv6_safi_flap_route_map_cmd,
        !          8876:        "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
1.1       misho    8877:        SHOW_STR
                   8878:        BGP_STR
1.1.1.4 ! misho    8879:        IPV6_STR
        !          8880:        "Address Family Modifier\n"
        !          8881:        "Address Family Modifier\n"
        !          8882:        "Address Family Modifier\n"
        !          8883:        "Address Family Modifier\n"
        !          8884:        "Display flap statistics of routes\n"
        !          8885:        "Display routes matching the route-map\n"
        !          8886:        "A route-map to match on\n")
1.1       misho    8887: {
1.1.1.4 ! misho    8888:   safi_t       safi;
        !          8889:   if (bgp_parse_safi(argv[0], &safi)) {
        !          8890:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          8891:     return CMD_WARNING;
        !          8892:   }
        !          8893:   return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
        !          8894:                             bgp_show_type_flap_route_map);
1.1       misho    8895: }
1.1.1.4 ! misho    8896: ALIAS (show_bgp_ipv6_safi_flap_route_map, 
        !          8897:        show_bgp_ipv6_safi_damp_flap_route_map_cmd,
        !          8898:        "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
1.1       misho    8899:        SHOW_STR
1.1.1.4 ! misho    8900:        BGP_STR
1.1       misho    8901:        IPV6_STR
1.1.1.4 ! misho    8902:        "Address Family Modifier\n"
        !          8903:        "Address Family Modifier\n"
        !          8904:        "Address Family Modifier\n"
        !          8905:        "Address Family Modifier\n"
        !          8906:        "Display detailed information about dampening\n"
        !          8907:        "Display flap statistics of routes\n"
        !          8908:        "Display routes matching the route-map\n"
        !          8909:        "A route-map to match on\n")
        !          8910: 
        !          8911: DEFUN (show_bgp_ipv4_safi_route_map, 
        !          8912:        show_bgp_ipv4_safi_route_map_cmd,
        !          8913:        "show bgp ipv4 (encap|multicast|unicast|vpn) route-map WORD",
        !          8914:        SHOW_STR
1.1       misho    8915:        BGP_STR
1.1.1.4 ! misho    8916:        "Address family\n"
        !          8917:        "Address Family modifier\n"
        !          8918:        "Address Family modifier\n"
        !          8919:        "Address Family modifier\n"
        !          8920:        "Address Family modifier\n"
        !          8921:        "Display routes matching the route-map\n"
        !          8922:        "A route-map to match on\n")
        !          8923: {
        !          8924:   safi_t       safi;
        !          8925:   if (bgp_parse_safi(argv[0], &safi)) {
        !          8926:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          8927:     return CMD_WARNING;
        !          8928:   }
        !          8929:   return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
        !          8930:                             bgp_show_type_route_map);
        !          8931: }
        !          8932: 
        !          8933: DEFUN (show_bgp_ipv6_safi_route_map, 
        !          8934:        show_bgp_ipv6_safi_route_map_cmd,
        !          8935:        "show bgp ipv6 (encap|multicast|unicast|vpn) route-map WORD",
        !          8936:        SHOW_STR
        !          8937:        BGP_STR
        !          8938:        "Address family\n"
        !          8939:        "Address Family modifier\n"
        !          8940:        "Address Family modifier\n"
        !          8941:        "Address Family modifier\n"
        !          8942:        "Address Family modifier\n"
        !          8943:        "Display routes matching the route-map\n"
        !          8944:        "A route-map to match on\n")
        !          8945: {
        !          8946:   safi_t       safi;
        !          8947:   if (bgp_parse_safi(argv[0], &safi)) {
        !          8948:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          8949:     return CMD_WARNING;
        !          8950:   }
        !          8951:   return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
        !          8952:                             bgp_show_type_route_map);
        !          8953: }
        !          8954: 
        !          8955: DEFUN (show_bgp_ipv6_route_map, 
        !          8956:        show_bgp_ipv6_route_map_cmd,
        !          8957:        "show bgp ipv6 route-map WORD",
        !          8958:        SHOW_STR
        !          8959:        BGP_STR
        !          8960:        "Address family\n"
        !          8961:        "Display routes matching the route-map\n"
        !          8962:        "A route-map to match on\n")
        !          8963: {
        !          8964:   return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
        !          8965:                             bgp_show_type_route_map);
        !          8966: }
        !          8967: 
        !          8968: DEFUN (show_bgp_ipv4_cidr_only,
        !          8969:        show_bgp_ipv4_cidr_only_cmd,
        !          8970:        "show bgp ipv4 cidr-only",
        !          8971:        SHOW_STR
        !          8972:        BGP_STR
        !          8973:        IP_STR
        !          8974:        "Display only routes with non-natural netmasks\n")
        !          8975: {
        !          8976:     return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
        !          8977:                     bgp_show_type_cidr_only, NULL);
        !          8978: }
        !          8979: 
        !          8980: DEFUN (show_bgp_ipv4_safi_flap_cidr_only,
        !          8981:        show_bgp_ipv4_safi_flap_cidr_only_cmd,
        !          8982:        "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics cidr-only",
        !          8983:        SHOW_STR
        !          8984:        BGP_STR
        !          8985:        "Address Family\n"
        !          8986:        "Address Family Modifier\n"
        !          8987:        "Address Family Modifier\n"
        !          8988:        "Address Family Modifier\n"
        !          8989:        "Address Family Modifier\n"
        !          8990:        "Display flap statistics of routes\n"
        !          8991:        "Display only routes with non-natural netmasks\n")
        !          8992: {
        !          8993:   safi_t       safi;
        !          8994: 
        !          8995:   if (bgp_parse_safi(argv[0], &safi)) {
        !          8996:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          8997:     return CMD_WARNING;
        !          8998:   }
        !          8999:   return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_cidr_only, NULL);
        !          9000: }
        !          9001: 
        !          9002: ALIAS (show_bgp_ipv4_safi_flap_cidr_only,
        !          9003:        show_bgp_ipv4_safi_damp_flap_cidr_only_cmd,
        !          9004:        "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics cidr-only",
        !          9005:        SHOW_STR
        !          9006:        BGP_STR
        !          9007:        "Address Family\n"
        !          9008:        "Address Family Modifier\n"
        !          9009:        "Address Family Modifier\n"
        !          9010:        "Address Family Modifier\n"
        !          9011:        "Address Family Modifier\n"
        !          9012:        "Display detailed information about dampening\n"
        !          9013:        "Display flap statistics of routes\n"
        !          9014:        "Display only routes with non-natural netmasks\n")
        !          9015: 
        !          9016: DEFUN (show_bgp_ipv4_safi_cidr_only,
        !          9017:        show_bgp_ipv4_safi_cidr_only_cmd,
        !          9018:        "show bgp ipv4 (unicast|multicast) cidr-only",
        !          9019:        SHOW_STR
        !          9020:        BGP_STR
        !          9021:        "Address family\n"
        !          9022:        "Address Family modifier\n"
        !          9023:        "Address Family modifier\n"
        !          9024:        "Display only routes with non-natural netmasks\n")
        !          9025: {
        !          9026:   if (strncmp (argv[0], "m", 1) == 0)
        !          9027:     return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
        !          9028:                     bgp_show_type_cidr_only, NULL);
        !          9029: 
        !          9030:   return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
        !          9031:                     bgp_show_type_cidr_only, NULL);
        !          9032: }
        !          9033: 
        !          9034: /* new046 */
        !          9035: DEFUN (show_bgp_afi_safi_community_all,
        !          9036:        show_bgp_afi_safi_community_all_cmd,
        !          9037:        "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) community",
        !          9038:        SHOW_STR
        !          9039:        BGP_STR
        !          9040:        "Address family\n"
        !          9041:        "Address family\n"
        !          9042:        "Address Family modifier\n"
        !          9043:        "Address Family modifier\n"
        !          9044:        "Address Family modifier\n"
        !          9045:        "Address Family modifier\n"
        !          9046:        "Display routes matching the communities\n")
        !          9047: {
        !          9048:   safi_t       safi;
        !          9049:   afi_t                afi;
        !          9050: 
        !          9051:   if (bgp_parse_afi(argv[0], &afi)) {
        !          9052:     vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
        !          9053:     return CMD_WARNING;
        !          9054:   }
        !          9055:   if (bgp_parse_safi(argv[1], &safi)) {
        !          9056:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
        !          9057:     return CMD_WARNING;
        !          9058:   }
        !          9059: 
        !          9060:   return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
        !          9061: }
        !          9062: DEFUN (show_bgp_afi_community_all,
        !          9063:        show_bgp_afi_community_all_cmd,
        !          9064:        "show bgp (ipv4|ipv6) community",
        !          9065:        SHOW_STR
        !          9066:        BGP_STR
        !          9067:        "Address family\n"
        !          9068:        "Address family\n"
        !          9069:        "Display routes matching the communities\n")
        !          9070: {
        !          9071:   afi_t                afi;
        !          9072:   safi_t       safi = SAFI_UNICAST;
        !          9073: 
        !          9074:   if (bgp_parse_afi(argv[0], &afi)) {
        !          9075:     vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
        !          9076:     return CMD_WARNING;
        !          9077:   }
        !          9078:   return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
        !          9079: }
        !          9080: 
        !          9081: static int
        !          9082: bgp_show_community (struct vty *vty, const char *view_name, int argc,
        !          9083:                    const char **argv, int exact, afi_t afi, safi_t safi)
        !          9084: {
        !          9085:   struct community *com;
        !          9086:   struct buffer *b;
        !          9087:   struct bgp *bgp;
        !          9088:   int i;
        !          9089:   char *str;
        !          9090:   int first = 0;
        !          9091: 
        !          9092:   /* BGP structure lookup */
        !          9093:   if (view_name)
        !          9094:     {
        !          9095:       bgp = bgp_lookup_by_name (view_name);
        !          9096:       if (bgp == NULL)
        !          9097:        {
        !          9098:          vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
        !          9099:          return CMD_WARNING;
        !          9100:        }
        !          9101:     }
        !          9102:   else
        !          9103:     {
        !          9104:       bgp = bgp_get_default ();
        !          9105:       if (bgp == NULL)
        !          9106:        {
        !          9107:          vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
        !          9108:          return CMD_WARNING;
        !          9109:        }
        !          9110:     }
        !          9111: 
        !          9112:   b = buffer_new (1024);
        !          9113:   for (i = 0; i < argc; i++)
        !          9114:     {
        !          9115:       if (first)
        !          9116:         buffer_putc (b, ' ');
        !          9117:       else
        !          9118:        {
        !          9119:          if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
        !          9120:            continue;
        !          9121:          first = 1;
        !          9122:        }
        !          9123:       
        !          9124:       buffer_putstr (b, argv[i]);
        !          9125:     }
        !          9126:   buffer_putc (b, '\0');
        !          9127: 
        !          9128:   str = buffer_getstr (b);
        !          9129:   buffer_free (b);
        !          9130: 
        !          9131:   com = community_str2com (str);
        !          9132:   XFREE (MTYPE_TMP, str);
        !          9133:   if (! com)
        !          9134:     {
        !          9135:       vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE);
        !          9136:       return CMD_WARNING;
        !          9137:     }
        !          9138: 
        !          9139:   return bgp_show (vty, bgp, afi, safi,
        !          9140:                    (exact ? bgp_show_type_community_exact :
        !          9141:                            bgp_show_type_community), com);
        !          9142: }
        !          9143: 
        !          9144: DEFUN (show_ip_bgp_community,
        !          9145:        show_ip_bgp_community_cmd,
        !          9146:        "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
        !          9147:        SHOW_STR
        !          9148:        IP_STR
        !          9149:        BGP_STR
        !          9150:        "Display routes matching the communities\n"
        !          9151:        "community number\n"
1.1       misho    9152:        "Do not send outside local AS (well-known community)\n"
                   9153:        "Do not advertise to any peer (well-known community)\n"
                   9154:        "Do not export to next AS (well-known community)\n")
1.1.1.4 ! misho    9155: {
        !          9156:   return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
        !          9157: }
1.1       misho    9158: 
1.1.1.4 ! misho    9159: ALIAS (show_ip_bgp_community,
        !          9160:        show_ip_bgp_community2_cmd,
        !          9161:        "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
1.1       misho    9162:        SHOW_STR
1.1.1.4 ! misho    9163:        IP_STR
        !          9164:        BGP_STR
        !          9165:        "Display routes matching the communities\n"
        !          9166:        "community number\n"
        !          9167:        "Do not send outside local AS (well-known community)\n"
        !          9168:        "Do not advertise to any peer (well-known community)\n"
        !          9169:        "Do not export to next AS (well-known community)\n"
        !          9170:        "community number\n"
        !          9171:        "Do not send outside local AS (well-known community)\n"
        !          9172:        "Do not advertise to any peer (well-known community)\n"
        !          9173:        "Do not export to next AS (well-known community)\n")
        !          9174:        
        !          9175: ALIAS (show_ip_bgp_community,
        !          9176:        show_ip_bgp_community3_cmd,
        !          9177:        "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
        !          9178:        SHOW_STR
        !          9179:        IP_STR
1.1       misho    9180:        BGP_STR
                   9181:        "Display routes matching the communities\n"
                   9182:        "community number\n"
                   9183:        "Do not send outside local AS (well-known community)\n"
                   9184:        "Do not advertise to any peer (well-known community)\n"
                   9185:        "Do not export to next AS (well-known community)\n"
                   9186:        "community number\n"
                   9187:        "Do not send outside local AS (well-known community)\n"
                   9188:        "Do not advertise to any peer (well-known community)\n"
                   9189:        "Do not export to next AS (well-known community)\n"
                   9190:        "community number\n"
                   9191:        "Do not send outside local AS (well-known community)\n"
                   9192:        "Do not advertise to any peer (well-known community)\n"
                   9193:        "Do not export to next AS (well-known community)\n")
1.1.1.4 ! misho    9194:        
        !          9195: ALIAS (show_ip_bgp_community,
        !          9196:        show_ip_bgp_community4_cmd,
        !          9197:        "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
1.1       misho    9198:        SHOW_STR
1.1.1.4 ! misho    9199:        IP_STR
1.1       misho    9200:        BGP_STR
                   9201:        "Display routes matching the communities\n"
                   9202:        "community number\n"
                   9203:        "Do not send outside local AS (well-known community)\n"
                   9204:        "Do not advertise to any peer (well-known community)\n"
                   9205:        "Do not export to next AS (well-known community)\n"
                   9206:        "community number\n"
                   9207:        "Do not send outside local AS (well-known community)\n"
                   9208:        "Do not advertise to any peer (well-known community)\n"
                   9209:        "Do not export to next AS (well-known community)\n"
                   9210:        "community number\n"
                   9211:        "Do not send outside local AS (well-known community)\n"
                   9212:        "Do not advertise to any peer (well-known community)\n"
                   9213:        "Do not export to next AS (well-known community)\n"
                   9214:        "community number\n"
                   9215:        "Do not send outside local AS (well-known community)\n"
                   9216:        "Do not advertise to any peer (well-known community)\n"
                   9217:        "Do not export to next AS (well-known community)\n")
                   9218: 
1.1.1.4 ! misho    9219: DEFUN (show_ip_bgp_ipv4_community,
        !          9220:        show_ip_bgp_ipv4_community_cmd,
        !          9221:        "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
1.1       misho    9222:        SHOW_STR
1.1.1.4 ! misho    9223:        IP_STR
1.1       misho    9224:        BGP_STR
1.1.1.4 ! misho    9225:        "Address family\n"
        !          9226:        "Address Family modifier\n"
        !          9227:        "Address Family modifier\n"
1.1       misho    9228:        "Display routes matching the communities\n"
                   9229:        "community number\n"
                   9230:        "Do not send outside local AS (well-known community)\n"
                   9231:        "Do not advertise to any peer (well-known community)\n"
1.1.1.4 ! misho    9232:        "Do not export to next AS (well-known community)\n")
1.1       misho    9233: {
1.1.1.4 ! misho    9234:   if (strncmp (argv[0], "m", 1) == 0)
        !          9235:     return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
        !          9236:  
        !          9237:   return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
1.1       misho    9238: }
                   9239: 
1.1.1.4 ! misho    9240: ALIAS (show_ip_bgp_ipv4_community,
        !          9241:        show_ip_bgp_ipv4_community2_cmd,
        !          9242:        "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
1.1       misho    9243:        SHOW_STR
1.1.1.4 ! misho    9244:        IP_STR
1.1       misho    9245:        BGP_STR
                   9246:        "Address family\n"
1.1.1.4 ! misho    9247:        "Address Family modifier\n"
        !          9248:        "Address Family modifier\n"
1.1       misho    9249:        "Display routes matching the communities\n"
                   9250:        "community number\n"
                   9251:        "Do not send outside local AS (well-known community)\n"
                   9252:        "Do not advertise to any peer (well-known community)\n"
                   9253:        "Do not export to next AS (well-known community)\n"
                   9254:        "community number\n"
                   9255:        "Do not send outside local AS (well-known community)\n"
                   9256:        "Do not advertise to any peer (well-known community)\n"
1.1.1.4 ! misho    9257:        "Do not export to next AS (well-known community)\n")
        !          9258:        
        !          9259: ALIAS (show_ip_bgp_ipv4_community,
        !          9260:        show_ip_bgp_ipv4_community3_cmd,
        !          9261:        "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
1.1       misho    9262:        SHOW_STR
1.1.1.4 ! misho    9263:        IP_STR
1.1       misho    9264:        BGP_STR
                   9265:        "Address family\n"
1.1.1.4 ! misho    9266:        "Address Family modifier\n"
        !          9267:        "Address Family modifier\n"
1.1       misho    9268:        "Display routes matching the communities\n"
                   9269:        "community number\n"
                   9270:        "Do not send outside local AS (well-known community)\n"
                   9271:        "Do not advertise to any peer (well-known community)\n"
                   9272:        "Do not export to next AS (well-known community)\n"
                   9273:        "community number\n"
                   9274:        "Do not send outside local AS (well-known community)\n"
                   9275:        "Do not advertise to any peer (well-known community)\n"
                   9276:        "Do not export to next AS (well-known community)\n"
1.1.1.4 ! misho    9277:        "community number\n"
        !          9278:        "Do not send outside local AS (well-known community)\n"
        !          9279:        "Do not advertise to any peer (well-known community)\n"
        !          9280:        "Do not export to next AS (well-known community)\n")
        !          9281:        
        !          9282: ALIAS (show_ip_bgp_ipv4_community,
        !          9283:        show_ip_bgp_ipv4_community4_cmd,
        !          9284:        "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
1.1       misho    9285:        SHOW_STR
1.1.1.4 ! misho    9286:        IP_STR
1.1       misho    9287:        BGP_STR
1.1.1.4 ! misho    9288:        "Address family\n"
        !          9289:        "Address Family modifier\n"
        !          9290:        "Address Family modifier\n"
1.1       misho    9291:        "Display routes matching the communities\n"
                   9292:        "community number\n"
                   9293:        "Do not send outside local AS (well-known community)\n"
                   9294:        "Do not advertise to any peer (well-known community)\n"
                   9295:        "Do not export to next AS (well-known community)\n"
                   9296:        "community number\n"
                   9297:        "Do not send outside local AS (well-known community)\n"
                   9298:        "Do not advertise to any peer (well-known community)\n"
                   9299:        "Do not export to next AS (well-known community)\n"
                   9300:        "community number\n"
                   9301:        "Do not send outside local AS (well-known community)\n"
                   9302:        "Do not advertise to any peer (well-known community)\n"
                   9303:        "Do not export to next AS (well-known community)\n"
1.1.1.4 ! misho    9304:        "community number\n"
        !          9305:        "Do not send outside local AS (well-known community)\n"
        !          9306:        "Do not advertise to any peer (well-known community)\n"
        !          9307:        "Do not export to next AS (well-known community)\n")
1.1       misho    9308: 
1.1.1.4 ! misho    9309: DEFUN (show_ip_bgp_community_exact,
        !          9310:        show_ip_bgp_community_exact_cmd,
        !          9311:        "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
1.1       misho    9312:        SHOW_STR
1.1.1.4 ! misho    9313:        IP_STR
1.1       misho    9314:        BGP_STR
                   9315:        "Display routes matching the communities\n"
                   9316:        "community number\n"
                   9317:        "Do not send outside local AS (well-known community)\n"
                   9318:        "Do not advertise to any peer (well-known community)\n"
                   9319:        "Do not export to next AS (well-known community)\n"
1.1.1.4 ! misho    9320:        "Exact match of the communities")
        !          9321: {
        !          9322:   return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
        !          9323: }
        !          9324: 
        !          9325: ALIAS (show_ip_bgp_community_exact,
        !          9326:        show_ip_bgp_community2_exact_cmd,
        !          9327:        "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
        !          9328:        SHOW_STR
        !          9329:        IP_STR
        !          9330:        BGP_STR
        !          9331:        "Display routes matching the communities\n"
1.1       misho    9332:        "community number\n"
                   9333:        "Do not send outside local AS (well-known community)\n"
                   9334:        "Do not advertise to any peer (well-known community)\n"
                   9335:        "Do not export to next AS (well-known community)\n"
                   9336:        "community number\n"
                   9337:        "Do not send outside local AS (well-known community)\n"
                   9338:        "Do not advertise to any peer (well-known community)\n"
                   9339:        "Do not export to next AS (well-known community)\n"
                   9340:        "Exact match of the communities")
                   9341: 
1.1.1.4 ! misho    9342: ALIAS (show_ip_bgp_community_exact,
        !          9343:        show_ip_bgp_community3_exact_cmd,
        !          9344:        "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
1.1       misho    9345:        SHOW_STR
1.1.1.4 ! misho    9346:        IP_STR
1.1       misho    9347:        BGP_STR
                   9348:        "Display routes matching the communities\n"
                   9349:        "community number\n"
                   9350:        "Do not send outside local AS (well-known community)\n"
                   9351:        "Do not advertise to any peer (well-known community)\n"
                   9352:        "Do not export to next AS (well-known community)\n"
                   9353:        "community number\n"
                   9354:        "Do not send outside local AS (well-known community)\n"
                   9355:        "Do not advertise to any peer (well-known community)\n"
                   9356:        "Do not export to next AS (well-known community)\n"
                   9357:        "community number\n"
                   9358:        "Do not send outside local AS (well-known community)\n"
                   9359:        "Do not advertise to any peer (well-known community)\n"
                   9360:        "Do not export to next AS (well-known community)\n"
                   9361:        "Exact match of the communities")
1.1.1.4 ! misho    9362: 
        !          9363: ALIAS (show_ip_bgp_community_exact,
        !          9364:        show_ip_bgp_community4_exact_cmd,
        !          9365:        "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
1.1       misho    9366:        SHOW_STR
1.1.1.4 ! misho    9367:        IP_STR
1.1       misho    9368:        BGP_STR
                   9369:        "Display routes matching the communities\n"
                   9370:        "community number\n"
                   9371:        "Do not send outside local AS (well-known community)\n"
                   9372:        "Do not advertise to any peer (well-known community)\n"
                   9373:        "Do not export to next AS (well-known community)\n"
                   9374:        "community number\n"
                   9375:        "Do not send outside local AS (well-known community)\n"
                   9376:        "Do not advertise to any peer (well-known community)\n"
                   9377:        "Do not export to next AS (well-known community)\n"
                   9378:        "community number\n"
                   9379:        "Do not send outside local AS (well-known community)\n"
                   9380:        "Do not advertise to any peer (well-known community)\n"
                   9381:        "Do not export to next AS (well-known community)\n"
                   9382:        "community number\n"
                   9383:        "Do not send outside local AS (well-known community)\n"
                   9384:        "Do not advertise to any peer (well-known community)\n"
                   9385:        "Do not export to next AS (well-known community)\n"
                   9386:        "Exact match of the communities")
                   9387: 
1.1.1.4 ! misho    9388: DEFUN (show_ip_bgp_ipv4_community_exact,
        !          9389:        show_ip_bgp_ipv4_community_exact_cmd,
        !          9390:        "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
1.1       misho    9391:        SHOW_STR
1.1.1.4 ! misho    9392:        IP_STR
1.1       misho    9393:        BGP_STR
1.1.1.4 ! misho    9394:        "Address family\n"
        !          9395:        "Address Family modifier\n"
        !          9396:        "Address Family modifier\n"
1.1       misho    9397:        "Display routes matching the communities\n"
                   9398:        "community number\n"
                   9399:        "Do not send outside local AS (well-known community)\n"
                   9400:        "Do not advertise to any peer (well-known community)\n"
                   9401:        "Do not export to next AS (well-known community)\n"
                   9402:        "Exact match of the communities")
                   9403: {
1.1.1.4 ! misho    9404:   if (strncmp (argv[0], "m", 1) == 0)
        !          9405:     return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
        !          9406:  
        !          9407:   return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
1.1       misho    9408: }
                   9409: 
1.1.1.4 ! misho    9410: ALIAS (show_ip_bgp_ipv4_community_exact,
        !          9411:        show_ip_bgp_ipv4_community2_exact_cmd,
        !          9412:        "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
1.1       misho    9413:        SHOW_STR
1.1.1.4 ! misho    9414:        IP_STR
1.1       misho    9415:        BGP_STR
1.1.1.4 ! misho    9416:        "Address family\n"
        !          9417:        "Address Family modifier\n"
        !          9418:        "Address Family modifier\n"
1.1       misho    9419:        "Display routes matching the communities\n"
                   9420:        "community number\n"
                   9421:        "Do not send outside local AS (well-known community)\n"
                   9422:        "Do not advertise to any peer (well-known community)\n"
                   9423:        "Do not export to next AS (well-known community)\n"
                   9424:        "community number\n"
                   9425:        "Do not send outside local AS (well-known community)\n"
                   9426:        "Do not advertise to any peer (well-known community)\n"
                   9427:        "Do not export to next AS (well-known community)\n"
                   9428:        "Exact match of the communities")
                   9429: 
1.1.1.4 ! misho    9430: ALIAS (show_ip_bgp_ipv4_community_exact,
        !          9431:        show_ip_bgp_ipv4_community3_exact_cmd,
        !          9432:        "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
1.1       misho    9433:        SHOW_STR
1.1.1.4 ! misho    9434:        IP_STR
1.1       misho    9435:        BGP_STR
1.1.1.4 ! misho    9436:        "Address family\n"
        !          9437:        "Address Family modifier\n"
        !          9438:        "Address Family modifier\n"
1.1       misho    9439:        "Display routes matching the communities\n"
                   9440:        "community number\n"
                   9441:        "Do not send outside local AS (well-known community)\n"
                   9442:        "Do not advertise to any peer (well-known community)\n"
                   9443:        "Do not export to next AS (well-known community)\n"
                   9444:        "community number\n"
                   9445:        "Do not send outside local AS (well-known community)\n"
                   9446:        "Do not advertise to any peer (well-known community)\n"
                   9447:        "Do not export to next AS (well-known community)\n"
                   9448:        "community number\n"
                   9449:        "Do not send outside local AS (well-known community)\n"
                   9450:        "Do not advertise to any peer (well-known community)\n"
                   9451:        "Do not export to next AS (well-known community)\n"
                   9452:        "Exact match of the communities")
1.1.1.4 ! misho    9453:        
        !          9454: ALIAS (show_ip_bgp_ipv4_community_exact,
        !          9455:        show_ip_bgp_ipv4_community4_exact_cmd,
        !          9456:        "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
1.1       misho    9457:        SHOW_STR
1.1.1.4 ! misho    9458:        IP_STR
1.1       misho    9459:        BGP_STR
1.1.1.4 ! misho    9460:        "Address family\n"
        !          9461:        "Address Family modifier\n"
        !          9462:        "Address Family modifier\n"
1.1       misho    9463:        "Display routes matching the communities\n"
                   9464:        "community number\n"
                   9465:        "Do not send outside local AS (well-known community)\n"
                   9466:        "Do not advertise to any peer (well-known community)\n"
                   9467:        "Do not export to next AS (well-known community)\n"
                   9468:        "community number\n"
                   9469:        "Do not send outside local AS (well-known community)\n"
                   9470:        "Do not advertise to any peer (well-known community)\n"
                   9471:        "Do not export to next AS (well-known community)\n"
                   9472:        "community number\n"
                   9473:        "Do not send outside local AS (well-known community)\n"
                   9474:        "Do not advertise to any peer (well-known community)\n"
                   9475:        "Do not export to next AS (well-known community)\n"
                   9476:        "community number\n"
                   9477:        "Do not send outside local AS (well-known community)\n"
                   9478:        "Do not advertise to any peer (well-known community)\n"
                   9479:        "Do not export to next AS (well-known community)\n"
                   9480:        "Exact match of the communities")
1.1.1.4 ! misho    9481: 
        !          9482: DEFUN (show_bgp_community,
        !          9483:        show_bgp_community_cmd,
        !          9484:        "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
1.1       misho    9485:        SHOW_STR
1.1.1.4 ! misho    9486:        BGP_STR
1.1       misho    9487:        "Display routes matching the communities\n"
                   9488:        "community number\n"
                   9489:        "Do not send outside local AS (well-known community)\n"
                   9490:        "Do not advertise to any peer (well-known community)\n"
                   9491:        "Do not export to next AS (well-known community)\n")
                   9492: {
1.1.1.4 ! misho    9493:   return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
1.1       misho    9494: }
                   9495: 
1.1.1.4 ! misho    9496: ALIAS (show_bgp_community,
        !          9497:        show_bgp_ipv6_community_cmd,
        !          9498:        "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
1.1       misho    9499:        SHOW_STR
1.1.1.4 ! misho    9500:        BGP_STR
        !          9501:        "Address family\n"
1.1       misho    9502:        "Display routes matching the communities\n"
                   9503:        "community number\n"
                   9504:        "Do not send outside local AS (well-known community)\n"
                   9505:        "Do not advertise to any peer (well-known community)\n"
                   9506:        "Do not export to next AS (well-known community)\n")
                   9507: 
1.1.1.4 ! misho    9508: ALIAS (show_bgp_community,
        !          9509:        show_bgp_community2_cmd,
        !          9510:        "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
1.1       misho    9511:        SHOW_STR
1.1.1.4 ! misho    9512:        BGP_STR
1.1       misho    9513:        "Display routes matching the communities\n"
                   9514:        "community number\n"
                   9515:        "Do not send outside local AS (well-known community)\n"
                   9516:        "Do not advertise to any peer (well-known community)\n"
                   9517:        "Do not export to next AS (well-known community)\n"
                   9518:        "community number\n"
                   9519:        "Do not send outside local AS (well-known community)\n"
                   9520:        "Do not advertise to any peer (well-known community)\n"
                   9521:        "Do not export to next AS (well-known community)\n")
                   9522: 
1.1.1.4 ! misho    9523: ALIAS (show_bgp_community,
        !          9524:        show_bgp_ipv6_community2_cmd,
        !          9525:        "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
1.1       misho    9526:        SHOW_STR
1.1.1.4 ! misho    9527:        BGP_STR
        !          9528:        "Address family\n"
1.1       misho    9529:        "Display routes matching the communities\n"
                   9530:        "community number\n"
                   9531:        "Do not send outside local AS (well-known community)\n"
                   9532:        "Do not advertise to any peer (well-known community)\n"
                   9533:        "Do not export to next AS (well-known community)\n"
                   9534:        "community number\n"
                   9535:        "Do not send outside local AS (well-known community)\n"
                   9536:        "Do not advertise to any peer (well-known community)\n"
1.1.1.4 ! misho    9537:        "Do not export to next AS (well-known community)\n")
        !          9538: 
        !          9539: ALIAS (show_bgp_community,
        !          9540:        show_bgp_community3_cmd,
        !          9541:        "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
        !          9542:        SHOW_STR
        !          9543:        BGP_STR
        !          9544:        "Display routes matching the communities\n"
        !          9545:        "community number\n"
        !          9546:        "Do not send outside local AS (well-known community)\n"
        !          9547:        "Do not advertise to any peer (well-known community)\n"
1.1       misho    9548:        "Do not export to next AS (well-known community)\n"
                   9549:        "community number\n"
                   9550:        "Do not send outside local AS (well-known community)\n"
                   9551:        "Do not advertise to any peer (well-known community)\n"
                   9552:        "Do not export to next AS (well-known community)\n"
                   9553:        "community number\n"
                   9554:        "Do not send outside local AS (well-known community)\n"
                   9555:        "Do not advertise to any peer (well-known community)\n"
                   9556:        "Do not export to next AS (well-known community)\n")
                   9557: 
1.1.1.4 ! misho    9558: ALIAS (show_bgp_community,
        !          9559:        show_bgp_ipv6_community3_cmd,
        !          9560:        "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
1.1       misho    9561:        SHOW_STR
1.1.1.4 ! misho    9562:        BGP_STR
        !          9563:        "Address family\n"
1.1       misho    9564:        "Display routes matching the communities\n"
                   9565:        "community number\n"
                   9566:        "Do not send outside local AS (well-known community)\n"
                   9567:        "Do not advertise to any peer (well-known community)\n"
                   9568:        "Do not export to next AS (well-known community)\n"
                   9569:        "community number\n"
                   9570:        "Do not send outside local AS (well-known community)\n"
                   9571:        "Do not advertise to any peer (well-known community)\n"
                   9572:        "Do not export to next AS (well-known community)\n"
                   9573:        "community number\n"
                   9574:        "Do not send outside local AS (well-known community)\n"
                   9575:        "Do not advertise to any peer (well-known community)\n"
1.1.1.4 ! misho    9576:        "Do not export to next AS (well-known community)\n")
1.1       misho    9577: 
1.1.1.4 ! misho    9578: ALIAS (show_bgp_community,
        !          9579:        show_bgp_community4_cmd,
        !          9580:        "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
1.1       misho    9581:        SHOW_STR
1.1.1.4 ! misho    9582:        BGP_STR
1.1       misho    9583:        "Display routes matching the communities\n"
                   9584:        "community number\n"
                   9585:        "Do not send outside local AS (well-known community)\n"
                   9586:        "Do not advertise to any peer (well-known community)\n"
                   9587:        "Do not export to next AS (well-known community)\n"
                   9588:        "community number\n"
                   9589:        "Do not send outside local AS (well-known community)\n"
                   9590:        "Do not advertise to any peer (well-known community)\n"
                   9591:        "Do not export to next AS (well-known community)\n"
                   9592:        "community number\n"
                   9593:        "Do not send outside local AS (well-known community)\n"
                   9594:        "Do not advertise to any peer (well-known community)\n"
                   9595:        "Do not export to next AS (well-known community)\n"
1.1.1.4 ! misho    9596:        "community number\n"
        !          9597:        "Do not send outside local AS (well-known community)\n"
        !          9598:        "Do not advertise to any peer (well-known community)\n"
        !          9599:        "Do not export to next AS (well-known community)\n")
1.1       misho    9600: 
1.1.1.4 ! misho    9601: ALIAS (show_bgp_community,
        !          9602:        show_bgp_ipv6_community4_cmd,
        !          9603:        "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
1.1       misho    9604:        SHOW_STR
1.1.1.4 ! misho    9605:        BGP_STR
        !          9606:        "Address family\n"
1.1       misho    9607:        "Display routes matching the communities\n"
                   9608:        "community number\n"
                   9609:        "Do not send outside local AS (well-known community)\n"
                   9610:        "Do not advertise to any peer (well-known community)\n"
                   9611:        "Do not export to next AS (well-known community)\n"
                   9612:        "community number\n"
                   9613:        "Do not send outside local AS (well-known community)\n"
                   9614:        "Do not advertise to any peer (well-known community)\n"
                   9615:        "Do not export to next AS (well-known community)\n"
                   9616:        "community number\n"
                   9617:        "Do not send outside local AS (well-known community)\n"
                   9618:        "Do not advertise to any peer (well-known community)\n"
                   9619:        "Do not export to next AS (well-known community)\n"
                   9620:        "community number\n"
                   9621:        "Do not send outside local AS (well-known community)\n"
                   9622:        "Do not advertise to any peer (well-known community)\n"
1.1.1.4 ! misho    9623:        "Do not export to next AS (well-known community)\n")
1.1       misho    9624: 
1.1.1.4 ! misho    9625: /* old command */
        !          9626: DEFUN (show_ipv6_bgp_community,
        !          9627:        show_ipv6_bgp_community_cmd,
        !          9628:        "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
1.1       misho    9629:        SHOW_STR
1.1.1.4 ! misho    9630:        IPV6_STR
1.1       misho    9631:        BGP_STR
1.1.1.4 ! misho    9632:        "Display routes matching the communities\n"
        !          9633:        "community number\n"
        !          9634:        "Do not send outside local AS (well-known community)\n"
        !          9635:        "Do not advertise to any peer (well-known community)\n"
        !          9636:        "Do not export to next AS (well-known community)\n")
1.1       misho    9637: {
1.1.1.4 ! misho    9638:   return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
1.1       misho    9639: }
                   9640: 
1.1.1.4 ! misho    9641: /* old command */
        !          9642: ALIAS (show_ipv6_bgp_community,
        !          9643:        show_ipv6_bgp_community2_cmd,
        !          9644:        "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
1.1       misho    9645:        SHOW_STR
1.1.1.4 ! misho    9646:        IPV6_STR
1.1       misho    9647:        BGP_STR
1.1.1.4 ! misho    9648:        "Display routes matching the communities\n"
        !          9649:        "community number\n"
        !          9650:        "Do not send outside local AS (well-known community)\n"
        !          9651:        "Do not advertise to any peer (well-known community)\n"
        !          9652:        "Do not export to next AS (well-known community)\n"
        !          9653:        "community number\n"
        !          9654:        "Do not send outside local AS (well-known community)\n"
        !          9655:        "Do not advertise to any peer (well-known community)\n"
        !          9656:        "Do not export to next AS (well-known community)\n")
1.1       misho    9657: 
1.1.1.4 ! misho    9658: /* old command */
        !          9659: ALIAS (show_ipv6_bgp_community,
        !          9660:        show_ipv6_bgp_community3_cmd,
        !          9661:        "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
1.1       misho    9662:        SHOW_STR
1.1.1.4 ! misho    9663:        IPV6_STR
1.1       misho    9664:        BGP_STR
1.1.1.4 ! misho    9665:        "Display routes matching the communities\n"
        !          9666:        "community number\n"
        !          9667:        "Do not send outside local AS (well-known community)\n"
        !          9668:        "Do not advertise to any peer (well-known community)\n"
        !          9669:        "Do not export to next AS (well-known community)\n"
        !          9670:        "community number\n"
        !          9671:        "Do not send outside local AS (well-known community)\n"
        !          9672:        "Do not advertise to any peer (well-known community)\n"
        !          9673:        "Do not export to next AS (well-known community)\n"
        !          9674:        "community number\n"
        !          9675:        "Do not send outside local AS (well-known community)\n"
        !          9676:        "Do not advertise to any peer (well-known community)\n"
        !          9677:        "Do not export to next AS (well-known community)\n")
1.1       misho    9678: 
1.1.1.4 ! misho    9679: /* old command */
        !          9680: ALIAS (show_ipv6_bgp_community,
        !          9681:        show_ipv6_bgp_community4_cmd,
        !          9682:        "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
1.1       misho    9683:        SHOW_STR
1.1.1.4 ! misho    9684:        IPV6_STR
1.1       misho    9685:        BGP_STR
1.1.1.4 ! misho    9686:        "Display routes matching the communities\n"
        !          9687:        "community number\n"
        !          9688:        "Do not send outside local AS (well-known community)\n"
        !          9689:        "Do not advertise to any peer (well-known community)\n"
        !          9690:        "Do not export to next AS (well-known community)\n"
        !          9691:        "community number\n"
        !          9692:        "Do not send outside local AS (well-known community)\n"
        !          9693:        "Do not advertise to any peer (well-known community)\n"
        !          9694:        "Do not export to next AS (well-known community)\n"
        !          9695:        "community number\n"
        !          9696:        "Do not send outside local AS (well-known community)\n"
        !          9697:        "Do not advertise to any peer (well-known community)\n"
        !          9698:        "Do not export to next AS (well-known community)\n"
        !          9699:        "community number\n"
        !          9700:        "Do not send outside local AS (well-known community)\n"
        !          9701:        "Do not advertise to any peer (well-known community)\n"
        !          9702:        "Do not export to next AS (well-known community)\n")
1.1       misho    9703: 
1.1.1.4 ! misho    9704: DEFUN (show_bgp_community_exact,
        !          9705:        show_bgp_community_exact_cmd,
        !          9706:        "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
1.1       misho    9707:        SHOW_STR
                   9708:        BGP_STR
1.1.1.4 ! misho    9709:        "Display routes matching the communities\n"
        !          9710:        "community number\n"
        !          9711:        "Do not send outside local AS (well-known community)\n"
        !          9712:        "Do not advertise to any peer (well-known community)\n"
        !          9713:        "Do not export to next AS (well-known community)\n"
        !          9714:        "Exact match of the communities")
1.1       misho    9715: {
1.1.1.4 ! misho    9716:   return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
1.1       misho    9717: }
                   9718: 
1.1.1.4 ! misho    9719: ALIAS (show_bgp_community_exact,
        !          9720:        show_bgp_ipv6_community_exact_cmd,
        !          9721:        "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
1.1       misho    9722:        SHOW_STR
                   9723:        BGP_STR
                   9724:        "Address family\n"
1.1.1.4 ! misho    9725:        "Display routes matching the communities\n"
        !          9726:        "community number\n"
        !          9727:        "Do not send outside local AS (well-known community)\n"
        !          9728:        "Do not advertise to any peer (well-known community)\n"
        !          9729:        "Do not export to next AS (well-known community)\n"
        !          9730:        "Exact match of the communities")
1.1       misho    9731: 
1.1.1.4 ! misho    9732: ALIAS (show_bgp_community_exact,
        !          9733:        show_bgp_community2_exact_cmd,
        !          9734:        "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
1.1       misho    9735:        SHOW_STR
                   9736:        BGP_STR
1.1.1.4 ! misho    9737:        "Display routes matching the communities\n"
        !          9738:        "community number\n"
        !          9739:        "Do not send outside local AS (well-known community)\n"
        !          9740:        "Do not advertise to any peer (well-known community)\n"
        !          9741:        "Do not export to next AS (well-known community)\n"
        !          9742:        "community number\n"
        !          9743:        "Do not send outside local AS (well-known community)\n"
        !          9744:        "Do not advertise to any peer (well-known community)\n"
        !          9745:        "Do not export to next AS (well-known community)\n"
        !          9746:        "Exact match of the communities")
1.1       misho    9747: 
1.1.1.4 ! misho    9748: ALIAS (show_bgp_community_exact,
        !          9749:        show_bgp_ipv6_community2_exact_cmd,
        !          9750:        "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
1.1       misho    9751:        SHOW_STR
1.1.1.4 ! misho    9752:        BGP_STR
        !          9753:        "Address family\n"
        !          9754:        "Display routes matching the communities\n"
        !          9755:        "community number\n"
        !          9756:        "Do not send outside local AS (well-known community)\n"
        !          9757:        "Do not advertise to any peer (well-known community)\n"
        !          9758:        "Do not export to next AS (well-known community)\n"
        !          9759:        "community number\n"
        !          9760:        "Do not send outside local AS (well-known community)\n"
        !          9761:        "Do not advertise to any peer (well-known community)\n"
        !          9762:        "Do not export to next AS (well-known community)\n"
        !          9763:        "Exact match of the communities")
1.1       misho    9764: 
1.1.1.4 ! misho    9765: ALIAS (show_bgp_community_exact,
        !          9766:        show_bgp_community3_exact_cmd,
        !          9767:        "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
1.1       misho    9768:        SHOW_STR
                   9769:        BGP_STR
1.1.1.4 ! misho    9770:        "Display routes matching the communities\n"
        !          9771:        "community number\n"
        !          9772:        "Do not send outside local AS (well-known community)\n"
        !          9773:        "Do not advertise to any peer (well-known community)\n"
        !          9774:        "Do not export to next AS (well-known community)\n"
        !          9775:        "community number\n"
        !          9776:        "Do not send outside local AS (well-known community)\n"
        !          9777:        "Do not advertise to any peer (well-known community)\n"
        !          9778:        "Do not export to next AS (well-known community)\n"
        !          9779:        "community number\n"
        !          9780:        "Do not send outside local AS (well-known community)\n"
        !          9781:        "Do not advertise to any peer (well-known community)\n"
        !          9782:        "Do not export to next AS (well-known community)\n"
        !          9783:        "Exact match of the communities")
1.1       misho    9784: 
1.1.1.4 ! misho    9785: ALIAS (show_bgp_community_exact,
        !          9786:        show_bgp_ipv6_community3_exact_cmd,
        !          9787:        "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
1.1       misho    9788:        SHOW_STR
                   9789:        BGP_STR
                   9790:        "Address family\n"
1.1.1.4 ! misho    9791:        "Display routes matching the communities\n"
        !          9792:        "community number\n"
        !          9793:        "Do not send outside local AS (well-known community)\n"
        !          9794:        "Do not advertise to any peer (well-known community)\n"
        !          9795:        "Do not export to next AS (well-known community)\n"
        !          9796:        "community number\n"
        !          9797:        "Do not send outside local AS (well-known community)\n"
        !          9798:        "Do not advertise to any peer (well-known community)\n"
        !          9799:        "Do not export to next AS (well-known community)\n"
        !          9800:        "community number\n"
        !          9801:        "Do not send outside local AS (well-known community)\n"
        !          9802:        "Do not advertise to any peer (well-known community)\n"
        !          9803:        "Do not export to next AS (well-known community)\n"
        !          9804:        "Exact match of the communities")
1.1       misho    9805: 
1.1.1.4 ! misho    9806: ALIAS (show_bgp_community_exact,
        !          9807:        show_bgp_community4_exact_cmd,
        !          9808:        "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
1.1       misho    9809:        SHOW_STR
                   9810:        BGP_STR
1.1.1.4 ! misho    9811:        "Display routes matching the communities\n"
        !          9812:        "community number\n"
        !          9813:        "Do not send outside local AS (well-known community)\n"
        !          9814:        "Do not advertise to any peer (well-known community)\n"
        !          9815:        "Do not export to next AS (well-known community)\n"
        !          9816:        "community number\n"
        !          9817:        "Do not send outside local AS (well-known community)\n"
        !          9818:        "Do not advertise to any peer (well-known community)\n"
        !          9819:        "Do not export to next AS (well-known community)\n"
        !          9820:        "community number\n"
        !          9821:        "Do not send outside local AS (well-known community)\n"
        !          9822:        "Do not advertise to any peer (well-known community)\n"
        !          9823:        "Do not export to next AS (well-known community)\n"
        !          9824:        "community number\n"
        !          9825:        "Do not send outside local AS (well-known community)\n"
        !          9826:        "Do not advertise to any peer (well-known community)\n"
        !          9827:        "Do not export to next AS (well-known community)\n"
        !          9828:        "Exact match of the communities")
1.1       misho    9829: 
1.1.1.4 ! misho    9830: ALIAS (show_bgp_community_exact,
        !          9831:        show_bgp_ipv6_community4_exact_cmd,
        !          9832:        "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
1.1       misho    9833:        SHOW_STR
                   9834:        BGP_STR
                   9835:        "Address family\n"
1.1.1.4 ! misho    9836:        "Display routes matching the communities\n"
        !          9837:        "community number\n"
        !          9838:        "Do not send outside local AS (well-known community)\n"
        !          9839:        "Do not advertise to any peer (well-known community)\n"
        !          9840:        "Do not export to next AS (well-known community)\n"
        !          9841:        "community number\n"
        !          9842:        "Do not send outside local AS (well-known community)\n"
        !          9843:        "Do not advertise to any peer (well-known community)\n"
        !          9844:        "Do not export to next AS (well-known community)\n"
        !          9845:        "community number\n"
        !          9846:        "Do not send outside local AS (well-known community)\n"
        !          9847:        "Do not advertise to any peer (well-known community)\n"
        !          9848:        "Do not export to next AS (well-known community)\n"
        !          9849:        "community number\n"
        !          9850:        "Do not send outside local AS (well-known community)\n"
        !          9851:        "Do not advertise to any peer (well-known community)\n"
        !          9852:        "Do not export to next AS (well-known community)\n"
        !          9853:        "Exact match of the communities")
1.1       misho    9854: 
1.1.1.4 ! misho    9855: /* old command */
        !          9856: DEFUN (show_ipv6_bgp_community_exact,
        !          9857:        show_ipv6_bgp_community_exact_cmd,
        !          9858:        "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
1.1       misho    9859:        SHOW_STR
1.1.1.4 ! misho    9860:        IPV6_STR
1.1       misho    9861:        BGP_STR
1.1.1.4 ! misho    9862:        "Display routes matching the communities\n"
        !          9863:        "community number\n"
        !          9864:        "Do not send outside local AS (well-known community)\n"
        !          9865:        "Do not advertise to any peer (well-known community)\n"
        !          9866:        "Do not export to next AS (well-known community)\n"
        !          9867:        "Exact match of the communities")
1.1       misho    9868: {
1.1.1.4 ! misho    9869:   return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
1.1       misho    9870: }
                   9871: 
1.1.1.4 ! misho    9872: /* old command */
        !          9873: ALIAS (show_ipv6_bgp_community_exact,
        !          9874:        show_ipv6_bgp_community2_exact_cmd,
        !          9875:        "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
1.1       misho    9876:        SHOW_STR
1.1.1.4 ! misho    9877:        IPV6_STR
1.1       misho    9878:        BGP_STR
1.1.1.4 ! misho    9879:        "Display routes matching the communities\n"
        !          9880:        "community number\n"
        !          9881:        "Do not send outside local AS (well-known community)\n"
        !          9882:        "Do not advertise to any peer (well-known community)\n"
        !          9883:        "Do not export to next AS (well-known community)\n"
        !          9884:        "community number\n"
        !          9885:        "Do not send outside local AS (well-known community)\n"
        !          9886:        "Do not advertise to any peer (well-known community)\n"
        !          9887:        "Do not export to next AS (well-known community)\n"
        !          9888:        "Exact match of the communities")
1.1       misho    9889: 
1.1.1.4 ! misho    9890: /* old command */
        !          9891: ALIAS (show_ipv6_bgp_community_exact,
        !          9892:        show_ipv6_bgp_community3_exact_cmd,
        !          9893:        "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
1.1       misho    9894:        SHOW_STR
1.1.1.4 ! misho    9895:        IPV6_STR
1.1       misho    9896:        BGP_STR
1.1.1.4 ! misho    9897:        "Display routes matching the communities\n"
        !          9898:        "community number\n"
        !          9899:        "Do not send outside local AS (well-known community)\n"
        !          9900:        "Do not advertise to any peer (well-known community)\n"
        !          9901:        "Do not export to next AS (well-known community)\n"
        !          9902:        "community number\n"
        !          9903:        "Do not send outside local AS (well-known community)\n"
        !          9904:        "Do not advertise to any peer (well-known community)\n"
        !          9905:        "Do not export to next AS (well-known community)\n"
        !          9906:        "community number\n"
        !          9907:        "Do not send outside local AS (well-known community)\n"
        !          9908:        "Do not advertise to any peer (well-known community)\n"
        !          9909:        "Do not export to next AS (well-known community)\n"
        !          9910:        "Exact match of the communities")
1.1       misho    9911: 
                   9912: /* old command */
1.1.1.4 ! misho    9913: ALIAS (show_ipv6_bgp_community_exact,
        !          9914:        show_ipv6_bgp_community4_exact_cmd,
        !          9915:        "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
1.1       misho    9916:        SHOW_STR
                   9917:        IPV6_STR
                   9918:        BGP_STR
1.1.1.4 ! misho    9919:        "Display routes matching the communities\n"
        !          9920:        "community number\n"
        !          9921:        "Do not send outside local AS (well-known community)\n"
        !          9922:        "Do not advertise to any peer (well-known community)\n"
        !          9923:        "Do not export to next AS (well-known community)\n"
        !          9924:        "community number\n"
        !          9925:        "Do not send outside local AS (well-known community)\n"
        !          9926:        "Do not advertise to any peer (well-known community)\n"
        !          9927:        "Do not export to next AS (well-known community)\n"
        !          9928:        "community number\n"
        !          9929:        "Do not send outside local AS (well-known community)\n"
        !          9930:        "Do not advertise to any peer (well-known community)\n"
        !          9931:        "Do not export to next AS (well-known community)\n"
        !          9932:        "community number\n"
        !          9933:        "Do not send outside local AS (well-known community)\n"
        !          9934:        "Do not advertise to any peer (well-known community)\n"
        !          9935:        "Do not export to next AS (well-known community)\n"
        !          9936:        "Exact match of the communities")
        !          9937:  
1.1       misho    9938: /* old command */
1.1.1.4 ! misho    9939: DEFUN (show_ipv6_mbgp_community,
        !          9940:        show_ipv6_mbgp_community_cmd,
        !          9941:        "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
1.1       misho    9942:        SHOW_STR
                   9943:        IPV6_STR
                   9944:        MBGP_STR
1.1.1.4 ! misho    9945:        "Display routes matching the communities\n"
        !          9946:        "community number\n"
        !          9947:        "Do not send outside local AS (well-known community)\n"
        !          9948:        "Do not advertise to any peer (well-known community)\n"
        !          9949:        "Do not export to next AS (well-known community)\n")
        !          9950: {
        !          9951:   return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST);
        !          9952: }
        !          9953: 
        !          9954: /* old command */
        !          9955: ALIAS (show_ipv6_mbgp_community,
        !          9956:        show_ipv6_mbgp_community2_cmd,
        !          9957:        "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
        !          9958:        SHOW_STR
        !          9959:        IPV6_STR
        !          9960:        MBGP_STR
        !          9961:        "Display routes matching the communities\n"
        !          9962:        "community number\n"
        !          9963:        "Do not send outside local AS (well-known community)\n"
        !          9964:        "Do not advertise to any peer (well-known community)\n"
        !          9965:        "Do not export to next AS (well-known community)\n"
        !          9966:        "community number\n"
        !          9967:        "Do not send outside local AS (well-known community)\n"
        !          9968:        "Do not advertise to any peer (well-known community)\n"
        !          9969:        "Do not export to next AS (well-known community)\n")
        !          9970: 
        !          9971: /* old command */
        !          9972: ALIAS (show_ipv6_mbgp_community,
        !          9973:        show_ipv6_mbgp_community3_cmd,
        !          9974:        "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
        !          9975:        SHOW_STR
        !          9976:        IPV6_STR
        !          9977:        MBGP_STR
        !          9978:        "Display routes matching the communities\n"
        !          9979:        "community number\n"
        !          9980:        "Do not send outside local AS (well-known community)\n"
        !          9981:        "Do not advertise to any peer (well-known community)\n"
        !          9982:        "Do not export to next AS (well-known community)\n"
        !          9983:        "community number\n"
        !          9984:        "Do not send outside local AS (well-known community)\n"
        !          9985:        "Do not advertise to any peer (well-known community)\n"
        !          9986:        "Do not export to next AS (well-known community)\n"
        !          9987:        "community number\n"
        !          9988:        "Do not send outside local AS (well-known community)\n"
        !          9989:        "Do not advertise to any peer (well-known community)\n"
        !          9990:        "Do not export to next AS (well-known community)\n")
        !          9991: 
        !          9992: /* old command */
        !          9993: ALIAS (show_ipv6_mbgp_community,
        !          9994:        show_ipv6_mbgp_community4_cmd,
        !          9995:        "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
        !          9996:        SHOW_STR
        !          9997:        IPV6_STR
        !          9998:        MBGP_STR
        !          9999:        "Display routes matching the communities\n"
        !          10000:        "community number\n"
        !          10001:        "Do not send outside local AS (well-known community)\n"
        !          10002:        "Do not advertise to any peer (well-known community)\n"
        !          10003:        "Do not export to next AS (well-known community)\n"
        !          10004:        "community number\n"
        !          10005:        "Do not send outside local AS (well-known community)\n"
        !          10006:        "Do not advertise to any peer (well-known community)\n"
        !          10007:        "Do not export to next AS (well-known community)\n"
        !          10008:        "community number\n"
        !          10009:        "Do not send outside local AS (well-known community)\n"
        !          10010:        "Do not advertise to any peer (well-known community)\n"
        !          10011:        "Do not export to next AS (well-known community)\n"
        !          10012:        "community number\n"
        !          10013:        "Do not send outside local AS (well-known community)\n"
        !          10014:        "Do not advertise to any peer (well-known community)\n"
        !          10015:        "Do not export to next AS (well-known community)\n")
        !          10016: 
        !          10017: /* old command */
        !          10018: DEFUN (show_ipv6_mbgp_community_exact,
        !          10019:        show_ipv6_mbgp_community_exact_cmd,
        !          10020:        "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
        !          10021:        SHOW_STR
        !          10022:        IPV6_STR
        !          10023:        MBGP_STR
        !          10024:        "Display routes matching the communities\n"
        !          10025:        "community number\n"
        !          10026:        "Do not send outside local AS (well-known community)\n"
        !          10027:        "Do not advertise to any peer (well-known community)\n"
        !          10028:        "Do not export to next AS (well-known community)\n"
        !          10029:        "Exact match of the communities")
        !          10030: {
        !          10031:   return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST);
        !          10032: }
        !          10033: 
        !          10034: /* old command */
        !          10035: ALIAS (show_ipv6_mbgp_community_exact,
        !          10036:        show_ipv6_mbgp_community2_exact_cmd,
        !          10037:        "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
        !          10038:        SHOW_STR
        !          10039:        IPV6_STR
        !          10040:        MBGP_STR
        !          10041:        "Display routes matching the communities\n"
        !          10042:        "community number\n"
        !          10043:        "Do not send outside local AS (well-known community)\n"
        !          10044:        "Do not advertise to any peer (well-known community)\n"
        !          10045:        "Do not export to next AS (well-known community)\n"
        !          10046:        "community number\n"
        !          10047:        "Do not send outside local AS (well-known community)\n"
        !          10048:        "Do not advertise to any peer (well-known community)\n"
        !          10049:        "Do not export to next AS (well-known community)\n"
        !          10050:        "Exact match of the communities")
        !          10051: 
        !          10052: /* old command */
        !          10053: ALIAS (show_ipv6_mbgp_community_exact,
        !          10054:        show_ipv6_mbgp_community3_exact_cmd,
        !          10055:        "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
        !          10056:        SHOW_STR
        !          10057:        IPV6_STR
        !          10058:        MBGP_STR
        !          10059:        "Display routes matching the communities\n"
        !          10060:        "community number\n"
        !          10061:        "Do not send outside local AS (well-known community)\n"
        !          10062:        "Do not advertise to any peer (well-known community)\n"
        !          10063:        "Do not export to next AS (well-known community)\n"
        !          10064:        "community number\n"
        !          10065:        "Do not send outside local AS (well-known community)\n"
        !          10066:        "Do not advertise to any peer (well-known community)\n"
        !          10067:        "Do not export to next AS (well-known community)\n"
        !          10068:        "community number\n"
        !          10069:        "Do not send outside local AS (well-known community)\n"
        !          10070:        "Do not advertise to any peer (well-known community)\n"
        !          10071:        "Do not export to next AS (well-known community)\n"
        !          10072:        "Exact match of the communities")
        !          10073: 
        !          10074: /* old command */
        !          10075: ALIAS (show_ipv6_mbgp_community_exact,
        !          10076:        show_ipv6_mbgp_community4_exact_cmd,
        !          10077:        "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
        !          10078:        SHOW_STR
        !          10079:        IPV6_STR
        !          10080:        MBGP_STR
        !          10081:        "Display routes matching the communities\n"
        !          10082:        "community number\n"
        !          10083:        "Do not send outside local AS (well-known community)\n"
        !          10084:        "Do not advertise to any peer (well-known community)\n"
        !          10085:        "Do not export to next AS (well-known community)\n"
        !          10086:        "community number\n"
        !          10087:        "Do not send outside local AS (well-known community)\n"
        !          10088:        "Do not advertise to any peer (well-known community)\n"
        !          10089:        "Do not export to next AS (well-known community)\n"
        !          10090:        "community number\n"
        !          10091:        "Do not send outside local AS (well-known community)\n"
        !          10092:        "Do not advertise to any peer (well-known community)\n"
        !          10093:        "Do not export to next AS (well-known community)\n"
        !          10094:        "community number\n"
        !          10095:        "Do not send outside local AS (well-known community)\n"
        !          10096:        "Do not advertise to any peer (well-known community)\n"
        !          10097:        "Do not export to next AS (well-known community)\n"
        !          10098:        "Exact match of the communities")
        !          10099: 
        !          10100: DEFUN (show_bgp_ipv4_community,
        !          10101:        show_bgp_ipv4_community_cmd,
        !          10102:        "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export)",
        !          10103:        SHOW_STR
        !          10104:        BGP_STR
        !          10105:        IP_STR
        !          10106:        "Display routes matching the communities\n"
        !          10107:        "community number\n"
        !          10108:        "Do not send outside local AS (well-known community)\n"
        !          10109:        "Do not advertise to any peer (well-known community)\n"
        !          10110:        "Do not export to next AS (well-known community)\n")
        !          10111: {
        !          10112:   return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
        !          10113: }
        !          10114: 
        !          10115: ALIAS (show_bgp_ipv4_community,
        !          10116:        show_bgp_ipv4_community2_cmd,
        !          10117:        "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
        !          10118:        SHOW_STR
        !          10119:        BGP_STR
        !          10120:        IP_STR
        !          10121:        "Display routes matching the communities\n"
        !          10122:        "community number\n"
        !          10123:        "Do not send outside local AS (well-known community)\n"
        !          10124:        "Do not advertise to any peer (well-known community)\n"
        !          10125:        "Do not export to next AS (well-known community)\n"
        !          10126:        "community number\n"
        !          10127:        "Do not send outside local AS (well-known community)\n"
        !          10128:        "Do not advertise to any peer (well-known community)\n"
        !          10129:        "Do not export to next AS (well-known community)\n")
        !          10130:        
        !          10131: ALIAS (show_bgp_ipv4_community,
        !          10132:        show_bgp_ipv4_community3_cmd,
        !          10133:        "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
        !          10134:        SHOW_STR
        !          10135:        BGP_STR
        !          10136:        IP_STR
        !          10137:        "Display routes matching the communities\n"
        !          10138:        "community number\n"
        !          10139:        "Do not send outside local AS (well-known community)\n"
        !          10140:        "Do not advertise to any peer (well-known community)\n"
        !          10141:        "Do not export to next AS (well-known community)\n"
        !          10142:        "community number\n"
        !          10143:        "Do not send outside local AS (well-known community)\n"
        !          10144:        "Do not advertise to any peer (well-known community)\n"
        !          10145:        "Do not export to next AS (well-known community)\n"
        !          10146:        "community number\n"
        !          10147:        "Do not send outside local AS (well-known community)\n"
        !          10148:        "Do not advertise to any peer (well-known community)\n"
        !          10149:        "Do not export to next AS (well-known community)\n")
        !          10150:        
        !          10151: ALIAS (show_bgp_ipv4_community,
        !          10152:        show_bgp_ipv4_community4_cmd,
        !          10153:        "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
        !          10154:        SHOW_STR
        !          10155:        BGP_STR
        !          10156:        IP_STR
        !          10157:        "Display routes matching the communities\n"
        !          10158:        "community number\n"
        !          10159:        "Do not send outside local AS (well-known community)\n"
        !          10160:        "Do not advertise to any peer (well-known community)\n"
        !          10161:        "Do not export to next AS (well-known community)\n"
        !          10162:        "community number\n"
        !          10163:        "Do not send outside local AS (well-known community)\n"
        !          10164:        "Do not advertise to any peer (well-known community)\n"
        !          10165:        "Do not export to next AS (well-known community)\n"
        !          10166:        "community number\n"
        !          10167:        "Do not send outside local AS (well-known community)\n"
        !          10168:        "Do not advertise to any peer (well-known community)\n"
        !          10169:        "Do not export to next AS (well-known community)\n"
        !          10170:        "community number\n"
        !          10171:        "Do not send outside local AS (well-known community)\n"
        !          10172:        "Do not advertise to any peer (well-known community)\n"
        !          10173:        "Do not export to next AS (well-known community)\n")
        !          10174: 
        !          10175: DEFUN (show_bgp_ipv4_safi_community,
        !          10176:        show_bgp_ipv4_safi_community_cmd,
        !          10177:        "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
        !          10178:        SHOW_STR
        !          10179:        BGP_STR
        !          10180:        "Address family\n"
        !          10181:        "Address Family modifier\n"
        !          10182:        "Address Family modifier\n"
        !          10183:        "Display routes matching the communities\n"
        !          10184:        "community number\n"
        !          10185:        "Do not send outside local AS (well-known community)\n"
        !          10186:        "Do not advertise to any peer (well-known community)\n"
        !          10187:        "Do not export to next AS (well-known community)\n")
        !          10188: {
        !          10189:   if (strncmp (argv[0], "m", 1) == 0)
        !          10190:     return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
        !          10191:  
        !          10192:   return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
        !          10193: }
        !          10194: 
        !          10195: ALIAS (show_bgp_ipv4_safi_community,
        !          10196:        show_bgp_ipv4_safi_community2_cmd,
        !          10197:        "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
        !          10198:        SHOW_STR
        !          10199:        BGP_STR
        !          10200:        "Address family\n"
        !          10201:        "Address Family modifier\n"
        !          10202:        "Address Family modifier\n"
        !          10203:        "Display routes matching the communities\n"
        !          10204:        "community number\n"
        !          10205:        "Do not send outside local AS (well-known community)\n"
        !          10206:        "Do not advertise to any peer (well-known community)\n"
        !          10207:        "Do not export to next AS (well-known community)\n"
        !          10208:        "community number\n"
        !          10209:        "Do not send outside local AS (well-known community)\n"
        !          10210:        "Do not advertise to any peer (well-known community)\n"
        !          10211:        "Do not export to next AS (well-known community)\n")
        !          10212:        
        !          10213: ALIAS (show_bgp_ipv4_safi_community,
        !          10214:        show_bgp_ipv4_safi_community3_cmd,
        !          10215:        "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
        !          10216:        SHOW_STR
        !          10217:        BGP_STR
        !          10218:        "Address family\n"
        !          10219:        "Address Family modifier\n"
        !          10220:        "Address Family modifier\n"
        !          10221:        "Display routes matching the communities\n"
        !          10222:        "community number\n"
        !          10223:        "Do not send outside local AS (well-known community)\n"
        !          10224:        "Do not advertise to any peer (well-known community)\n"
        !          10225:        "Do not export to next AS (well-known community)\n"
        !          10226:        "community number\n"
        !          10227:        "Do not send outside local AS (well-known community)\n"
        !          10228:        "Do not advertise to any peer (well-known community)\n"
        !          10229:        "Do not export to next AS (well-known community)\n"
        !          10230:        "community number\n"
        !          10231:        "Do not send outside local AS (well-known community)\n"
        !          10232:        "Do not advertise to any peer (well-known community)\n"
        !          10233:        "Do not export to next AS (well-known community)\n")
        !          10234:        
        !          10235: ALIAS (show_bgp_ipv4_safi_community,
        !          10236:        show_bgp_ipv4_safi_community4_cmd,
        !          10237:        "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
        !          10238:        SHOW_STR
        !          10239:        BGP_STR
        !          10240:        "Address family\n"
        !          10241:        "Address Family modifier\n"
        !          10242:        "Address Family modifier\n"
        !          10243:        "Display routes matching the communities\n"
        !          10244:        "community number\n"
        !          10245:        "Do not send outside local AS (well-known community)\n"
        !          10246:        "Do not advertise to any peer (well-known community)\n"
        !          10247:        "Do not export to next AS (well-known community)\n"
        !          10248:        "community number\n"
        !          10249:        "Do not send outside local AS (well-known community)\n"
        !          10250:        "Do not advertise to any peer (well-known community)\n"
        !          10251:        "Do not export to next AS (well-known community)\n"
        !          10252:        "community number\n"
        !          10253:        "Do not send outside local AS (well-known community)\n"
        !          10254:        "Do not advertise to any peer (well-known community)\n"
        !          10255:        "Do not export to next AS (well-known community)\n"
        !          10256:        "community number\n"
        !          10257:        "Do not send outside local AS (well-known community)\n"
        !          10258:        "Do not advertise to any peer (well-known community)\n"
        !          10259:        "Do not export to next AS (well-known community)\n")
        !          10260: 
        !          10261: DEFUN (show_bgp_view_afi_safi_community_all,
        !          10262:        show_bgp_view_afi_safi_community_all_cmd,
        !          10263:        "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community",
        !          10264:        SHOW_STR
        !          10265:        BGP_STR
        !          10266:        "BGP view\n"
        !          10267:        "View name\n"
        !          10268:        "Address family\n"
        !          10269:        "Address family\n"
        !          10270:        "Address Family modifier\n"
        !          10271:        "Address Family modifier\n"
        !          10272:        "Display routes matching the communities\n")
        !          10273: {
        !          10274:   int afi;
        !          10275:   int safi;
        !          10276:   struct bgp *bgp;
        !          10277: 
        !          10278:   /* BGP structure lookup. */
        !          10279:   bgp = bgp_lookup_by_name (argv[0]);
        !          10280:   if (bgp == NULL)
        !          10281:     {
        !          10282:       vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
        !          10283:       return CMD_WARNING;
        !          10284:     }
        !          10285: 
        !          10286:   afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
        !          10287:   safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
        !          10288:   return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL);
        !          10289: }
        !          10290: 
        !          10291: DEFUN (show_bgp_view_afi_safi_community,
        !          10292:        show_bgp_view_afi_safi_community_cmd,
        !          10293:        "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
        !          10294:        SHOW_STR
        !          10295:        BGP_STR
        !          10296:        "BGP view\n"
        !          10297:        "View name\n"
        !          10298:        "Address family\n"
        !          10299:        "Address family\n"
        !          10300:        "Address family modifier\n"
        !          10301:        "Address family modifier\n"
        !          10302:        "Display routes matching the communities\n"
        !          10303:        "community number\n"
        !          10304:        "Do not send outside local AS (well-known community)\n"
        !          10305:        "Do not advertise to any peer (well-known community)\n"
        !          10306:        "Do not export to next AS (well-known community)\n")
        !          10307: {
        !          10308:   int afi;
        !          10309:   int safi;
        !          10310: 
        !          10311:   afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
        !          10312:   safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
        !          10313:   return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi);
        !          10314: }
        !          10315: 
        !          10316: ALIAS (show_bgp_view_afi_safi_community,
        !          10317:        show_bgp_view_afi_safi_community2_cmd,
        !          10318:        "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
        !          10319:        SHOW_STR
        !          10320:        BGP_STR
        !          10321:        "BGP view\n"
        !          10322:        "View name\n"
        !          10323:        "Address family\n"
        !          10324:        "Address family\n"
        !          10325:        "Address family modifier\n"
        !          10326:        "Address family modifier\n"
        !          10327:        "Display routes matching the communities\n"
        !          10328:        "community number\n"
        !          10329:        "Do not send outside local AS (well-known community)\n"
        !          10330:        "Do not advertise to any peer (well-known community)\n"
        !          10331:        "Do not export to next AS (well-known community)\n"
        !          10332:        "community number\n"
        !          10333:        "Do not send outside local AS (well-known community)\n"
        !          10334:        "Do not advertise to any peer (well-known community)\n"
        !          10335:        "Do not export to next AS (well-known community)\n")
        !          10336: 
        !          10337: ALIAS (show_bgp_view_afi_safi_community,
        !          10338:        show_bgp_view_afi_safi_community3_cmd,
        !          10339:        "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
        !          10340:        SHOW_STR
        !          10341:        BGP_STR
        !          10342:        "BGP view\n"
        !          10343:        "View name\n"
        !          10344:        "Address family\n"
        !          10345:        "Address family\n"
        !          10346:        "Address family modifier\n"
        !          10347:        "Address family modifier\n"
        !          10348:        "Display routes matching the communities\n"
        !          10349:        "community number\n"
        !          10350:        "Do not send outside local AS (well-known community)\n"
        !          10351:        "Do not advertise to any peer (well-known community)\n"
        !          10352:        "Do not export to next AS (well-known community)\n"
        !          10353:        "community number\n"
        !          10354:        "Do not send outside local AS (well-known community)\n"
        !          10355:        "Do not advertise to any peer (well-known community)\n"
        !          10356:        "Do not export to next AS (well-known community)\n"
        !          10357:        "community number\n"
        !          10358:        "Do not send outside local AS (well-known community)\n"
        !          10359:        "Do not advertise to any peer (well-known community)\n"
        !          10360:        "Do not export to next AS (well-known community)\n")
        !          10361: 
        !          10362: ALIAS (show_bgp_view_afi_safi_community,
        !          10363:        show_bgp_view_afi_safi_community4_cmd,
        !          10364:        "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
        !          10365:        SHOW_STR
        !          10366:        BGP_STR
        !          10367:        "BGP view\n"
        !          10368:        "View name\n"
        !          10369:        "Address family\n"
        !          10370:        "Address family\n"
        !          10371:        "Address family modifier\n"
        !          10372:        "Address family modifier\n"
        !          10373:        "Display routes matching the communities\n"
        !          10374:        "community number\n"
        !          10375:        "Do not send outside local AS (well-known community)\n"
        !          10376:        "Do not advertise to any peer (well-known community)\n"
        !          10377:        "Do not export to next AS (well-known community)\n"
        !          10378:        "community number\n"
        !          10379:        "Do not send outside local AS (well-known community)\n"
        !          10380:        "Do not advertise to any peer (well-known community)\n"
        !          10381:        "Do not export to next AS (well-known community)\n"
        !          10382:        "community number\n"
        !          10383:        "Do not send outside local AS (well-known community)\n"
        !          10384:        "Do not advertise to any peer (well-known community)\n"
        !          10385:        "Do not export to next AS (well-known community)\n"
        !          10386:        "community number\n"
        !          10387:        "Do not send outside local AS (well-known community)\n"
        !          10388:        "Do not advertise to any peer (well-known community)\n"
        !          10389:        "Do not export to next AS (well-known community)\n")
        !          10390: 
        !          10391: DEFUN (show_bgp_ipv4_community_exact,
        !          10392:        show_bgp_ipv4_community_exact_cmd,
        !          10393:        "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
        !          10394:        SHOW_STR
        !          10395:        BGP_STR
        !          10396:        IP_STR
        !          10397:        "Display routes matching the communities\n"
        !          10398:        "community number\n"
        !          10399:        "Do not send outside local AS (well-known community)\n"
        !          10400:        "Do not advertise to any peer (well-known community)\n"
        !          10401:        "Do not export to next AS (well-known community)\n"
        !          10402:        "Exact match of the communities")
        !          10403: {
        !          10404:   return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
        !          10405: }
        !          10406: 
        !          10407: ALIAS (show_bgp_ipv4_community_exact,
        !          10408:        show_bgp_ipv4_community2_exact_cmd,
        !          10409:        "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
        !          10410:        SHOW_STR
        !          10411:        BGP_STR
        !          10412:        IP_STR
        !          10413:        "Display routes matching the communities\n"
        !          10414:        "community number\n"
        !          10415:        "Do not send outside local AS (well-known community)\n"
        !          10416:        "Do not advertise to any peer (well-known community)\n"
        !          10417:        "Do not export to next AS (well-known community)\n"
        !          10418:        "community number\n"
        !          10419:        "Do not send outside local AS (well-known community)\n"
        !          10420:        "Do not advertise to any peer (well-known community)\n"
        !          10421:        "Do not export to next AS (well-known community)\n"
        !          10422:        "Exact match of the communities")
        !          10423: 
        !          10424: ALIAS (show_bgp_ipv4_community_exact,
        !          10425:        show_bgp_ipv4_community3_exact_cmd,
        !          10426:        "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
        !          10427:        SHOW_STR
        !          10428:        BGP_STR
        !          10429:        IP_STR
        !          10430:        "Display routes matching the communities\n"
        !          10431:        "community number\n"
        !          10432:        "Do not send outside local AS (well-known community)\n"
        !          10433:        "Do not advertise to any peer (well-known community)\n"
        !          10434:        "Do not export to next AS (well-known community)\n"
        !          10435:        "community number\n"
        !          10436:        "Do not send outside local AS (well-known community)\n"
        !          10437:        "Do not advertise to any peer (well-known community)\n"
        !          10438:        "Do not export to next AS (well-known community)\n"
        !          10439:        "community number\n"
        !          10440:        "Do not send outside local AS (well-known community)\n"
        !          10441:        "Do not advertise to any peer (well-known community)\n"
        !          10442:        "Do not export to next AS (well-known community)\n"
        !          10443:        "Exact match of the communities")
        !          10444: 
        !          10445: ALIAS (show_bgp_ipv4_community_exact,
        !          10446:        show_bgp_ipv4_community4_exact_cmd,
        !          10447:        "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
        !          10448:        SHOW_STR
        !          10449:        BGP_STR
        !          10450:        IP_STR
        !          10451:        "Display routes matching the communities\n"
        !          10452:        "community number\n"
        !          10453:        "Do not send outside local AS (well-known community)\n"
        !          10454:        "Do not advertise to any peer (well-known community)\n"
        !          10455:        "Do not export to next AS (well-known community)\n"
        !          10456:        "community number\n"
        !          10457:        "Do not send outside local AS (well-known community)\n"
        !          10458:        "Do not advertise to any peer (well-known community)\n"
        !          10459:        "Do not export to next AS (well-known community)\n"
        !          10460:        "community number\n"
        !          10461:        "Do not send outside local AS (well-known community)\n"
        !          10462:        "Do not advertise to any peer (well-known community)\n"
        !          10463:        "Do not export to next AS (well-known community)\n"
        !          10464:        "community number\n"
        !          10465:        "Do not send outside local AS (well-known community)\n"
        !          10466:        "Do not advertise to any peer (well-known community)\n"
        !          10467:        "Do not export to next AS (well-known community)\n"
        !          10468:        "Exact match of the communities")
        !          10469: 
        !          10470: DEFUN (show_bgp_ipv4_safi_community4_exact,
        !          10471:        show_bgp_ipv4_safi_community_exact_cmd,
        !          10472:        "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
        !          10473:        SHOW_STR
        !          10474:        BGP_STR
        !          10475:        "Address family\n"
        !          10476:        "Address Family modifier\n"
        !          10477:        "Address Family modifier\n"
        !          10478:        "Display routes matching the communities\n"
        !          10479:        "community number\n"
        !          10480:        "Do not send outside local AS (well-known community)\n"
        !          10481:        "Do not advertise to any peer (well-known community)\n"
        !          10482:        "Do not export to next AS (well-known community)\n"
        !          10483:        "Exact match of the communities")
        !          10484: {
        !          10485:   if (strncmp (argv[0], "m", 1) == 0)
        !          10486:     return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
        !          10487:  
        !          10488:   return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
        !          10489: }
        !          10490: 
        !          10491: ALIAS (show_bgp_ipv4_safi_community4_exact,
        !          10492:        show_bgp_ipv4_safi_community2_exact_cmd,
        !          10493:        "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
        !          10494:        SHOW_STR
        !          10495:        BGP_STR
        !          10496:        "Address family\n"
        !          10497:        "Address Family modifier\n"
        !          10498:        "Address Family modifier\n"
        !          10499:        "Display routes matching the communities\n"
        !          10500:        "community number\n"
        !          10501:        "Do not send outside local AS (well-known community)\n"
        !          10502:        "Do not advertise to any peer (well-known community)\n"
        !          10503:        "Do not export to next AS (well-known community)\n"
        !          10504:        "community number\n"
        !          10505:        "Do not send outside local AS (well-known community)\n"
        !          10506:        "Do not advertise to any peer (well-known community)\n"
        !          10507:        "Do not export to next AS (well-known community)\n"
        !          10508:        "Exact match of the communities")
        !          10509: 
        !          10510: ALIAS (show_bgp_ipv4_safi_community4_exact,
        !          10511:        show_bgp_ipv4_safi_community3_exact_cmd,
        !          10512:        "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
        !          10513:        SHOW_STR
        !          10514:        BGP_STR
        !          10515:        "Address family\n"
        !          10516:        "Address Family modifier\n"
        !          10517:        "Address Family modifier\n"
        !          10518:        "Display routes matching the communities\n"
        !          10519:        "community number\n"
        !          10520:        "Do not send outside local AS (well-known community)\n"
        !          10521:        "Do not advertise to any peer (well-known community)\n"
        !          10522:        "Do not export to next AS (well-known community)\n"
        !          10523:        "community number\n"
        !          10524:        "Do not send outside local AS (well-known community)\n"
        !          10525:        "Do not advertise to any peer (well-known community)\n"
        !          10526:        "Do not export to next AS (well-known community)\n"
        !          10527:        "community number\n"
        !          10528:        "Do not send outside local AS (well-known community)\n"
        !          10529:        "Do not advertise to any peer (well-known community)\n"
        !          10530:        "Do not export to next AS (well-known community)\n"
        !          10531:        "Exact match of the communities")
        !          10532:        
        !          10533: ALIAS (show_bgp_ipv4_safi_community4_exact,
        !          10534:        show_bgp_ipv4_safi_community4_exact_cmd,
        !          10535:        "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
        !          10536:        SHOW_STR
        !          10537:        BGP_STR
        !          10538:        "Address family\n"
        !          10539:        "Address Family modifier\n"
        !          10540:        "Address Family modifier\n"
        !          10541:        "Display routes matching the communities\n"
        !          10542:        "community number\n"
        !          10543:        "Do not send outside local AS (well-known community)\n"
        !          10544:        "Do not advertise to any peer (well-known community)\n"
        !          10545:        "Do not export to next AS (well-known community)\n"
        !          10546:        "community number\n"
        !          10547:        "Do not send outside local AS (well-known community)\n"
        !          10548:        "Do not advertise to any peer (well-known community)\n"
        !          10549:        "Do not export to next AS (well-known community)\n"
        !          10550:        "community number\n"
        !          10551:        "Do not send outside local AS (well-known community)\n"
        !          10552:        "Do not advertise to any peer (well-known community)\n"
        !          10553:        "Do not export to next AS (well-known community)\n"
        !          10554:        "community number\n"
        !          10555:        "Do not send outside local AS (well-known community)\n"
        !          10556:        "Do not advertise to any peer (well-known community)\n"
        !          10557:        "Do not export to next AS (well-known community)\n"
        !          10558:        "Exact match of the communities")
        !          10559: 
        !          10560: DEFUN (show_bgp_ipv6_safi_community,
        !          10561:        show_bgp_ipv6_safi_community_cmd,
        !          10562:        "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export)",
        !          10563:        SHOW_STR
        !          10564:        BGP_STR
        !          10565:        "Address family\n"
        !          10566:        "Address family modifier\n"
        !          10567:        "Address family modifier\n"
        !          10568:        "Address family modifier\n"
        !          10569:        "Address family modifier\n"
        !          10570:        "Display routes matching the communities\n"
        !          10571:        "community number\n"
        !          10572:        "Do not send outside local AS (well-known community)\n"
        !          10573:        "Do not advertise to any peer (well-known community)\n"
        !          10574:        "Do not export to next AS (well-known community)\n")
        !          10575: {
        !          10576:   safi_t       safi;
        !          10577: 
        !          10578:   if (bgp_parse_safi(argv[0], &safi)) {
        !          10579:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          10580:     return CMD_WARNING;
        !          10581:   }
        !          10582:   return bgp_show_community (vty, NULL, argc-1, argv+1, 0, AFI_IP6, safi);
        !          10583: }
        !          10584: 
        !          10585: ALIAS (show_bgp_ipv6_safi_community,
        !          10586:        show_bgp_ipv6_safi_community2_cmd,
        !          10587:        "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
        !          10588:        SHOW_STR
        !          10589:        BGP_STR
        !          10590:        "Address family\n"
        !          10591:        "Address family modifier\n"
        !          10592:        "Address family modifier\n"
        !          10593:        "Address family modifier\n"
        !          10594:        "Address family modifier\n"
        !          10595:        "Display routes matching the communities\n"
        !          10596:        "community number\n"
        !          10597:        "Do not send outside local AS (well-known community)\n"
        !          10598:        "Do not advertise to any peer (well-known community)\n"
        !          10599:        "Do not export to next AS (well-known community)\n"
        !          10600:        "community number\n"
        !          10601:        "Do not send outside local AS (well-known community)\n"
        !          10602:        "Do not advertise to any peer (well-known community)\n"
        !          10603:        "Do not export to next AS (well-known community)\n")
        !          10604:        
        !          10605: ALIAS (show_bgp_ipv6_safi_community,
        !          10606:        show_bgp_ipv6_safi_community3_cmd,
        !          10607:        "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
        !          10608:        SHOW_STR
        !          10609:        BGP_STR
        !          10610:        "Address family\n"
        !          10611:        "Address family modifier\n"
        !          10612:        "Address family modifier\n"
        !          10613:        "Address family modifier\n"
        !          10614:        "Address family modifier\n"
        !          10615:        "Display routes matching the communities\n"
        !          10616:        "community number\n"
        !          10617:        "Do not send outside local AS (well-known community)\n"
        !          10618:        "Do not advertise to any peer (well-known community)\n"
        !          10619:        "Do not export to next AS (well-known community)\n"
        !          10620:        "community number\n"
        !          10621:        "Do not send outside local AS (well-known community)\n"
        !          10622:        "Do not advertise to any peer (well-known community)\n"
        !          10623:        "Do not export to next AS (well-known community)\n"
        !          10624:        "community number\n"
        !          10625:        "Do not send outside local AS (well-known community)\n"
        !          10626:        "Do not advertise to any peer (well-known community)\n"
        !          10627:        "Do not export to next AS (well-known community)\n")
        !          10628: 
        !          10629: ALIAS (show_bgp_ipv6_safi_community,
        !          10630:        show_bgp_ipv6_safi_community4_cmd,
        !          10631:        "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
        !          10632:        SHOW_STR
        !          10633:        BGP_STR
        !          10634:        "Address family\n"
        !          10635:        "Address family modifier\n"
        !          10636:        "Address family modifier\n"
        !          10637:        "Address family modifier\n"
        !          10638:        "Address family modifier\n"
        !          10639:        "Display routes matching the communities\n"
        !          10640:        "community number\n"
        !          10641:        "Do not send outside local AS (well-known community)\n"
        !          10642:        "Do not advertise to any peer (well-known community)\n"
        !          10643:        "Do not export to next AS (well-known community)\n"
        !          10644:        "community number\n"
        !          10645:        "Do not send outside local AS (well-known community)\n"
        !          10646:        "Do not advertise to any peer (well-known community)\n"
        !          10647:        "Do not export to next AS (well-known community)\n"
        !          10648:        "community number\n"
        !          10649:        "Do not send outside local AS (well-known community)\n"
        !          10650:        "Do not advertise to any peer (well-known community)\n"
        !          10651:        "Do not export to next AS (well-known community)\n"
        !          10652:        "community number\n"
        !          10653:        "Do not send outside local AS (well-known community)\n"
        !          10654:        "Do not advertise to any peer (well-known community)\n"
        !          10655:        "Do not export to next AS (well-known community)\n")
        !          10656: 
        !          10657: 
        !          10658: DEFUN (show_bgp_ipv6_safi_community_exact,
        !          10659:        show_bgp_ipv6_safi_community_exact_cmd,
        !          10660:        "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
        !          10661:        SHOW_STR
        !          10662:        BGP_STR
        !          10663:        "Address family\n"
        !          10664:        "Address family modifier\n"
        !          10665:        "Address family modifier\n"
        !          10666:        "Address family modifier\n"
        !          10667:        "Address family modifier\n"
        !          10668:        "Display routes matching the communities\n"
        !          10669:        "community number\n"
        !          10670:        "Do not send outside local AS (well-known community)\n"
        !          10671:        "Do not advertise to any peer (well-known community)\n"
        !          10672:        "Do not export to next AS (well-known community)\n"
        !          10673:        "Exact match of the communities")
        !          10674: {
        !          10675:   safi_t       safi;
        !          10676: 
        !          10677:   if (bgp_parse_safi(argv[0], &safi)) {
        !          10678:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          10679:     return CMD_WARNING;
        !          10680:   }
        !          10681:   return bgp_show_community (vty, NULL, argc-1, argv+1, 1, AFI_IP6, safi);
        !          10682: }
        !          10683: 
        !          10684: 
        !          10685: ALIAS (show_bgp_community_exact,
        !          10686:        show_bgp_ipv6_safi_community2_exact_cmd,
        !          10687:        "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
        !          10688:        SHOW_STR
        !          10689:        BGP_STR
        !          10690:        "Address family\n"
        !          10691:        "Address family modifier\n"
        !          10692:        "Address family modifier\n"
        !          10693:        "Address family modifier\n"
        !          10694:        "Address family modifier\n"
        !          10695:        "Display routes matching the communities\n"
        !          10696:        "community number\n"
        !          10697:        "Do not send outside local AS (well-known community)\n"
        !          10698:        "Do not advertise to any peer (well-known community)\n"
        !          10699:        "Do not export to next AS (well-known community)\n"
        !          10700:        "community number\n"
        !          10701:        "Do not send outside local AS (well-known community)\n"
        !          10702:        "Do not advertise to any peer (well-known community)\n"
        !          10703:        "Do not export to next AS (well-known community)\n"
        !          10704:        "Exact match of the communities")
        !          10705: 
        !          10706: ALIAS (show_bgp_community_exact,
        !          10707:        show_bgp_ipv6_safi_community3_exact_cmd,
        !          10708:        "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
        !          10709:        SHOW_STR
        !          10710:        BGP_STR
        !          10711:        "Address family\n"
        !          10712:        "Address family modifier\n"
        !          10713:        "Address family modifier\n"
        !          10714:        "Address family modifier\n"
        !          10715:        "Address family modifier\n"
        !          10716:        "Display routes matching the communities\n"
        !          10717:        "community number\n"
        !          10718:        "Do not send outside local AS (well-known community)\n"
        !          10719:        "Do not advertise to any peer (well-known community)\n"
        !          10720:        "Do not export to next AS (well-known community)\n"
        !          10721:        "community number\n"
        !          10722:        "Do not send outside local AS (well-known community)\n"
        !          10723:        "Do not advertise to any peer (well-known community)\n"
        !          10724:        "Do not export to next AS (well-known community)\n"
        !          10725:        "community number\n"
        !          10726:        "Do not send outside local AS (well-known community)\n"
        !          10727:        "Do not advertise to any peer (well-known community)\n"
        !          10728:        "Do not export to next AS (well-known community)\n"
        !          10729:        "Exact match of the communities")
        !          10730: 
        !          10731: ALIAS (show_bgp_community_exact,
        !          10732:        show_bgp_ipv6_safi_community4_exact_cmd,
        !          10733:        "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
        !          10734:        SHOW_STR
        !          10735:        BGP_STR
        !          10736:        "Address family\n"
        !          10737:        "Address family modifier\n"
        !          10738:        "Address family modifier\n"
        !          10739:        "Address family modifier\n"
        !          10740:        "Address family modifier\n"
        !          10741:        "Display routes matching the communities\n"
        !          10742:        "community number\n"
        !          10743:        "Do not send outside local AS (well-known community)\n"
        !          10744:        "Do not advertise to any peer (well-known community)\n"
        !          10745:        "Do not export to next AS (well-known community)\n"
        !          10746:        "community number\n"
        !          10747:        "Do not send outside local AS (well-known community)\n"
        !          10748:        "Do not advertise to any peer (well-known community)\n"
        !          10749:        "Do not export to next AS (well-known community)\n"
        !          10750:        "community number\n"
        !          10751:        "Do not send outside local AS (well-known community)\n"
        !          10752:        "Do not advertise to any peer (well-known community)\n"
        !          10753:        "Do not export to next AS (well-known community)\n"
        !          10754:        "community number\n"
        !          10755:        "Do not send outside local AS (well-known community)\n"
        !          10756:        "Do not advertise to any peer (well-known community)\n"
        !          10757:        "Do not export to next AS (well-known community)\n"
        !          10758:        "Exact match of the communities")
        !          10759: 
        !          10760: static int
        !          10761: bgp_show_community_list (struct vty *vty, const char *com, int exact,
        !          10762:                         afi_t afi, safi_t safi)
        !          10763: {
        !          10764:   struct community_list *list;
        !          10765: 
        !          10766:   list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER);
        !          10767:   if (list == NULL)
        !          10768:     {
        !          10769:       vty_out (vty, "%% %s is not a valid community-list name%s", com,
        !          10770:               VTY_NEWLINE);
        !          10771:       return CMD_WARNING;
        !          10772:     }
        !          10773: 
        !          10774:   return bgp_show (vty, NULL, afi, safi,
        !          10775:                    (exact ? bgp_show_type_community_list_exact :
        !          10776:                            bgp_show_type_community_list), list);
        !          10777: }
        !          10778: 
        !          10779: DEFUN (show_ip_bgp_community_list,
        !          10780:        show_ip_bgp_community_list_cmd,
        !          10781:        "show ip bgp community-list (<1-500>|WORD)",
        !          10782:        SHOW_STR
        !          10783:        IP_STR
        !          10784:        BGP_STR
        !          10785:        "Display routes matching the community-list\n"
        !          10786:        "community-list number\n"
        !          10787:        "community-list name\n")
        !          10788: {
        !          10789:   return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
        !          10790: }
        !          10791: 
        !          10792: DEFUN (show_ip_bgp_ipv4_community_list,
        !          10793:        show_ip_bgp_ipv4_community_list_cmd,
        !          10794:        "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
        !          10795:        SHOW_STR
        !          10796:        IP_STR
        !          10797:        BGP_STR
        !          10798:        "Address family\n"
        !          10799:        "Address Family modifier\n"
        !          10800:        "Address Family modifier\n"
        !          10801:        "Display routes matching the community-list\n"
        !          10802:        "community-list number\n"
        !          10803:        "community-list name\n")
        !          10804: {
        !          10805:   if (strncmp (argv[0], "m", 1) == 0)
        !          10806:     return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
        !          10807:   
        !          10808:   return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
        !          10809: }
        !          10810: 
        !          10811: DEFUN (show_ip_bgp_community_list_exact,
        !          10812:        show_ip_bgp_community_list_exact_cmd,
        !          10813:        "show ip bgp community-list (<1-500>|WORD) exact-match",
        !          10814:        SHOW_STR
        !          10815:        IP_STR
        !          10816:        BGP_STR
        !          10817:        "Display routes matching the community-list\n"
        !          10818:        "community-list number\n"
        !          10819:        "community-list name\n"
        !          10820:        "Exact match of the communities\n")
        !          10821: {
        !          10822:   return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
        !          10823: }
        !          10824: 
        !          10825: DEFUN (show_ip_bgp_ipv4_community_list_exact,
        !          10826:        show_ip_bgp_ipv4_community_list_exact_cmd,
        !          10827:        "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
        !          10828:        SHOW_STR
        !          10829:        IP_STR
        !          10830:        BGP_STR
        !          10831:        "Address family\n"
        !          10832:        "Address Family modifier\n"
        !          10833:        "Address Family modifier\n"
        !          10834:        "Display routes matching the community-list\n"
        !          10835:        "community-list number\n"
        !          10836:        "community-list name\n"
        !          10837:        "Exact match of the communities\n")
        !          10838: {
        !          10839:   if (strncmp (argv[0], "m", 1) == 0)
        !          10840:     return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
        !          10841:  
        !          10842:   return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
        !          10843: }
        !          10844: 
        !          10845: DEFUN (show_bgp_community_list,
        !          10846:        show_bgp_community_list_cmd,
        !          10847:        "show bgp community-list (<1-500>|WORD)",
        !          10848:        SHOW_STR
        !          10849:        BGP_STR
        !          10850:        "Display routes matching the community-list\n"
        !          10851:        "community-list number\n"
        !          10852:        "community-list name\n")
        !          10853: {
        !          10854:   return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
        !          10855: }
        !          10856: 
        !          10857: ALIAS (show_bgp_community_list,
        !          10858:        show_bgp_ipv6_community_list_cmd,
        !          10859:        "show bgp ipv6 community-list (<1-500>|WORD)",
        !          10860:        SHOW_STR
        !          10861:        BGP_STR
        !          10862:        "Address family\n"
        !          10863:        "Display routes matching the community-list\n"
        !          10864:        "community-list number\n"
        !          10865:        "community-list name\n")
        !          10866: 
        !          10867: /* old command */
        !          10868: DEFUN (show_ipv6_bgp_community_list,
        !          10869:        show_ipv6_bgp_community_list_cmd,
        !          10870:        "show ipv6 bgp community-list WORD",
        !          10871:        SHOW_STR
        !          10872:        IPV6_STR
        !          10873:        BGP_STR
        !          10874:        "Display routes matching the community-list\n"
        !          10875:        "community-list name\n")
        !          10876: {
        !          10877:   return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
        !          10878: }
        !          10879: 
        !          10880: /* old command */
        !          10881: DEFUN (show_ipv6_mbgp_community_list,
        !          10882:        show_ipv6_mbgp_community_list_cmd,
        !          10883:        "show ipv6 mbgp community-list WORD",
        !          10884:        SHOW_STR
        !          10885:        IPV6_STR
        !          10886:        MBGP_STR
        !          10887:        "Display routes matching the community-list\n"
        !          10888:        "community-list name\n")
        !          10889: {
        !          10890:   return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST);
        !          10891: }
        !          10892: 
        !          10893: DEFUN (show_bgp_community_list_exact,
        !          10894:        show_bgp_community_list_exact_cmd,
        !          10895:        "show bgp community-list (<1-500>|WORD) exact-match",
        !          10896:        SHOW_STR
        !          10897:        BGP_STR
        !          10898:        "Display routes matching the community-list\n"
        !          10899:        "community-list number\n"
        !          10900:        "community-list name\n"
        !          10901:        "Exact match of the communities\n")
        !          10902: {
        !          10903:   return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
        !          10904: }
        !          10905: 
        !          10906: ALIAS (show_bgp_community_list_exact,
        !          10907:        show_bgp_ipv6_community_list_exact_cmd,
        !          10908:        "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
        !          10909:        SHOW_STR
        !          10910:        BGP_STR
        !          10911:        "Address family\n"
        !          10912:        "Display routes matching the community-list\n"
        !          10913:        "community-list number\n"
        !          10914:        "community-list name\n"
        !          10915:        "Exact match of the communities\n")
        !          10916: 
        !          10917: /* old command */
        !          10918: DEFUN (show_ipv6_bgp_community_list_exact,
        !          10919:        show_ipv6_bgp_community_list_exact_cmd,
        !          10920:        "show ipv6 bgp community-list WORD exact-match",
        !          10921:        SHOW_STR
        !          10922:        IPV6_STR
        !          10923:        BGP_STR
        !          10924:        "Display routes matching the community-list\n"
        !          10925:        "community-list name\n"
        !          10926:        "Exact match of the communities\n")
        !          10927: {
        !          10928:   return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
        !          10929: }
        !          10930: 
        !          10931: /* old command */
        !          10932: DEFUN (show_ipv6_mbgp_community_list_exact,
        !          10933:        show_ipv6_mbgp_community_list_exact_cmd,
        !          10934:        "show ipv6 mbgp community-list WORD exact-match",
        !          10935:        SHOW_STR
        !          10936:        IPV6_STR
        !          10937:        MBGP_STR
        !          10938:        "Display routes matching the community-list\n"
        !          10939:        "community-list name\n"
        !          10940:        "Exact match of the communities\n")
        !          10941: {
        !          10942:   return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST);
        !          10943: }
        !          10944: 
        !          10945: DEFUN (show_bgp_ipv4_community_list,
        !          10946:        show_bgp_ipv4_community_list_cmd,
        !          10947:        "show bgp ipv4 community-list (<1-500>|WORD)",
        !          10948:        SHOW_STR
        !          10949:        BGP_STR
        !          10950:        IP_STR
        !          10951:        "Display routes matching the community-list\n"
        !          10952:        "community-list number\n"
        !          10953:        "community-list name\n")
        !          10954: {
        !          10955:   return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
        !          10956: }
        !          10957: 
        !          10958: DEFUN (show_bgp_ipv4_safi_community_list,
        !          10959:        show_bgp_ipv4_safi_community_list_cmd,
        !          10960:        "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
        !          10961:        SHOW_STR
        !          10962:        BGP_STR
        !          10963:        "Address family\n"
        !          10964:        "Address Family modifier\n"
        !          10965:        "Address Family modifier\n"
        !          10966:        "Display routes matching the community-list\n"
        !          10967:        "community-list number\n"
        !          10968:        "community-list name\n")
        !          10969: {
        !          10970:   if (strncmp (argv[0], "m", 1) == 0)
        !          10971:     return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
        !          10972:   
        !          10973:   return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
        !          10974: }
        !          10975: 
        !          10976: DEFUN (show_bgp_ipv4_community_list_exact,
        !          10977:        show_bgp_ipv4_community_list_exact_cmd,
        !          10978:        "show bgp ipv4 community-list (<1-500>|WORD) exact-match",
        !          10979:        SHOW_STR
        !          10980:        BGP_STR
        !          10981:        IP_STR
        !          10982:        "Display routes matching the community-list\n"
        !          10983:        "community-list number\n"
        !          10984:        "community-list name\n"
        !          10985:        "Exact match of the communities\n")
        !          10986: {
        !          10987:   return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
        !          10988: }
        !          10989: 
        !          10990: DEFUN (show_bgp_ipv4_safi_community_list_exact,
        !          10991:        show_bgp_ipv4_safi_community_list_exact_cmd,
        !          10992:        "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
        !          10993:        SHOW_STR
        !          10994:        BGP_STR
        !          10995:        "Address family\n"
        !          10996:        "Address Family modifier\n"
        !          10997:        "Address Family modifier\n"
        !          10998:        "Display routes matching the community-list\n"
        !          10999:        "community-list number\n"
        !          11000:        "community-list name\n"
        !          11001:        "Exact match of the communities\n")
        !          11002: {
        !          11003:   if (strncmp (argv[0], "m", 1) == 0)
        !          11004:     return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
        !          11005:  
        !          11006:   return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
        !          11007: }
        !          11008: 
        !          11009: DEFUN (show_bgp_ipv6_safi_community_list,
        !          11010:        show_bgp_ipv6_safi_community_list_cmd,
        !          11011:        "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD)",
        !          11012:        SHOW_STR
        !          11013:        BGP_STR
        !          11014:        "Address family\n"
        !          11015:        "Address family modifier\n"
        !          11016:        "Address family modifier\n"
        !          11017:        "Address family modifier\n"
        !          11018:        "Address family modifier\n"
        !          11019:        "Display routes matching the community-list\n"
        !          11020:        "community-list number\n"
        !          11021:        "community-list name\n")
        !          11022: {
        !          11023:   safi_t       safi;
        !          11024: 
        !          11025:   if (bgp_parse_safi(argv[0], &safi)) {
        !          11026:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          11027:     return CMD_WARNING;
        !          11028:   }
        !          11029:   return bgp_show_community_list (vty, argv[1], 0, AFI_IP6, safi);
        !          11030: }
        !          11031: 
        !          11032: DEFUN (show_bgp_ipv6_safi_community_list_exact,
        !          11033:        show_bgp_ipv6_safi_community_list_exact_cmd,
        !          11034:        "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD) exact-match",
        !          11035:        SHOW_STR
        !          11036:        BGP_STR
        !          11037:        "Address family\n"
        !          11038:        "Address family modifier\n"
        !          11039:        "Address family modifier\n"
        !          11040:        "Address family modifier\n"
        !          11041:        "Address family modifier\n"
        !          11042:        "Display routes matching the community-list\n"
        !          11043:        "community-list number\n"
        !          11044:        "community-list name\n"
        !          11045:        "Exact match of the communities\n")
        !          11046: {
        !          11047:   safi_t       safi;
        !          11048: 
        !          11049:   if (bgp_parse_safi(argv[0], &safi)) {
        !          11050:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          11051:     return CMD_WARNING;
        !          11052:   }
        !          11053:   return bgp_show_community_list (vty, argv[1], 1, AFI_IP6, safi);
        !          11054: }
        !          11055: 
        !          11056: static int
        !          11057: bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi,
        !          11058:                        safi_t safi, enum bgp_show_type type)
        !          11059: {
        !          11060:   int ret;
        !          11061:   struct prefix *p;
        !          11062: 
        !          11063:   p = prefix_new();
        !          11064: 
        !          11065:   ret = str2prefix (prefix, p);
        !          11066:   if (! ret)
        !          11067:     {
        !          11068:       vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
        !          11069:       return CMD_WARNING;
        !          11070:     }
        !          11071: 
        !          11072:   ret = bgp_show (vty, NULL, afi, safi, type, p);
        !          11073:   prefix_free(p);
        !          11074:   return ret;
        !          11075: }
        !          11076: 
        !          11077: DEFUN (show_ip_bgp_prefix_longer,
        !          11078:        show_ip_bgp_prefix_longer_cmd,
        !          11079:        "show ip bgp A.B.C.D/M longer-prefixes",
        !          11080:        SHOW_STR
        !          11081:        IP_STR
        !          11082:        BGP_STR
        !          11083:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
        !          11084:        "Display route and more specific routes\n")
        !          11085: {
        !          11086:   return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
        !          11087:                                 bgp_show_type_prefix_longer);
        !          11088: }
        !          11089: 
        !          11090: DEFUN (show_ip_bgp_flap_prefix_longer,
        !          11091:        show_ip_bgp_flap_prefix_longer_cmd,
        !          11092:        "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
        !          11093:        SHOW_STR
        !          11094:        IP_STR
        !          11095:        BGP_STR
        !          11096:        "Display flap statistics of routes\n"
        !          11097:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
        !          11098:        "Display route and more specific routes\n")
        !          11099: {
        !          11100:   return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
        !          11101:                                 bgp_show_type_flap_prefix_longer);
        !          11102: }
        !          11103: 
        !          11104: ALIAS (show_ip_bgp_flap_prefix_longer,
        !          11105:        show_ip_bgp_damp_flap_prefix_longer_cmd,
        !          11106:        "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
        !          11107:        SHOW_STR
        !          11108:        IP_STR
        !          11109:        BGP_STR
        !          11110:        "Display detailed information about dampening\n"
        !          11111:        "Display flap statistics of routes\n"
        !          11112:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
        !          11113:        "Display route and more specific routes\n")
        !          11114: 
        !          11115: DEFUN (show_ip_bgp_ipv4_prefix_longer,
        !          11116:        show_ip_bgp_ipv4_prefix_longer_cmd,
        !          11117:        "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
        !          11118:        SHOW_STR
        !          11119:        IP_STR
        !          11120:        BGP_STR
        !          11121:        "Address family\n"
        !          11122:        "Address Family modifier\n"
        !          11123:        "Address Family modifier\n"
        !          11124:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
        !          11125:        "Display route and more specific routes\n")
        !          11126: {
        !          11127:   if (strncmp (argv[0], "m", 1) == 0)
        !          11128:     return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST,
        !          11129:                                   bgp_show_type_prefix_longer);
        !          11130: 
        !          11131:   return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST,
        !          11132:                                 bgp_show_type_prefix_longer);
        !          11133: }
        !          11134: 
        !          11135: DEFUN (show_ip_bgp_flap_address,
        !          11136:        show_ip_bgp_flap_address_cmd,
        !          11137:        "show ip bgp flap-statistics A.B.C.D",
        !          11138:        SHOW_STR
        !          11139:        IP_STR
        !          11140:        BGP_STR
        !          11141:        "Display flap statistics of routes\n"
        !          11142:        "Network in the BGP routing table to display\n")
        !          11143: {
        !          11144:   return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
        !          11145:                                 bgp_show_type_flap_address);
        !          11146: }
        !          11147: 
        !          11148: ALIAS (show_ip_bgp_flap_address,
        !          11149:        show_ip_bgp_damp_flap_address_cmd,
        !          11150:        "show ip bgp dampening flap-statistics A.B.C.D",
        !          11151:        SHOW_STR
        !          11152:        IP_STR
        !          11153:        BGP_STR
        !          11154:        "Display detailed information about dampening\n"
        !          11155:        "Display flap statistics of routes\n"
        !          11156:        "Network in the BGP routing table to display\n")
        !          11157: 
        !          11158: DEFUN (show_ip_bgp_flap_prefix,
        !          11159:        show_ip_bgp_flap_prefix_cmd,
        !          11160:        "show ip bgp flap-statistics A.B.C.D/M",
        !          11161:        SHOW_STR
        !          11162:        IP_STR
        !          11163:        BGP_STR
        !          11164:        "Display flap statistics of routes\n"
        !          11165:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
        !          11166: {
        !          11167:   return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
        !          11168:                                 bgp_show_type_flap_prefix);
        !          11169: }
        !          11170: 
        !          11171: ALIAS (show_ip_bgp_flap_prefix,
        !          11172:        show_ip_bgp_damp_flap_prefix_cmd,
        !          11173:        "show ip bgp dampening flap-statistics A.B.C.D/M",
        !          11174:        SHOW_STR
        !          11175:        IP_STR
        !          11176:        BGP_STR
        !          11177:        "Display detailed information about dampening\n"
        !          11178:        "Display flap statistics of routes\n"
        !          11179:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
        !          11180: 
        !          11181: DEFUN (show_bgp_prefix_longer,
        !          11182:        show_bgp_prefix_longer_cmd,
        !          11183:        "show bgp X:X::X:X/M longer-prefixes",
        !          11184:        SHOW_STR
        !          11185:        BGP_STR
        !          11186:        "IPv6 prefix <network>/<length>\n"
        !          11187:        "Display route and more specific routes\n")
        !          11188: {
        !          11189:   return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
        !          11190:                                 bgp_show_type_prefix_longer);
        !          11191: }
        !          11192: 
        !          11193: /* old command */
        !          11194: DEFUN (show_ipv6_bgp_prefix_longer,
        !          11195:        show_ipv6_bgp_prefix_longer_cmd,
        !          11196:        "show ipv6 bgp X:X::X:X/M longer-prefixes",
        !          11197:        SHOW_STR
        !          11198:        IPV6_STR
        !          11199:        BGP_STR
1.1       misho    11200:        "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
                   11201:        "Display route and more specific routes\n")
                   11202: {
1.1.1.4 ! misho    11203:   return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
        !          11204:                                 bgp_show_type_prefix_longer);
        !          11205: }
        !          11206: 
        !          11207: /* old command */
        !          11208: DEFUN (show_ipv6_mbgp_prefix_longer,
        !          11209:        show_ipv6_mbgp_prefix_longer_cmd,
        !          11210:        "show ipv6 mbgp X:X::X:X/M longer-prefixes",
        !          11211:        SHOW_STR
        !          11212:        IPV6_STR
        !          11213:        MBGP_STR
        !          11214:        "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
        !          11215:        "Display route and more specific routes\n")
        !          11216: {
        !          11217:   return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
        !          11218:                                 bgp_show_type_prefix_longer);
        !          11219: }
        !          11220: 
        !          11221: DEFUN (show_bgp_ipv4_prefix_longer,
        !          11222:        show_bgp_ipv4_prefix_longer_cmd,
        !          11223:        "show bgp ipv4 A.B.C.D/M longer-prefixes",
        !          11224:        SHOW_STR
        !          11225:        BGP_STR
        !          11226:        IP_STR
        !          11227:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
        !          11228:        "Display route and more specific routes\n")
        !          11229: {
        !          11230:   return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
        !          11231:                                 bgp_show_type_prefix_longer);
        !          11232: }
        !          11233: 
        !          11234: DEFUN (show_bgp_ipv4_safi_flap_prefix_longer,
        !          11235:        show_bgp_ipv4_safi_flap_prefix_longer_cmd,
        !          11236:        "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M longer-prefixes",
        !          11237:        SHOW_STR
        !          11238:        BGP_STR
        !          11239:        "Address family\n"
        !          11240:        "Address Family modifier\n"
        !          11241:        "Address Family modifier\n"
        !          11242:        "Address Family modifier\n"
        !          11243:        "Address Family modifier\n"
        !          11244:        "Display flap statistics of routes\n"
        !          11245:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
        !          11246:        "Display route and more specific routes\n")
        !          11247: {
        !          11248:   safi_t       safi;
        !          11249: 
        !          11250:   if (bgp_parse_safi(argv[0], &safi)) {
        !          11251:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          11252:     return CMD_WARNING;
        !          11253:   }
        !          11254:   return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
        !          11255:                                 bgp_show_type_flap_prefix_longer);
        !          11256: }
        !          11257: 
        !          11258: ALIAS (show_bgp_ipv4_safi_flap_prefix_longer,
        !          11259:        show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd,
        !          11260:        "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M longer-prefixes",
        !          11261:        SHOW_STR
        !          11262:        BGP_STR
        !          11263:        "Address family\n"
        !          11264:        "Address Family modifier\n"
        !          11265:        "Address Family modifier\n"
        !          11266:        "Address Family modifier\n"
        !          11267:        "Address Family modifier\n"
        !          11268:        "Display detailed information about dampening\n"
        !          11269:        "Display flap statistics of routes\n"
        !          11270:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
        !          11271:        "Display route and more specific routes\n")
        !          11272: 
        !          11273: DEFUN (show_bgp_ipv6_safi_flap_prefix_longer,
        !          11274:        show_bgp_ipv6_safi_flap_prefix_longer_cmd,
        !          11275:        "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M longer-prefixes",
        !          11276:        SHOW_STR
        !          11277:        BGP_STR
        !          11278:        "Address family\n"
        !          11279:        "Address Family modifier\n"
        !          11280:        "Address Family modifier\n"
        !          11281:        "Address Family modifier\n"
        !          11282:        "Address Family modifier\n"
        !          11283:        "Display flap statistics of routes\n"
        !          11284:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
        !          11285:        "Display route and more specific routes\n")
        !          11286: {
        !          11287:   safi_t       safi;
        !          11288: 
        !          11289:   if (bgp_parse_safi(argv[0], &safi)) {
        !          11290:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          11291:     return CMD_WARNING;
        !          11292:   }
        !          11293:   return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
        !          11294:                                 bgp_show_type_flap_prefix_longer);
        !          11295: }
        !          11296: ALIAS (show_bgp_ipv6_safi_flap_prefix_longer,
        !          11297:        show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd,
        !          11298:        "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M longer-prefixes",
        !          11299:        SHOW_STR
        !          11300:        BGP_STR
        !          11301:        "Address family\n"
        !          11302:        "Address Family modifier\n"
        !          11303:        "Address Family modifier\n"
        !          11304:        "Address Family modifier\n"
        !          11305:        "Address Family modifier\n"
        !          11306:        "Display detailed information about dampening\n"
        !          11307:        "Display flap statistics of routes\n"
        !          11308:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
        !          11309:        "Display route and more specific routes\n")
        !          11310: 
        !          11311: DEFUN (show_bgp_ipv4_safi_prefix_longer,
        !          11312:        show_bgp_ipv4_safi_prefix_longer_cmd,
        !          11313:        "show bgp ipv4 (encap|multicast|unicast|vpn) A.B.C.D/M longer-prefixes",
        !          11314:        SHOW_STR
        !          11315:        BGP_STR
        !          11316:        "Address family\n"
        !          11317:        "Address Family modifier\n"
        !          11318:        "Address Family modifier\n"
        !          11319:        "Address Family modifier\n"
        !          11320:        "Address Family modifier\n"
        !          11321:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
        !          11322:        "Display route and more specific routes\n")
        !          11323: {
        !          11324:   safi_t       safi;
        !          11325: 
        !          11326:   if (bgp_parse_safi(argv[0], &safi)) {
        !          11327:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          11328:     return CMD_WARNING;
        !          11329:   }
        !          11330: 
        !          11331:   return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
        !          11332:                                   bgp_show_type_prefix_longer);
        !          11333: }
        !          11334: 
        !          11335: DEFUN (show_bgp_ipv6_safi_prefix_longer,
        !          11336:        show_bgp_ipv6_safi_prefix_longer_cmd,
        !          11337:        "show bgp ipv6 (encap|multicast|unicast|vpn) X:X::X:X/M longer-prefixes",
        !          11338:        SHOW_STR
        !          11339:        BGP_STR
        !          11340:        "Address family\n"
        !          11341:        "Address Family modifier\n"
        !          11342:        "Address Family modifier\n"
        !          11343:        "Address Family modifier\n"
        !          11344:        "Address Family modifier\n"
        !          11345:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
        !          11346:        "Display route and more specific routes\n")
        !          11347: {
        !          11348:   safi_t       safi;
        !          11349: 
        !          11350:   if (bgp_parse_safi(argv[0], &safi)) {
        !          11351:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          11352:     return CMD_WARNING;
        !          11353:   }
        !          11354: 
        !          11355:   return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
        !          11356:                                   bgp_show_type_prefix_longer);
        !          11357: }
        !          11358: 
        !          11359: DEFUN (show_bgp_ipv4_safi_flap_address,
        !          11360:        show_bgp_ipv4_safi_flap_address_cmd,
        !          11361:        "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
        !          11362:        SHOW_STR
        !          11363:        BGP_STR
        !          11364:        "Address family\n"
        !          11365:        "Address Family modifier\n"
        !          11366:        "Address Family modifier\n"
        !          11367:        "Address Family modifier\n"
        !          11368:        "Address Family modifier\n"
        !          11369:        "Display flap statistics of routes\n"
        !          11370:        "Network in the BGP routing table to display\n")
        !          11371: {
        !          11372:   safi_t       safi;
        !          11373: 
        !          11374:   if (bgp_parse_safi(argv[0], &safi)) {
        !          11375:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          11376:     return CMD_WARNING;
        !          11377:   }
        !          11378:   return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
        !          11379:                                 bgp_show_type_flap_address);
        !          11380: }
        !          11381: ALIAS (show_bgp_ipv4_safi_flap_address,
        !          11382:        show_bgp_ipv4_safi_damp_flap_address_cmd,
        !          11383:        "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
        !          11384:        SHOW_STR
        !          11385:        BGP_STR
        !          11386:        "Address family\n"
        !          11387:        "Address Family modifier\n"
        !          11388:        "Address Family modifier\n"
        !          11389:        "Address Family modifier\n"
        !          11390:        "Address Family modifier\n"
        !          11391:        "Display detailed information about dampening\n"
        !          11392:        "Display flap statistics of routes\n"
        !          11393:        "Network in the BGP routing table to display\n")
        !          11394: 
        !          11395: DEFUN (show_bgp_ipv6_flap_address,
        !          11396:        show_bgp_ipv6_flap_address_cmd,
        !          11397:        "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
        !          11398:        SHOW_STR
        !          11399:        BGP_STR
        !          11400:        "Address family\n"
        !          11401:        "Address Family modifier\n"
        !          11402:        "Address Family modifier\n"
        !          11403:        "Address Family modifier\n"
        !          11404:        "Address Family modifier\n"
        !          11405:        "Display flap statistics of routes\n"
        !          11406:        "Network in the BGP routing table to display\n")
        !          11407: {
        !          11408:   safi_t       safi;
        !          11409: 
        !          11410:   if (bgp_parse_safi(argv[0], &safi)) {
        !          11411:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
        !          11412:     return CMD_WARNING;
        !          11413:   }
        !          11414:   return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
        !          11415:                                 bgp_show_type_flap_address);
        !          11416: }
        !          11417: ALIAS (show_bgp_ipv6_flap_address,
        !          11418:        show_bgp_ipv6_damp_flap_address_cmd,
        !          11419:        "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
        !          11420:        SHOW_STR
        !          11421:        BGP_STR
        !          11422:        "Address family\n"
        !          11423:        "Address Family modifier\n"
        !          11424:        "Address Family modifier\n"
        !          11425:        "Address Family modifier\n"
        !          11426:        "Address Family modifier\n"
        !          11427:        "Display detailed information about dampening\n"
        !          11428:        "Display flap statistics of routes\n"
        !          11429:        "Network in the BGP routing table to display\n")
        !          11430: 
        !          11431: DEFUN (show_bgp_ipv4_safi_flap_prefix,
        !          11432:        show_bgp_ipv4_safi_flap_prefix_cmd,
        !          11433:        "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M",
        !          11434:        SHOW_STR
        !          11435:        BGP_STR
        !          11436:        "Address family\n"
        !          11437:        "Address Family modifier\n"
        !          11438:        "Address Family modifier\n"
        !          11439:        "Address Family modifier\n"
        !          11440:        "Address Family modifier\n"
        !          11441:        "Display flap statistics of routes\n"
        !          11442:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
        !          11443: {
        !          11444:   safi_t       safi;
        !          11445: 
        !          11446:   if (bgp_parse_safi(argv[0], &safi)) {
        !          11447:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
        !          11448:     return CMD_WARNING;
        !          11449:   }
        !          11450:   return bgp_show_prefix_longer (vty, argv[0], AFI_IP, safi,
        !          11451:                                 bgp_show_type_flap_prefix);
        !          11452: }
        !          11453: 
        !          11454: ALIAS (show_bgp_ipv4_safi_flap_prefix,
        !          11455:        show_bgp_ipv4_safi_damp_flap_prefix_cmd,
        !          11456:        "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M",
        !          11457:        SHOW_STR
        !          11458:        BGP_STR
        !          11459:        "Address family\n"
        !          11460:        "Address Family modifier\n"
        !          11461:        "Address Family modifier\n"
        !          11462:        "Address Family modifier\n"
        !          11463:        "Address Family modifier\n"
        !          11464:        "Display detailed information about dampening\n"
        !          11465:        "Display flap statistics of routes\n"
        !          11466:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
        !          11467: 
        !          11468: DEFUN (show_bgp_ipv6_safi_flap_prefix,
        !          11469:        show_bgp_ipv6_safi_flap_prefix_cmd,
        !          11470:        "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M",
        !          11471:        SHOW_STR
        !          11472:        BGP_STR
        !          11473:        "Address family\n"
        !          11474:        "Address Family modifier\n"
        !          11475:        "Address Family modifier\n"
        !          11476:        "Address Family modifier\n"
        !          11477:        "Address Family modifier\n"
        !          11478:        "Display flap statistics of routes\n"
        !          11479:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
        !          11480: {
        !          11481:   safi_t       safi;
        !          11482: 
        !          11483:   if (bgp_parse_safi(argv[0], &safi)) {
        !          11484:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
        !          11485:     return CMD_WARNING;
        !          11486:   }
        !          11487:   return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, safi,
        !          11488:                                 bgp_show_type_flap_prefix);
        !          11489: }
        !          11490: 
        !          11491: ALIAS (show_bgp_ipv6_safi_flap_prefix,
        !          11492:        show_bgp_ipv6_safi_damp_flap_prefix_cmd,
        !          11493:        "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M",
        !          11494:        SHOW_STR
        !          11495:        BGP_STR
        !          11496:        "Address family\n"
        !          11497:        "Address Family modifier\n"
        !          11498:        "Address Family modifier\n"
        !          11499:        "Address Family modifier\n"
        !          11500:        "Address Family modifier\n"
        !          11501:        "Display detailed information about dampening\n"
        !          11502:        "Display flap statistics of routes\n"
        !          11503:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
        !          11504: 
        !          11505: DEFUN (show_bgp_ipv6_prefix_longer,
        !          11506:        show_bgp_ipv6_prefix_longer_cmd,
        !          11507:        "show bgp ipv6 X:X::X:X/M longer-prefixes",
        !          11508:        SHOW_STR
        !          11509:        BGP_STR
        !          11510:        "Address family\n"
        !          11511:        "IPv6 prefix <network>/<length>\n"
        !          11512:        "Display route and more specific routes\n")
        !          11513: {
        !          11514:   return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
        !          11515:                                 bgp_show_type_prefix_longer);
        !          11516: }
        !          11517: 
        !          11518: static struct peer *
        !          11519: peer_lookup_in_view (struct vty *vty, const char *view_name, 
        !          11520:                      const char *ip_str)
        !          11521: {
        !          11522:   int ret;
        !          11523:   struct bgp *bgp;
        !          11524:   struct peer *peer;
        !          11525:   union sockunion su;
        !          11526: 
        !          11527:   /* BGP structure lookup. */
        !          11528:   if (view_name)
        !          11529:     {
        !          11530:       bgp = bgp_lookup_by_name (view_name);
        !          11531:       if (! bgp)
        !          11532:         {
        !          11533:           vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
        !          11534:           return NULL;
        !          11535:         }      
        !          11536:     }
        !          11537:   else
        !          11538:     {
        !          11539:       bgp = bgp_get_default ();
        !          11540:       if (! bgp)
        !          11541:         {
        !          11542:           vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
        !          11543:           return NULL;
        !          11544:         }
        !          11545:     }
        !          11546: 
        !          11547:   /* Get peer sockunion. */  
        !          11548:   ret = str2sockunion (ip_str, &su);
        !          11549:   if (ret < 0)
        !          11550:     {
        !          11551:       vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE);
        !          11552:       return NULL;
        !          11553:     }
        !          11554: 
        !          11555:   /* Peer structure lookup. */
        !          11556:   peer = peer_lookup (bgp, &su);
        !          11557:   if (! peer)
        !          11558:     {
        !          11559:       vty_out (vty, "No such neighbor%s", VTY_NEWLINE);
        !          11560:       return NULL;
        !          11561:     }
        !          11562:   
        !          11563:   return peer;
        !          11564: }
        !          11565: 
        !          11566: enum bgp_stats
        !          11567: {
        !          11568:   BGP_STATS_MAXBITLEN = 0,
        !          11569:   BGP_STATS_RIB,
        !          11570:   BGP_STATS_PREFIXES,
        !          11571:   BGP_STATS_TOTPLEN,
        !          11572:   BGP_STATS_UNAGGREGATEABLE,
        !          11573:   BGP_STATS_MAX_AGGREGATEABLE,
        !          11574:   BGP_STATS_AGGREGATES,
        !          11575:   BGP_STATS_SPACE,
        !          11576:   BGP_STATS_ASPATH_COUNT,
        !          11577:   BGP_STATS_ASPATH_MAXHOPS,
        !          11578:   BGP_STATS_ASPATH_TOTHOPS,
        !          11579:   BGP_STATS_ASPATH_MAXSIZE,
        !          11580:   BGP_STATS_ASPATH_TOTSIZE,
        !          11581:   BGP_STATS_ASN_HIGHEST,
        !          11582:   BGP_STATS_MAX,
        !          11583: };
        !          11584: 
        !          11585: static const char *table_stats_strs[] =
        !          11586: {
        !          11587:   [BGP_STATS_PREFIXES]            = "Total Prefixes",
        !          11588:   [BGP_STATS_TOTPLEN]             = "Average prefix length",
        !          11589:   [BGP_STATS_RIB]                 = "Total Advertisements",
        !          11590:   [BGP_STATS_UNAGGREGATEABLE]     = "Unaggregateable prefixes",
        !          11591:   [BGP_STATS_MAX_AGGREGATEABLE]   = "Maximum aggregateable prefixes",
        !          11592:   [BGP_STATS_AGGREGATES]          = "BGP Aggregate advertisements",
        !          11593:   [BGP_STATS_SPACE]               = "Address space advertised",
        !          11594:   [BGP_STATS_ASPATH_COUNT]        = "Advertisements with paths",
        !          11595:   [BGP_STATS_ASPATH_MAXHOPS]      = "Longest AS-Path (hops)",
        !          11596:   [BGP_STATS_ASPATH_MAXSIZE]      = "Largest AS-Path (bytes)",
        !          11597:   [BGP_STATS_ASPATH_TOTHOPS]      = "Average AS-Path length (hops)",
        !          11598:   [BGP_STATS_ASPATH_TOTSIZE]      = "Average AS-Path size (bytes)",
        !          11599:   [BGP_STATS_ASN_HIGHEST]         = "Highest public ASN",
        !          11600:   [BGP_STATS_MAX] = NULL,
        !          11601: };
        !          11602: 
        !          11603: struct bgp_table_stats
        !          11604: {
        !          11605:   struct bgp_table *table;
        !          11606:   unsigned long long counts[BGP_STATS_MAX];
        !          11607: };
        !          11608: 
        !          11609: #if 0
        !          11610: #define TALLY_SIGFIG 100000
        !          11611: static unsigned long
        !          11612: ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval)
        !          11613: {
        !          11614:   unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG);
        !          11615:   unsigned long res = (newtot * TALLY_SIGFIG) / count;
        !          11616:   unsigned long ret = newtot / count;
        !          11617:   
        !          11618:   if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2))
        !          11619:     return ret + 1;
        !          11620:   else
        !          11621:     return ret;
        !          11622: }
        !          11623: #endif
        !          11624: 
        !          11625: static int
        !          11626: bgp_table_stats_walker (struct thread *t)
        !          11627: {
        !          11628:   struct bgp_node *rn;
        !          11629:   struct bgp_node *top;
        !          11630:   struct bgp_table_stats *ts = THREAD_ARG (t);
        !          11631:   unsigned int space = 0;
        !          11632:   
        !          11633:   if (!(top = bgp_table_top (ts->table)))
        !          11634:     return 0;
        !          11635: 
        !          11636:   switch (top->p.family)
        !          11637:     {
        !          11638:       case AF_INET:
        !          11639:         space = IPV4_MAX_BITLEN;
        !          11640:         break;
        !          11641:       case AF_INET6:
        !          11642:         space = IPV6_MAX_BITLEN;
        !          11643:         break;
        !          11644:     }
        !          11645:     
        !          11646:   ts->counts[BGP_STATS_MAXBITLEN] = space;
        !          11647: 
        !          11648:   for (rn = top; rn; rn = bgp_route_next (rn))
        !          11649:     {
        !          11650:       struct bgp_info *ri;
        !          11651:       struct bgp_node *prn = bgp_node_parent_nolock (rn);
        !          11652:       unsigned int rinum = 0;
        !          11653:       
        !          11654:       if (rn == top)
        !          11655:         continue;
        !          11656:       
        !          11657:       if (!rn->info)
        !          11658:         continue;
        !          11659:       
        !          11660:       ts->counts[BGP_STATS_PREFIXES]++;
        !          11661:       ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen;
        !          11662: 
        !          11663: #if 0
        !          11664:       ts->counts[BGP_STATS_AVGPLEN]
        !          11665:         = ravg_tally (ts->counts[BGP_STATS_PREFIXES],
        !          11666:                       ts->counts[BGP_STATS_AVGPLEN],
        !          11667:                       rn->p.prefixlen);
        !          11668: #endif
        !          11669:       
        !          11670:       /* check if the prefix is included by any other announcements */
        !          11671:       while (prn && !prn->info)
        !          11672:         prn = bgp_node_parent_nolock (prn);
        !          11673:       
        !          11674:       if (prn == NULL || prn == top)
        !          11675:         {
        !          11676:           ts->counts[BGP_STATS_UNAGGREGATEABLE]++;
        !          11677:           /* announced address space */
        !          11678:           if (space)
        !          11679:             ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen);
        !          11680:         }
        !          11681:       else if (prn->info)
        !          11682:         ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++;
        !          11683:       
        !          11684:       for (ri = rn->info; ri; ri = ri->next)
        !          11685:         {
        !          11686:           rinum++;
        !          11687:           ts->counts[BGP_STATS_RIB]++;
        !          11688:           
        !          11689:           if (ri->attr &&
        !          11690:               (CHECK_FLAG (ri->attr->flag,
        !          11691:                            ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE))))
        !          11692:             ts->counts[BGP_STATS_AGGREGATES]++;
        !          11693:           
        !          11694:           /* as-path stats */
        !          11695:           if (ri->attr && ri->attr->aspath)
        !          11696:             {
        !          11697:               unsigned int hops = aspath_count_hops (ri->attr->aspath);
        !          11698:               unsigned int size = aspath_size (ri->attr->aspath);
        !          11699:               as_t highest = aspath_highest (ri->attr->aspath);
        !          11700:               
        !          11701:               ts->counts[BGP_STATS_ASPATH_COUNT]++;
        !          11702:               
        !          11703:               if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS])
        !          11704:                 ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops;
        !          11705:               
        !          11706:               if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE])
        !          11707:                 ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size;
        !          11708:               
        !          11709:               ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops;
        !          11710:               ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size;
        !          11711: #if 0
        !          11712:               ts->counts[BGP_STATS_ASPATH_AVGHOPS] 
        !          11713:                 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
        !          11714:                               ts->counts[BGP_STATS_ASPATH_AVGHOPS],
        !          11715:                               hops);
        !          11716:               ts->counts[BGP_STATS_ASPATH_AVGSIZE]
        !          11717:                 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
        !          11718:                               ts->counts[BGP_STATS_ASPATH_AVGSIZE],
        !          11719:                               size);
        !          11720: #endif
        !          11721:               if (highest > ts->counts[BGP_STATS_ASN_HIGHEST])
        !          11722:                 ts->counts[BGP_STATS_ASN_HIGHEST] = highest;
        !          11723:             }
        !          11724:         }
        !          11725:     }
        !          11726:   return 0;
        !          11727: }
        !          11728: 
        !          11729: static int
        !          11730: bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi)
        !          11731: {
        !          11732:   struct bgp_table_stats ts;
        !          11733:   unsigned int i;
        !          11734:   
        !          11735:   if (!bgp->rib[afi][safi])
        !          11736:     {
        !          11737:       vty_out (vty, "%% No RIB exists for the AFI/SAFI%s", VTY_NEWLINE);
        !          11738:       return CMD_WARNING;
        !          11739:     }
        !          11740:   
        !          11741:   memset (&ts, 0, sizeof (ts));
        !          11742:   ts.table = bgp->rib[afi][safi];
        !          11743:   thread_execute (bm->master, bgp_table_stats_walker, &ts, 0);
        !          11744: 
        !          11745:   vty_out (vty, "BGP %s RIB statistics%s%s",
        !          11746:            afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE);
        !          11747:   
        !          11748:   for (i = 0; i < BGP_STATS_MAX; i++)
        !          11749:     {
        !          11750:       if (!table_stats_strs[i])
        !          11751:         continue;
        !          11752:       
        !          11753:       switch (i)
        !          11754:         {
        !          11755: #if 0
        !          11756:           case BGP_STATS_ASPATH_AVGHOPS:
        !          11757:           case BGP_STATS_ASPATH_AVGSIZE:
        !          11758:           case BGP_STATS_AVGPLEN:
        !          11759:             vty_out (vty, "%-30s: ", table_stats_strs[i]);
        !          11760:             vty_out (vty, "%12.2f",
        !          11761:                      (float)ts.counts[i] / (float)TALLY_SIGFIG);
        !          11762:             break;
        !          11763: #endif
        !          11764:           case BGP_STATS_ASPATH_TOTHOPS:
        !          11765:           case BGP_STATS_ASPATH_TOTSIZE:
        !          11766:             vty_out (vty, "%-30s: ", table_stats_strs[i]);
        !          11767:             vty_out (vty, "%12.2f",
        !          11768:                      ts.counts[i] ?
        !          11769:                      (float)ts.counts[i] / 
        !          11770:                       (float)ts.counts[BGP_STATS_ASPATH_COUNT]
        !          11771:                      : 0);
        !          11772:             break;
        !          11773:           case BGP_STATS_TOTPLEN:
        !          11774:             vty_out (vty, "%-30s: ", table_stats_strs[i]);
        !          11775:             vty_out (vty, "%12.2f",
        !          11776:                      ts.counts[i] ?
        !          11777:                      (float)ts.counts[i] / 
        !          11778:                       (float)ts.counts[BGP_STATS_PREFIXES]
        !          11779:                      : 0);
        !          11780:             break;
        !          11781:           case BGP_STATS_SPACE:
        !          11782:             vty_out (vty, "%-30s: ", table_stats_strs[i]);
        !          11783:             vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE);
        !          11784:             if (ts.counts[BGP_STATS_MAXBITLEN] < 9)
        !          11785:               break;
        !          11786:             vty_out (vty, "%30s: ", "%% announced ");
        !          11787:             vty_out (vty, "%12.2f%s", 
        !          11788:                      100 * (float)ts.counts[BGP_STATS_SPACE] / 
        !          11789:                        (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]),
        !          11790:                        VTY_NEWLINE);
        !          11791:             vty_out (vty, "%30s: ", "/8 equivalent ");
        !          11792:             vty_out (vty, "%12.2f%s", 
        !          11793:                      (float)ts.counts[BGP_STATS_SPACE] / 
        !          11794:                        (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)),
        !          11795:                      VTY_NEWLINE);
        !          11796:             if (ts.counts[BGP_STATS_MAXBITLEN] < 25)
        !          11797:               break;
        !          11798:             vty_out (vty, "%30s: ", "/24 equivalent ");
        !          11799:             vty_out (vty, "%12.2f", 
        !          11800:                      (float)ts.counts[BGP_STATS_SPACE] / 
        !          11801:                        (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24)));
        !          11802:             break;
        !          11803:           default:
        !          11804:             vty_out (vty, "%-30s: ", table_stats_strs[i]);
        !          11805:             vty_out (vty, "%12llu", ts.counts[i]);
        !          11806:         }
        !          11807:         
        !          11808:       vty_out (vty, "%s", VTY_NEWLINE);
        !          11809:     }
        !          11810:   return CMD_SUCCESS;
        !          11811: }
        !          11812: 
        !          11813: static int
        !          11814: bgp_table_stats_vty (struct vty *vty, const char *name,
        !          11815:                      const char *afi_str, const char *safi_str)
        !          11816: {
        !          11817:   struct bgp *bgp;
        !          11818:   afi_t afi;
        !          11819:   safi_t safi;
        !          11820:   
        !          11821:  if (name)
        !          11822:     bgp = bgp_lookup_by_name (name);
        !          11823:   else
        !          11824:     bgp = bgp_get_default ();
        !          11825: 
        !          11826:   if (!bgp)
        !          11827:     {
        !          11828:       vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE);
        !          11829:       return CMD_WARNING;
        !          11830:     }
        !          11831:   if (strncmp (afi_str, "ipv", 3) == 0)
        !          11832:     {
        !          11833:       if (strncmp (afi_str, "ipv4", 4) == 0)
        !          11834:         afi = AFI_IP;
        !          11835:       else if (strncmp (afi_str, "ipv6", 4) == 0)
        !          11836:         afi = AFI_IP6;
        !          11837:       else
        !          11838:         {
        !          11839:           vty_out (vty, "%% Invalid address family %s%s",
        !          11840:                    afi_str, VTY_NEWLINE);
        !          11841:           return CMD_WARNING;
        !          11842:         }
        !          11843:       switch (safi_str[0]) {
        !          11844:        case 'm':
        !          11845:            safi = SAFI_MULTICAST;
        !          11846:            break;
        !          11847:        case 'u':
        !          11848:            safi = SAFI_UNICAST;
        !          11849:            break;
        !          11850:        case 'v':
        !          11851:            safi =  SAFI_MPLS_LABELED_VPN;
        !          11852:            break;
        !          11853:        case 'e':
        !          11854:            safi = SAFI_ENCAP;
        !          11855:            break;
        !          11856:        default:
        !          11857:            vty_out (vty, "%% Invalid subsequent address family %s%s",
        !          11858:                    safi_str, VTY_NEWLINE);
        !          11859:             return CMD_WARNING;
        !          11860:       }
        !          11861:     }
        !          11862:   else
        !          11863:     {
        !          11864:       vty_out (vty, "%% Invalid address family \"%s\"%s",
        !          11865:                afi_str, VTY_NEWLINE);
        !          11866:       return CMD_WARNING;
        !          11867:     }
        !          11868: 
        !          11869:   return bgp_table_stats (vty, bgp, afi, safi);
        !          11870: }
        !          11871: 
        !          11872: DEFUN (show_bgp_statistics,
        !          11873:        show_bgp_statistics_cmd,
        !          11874:        "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
        !          11875:        SHOW_STR
        !          11876:        BGP_STR
        !          11877:        "Address family\n"
        !          11878:        "Address family\n"
        !          11879:        "Address Family modifier\n"
        !          11880:        "Address Family modifier\n"
        !          11881:        "Address Family modifier\n"
        !          11882:        "Address Family modifier\n"
        !          11883:        "BGP RIB advertisement statistics\n")
        !          11884: {
        !          11885:   return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
        !          11886: }
        !          11887: 
        !          11888: ALIAS (show_bgp_statistics,
        !          11889:        show_bgp_statistics_vpnv4_cmd,
        !          11890:        "show bgp (ipv4) (vpnv4) statistics",
        !          11891:        SHOW_STR
        !          11892:        BGP_STR
        !          11893:        "Address family\n"
        !          11894:        "Address Family modifier\n"
        !          11895:        "BGP RIB advertisement statistics\n")
        !          11896: 
        !          11897: DEFUN (show_bgp_statistics_view,
        !          11898:        show_bgp_statistics_view_cmd,
        !          11899:        "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
        !          11900:        SHOW_STR
        !          11901:        BGP_STR
        !          11902:        "BGP view\n"
        !          11903:        "Address family\n"
        !          11904:        "Address family\n"
        !          11905:        "Address Family modifier\n"
        !          11906:        "Address Family modifier\n"
        !          11907:        "Address Family modifier\n"
        !          11908:        "Address Family modifier\n"
        !          11909:        "BGP RIB advertisement statistics\n")
        !          11910: {
        !          11911:   return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
        !          11912: }
        !          11913: 
        !          11914: ALIAS (show_bgp_statistics_view,
        !          11915:        show_bgp_statistics_view_vpnv4_cmd,
        !          11916:        "show bgp view WORD (ipv4) (vpnv4) statistics",
        !          11917:        SHOW_STR
        !          11918:        BGP_STR
        !          11919:        "BGP view\n"
        !          11920:        "Address family\n"
        !          11921:        "Address Family modifier\n"
        !          11922:        "BGP RIB advertisement statistics\n")
        !          11923: 
        !          11924: enum bgp_pcounts
        !          11925: {
        !          11926:   PCOUNT_ADJ_IN = 0,
        !          11927:   PCOUNT_DAMPED,
        !          11928:   PCOUNT_REMOVED,
        !          11929:   PCOUNT_HISTORY,
        !          11930:   PCOUNT_STALE,
        !          11931:   PCOUNT_VALID,
        !          11932:   PCOUNT_ALL,
        !          11933:   PCOUNT_COUNTED,
        !          11934:   PCOUNT_PFCNT, /* the figure we display to users */
        !          11935:   PCOUNT_MAX,
        !          11936: };
        !          11937: 
        !          11938: static const char *pcount_strs[] =
        !          11939: {
        !          11940:   [PCOUNT_ADJ_IN]  = "Adj-in",
        !          11941:   [PCOUNT_DAMPED]  = "Damped",
        !          11942:   [PCOUNT_REMOVED] = "Removed",
        !          11943:   [PCOUNT_HISTORY] = "History",
        !          11944:   [PCOUNT_STALE]   = "Stale",
        !          11945:   [PCOUNT_VALID]   = "Valid",
        !          11946:   [PCOUNT_ALL]     = "All RIB",
        !          11947:   [PCOUNT_COUNTED] = "PfxCt counted",
        !          11948:   [PCOUNT_PFCNT]   = "Useable",
        !          11949:   [PCOUNT_MAX]     = NULL,
        !          11950: };
        !          11951: 
        !          11952: struct peer_pcounts
        !          11953: {
        !          11954:   unsigned int count[PCOUNT_MAX];
        !          11955:   const struct peer *peer;
        !          11956:   const struct bgp_table *table;
        !          11957: };
        !          11958: 
        !          11959: static int
        !          11960: bgp_peer_count_walker (struct thread *t)
        !          11961: {
        !          11962:   struct bgp_node *rn;
        !          11963:   struct peer_pcounts *pc = THREAD_ARG (t);
        !          11964:   const struct peer *peer = pc->peer;
        !          11965:   
        !          11966:   for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn))
        !          11967:     {
        !          11968:       struct bgp_adj_in *ain;
        !          11969:       struct bgp_info *ri;
        !          11970:       
        !          11971:       for (ain = rn->adj_in; ain; ain = ain->next)
        !          11972:         if (ain->peer == peer)
        !          11973:           pc->count[PCOUNT_ADJ_IN]++;
        !          11974: 
        !          11975:       for (ri = rn->info; ri; ri = ri->next)
        !          11976:         {
        !          11977:           char buf[SU_ADDRSTRLEN];
        !          11978:           
        !          11979:           if (ri->peer != peer)
        !          11980:             continue;
        !          11981:           
        !          11982:           pc->count[PCOUNT_ALL]++;
        !          11983:           
        !          11984:           if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED))
        !          11985:             pc->count[PCOUNT_DAMPED]++;
        !          11986:           if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
        !          11987:             pc->count[PCOUNT_HISTORY]++;
        !          11988:           if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED))
        !          11989:             pc->count[PCOUNT_REMOVED]++;
        !          11990:           if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
        !          11991:             pc->count[PCOUNT_STALE]++;
        !          11992:           if (CHECK_FLAG (ri->flags, BGP_INFO_VALID))
        !          11993:             pc->count[PCOUNT_VALID]++;
        !          11994:           if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
        !          11995:             pc->count[PCOUNT_PFCNT]++;
        !          11996:           
        !          11997:           if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
        !          11998:             {
        !          11999:               pc->count[PCOUNT_COUNTED]++;
        !          12000:               if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
        !          12001:                 plog_warn (peer->log,
        !          12002:                            "%s [pcount] %s/%d is counted but flags 0x%x",
        !          12003:                            peer->host,
        !          12004:                            inet_ntop(rn->p.family, &rn->p.u.prefix,
        !          12005:                                      buf, SU_ADDRSTRLEN),
        !          12006:                            rn->p.prefixlen,
        !          12007:                            ri->flags);
        !          12008:             }
        !          12009:           else
        !          12010:             {
        !          12011:               if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
        !          12012:                 plog_warn (peer->log,
        !          12013:                            "%s [pcount] %s/%d not counted but flags 0x%x",
        !          12014:                            peer->host,
        !          12015:                            inet_ntop(rn->p.family, &rn->p.u.prefix,
        !          12016:                                      buf, SU_ADDRSTRLEN),
        !          12017:                            rn->p.prefixlen,
        !          12018:                            ri->flags);
        !          12019:             }
        !          12020:         }
        !          12021:     }
        !          12022:   return 0;
        !          12023: }
        !          12024: 
        !          12025: static int
        !          12026: bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi)
        !          12027: {
        !          12028:   struct peer_pcounts pcounts = { .peer = peer };
        !          12029:   unsigned int i;
        !          12030:   
        !          12031:   if (!peer || !peer->bgp || !peer->afc[afi][safi]
        !          12032:       || !peer->bgp->rib[afi][safi])
        !          12033:     {
        !          12034:       vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
        !          12035:       return CMD_WARNING;
        !          12036:     }
        !          12037:   
        !          12038:   memset (&pcounts, 0, sizeof(pcounts));
        !          12039:   pcounts.peer = peer;
        !          12040:   pcounts.table = peer->bgp->rib[afi][safi];
        !          12041:   
        !          12042:   /* in-place call via thread subsystem so as to record execution time
        !          12043:    * stats for the thread-walk (i.e. ensure this can't be blamed on
        !          12044:    * on just vty_read()).
        !          12045:    */
        !          12046:   thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0);
        !          12047:   
        !          12048:   vty_out (vty, "Prefix counts for %s, %s%s", 
        !          12049:            peer->host, afi_safi_print (afi, safi), VTY_NEWLINE);
        !          12050:   vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE);
        !          12051:   vty_out (vty, "%sCounts from RIB table walk:%s%s", 
        !          12052:            VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
        !          12053: 
        !          12054:   for (i = 0; i < PCOUNT_MAX; i++)
        !          12055:       vty_out (vty, "%20s: %-10d%s",
        !          12056:                pcount_strs[i], pcounts.count[i], VTY_NEWLINE);
        !          12057: 
        !          12058:   if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi])
        !          12059:     {
        !          12060:       vty_out (vty, "%s [pcount] PfxCt drift!%s",
        !          12061:                peer->host, VTY_NEWLINE);
        !          12062:       vty_out (vty, "Please report this bug, with the above command output%s",
        !          12063:               VTY_NEWLINE);
        !          12064:     }
        !          12065:                
        !          12066:   return CMD_SUCCESS;
        !          12067: }
        !          12068: 
        !          12069: DEFUN (show_ip_bgp_neighbor_prefix_counts,
        !          12070:        show_ip_bgp_neighbor_prefix_counts_cmd,
        !          12071:        "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
        !          12072:        SHOW_STR
        !          12073:        IP_STR
        !          12074:        BGP_STR
        !          12075:        "Detailed information on TCP and BGP neighbor connections\n"
        !          12076:        "Neighbor to display information about\n"
        !          12077:        "Neighbor to display information about\n"
        !          12078:        "Display detailed prefix count information\n")
        !          12079: {
        !          12080:   struct peer *peer;
        !          12081: 
        !          12082:   peer = peer_lookup_in_view (vty, NULL, argv[0]);  
        !          12083:   if (! peer) 
        !          12084:     return CMD_WARNING;
        !          12085:  
        !          12086:   return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
        !          12087: }
        !          12088: 
        !          12089: DEFUN (show_bgp_ipv6_neighbor_prefix_counts,
        !          12090:        show_bgp_ipv6_neighbor_prefix_counts_cmd,
        !          12091:        "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
        !          12092:        SHOW_STR
        !          12093:        BGP_STR
        !          12094:        "Address family\n"
        !          12095:        "Detailed information on TCP and BGP neighbor connections\n"
        !          12096:        "Neighbor to display information about\n"
        !          12097:        "Neighbor to display information about\n"
        !          12098:        "Display detailed prefix count information\n")
        !          12099: {
        !          12100:   struct peer *peer;
        !          12101: 
        !          12102:   peer = peer_lookup_in_view (vty, NULL, argv[0]);  
        !          12103:   if (! peer) 
        !          12104:     return CMD_WARNING;
        !          12105:  
        !          12106:   return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST);
        !          12107: }
        !          12108: 
        !          12109: DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts,
        !          12110:        show_ip_bgp_ipv4_neighbor_prefix_counts_cmd,
        !          12111:        "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
        !          12112:        SHOW_STR
        !          12113:        IP_STR
        !          12114:        BGP_STR
        !          12115:        "Address family\n"
        !          12116:        "Address Family modifier\n"
        !          12117:        "Address Family modifier\n"
        !          12118:        "Detailed information on TCP and BGP neighbor connections\n"
        !          12119:        "Neighbor to display information about\n"
        !          12120:        "Neighbor to display information about\n"
        !          12121:        "Display detailed prefix count information\n")
        !          12122: {
        !          12123:   struct peer *peer;
        !          12124: 
        !          12125:   peer = peer_lookup_in_view (vty, NULL, argv[1]);
        !          12126:   if (! peer)
        !          12127:     return CMD_WARNING;
        !          12128: 
        !          12129:   if (strncmp (argv[0], "m", 1) == 0)
        !          12130:     return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST);
        !          12131: 
        !          12132:   return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
        !          12133: }
        !          12134: 
        !          12135: DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts,
        !          12136:        show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd,
        !          12137:        "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
        !          12138:        SHOW_STR
        !          12139:        IP_STR
        !          12140:        BGP_STR
        !          12141:        "Address family\n"
        !          12142:        "Address Family modifier\n"
        !          12143:        "Address Family modifier\n"
        !          12144:        "Detailed information on TCP and BGP neighbor connections\n"
        !          12145:        "Neighbor to display information about\n"
        !          12146:        "Neighbor to display information about\n"
        !          12147:        "Display detailed prefix count information\n")
        !          12148: {
        !          12149:   struct peer *peer;
        !          12150: 
        !          12151:   peer = peer_lookup_in_view (vty, NULL, argv[0]);
        !          12152:   if (! peer)
        !          12153:     return CMD_WARNING;
        !          12154:   
        !          12155:   return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN);
        !          12156: }
        !          12157: 
        !          12158: DEFUN (show_bgp_ipv4_safi_neighbor_prefix_counts,
        !          12159:        show_bgp_ipv4_safi_neighbor_prefix_counts_cmd,
        !          12160:        "show bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
        !          12161:        SHOW_STR
        !          12162:        BGP_STR
        !          12163:        "Address family\n"
        !          12164:        "Address Family modifier\n"
        !          12165:        "Address Family modifier\n"
        !          12166:        "Address Family modifier\n"
        !          12167:        "Address Family modifier\n"
        !          12168:        "Detailed information on TCP and BGP neighbor connections\n"
        !          12169:        "Neighbor to display information about\n"
        !          12170:        "Neighbor to display information about\n"
        !          12171:        "Display detailed prefix count information\n")
        !          12172: {
        !          12173:   struct peer *peer;
        !          12174:   safi_t       safi;
        !          12175: 
        !          12176:   if (bgp_parse_safi(argv[0], &safi)) {
        !          12177:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          12178:     return CMD_WARNING;
        !          12179:   }
        !          12180: 
        !          12181:   peer = peer_lookup_in_view (vty, NULL, argv[1]);
        !          12182:   if (! peer)
        !          12183:     return CMD_WARNING;
        !          12184: 
        !          12185:   return bgp_peer_counts (vty, peer, AFI_IP, safi);
1.1       misho    12186: }
                   12187: 
1.1.1.4 ! misho    12188: DEFUN (show_bgp_ipv6_safi_neighbor_prefix_counts,
        !          12189:        show_bgp_ipv6_safi_neighbor_prefix_counts_cmd,
        !          12190:        "show bgp ipv6 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
        !          12191:        SHOW_STR
        !          12192:        BGP_STR
        !          12193:        "Address family\n"
        !          12194:        "Address Family modifier\n"
        !          12195:        "Address Family modifier\n"
        !          12196:        "Address Family modifier\n"
        !          12197:        "Address Family modifier\n"
        !          12198:        "Detailed information on TCP and BGP neighbor connections\n"
        !          12199:        "Neighbor to display information about\n"
        !          12200:        "Neighbor to display information about\n"
        !          12201:        "Display detailed prefix count information\n")
1.1       misho    12202: {
                   12203:   struct peer *peer;
1.1.1.4 ! misho    12204:   safi_t       safi;
1.1       misho    12205: 
1.1.1.4 ! misho    12206:   if (bgp_parse_safi(argv[0], &safi)) {
        !          12207:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          12208:     return CMD_WARNING;
        !          12209:   }
1.1       misho    12210: 
1.1.1.4 ! misho    12211:   peer = peer_lookup_in_view (vty, NULL, argv[1]);
1.1       misho    12212:   if (! peer)
1.1.1.4 ! misho    12213:     return CMD_WARNING;
1.1       misho    12214: 
1.1.1.4 ! misho    12215:   return bgp_peer_counts (vty, peer, AFI_IP6, safi);
        !          12216: }
1.1       misho    12217: 
1.1.1.4 ! misho    12218: DEFUN (show_ip_bgp_encap_neighbor_prefix_counts,
        !          12219:        show_ip_bgp_encap_neighbor_prefix_counts_cmd,
        !          12220:        "show ip bgp encap all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
        !          12221:        SHOW_STR
        !          12222:        IP_STR
        !          12223:        BGP_STR
        !          12224:        "Address family\n"
        !          12225:        "Address Family modifier\n"
        !          12226:        "Address Family modifier\n"
        !          12227:        "Detailed information on TCP and BGP neighbor connections\n"
        !          12228:        "Neighbor to display information about\n"
        !          12229:        "Neighbor to display information about\n"
        !          12230:        "Display detailed prefix count information\n")
1.1       misho    12231: {
1.1.1.4 ! misho    12232:   struct peer *peer;
1.1       misho    12233: 
1.1.1.4 ! misho    12234:   peer = peer_lookup_in_view (vty, NULL, argv[0]);
        !          12235:   if (! peer)
        !          12236:     return CMD_WARNING;
1.1       misho    12237:   
1.1.1.4 ! misho    12238:   return bgp_peer_counts (vty, peer, AFI_IP, SAFI_ENCAP);
1.1       misho    12239: }
                   12240: 
1.1.1.4 ! misho    12241: 
        !          12242: static void
        !          12243: show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi,
        !          12244:                int in)
1.1       misho    12245: {
1.1.1.4 ! misho    12246:   struct bgp_table *table;
        !          12247:   struct bgp_adj_in *ain;
        !          12248:   struct bgp_adj_out *adj;
        !          12249:   unsigned long output_count;
1.1       misho    12250:   struct bgp_node *rn;
1.1.1.4 ! misho    12251:   int header1 = 1;
        !          12252:   struct bgp *bgp;
        !          12253:   int header2 = 1;
1.1       misho    12254: 
1.1.1.4 ! misho    12255:   bgp = peer->bgp;
1.1       misho    12256: 
1.1.1.4 ! misho    12257:   if (! bgp)
        !          12258:     return;
1.1       misho    12259: 
1.1.1.4 ! misho    12260:   table = bgp->rib[afi][safi];
        !          12261: 
        !          12262:   output_count = 0;
        !          12263:        
        !          12264:   if (! in && CHECK_FLAG (peer->af_sflags[afi][safi],
        !          12265:                          PEER_STATUS_DEFAULT_ORIGINATE))
        !          12266:     {
        !          12267:       vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE);
        !          12268:       vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
        !          12269:       vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
        !          12270: 
        !          12271:       vty_out (vty, "Originating default network 0.0.0.0%s%s",
        !          12272:               VTY_NEWLINE, VTY_NEWLINE);
        !          12273:       header1 = 0;
1.1       misho    12274:     }
1.1.1.4 ! misho    12275: 
        !          12276:   for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
        !          12277:     if (in)
        !          12278:       {
        !          12279:        for (ain = rn->adj_in; ain; ain = ain->next)
        !          12280:          if (ain->peer == peer)
        !          12281:            {
        !          12282:              if (header1)
        !          12283:                {
        !          12284:                  vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE);
        !          12285:                  vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
        !          12286:                  vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
        !          12287:                  header1 = 0;
        !          12288:                }
        !          12289:              if (header2)
        !          12290:                {
        !          12291:                  vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
        !          12292:                  header2 = 0;
        !          12293:                }
        !          12294:              if (ain->attr)
        !          12295:                { 
        !          12296:                  route_vty_out_tmp (vty, &rn->p, ain->attr, safi);
        !          12297:                  output_count++;
        !          12298:                }
        !          12299:            }
        !          12300:       }
        !          12301:     else
        !          12302:       {
        !          12303:        for (adj = rn->adj_out; adj; adj = adj->next)
        !          12304:          if (adj->peer == peer)
        !          12305:            {
        !          12306:              if (header1)
        !          12307:                {
        !          12308:                  vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE);
        !          12309:                  vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
        !          12310:                  vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
        !          12311:                  header1 = 0;
        !          12312:                }
        !          12313:              if (header2)
        !          12314:                {
        !          12315:                  vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
        !          12316:                  header2 = 0;
        !          12317:                }
        !          12318:              if (adj->attr)
        !          12319:                {       
        !          12320:                  route_vty_out_tmp (vty, &rn->p, adj->attr, safi);
        !          12321:                  output_count++;
        !          12322:                }
        !          12323:            }
        !          12324:       }
        !          12325:   
        !          12326:   if (output_count != 0)
        !          12327:     vty_out (vty, "%sTotal number of prefixes %ld%s",
        !          12328:             VTY_NEWLINE, output_count, VTY_NEWLINE);
1.1       misho    12329: }
                   12330: 
                   12331: static int
1.1.1.4 ! misho    12332: peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in)
        !          12333: {    
        !          12334:   if (! peer || ! peer->afc[afi][safi])
1.1       misho    12335:     {
1.1.1.4 ! misho    12336:       vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
1.1       misho    12337:       return CMD_WARNING;
                   12338:     }
                   12339: 
1.1.1.4 ! misho    12340:   if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
1.1       misho    12341:     {
1.1.1.4 ! misho    12342:       vty_out (vty, "%% Inbound soft reconfiguration not enabled%s",
        !          12343:               VTY_NEWLINE);
        !          12344:       return CMD_WARNING;
1.1       misho    12345:     }
1.1.1.4 ! misho    12346: 
        !          12347:   show_adj_route (vty, peer, afi, safi, in);
        !          12348: 
1.1       misho    12349:   return CMD_SUCCESS;
                   12350: }
                   12351: 
1.1.1.4 ! misho    12352: DEFUN (show_ip_bgp_view_neighbor_advertised_route,
        !          12353:        show_ip_bgp_view_neighbor_advertised_route_cmd,
        !          12354:        "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
        !          12355:        SHOW_STR
        !          12356:        IP_STR
        !          12357:        BGP_STR
        !          12358:        "BGP view\n"
        !          12359:        "View name\n"
        !          12360:        "Detailed information on TCP and BGP neighbor connections\n"
        !          12361:        "Neighbor to display information about\n"
        !          12362:        "Neighbor to display information about\n"
        !          12363:        "Display the routes advertised to a BGP neighbor\n")
1.1       misho    12364: {
1.1.1.4 ! misho    12365:   struct peer *peer;
1.1       misho    12366: 
1.1.1.4 ! misho    12367:   if (argc == 2)
        !          12368:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
1.1       misho    12369:   else
1.1.1.4 ! misho    12370:     peer = peer_lookup_in_view (vty, NULL, argv[0]);
        !          12371: 
        !          12372:   if (! peer) 
        !          12373:     return CMD_WARNING;
        !          12374:  
        !          12375:   return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
        !          12376: }
        !          12377: 
        !          12378: ALIAS (show_ip_bgp_view_neighbor_advertised_route,
        !          12379:        show_ip_bgp_neighbor_advertised_route_cmd,
        !          12380:        "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
        !          12381:        SHOW_STR
        !          12382:        IP_STR
        !          12383:        BGP_STR
        !          12384:        "Detailed information on TCP and BGP neighbor connections\n"
        !          12385:        "Neighbor to display information about\n"
        !          12386:        "Neighbor to display information about\n"
        !          12387:        "Display the routes advertised to a BGP neighbor\n")
        !          12388: 
        !          12389: DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route,
        !          12390:        show_ip_bgp_ipv4_neighbor_advertised_route_cmd,
        !          12391:        "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
        !          12392:        SHOW_STR
        !          12393:        IP_STR
        !          12394:        BGP_STR
        !          12395:        "Address family\n"
        !          12396:        "Address Family modifier\n"
        !          12397:        "Address Family modifier\n"
        !          12398:        "Detailed information on TCP and BGP neighbor connections\n"
        !          12399:        "Neighbor to display information about\n"
        !          12400:        "Neighbor to display information about\n"
        !          12401:        "Display the routes advertised to a BGP neighbor\n")
        !          12402: {
        !          12403:   struct peer *peer;
        !          12404: 
        !          12405:   peer = peer_lookup_in_view (vty, NULL, argv[1]);
        !          12406:   if (! peer)
        !          12407:     return CMD_WARNING;
        !          12408: 
        !          12409:   if (strncmp (argv[0], "m", 1) == 0)
        !          12410:     return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0);
        !          12411: 
        !          12412:   return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
        !          12413: }
        !          12414: 
        !          12415: DEFUN (show_bgp_view_neighbor_advertised_route,
        !          12416:        show_bgp_view_neighbor_advertised_route_cmd,
        !          12417:        "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
        !          12418:        SHOW_STR
        !          12419:        BGP_STR
        !          12420:        "BGP view\n"
        !          12421:        "View name\n"
        !          12422:        "Detailed information on TCP and BGP neighbor connections\n"
        !          12423:        "Neighbor to display information about\n"
        !          12424:        "Neighbor to display information about\n"
        !          12425:        "Display the routes advertised to a BGP neighbor\n")
        !          12426: {
        !          12427:   struct peer *peer;
        !          12428: 
        !          12429:   if (argc == 2)
        !          12430:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
        !          12431:   else
        !          12432:     peer = peer_lookup_in_view (vty, NULL, argv[0]);
1.1       misho    12433: 
1.1.1.4 ! misho    12434:   if (! peer)
        !          12435:     return CMD_WARNING;    
        !          12436: 
        !          12437:   return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
1.1       misho    12438: }
                   12439: 
1.1.1.4 ! misho    12440: DEFUN (show_bgp_view_neighbor_received_routes,
        !          12441:        show_bgp_view_neighbor_received_routes_cmd,
        !          12442:        "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
1.1       misho    12443:        SHOW_STR
                   12444:        BGP_STR
1.1.1.4 ! misho    12445:        "BGP view\n"
        !          12446:        "View name\n"
        !          12447:        "Detailed information on TCP and BGP neighbor connections\n"
        !          12448:        "Neighbor to display information about\n"
        !          12449:        "Neighbor to display information about\n"
        !          12450:        "Display the received routes from neighbor\n")
1.1       misho    12451: {
1.1.1.4 ! misho    12452:   struct peer *peer;
        !          12453: 
        !          12454:   if (argc == 2)
        !          12455:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
        !          12456:   else
        !          12457:     peer = peer_lookup_in_view (vty, NULL, argv[0]);
        !          12458: 
        !          12459:   if (! peer)
        !          12460:     return CMD_WARNING;
        !          12461: 
        !          12462:   return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
1.1       misho    12463: }
                   12464: 
1.1.1.4 ! misho    12465: ALIAS (show_bgp_view_neighbor_advertised_route,
        !          12466:        show_bgp_neighbor_advertised_route_cmd,
        !          12467:        "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
1.1       misho    12468:        SHOW_STR
                   12469:        BGP_STR
1.1.1.4 ! misho    12470:        "Detailed information on TCP and BGP neighbor connections\n"
        !          12471:        "Neighbor to display information about\n"
        !          12472:        "Neighbor to display information about\n"
        !          12473:        "Display the routes advertised to a BGP neighbor\n")
        !          12474:        
        !          12475: ALIAS (show_bgp_view_neighbor_advertised_route,
        !          12476:        show_bgp_ipv6_neighbor_advertised_route_cmd,
        !          12477:        "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
1.1       misho    12478:        SHOW_STR
                   12479:        BGP_STR
                   12480:        "Address family\n"
1.1.1.4 ! misho    12481:        "Detailed information on TCP and BGP neighbor connections\n"
        !          12482:        "Neighbor to display information about\n"
        !          12483:        "Neighbor to display information about\n"
        !          12484:        "Display the routes advertised to a BGP neighbor\n")
1.1       misho    12485: 
1.1.1.4 ! misho    12486: /* old command */
        !          12487: ALIAS (show_bgp_view_neighbor_advertised_route,
        !          12488:        ipv6_bgp_neighbor_advertised_route_cmd,
        !          12489:        "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
1.1       misho    12490:        SHOW_STR
1.1.1.4 ! misho    12491:        IPV6_STR
1.1       misho    12492:        BGP_STR
1.1.1.4 ! misho    12493:        "Detailed information on TCP and BGP neighbor connections\n"
        !          12494:        "Neighbor to display information about\n"
        !          12495:        "Neighbor to display information about\n"
        !          12496:        "Display the routes advertised to a BGP neighbor\n")
        !          12497:   
        !          12498: /* old command */
        !          12499: DEFUN (ipv6_mbgp_neighbor_advertised_route,
        !          12500:        ipv6_mbgp_neighbor_advertised_route_cmd,
        !          12501:        "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
        !          12502:        SHOW_STR
        !          12503:        IPV6_STR
        !          12504:        MBGP_STR
        !          12505:        "Detailed information on TCP and BGP neighbor connections\n"
        !          12506:        "Neighbor to display information about\n"
        !          12507:        "Neighbor to display information about\n"
        !          12508:        "Display the routes advertised to a BGP neighbor\n")
1.1       misho    12509: {
1.1.1.4 ! misho    12510:   struct peer *peer;
1.1       misho    12511: 
1.1.1.4 ! misho    12512:   peer = peer_lookup_in_view (vty, NULL, argv[0]);
        !          12513:   if (! peer)
        !          12514:     return CMD_WARNING;  
1.1       misho    12515: 
1.1.1.4 ! misho    12516:   return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0);
1.1       misho    12517: }
                   12518: 
1.1.1.4 ! misho    12519: DEFUN (show_ip_bgp_view_neighbor_received_routes,
        !          12520:        show_ip_bgp_view_neighbor_received_routes_cmd,
        !          12521:        "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
        !          12522:        SHOW_STR
        !          12523:        IP_STR
        !          12524:        BGP_STR
        !          12525:        "BGP view\n"
        !          12526:        "View name\n"
        !          12527:        "Detailed information on TCP and BGP neighbor connections\n"
        !          12528:        "Neighbor to display information about\n"
        !          12529:        "Neighbor to display information about\n"
        !          12530:        "Display the received routes from neighbor\n")
1.1       misho    12531: {
1.1.1.4 ! misho    12532:   struct peer *peer;
1.1       misho    12533: 
1.1.1.4 ! misho    12534:   if (argc == 2)
        !          12535:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
        !          12536:   else
        !          12537:     peer = peer_lookup_in_view (vty, NULL, argv[0]);
1.1       misho    12538: 
1.1.1.4 ! misho    12539:   if (! peer)
        !          12540:     return CMD_WARNING;
        !          12541: 
        !          12542:   return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
1.1       misho    12543: }
                   12544: 
1.1.1.4 ! misho    12545: ALIAS (show_ip_bgp_view_neighbor_received_routes,
        !          12546:        show_ip_bgp_neighbor_received_routes_cmd,
        !          12547:        "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
1.1       misho    12548:        SHOW_STR
                   12549:        IP_STR
                   12550:        BGP_STR
                   12551:        "Detailed information on TCP and BGP neighbor connections\n"
                   12552:        "Neighbor to display information about\n"
                   12553:        "Neighbor to display information about\n"
1.1.1.4 ! misho    12554:        "Display the received routes from neighbor\n")
1.1       misho    12555: 
1.1.1.4 ! misho    12556: ALIAS (show_bgp_view_neighbor_received_routes,
        !          12557:        show_bgp_ipv6_neighbor_received_routes_cmd,
        !          12558:        "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
1.1       misho    12559:        SHOW_STR
                   12560:        BGP_STR
                   12561:        "Address family\n"
                   12562:        "Detailed information on TCP and BGP neighbor connections\n"
                   12563:        "Neighbor to display information about\n"
                   12564:        "Neighbor to display information about\n"
1.1.1.4 ! misho    12565:        "Display the received routes from neighbor\n")
1.1       misho    12566: 
1.1.1.4 ! misho    12567: DEFUN (show_bgp_neighbor_received_prefix_filter,
        !          12568:        show_bgp_neighbor_received_prefix_filter_cmd,
        !          12569:        "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
1.1       misho    12570:        SHOW_STR
                   12571:        BGP_STR
                   12572:        "Detailed information on TCP and BGP neighbor connections\n"
                   12573:        "Neighbor to display information about\n"
                   12574:        "Neighbor to display information about\n"
1.1.1.4 ! misho    12575:        "Display information received from a BGP neighbor\n"
        !          12576:        "Display the prefixlist filter\n")
1.1       misho    12577: {
1.1.1.4 ! misho    12578:   char name[BUFSIZ];
        !          12579:   union sockunion su;
1.1       misho    12580:   struct peer *peer;
1.1.1.4 ! misho    12581:   int count, ret;
1.1       misho    12582: 
1.1.1.4 ! misho    12583:   ret = str2sockunion (argv[0], &su);
        !          12584:   if (ret < 0)
        !          12585:     {
        !          12586:       vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
        !          12587:       return CMD_WARNING;
        !          12588:     }
        !          12589: 
        !          12590:   peer = peer_lookup (NULL, &su);
1.1       misho    12591:   if (! peer)
                   12592:     return CMD_WARNING;
                   12593: 
1.1.1.4 ! misho    12594:   sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
        !          12595:   count =  prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
        !          12596:   if (count)
        !          12597:     {
        !          12598:       vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
        !          12599:       prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
        !          12600:     }
1.1       misho    12601: 
1.1.1.4 ! misho    12602:   return CMD_SUCCESS;
1.1       misho    12603: }
                   12604: 
1.1.1.4 ! misho    12605: /* old command */
        !          12606: ALIAS (show_bgp_view_neighbor_received_routes,
        !          12607:        ipv6_bgp_neighbor_received_routes_cmd,
        !          12608:        "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
1.1       misho    12609:        SHOW_STR
1.1.1.4 ! misho    12610:        IPV6_STR
1.1       misho    12611:        BGP_STR
                   12612:        "Detailed information on TCP and BGP neighbor connections\n"
                   12613:        "Neighbor to display information about\n"
                   12614:        "Neighbor to display information about\n"
1.1.1.4 ! misho    12615:        "Display the received routes from neighbor\n")
        !          12616: 
        !          12617: /* old command */
        !          12618: DEFUN (ipv6_mbgp_neighbor_received_routes,
        !          12619:        ipv6_mbgp_neighbor_received_routes_cmd,
        !          12620:        "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
        !          12621:        SHOW_STR
        !          12622:        IPV6_STR
        !          12623:        MBGP_STR
        !          12624:        "Detailed information on TCP and BGP neighbor connections\n"
        !          12625:        "Neighbor to display information about\n"
        !          12626:        "Neighbor to display information about\n"
        !          12627:        "Display the received routes from neighbor\n")
1.1       misho    12628: {
                   12629:   struct peer *peer;
                   12630: 
                   12631:   peer = peer_lookup_in_view (vty, NULL, argv[0]);
                   12632:   if (! peer)
                   12633:     return CMD_WARNING;
                   12634: 
1.1.1.4 ! misho    12635:   return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1);
1.1       misho    12636: }
                   12637: 
1.1.1.4 ! misho    12638: DEFUN (show_bgp_view_neighbor_received_prefix_filter,
        !          12639:        show_bgp_view_neighbor_received_prefix_filter_cmd,
        !          12640:        "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
1.1       misho    12641:        SHOW_STR
                   12642:        BGP_STR
                   12643:        "BGP view\n"
                   12644:        "View name\n"
                   12645:        "Detailed information on TCP and BGP neighbor connections\n"
                   12646:        "Neighbor to display information about\n"
                   12647:        "Neighbor to display information about\n"
1.1.1.4 ! misho    12648:        "Display information received from a BGP neighbor\n"
        !          12649:        "Display the prefixlist filter\n")
1.1       misho    12650: {
1.1.1.4 ! misho    12651:   char name[BUFSIZ];
        !          12652:   union sockunion su;
1.1       misho    12653:   struct peer *peer;
1.1.1.4 ! misho    12654:   struct bgp *bgp;
        !          12655:   int count, ret;
1.1       misho    12656: 
1.1.1.4 ! misho    12657:   /* BGP structure lookup. */
        !          12658:   bgp = bgp_lookup_by_name (argv[0]);
        !          12659:   if (bgp == NULL)
        !          12660:   {  
        !          12661:          vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
        !          12662:          return CMD_WARNING;
        !          12663:        }
        !          12664:   
        !          12665:   ret = str2sockunion (argv[1], &su);
        !          12666:   if (ret < 0)
        !          12667:     {
        !          12668:       vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
        !          12669:       return CMD_WARNING;
        !          12670:     }
1.1       misho    12671: 
1.1.1.4 ! misho    12672:   peer = peer_lookup (bgp, &su);
        !          12673:   if (! peer)
1.1       misho    12674:     return CMD_WARNING;
1.1.1.4 ! misho    12675: 
        !          12676:   sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
        !          12677:   count =  prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
        !          12678:   if (count)
        !          12679:     {
        !          12680:       vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
        !          12681:       prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
        !          12682:     }
        !          12683: 
        !          12684:   return CMD_SUCCESS;
1.1       misho    12685: }
                   12686: 
                   12687: 
1.1.1.4 ! misho    12688: DEFUN (show_ip_bgp_ipv4_neighbor_received_routes,
        !          12689:        show_ip_bgp_ipv4_neighbor_received_routes_cmd,
        !          12690:        "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
1.1       misho    12691:        SHOW_STR
                   12692:        IP_STR
                   12693:        BGP_STR
                   12694:        "Address family\n"
                   12695:        "Address Family modifier\n"
                   12696:        "Address Family modifier\n"
                   12697:        "Detailed information on TCP and BGP neighbor connections\n"
                   12698:        "Neighbor to display information about\n"
                   12699:        "Neighbor to display information about\n"
1.1.1.4 ! misho    12700:        "Display the received routes from neighbor\n")
1.1       misho    12701: {
                   12702:   struct peer *peer;
                   12703: 
                   12704:   peer = peer_lookup_in_view (vty, NULL, argv[1]);
                   12705:   if (! peer)
                   12706:     return CMD_WARNING;
1.1.1.4 ! misho    12707:   
1.1       misho    12708:   if (strncmp (argv[0], "m", 1) == 0)
1.1.1.4 ! misho    12709:     return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1);
1.1       misho    12710: 
1.1.1.4 ! misho    12711:   return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
1.1       misho    12712: }
                   12713: 
1.1.1.4 ! misho    12714: DEFUN (show_bgp_ipv4_safi_neighbor_advertised_route,
        !          12715:        show_bgp_ipv4_safi_neighbor_advertised_route_cmd,
        !          12716:        "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
1.1       misho    12717:        SHOW_STR
                   12718:        BGP_STR
1.1.1.4 ! misho    12719:        "Address Family modifier\n"
        !          12720:        "Address Family modifier\n"
1.1       misho    12721:        "Detailed information on TCP and BGP neighbor connections\n"
                   12722:        "Neighbor to display information about\n"
                   12723:        "Neighbor to display information about\n"
                   12724:        "Display the routes advertised to a BGP neighbor\n")
                   12725: {
                   12726:   struct peer *peer;
1.1.1.4 ! misho    12727:   safi_t       safi;
1.1       misho    12728: 
1.1.1.4 ! misho    12729:   if (bgp_parse_safi(argv[0], &safi)) {
        !          12730:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          12731:     return CMD_WARNING;
        !          12732:   }
1.1       misho    12733: 
1.1.1.4 ! misho    12734:   peer = peer_lookup_in_view (vty, NULL, argv[1]);
1.1       misho    12735:   if (! peer)
1.1.1.4 ! misho    12736:     return CMD_WARNING;
1.1       misho    12737: 
1.1.1.4 ! misho    12738:   return peer_adj_routes (vty, peer, AFI_IP, safi, 0);
1.1       misho    12739: }
                   12740: 
1.1.1.4 ! misho    12741: DEFUN (show_bgp_ipv6_safi_neighbor_advertised_route,
        !          12742:        show_bgp_ipv6_safi_neighbor_advertised_route_cmd,
        !          12743:        "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
1.1       misho    12744:        SHOW_STR
                   12745:        BGP_STR
1.1.1.4 ! misho    12746:        "Address Family modifier\n"
        !          12747:        "Address Family modifier\n"
        !          12748:        "Address Family modifier\n"
1.1       misho    12749:        "Detailed information on TCP and BGP neighbor connections\n"
                   12750:        "Neighbor to display information about\n"
                   12751:        "Neighbor to display information about\n"
                   12752:        "Display the routes advertised to a BGP neighbor\n")
                   12753: {
                   12754:   struct peer *peer;
1.1.1.4 ! misho    12755:   safi_t       safi;
1.1       misho    12756: 
1.1.1.4 ! misho    12757:   if (bgp_parse_safi(argv[0], &safi)) {
        !          12758:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          12759:     return CMD_WARNING;
        !          12760:   }
1.1       misho    12761: 
1.1.1.4 ! misho    12762:   peer = peer_lookup_in_view (vty, NULL, argv[1]);
1.1       misho    12763:   if (! peer)
                   12764:     return CMD_WARNING;
                   12765: 
1.1.1.4 ! misho    12766:   return peer_adj_routes (vty, peer, AFI_IP6, safi, 0);
1.1       misho    12767: }
                   12768: 
1.1.1.4 ! misho    12769: DEFUN (show_bgp_view_ipv6_neighbor_advertised_route,
        !          12770:        show_bgp_view_ipv6_neighbor_advertised_route_cmd,
        !          12771:        "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
1.1       misho    12772:        SHOW_STR
                   12773:        BGP_STR
                   12774:        "BGP view\n"
                   12775:        "View name\n"
                   12776:        "Address family\n"
                   12777:        "Detailed information on TCP and BGP neighbor connections\n"
                   12778:        "Neighbor to display information about\n"
                   12779:        "Neighbor to display information about\n"
                   12780:        "Display the routes advertised to a BGP neighbor\n")
                   12781: {
                   12782:   struct peer *peer;
                   12783: 
1.1.1.4 ! misho    12784:   if (argc == 2)
        !          12785:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
        !          12786:   else
        !          12787:     peer = peer_lookup_in_view (vty, NULL, argv[0]);
        !          12788: 
1.1       misho    12789:   if (! peer)
1.1.1.4 ! misho    12790:     return CMD_WARNING;    
1.1       misho    12791: 
1.1.1.4 ! misho    12792:   return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
1.1       misho    12793: }
1.1.1.4 ! misho    12794: 
        !          12795: DEFUN (show_bgp_view_ipv6_neighbor_received_routes,
        !          12796:        show_bgp_view_ipv6_neighbor_received_routes_cmd,
        !          12797:        "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
1.1       misho    12798:        SHOW_STR
                   12799:        BGP_STR
                   12800:        "BGP view\n"
                   12801:        "View name\n"
1.1.1.4 ! misho    12802:        "Address family\n"
1.1       misho    12803:        "Detailed information on TCP and BGP neighbor connections\n"
                   12804:        "Neighbor to display information about\n"
                   12805:        "Neighbor to display information about\n"
                   12806:        "Display the received routes from neighbor\n")
                   12807: {
                   12808:   struct peer *peer;
                   12809: 
                   12810:   if (argc == 2)
                   12811:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
                   12812:   else
                   12813:     peer = peer_lookup_in_view (vty, NULL, argv[0]);
                   12814: 
                   12815:   if (! peer)
                   12816:     return CMD_WARNING;
                   12817: 
1.1.1.4 ! misho    12818:   return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
1.1       misho    12819: }
                   12820: 
1.1.1.4 ! misho    12821: DEFUN (show_bgp_ipv4_safi_neighbor_received_routes,
        !          12822:        show_bgp_ipv4_safi_neighbor_received_routes_cmd,
        !          12823:        "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes",
1.1       misho    12824:        SHOW_STR
                   12825:        BGP_STR
1.1.1.4 ! misho    12826:        "Address family\n"
        !          12827:        "Address Family modifier\n"
        !          12828:        "Address Family modifier\n"
        !          12829:        "Address Family modifier\n"
        !          12830:        "Address Family modifier\n"
1.1       misho    12831:        "Detailed information on TCP and BGP neighbor connections\n"
                   12832:        "Neighbor to display information about\n"
                   12833:        "Neighbor to display information about\n"
                   12834:        "Display the received routes from neighbor\n")
1.1.1.4 ! misho    12835: {
        !          12836:   struct peer *peer;
        !          12837:   safi_t       safi;
1.1       misho    12838: 
1.1.1.4 ! misho    12839:   if (bgp_parse_safi(argv[0], &safi)) {
        !          12840:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          12841:     return CMD_WARNING;
        !          12842:   }
        !          12843: 
        !          12844:   peer = peer_lookup_in_view (vty, NULL, argv[1]);
        !          12845:   if (! peer)
        !          12846:     return CMD_WARNING;
        !          12847:   
        !          12848:   return peer_adj_routes (vty, peer, AFI_IP, safi, 1);
        !          12849: }
        !          12850: 
        !          12851: DEFUN (show_bgp_ipv6_safi_neighbor_received_routes,
        !          12852:        show_bgp_ipv6_safi_neighbor_received_routes_cmd,
        !          12853:        "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes",
1.1       misho    12854:        SHOW_STR
                   12855:        BGP_STR
                   12856:        "Address family\n"
                   12857:        "Address Family modifier\n"
                   12858:        "Address Family modifier\n"
1.1.1.4 ! misho    12859:        "Address Family modifier\n"
        !          12860:        "Address Family modifier\n"
1.1       misho    12861:        "Detailed information on TCP and BGP neighbor connections\n"
                   12862:        "Neighbor to display information about\n"
                   12863:        "Neighbor to display information about\n"
                   12864:        "Display the received routes from neighbor\n")
                   12865: {
                   12866:   struct peer *peer;
1.1.1.4 ! misho    12867:   safi_t       safi;
        !          12868: 
        !          12869:   if (bgp_parse_safi(argv[0], &safi)) {
        !          12870:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          12871:     return CMD_WARNING;
        !          12872:   }
1.1       misho    12873: 
                   12874:   peer = peer_lookup_in_view (vty, NULL, argv[1]);
                   12875:   if (! peer)
                   12876:     return CMD_WARNING;
                   12877:   
1.1.1.4 ! misho    12878:   return peer_adj_routes (vty, peer, AFI_IP6, safi, 1);
1.1       misho    12879: }
                   12880: 
                   12881: DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes,
                   12882:        show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd,
                   12883:        "show bgp view WORD (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)",
                   12884:        SHOW_STR
                   12885:        BGP_STR
                   12886:        "BGP view\n"
1.1.1.4 ! misho    12887:        "View name\n"
1.1       misho    12888:        "Address family\n"
                   12889:        "Address family\n"
                   12890:        "Address family modifier\n"
                   12891:        "Address family modifier\n"
                   12892:        "Detailed information on TCP and BGP neighbor connections\n"
                   12893:        "Neighbor to display information about\n"
                   12894:        "Neighbor to display information about\n"
                   12895:        "Display the advertised routes to neighbor\n"
                   12896:        "Display the received routes from neighbor\n")
                   12897: {
                   12898:   int afi;
                   12899:   int safi;
                   12900:   int in;
                   12901:   struct peer *peer;
                   12902: 
1.1.1.4 ! misho    12903:   peer = peer_lookup_in_view (vty, argv[0], argv[3]);
1.1       misho    12904: 
                   12905:   if (! peer)
                   12906:     return CMD_WARNING;
                   12907: 
                   12908:   afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
                   12909:   safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
                   12910:   in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0;
                   12911: 
                   12912:   return peer_adj_routes (vty, peer, afi, safi, in);
                   12913: }
                   12914: 
                   12915: DEFUN (show_ip_bgp_neighbor_received_prefix_filter,
                   12916:        show_ip_bgp_neighbor_received_prefix_filter_cmd,
                   12917:        "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
                   12918:        SHOW_STR
                   12919:        IP_STR
                   12920:        BGP_STR
                   12921:        "Detailed information on TCP and BGP neighbor connections\n"
                   12922:        "Neighbor to display information about\n"
                   12923:        "Neighbor to display information about\n"
                   12924:        "Display information received from a BGP neighbor\n"
                   12925:        "Display the prefixlist filter\n")
                   12926: {
                   12927:   char name[BUFSIZ];
1.1.1.3   misho    12928:   union sockunion su;
1.1       misho    12929:   struct peer *peer;
1.1.1.3   misho    12930:   int count, ret;
1.1       misho    12931: 
1.1.1.3   misho    12932:   ret = str2sockunion (argv[0], &su);
                   12933:   if (ret < 0)
                   12934:     {
                   12935:       vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
                   12936:       return CMD_WARNING;
                   12937:     }
1.1       misho    12938: 
1.1.1.3   misho    12939:   peer = peer_lookup (NULL, &su);
1.1       misho    12940:   if (! peer)
                   12941:     return CMD_WARNING;
                   12942: 
                   12943:   sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
                   12944:   count =  prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
                   12945:   if (count)
                   12946:     {
                   12947:       vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
                   12948:       prefix_bgp_show_prefix_list (vty, AFI_IP, name);
                   12949:     }
                   12950: 
                   12951:   return CMD_SUCCESS;
                   12952: }
                   12953: 
                   12954: DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter,
                   12955:        show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd,
                   12956:        "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
                   12957:        SHOW_STR
                   12958:        IP_STR
                   12959:        BGP_STR
                   12960:        "Address family\n"
                   12961:        "Address Family modifier\n"
                   12962:        "Address Family modifier\n"
                   12963:        "Detailed information on TCP and BGP neighbor connections\n"
                   12964:        "Neighbor to display information about\n"
                   12965:        "Neighbor to display information about\n"
                   12966:        "Display information received from a BGP neighbor\n"
                   12967:        "Display the prefixlist filter\n")
                   12968: {
                   12969:   char name[BUFSIZ];
1.1.1.3   misho    12970:   union sockunion su;
1.1       misho    12971:   struct peer *peer;
1.1.1.3   misho    12972:   int count, ret;
1.1       misho    12973: 
1.1.1.3   misho    12974:   ret = str2sockunion (argv[1], &su);
                   12975:   if (ret < 0)
                   12976:     {
                   12977:       vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
                   12978:       return CMD_WARNING;
                   12979:     }
1.1       misho    12980: 
1.1.1.3   misho    12981:   peer = peer_lookup (NULL, &su);
1.1       misho    12982:   if (! peer)
                   12983:     return CMD_WARNING;
                   12984: 
                   12985:   if (strncmp (argv[0], "m", 1) == 0)
                   12986:     {
                   12987:       sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST);
                   12988:       count =  prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
                   12989:       if (count)
                   12990:        {
                   12991:          vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE);
                   12992:          prefix_bgp_show_prefix_list (vty, AFI_IP, name);
                   12993:        }
                   12994:     }
                   12995:   else 
                   12996:     {
                   12997:       sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
                   12998:       count =  prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
                   12999:       if (count)
                   13000:        {
                   13001:          vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
                   13002:          prefix_bgp_show_prefix_list (vty, AFI_IP, name);
                   13003:        }
                   13004:     }
                   13005: 
                   13006:   return CMD_SUCCESS;
                   13007: }
                   13008: 
                   13009: ALIAS (show_bgp_view_neighbor_received_routes,
                   13010:        show_bgp_neighbor_received_routes_cmd,
                   13011:        "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
                   13012:        SHOW_STR
                   13013:        BGP_STR
                   13014:        "Detailed information on TCP and BGP neighbor connections\n"
                   13015:        "Neighbor to display information about\n"
                   13016:        "Neighbor to display information about\n"
                   13017:        "Display the received routes from neighbor\n")
                   13018: 
1.1.1.4 ! misho    13019: DEFUN (show_bgp_ipv4_safi_neighbor_received_prefix_filter,
        !          13020:        show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd,
        !          13021:        "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
1.1       misho    13022:        SHOW_STR
                   13023:        BGP_STR
1.1.1.4 ! misho    13024:        IP_STR
        !          13025:        "Address Family modifier\n"
        !          13026:        "Address Family modifier\n"
        !          13027:        "Address Family modifier\n"
        !          13028:        "Address Family modifier\n"
1.1       misho    13029:        "Detailed information on TCP and BGP neighbor connections\n"
                   13030:        "Neighbor to display information about\n"
                   13031:        "Neighbor to display information about\n"
1.1.1.4 ! misho    13032:        "Display information received from a BGP neighbor\n"
        !          13033:        "Display the prefixlist filter\n")
        !          13034: {
        !          13035:   char name[BUFSIZ];
        !          13036:   union sockunion su;
        !          13037:   struct peer *peer;
        !          13038:   int count, ret;
        !          13039:   safi_t       safi;
        !          13040: 
        !          13041:   if (bgp_parse_safi(argv[0], &safi)) {
        !          13042:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          13043:     return CMD_WARNING;
        !          13044:   }
        !          13045: 
        !          13046:   ret = str2sockunion (argv[1], &su);
        !          13047:   if (ret < 0)
        !          13048:     {
        !          13049:       vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
        !          13050:       return CMD_WARNING;
        !          13051:     }
        !          13052: 
        !          13053:   peer = peer_lookup (NULL, &su);
        !          13054:   if (! peer)
        !          13055:     return CMD_WARNING;
        !          13056: 
        !          13057:   sprintf (name, "%s.%d.%d", peer->host, AFI_IP, safi);
        !          13058:   count =  prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
        !          13059:   if (count) {
        !          13060:       vty_out (vty, "Address family: IPv4 %s%s", safi2str(safi), VTY_NEWLINE);
        !          13061:       prefix_bgp_show_prefix_list (vty, AFI_IP, name);
        !          13062:   }
        !          13063: 
        !          13064:   return CMD_SUCCESS;
        !          13065: }
        !          13066: 
        !          13067: DEFUN (show_bgp_ipv6_safi_neighbor_received_prefix_filter,
        !          13068:        show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd,
        !          13069:        "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
        !          13070:        SHOW_STR
        !          13071:        BGP_STR
        !          13072:        IP_STR
        !          13073:        "Address Family modifier\n"
        !          13074:        "Address Family modifier\n"
        !          13075:        "Address Family modifier\n"
        !          13076:        "Address Family modifier\n"
        !          13077:        "Detailed information on TCP and BGP neighbor connections\n"
        !          13078:        "Neighbor to display information about\n"
        !          13079:        "Neighbor to display information about\n"
        !          13080:        "Display information received from a BGP neighbor\n"
        !          13081:        "Display the prefixlist filter\n")
        !          13082: {
        !          13083:   char name[BUFSIZ];
        !          13084:   union sockunion su;
        !          13085:   struct peer *peer;
        !          13086:   int count, ret;
        !          13087:   safi_t       safi;
        !          13088: 
        !          13089:   if (bgp_parse_safi(argv[0], &safi)) {
        !          13090:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          13091:     return CMD_WARNING;
        !          13092:   }
        !          13093: 
        !          13094:   ret = str2sockunion (argv[1], &su);
        !          13095:   if (ret < 0)
        !          13096:     {
        !          13097:       vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
        !          13098:       return CMD_WARNING;
        !          13099:     }
        !          13100: 
        !          13101:   peer = peer_lookup (NULL, &su);
        !          13102:   if (! peer)
        !          13103:     return CMD_WARNING;
        !          13104: 
        !          13105:   sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, safi);
        !          13106:   count =  prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
        !          13107:   if (count) {
        !          13108:       vty_out (vty, "Address family: IPv6 %s%s", safi2str(safi), VTY_NEWLINE);
        !          13109:       prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
        !          13110:   }
1.1       misho    13111: 
1.1.1.4 ! misho    13112:   return CMD_SUCCESS;
        !          13113: }
        !          13114: 
        !          13115: DEFUN (show_bgp_ipv6_neighbor_received_prefix_filter,
        !          13116:        show_bgp_ipv6_neighbor_received_prefix_filter_cmd,
        !          13117:        "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
1.1       misho    13118:        SHOW_STR
                   13119:        BGP_STR
1.1.1.4 ! misho    13120:        "Address family\n"
1.1       misho    13121:        "Detailed information on TCP and BGP neighbor connections\n"
                   13122:        "Neighbor to display information about\n"
                   13123:        "Neighbor to display information about\n"
                   13124:        "Display information received from a BGP neighbor\n"
                   13125:        "Display the prefixlist filter\n")
                   13126: {
                   13127:   char name[BUFSIZ];
1.1.1.3   misho    13128:   union sockunion su;
1.1       misho    13129:   struct peer *peer;
1.1.1.3   misho    13130:   int count, ret;
1.1       misho    13131: 
1.1.1.3   misho    13132:   ret = str2sockunion (argv[0], &su);
                   13133:   if (ret < 0)
                   13134:     {
                   13135:       vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
                   13136:       return CMD_WARNING;
                   13137:     }
1.1       misho    13138: 
1.1.1.3   misho    13139:   peer = peer_lookup (NULL, &su);
1.1       misho    13140:   if (! peer)
                   13141:     return CMD_WARNING;
                   13142: 
                   13143:   sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
                   13144:   count =  prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
                   13145:   if (count)
                   13146:     {
                   13147:       vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
                   13148:       prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
                   13149:     }
                   13150: 
                   13151:   return CMD_SUCCESS;
                   13152: }
                   13153: 
1.1.1.4 ! misho    13154: DEFUN (show_bgp_view_ipv6_neighbor_received_prefix_filter,
        !          13155:        show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd,
        !          13156:        "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
1.1       misho    13157:        SHOW_STR
                   13158:        BGP_STR
                   13159:        "BGP view\n"
                   13160:        "View name\n"
1.1.1.4 ! misho    13161:        "Address family\n"
1.1       misho    13162:        "Detailed information on TCP and BGP neighbor connections\n"
                   13163:        "Neighbor to display information about\n"
                   13164:        "Neighbor to display information about\n"
                   13165:        "Display information received from a BGP neighbor\n"
                   13166:        "Display the prefixlist filter\n")
                   13167: {
                   13168:   char name[BUFSIZ];
1.1.1.3   misho    13169:   union sockunion su;
1.1       misho    13170:   struct peer *peer;
                   13171:   struct bgp *bgp;
1.1.1.3   misho    13172:   int count, ret;
1.1       misho    13173: 
                   13174:   /* BGP structure lookup. */
                   13175:   bgp = bgp_lookup_by_name (argv[0]);
                   13176:   if (bgp == NULL)
                   13177:   {  
                   13178:          vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
                   13179:          return CMD_WARNING;
                   13180:        }
                   13181:   
1.1.1.3   misho    13182:   ret = str2sockunion (argv[1], &su);
                   13183:   if (ret < 0)
                   13184:     {
                   13185:       vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
                   13186:       return CMD_WARNING;
                   13187:     }
1.1       misho    13188: 
1.1.1.3   misho    13189:   peer = peer_lookup (bgp, &su);
1.1       misho    13190:   if (! peer)
                   13191:     return CMD_WARNING;
                   13192: 
                   13193:   sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
                   13194:   count =  prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
                   13195:   if (count)
                   13196:     {
                   13197:       vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
                   13198:       prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
                   13199:     }
                   13200: 
                   13201:   return CMD_SUCCESS;
                   13202: }
                   13203: 
                   13204: static int
                   13205: bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi,
                   13206:                         safi_t safi, enum bgp_show_type type)
                   13207: {
                   13208:   if (! peer || ! peer->afc[afi][safi])
                   13209:     {
                   13210:       vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
                   13211:       return CMD_WARNING;
                   13212:     }
                   13213:  
                   13214:   return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su);
                   13215: }
                   13216: DEFUN (show_ip_bgp_neighbor_routes,
                   13217:        show_ip_bgp_neighbor_routes_cmd,
                   13218:        "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
                   13219:        SHOW_STR
                   13220:        IP_STR
                   13221:        BGP_STR
                   13222:        "Detailed information on TCP and BGP neighbor connections\n"
                   13223:        "Neighbor to display information about\n"
                   13224:        "Neighbor to display information about\n"
                   13225:        "Display routes learned from neighbor\n")
                   13226: {
                   13227:   struct peer *peer;
                   13228: 
                   13229:   peer = peer_lookup_in_view (vty, NULL, argv[0]);
                   13230:   if (! peer)
                   13231:     return CMD_WARNING;
                   13232:     
                   13233:   return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
                   13234:                                  bgp_show_type_neighbor);
                   13235: }
                   13236: 
                   13237: DEFUN (show_ip_bgp_neighbor_flap,
                   13238:        show_ip_bgp_neighbor_flap_cmd,
                   13239:        "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
                   13240:        SHOW_STR
                   13241:        IP_STR
                   13242:        BGP_STR
                   13243:        "Detailed information on TCP and BGP neighbor connections\n"
                   13244:        "Neighbor to display information about\n"
                   13245:        "Neighbor to display information about\n"
                   13246:        "Display flap statistics of the routes learned from neighbor\n")
                   13247: {
                   13248:   struct peer *peer;
                   13249: 
                   13250:   peer = peer_lookup_in_view (vty, NULL, argv[0]);
                   13251:   if (! peer)
                   13252:     return CMD_WARNING;
                   13253:     
                   13254:   return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
                   13255:                                  bgp_show_type_flap_neighbor);
                   13256: }
                   13257: 
                   13258: DEFUN (show_ip_bgp_neighbor_damp,
                   13259:        show_ip_bgp_neighbor_damp_cmd,
                   13260:        "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
                   13261:        SHOW_STR
                   13262:        IP_STR
                   13263:        BGP_STR
                   13264:        "Detailed information on TCP and BGP neighbor connections\n"
                   13265:        "Neighbor to display information about\n"
                   13266:        "Neighbor to display information about\n"
                   13267:        "Display the dampened routes received from neighbor\n")
                   13268: {
                   13269:   struct peer *peer;
                   13270: 
                   13271:   peer = peer_lookup_in_view (vty, NULL, argv[0]);
                   13272:   if (! peer)
                   13273:     return CMD_WARNING;
                   13274:     
                   13275:   return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
                   13276:                                  bgp_show_type_damp_neighbor);
                   13277: }
                   13278: 
                   13279: DEFUN (show_ip_bgp_ipv4_neighbor_routes,
                   13280:        show_ip_bgp_ipv4_neighbor_routes_cmd,
                   13281:        "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
                   13282:        SHOW_STR
                   13283:        IP_STR
                   13284:        BGP_STR
                   13285:        "Address family\n"
                   13286:        "Address Family modifier\n"
                   13287:        "Address Family modifier\n"
                   13288:        "Detailed information on TCP and BGP neighbor connections\n"
                   13289:        "Neighbor to display information about\n"
                   13290:        "Neighbor to display information about\n"
                   13291:        "Display routes learned from neighbor\n")
                   13292: {
                   13293:   struct peer *peer;
                   13294: 
                   13295:   peer = peer_lookup_in_view (vty, NULL, argv[1]);
                   13296:   if (! peer)
                   13297:     return CMD_WARNING;
                   13298:  
                   13299:   if (strncmp (argv[0], "m", 1) == 0)
                   13300:     return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST,
                   13301:                                    bgp_show_type_neighbor);
                   13302: 
                   13303:   return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
                   13304:                                  bgp_show_type_neighbor);
                   13305: }
                   13306: 
                   13307: DEFUN (show_ip_bgp_view_rsclient,
                   13308:        show_ip_bgp_view_rsclient_cmd,
                   13309:        "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
                   13310:        SHOW_STR
                   13311:        IP_STR
                   13312:        BGP_STR
                   13313:        "BGP view\n"
1.1.1.4 ! misho    13314:        "View name\n"
1.1       misho    13315:        "Information about Route Server Client\n"
                   13316:        NEIGHBOR_ADDR_STR)
                   13317: {
                   13318:   struct bgp_table *table;
                   13319:   struct peer *peer;
                   13320: 
                   13321:   if (argc == 2)
                   13322:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
                   13323:   else
                   13324:     peer = peer_lookup_in_view (vty, NULL, argv[0]);
                   13325: 
                   13326:   if (! peer)
                   13327:     return CMD_WARNING;
                   13328: 
                   13329:   if (! peer->afc[AFI_IP][SAFI_UNICAST])
                   13330:     {
                   13331:       vty_out (vty, "%% Activate the neighbor for the address family first%s",
                   13332:             VTY_NEWLINE);
                   13333:       return CMD_WARNING;
                   13334:     }
                   13335: 
                   13336:   if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
                   13337:               PEER_FLAG_RSERVER_CLIENT))
                   13338:     {
                   13339:       vty_out (vty, "%% Neighbor is not a Route-Server client%s",
                   13340:             VTY_NEWLINE);
                   13341:       return CMD_WARNING;
                   13342:     }
                   13343: 
                   13344:   table = peer->rib[AFI_IP][SAFI_UNICAST];
                   13345: 
                   13346:   return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
                   13347: }
                   13348: 
                   13349: ALIAS (show_ip_bgp_view_rsclient,
                   13350:        show_ip_bgp_rsclient_cmd,
                   13351:        "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
                   13352:        SHOW_STR
                   13353:        IP_STR
                   13354:        BGP_STR
                   13355:        "Information about Route Server Client\n"
                   13356:        NEIGHBOR_ADDR_STR)
                   13357: 
                   13358: DEFUN (show_bgp_view_ipv4_safi_rsclient,
                   13359:        show_bgp_view_ipv4_safi_rsclient_cmd,
                   13360:        "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
                   13361:        SHOW_STR
                   13362:        BGP_STR
                   13363:        "BGP view\n"
1.1.1.4 ! misho    13364:        "View name\n"
1.1       misho    13365:        "Address family\n"
                   13366:        "Address Family modifier\n"
                   13367:        "Address Family modifier\n"
                   13368:        "Information about Route Server Client\n"
                   13369:        NEIGHBOR_ADDR_STR)
                   13370: {
                   13371:   struct bgp_table *table;
                   13372:   struct peer *peer;
                   13373:   safi_t safi;
                   13374: 
                   13375:   if (argc == 3) {
                   13376:     peer = peer_lookup_in_view (vty, argv[0], argv[2]);
                   13377:     safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
                   13378:   } else {
                   13379:     peer = peer_lookup_in_view (vty, NULL, argv[1]);
                   13380:     safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
                   13381:   }
                   13382: 
                   13383:   if (! peer)
                   13384:     return CMD_WARNING;
                   13385: 
                   13386:   if (! peer->afc[AFI_IP][safi])
                   13387:     {
                   13388:       vty_out (vty, "%% Activate the neighbor for the address family first%s",
                   13389:             VTY_NEWLINE);
                   13390:       return CMD_WARNING;
                   13391:     }
                   13392: 
                   13393:   if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
                   13394:               PEER_FLAG_RSERVER_CLIENT))
                   13395:     {
                   13396:       vty_out (vty, "%% Neighbor is not a Route-Server client%s",
                   13397:             VTY_NEWLINE);
                   13398:       return CMD_WARNING;
                   13399:     }
                   13400: 
                   13401:   table = peer->rib[AFI_IP][safi];
                   13402: 
                   13403:   return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
                   13404: }
                   13405: 
                   13406: ALIAS (show_bgp_view_ipv4_safi_rsclient,
                   13407:        show_bgp_ipv4_safi_rsclient_cmd,
                   13408:        "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
                   13409:        SHOW_STR
                   13410:        BGP_STR
                   13411:        "Address family\n"
                   13412:        "Address Family modifier\n"
                   13413:        "Address Family modifier\n"
                   13414:        "Information about Route Server Client\n"
                   13415:        NEIGHBOR_ADDR_STR)
                   13416: 
                   13417: DEFUN (show_ip_bgp_view_rsclient_route,
                   13418:        show_ip_bgp_view_rsclient_route_cmd,
                   13419:        "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
                   13420:        SHOW_STR
                   13421:        IP_STR
                   13422:        BGP_STR
                   13423:        "BGP view\n"
1.1.1.4 ! misho    13424:        "View name\n"
1.1       misho    13425:        "Information about Route Server Client\n"
                   13426:        NEIGHBOR_ADDR_STR
                   13427:        "Network in the BGP routing table to display\n")
                   13428: {
                   13429:   struct bgp *bgp;
                   13430:   struct peer *peer;
                   13431: 
                   13432:   /* BGP structure lookup. */
                   13433:   if (argc == 3)
                   13434:     {
                   13435:       bgp = bgp_lookup_by_name (argv[0]);
                   13436:       if (bgp == NULL)
                   13437:        {
                   13438:          vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
                   13439:          return CMD_WARNING;
                   13440:        }
                   13441:     }
                   13442:   else
                   13443:     {
                   13444:       bgp = bgp_get_default ();
                   13445:       if (bgp == NULL)
                   13446:        {
                   13447:          vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
                   13448:          return CMD_WARNING;
                   13449:        }
                   13450:     }
                   13451: 
                   13452:   if (argc == 3)
                   13453:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
                   13454:   else
                   13455:     peer = peer_lookup_in_view (vty, NULL, argv[0]);
                   13456: 
                   13457:   if (! peer)
                   13458:     return CMD_WARNING;
                   13459: 
                   13460:   if (! peer->afc[AFI_IP][SAFI_UNICAST])
                   13461:     {
                   13462:       vty_out (vty, "%% Activate the neighbor for the address family first%s",
                   13463:             VTY_NEWLINE);
                   13464:       return CMD_WARNING;
                   13465: }
                   13466: 
                   13467:   if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
                   13468:               PEER_FLAG_RSERVER_CLIENT))
                   13469:     {
                   13470:       vty_out (vty, "%% Neighbor is not a Route-Server client%s",
                   13471:             VTY_NEWLINE);
                   13472:       return CMD_WARNING;
                   13473:     }
                   13474:  
                   13475:   return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], 
                   13476:                                   (argc == 3) ? argv[2] : argv[1],
                   13477:                                   AFI_IP, SAFI_UNICAST, NULL, 0);
                   13478: }
                   13479: 
                   13480: ALIAS (show_ip_bgp_view_rsclient_route,
                   13481:        show_ip_bgp_rsclient_route_cmd,
                   13482:        "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
                   13483:        SHOW_STR
                   13484:        IP_STR
                   13485:        BGP_STR
                   13486:        "Information about Route Server Client\n"
                   13487:        NEIGHBOR_ADDR_STR
                   13488:        "Network in the BGP routing table to display\n")
                   13489: 
1.1.1.4 ! misho    13490: DEFUN (show_bgp_ipv4_safi_neighbor_flap,
        !          13491:        show_bgp_ipv4_safi_neighbor_flap_cmd,
        !          13492:        "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
        !          13493:        SHOW_STR
        !          13494:        BGP_STR
        !          13495:        "Address Family Modifier\n"
        !          13496:        "Address Family Modifier\n"
        !          13497:        "Address Family Modifier\n"
        !          13498:        "Address Family Modifier\n"
        !          13499:        "Detailed information on TCP and BGP neighbor connections\n"
        !          13500:        "Neighbor to display information about\n"
        !          13501:        "Neighbor to display information about\n"
        !          13502:        "Display flap statistics of the routes learned from neighbor\n")
        !          13503: {
        !          13504:   struct peer *peer;
        !          13505:   safi_t       safi;
        !          13506: 
        !          13507:   if (bgp_parse_safi(argv[0], &safi)) {
        !          13508:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          13509:     return CMD_WARNING;
        !          13510:   }
        !          13511: 
        !          13512:   peer = peer_lookup_in_view (vty, NULL, argv[1]);
        !          13513:   if (! peer)
        !          13514:     return CMD_WARNING;
        !          13515:     
        !          13516:   return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
        !          13517:                                  bgp_show_type_flap_neighbor);
        !          13518: }
        !          13519: 
        !          13520: DEFUN (show_bgp_ipv6_safi_neighbor_flap,
        !          13521:        show_bgp_ipv6_safi_neighbor_flap_cmd,
        !          13522:        "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
        !          13523:        SHOW_STR
        !          13524:        BGP_STR
        !          13525:        "Address Family Modifier\n"
        !          13526:        "Address Family Modifier\n"
        !          13527:        "Address Family Modifier\n"
        !          13528:        "Address Family Modifier\n"
        !          13529:        "Detailed information on TCP and BGP neighbor connections\n"
        !          13530:        "Neighbor to display information about\n"
        !          13531:        "Neighbor to display information about\n"
        !          13532:        "Display flap statistics of the routes learned from neighbor\n")
        !          13533: {
        !          13534:   struct peer *peer;
        !          13535:   safi_t       safi;
        !          13536: 
        !          13537:   if (bgp_parse_safi(argv[0], &safi)) {
        !          13538:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          13539:     return CMD_WARNING;
        !          13540:   }
        !          13541: 
        !          13542:   peer = peer_lookup_in_view (vty, NULL, argv[1]);
        !          13543:   if (! peer)
        !          13544:     return CMD_WARNING;
        !          13545:     
        !          13546:   return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
        !          13547:                                  bgp_show_type_flap_neighbor);
        !          13548: }
        !          13549: 
        !          13550: DEFUN (show_bgp_ipv4_safi_neighbor_damp,
        !          13551:        show_bgp_ipv4_safi_neighbor_damp_cmd,
        !          13552:        "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
        !          13553:        SHOW_STR
        !          13554:        BGP_STR
        !          13555:        "Address Family Modifier\n"
        !          13556:        "Address Family Modifier\n"
        !          13557:        "Address Family Modifier\n"
        !          13558:        "Address Family Modifier\n"
        !          13559:        "Detailed information on TCP and BGP neighbor connections\n"
        !          13560:        "Neighbor to display information about\n"
        !          13561:        "Neighbor to display information about\n"
        !          13562:        "Display the dampened routes received from neighbor\n")
        !          13563: {
        !          13564:   struct peer *peer;
        !          13565:   safi_t       safi;
        !          13566: 
        !          13567:   if (bgp_parse_safi(argv[0], &safi)) {
        !          13568:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          13569:     return CMD_WARNING;
        !          13570:   }
        !          13571: 
        !          13572:   peer = peer_lookup_in_view (vty, NULL, argv[1]);
        !          13573:   if (! peer)
        !          13574:     return CMD_WARNING;
        !          13575:     
        !          13576:   return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
        !          13577:                                  bgp_show_type_damp_neighbor);
        !          13578: }
        !          13579: 
        !          13580: DEFUN (show_bgp_ipv6_safi_neighbor_damp,
        !          13581:        show_bgp_ipv6_safi_neighbor_damp_cmd,
        !          13582:        "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
        !          13583:        SHOW_STR
        !          13584:        BGP_STR
        !          13585:        "Address Family Modifier\n"
        !          13586:        "Address Family Modifier\n"
        !          13587:        "Address Family Modifier\n"
        !          13588:        "Address Family Modifier\n"
        !          13589:        "Detailed information on TCP and BGP neighbor connections\n"
        !          13590:        "Neighbor to display information about\n"
        !          13591:        "Neighbor to display information about\n"
        !          13592:        "Display the dampened routes received from neighbor\n")
        !          13593: {
        !          13594:   struct peer *peer;
        !          13595:   safi_t       safi;
        !          13596: 
        !          13597:   if (bgp_parse_safi(argv[0], &safi)) {
        !          13598:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          13599:     return CMD_WARNING;
        !          13600:   }
        !          13601: 
        !          13602:   peer = peer_lookup_in_view (vty, NULL, argv[1]);
        !          13603:   if (! peer)
        !          13604:     return CMD_WARNING;
        !          13605:     
        !          13606:   return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
        !          13607:                                  bgp_show_type_damp_neighbor);
        !          13608: }
        !          13609: 
        !          13610: DEFUN (show_bgp_ipv4_safi_neighbor_routes,
        !          13611:        show_bgp_ipv4_safi_neighbor_routes_cmd,
        !          13612:        "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
        !          13613:        SHOW_STR
        !          13614:        BGP_STR
        !          13615:        "Address family\n"
        !          13616:        "Address Family modifier\n"
        !          13617:        "Address Family modifier\n"
        !          13618:        "Detailed information on TCP and BGP neighbor connections\n"
        !          13619:        "Neighbor to display information about\n"
        !          13620:        "Neighbor to display information about\n"
        !          13621:        "Display routes learned from neighbor\n")
        !          13622: {
        !          13623:   struct peer *peer;
        !          13624:   safi_t       safi;
        !          13625: 
        !          13626:   if (bgp_parse_safi(argv[0], &safi)) {
        !          13627:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          13628:     return CMD_WARNING;
        !          13629:   }
        !          13630: 
        !          13631:   peer = peer_lookup_in_view (vty, NULL, argv[1]);
        !          13632:   if (! peer)
        !          13633:     return CMD_WARNING;
        !          13634:  
        !          13635:   return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
        !          13636:                                  bgp_show_type_neighbor);
        !          13637: }
        !          13638: 
        !          13639: DEFUN (show_bgp_ipv6_safi_neighbor_routes,
        !          13640:        show_bgp_ipv6_safi_neighbor_routes_cmd,
        !          13641:        "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
        !          13642:        SHOW_STR
        !          13643:        BGP_STR
        !          13644:        "Address family\n"
        !          13645:        "Address Family modifier\n"
        !          13646:        "Address Family modifier\n"
        !          13647:        "Detailed information on TCP and BGP neighbor connections\n"
        !          13648:        NEIGHBOR_ADDR_STR
        !          13649:        NEIGHBOR_ADDR_STR
        !          13650:        "Display routes learned from neighbor\n")
        !          13651: {
        !          13652:   struct peer *peer;
        !          13653:   safi_t       safi;
        !          13654: 
        !          13655:   if (bgp_parse_safi(argv[0], &safi)) {
        !          13656:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          13657:     return CMD_WARNING;
        !          13658:   }
        !          13659: 
        !          13660:   peer = peer_lookup_in_view (vty, NULL, argv[1]);
        !          13661:   if (! peer)
        !          13662:     return CMD_WARNING;
        !          13663:  
        !          13664:   return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
        !          13665:                                  bgp_show_type_neighbor);
        !          13666: }
        !          13667: 
1.1       misho    13668: DEFUN (show_bgp_view_ipv4_safi_rsclient_route,
                   13669:        show_bgp_view_ipv4_safi_rsclient_route_cmd,
                   13670:        "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
                   13671:        SHOW_STR
                   13672:        BGP_STR
                   13673:        "BGP view\n"
1.1.1.4 ! misho    13674:        "View name\n"
1.1       misho    13675:        "Address family\n"
                   13676:        "Address Family modifier\n"
                   13677:        "Address Family modifier\n"
                   13678:        "Information about Route Server Client\n"
                   13679:        NEIGHBOR_ADDR_STR
                   13680:        "Network in the BGP routing table to display\n")
                   13681: {
                   13682:   struct bgp *bgp;
                   13683:   struct peer *peer;
                   13684:   safi_t safi;
                   13685: 
                   13686:   /* BGP structure lookup. */
                   13687:   if (argc == 4)
                   13688:     {
                   13689:       bgp = bgp_lookup_by_name (argv[0]);
                   13690:       if (bgp == NULL)
                   13691:        {
                   13692:          vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
                   13693:          return CMD_WARNING;
                   13694:        }
                   13695:     }
                   13696:   else
                   13697:     {
                   13698:       bgp = bgp_get_default ();
                   13699:       if (bgp == NULL)
                   13700:        {
                   13701:          vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
                   13702:          return CMD_WARNING;
                   13703:        }
                   13704:     }
                   13705: 
                   13706:   if (argc == 4) {
                   13707:     peer = peer_lookup_in_view (vty, argv[0], argv[2]);
                   13708:     safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
                   13709:   } else {
                   13710:     peer = peer_lookup_in_view (vty, NULL, argv[1]);
                   13711:     safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
                   13712:   }
                   13713: 
                   13714:   if (! peer)
                   13715:     return CMD_WARNING;
                   13716: 
                   13717:   if (! peer->afc[AFI_IP][safi])
                   13718:     {
                   13719:       vty_out (vty, "%% Activate the neighbor for the address family first%s",
                   13720:             VTY_NEWLINE);
                   13721:       return CMD_WARNING;
                   13722: }
                   13723: 
                   13724:   if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
                   13725:               PEER_FLAG_RSERVER_CLIENT))
                   13726:     {
                   13727:       vty_out (vty, "%% Neighbor is not a Route-Server client%s",
                   13728:             VTY_NEWLINE);
                   13729:       return CMD_WARNING;
                   13730:     }
                   13731: 
                   13732:   return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
                   13733:                                   (argc == 4) ? argv[3] : argv[2],
                   13734:                                   AFI_IP, safi, NULL, 0);
                   13735: }
                   13736: 
                   13737: ALIAS (show_bgp_view_ipv4_safi_rsclient_route,
                   13738:        show_bgp_ipv4_safi_rsclient_route_cmd,
                   13739:        "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
                   13740:        SHOW_STR
                   13741:        BGP_STR
                   13742:        "Address family\n"
                   13743:        "Address Family modifier\n"
                   13744:        "Address Family modifier\n"
                   13745:        "Information about Route Server Client\n"
                   13746:        NEIGHBOR_ADDR_STR
                   13747:        "Network in the BGP routing table to display\n")
                   13748: 
1.1.1.4 ! misho    13749: 
        !          13750: DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix,
        !          13751:        show_bgp_view_ipv4_safi_rsclient_prefix_cmd,
        !          13752:        "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
1.1       misho    13753:        SHOW_STR
                   13754:        BGP_STR
                   13755:        "BGP view\n"
1.1.1.4 ! misho    13756:        "View name\n"
        !          13757:        "Address family\n"
        !          13758:        "Address Family modifier\n"
        !          13759:        "Address Family modifier\n"
1.1       misho    13760:        "Information about Route Server Client\n"
                   13761:        NEIGHBOR_ADDR_STR
                   13762:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
                   13763: {
                   13764:   struct bgp *bgp;
                   13765:   struct peer *peer;
1.1.1.4 ! misho    13766:   safi_t safi;
1.1       misho    13767: 
                   13768:   /* BGP structure lookup. */
1.1.1.4 ! misho    13769:   if (argc == 4)
1.1       misho    13770:     {
                   13771:       bgp = bgp_lookup_by_name (argv[0]);
                   13772:       if (bgp == NULL)
                   13773:        {
                   13774:          vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
                   13775:          return CMD_WARNING;
                   13776:        }
                   13777:     }
                   13778:   else
                   13779:     {
                   13780:       bgp = bgp_get_default ();
                   13781:       if (bgp == NULL)
                   13782:        {
                   13783:          vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
                   13784:          return CMD_WARNING;
                   13785:        }
                   13786:     }
                   13787: 
1.1.1.4 ! misho    13788:   if (argc == 4) {
        !          13789:     peer = peer_lookup_in_view (vty, argv[0], argv[2]);
        !          13790:     safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
        !          13791:   } else {
        !          13792:     peer = peer_lookup_in_view (vty, NULL, argv[1]);
        !          13793:     safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
        !          13794:   }
1.1       misho    13795: 
                   13796:   if (! peer)
                   13797:     return CMD_WARNING;
1.1.1.4 ! misho    13798: 
        !          13799:   if (! peer->afc[AFI_IP][safi])
1.1       misho    13800:     {
                   13801:       vty_out (vty, "%% Activate the neighbor for the address family first%s",
                   13802:             VTY_NEWLINE);
                   13803:       return CMD_WARNING;
                   13804: }
                   13805: 
1.1.1.4 ! misho    13806:   if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
1.1       misho    13807:               PEER_FLAG_RSERVER_CLIENT))
                   13808: {
                   13809:       vty_out (vty, "%% Neighbor is not a Route-Server client%s",
                   13810:             VTY_NEWLINE);
                   13811:     return CMD_WARNING;
                   13812:     }
                   13813: 
1.1.1.4 ! misho    13814:   return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
        !          13815:                                   (argc == 4) ? argv[3] : argv[2],
        !          13816:                                   AFI_IP, safi, NULL, 1);
        !          13817: }
1.1       misho    13818: 
1.1.1.4 ! misho    13819: DEFUN (show_ip_bgp_view_rsclient_prefix,
        !          13820:        show_ip_bgp_view_rsclient_prefix_cmd,
        !          13821:        "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
1.1       misho    13822:        SHOW_STR
1.1.1.4 ! misho    13823:        IP_STR
1.1       misho    13824:        BGP_STR
                   13825:        "BGP view\n"
1.1.1.4 ! misho    13826:        "View name\n"
1.1       misho    13827:        "Information about Route Server Client\n"
                   13828:        NEIGHBOR_ADDR_STR
                   13829:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
                   13830: {
                   13831:   struct bgp *bgp;
                   13832:   struct peer *peer;
                   13833: 
                   13834:   /* BGP structure lookup. */
1.1.1.4 ! misho    13835:   if (argc == 3)
1.1       misho    13836:     {
                   13837:       bgp = bgp_lookup_by_name (argv[0]);
                   13838:       if (bgp == NULL)
                   13839:        {
                   13840:          vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
                   13841:          return CMD_WARNING;
                   13842:        }
                   13843:     }
                   13844:   else
                   13845:     {
                   13846:       bgp = bgp_get_default ();
                   13847:       if (bgp == NULL)
                   13848:        {
                   13849:          vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
                   13850:          return CMD_WARNING;
                   13851:        }
                   13852:     }
                   13853: 
1.1.1.4 ! misho    13854:   if (argc == 3)
        !          13855:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
        !          13856:   else
        !          13857:   peer = peer_lookup_in_view (vty, NULL, argv[0]);
1.1       misho    13858: 
                   13859:   if (! peer)
                   13860:     return CMD_WARNING;
1.1.1.4 ! misho    13861:     
        !          13862:   if (! peer->afc[AFI_IP][SAFI_UNICAST])
1.1       misho    13863:     {
                   13864:       vty_out (vty, "%% Activate the neighbor for the address family first%s",
                   13865:             VTY_NEWLINE);
                   13866:       return CMD_WARNING;
                   13867: }
                   13868: 
1.1.1.4 ! misho    13869:   if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
1.1       misho    13870:               PEER_FLAG_RSERVER_CLIENT))
                   13871: {
                   13872:       vty_out (vty, "%% Neighbor is not a Route-Server client%s",
                   13873:             VTY_NEWLINE);
                   13874:     return CMD_WARNING;
                   13875:     }
1.1.1.4 ! misho    13876:     
        !          13877:   return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], 
        !          13878:                                   (argc == 3) ? argv[2] : argv[1],
        !          13879:                                   AFI_IP, SAFI_UNICAST, NULL, 1);
1.1       misho    13880: }
                   13881: 
1.1.1.4 ! misho    13882: ALIAS (show_ip_bgp_view_rsclient_prefix,
        !          13883:        show_ip_bgp_rsclient_prefix_cmd,
        !          13884:        "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
        !          13885:        SHOW_STR
        !          13886:        IP_STR
        !          13887:        BGP_STR
        !          13888:        "Information about Route Server Client\n"
        !          13889:        NEIGHBOR_ADDR_STR
        !          13890:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
        !          13891: 
1.1       misho    13892: ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix,
                   13893:        show_bgp_ipv4_safi_rsclient_prefix_cmd,
                   13894:        "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
                   13895:        SHOW_STR
                   13896:        BGP_STR
                   13897:        "Address family\n"
                   13898:        "Address Family modifier\n"
                   13899:        "Address Family modifier\n"
                   13900:        "Information about Route Server Client\n"
                   13901:        NEIGHBOR_ADDR_STR
                   13902:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
                   13903: 
1.1.1.4 ! misho    13904: DEFUN (show_bgp_view_ipv6_neighbor_routes,
        !          13905:        show_bgp_view_ipv6_neighbor_routes_cmd,
        !          13906:        "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
1.1       misho    13907:        SHOW_STR
                   13908:        BGP_STR
                   13909:        "BGP view\n"
1.1.1.4 ! misho    13910:        "View name\n"
        !          13911:        "Address family\n"
1.1       misho    13912:        "Detailed information on TCP and BGP neighbor connections\n"
                   13913:        "Neighbor to display information about\n"
                   13914:        "Neighbor to display information about\n"
                   13915:        "Display routes learned from neighbor\n")
                   13916: {
                   13917:   struct peer *peer;
                   13918: 
                   13919:   if (argc == 2)
                   13920:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
                   13921:   else
                   13922:     peer = peer_lookup_in_view (vty, NULL, argv[0]);
                   13923:    
                   13924:   if (! peer)
                   13925:     return CMD_WARNING;
                   13926: 
                   13927:   return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
                   13928:                                  bgp_show_type_neighbor);
                   13929: }
                   13930: 
1.1.1.4 ! misho    13931: DEFUN (show_bgp_view_neighbor_damp,
        !          13932:        show_bgp_view_neighbor_damp_cmd,
        !          13933:        "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
1.1       misho    13934:        SHOW_STR
                   13935:        BGP_STR
                   13936:        "BGP view\n"
1.1.1.4 ! misho    13937:        "View name\n"
1.1       misho    13938:        "Detailed information on TCP and BGP neighbor connections\n"
                   13939:        "Neighbor to display information about\n"
                   13940:        "Neighbor to display information about\n"
1.1.1.4 ! misho    13941:        "Display the dampened routes received from neighbor\n")
        !          13942: {
        !          13943:   struct peer *peer;
1.1       misho    13944: 
1.1.1.4 ! misho    13945:   if (argc == 2)
        !          13946:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
        !          13947:   else
        !          13948:     peer = peer_lookup_in_view (vty, NULL, argv[0]);
        !          13949: 
        !          13950:   if (! peer)
        !          13951:     return CMD_WARNING;
        !          13952: 
        !          13953:   return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
        !          13954:                                  bgp_show_type_damp_neighbor);
        !          13955: }
        !          13956: 
        !          13957: DEFUN (show_bgp_view_ipv6_neighbor_damp,
        !          13958:        show_bgp_view_ipv6_neighbor_damp_cmd,
        !          13959:        "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
1.1       misho    13960:        SHOW_STR
                   13961:        BGP_STR
                   13962:        "BGP view\n"
1.1.1.4 ! misho    13963:        "View name\n"
        !          13964:        "Address family\n"
1.1       misho    13965:        "Detailed information on TCP and BGP neighbor connections\n"
                   13966:        "Neighbor to display information about\n"
                   13967:        "Neighbor to display information about\n"
                   13968:        "Display the dampened routes received from neighbor\n")
                   13969: {
                   13970:   struct peer *peer;
                   13971: 
                   13972:   if (argc == 2)
                   13973:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
                   13974:   else
                   13975:     peer = peer_lookup_in_view (vty, NULL, argv[0]);
                   13976: 
                   13977:   if (! peer)
                   13978:     return CMD_WARNING;
                   13979: 
                   13980:   return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
                   13981:                                  bgp_show_type_damp_neighbor);
                   13982: }
                   13983: 
1.1.1.4 ! misho    13984: DEFUN (show_bgp_view_ipv6_neighbor_flap,
        !          13985:        show_bgp_view_ipv6_neighbor_flap_cmd,
        !          13986:        "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
1.1       misho    13987:        SHOW_STR
                   13988:        BGP_STR
                   13989:        "BGP view\n"
1.1.1.4 ! misho    13990:        "View name\n"
1.1       misho    13991:        "Address family\n"
                   13992:        "Detailed information on TCP and BGP neighbor connections\n"
                   13993:        "Neighbor to display information about\n"
                   13994:        "Neighbor to display information about\n"
                   13995:        "Display the dampened routes received from neighbor\n")
1.1.1.4 ! misho    13996: {
        !          13997:   struct peer *peer;
        !          13998: 
        !          13999:   if (argc == 2)
        !          14000:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
        !          14001:   else
        !          14002:     peer = peer_lookup_in_view (vty, NULL, argv[0]);
        !          14003: 
        !          14004:   if (! peer)
        !          14005:     return CMD_WARNING;
        !          14006: 
        !          14007:   return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
        !          14008:                                  bgp_show_type_flap_neighbor);
        !          14009: }
1.1       misho    14010: 
                   14011: DEFUN (show_bgp_view_neighbor_flap,
                   14012:        show_bgp_view_neighbor_flap_cmd,
                   14013:        "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
                   14014:        SHOW_STR
                   14015:        BGP_STR
                   14016:        "BGP view\n"
1.1.1.4 ! misho    14017:        "View name\n"
1.1       misho    14018:        "Detailed information on TCP and BGP neighbor connections\n"
                   14019:        "Neighbor to display information about\n"
                   14020:        "Neighbor to display information about\n"
                   14021:        "Display flap statistics of the routes learned from neighbor\n")
                   14022: {
                   14023:   struct peer *peer;
                   14024: 
                   14025:   if (argc == 2)
                   14026:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
                   14027:   else
                   14028:     peer = peer_lookup_in_view (vty, NULL, argv[0]);
                   14029: 
                   14030:   if (! peer)
                   14031:     return CMD_WARNING;
                   14032: 
                   14033:   return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
                   14034:                                  bgp_show_type_flap_neighbor);
                   14035: }
                   14036: 
                   14037: ALIAS (show_bgp_view_neighbor_flap,
1.1.1.4 ! misho    14038:        show_bgp_neighbor_flap_cmd,
        !          14039:        "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
1.1       misho    14040:        SHOW_STR
                   14041:        BGP_STR
                   14042:        "Detailed information on TCP and BGP neighbor connections\n"
                   14043:        "Neighbor to display information about\n"
                   14044:        "Neighbor to display information about\n"
                   14045:        "Display flap statistics of the routes learned from neighbor\n")
1.1.1.4 ! misho    14046: 
        !          14047: ALIAS (show_bgp_view_neighbor_damp,
        !          14048:        show_bgp_neighbor_damp_cmd,
        !          14049:        "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
        !          14050:        SHOW_STR
        !          14051:        BGP_STR
        !          14052:        "Detailed information on TCP and BGP neighbor connections\n"
        !          14053:        "Neighbor to display information about\n"
        !          14054:        "Neighbor to display information about\n"
        !          14055:        "Display the dampened routes received from neighbor\n")
        !          14056: 
        !          14057: DEFUN (show_bgp_view_neighbor_routes,
        !          14058:        show_bgp_view_neighbor_routes_cmd,
        !          14059:        "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
        !          14060:        SHOW_STR
        !          14061:        BGP_STR
        !          14062:        "BGP view\n"
        !          14063:        "View name\n"
        !          14064:        "Detailed information on TCP and BGP neighbor connections\n"
        !          14065:        "Neighbor to display information about\n"
        !          14066:        "Neighbor to display information about\n"
        !          14067:        "Display routes learned from neighbor\n")
        !          14068: {
        !          14069:   struct peer *peer;
        !          14070: 
        !          14071:   if (argc == 2)
        !          14072:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
        !          14073:   else
        !          14074:     peer = peer_lookup_in_view (vty, NULL, argv[0]);
        !          14075:    
        !          14076:   if (! peer)
        !          14077:     return CMD_WARNING;
        !          14078: 
        !          14079:   return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
        !          14080:                                  bgp_show_type_neighbor);
        !          14081: }
        !          14082: 
1.1       misho    14083: ALIAS (show_bgp_view_neighbor_routes,
                   14084:        show_bgp_neighbor_routes_cmd,
                   14085:        "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
                   14086:        SHOW_STR
                   14087:        BGP_STR
                   14088:        "Detailed information on TCP and BGP neighbor connections\n"
                   14089:        "Neighbor to display information about\n"
                   14090:        "Neighbor to display information about\n"
                   14091:        "Display routes learned from neighbor\n")
                   14092: 
                   14093: ALIAS (show_bgp_view_neighbor_routes,
                   14094:        show_bgp_ipv6_neighbor_routes_cmd,
                   14095:        "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
                   14096:        SHOW_STR
                   14097:        BGP_STR
                   14098:        "Address family\n"
                   14099:        "Detailed information on TCP and BGP neighbor connections\n"
                   14100:        "Neighbor to display information about\n"
                   14101:        "Neighbor to display information about\n"
                   14102:        "Display routes learned from neighbor\n")
                   14103: 
                   14104: /* old command */
                   14105: ALIAS (show_bgp_view_neighbor_routes,
                   14106:        ipv6_bgp_neighbor_routes_cmd,
                   14107:        "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
                   14108:        SHOW_STR
                   14109:        IPV6_STR
                   14110:        BGP_STR
                   14111:        "Detailed information on TCP and BGP neighbor connections\n"
                   14112:        "Neighbor to display information about\n"
                   14113:        "Neighbor to display information about\n"
                   14114:        "Display routes learned from neighbor\n")
                   14115: 
                   14116: /* old command */
                   14117: DEFUN (ipv6_mbgp_neighbor_routes,
                   14118:        ipv6_mbgp_neighbor_routes_cmd,
                   14119:        "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
                   14120:        SHOW_STR
                   14121:        IPV6_STR
                   14122:        MBGP_STR
                   14123:        "Detailed information on TCP and BGP neighbor connections\n"
                   14124:        "Neighbor to display information about\n"
                   14125:        "Neighbor to display information about\n"
                   14126:        "Display routes learned from neighbor\n")
                   14127: {
                   14128:   struct peer *peer;
                   14129: 
                   14130:   peer = peer_lookup_in_view (vty, NULL, argv[0]);
                   14131:   if (! peer)
                   14132:     return CMD_WARNING;
                   14133:  
                   14134:   return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST,
                   14135:                                  bgp_show_type_neighbor);
                   14136: }
                   14137: 
                   14138: ALIAS (show_bgp_view_neighbor_flap,
                   14139:        show_bgp_ipv6_neighbor_flap_cmd,
                   14140:        "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
                   14141:        SHOW_STR
                   14142:        BGP_STR
                   14143:        "Address family\n"
                   14144:        "Detailed information on TCP and BGP neighbor connections\n"
                   14145:        "Neighbor to display information about\n"
                   14146:        "Neighbor to display information about\n"
                   14147:        "Display flap statistics of the routes learned from neighbor\n")
                   14148: 
                   14149: ALIAS (show_bgp_view_neighbor_damp,
                   14150:        show_bgp_ipv6_neighbor_damp_cmd,
                   14151:        "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
                   14152:        SHOW_STR
                   14153:        BGP_STR
                   14154:        "Address family\n"
                   14155:        "Detailed information on TCP and BGP neighbor connections\n"
                   14156:        "Neighbor to display information about\n"
                   14157:        "Neighbor to display information about\n"
                   14158:        "Display the dampened routes received from neighbor\n")
                   14159: 
                   14160: DEFUN (show_bgp_view_rsclient,
                   14161:        show_bgp_view_rsclient_cmd,
                   14162:        "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
                   14163:        SHOW_STR
                   14164:        BGP_STR
                   14165:        "BGP view\n"
1.1.1.4 ! misho    14166:        "View name\n"
1.1       misho    14167:        "Information about Route Server Client\n"
                   14168:        NEIGHBOR_ADDR_STR)
                   14169: {
                   14170:   struct bgp_table *table;
                   14171:   struct peer *peer;
                   14172: 
                   14173:   if (argc == 2)
                   14174:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
                   14175:   else
                   14176:     peer = peer_lookup_in_view (vty, NULL, argv[0]);
                   14177: 
                   14178:   if (! peer)
                   14179:     return CMD_WARNING;
                   14180: 
                   14181:   if (! peer->afc[AFI_IP6][SAFI_UNICAST])
                   14182:     {
                   14183:       vty_out (vty, "%% Activate the neighbor for the address family first%s",
                   14184:             VTY_NEWLINE);
                   14185:       return CMD_WARNING;
                   14186:     }
                   14187: 
                   14188:   if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
                   14189:               PEER_FLAG_RSERVER_CLIENT))
                   14190:     {
                   14191:       vty_out (vty, "%% Neighbor is not a Route-Server client%s",
                   14192:             VTY_NEWLINE);
                   14193:       return CMD_WARNING;
                   14194:     }
                   14195: 
                   14196:   table = peer->rib[AFI_IP6][SAFI_UNICAST];
                   14197: 
                   14198:   return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
                   14199: }
                   14200: 
1.1.1.4 ! misho    14201: ALIAS (show_bgp_view_rsclient,
        !          14202:        show_bgp_rsclient_cmd,
        !          14203:        "show bgp rsclient (A.B.C.D|X:X::X:X)",
        !          14204:        SHOW_STR
        !          14205:        BGP_STR
        !          14206:        "Information about Route Server Client\n"
        !          14207:        NEIGHBOR_ADDR_STR)
        !          14208: 
        !          14209: DEFUN (show_bgp_view_ipv4_rsclient,
        !          14210:        show_bgp_view_ipv4_rsclient_cmd,
        !          14211:        "show bgp view WORD ipv4 rsclient (A.B.C.D|X:X::X:X)",
        !          14212:        SHOW_STR
        !          14213:        BGP_STR
        !          14214:        "BGP view\n"
        !          14215:        "View name\n"
        !          14216:        "Address Family\n"
        !          14217:        "Information about Route Server Client\n"
        !          14218:        NEIGHBOR_ADDR_STR2)
        !          14219: {
        !          14220:   struct bgp_table     *table;
        !          14221:   struct peer          *peer;
        !          14222: 
        !          14223:   if (argc == 2)
        !          14224:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
        !          14225:   else
        !          14226:     peer = peer_lookup_in_view (vty, NULL, argv[0]);
        !          14227: 
        !          14228:   if (! peer)
        !          14229:     return CMD_WARNING;
        !          14230: 
        !          14231:   if (! peer->afc[AFI_IP][SAFI_UNICAST])
        !          14232:     {
        !          14233:       vty_out (vty, "%% Activate the neighbor for the address family first%s",
        !          14234:             VTY_NEWLINE);
        !          14235:       return CMD_WARNING;
        !          14236:     }
        !          14237: 
        !          14238:   if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
        !          14239:               PEER_FLAG_RSERVER_CLIENT))
        !          14240:     {
        !          14241:       vty_out (vty, "%% Neighbor is not a Route-Server client%s",
        !          14242:             VTY_NEWLINE);
        !          14243:       return CMD_WARNING;
        !          14244:     }
        !          14245: 
        !          14246:   table = peer->rib[AFI_IP][SAFI_UNICAST];
        !          14247: 
        !          14248:   return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
        !          14249: }
        !          14250: DEFUN (show_bgp_view_ipv6_rsclient,
        !          14251:        show_bgp_view_ipv6_rsclient_cmd,
        !          14252:        "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X)",
        !          14253:        SHOW_STR
        !          14254:        BGP_STR
        !          14255:        "BGP view\n"
        !          14256:        "BGP view name\n"
        !          14257:        "Address Family\n"
        !          14258:        "Information about Route Server Client\n"
        !          14259:        NEIGHBOR_ADDR_STR2)
        !          14260: {
        !          14261:   struct bgp_table     *table;
        !          14262:   struct peer          *peer;
        !          14263: 
        !          14264:   if (argc == 2)
        !          14265:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
        !          14266:   else
        !          14267:     peer = peer_lookup_in_view (vty, NULL, argv[0]);
        !          14268: 
        !          14269:   if (! peer)
        !          14270:     return CMD_WARNING;
        !          14271: 
        !          14272:   if (! peer->afc[AFI_IP6][SAFI_UNICAST])
        !          14273:     {
        !          14274:       vty_out (vty, "%% Activate the neighbor for the address family first%s",
        !          14275:             VTY_NEWLINE);
        !          14276:       return CMD_WARNING;
        !          14277:     }
        !          14278: 
        !          14279:   if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
        !          14280:               PEER_FLAG_RSERVER_CLIENT))
        !          14281:     {
        !          14282:       vty_out (vty, "%% Neighbor is not a Route-Server client%s",
        !          14283:             VTY_NEWLINE);
        !          14284:       return CMD_WARNING;
        !          14285:     }
        !          14286: 
        !          14287:   table = peer->rib[AFI_IP6][SAFI_UNICAST];
        !          14288: 
        !          14289:   return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
        !          14290: }
        !          14291: 
        !          14292: ALIAS (show_bgp_view_ipv4_rsclient,
        !          14293:        show_bgp_ipv4_rsclient_cmd,
        !          14294:        "show bgp ipv4 rsclient (A.B.C.D|X:X::X:X)",
1.1       misho    14295:        SHOW_STR
                   14296:        BGP_STR
1.1.1.4 ! misho    14297:        "Address Family\n"
1.1       misho    14298:        "Information about Route Server Client\n"
1.1.1.4 ! misho    14299:        NEIGHBOR_ADDR_STR2)
        !          14300: 
        !          14301: ALIAS (show_bgp_view_ipv6_rsclient,
        !          14302:        show_bgp_ipv6_rsclient_cmd,
        !          14303:        "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X)",
        !          14304:        SHOW_STR
        !          14305:        BGP_STR
        !          14306:        "Address Family\n"
        !          14307:        "Information about Route Server Client\n"
        !          14308:        NEIGHBOR_ADDR_STR2)
1.1       misho    14309: 
                   14310: DEFUN (show_bgp_view_ipv6_safi_rsclient,
                   14311:        show_bgp_view_ipv6_safi_rsclient_cmd,
                   14312:        "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
                   14313:        SHOW_STR
                   14314:        BGP_STR
                   14315:        "BGP view\n"
1.1.1.4 ! misho    14316:        "View name\n"
1.1       misho    14317:        "Address family\n"
                   14318:        "Address Family modifier\n"
                   14319:        "Address Family modifier\n"
                   14320:        "Information about Route Server Client\n"
                   14321:        NEIGHBOR_ADDR_STR)
                   14322: {
                   14323:   struct bgp_table *table;
                   14324:   struct peer *peer;
                   14325:   safi_t safi;
                   14326: 
                   14327:   if (argc == 3) {
                   14328:     peer = peer_lookup_in_view (vty, argv[0], argv[2]);
                   14329:     safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
                   14330:   } else {
                   14331:     peer = peer_lookup_in_view (vty, NULL, argv[1]);
                   14332:     safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
                   14333:   }
                   14334: 
                   14335:   if (! peer)
                   14336:     return CMD_WARNING;
                   14337: 
                   14338:   if (! peer->afc[AFI_IP6][safi])
                   14339:     {
                   14340:       vty_out (vty, "%% Activate the neighbor for the address family first%s",
                   14341:             VTY_NEWLINE);
                   14342:       return CMD_WARNING;
                   14343:     }
                   14344: 
                   14345:   if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
                   14346:               PEER_FLAG_RSERVER_CLIENT))
                   14347:     {
                   14348:       vty_out (vty, "%% Neighbor is not a Route-Server client%s",
                   14349:             VTY_NEWLINE);
                   14350:       return CMD_WARNING;
                   14351:     }
                   14352: 
                   14353:   table = peer->rib[AFI_IP6][safi];
                   14354: 
                   14355:   return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
                   14356: }
                   14357: 
                   14358: ALIAS (show_bgp_view_ipv6_safi_rsclient,
                   14359:        show_bgp_ipv6_safi_rsclient_cmd,
                   14360:        "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
                   14361:        SHOW_STR
                   14362:        BGP_STR
                   14363:        "Address family\n"
                   14364:        "Address Family modifier\n"
                   14365:        "Address Family modifier\n"
                   14366:        "Information about Route Server Client\n"
                   14367:        NEIGHBOR_ADDR_STR)
                   14368: 
                   14369: DEFUN (show_bgp_view_rsclient_route,
                   14370:        show_bgp_view_rsclient_route_cmd,
                   14371:        "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
                   14372:        SHOW_STR
                   14373:        BGP_STR
                   14374:        "BGP view\n"
1.1.1.4 ! misho    14375:        "View name\n"
        !          14376:        "Information about Route Server Client\n"
        !          14377:        NEIGHBOR_ADDR_STR
        !          14378:        "Network in the BGP routing table to display\n")
        !          14379: {
        !          14380:   struct bgp *bgp;
        !          14381:   struct peer *peer;
        !          14382: 
        !          14383:   /* BGP structure lookup. */
        !          14384:   if (argc == 3)
        !          14385:     {
        !          14386:       bgp = bgp_lookup_by_name (argv[0]);
        !          14387:       if (bgp == NULL)
        !          14388:         {
        !          14389:           vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
        !          14390:           return CMD_WARNING;
        !          14391:         }
        !          14392:     }
        !          14393:   else
        !          14394:     {
        !          14395:       bgp = bgp_get_default ();
        !          14396:       if (bgp == NULL)
        !          14397:         {
        !          14398:           vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
        !          14399:           return CMD_WARNING;
        !          14400:         }
        !          14401:     }
        !          14402: 
        !          14403:   if (argc == 3)
        !          14404:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
        !          14405:   else
        !          14406:     peer = peer_lookup_in_view (vty, NULL, argv[0]);
        !          14407: 
        !          14408:   if (! peer)
        !          14409:     return CMD_WARNING;
        !          14410: 
        !          14411:   if (! peer->afc[AFI_IP6][SAFI_UNICAST])
        !          14412:     {
        !          14413:       vty_out (vty, "%% Activate the neighbor for the address family first%s",
        !          14414:             VTY_NEWLINE);
        !          14415:       return CMD_WARNING;
        !          14416:     }
        !          14417: 
        !          14418:   if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
        !          14419:               PEER_FLAG_RSERVER_CLIENT))
        !          14420:     {
        !          14421:       vty_out (vty, "%% Neighbor is not a Route-Server client%s",
        !          14422:             VTY_NEWLINE);
        !          14423:       return CMD_WARNING;
        !          14424:     }
        !          14425: 
        !          14426:   return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
        !          14427:                                   (argc == 3) ? argv[2] : argv[1],
        !          14428:                                   AFI_IP6, SAFI_UNICAST, NULL, 0);
        !          14429: }
        !          14430: 
        !          14431: DEFUN (show_bgp_view_ipv6_rsclient_route,
        !          14432:        show_bgp_view_ipv6_rsclient_route_cmd,
        !          14433:        "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
        !          14434:        SHOW_STR
        !          14435:        BGP_STR
        !          14436:        "BGP view\n"
1.1       misho    14437:        "BGP view name\n"
1.1.1.4 ! misho    14438:        "IP6_STR"
1.1       misho    14439:        "Information about Route Server Client\n"
                   14440:        NEIGHBOR_ADDR_STR
                   14441:        "Network in the BGP routing table to display\n")
                   14442: {
                   14443:   struct bgp *bgp;
                   14444:   struct peer *peer;
                   14445: 
                   14446:   /* BGP structure lookup. */
                   14447:   if (argc == 3)
                   14448:     {
                   14449:       bgp = bgp_lookup_by_name (argv[0]);
                   14450:       if (bgp == NULL)
                   14451:         {
                   14452:           vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
                   14453:           return CMD_WARNING;
                   14454:         }
                   14455:     }
                   14456:   else
                   14457:     {
                   14458:       bgp = bgp_get_default ();
                   14459:       if (bgp == NULL)
                   14460:         {
                   14461:           vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
                   14462:           return CMD_WARNING;
                   14463:         }
                   14464:     }
                   14465: 
                   14466:   if (argc == 3)
                   14467:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
                   14468:   else
                   14469:     peer = peer_lookup_in_view (vty, NULL, argv[0]);
                   14470: 
                   14471:   if (! peer)
                   14472:     return CMD_WARNING;
                   14473: 
                   14474:   if (! peer->afc[AFI_IP6][SAFI_UNICAST])
                   14475:     {
                   14476:       vty_out (vty, "%% Activate the neighbor for the address family first%s",
                   14477:             VTY_NEWLINE);
                   14478:       return CMD_WARNING;
                   14479:     }
                   14480: 
                   14481:   if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
                   14482:               PEER_FLAG_RSERVER_CLIENT))
                   14483:     {
                   14484:       vty_out (vty, "%% Neighbor is not a Route-Server client%s",
                   14485:             VTY_NEWLINE);
                   14486:       return CMD_WARNING;
                   14487:     }
                   14488: 
                   14489:   return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
                   14490:                                   (argc == 3) ? argv[2] : argv[1],
                   14491:                                   AFI_IP6, SAFI_UNICAST, NULL, 0);
                   14492: }
                   14493: 
1.1.1.4 ! misho    14494: ALIAS (show_bgp_view_ipv6_rsclient_route,
1.1       misho    14495:        show_bgp_rsclient_route_cmd,
                   14496:        "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
                   14497:        SHOW_STR
                   14498:        BGP_STR
                   14499:        "Information about Route Server Client\n"
                   14500:        NEIGHBOR_ADDR_STR
                   14501:        "Network in the BGP routing table to display\n")
                   14502: 
1.1.1.4 ! misho    14503: ALIAS (show_bgp_view_ipv6_rsclient_route,
        !          14504:        show_bgp_ipv6_rsclient_route_cmd,
        !          14505:        "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
        !          14506:        SHOW_STR
        !          14507:        BGP_STR
        !          14508:        IP6_STR
        !          14509:        "Information about Route Server Client\n"
        !          14510:        NEIGHBOR_ADDR_STR
        !          14511:        "Network in the BGP routing table to display\n")
        !          14512: 
1.1       misho    14513: DEFUN (show_bgp_view_ipv6_safi_rsclient_route,
                   14514:        show_bgp_view_ipv6_safi_rsclient_route_cmd,
                   14515:        "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
                   14516:        SHOW_STR
                   14517:        BGP_STR
                   14518:        "BGP view\n"
1.1.1.4 ! misho    14519:        "View name\n"
1.1       misho    14520:        "Address family\n"
                   14521:        "Address Family modifier\n"
                   14522:        "Address Family modifier\n"
                   14523:        "Information about Route Server Client\n"
                   14524:        NEIGHBOR_ADDR_STR
                   14525:        "Network in the BGP routing table to display\n")
                   14526: {
                   14527:   struct bgp *bgp;
                   14528:   struct peer *peer;
                   14529:   safi_t safi;
                   14530: 
                   14531:   /* BGP structure lookup. */
                   14532:   if (argc == 4)
                   14533:     {
                   14534:       bgp = bgp_lookup_by_name (argv[0]);
                   14535:       if (bgp == NULL)
                   14536:        {
                   14537:          vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
                   14538:          return CMD_WARNING;
                   14539:        }
                   14540:     }
                   14541:   else
                   14542:     {
                   14543:       bgp = bgp_get_default ();
                   14544:       if (bgp == NULL)
                   14545:        {
                   14546:          vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
                   14547:          return CMD_WARNING;
                   14548:        }
                   14549:     }
                   14550: 
                   14551:   if (argc == 4) {
                   14552:     peer = peer_lookup_in_view (vty, argv[0], argv[2]);
                   14553:     safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
                   14554:   } else {
                   14555:     peer = peer_lookup_in_view (vty, NULL, argv[1]);
                   14556:     safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
                   14557:   }
                   14558: 
                   14559:   if (! peer)
                   14560:     return CMD_WARNING;
                   14561: 
                   14562:   if (! peer->afc[AFI_IP6][safi])
                   14563:     {
                   14564:       vty_out (vty, "%% Activate the neighbor for the address family first%s",
                   14565:             VTY_NEWLINE);
                   14566:       return CMD_WARNING;
                   14567: }
                   14568: 
                   14569:   if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
                   14570:               PEER_FLAG_RSERVER_CLIENT))
                   14571:     {
                   14572:       vty_out (vty, "%% Neighbor is not a Route-Server client%s",
                   14573:             VTY_NEWLINE);
                   14574:       return CMD_WARNING;
                   14575:     }
                   14576: 
                   14577:   return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
                   14578:                                   (argc == 4) ? argv[3] : argv[2],
                   14579:                                   AFI_IP6, safi, NULL, 0);
                   14580: }
                   14581: 
                   14582: ALIAS (show_bgp_view_ipv6_safi_rsclient_route,
                   14583:        show_bgp_ipv6_safi_rsclient_route_cmd,
                   14584:        "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
                   14585:        SHOW_STR
                   14586:        BGP_STR
                   14587:        "Address family\n"
                   14588:        "Address Family modifier\n"
                   14589:        "Address Family modifier\n"
                   14590:        "Information about Route Server Client\n"
                   14591:        NEIGHBOR_ADDR_STR
                   14592:        "Network in the BGP routing table to display\n")
                   14593: 
1.1.1.4 ! misho    14594: 
1.1       misho    14595: DEFUN (show_bgp_view_rsclient_prefix,
                   14596:        show_bgp_view_rsclient_prefix_cmd,
                   14597:        "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
                   14598:        SHOW_STR
                   14599:        BGP_STR
                   14600:        "BGP view\n"
1.1.1.4 ! misho    14601:        "View name\n"
        !          14602:        "Information about Route Server Client\n"
        !          14603:        NEIGHBOR_ADDR_STR
        !          14604:        "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
        !          14605: {
        !          14606:   struct bgp *bgp;
        !          14607:   struct peer *peer;
        !          14608: 
        !          14609:   /* BGP structure lookup. */
        !          14610:   if (argc == 3)
        !          14611:     {
        !          14612:       bgp = bgp_lookup_by_name (argv[0]);
        !          14613:       if (bgp == NULL)
        !          14614:         {
        !          14615:           vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
        !          14616:           return CMD_WARNING;
        !          14617:         }
        !          14618:     }
        !          14619:   else
        !          14620:     {
        !          14621:       bgp = bgp_get_default ();
        !          14622:       if (bgp == NULL)
        !          14623:         {
        !          14624:           vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
        !          14625:           return CMD_WARNING;
        !          14626:         }
        !          14627:     }
        !          14628: 
        !          14629:   if (argc == 3)
        !          14630:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
        !          14631:   else
        !          14632:     peer = peer_lookup_in_view (vty, NULL, argv[0]);
        !          14633: 
        !          14634:   if (! peer)
        !          14635:     return CMD_WARNING;
        !          14636: 
        !          14637:   if (! peer->afc[AFI_IP6][SAFI_UNICAST])
        !          14638:     {
        !          14639:       vty_out (vty, "%% Activate the neighbor for the address family first%s",
        !          14640:             VTY_NEWLINE);
        !          14641:       return CMD_WARNING;
        !          14642:     }
        !          14643: 
        !          14644:   if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
        !          14645:               PEER_FLAG_RSERVER_CLIENT))
        !          14646:     {
        !          14647:       vty_out (vty, "%% Neighbor is not a Route-Server client%s",
        !          14648:             VTY_NEWLINE);
        !          14649:       return CMD_WARNING;
        !          14650:     }
        !          14651: 
        !          14652:   return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
        !          14653:                                   (argc == 3) ? argv[2] : argv[1],
        !          14654:                                   AFI_IP6, SAFI_UNICAST, NULL, 1);
        !          14655: }
        !          14656: 
        !          14657: DEFUN (show_bgp_view_ipv6_rsclient_prefix,
        !          14658:        show_bgp_view_ipv6_rsclient_prefix_cmd,
        !          14659:        "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
        !          14660:        SHOW_STR
        !          14661:        BGP_STR
        !          14662:        "BGP view\n"
        !          14663:        "View name\n"
        !          14664:        IP6_STR
1.1       misho    14665:        "Information about Route Server Client\n"
                   14666:        NEIGHBOR_ADDR_STR
                   14667:        "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
                   14668: {
                   14669:   struct bgp *bgp;
                   14670:   struct peer *peer;
                   14671: 
                   14672:   /* BGP structure lookup. */
                   14673:   if (argc == 3)
                   14674:     {
                   14675:       bgp = bgp_lookup_by_name (argv[0]);
                   14676:       if (bgp == NULL)
                   14677:         {
                   14678:           vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
                   14679:           return CMD_WARNING;
                   14680:         }
                   14681:     }
                   14682:   else
                   14683:     {
                   14684:       bgp = bgp_get_default ();
                   14685:       if (bgp == NULL)
                   14686:         {
                   14687:           vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
                   14688:           return CMD_WARNING;
                   14689:         }
                   14690:     }
                   14691: 
                   14692:   if (argc == 3)
                   14693:     peer = peer_lookup_in_view (vty, argv[0], argv[1]);
                   14694:   else
                   14695:     peer = peer_lookup_in_view (vty, NULL, argv[0]);
                   14696: 
                   14697:   if (! peer)
                   14698:     return CMD_WARNING;
                   14699: 
                   14700:   if (! peer->afc[AFI_IP6][SAFI_UNICAST])
                   14701:     {
                   14702:       vty_out (vty, "%% Activate the neighbor for the address family first%s",
                   14703:             VTY_NEWLINE);
                   14704:       return CMD_WARNING;
                   14705:     }
                   14706: 
                   14707:   if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
                   14708:               PEER_FLAG_RSERVER_CLIENT))
                   14709:     {
                   14710:       vty_out (vty, "%% Neighbor is not a Route-Server client%s",
                   14711:             VTY_NEWLINE);
                   14712:       return CMD_WARNING;
                   14713:     }
                   14714: 
                   14715:   return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
                   14716:                                   (argc == 3) ? argv[2] : argv[1],
                   14717:                                   AFI_IP6, SAFI_UNICAST, NULL, 1);
                   14718: }
                   14719: 
1.1.1.4 ! misho    14720: ALIAS (show_bgp_view_ipv6_rsclient_prefix,
1.1       misho    14721:        show_bgp_rsclient_prefix_cmd,
                   14722:        "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
                   14723:        SHOW_STR
                   14724:        BGP_STR
                   14725:        "Information about Route Server Client\n"
                   14726:        NEIGHBOR_ADDR_STR
                   14727:        "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
                   14728: 
1.1.1.4 ! misho    14729: ALIAS (show_bgp_view_ipv6_rsclient_prefix,
        !          14730:        show_bgp_ipv6_rsclient_prefix_cmd,
        !          14731:        "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
        !          14732:        SHOW_STR
        !          14733:        BGP_STR
        !          14734:        "Information about Route Server Client\n"
        !          14735:        NEIGHBOR_ADDR_STR
        !          14736:        "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
        !          14737: 
1.1       misho    14738: DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix,
                   14739:        show_bgp_view_ipv6_safi_rsclient_prefix_cmd,
                   14740:        "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
                   14741:        SHOW_STR
                   14742:        BGP_STR
                   14743:        "BGP view\n"
1.1.1.4 ! misho    14744:        "View name\n"
1.1       misho    14745:        "Address family\n"
                   14746:        "Address Family modifier\n"
                   14747:        "Address Family modifier\n"
                   14748:        "Information about Route Server Client\n"
                   14749:        NEIGHBOR_ADDR_STR
                   14750:        "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
                   14751: {
                   14752:   struct bgp *bgp;
                   14753:   struct peer *peer;
                   14754:   safi_t safi;
                   14755: 
                   14756:   /* BGP structure lookup. */
                   14757:   if (argc == 4)
                   14758:     {
                   14759:       bgp = bgp_lookup_by_name (argv[0]);
                   14760:       if (bgp == NULL)
                   14761:        {
                   14762:          vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
                   14763:          return CMD_WARNING;
                   14764:        }
                   14765:     }
                   14766:   else
                   14767:     {
                   14768:       bgp = bgp_get_default ();
                   14769:       if (bgp == NULL)
                   14770:        {
                   14771:          vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
                   14772:          return CMD_WARNING;
                   14773:        }
                   14774:     }
                   14775: 
                   14776:   if (argc == 4) {
                   14777:     peer = peer_lookup_in_view (vty, argv[0], argv[2]);
                   14778:     safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
                   14779:   } else {
                   14780:     peer = peer_lookup_in_view (vty, NULL, argv[1]);
                   14781:     safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
                   14782:   }
                   14783: 
                   14784:   if (! peer)
                   14785:     return CMD_WARNING;
                   14786: 
                   14787:   if (! peer->afc[AFI_IP6][safi])
                   14788:     {
                   14789:       vty_out (vty, "%% Activate the neighbor for the address family first%s",
                   14790:             VTY_NEWLINE);
                   14791:       return CMD_WARNING;
                   14792: }
                   14793: 
                   14794:   if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
                   14795:               PEER_FLAG_RSERVER_CLIENT))
                   14796: {
                   14797:       vty_out (vty, "%% Neighbor is not a Route-Server client%s",
                   14798:             VTY_NEWLINE);
                   14799:     return CMD_WARNING;
                   14800:     }
                   14801: 
                   14802:   return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
                   14803:                                   (argc == 4) ? argv[3] : argv[2],
                   14804:                                   AFI_IP6, safi, NULL, 1);
                   14805: }
                   14806: 
                   14807: ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix,
                   14808:        show_bgp_ipv6_safi_rsclient_prefix_cmd,
                   14809:        "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
                   14810:        SHOW_STR
                   14811:        BGP_STR
                   14812:        "Address family\n"
                   14813:        "Address Family modifier\n"
                   14814:        "Address Family modifier\n"
                   14815:        "Information about Route Server Client\n"
                   14816:        NEIGHBOR_ADDR_STR
                   14817:        "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
                   14818: 
                   14819: struct bgp_table *bgp_distance_table;
                   14820: 
                   14821: struct bgp_distance
                   14822: {
                   14823:   /* Distance value for the IP source prefix. */
                   14824:   u_char distance;
                   14825: 
                   14826:   /* Name of the access-list to be matched. */
                   14827:   char *access_list;
                   14828: };
                   14829: 
                   14830: static struct bgp_distance *
                   14831: bgp_distance_new (void)
                   14832: {
                   14833:   return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance));
                   14834: }
                   14835: 
                   14836: static void
                   14837: bgp_distance_free (struct bgp_distance *bdistance)
                   14838: {
                   14839:   XFREE (MTYPE_BGP_DISTANCE, bdistance);
                   14840: }
                   14841: 
                   14842: static int
                   14843: bgp_distance_set (struct vty *vty, const char *distance_str, 
                   14844:                   const char *ip_str, const char *access_list_str)
                   14845: {
                   14846:   int ret;
                   14847:   struct prefix_ipv4 p;
                   14848:   u_char distance;
                   14849:   struct bgp_node *rn;
                   14850:   struct bgp_distance *bdistance;
                   14851: 
                   14852:   ret = str2prefix_ipv4 (ip_str, &p);
                   14853:   if (ret == 0)
                   14854:     {
                   14855:       vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
                   14856:       return CMD_WARNING;
                   14857:     }
                   14858: 
                   14859:   distance = atoi (distance_str);
                   14860: 
                   14861:   /* Get BGP distance node. */
                   14862:   rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p);
                   14863:   if (rn->info)
                   14864:     {
                   14865:       bdistance = rn->info;
                   14866:       bgp_unlock_node (rn);
                   14867:     }
                   14868:   else
                   14869:     {
                   14870:       bdistance = bgp_distance_new ();
                   14871:       rn->info = bdistance;
                   14872:     }
                   14873: 
                   14874:   /* Set distance value. */
                   14875:   bdistance->distance = distance;
                   14876: 
                   14877:   /* Reset access-list configuration. */
                   14878:   if (bdistance->access_list)
                   14879:     {
                   14880:       free (bdistance->access_list);
                   14881:       bdistance->access_list = NULL;
                   14882:     }
                   14883:   if (access_list_str)
                   14884:     bdistance->access_list = strdup (access_list_str);
                   14885: 
                   14886:   return CMD_SUCCESS;
                   14887: }
                   14888: 
                   14889: static int
                   14890: bgp_distance_unset (struct vty *vty, const char *distance_str, 
                   14891:                     const char *ip_str, const char *access_list_str)
                   14892: {
                   14893:   int ret;
                   14894:   struct prefix_ipv4 p;
                   14895:   u_char distance;
                   14896:   struct bgp_node *rn;
                   14897:   struct bgp_distance *bdistance;
                   14898: 
                   14899:   ret = str2prefix_ipv4 (ip_str, &p);
                   14900:   if (ret == 0)
                   14901:     {
                   14902:       vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
                   14903:       return CMD_WARNING;
                   14904:     }
                   14905: 
                   14906:   distance = atoi (distance_str);
                   14907: 
                   14908:   rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p);
                   14909:   if (! rn)
                   14910:     {
                   14911:       vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE);
                   14912:       return CMD_WARNING;
                   14913:     }
                   14914: 
                   14915:   bdistance = rn->info;
1.1.1.4 ! misho    14916:   
        !          14917:   if (bdistance->distance != distance)
        !          14918:     {
        !          14919:        vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE);
        !          14920:        return CMD_WARNING;
        !          14921:     }
        !          14922:   
1.1       misho    14923:   if (bdistance->access_list)
                   14924:     free (bdistance->access_list);
                   14925:   bgp_distance_free (bdistance);
                   14926: 
                   14927:   rn->info = NULL;
                   14928:   bgp_unlock_node (rn);
                   14929:   bgp_unlock_node (rn);
                   14930: 
                   14931:   return CMD_SUCCESS;
                   14932: }
                   14933: 
                   14934: /* Apply BGP information to distance method. */
                   14935: u_char
                   14936: bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
                   14937: {
                   14938:   struct bgp_node *rn;
                   14939:   struct prefix_ipv4 q;
                   14940:   struct peer *peer;
                   14941:   struct bgp_distance *bdistance;
                   14942:   struct access_list *alist;
                   14943:   struct bgp_static *bgp_static;
                   14944: 
                   14945:   if (! bgp)
                   14946:     return 0;
                   14947: 
                   14948:   if (p->family != AF_INET)
                   14949:     return 0;
                   14950: 
                   14951:   peer = rinfo->peer;
                   14952: 
                   14953:   if (peer->su.sa.sa_family != AF_INET)
                   14954:     return 0;
                   14955: 
                   14956:   memset (&q, 0, sizeof (struct prefix_ipv4));
                   14957:   q.family = AF_INET;
                   14958:   q.prefix = peer->su.sin.sin_addr;
                   14959:   q.prefixlen = IPV4_MAX_BITLEN;
                   14960: 
                   14961:   /* Check source address. */
                   14962:   rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
                   14963:   if (rn)
                   14964:     {
                   14965:       bdistance = rn->info;
                   14966:       bgp_unlock_node (rn);
                   14967: 
                   14968:       if (bdistance->access_list)
                   14969:        {
                   14970:          alist = access_list_lookup (AFI_IP, bdistance->access_list);
                   14971:          if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
                   14972:            return bdistance->distance;
                   14973:        }
                   14974:       else
                   14975:        return bdistance->distance;
                   14976:     }
                   14977: 
                   14978:   /* Backdoor check. */
                   14979:   rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p);
                   14980:   if (rn)
                   14981:     {
                   14982:       bgp_static = rn->info;
                   14983:       bgp_unlock_node (rn);
                   14984: 
                   14985:       if (bgp_static->backdoor)
                   14986:        {
                   14987:          if (bgp->distance_local)
                   14988:            return bgp->distance_local;
                   14989:          else
                   14990:            return ZEBRA_IBGP_DISTANCE_DEFAULT;
                   14991:        }
                   14992:     }
                   14993: 
1.1.1.3   misho    14994:   if (peer->sort == BGP_PEER_EBGP)
1.1       misho    14995:     {
                   14996:       if (bgp->distance_ebgp)
                   14997:        return bgp->distance_ebgp;
                   14998:       return ZEBRA_EBGP_DISTANCE_DEFAULT;
                   14999:     }
                   15000:   else
                   15001:     {
                   15002:       if (bgp->distance_ibgp)
                   15003:        return bgp->distance_ibgp;
                   15004:       return ZEBRA_IBGP_DISTANCE_DEFAULT;
                   15005:     }
                   15006: }
                   15007: 
                   15008: DEFUN (bgp_distance,
                   15009:        bgp_distance_cmd,
                   15010:        "distance bgp <1-255> <1-255> <1-255>",
                   15011:        "Define an administrative distance\n"
                   15012:        "BGP distance\n"
                   15013:        "Distance for routes external to the AS\n"
                   15014:        "Distance for routes internal to the AS\n"
                   15015:        "Distance for local routes\n")
                   15016: {
                   15017:   struct bgp *bgp;
                   15018: 
                   15019:   bgp = vty->index;
                   15020: 
                   15021:   bgp->distance_ebgp = atoi (argv[0]);
                   15022:   bgp->distance_ibgp = atoi (argv[1]);
                   15023:   bgp->distance_local = atoi (argv[2]);
                   15024:   return CMD_SUCCESS;
                   15025: }
                   15026: 
                   15027: DEFUN (no_bgp_distance,
                   15028:        no_bgp_distance_cmd,
                   15029:        "no distance bgp <1-255> <1-255> <1-255>",
                   15030:        NO_STR
                   15031:        "Define an administrative distance\n"
                   15032:        "BGP distance\n"
                   15033:        "Distance for routes external to the AS\n"
                   15034:        "Distance for routes internal to the AS\n"
                   15035:        "Distance for local routes\n")
                   15036: {
                   15037:   struct bgp *bgp;
                   15038: 
                   15039:   bgp = vty->index;
                   15040: 
                   15041:   bgp->distance_ebgp= 0;
                   15042:   bgp->distance_ibgp = 0;
                   15043:   bgp->distance_local = 0;
                   15044:   return CMD_SUCCESS;
                   15045: }
                   15046: 
                   15047: ALIAS (no_bgp_distance,
                   15048:        no_bgp_distance2_cmd,
                   15049:        "no distance bgp",
                   15050:        NO_STR
                   15051:        "Define an administrative distance\n"
                   15052:        "BGP distance\n")
                   15053: 
                   15054: DEFUN (bgp_distance_source,
                   15055:        bgp_distance_source_cmd,
                   15056:        "distance <1-255> A.B.C.D/M",
                   15057:        "Define an administrative distance\n"
                   15058:        "Administrative distance\n"
                   15059:        "IP source prefix\n")
                   15060: {
                   15061:   bgp_distance_set (vty, argv[0], argv[1], NULL);
                   15062:   return CMD_SUCCESS;
                   15063: }
                   15064: 
                   15065: DEFUN (no_bgp_distance_source,
                   15066:        no_bgp_distance_source_cmd,
                   15067:        "no distance <1-255> A.B.C.D/M",
                   15068:        NO_STR
                   15069:        "Define an administrative distance\n"
                   15070:        "Administrative distance\n"
                   15071:        "IP source prefix\n")
                   15072: {
                   15073:   bgp_distance_unset (vty, argv[0], argv[1], NULL);
                   15074:   return CMD_SUCCESS;
                   15075: }
                   15076: 
                   15077: DEFUN (bgp_distance_source_access_list,
                   15078:        bgp_distance_source_access_list_cmd,
                   15079:        "distance <1-255> A.B.C.D/M WORD",
                   15080:        "Define an administrative distance\n"
                   15081:        "Administrative distance\n"
                   15082:        "IP source prefix\n"
                   15083:        "Access list name\n")
                   15084: {
                   15085:   bgp_distance_set (vty, argv[0], argv[1], argv[2]);
                   15086:   return CMD_SUCCESS;
                   15087: }
                   15088: 
                   15089: DEFUN (no_bgp_distance_source_access_list,
                   15090:        no_bgp_distance_source_access_list_cmd,
                   15091:        "no distance <1-255> A.B.C.D/M WORD",
                   15092:        NO_STR
                   15093:        "Define an administrative distance\n"
                   15094:        "Administrative distance\n"
                   15095:        "IP source prefix\n"
                   15096:        "Access list name\n")
                   15097: {
                   15098:   bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
                   15099:   return CMD_SUCCESS;
                   15100: }
1.1.1.4 ! misho    15101: 
1.1       misho    15102: DEFUN (bgp_damp_set,
                   15103:        bgp_damp_set_cmd,
                   15104:        "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
                   15105:        "BGP Specific commands\n"
                   15106:        "Enable route-flap dampening\n"
                   15107:        "Half-life time for the penalty\n"
                   15108:        "Value to start reusing a route\n"
                   15109:        "Value to start suppressing a route\n"
                   15110:        "Maximum duration to suppress a stable route\n")
                   15111: {
                   15112:   struct bgp *bgp;
                   15113:   int half = DEFAULT_HALF_LIFE * 60;
                   15114:   int reuse = DEFAULT_REUSE;
                   15115:   int suppress = DEFAULT_SUPPRESS;
                   15116:   int max = 4 * half;
                   15117: 
                   15118:   if (argc == 4)
                   15119:     {
                   15120:       half = atoi (argv[0]) * 60;
                   15121:       reuse = atoi (argv[1]);
                   15122:       suppress = atoi (argv[2]);
                   15123:       max = atoi (argv[3]) * 60;
                   15124:     }
                   15125:   else if (argc == 1)
                   15126:     {
                   15127:       half = atoi (argv[0]) * 60;
                   15128:       max = 4 * half;
                   15129:     }
                   15130: 
                   15131:   bgp = vty->index;
1.1.1.4 ! misho    15132: 
        !          15133:   if (suppress < reuse)
        !          15134:     {
        !          15135:       vty_out (vty, "Suppress value cannot be less than reuse value %s",
        !          15136:                     VTY_NEWLINE);
        !          15137:       return 0;
        !          15138:     }
        !          15139: 
1.1       misho    15140:   return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty),
                   15141:                          half, reuse, suppress, max);
                   15142: }
                   15143: 
                   15144: ALIAS (bgp_damp_set,
                   15145:        bgp_damp_set2_cmd,
                   15146:        "bgp dampening <1-45>",
                   15147:        "BGP Specific commands\n"
                   15148:        "Enable route-flap dampening\n"
                   15149:        "Half-life time for the penalty\n")
                   15150: 
                   15151: ALIAS (bgp_damp_set,
                   15152:        bgp_damp_set3_cmd,
                   15153:        "bgp dampening",
                   15154:        "BGP Specific commands\n"
                   15155:        "Enable route-flap dampening\n")
                   15156: 
                   15157: DEFUN (bgp_damp_unset,
                   15158:        bgp_damp_unset_cmd,
                   15159:        "no bgp dampening",
                   15160:        NO_STR
                   15161:        "BGP Specific commands\n"
                   15162:        "Enable route-flap dampening\n")
                   15163: {
                   15164:   struct bgp *bgp;
                   15165: 
                   15166:   bgp = vty->index;
                   15167:   return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty));
                   15168: }
                   15169: 
                   15170: ALIAS (bgp_damp_unset,
                   15171:        bgp_damp_unset2_cmd,
                   15172:        "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
                   15173:        NO_STR
                   15174:        "BGP Specific commands\n"
                   15175:        "Enable route-flap dampening\n"
                   15176:        "Half-life time for the penalty\n"
                   15177:        "Value to start reusing a route\n"
                   15178:        "Value to start suppressing a route\n"
                   15179:        "Maximum duration to suppress a stable route\n")
                   15180: 
                   15181: DEFUN (show_ip_bgp_dampened_paths,
                   15182:        show_ip_bgp_dampened_paths_cmd,
                   15183:        "show ip bgp dampened-paths",
                   15184:        SHOW_STR
                   15185:        IP_STR
                   15186:        BGP_STR
                   15187:        "Display paths suppressed due to dampening\n")
                   15188: {
                   15189:   return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths,
                   15190:                    NULL);
                   15191: }
                   15192: 
1.1.1.4 ! misho    15193: ALIAS (show_ip_bgp_dampened_paths,
        !          15194:        show_ip_bgp_damp_dampened_paths_cmd,
        !          15195:        "show ip bgp dampening dampened-paths",
        !          15196:        SHOW_STR
        !          15197:        IP_STR
        !          15198:        BGP_STR
        !          15199:        "Display detailed information about dampening\n"
        !          15200:        "Display paths suppressed due to dampening\n")
        !          15201: 
1.1       misho    15202: DEFUN (show_ip_bgp_flap_statistics,
                   15203:        show_ip_bgp_flap_statistics_cmd,
                   15204:        "show ip bgp flap-statistics",
                   15205:        SHOW_STR
1.1.1.4 ! misho    15206:        IP_STR
        !          15207:        BGP_STR
        !          15208:        "Display flap statistics of routes\n")
        !          15209: {
        !          15210:   return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
        !          15211:                    bgp_show_type_flap_statistics, NULL);
        !          15212: }
        !          15213: 
        !          15214: ALIAS (show_ip_bgp_flap_statistics,
        !          15215:        show_ip_bgp_damp_flap_statistics_cmd,
        !          15216:        "show ip bgp dampening flap-statistics",
        !          15217:        SHOW_STR
        !          15218:        IP_STR
        !          15219:        BGP_STR
        !          15220:        "Display detailed information about dampening\n"
        !          15221:        "Display flap statistics of routes\n")
        !          15222: 
        !          15223: DEFUN (show_bgp_ipv4_safi_dampened_paths,
        !          15224:        show_bgp_ipv4_safi_dampened_paths_cmd,
        !          15225:        "show bgp ipv4 (encap|multicast|unicast|vpn) dampened-paths",
        !          15226:        SHOW_STR
        !          15227:        BGP_STR
        !          15228:        IP_STR
        !          15229:        "Address Family modifier\n"
        !          15230:        "Address Family modifier\n"
        !          15231:        "Address Family modifier\n"
        !          15232:        "Address Family modifier\n"
        !          15233:        "Display paths suppressed due to dampening\n")
        !          15234: {
        !          15235:   safi_t       safi;
        !          15236: 
        !          15237:   if (bgp_parse_safi(argv[0], &safi)) {
        !          15238:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          15239:     return CMD_WARNING;
        !          15240:   }
        !          15241: 
        !          15242:   return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_dampend_paths, NULL);
        !          15243: }
        !          15244: ALIAS (show_bgp_ipv4_safi_dampened_paths,
        !          15245:        show_bgp_ipv4_safi_damp_dampened_paths_cmd,
        !          15246:        "show bgp ipv4 (encap|multicast|unicast|vpn) dampening dampened-paths",
        !          15247:        SHOW_STR
        !          15248:        BGP_STR
        !          15249:        IP_STR
        !          15250:        "Address Family modifier\n"
        !          15251:        "Address Family modifier\n"
        !          15252:        "Address Family modifier\n"
        !          15253:        "Address Family modifier\n"
        !          15254:        "Display detailed information about dampening\n"
        !          15255:        "Display paths suppressed due to dampening\n")
        !          15256: 
        !          15257: DEFUN (show_bgp_ipv6_safi_dampened_paths,
        !          15258:        show_bgp_ipv6_safi_dampened_paths_cmd,
        !          15259:        "show bgp ipv6 (encap|multicast|unicast|vpn) dampened-paths",
        !          15260:        SHOW_STR
        !          15261:        BGP_STR
        !          15262:        IPV6_STR
        !          15263:        "Address Family modifier\n"
        !          15264:        "Address Family modifier\n"
        !          15265:        "Address Family modifier\n"
        !          15266:        "Address Family modifier\n"
        !          15267:        "Display paths suppressed due to dampening\n")
        !          15268: {
        !          15269:   safi_t       safi;
        !          15270: 
        !          15271:   if (bgp_parse_safi(argv[0], &safi)) {
        !          15272:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          15273:     return CMD_WARNING;
        !          15274:   }
        !          15275: 
        !          15276:   return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_dampend_paths, NULL);
        !          15277: }
        !          15278: ALIAS (show_bgp_ipv6_safi_dampened_paths,
        !          15279:        show_bgp_ipv6_safi_damp_dampened_paths_cmd,
        !          15280:        "show bgp ipv6 (encap|multicast|unicast|vpn) dampening dampened-paths",
        !          15281:        SHOW_STR
        !          15282:        BGP_STR
        !          15283:        IPV6_STR
        !          15284:        "Address Family modifier\n"
        !          15285:        "Address Family modifier\n"
        !          15286:        "Address Family modifier\n"
        !          15287:        "Address Family modifier\n"
        !          15288:        "Display detailed information about dampening\n"
        !          15289:        "Display paths suppressed due to dampening\n")
        !          15290: 
        !          15291: DEFUN (show_bgp_ipv4_safi_flap_statistics,
        !          15292:        show_bgp_ipv4_safi_flap_statistics_cmd,
        !          15293:        "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics",
        !          15294:        SHOW_STR
        !          15295:        BGP_STR
        !          15296:        "Address Family\n"
        !          15297:        "Address Family modifier\n"
        !          15298:        "Address Family modifier\n"
        !          15299:        "Address Family modifier\n"
        !          15300:        "Address Family modifier\n"
        !          15301:        "Display flap statistics of routes\n")
        !          15302: {
        !          15303:   safi_t       safi;
        !          15304: 
        !          15305:   if (bgp_parse_safi(argv[0], &safi)) {
        !          15306:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          15307:     return CMD_WARNING;
        !          15308:   }
        !          15309: 
        !          15310:   return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_statistics, NULL);
        !          15311: }
        !          15312: ALIAS (show_bgp_ipv4_safi_flap_statistics,
        !          15313:        show_bgp_ipv4_safi_damp_flap_statistics_cmd,
        !          15314:        "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics",
        !          15315:        SHOW_STR
        !          15316:        BGP_STR
        !          15317:        "Address Family\n"
        !          15318:        "Address Family modifier\n"
        !          15319:        "Address Family modifier\n"
        !          15320:        "Address Family modifier\n"
        !          15321:        "Address Family modifier\n"
        !          15322:        "Display detailed information about dampening\n"
        !          15323:        "Display flap statistics of routes\n")
        !          15324: 
        !          15325: DEFUN (show_bgp_ipv6_safi_flap_statistics,
        !          15326:        show_bgp_ipv6_safi_flap_statistics_cmd,
        !          15327:        "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics",
        !          15328:        SHOW_STR
        !          15329:        BGP_STR
        !          15330:        "Address Family\n"
        !          15331:        "Address Family modifier\n"
        !          15332:        "Address Family modifier\n"
        !          15333:        "Address Family modifier\n"
        !          15334:        "Address Family modifier\n"
        !          15335:        "Display flap statistics of routes\n")
        !          15336: {
        !          15337:   safi_t       safi;
        !          15338: 
        !          15339:   if (bgp_parse_safi(argv[0], &safi)) {
        !          15340:     vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
        !          15341:     return CMD_WARNING;
        !          15342:   }
        !          15343: 
        !          15344:   return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_flap_statistics, NULL);
        !          15345: }
        !          15346: ALIAS (show_bgp_ipv6_safi_flap_statistics,
        !          15347:        show_bgp_ipv6_safi_damp_flap_statistics_cmd,
        !          15348:        "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics",
        !          15349:        SHOW_STR
1.1       misho    15350:        BGP_STR
1.1.1.4 ! misho    15351:        "Address Family\n"
        !          15352:        "Address Family modifier\n"
        !          15353:        "Address Family modifier\n"
        !          15354:        "Address Family modifier\n"
        !          15355:        "Address Family modifier\n"
        !          15356:        "Display detailed information about dampening\n"
1.1       misho    15357:        "Display flap statistics of routes\n")
1.1.1.4 ! misho    15358: 
1.1       misho    15359: /* Display specified route of BGP table. */
                   15360: static int
                   15361: bgp_clear_damp_route (struct vty *vty, const char *view_name, 
                   15362:                       const char *ip_str, afi_t afi, safi_t safi, 
                   15363:                       struct prefix_rd *prd, int prefix_check)
                   15364: {
                   15365:   int ret;
                   15366:   struct prefix match;
                   15367:   struct bgp_node *rn;
                   15368:   struct bgp_node *rm;
                   15369:   struct bgp_info *ri;
                   15370:   struct bgp_info *ri_temp;
                   15371:   struct bgp *bgp;
                   15372:   struct bgp_table *table;
                   15373: 
                   15374:   /* BGP structure lookup. */
                   15375:   if (view_name)
                   15376:     {
                   15377:       bgp = bgp_lookup_by_name (view_name);
                   15378:       if (bgp == NULL)
                   15379:        {
                   15380:          vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE);
                   15381:          return CMD_WARNING;
                   15382:        }
                   15383:     }
                   15384:   else
                   15385:     {
                   15386:       bgp = bgp_get_default ();
                   15387:       if (bgp == NULL)
                   15388:        {
                   15389:          vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
                   15390:          return CMD_WARNING;
                   15391:        }
                   15392:     }
                   15393: 
                   15394:   /* Check IP address argument. */
                   15395:   ret = str2prefix (ip_str, &match);
                   15396:   if (! ret)
                   15397:     {
                   15398:       vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
                   15399:       return CMD_WARNING;
                   15400:     }
                   15401: 
                   15402:   match.family = afi2family (afi);
                   15403: 
1.1.1.4 ! misho    15404:   if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
1.1       misho    15405:     {
1.1.1.4 ! misho    15406:       for (rn = bgp_table_top (bgp->rib[AFI_IP][safi]); rn; rn = bgp_route_next (rn))
1.1       misho    15407:         {
                   15408:           if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
                   15409:             continue;
                   15410: 
                   15411:          if ((table = rn->info) != NULL)
                   15412:            if ((rm = bgp_node_match (table, &match)) != NULL)
                   15413:               {
                   15414:                 if (! prefix_check || rm->p.prefixlen == match.prefixlen)
                   15415:                   {
                   15416:                     ri = rm->info;
                   15417:                     while (ri)
                   15418:                       {
                   15419:                         if (ri->extra && ri->extra->damp_info)
                   15420:                           {
                   15421:                             ri_temp = ri->next;
                   15422:                             bgp_damp_info_free (ri->extra->damp_info, 1);
                   15423:                             ri = ri_temp;
                   15424:                           }
                   15425:                         else
                   15426:                           ri = ri->next;
                   15427:                       }
                   15428:                   }
                   15429: 
                   15430:                 bgp_unlock_node (rm);
                   15431:               }
                   15432:         }
                   15433:     }
                   15434:   else
                   15435:     {
                   15436:       if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL)
                   15437:         {
                   15438:           if (! prefix_check || rn->p.prefixlen == match.prefixlen)
                   15439:             {
                   15440:               ri = rn->info;
                   15441:               while (ri)
                   15442:                 {
                   15443:                   if (ri->extra && ri->extra->damp_info)
                   15444:                     {
                   15445:                       ri_temp = ri->next;
                   15446:                       bgp_damp_info_free (ri->extra->damp_info, 1);
                   15447:                       ri = ri_temp;
                   15448:                     }
                   15449:                   else
                   15450:                     ri = ri->next;
                   15451:                 }
                   15452:             }
                   15453: 
                   15454:           bgp_unlock_node (rn);
                   15455:         }
                   15456:     }
                   15457: 
                   15458:   return CMD_SUCCESS;
                   15459: }
                   15460: 
                   15461: DEFUN (clear_ip_bgp_dampening,
                   15462:        clear_ip_bgp_dampening_cmd,
                   15463:        "clear ip bgp dampening",
                   15464:        CLEAR_STR
                   15465:        IP_STR
                   15466:        BGP_STR
                   15467:        "Clear route flap dampening information\n")
                   15468: {
                   15469:   bgp_damp_info_clean ();
                   15470:   return CMD_SUCCESS;
                   15471: }
                   15472: 
                   15473: DEFUN (clear_ip_bgp_dampening_prefix,
                   15474:        clear_ip_bgp_dampening_prefix_cmd,
                   15475:        "clear ip bgp dampening A.B.C.D/M",
                   15476:        CLEAR_STR
                   15477:        IP_STR
                   15478:        BGP_STR
                   15479:        "Clear route flap dampening information\n"
                   15480:        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
                   15481: {
                   15482:   return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
                   15483:                               SAFI_UNICAST, NULL, 1);
                   15484: }
                   15485: 
                   15486: DEFUN (clear_ip_bgp_dampening_address,
                   15487:        clear_ip_bgp_dampening_address_cmd,
                   15488:        "clear ip bgp dampening A.B.C.D",
                   15489:        CLEAR_STR
                   15490:        IP_STR
                   15491:        BGP_STR
                   15492:        "Clear route flap dampening information\n"
                   15493:        "Network to clear damping information\n")
                   15494: {
                   15495:   return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
                   15496:                               SAFI_UNICAST, NULL, 0);
                   15497: }
                   15498: 
                   15499: DEFUN (clear_ip_bgp_dampening_address_mask,
                   15500:        clear_ip_bgp_dampening_address_mask_cmd,
                   15501:        "clear ip bgp dampening A.B.C.D A.B.C.D",
                   15502:        CLEAR_STR
                   15503:        IP_STR
                   15504:        BGP_STR
                   15505:        "Clear route flap dampening information\n"
                   15506:        "Network to clear damping information\n"
                   15507:        "Network mask\n")
                   15508: {
                   15509:   int ret;
                   15510:   char prefix_str[BUFSIZ];
                   15511: 
                   15512:   ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
                   15513:   if (! ret)
                   15514:     {
                   15515:       vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
                   15516:       return CMD_WARNING;
                   15517:     }
                   15518: 
                   15519:   return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP,
                   15520:                               SAFI_UNICAST, NULL, 0);
                   15521: }
1.1.1.4 ! misho    15522: 
        !          15523: /* also used for encap safi */
1.1       misho    15524: static int
                   15525: bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp,
                   15526:                                afi_t afi, safi_t safi, int *write)
                   15527: {
                   15528:   struct bgp_node *prn;
                   15529:   struct bgp_node *rn;
                   15530:   struct bgp_table *table;
                   15531:   struct prefix *p;
                   15532:   struct prefix_rd *prd;
                   15533:   struct bgp_static *bgp_static;
                   15534:   u_int32_t label;
                   15535:   char buf[SU_ADDRSTRLEN];
                   15536:   char rdbuf[RD_ADDRSTRLEN];
                   15537:   
                   15538:   /* Network configuration. */
                   15539:   for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn))
                   15540:     if ((table = prn->info) != NULL)
                   15541:       for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) 
                   15542:        if ((bgp_static = rn->info) != NULL)
                   15543:          {
                   15544:            p = &rn->p;
                   15545:            prd = (struct prefix_rd *) &prn->p;
                   15546: 
                   15547:            /* "address-family" display.  */
                   15548:            bgp_config_write_family_header (vty, afi, safi, write);
                   15549: 
                   15550:            /* "network" configuration display.  */
                   15551:            prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN);
                   15552:            label = decode_label (bgp_static->tag);
                   15553: 
                   15554:            vty_out (vty, " network %s/%d rd %s tag %d",
                   15555:                     inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), 
                   15556:                     p->prefixlen,
                   15557:                     rdbuf, label);
                   15558:            vty_out (vty, "%s", VTY_NEWLINE);
                   15559:          }
                   15560:   return 0;
                   15561: }
                   15562: 
                   15563: /* Configuration of static route announcement and aggregate
                   15564:    information. */
                   15565: int
                   15566: bgp_config_write_network (struct vty *vty, struct bgp *bgp,
                   15567:                          afi_t afi, safi_t safi, int *write)
                   15568: {
                   15569:   struct bgp_node *rn;
                   15570:   struct prefix *p;
                   15571:   struct bgp_static *bgp_static;
                   15572:   struct bgp_aggregate *bgp_aggregate;
                   15573:   char buf[SU_ADDRSTRLEN];
                   15574:   
1.1.1.4 ! misho    15575:   if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)))
1.1       misho    15576:     return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write);
                   15577: 
                   15578:   /* Network configuration. */
                   15579:   for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) 
                   15580:     if ((bgp_static = rn->info) != NULL)
                   15581:       {
                   15582:        p = &rn->p;
                   15583: 
                   15584:        /* "address-family" display.  */
                   15585:        bgp_config_write_family_header (vty, afi, safi, write);
                   15586: 
                   15587:        /* "network" configuration display.  */
                   15588:        if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
                   15589:          {
                   15590:            u_int32_t destination; 
                   15591:            struct in_addr netmask;
                   15592: 
                   15593:            destination = ntohl (p->u.prefix4.s_addr);
                   15594:            masklen2ip (p->prefixlen, &netmask);
                   15595:            vty_out (vty, " network %s",
                   15596:                     inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN));
                   15597: 
                   15598:            if ((IN_CLASSC (destination) && p->prefixlen == 24)
                   15599:                || (IN_CLASSB (destination) && p->prefixlen == 16)
                   15600:                || (IN_CLASSA (destination) && p->prefixlen == 8)
                   15601:                || p->u.prefix4.s_addr == 0)
                   15602:              {
                   15603:                /* Natural mask is not display. */
                   15604:              }
                   15605:            else
                   15606:              vty_out (vty, " mask %s", inet_ntoa (netmask));
                   15607:          }
                   15608:        else
                   15609:          {
                   15610:            vty_out (vty, " network %s/%d",
                   15611:                     inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), 
                   15612:                     p->prefixlen);
                   15613:          }
                   15614: 
                   15615:        if (bgp_static->rmap.name)
                   15616:          vty_out (vty, " route-map %s", bgp_static->rmap.name);
                   15617:        else 
                   15618:          {
                   15619:            if (bgp_static->backdoor)
                   15620:              vty_out (vty, " backdoor");
                   15621:           }
                   15622: 
                   15623:        vty_out (vty, "%s", VTY_NEWLINE);
                   15624:       }
                   15625: 
                   15626:   /* Aggregate-address configuration. */
                   15627:   for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn))
                   15628:     if ((bgp_aggregate = rn->info) != NULL)
                   15629:       {
                   15630:        p = &rn->p;
                   15631: 
                   15632:        /* "address-family" display.  */
                   15633:        bgp_config_write_family_header (vty, afi, safi, write);
                   15634: 
                   15635:        if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
                   15636:          {
                   15637:            struct in_addr netmask;
                   15638: 
                   15639:            masklen2ip (p->prefixlen, &netmask);
                   15640:            vty_out (vty, " aggregate-address %s %s",
                   15641:                     inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
                   15642:                     inet_ntoa (netmask));
                   15643:          }
                   15644:        else
                   15645:          {
                   15646:            vty_out (vty, " aggregate-address %s/%d",
                   15647:                     inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
                   15648:                     p->prefixlen);
                   15649:          }
                   15650: 
                   15651:        if (bgp_aggregate->as_set)
                   15652:          vty_out (vty, " as-set");
                   15653:        
                   15654:        if (bgp_aggregate->summary_only)
                   15655:          vty_out (vty, " summary-only");
                   15656: 
                   15657:        vty_out (vty, "%s", VTY_NEWLINE);
                   15658:       }
                   15659: 
                   15660:   return 0;
                   15661: }
                   15662: 
                   15663: int
                   15664: bgp_config_write_distance (struct vty *vty, struct bgp *bgp)
                   15665: {
                   15666:   struct bgp_node *rn;
                   15667:   struct bgp_distance *bdistance;
                   15668: 
                   15669:   /* Distance configuration. */
                   15670:   if (bgp->distance_ebgp
                   15671:       && bgp->distance_ibgp
                   15672:       && bgp->distance_local
                   15673:       && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
                   15674:          || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
                   15675:          || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
                   15676:     vty_out (vty, " distance bgp %d %d %d%s",
                   15677:             bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local,
                   15678:             VTY_NEWLINE);
                   15679:   
                   15680:   for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
                   15681:     if ((bdistance = rn->info) != NULL)
                   15682:       {
                   15683:        vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
                   15684:                 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
                   15685:                 bdistance->access_list ? bdistance->access_list : "",
                   15686:                 VTY_NEWLINE);
                   15687:       }
                   15688: 
                   15689:   return 0;
                   15690: }
                   15691: 
                   15692: /* Allocate routing table structure and install commands. */
                   15693: void
                   15694: bgp_route_init (void)
                   15695: {
                   15696:   /* Init BGP distance table. */
                   15697:   bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST);
                   15698: 
                   15699:   /* IPv4 BGP commands. */
                   15700:   install_element (BGP_NODE, &bgp_network_cmd);
                   15701:   install_element (BGP_NODE, &bgp_network_mask_cmd);
                   15702:   install_element (BGP_NODE, &bgp_network_mask_natural_cmd);
                   15703:   install_element (BGP_NODE, &bgp_network_route_map_cmd);
                   15704:   install_element (BGP_NODE, &bgp_network_mask_route_map_cmd);
                   15705:   install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd);
                   15706:   install_element (BGP_NODE, &bgp_network_backdoor_cmd);
                   15707:   install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd);
                   15708:   install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd);
                   15709:   install_element (BGP_NODE, &no_bgp_network_cmd);
                   15710:   install_element (BGP_NODE, &no_bgp_network_mask_cmd);
                   15711:   install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd);
                   15712:   install_element (BGP_NODE, &no_bgp_network_route_map_cmd);
                   15713:   install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd);
                   15714:   install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd);
                   15715:   install_element (BGP_NODE, &no_bgp_network_backdoor_cmd);
                   15716:   install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd);
                   15717:   install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd);
                   15718: 
1.1.1.4 ! misho    15719:   install_element (BGP_NODE, &aggregate_address_cmd);
        !          15720:   install_element (BGP_NODE, &aggregate_address_mask_cmd);
        !          15721:   install_element (BGP_NODE, &aggregate_address_summary_only_cmd);
        !          15722:   install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd);
        !          15723:   install_element (BGP_NODE, &aggregate_address_as_set_cmd);
        !          15724:   install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd);
        !          15725:   install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd);
        !          15726:   install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd);
        !          15727:   install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd);
        !          15728:   install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd);
        !          15729:   install_element (BGP_NODE, &no_aggregate_address_cmd);
        !          15730:   install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd);
        !          15731:   install_element (BGP_NODE, &no_aggregate_address_as_set_cmd);
        !          15732:   install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd);
        !          15733:   install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd);
        !          15734:   install_element (BGP_NODE, &no_aggregate_address_mask_cmd);
        !          15735:   install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd);
        !          15736:   install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd);
        !          15737:   install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
        !          15738:   install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
        !          15739: 
        !          15740:   /* IPv4 unicast configuration.  */
        !          15741:   install_element (BGP_IPV4_NODE, &bgp_network_cmd);
        !          15742:   install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd);
        !          15743:   install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd);
        !          15744:   install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd);
        !          15745:   install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd);
        !          15746:   install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd);
        !          15747:   install_element (BGP_IPV4_NODE, &no_bgp_network_cmd);
        !          15748:   install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd);
        !          15749:   install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd);
        !          15750:   install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd);
        !          15751:   install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd);
        !          15752:   install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd);
        !          15753:   
        !          15754:   install_element (BGP_IPV4_NODE, &aggregate_address_cmd);
        !          15755:   install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd);
        !          15756:   install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd);
        !          15757:   install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd);
        !          15758:   install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd);
        !          15759:   install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd);
        !          15760:   install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd);
        !          15761:   install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd);
        !          15762:   install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd);
        !          15763:   install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd);
        !          15764:   install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd);
        !          15765:   install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd);
        !          15766:   install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd);
        !          15767:   install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd);
        !          15768:   install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd);
        !          15769:   install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd);
        !          15770:   install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd);
        !          15771:   install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd);
        !          15772:   install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
        !          15773:   install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
        !          15774: 
        !          15775:   /* IPv4 multicast configuration.  */
        !          15776:   install_element (BGP_IPV4M_NODE, &bgp_network_cmd);
        !          15777:   install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd);
        !          15778:   install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd);
        !          15779:   install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd);
        !          15780:   install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd);
        !          15781:   install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd);
        !          15782:   install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd);
        !          15783:   install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd);
        !          15784:   install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd);
        !          15785:   install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd);
        !          15786:   install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd);
        !          15787:   install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd);
        !          15788:   install_element (BGP_IPV4M_NODE, &aggregate_address_cmd);
        !          15789:   install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd);
        !          15790:   install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd);
        !          15791:   install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd);
        !          15792:   install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd);
        !          15793:   install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd);
        !          15794:   install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd);
        !          15795:   install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd);
        !          15796:   install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd);
        !          15797:   install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd);
        !          15798:   install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd);
        !          15799:   install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd);
        !          15800:   install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd);
        !          15801:   install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd);
        !          15802:   install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd);
        !          15803:   install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd);
        !          15804:   install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd);
        !          15805:   install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd);
        !          15806:   install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
        !          15807:   install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
        !          15808: 
        !          15809:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd);
        !          15810:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd);
        !          15811:   install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd);
        !          15812:   install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd);
        !          15813:   install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
        !          15814:   install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
        !          15815:   install_element (VIEW_NODE, &show_bgp_ipv4_encap_route_cmd);
        !          15816:   install_element (VIEW_NODE, &show_bgp_ipv6_encap_route_cmd);
        !          15817:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
        !          15818:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
        !          15819:   install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd);
        !          15820:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd);
        !          15821:   install_element (VIEW_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
        !          15822:   install_element (VIEW_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
        !          15823:   install_element (VIEW_NODE, &show_bgp_ipv4_encap_prefix_cmd);
        !          15824:   install_element (VIEW_NODE, &show_bgp_ipv6_encap_prefix_cmd);
        !          15825:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
        !          15826:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
        !          15827:   install_element (VIEW_NODE, &show_bgp_afi_safi_view_cmd);
        !          15828:   install_element (VIEW_NODE, &show_bgp_view_afi_safi_route_cmd);
        !          15829:   install_element (VIEW_NODE, &show_bgp_view_afi_safi_prefix_cmd);
        !          15830:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_regexp_cmd);
        !          15831:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_regexp_cmd);
        !          15832:   install_element (VIEW_NODE, &show_bgp_ipv4_prefix_list_cmd);
        !          15833:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_list_cmd);
        !          15834:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_list_cmd);
        !          15835:   install_element (VIEW_NODE, &show_bgp_ipv4_filter_list_cmd);
        !          15836:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_filter_list_cmd);
        !          15837:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_filter_list_cmd);
        !          15838:   install_element (VIEW_NODE, &show_bgp_ipv4_route_map_cmd);
        !          15839:   install_element (VIEW_NODE, &show_bgp_ipv4_cidr_only_cmd);
        !          15840:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_cidr_only_cmd);
        !          15841:   install_element (VIEW_NODE, &show_bgp_ipv4_community_cmd);
        !          15842:   install_element (VIEW_NODE, &show_bgp_ipv4_community2_cmd);
        !          15843:   install_element (VIEW_NODE, &show_bgp_ipv4_community3_cmd);
        !          15844:   install_element (VIEW_NODE, &show_bgp_ipv4_community4_cmd);
        !          15845:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_cmd);
        !          15846:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_cmd);
        !          15847:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_cmd);
        !          15848:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_cmd);
        !          15849:   install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd);
        !          15850:   install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd);
        !          15851:   install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd);
        !          15852:   install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd);
        !          15853:   install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd);
        !          15854:   install_element (VIEW_NODE, &show_bgp_ipv4_community_exact_cmd);
        !          15855:   install_element (VIEW_NODE, &show_bgp_ipv4_community2_exact_cmd);
        !          15856:   install_element (VIEW_NODE, &show_bgp_ipv4_community3_exact_cmd);
        !          15857:   install_element (VIEW_NODE, &show_bgp_ipv4_community4_exact_cmd);
        !          15858:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
        !          15859:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
        !          15860:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
        !          15861:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
        !          15862:   install_element (VIEW_NODE, &show_bgp_ipv4_community_list_cmd);
        !          15863:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_cmd);
        !          15864:   install_element (VIEW_NODE, &show_bgp_ipv4_community_list_exact_cmd);
        !          15865:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd);
        !          15866:   install_element (VIEW_NODE, &show_bgp_ipv4_prefix_longer_cmd);
        !          15867:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd);
        !          15868:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd);
        !          15869:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd);
        !          15870:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd);
        !          15871:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd);
        !          15872:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd);
        !          15873:   install_element (VIEW_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd);
        !          15874:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd);
        !          15875:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd);
        !          15876:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd);
        !          15877:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd);
        !          15878:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd);
        !          15879:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd);
        !          15880:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd);
        !          15881:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd);
        !          15882:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd);
        !          15883:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd);
        !          15884:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd);
        !          15885:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd);
        !          15886:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_address_cmd);
        !          15887:   install_element (VIEW_NODE, &show_bgp_ipv6_flap_address_cmd);
        !          15888:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd);
        !          15889:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd);
        !          15890:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd);
        !          15891:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd);
        !          15892:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd);
        !          15893:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd);
        !          15894:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd);
        !          15895:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd);
        !          15896:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd);
        !          15897:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd);
        !          15898:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd);
        !          15899:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd);
        !          15900:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd);
        !          15901:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd);
        !          15902:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd);
        !          15903:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd);
        !          15904:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd);
        !          15905:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd);
        !          15906:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd);
        !          15907:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd);
        !          15908:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd);
        !          15909:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd);
        !          15910:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd);
        !          15911:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd);
        !          15912:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd);
        !          15913:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd);
        !          15914:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd);
        !          15915:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd);
        !          15916:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd);
        !          15917:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd);
        !          15918:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd);
        !          15919:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd);
        !          15920:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
        !          15921:   install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
        !          15922:   install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd);
        !          15923:   install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
        !          15924:   install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
        !          15925:   
        !          15926:   /* Restricted node: VIEW_NODE - (set of dangerous commands) */
        !          15927:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd);
        !          15928:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
        !          15929:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
        !          15930:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
        !          15931:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
        !          15932:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_prefix_cmd);
        !          15933:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd);
        !          15934:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
        !          15935:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
        !          15936:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_encap_prefix_cmd);
        !          15937:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_encap_prefix_cmd);
        !          15938:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
        !          15939:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
        !          15940:   install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_route_cmd);
        !          15941:   install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_prefix_cmd);
        !          15942:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_cmd);
        !          15943:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_cmd);
        !          15944:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_cmd);
        !          15945:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_cmd);
        !          15946:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_cmd);
        !          15947:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_cmd);
        !          15948:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_cmd);
        !          15949:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_cmd);
        !          15950:   install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd);
        !          15951:   install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd);
        !          15952:   install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd);
        !          15953:   install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd);
        !          15954:   install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd);
        !          15955:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_exact_cmd);
        !          15956:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_exact_cmd);
        !          15957:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_exact_cmd);
        !          15958:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_exact_cmd);
        !          15959:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
        !          15960:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
        !          15961:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
        !          15962:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
        !          15963:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
        !          15964:   install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
        !          15965:   install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
        !          15966:   install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
        !          15967: 
        !          15968:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd);
        !          15969:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd);
        !          15970:   install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_route_cmd);
        !          15971:   install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_route_cmd);
        !          15972:   install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
        !          15973:   install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
        !          15974:   install_element (ENABLE_NODE, &show_bgp_ipv4_encap_route_cmd);
        !          15975:   install_element (ENABLE_NODE, &show_bgp_ipv6_encap_route_cmd);
        !          15976:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
        !          15977:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
        !          15978:   install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_cmd);
        !          15979:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd);
        !          15980:   install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
        !          15981:   install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
        !          15982:   install_element (ENABLE_NODE, &show_bgp_ipv4_encap_prefix_cmd);
        !          15983:   install_element (ENABLE_NODE, &show_bgp_ipv6_encap_prefix_cmd);
        !          15984:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
        !          15985:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
        !          15986:   install_element (ENABLE_NODE, &show_bgp_afi_safi_view_cmd);
        !          15987:   install_element (ENABLE_NODE, &show_bgp_view_afi_safi_route_cmd);
        !          15988:   install_element (ENABLE_NODE, &show_bgp_view_afi_safi_prefix_cmd);
        !          15989:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_regexp_cmd);
        !          15990:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_regexp_cmd);
        !          15991:   install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_list_cmd);
        !          15992:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_list_cmd);
        !          15993:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_list_cmd);
        !          15994:   install_element (ENABLE_NODE, &show_bgp_ipv4_filter_list_cmd);
        !          15995:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_filter_list_cmd);
        !          15996:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_filter_list_cmd);
        !          15997:   install_element (ENABLE_NODE, &show_bgp_ipv4_route_map_cmd);
        !          15998:   install_element (ENABLE_NODE, &show_bgp_ipv4_cidr_only_cmd);
        !          15999:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cidr_only_cmd);
        !          16000:   install_element (ENABLE_NODE, &show_bgp_ipv4_community_cmd);
        !          16001:   install_element (ENABLE_NODE, &show_bgp_ipv4_community2_cmd);
        !          16002:   install_element (ENABLE_NODE, &show_bgp_ipv4_community3_cmd);
        !          16003:   install_element (ENABLE_NODE, &show_bgp_ipv4_community4_cmd);
        !          16004:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_cmd);
        !          16005:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community2_cmd);
        !          16006:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community3_cmd);
        !          16007:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community4_cmd);
        !          16008:   install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd);
        !          16009:   install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd);
        !          16010:   install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd);
        !          16011:   install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd);
        !          16012:   install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd);
        !          16013:   install_element (ENABLE_NODE, &show_bgp_ipv4_community_exact_cmd);
        !          16014:   install_element (ENABLE_NODE, &show_bgp_ipv4_community2_exact_cmd);
        !          16015:   install_element (ENABLE_NODE, &show_bgp_ipv4_community3_exact_cmd);
        !          16016:   install_element (ENABLE_NODE, &show_bgp_ipv4_community4_exact_cmd);
        !          16017:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
        !          16018:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
        !          16019:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
        !          16020:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
        !          16021:   install_element (ENABLE_NODE, &show_bgp_ipv4_community_list_cmd);
        !          16022:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_list_cmd);
        !          16023:   install_element (ENABLE_NODE, &show_bgp_ipv4_community_list_exact_cmd);
        !          16024:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd);
        !          16025:   install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_longer_cmd);
        !          16026:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd);
        !          16027:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd);
        !          16028:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd);
        !          16029:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd);
        !          16030:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd);
        !          16031:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd);
        !          16032:   install_element (ENABLE_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd);
        !          16033:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd);
        !          16034:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd);
        !          16035:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd);
        !          16036:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd);
        !          16037:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd);
        !          16038:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd);
        !          16039:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd);
        !          16040:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd);
        !          16041:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd);
        !          16042:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd);
        !          16043:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd);
        !          16044:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd);
        !          16045:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_address_cmd);
        !          16046:   install_element (ENABLE_NODE, &show_bgp_ipv6_flap_address_cmd);
        !          16047:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd);
        !          16048:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd);
        !          16049:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd);
        !          16050:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd);
        !          16051:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd);
        !          16052:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd);
        !          16053:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd);
        !          16054:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd);
        !          16055:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd);
        !          16056:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd);
        !          16057:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd);
        !          16058:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd);
        !          16059:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd);
        !          16060:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd);
        !          16061:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd);
        !          16062:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd);
        !          16063:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd);
        !          16064:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd);
        !          16065:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd);
        !          16066:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd);
        !          16067:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd);
        !          16068:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd);
        !          16069:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd);
        !          16070:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd);
        !          16071:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd);
        !          16072:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd);
        !          16073:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd);
        !          16074:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd);
        !          16075:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd);
        !          16076:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd);
        !          16077:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd);
        !          16078:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd);
        !          16079:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
        !          16080:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
        !          16081:   install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd);
        !          16082:   install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
        !          16083:   install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
        !          16084: 
        !          16085:  /* BGP dampening clear commands */
        !          16086:   install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd);
        !          16087:   install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd);
        !          16088:   install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd);
        !          16089:   install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd);
        !          16090: 
        !          16091:   /* prefix count */
        !          16092:   install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_prefix_counts_cmd);
        !          16093:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_prefix_counts_cmd);
        !          16094:   install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd);
        !          16095: 
        !          16096:   /* New config IPv6 BGP commands.  */
        !          16097:   install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd);
        !          16098:   install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd);
        !          16099:   install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd);
        !          16100:   install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd);
        !          16101: 
        !          16102:   install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd);
        !          16103:   install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd);
        !          16104:   install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd);
        !          16105:   install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd);
        !          16106: 
        !          16107:   install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd);
        !          16108:   install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd);
        !          16109: 
        !          16110:   /* Old config IPv6 BGP commands.  */
        !          16111:   install_element (BGP_NODE, &old_ipv6_bgp_network_cmd);
        !          16112:   install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd);
        !          16113: 
        !          16114:   install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd);
        !          16115:   install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd);
        !          16116:   install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd);
        !          16117:   install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd);
        !          16118: 
        !          16119:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd);
        !          16120:   install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd);
        !          16121:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd);
        !          16122:   install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd);
        !          16123:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd);
        !          16124:   install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd);
        !          16125:   install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd);
        !          16126:   install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd);
        !          16127:   install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd);
        !          16128:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_cmd);
        !          16129:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_cmd);
        !          16130:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_cmd);
        !          16131:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_cmd);
        !          16132:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
        !          16133:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
        !          16134:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
        !          16135:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
        !          16136:   install_element (VIEW_NODE, &show_bgp_community_list_cmd);
        !          16137:   install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd);
        !          16138:   install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
        !          16139:   install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
        !          16140:   install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
        !          16141:   install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
        !          16142:   install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
        !          16143:   install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
        !          16144:   install_element (VIEW_NODE, &show_bgp_ipv4_rsclient_cmd);
        !          16145:   install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_cmd);
        !          16146:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd);
        !          16147:   install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_route_cmd);
        !          16148:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
        !          16149:   install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
        !          16150:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
        !          16151:   install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd);
        !          16152:   install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd);
        !          16153:   install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd);
        !          16154:   install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
        !          16155:   install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
        !          16156:   install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
        !          16157:   install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
        !          16158:   install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
        !          16159:   install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); 
        !          16160:   install_element (VIEW_NODE, &show_bgp_view_ipv4_rsclient_cmd);
        !          16161:   install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_cmd);
        !          16162:   install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd);
        !          16163:   install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
        !          16164:   install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
        !          16165:   install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
        !          16166:   install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
        !          16167:   
        !          16168:   /* Restricted:
        !          16169:    * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) 
        !          16170:    */
        !          16171:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd);
        !          16172:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd);
        !          16173:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd);
        !          16174:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd);
        !          16175:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_cmd);
        !          16176:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_cmd);
        !          16177:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_cmd);
        !          16178:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_cmd);
        !          16179:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
        !          16180:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
        !          16181:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
        !          16182:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
        !          16183:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_route_cmd);
        !          16184:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
        !          16185:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
        !          16186:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
        !          16187:   install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd);
        !          16188:   install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd);
        !          16189:   install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
        !          16190:   install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
        !          16191:   install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
        !          16192:   install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
        !          16193:   install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
        !          16194: 
        !          16195:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd);
        !          16196:   install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd);
        !          16197:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd);
        !          16198:   install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd);
        !          16199:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd);
        !          16200:   install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd);
        !          16201:   install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd);
        !          16202:   install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd);
        !          16203:   install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd);
        !          16204:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_cmd);
        !          16205:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community2_cmd);
        !          16206:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community3_cmd);
        !          16207:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community4_cmd);
        !          16208:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
        !          16209:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
        !          16210:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
        !          16211:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
        !          16212:   install_element (ENABLE_NODE, &show_bgp_community_list_cmd);
        !          16213:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd);
        !          16214:   install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd);
        !          16215:   install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
        !          16216:   install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
        !          16217:   install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
        !          16218:   install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
        !          16219:   install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
        !          16220:   install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
        !          16221:   install_element (ENABLE_NODE, &show_bgp_ipv4_rsclient_cmd);
        !          16222:   install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_cmd);
        !          16223:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd);
        !          16224:   install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_route_cmd);
        !          16225:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
        !          16226:   install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
        !          16227:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
        !          16228:   install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd);
        !          16229:   install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd);
        !          16230:   install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd);
        !          16231:   install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
        !          16232:   install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
        !          16233:   install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
        !          16234:   install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
        !          16235:   install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
        !          16236:   install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
        !          16237:   install_element (ENABLE_NODE, &show_bgp_view_ipv4_rsclient_cmd);
        !          16238:   install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_cmd);
        !          16239:   install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd);
        !          16240:   install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
        !          16241:   install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
        !          16242:   install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
        !          16243:   install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
        !          16244:   
        !          16245:   /* Statistics */
        !          16246:   install_element (ENABLE_NODE, &show_bgp_statistics_cmd);
        !          16247:   install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd);  
        !          16248: 
        !          16249:   install_element (BGP_NODE, &bgp_distance_cmd);
        !          16250:   install_element (BGP_NODE, &no_bgp_distance_cmd);
        !          16251:   install_element (BGP_NODE, &no_bgp_distance2_cmd);
        !          16252:   install_element (BGP_NODE, &bgp_distance_source_cmd);
        !          16253:   install_element (BGP_NODE, &no_bgp_distance_source_cmd);
        !          16254:   install_element (BGP_NODE, &bgp_distance_source_access_list_cmd);
        !          16255:   install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd);
1.1       misho    16256: 
1.1.1.4 ! misho    16257:   install_element (BGP_NODE, &bgp_damp_set_cmd);
        !          16258:   install_element (BGP_NODE, &bgp_damp_set2_cmd);
        !          16259:   install_element (BGP_NODE, &bgp_damp_set3_cmd);
        !          16260:   install_element (BGP_NODE, &bgp_damp_unset_cmd);
        !          16261:   install_element (BGP_NODE, &bgp_damp_unset2_cmd);
        !          16262:   install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd);
        !          16263:   install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd);
        !          16264:   install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd);
        !          16265:   install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd);
        !          16266:   install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd);
1.1       misho    16267:   
1.1.1.4 ! misho    16268:   /* Deprecated AS-Pathlimit commands */
        !          16269:   install_element (BGP_NODE, &bgp_network_ttl_cmd);
        !          16270:   install_element (BGP_NODE, &bgp_network_mask_ttl_cmd);
        !          16271:   install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd);
        !          16272:   install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd);
        !          16273:   install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd);
        !          16274:   install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
        !          16275:   
        !          16276:   install_element (BGP_NODE, &no_bgp_network_ttl_cmd);
        !          16277:   install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd);
        !          16278:   install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd);
        !          16279:   install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd);
        !          16280:   install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
        !          16281:   install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
        !          16282:   
        !          16283:   install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd);
        !          16284:   install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd);
        !          16285:   install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd);
        !          16286:   install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd);
        !          16287:   install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd);
        !          16288:   install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
        !          16289:   
        !          16290:   install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd);
        !          16291:   install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd);
        !          16292:   install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd);
        !          16293:   install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd);
        !          16294:   install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
        !          16295:   install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
        !          16296:   
        !          16297:   install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd);
        !          16298:   install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd);
        !          16299:   install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd);
        !          16300:   install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd);
        !          16301:   install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd);
        !          16302:   install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
        !          16303:   
        !          16304:   install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd);
        !          16305:   install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd);
        !          16306:   install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd);
        !          16307:   install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd);
        !          16308:   install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
        !          16309:   install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
1.1       misho    16310: 
1.1.1.4 ! misho    16311:   install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd);
        !          16312:   install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd);
1.1       misho    16313: 
1.1.1.4 ! misho    16314:   /* old style commands */
1.1       misho    16315:   install_element (VIEW_NODE, &show_ip_bgp_cmd);
                   16316:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd);
                   16317:   install_element (VIEW_NODE, &show_ip_bgp_route_cmd);
                   16318:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd);
                   16319:   install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
                   16320:   install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
                   16321:   install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd);
                   16322:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd);
                   16323:   install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
                   16324:   install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
                   16325:   install_element (VIEW_NODE, &show_ip_bgp_view_cmd);
                   16326:   install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd);
                   16327:   install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd);
                   16328:   install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd);
                   16329:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd);
                   16330:   install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd);
                   16331:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
                   16332:   install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd);
                   16333:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
                   16334:   install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd);
                   16335:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd);
                   16336:   install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd);
                   16337:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
                   16338:   install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd);
                   16339:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd);
                   16340:   install_element (VIEW_NODE, &show_ip_bgp_community_cmd);
                   16341:   install_element (VIEW_NODE, &show_ip_bgp_community2_cmd);
                   16342:   install_element (VIEW_NODE, &show_ip_bgp_community3_cmd);
                   16343:   install_element (VIEW_NODE, &show_ip_bgp_community4_cmd);
                   16344:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd);
                   16345:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd);
                   16346:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd);
                   16347:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd);
                   16348:   install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd);
                   16349:   install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd);
                   16350:   install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd);
                   16351:   install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd);
                   16352:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
                   16353:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
                   16354:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
                   16355:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
                   16356:   install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd);
                   16357:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd);
                   16358:   install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd);
                   16359:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
                   16360:   install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd);
                   16361:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
                   16362:   install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
                   16363:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
                   16364:   install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
                   16365:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
                   16366:   install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd);
                   16367:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
                   16368:   install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
                   16369:   install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
1.1.1.4 ! misho    16370:   install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd);
1.1       misho    16371:   install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd);
1.1.1.4 ! misho    16372:   install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd);
1.1       misho    16373:   install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd);
1.1.1.4 ! misho    16374:   install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd);
1.1       misho    16375:   install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd);
1.1.1.4 ! misho    16376:   install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd);
1.1       misho    16377:   install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd);
                   16378:   install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd);
1.1.1.4 ! misho    16379:   install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd);
1.1       misho    16380:   install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd);
                   16381:   install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd);
1.1.1.4 ! misho    16382:   install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd);
1.1       misho    16383:   install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd);
1.1.1.4 ! misho    16384:   install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd);
1.1       misho    16385:   install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
1.1.1.4 ! misho    16386:   install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd);
1.1       misho    16387:   install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd);
1.1.1.4 ! misho    16388:   install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd);
1.1       misho    16389:   install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd);
                   16390:   install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd);
                   16391:   install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd);
                   16392:   install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd);
                   16393:   install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd);
                   16394:   install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd);
                   16395:   install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd);
                   16396:   install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd);
                   16397:   install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd);
                   16398:   install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
                   16399:   install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd);
                   16400:   install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd);
                   16401:   install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
                   16402:   install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd);
                   16403:   install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd);
                   16404:   install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
                   16405:   install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
                   16406:   install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd);
                   16407:   install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd);
                   16408:   install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd);
                   16409:   install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd);
                   16410:   install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd);
                   16411:   install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd);
                   16412:   install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd);
                   16413:   install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd);
                   16414:   install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd);
                   16415:   install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd);
                   16416:   install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd);
                   16417:   install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd);
                   16418:   install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd);
                   16419:   install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd);
                   16420:   install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
                   16421:   install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
                   16422:   install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
                   16423:   install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
                   16424:   install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd);
                   16425:   install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd);
                   16426:   install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd);
                   16427:   install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
                   16428:   install_element (ENABLE_NODE, &show_ip_bgp_cmd);
                   16429:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd);
                   16430:   install_element (ENABLE_NODE, &show_ip_bgp_route_cmd);
                   16431:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd);
                   16432:   install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
                   16433:   install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
                   16434:   install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd);
                   16435:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd);
                   16436:   install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
                   16437:   install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
                   16438:   install_element (ENABLE_NODE, &show_ip_bgp_view_cmd);
                   16439:   install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd);
                   16440:   install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd);
                   16441:   install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd);
                   16442:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd);
                   16443:   install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd);
                   16444:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
                   16445:   install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd);
                   16446:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
                   16447:   install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd);
                   16448:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd);
                   16449:   install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd);
                   16450:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
                   16451:   install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd);
                   16452:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd);
                   16453:   install_element (ENABLE_NODE, &show_ip_bgp_community_cmd);
                   16454:   install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd);
                   16455:   install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd);
                   16456:   install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd);
                   16457:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd);
                   16458:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd);
                   16459:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd);
                   16460:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd);
                   16461:   install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd);
                   16462:   install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd);
                   16463:   install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd);
                   16464:   install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd);
                   16465:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
                   16466:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
                   16467:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
                   16468:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
                   16469:   install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd);
                   16470:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd);
                   16471:   install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd);
                   16472:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
                   16473:   install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd);
                   16474:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
                   16475:   install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
                   16476:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
                   16477:   install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
                   16478:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
                   16479:   install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd);
                   16480:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
                   16481:   install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
1.1.1.4 ! misho    16482:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
        !          16483:   install_element (ENABLE_NODE, &show_ip_bgp_dampening_params_cmd);
        !          16484:   install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd);
        !          16485:   install_element (ENABLE_NODE, &show_ip_bgp_damp_dampened_paths_cmd);
        !          16486:   install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd);
        !          16487:   install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_statistics_cmd);
        !          16488:   install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd);
        !          16489:   install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_address_cmd);
        !          16490:   install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd);
        !          16491:   install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd);
        !          16492:   install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd);
        !          16493:   install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd);
        !          16494:   install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_regexp_cmd);
        !          16495:   install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd);
        !          16496:   install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_filter_list_cmd);
        !          16497:   install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd);
        !          16498:   install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd);
        !          16499:   install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
        !          16500:   install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd);
        !          16501:   install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd);
        !          16502:   install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_route_map_cmd);
        !          16503:   install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd);
        !          16504:   install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd);
        !          16505:   install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd);
        !          16506:   install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd);
        !          16507:   install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd);
        !          16508:   install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd);
        !          16509:   install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd);
        !          16510:   install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd);
        !          16511:   install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd);
        !          16512:   install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
        !          16513:   install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd);
        !          16514:   install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd);
        !          16515:   install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd);
1.1       misho    16516:   install_element (VIEW_NODE, &show_bgp_cmd);
                   16517:   install_element (VIEW_NODE, &show_bgp_ipv6_cmd);
                   16518:   install_element (VIEW_NODE, &show_bgp_route_cmd);
                   16519:   install_element (VIEW_NODE, &show_bgp_prefix_cmd);
                   16520:   install_element (VIEW_NODE, &show_bgp_regexp_cmd);
                   16521:   install_element (VIEW_NODE, &show_bgp_prefix_list_cmd);
                   16522:   install_element (VIEW_NODE, &show_bgp_filter_list_cmd);
                   16523:   install_element (VIEW_NODE, &show_bgp_route_map_cmd);
                   16524:   install_element (VIEW_NODE, &show_bgp_community_all_cmd);
                   16525:   install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd);
                   16526:   install_element (VIEW_NODE, &show_bgp_community_cmd);
                   16527:   install_element (VIEW_NODE, &show_bgp_community2_cmd);
                   16528:   install_element (VIEW_NODE, &show_bgp_community3_cmd);
                   16529:   install_element (VIEW_NODE, &show_bgp_community4_cmd);
                   16530:   install_element (VIEW_NODE, &show_bgp_community_exact_cmd);
                   16531:   install_element (VIEW_NODE, &show_bgp_community2_exact_cmd);
                   16532:   install_element (VIEW_NODE, &show_bgp_community3_exact_cmd);
                   16533:   install_element (VIEW_NODE, &show_bgp_community4_exact_cmd);
1.1.1.4 ! misho    16534:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_cmd);
1.1       misho    16535:   install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd);
1.1.1.4 ! misho    16536:   install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd);
1.1       misho    16537:   install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd);
                   16538:   install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd);
                   16539:   install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd);
                   16540:   install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd);
                   16541:   install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
                   16542:   install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd);
                   16543:   install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd);
                   16544:   install_element (VIEW_NODE, &show_bgp_rsclient_cmd);
                   16545:   install_element (VIEW_NODE, &show_bgp_view_cmd);
                   16546:   install_element (VIEW_NODE, &show_bgp_view_route_cmd);
                   16547:   install_element (VIEW_NODE, &show_bgp_view_prefix_cmd);
                   16548:   install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
                   16549:   install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd);
                   16550:   install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd);
                   16551:   install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
                   16552:   install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd);
                   16553:   install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd);
                   16554:   install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd);
                   16555:   install_element (RESTRICTED_NODE, &show_bgp_route_cmd);
                   16556:   install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd);
                   16557:   install_element (RESTRICTED_NODE, &show_bgp_community_cmd);
                   16558:   install_element (RESTRICTED_NODE, &show_bgp_community2_cmd);
                   16559:   install_element (RESTRICTED_NODE, &show_bgp_community3_cmd);
                   16560:   install_element (RESTRICTED_NODE, &show_bgp_community4_cmd);
                   16561:   install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd);
                   16562:   install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd);
                   16563:   install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd);
                   16564:   install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd);
                   16565:   install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd);
                   16566:   install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd);
                   16567:   install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
                   16568:   install_element (ENABLE_NODE, &show_bgp_cmd);
                   16569:   install_element (ENABLE_NODE, &show_bgp_ipv6_cmd);
                   16570:   install_element (ENABLE_NODE, &show_bgp_route_cmd);
                   16571:   install_element (ENABLE_NODE, &show_bgp_prefix_cmd);
                   16572:   install_element (ENABLE_NODE, &show_bgp_regexp_cmd);
                   16573:   install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd);
                   16574:   install_element (ENABLE_NODE, &show_bgp_filter_list_cmd);
                   16575:   install_element (ENABLE_NODE, &show_bgp_route_map_cmd);
                   16576:   install_element (ENABLE_NODE, &show_bgp_community_all_cmd);
                   16577:   install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd);
                   16578:   install_element (ENABLE_NODE, &show_bgp_community_cmd);
                   16579:   install_element (ENABLE_NODE, &show_bgp_community2_cmd);
                   16580:   install_element (ENABLE_NODE, &show_bgp_community3_cmd);
                   16581:   install_element (ENABLE_NODE, &show_bgp_community4_cmd);
                   16582:   install_element (ENABLE_NODE, &show_bgp_community_exact_cmd);
                   16583:   install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd);
                   16584:   install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd);
                   16585:   install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd);
1.1.1.4 ! misho    16586:   install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_list_cmd);
1.1       misho    16587:   install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd);
                   16588:   install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd);
                   16589:   install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd);
                   16590:   install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd);
                   16591:   install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd);
                   16592:   install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
                   16593:   install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd);
                   16594:   install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd);
                   16595:   install_element (ENABLE_NODE, &show_bgp_rsclient_cmd);
                   16596:   install_element (ENABLE_NODE, &show_bgp_view_cmd);
                   16597:   install_element (ENABLE_NODE, &show_bgp_view_route_cmd);
                   16598:   install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd);
                   16599:   install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
                   16600:   install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd);
                   16601:   install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd);
                   16602:   install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
                   16603:   install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd);
                   16604:   install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd);
                   16605:   install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd);
                   16606:   install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd);
                   16607:   install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd);
                   16608:   install_element (VIEW_NODE, &show_ipv6_bgp_cmd);
                   16609:   install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd);
                   16610:   install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd);
                   16611:   install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd);
                   16612:   install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd);
                   16613:   install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd);
                   16614:   install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd);
                   16615:   install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd);
                   16616:   install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd);
                   16617:   install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd);
                   16618:   install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd);
                   16619:   install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd);
                   16620:   install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd);
                   16621:   install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd);
                   16622:   install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd);
                   16623:   install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd);
                   16624:   install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd);
                   16625:   install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd);
                   16626:   install_element (VIEW_NODE, &show_ipv6_mbgp_cmd);
                   16627:   install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd);
                   16628:   install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd);
                   16629:   install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd);
                   16630:   install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd);
                   16631:   install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd);
                   16632:   install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd);
                   16633:   install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd);
                   16634:   install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd);
                   16635:   install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd);
                   16636:   install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd);
                   16637:   install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd);
                   16638:   install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd);
                   16639:   install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd);
                   16640:   install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd);
                   16641:   install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd);
                   16642:   install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
                   16643:   install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
                   16644:   install_element (ENABLE_NODE, &show_ipv6_bgp_cmd);
                   16645:   install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd);
                   16646:   install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd);
                   16647:   install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd);
                   16648:   install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd);
                   16649:   install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd);
                   16650:   install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd);
                   16651:   install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd);
                   16652:   install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd);
                   16653:   install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd);
                   16654:   install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd);
                   16655:   install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd);
                   16656:   install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd);
                   16657:   install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd);
                   16658:   install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd);
                   16659:   install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd);
                   16660:   install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd);
                   16661:   install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd);
                   16662:   install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd);
                   16663:   install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd);
                   16664:   install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd);
                   16665:   install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd);
                   16666:   install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd);
                   16667:   install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd);
                   16668:   install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd);
                   16669:   install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd);
                   16670:   install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd);
                   16671:   install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd);
                   16672:   install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd);
                   16673:   install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd);
                   16674:   install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd);
                   16675:   install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd);
                   16676:   install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd);
                   16677:   install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd);
                   16678:   install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
                   16679:   install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
                   16680:   install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
                   16681:   install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
                   16682:   install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
                   16683:   install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
                   16684:   install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
                   16685:   install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
                   16686:   install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
                   16687:   install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
                   16688:   install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd);
                   16689:   install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd);
                   16690:   install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd);
                   16691:   install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd);
1.1.1.4 ! misho    16692:   /* old with name safi collision */
        !          16693:   install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd);
        !          16694:   install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd);
        !          16695:   install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd);
        !          16696:   install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd);
        !          16697:   install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd);
        !          16698:   install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd);
        !          16699:   install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd);
        !          16700:   install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd);
        !          16701:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd);
        !          16702:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd);
        !          16703:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd);
        !          16704:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd);
        !          16705:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd);
        !          16706:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd);
        !          16707:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd);
        !          16708:   install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd);
        !          16709:   install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd);
        !          16710:   install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd);
        !          16711:   install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd);
        !          16712:   install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd);
        !          16713:   install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd);
        !          16714:   install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd);
        !          16715:   install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd);
        !          16716:   install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd);
        !          16717:   install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd);
        !          16718:   install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd);
        !          16719:   install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd);
        !          16720:   install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd);
1.1       misho    16721: 
1.1.1.4 ! misho    16722:   install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd);
        !          16723:   install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd);
        !          16724:   install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd);
        !          16725:   install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd);
        !          16726:   install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd);
        !          16727:   install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd);
1.1       misho    16728: 
1.1.1.4 ! misho    16729:   install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd);
        !          16730:   install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd);
        !          16731:   install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd);
        !          16732:   install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd);
        !          16733:   install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd);
        !          16734:   install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd);
1.1       misho    16735: }
                   16736: 
                   16737: void
                   16738: bgp_route_finish (void)
                   16739: {
                   16740:   bgp_table_unlock (bgp_distance_table);
                   16741:   bgp_distance_table = NULL;
                   16742: }

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