xorp

rt_tab_extint.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_extint.hh,v 1.18 2008/10/02 21:58:12 bms Exp $
00021 
00022 #ifndef __RIB_RT_TAB_EXTINT_HH__
00023 #define __RIB_RT_TAB_EXTINT_HH__
00024 
00025 #include "rt_tab_base.hh"
00026 
00027 
00060 template<class A>
00061 class ExtIntTable : public RouteTable<A> {
00062 public:
00069     ExtIntTable(RouteTable<A>* ext_table,
00070         RouteTable<A>* int_table);
00071 
00082     int add_route(const IPRouteEntry<A>& route, RouteTable<A>* caller);
00083 
00096     int delete_route(const IPRouteEntry<A>* route, RouteTable<A>* caller);
00097 
00109     const IPRouteEntry<A>* lookup_route(const IPNet<A>& net) const;
00110 
00125     const IPRouteEntry<A>* lookup_route(const A& addr) const;
00126 
00142     RouteRange<A>* lookup_route_range(const A& addr) const;
00143 
00147     TableType type() const  { return EXTINT_TABLE; }
00148 
00155     void replumb(RouteTable<A>* old_parent, RouteTable<A>* new_parent);
00156 
00160     string str() const;
00161 
00162 private:
00163     typedef typename ResolvedIPRouteEntry<A>::RouteBackLink ResolvedRouteBackLink;
00164     typedef typename UnresolvedIPRouteEntry<A>::RouteBackLink UnresolvedRouteBackLink;
00165 
00166     int delete_ext_route(const IPRouteEntry<A>* route,
00167              bool& is_delete_propagated);
00168 
00169     const ResolvedIPRouteEntry<A>* lookup_in_resolved_table(
00170     const IPNet<A>& ipv4net);
00171 
00172     void resolve_unresolved_nexthops(const IPRouteEntry<A>& route);
00173 
00174     const ResolvedIPRouteEntry<A>* resolve_and_store_route(
00175     const IPRouteEntry<A>& route,
00176     const IPRouteEntry<A>* nexthop_route);
00177 
00178     bool delete_unresolved_nexthop(const IPRouteEntry<A>* route);
00179 
00180     void recalculate_nexthops(const IPRouteEntry<A>& route);
00181 
00182     const ResolvedIPRouteEntry<A>* lookup_by_igp_parent(
00183     const IPRouteEntry<A>* route);
00184 
00185     const ResolvedIPRouteEntry<A>* lookup_next_by_igp_parent(
00186     const IPRouteEntry<A>* route,
00187     const ResolvedIPRouteEntry<A>* previous);
00188 
00189     const IPRouteEntry<A>* lookup_route_in_igp_parent(
00190     const IPNet<A>& subnet) const;
00191     const IPRouteEntry<A>* lookup_route_in_igp_parent(const A& addr) const;
00192 
00193     const IPRouteEntry<A>* lookup_route_in_egp_parent(
00194     const IPNet<A>& subnet) const;
00195     const IPRouteEntry<A>* lookup_route_in_egp_parent(const A& addr) const;
00196 
00197     RouteTable<A>*              _ext_table;
00198     RouteTable<A>*              _int_table;
00199     Trie<A, const ResolvedIPRouteEntry<A>* >    _ip_route_table;
00200     multimap<A, UnresolvedIPRouteEntry<A>* >    _ip_unresolved_nexthops;
00201     map<IPNet<A>, UnresolvedIPRouteEntry<A>* >  _ip_unresolved_table;
00202 
00203     // _ip_igp_parents gives us a fast way of finding a route
00204     // affected by a change in an igp parent route
00205     multimap<const IPRouteEntry<A>*, ResolvedIPRouteEntry<A>* > _ip_igp_parents;
00206 
00207     // _resolving_routes is a Trie of all the routes that are used to
00208     // resolve external routes
00209     Trie<A, const IPRouteEntry<A>* > _resolving_routes;
00210 };
00211 
00212 #endif // __RIB_RT_TAB_EXTINT_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations