|
xorp
|
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_expect.hh,v 1.12 2008/10/02 21:58:12 bms Exp $ 00021 00022 #ifndef __RIB_RT_TAB_EXPECT_HH__ 00023 #define __RIB_RT_TAB_EXPECT_HH__ 00024 00025 #include "rt_tab_base.hh" 00026 00027 template<class A> class ExpectedRouteChange; 00028 00042 template<class A> 00043 class ExpectTable : public RouteTable<A> { 00044 public: 00045 ExpectTable(const string& tablename, RouteTable<A>* parent); 00046 ~ExpectTable(); 00047 00048 const list<ExpectedRouteChange<A> >& expected_route_changes() const { 00049 return _expected_route_changes; 00050 } 00051 00052 void expect_add(const IPRouteEntry<A>& route); 00053 void expect_delete(const IPRouteEntry<A>& route); 00054 int add_route(const IPRouteEntry<A>& route, RouteTable<A>* caller); 00055 int delete_route(const IPRouteEntry<A>* route, RouteTable<A>* caller); 00056 const IPRouteEntry<A>* lookup_route(const IPNet<A>& net) const; 00057 const IPRouteEntry<A>* lookup_route(const A& addr) const; 00058 RouteRange<A>* lookup_route_range(const A& addr) const; 00059 TableType type() const { return EXPECT_TABLE; } 00060 RouteTable<A>* parent() { return _parent; } 00061 void replumb(RouteTable<A>* old_parent, RouteTable<A>* new_parent); 00062 string str() const; 00063 00064 private: 00065 RouteTable<A>* _parent; 00066 list<ExpectedRouteChange<A> > _expected_route_changes; 00067 }; 00068 00069 template <typename A> 00070 class ExpectedRouteChange { 00071 public: 00072 ExpectedRouteChange(bool add, const IPRouteEntry<A>& route); 00073 bool matches_add(const IPRouteEntry<A>& route) const; 00074 bool matches_delete(const IPRouteEntry<A>* route) const; 00075 string str() const; 00076 00077 private: 00078 bool _add; // true = add, false = delete 00079 IPRouteEntry<A> _route; 00080 }; 00081 00082 #endif // __RIB_RT_TAB_EXPECT_HH__