xorp

route_table_base.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_base.hh,v 1.21 2008/11/08 06:14:38 mjh Exp $
00021 
00022 #ifndef __BGP_ROUTE_TABLE_BASE_HH__
00023 #define __BGP_ROUTE_TABLE_BASE_HH__
00024 
00025 
00026 
00027 
00028 #include "libxorp/ipv4net.hh"
00029 #include "libxorp/ipv4.hh"
00030 #include "internal_message.hh"
00031 //#include "dump_iterators.hh"
00032 
00033 template<class A>
00034 class DumpIterator;
00035 
00036 enum RouteTableType {
00037     RIB_IN_TABLE = 1,
00038     RIB_OUT_TABLE = 2,
00039     CACHE_TABLE = 3,
00040     DECISION_TABLE = 4,
00041     FANOUT_TABLE = 5,
00042     FILTER_TABLE = 6,
00043     DELETION_TABLE = 7,
00044     DUMP_TABLE = 8,
00045     NHLOOKUP_TABLE = 9,
00046     DEBUG_TABLE = 10,
00047     POLICY_TABLE = 11,
00048     AGGREGATION_TABLE = 12,
00049     DAMPING_TABLE = 13
00050 };
00051 
00052 #define MAX_TABLE_TYPE 13
00053 
00054 #define ADD_USED 1
00055 #define ADD_UNUSED 2
00056 #define ADD_FAILURE 3 
00057 #define ADD_FILTERED 4 
00058 
00075 template<class A>
00076 class BGPRouteTable {
00077 public:
00078     BGPRouteTable(string tablename, Safi safi);
00079     virtual ~BGPRouteTable();
00080     virtual int add_route(InternalMessage<A> &rtmsg, 
00081               BGPRouteTable<A> *caller) = 0;
00082     virtual int replace_route(InternalMessage<A> &old_rtmsg, 
00083                   InternalMessage<A> &new_rtmsg, 
00084                   BGPRouteTable<A> *caller) = 0;
00085     virtual int delete_route(InternalMessage<A> &rtmsg, 
00086                  BGPRouteTable<A> *caller) = 0;
00087     virtual int route_dump(InternalMessage<A> &rtmsg, 
00088                BGPRouteTable<A> *caller,
00089                const PeerHandler *dump_peer);
00090     virtual int push(BGPRouteTable<A> *caller) = 0;
00091 
00092     virtual const 
00093     SubnetRoute<A> *lookup_route(const IPNet<A> &net,
00094                  uint32_t& genid,
00095                  FPAListRef& pa_list) const = 0;
00096 
00097     virtual void route_used(const SubnetRoute<A>* /*route*/, 
00098                 bool /*in_use*/){
00099     abort();
00100     }
00101 
00102     void set_next_table(BGPRouteTable<A>* table) {
00103     _next_table = table;
00104     }
00105     BGPRouteTable<A> *next_table() { return _next_table;}
00106 
00107     /* parent is only supposed to be called on single-parent tables*/
00108     virtual BGPRouteTable<A> *parent() { return _parent; }
00109     virtual void set_parent(BGPRouteTable<A> *parent) { _parent = parent; }
00110 
00111     virtual RouteTableType type() const = 0;
00112     const string& tablename() const {return _tablename;}
00113     virtual string str() const = 0;
00114 
00115     /* mechanisms to implement flow control in the output plumbing */
00116     virtual void wakeup();
00117     virtual bool get_next_message(BGPRouteTable *) {abort(); return false; }
00118 
00119     virtual bool dump_next_route(DumpIterator<A>& dump_iter);
00125     virtual void igp_nexthop_changed(const A& bgp_nexthop);
00126 
00127     virtual void peering_went_down(const PeerHandler *peer, uint32_t genid,
00128                    BGPRouteTable<A> *caller);
00129     virtual void peering_down_complete(const PeerHandler *peer, uint32_t genid,
00130                        BGPRouteTable<A> *caller);
00131     virtual void peering_came_up(const PeerHandler *peer, uint32_t genid,
00132                  BGPRouteTable<A> *caller);
00133 
00134     Safi safi() const {return _safi; }
00135 protected:
00136     BGPRouteTable<A> *_next_table, *_parent;
00137     string _tablename;
00138     const Safi _safi;
00139 };
00140 
00141 #endif // __BGP_ROUTE_TABLE_BASE_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations