xorp

print_routes.hh

00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
00002 
00003 // Copyright (c) 2001-2009 XORP, Inc.
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License, Version 2, June
00007 // 1991 as published by the Free Software Foundation. Redistribution
00008 // and/or modification of this program under the terms of any other
00009 // version of the GNU General Public License is not permitted.
00010 // 
00011 // This program is distributed in the hope that it will be useful, but
00012 // WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
00014 // see the GNU General Public License, Version 2, a copy of which can be
00015 // found in the XORP LICENSE.gpl file.
00016 // 
00017 // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
00018 // http://xorp.net
00019 
00020 // $XORP: xorp/bgp/tools/print_routes.hh,v 1.25 2008/10/02 21:56:28 bms Exp $
00021 
00022 #ifndef __BGP_TOOLS_PRINT_PEER_HH__
00023 #define __BGP_TOOLS_PRINT_PEER_HH__
00024 
00025 #include "bgptools_module.h"
00026 
00027 #include "libxorp/xorp.h"
00028 #include "libxorp/xlog.h"
00029 
00030 #include "libxipc/xrl_std_router.hh"
00031 #include "libxipc/xrl_args.hh"
00032 
00033 #include "xrl/interfaces/bgp_xif.hh"
00034 
00035 #include "bgp/aspath.hh"
00036 #include "bgp/path_attribute.hh"
00037 
00038 
00039 template <typename A>
00040 class PrintRoutes : public XrlBgpV0p3Client {
00041 public:
00042     static const uint32_t MAX_REQUESTS = 100;
00043     static const int32_t INVALID = -1;
00044     enum detail_t {SUMMARY, NORMAL, DETAIL};
00045     PrintRoutes(detail_t verbose, int interval, IPNet<A> net, bool unicast,
00046         bool multicast, int lines = -1);
00047     void get_route_list_start(IPNet<A> net, bool unicast, bool multicast);
00048     void get_route_list_start_done(const XrlError& e,
00049                    const uint32_t* token);
00050     void get_route_list_next();
00051     void get_route_list_next_done(const XrlError&    e,
00052                   const IPv4*        peer_id,
00053                   const IPNet<A>*    net,
00054                   const uint32_t     *best_and_origin,
00055                   const vector<uint8_t>* aspath,
00056                   const A*       nexthop,
00057                   const int32_t*     med,
00058                   const int32_t*     localpref,
00059                   const int32_t*     atomic_agg,
00060                   const vector<uint8_t>* aggregator,
00061                   const int32_t*     calc_localpref,
00062                   const vector<uint8_t>* attr_unknown,
00063                   const bool*        valid,
00064                   const bool*        unicast,
00065                   const bool*        multicast);
00066 private:
00067     void timer_expired();
00068 
00069     EventLoop       _eventloop;
00070     XrlStdRouter    _xrl_rtr;
00071     detail_t        _verbose;
00072     uint32_t        _token;
00073     bool        _done;
00074     uint32_t        _count;
00075     bool        _prev_no_bgp;
00076     bool        _prev_no_routes;
00077 
00078     XorpTimer       _timer;
00079     int         _active_requests;
00080     bool        _unicast;
00081     bool        _multicast;
00082     int         _lines;
00083 };
00084 
00085 #endif // __BGP_TOOLS_PRINT_PEER_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations