xorp

print_peer.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_peer.hh,v 1.19 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 
00036 class PrintPeers : public XrlBgpV0p3Client {
00037 public:
00038     PrintPeers(bool verbose, int interval);
00039     void get_peer_list_start();
00040     void get_peer_list_start_done(const XrlError& e, 
00041                   const uint32_t* token, 
00042                   const bool* more);
00043     void get_peer_list_next();
00044     void get_peer_list_next_done(const XrlError& e, 
00045                  const string* local_ip, 
00046                  const uint32_t* local_port, 
00047                  const string* peer_ip, 
00048                  const uint32_t* peer_port, 
00049                  const bool* more);
00050     void print_peer_verbose(const string& local_ip, 
00051                 uint32_t local_port, 
00052                 const string& peer_ip, 
00053                 uint32_t peer_port);
00054     void get_peer_id_done(const XrlError& e, 
00055               const IPv4* peer_id);
00056     void get_peer_status_done(const XrlError& e, 
00057                   const uint32_t* peer_state, 
00058                   const uint32_t* admin_status);
00059     void get_peer_negotiated_version_done(const XrlError&, 
00060                       const int32_t* neg_version);
00061     void get_peer_as_done(const XrlError& e, 
00062               const string* peer_as);
00063     void get_peer_msg_stats_done(const XrlError& e, 
00064                  const uint32_t* in_updates, 
00065                  const uint32_t* out_updates, 
00066                  const uint32_t* in_msgs, 
00067                  const uint32_t* out_msgs, 
00068                  const uint32_t* last_error, 
00069                  const uint32_t* in_update_elapsed);
00070     void get_peer_established_stats_done(const XrlError&, 
00071                      const uint32_t* transitions, 
00072                      const uint32_t* established_time);
00073     void get_peer_timer_config_done(const XrlError& e, 
00074                     const uint32_t* retry_interval, 
00075                     const uint32_t* hold_time, 
00076                     const uint32_t* keep_alive, 
00077                     const uint32_t* hold_time_conf, 
00078                     const uint32_t* keep_alive_conf, 
00079                     const uint32_t* min_as_origination_interval,
00080                     const uint32_t* min_route_adv_interval);
00081     void do_verbose_peer_print();
00082     string time_units(uint32_t s) const;
00083     
00084 private:
00085     EventLoop _eventloop;
00086     XrlStdRouter _xrl_rtr;
00087     bool _verbose;
00088     uint32_t _token;
00089     bool _done;
00090     uint32_t _count;
00091     bool _prev_no_bgp;
00092     bool _prev_no_peers;
00093 
00094     //temporary storage while we retrieve peer data.
00095     bool _more; //after this one, are there more peers to retrieve
00096     uint32_t _received;
00097     IPv4 _peer_id;
00098     uint32_t _peer_state;
00099     uint32_t _admin_state;
00100     int32_t _negotiated_version;
00101     uint32_t _peer_as;
00102     uint32_t _in_updates;
00103     uint32_t _out_updates;
00104     uint32_t _in_msgs;
00105     uint32_t _out_msgs;
00106     uint32_t _last_error;
00107     uint32_t _in_update_elapsed;
00108     uint32_t _transitions;
00109     uint32_t _established_time;
00110     uint32_t _retry_interval;
00111     uint32_t _hold_time;
00112     uint32_t _keep_alive;
00113     uint32_t _hold_time_conf;
00114     uint32_t _keep_alive_conf;
00115     uint32_t _min_as_origination_interval;
00116     uint32_t _min_route_adv_interval;
00117 };
00118 
00119 #endif // __BGP_TOOLS_PRINT_PEER_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations