xorp

route_table_deletion.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_deletion.hh,v 1.25 2008/11/08 06:14:39 mjh Exp $
00021 
00022 #ifndef __BGP_ROUTE_TABLE_DELETION_HH__
00023 #define __BGP_ROUTE_TABLE_DELETION_HH__
00024 
00025 #include "route_table_base.hh"
00026 #include "peer_handler.hh"
00027 #include "bgp_trie.hh"
00028 #include "crash_dump.hh"
00029 
00030 
00031 class EventLoop;
00059 template<class A>
00060 class DeletionTable : public BGPRouteTable<A>, CrashDumper  {
00061 public:
00062     DeletionTable(string tablename,
00063           Safi safi,
00064           BgpTrie<A>* route_table,
00065           const PeerHandler *peer,
00066           uint32_t genid,
00067           BGPRouteTable<A> *parent);
00068     ~DeletionTable();
00069     int add_route(InternalMessage<A> &rtmsg,
00070           BGPRouteTable<A> *caller);
00071     int replace_route(InternalMessage<A> &old_rtmsg,
00072               InternalMessage<A> &new_rtmsg,
00073               BGPRouteTable<A> *caller);
00074     int delete_route(InternalMessage<A> &rtmsg,
00075              BGPRouteTable<A> *caller);
00076     int route_dump(InternalMessage<A> &rtmsg,
00077            BGPRouteTable<A> *caller,
00078            const PeerHandler *dump_peer);
00079     int push(BGPRouteTable<A> *caller);
00080     const SubnetRoute<A> *lookup_route(const IPNet<A> &net,
00081                        uint32_t& genid,
00082                        FPAListRef& pa_list) const;
00083     void route_used(const SubnetRoute<A>* route, bool in_use);
00084 
00085 
00086     RouteTableType type() const { return DELETION_TABLE; }
00087     string str() const;
00088 
00089     /* mechanisms to implement flow control in the output plumbing */
00090     void output_state(bool /*busy*/, BGPRouteTable<A> */*next_table*/) {
00091     abort();
00092     }
00093     bool get_next_message(BGPRouteTable<A> */*next_table*/) {
00094     abort();
00095     return false;
00096     }
00097 
00098     void initiate_background_deletion();
00099 
00103     uint32_t genid() const {return _genid;}
00104 
00105     string dump_state() const;
00106 
00107 private:
00108     void unplumb_self();
00109     bool delete_next_chain();
00110     EventLoop& eventloop() const {
00111     return _peer->eventloop();
00112     }
00113 
00114     const PeerHandler *_peer;
00115     uint32_t _genid;
00116     BgpTrie<A>* _route_table;
00117     typename BgpTrie<A>::PathmapType::const_iterator _del_sweep;
00118 
00119     int _deleted, _chains;
00120     XorpTask _deletion_task;
00121 };
00122 
00123 #endif // __BGP_ROUTE_TABLE_DELETION_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations