xorp

rt_tab_origin.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/rib/rt_tab_origin.hh,v 1.23 2008/10/02 21:58:13 bms Exp $
00021 
00022 #ifndef __RIB_RT_TAB_ORIGIN_HH__
00023 #define __RIB_RT_TAB_ORIGIN_HH__
00024 
00025 #include "libxorp/eventloop.hh"
00026 
00027 #include "rt_tab_base.hh"
00028 
00029 
00042 template<class A>
00043 class OriginTable : public RouteTable<A> {
00044 public:
00045     typedef Trie<A, const IPRouteEntry<A>*> RouteContainer;
00046 
00047 public:
00061     OriginTable(const string& tablename, uint32_t admin_distance,
00062         ProtocolType protocol_type, EventLoop& eventloop);
00063 
00067     ~OriginTable();
00068 
00076     int add_route(const IPRouteEntry<A>& route);
00077 
00082     int add_route(const IPRouteEntry<A>&, RouteTable<A>* );
00083 
00090     int delete_route(const IPNet<A>& net);
00091 
00096     int delete_route(const IPRouteEntry<A>* , RouteTable<A>* );
00097 
00103     void delete_all_routes();
00104 
00109     void routing_protocol_shutdown();
00110 
00117     const IPRouteEntry<A>* lookup_route(const IPNet<A>& net) const;
00118 
00127     const IPRouteEntry<A>* lookup_route(const A& addr) const;
00128 
00141     RouteRange<A>* lookup_route_range(const A& addr) const;
00142 
00146     uint32_t admin_distance() const { return _admin_distance; }
00147 
00151     int protocol_type() const       { return _protocol_type; }
00152 
00156     TableType type() const      { return ORIGIN_TABLE; }
00157 
00161     void replumb(RouteTable<A>* , RouteTable<A>* ) {}
00162 
00166     string str() const;
00167 
00172     uint32_t generation() const;
00173 
00177     uint32_t route_count() const;
00178 
00182     const RouteContainer& route_container() const;
00183 
00184 private:
00185     uint32_t        _admin_distance;    // 0 .. 255
00186     ProtocolType    _protocol_type; // IGP or EGP
00187     EventLoop&      _eventloop;
00188     RouteContainer* _ip_route_table;
00189     uint32_t        _gen;
00190 };
00191 
00192 
00193 template <class A>
00194 inline uint32_t
00195 OriginTable<A>::generation() const
00196 {
00197     return _gen;
00198 }
00199 
00200 template <class A>
00201 inline uint32_t
00202 OriginTable<A>::route_count() const
00203 {
00204     return _ip_route_table->route_count();
00205 }
00206 
00207 template <class A>
00208 inline const typename OriginTable<A>::RouteContainer&
00209 OriginTable<A>::route_container() const
00210 {
00211     return *_ip_route_table;
00212 }
00213 
00214 #endif // __RIB_RT_TAB_ORIGIN_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations