xorp

route_table_ribin.hh

00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
00002 
00003 // Copyright (c) 2001-2011 XORP, Inc and Others
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_ribin.hh,v 1.31 2008/11/08 06:14:40 mjh Exp $
00021 
00022 #ifndef __BGP_ROUTE_TABLE_RIBIN_HH__
00023 #define __BGP_ROUTE_TABLE_RIBIN_HH__
00024 
00025 
00026 
00027 #include "libxorp/eventloop.hh"
00028 #include "route_table_base.hh"
00029 #include "crash_dump.hh"
00030 #include "bgp_trie.hh"
00031 
00032 class EventLoop;
00033 
00052 template<class A>
00053 class RibInTable : public BGPRouteTable<A>, CrashDumper {
00054 public:
00055     RibInTable(string tablename, Safi safi, const PeerHandler *peer);
00056     ~RibInTable();
00060     void flush();
00061 
00062     /* this version is deprecated  - we only use messages between stages */
00063     int add_route(InternalMessage<A>& /*rtmsg*/,
00064           BGPRouteTable<A>* /*caller*/) { abort(); return 0; }
00065 
00066     int add_route(const IPNet<A> &net,
00067           FPAListRef& pa_list,
00068           const PolicyTags& policy_tags);
00069 
00070     void ribin_peering_went_down();
00071     void ribin_peering_came_up();
00072 
00073     /*replace_route doesn't make sense for a RibIn because it's the
00074       RibIn that decides whether this is an add or a replace*/
00075     int replace_route(InternalMessage<A> & /*old_rtmsg*/,
00076               InternalMessage<A> & /*new_rtmsg*/,
00077               BGPRouteTable<A> * /*caller*/ ) { abort(); return 0; }
00078 
00079     /* this version is deprecated  - we only use messages between stages */
00080     int delete_route(InternalMessage<A>& /*rtmsg*/,
00081              BGPRouteTable<A>* /*caller*/) { abort(); return 0; }
00082 
00083     int delete_route(const IPNet<A> &net);
00084     
00085 
00086     int push(BGPRouteTable<A> *caller);
00087     int delete_add_routes();
00088     const SubnetRoute<A> *lookup_route(const IPNet<A> &net, 
00089                        uint32_t& genid,
00090                        FPAListRef& pa_list) const;
00091     void route_used(const SubnetRoute<A>* route, bool in_use);
00092 
00093     BGPRouteTable<A> *parent() { return NULL; }
00094 
00095     RouteTableType type() const { return RIB_IN_TABLE; }
00096 
00097     string str() const;
00098 
00099     bool get_next_message(BGPRouteTable<A> */*next_table*/) {
00100     abort();
00101     return false;
00102     }
00103     void set_peer_is_up() { _peer_is_up = true; }
00104 
00105     bool dump_next_route(DumpIterator<A>& dump_iter);
00106 
00107     /*igp_nexthop_changed is called when the IGP routing changes in
00108       such a way that IGP information that was being used by BGP for
00109       its decision process is affected.  We need to scan through the
00110       RIB, looking for routes that have this nexthop, and propagate
00111       them downstream again to see if the change makes a difference */
00112     void igp_nexthop_changed(const A& bgp_nexthop);
00113 
00114     int route_count() const {
00115     return _route_table->route_count();
00116     }
00117 
00118     BgpTrie<A>& trie() const {
00119     return *_route_table;
00120     }
00121 
00122     const PeerHandler* peer_handler() const {
00123     return _peer;
00124     }
00125 
00126     uint32_t genid() const {
00127     return _genid;
00128     }
00129 
00130     void crash_dump() const {
00131     CrashDumper::crash_dump();
00132     }
00133     string dump_state() const;
00134 
00135 private:
00136     EventLoop& eventloop() const;
00137 
00138     BgpTrie<A>* _route_table;
00139     const PeerHandler *_peer;
00140     bool _peer_is_up;
00141     uint32_t _genid;
00142     uint32_t _table_version;
00143 
00144     // state and methods related to re-sending all the routes related
00145     // to a nexthop whose IGP information has changed.
00146     set <A> _changed_nexthops;
00147     bool _nexthop_push_active;
00148     A _current_changed_nexthop;
00149     typename BgpTrie<A>::PathmapType::const_iterator _current_chain;
00150     XorpTask _push_task;
00151     bool push_next_changed_nexthop();
00152     void deletion_nexthop_check(const SubnetRoute<A>* route);
00153     void next_chain();
00154     void stop_nexthop_push();
00155     // end of IGP nexthop handing stuff
00156 };
00157 
00158 #endif // __BGP_ROUTE_TABLE_RIBIN_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations