xorp

route_table_debug.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/route_table_debug.hh,v 1.16 2008/11/08 06:14:38 mjh Exp $
00021 
00022 #ifndef __BGP_ROUTE_TABLE_DEBUG_HH__
00023 #define __BGP_ROUTE_TABLE_DEBUG_HH__
00024 
00025 #include "route_table_base.hh"
00026 #include "libxorp/ref_trie.hh"
00027 
00028 template<class A>
00029 class DebugTable : public BGPRouteTable<A>  {
00030 public:
00031     DebugTable(string tablename, BGPRouteTable<A> *parent);
00032     ~DebugTable();
00033     int add_route(InternalMessage<A> &rtmsg,
00034           BGPRouteTable<A> *caller);
00035     int replace_route(InternalMessage<A> &old_rtmsg,
00036               InternalMessage<A> &new_rtmsg,
00037               BGPRouteTable<A> *caller);
00038     int delete_route(InternalMessage<A> &rtmsg, 
00039              BGPRouteTable<A> *caller);
00040     int push(BGPRouteTable<A> *caller);
00041     int route_dump(InternalMessage<A> &rtmsg, 
00042            BGPRouteTable<A> *caller,
00043            const PeerHandler *peer);
00044     const SubnetRoute<A> *lookup_route(const IPNet<A> &net,
00045                        uint32_t& genid,
00046                        FPAListRef& pa_list) const;
00047     void wakeup();
00048     void route_used(const SubnetRoute<A>* route, bool in_use);
00049 
00050     RouteTableType type() const {return DEBUG_TABLE;}
00051     string str() const;
00052 
00053     /* mechanisms to implement flow control in the output plumbing */
00054     void output_state(bool busy, BGPRouteTable<A> *next_table);
00055     bool get_next_message(BGPRouteTable<A> *next_table);
00056 
00057     void peering_went_down(const PeerHandler *peer, uint32_t genid,
00058                BGPRouteTable<A> *caller);
00059     void peering_down_complete(const PeerHandler *peer, uint32_t genid,
00060                    BGPRouteTable<A> *caller);
00061 
00062     void set_canned_response(int response) {
00063     _canned_response = response;
00064     }
00065     void set_next_messages(int msgs) {
00066     _msgs = msgs;
00067     }
00068     void set_get_on_wakeup(bool get_on_wakeup) {
00069     _get_on_wakeup = get_on_wakeup;
00070     }
00071     bool set_output_file(const string& filename);
00072     void set_output_file(FILE *file);
00073     FILE *output_file() const {return _ofile;}
00074     void write_separator() const;
00075     void write_comment(const string& s) const;
00076     void enable_tablename_printing() {_print_tablename = true;}
00077     void set_is_winner(bool value) {_set_is_winner = value;}
00078 private:
00079     void print_route(const SubnetRoute<A>& route, FPAListRef palist) const;
00080     int _canned_response;
00081     int _msgs;
00082     FILE *_ofile;
00083     bool _close_on_delete;
00084     bool _print_tablename;
00085     bool _get_on_wakeup;
00086     bool _set_is_winner;
00087 };
00088 
00089 #endif // __BGP_ROUTE_TABLE_DEBUG_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations