|
xorp
|
00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- 00002 // vim:set sts=4 ts=8: 00003 00004 // Copyright (c) 2001-2011 XORP, Inc and Others 00005 // 00006 // This program is free software; you can redistribute it and/or modify 00007 // it under the terms of the GNU General Public License, Version 2, June 00008 // 1991 as published by the Free Software Foundation. Redistribution 00009 // and/or modification of this program under the terms of any other 00010 // version of the GNU General Public License is not permitted. 00011 // 00012 // This program is distributed in the hope that it will be useful, but 00013 // WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, 00015 // see the GNU General Public License, Version 2, a copy of which can be 00016 // found in the XORP LICENSE.gpl file. 00017 // 00018 // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; 00019 // http://xorp.net 00020 00021 // $XORP: xorp/rip/redist.hh,v 1.14 2008/10/02 21:58:17 bms Exp $ 00022 00023 #ifndef __RIP_ROUTE_REDIST_HH__ 00024 #define __RIP_ROUTE_REDIST_HH__ 00025 00026 #include "route_entry.hh" 00027 00028 template <typename A> 00029 class RouteDB; 00030 00031 template <typename A> 00032 class RouteWalker; 00033 00047 template <typename A> 00048 class RedistRouteOrigin : 00049 public RouteEntryOrigin<A> 00050 { 00051 public: 00052 RedistRouteOrigin() : RouteEntryOrigin<A>(true) {} 00053 00060 uint32_t expiry_secs() const; 00061 00066 uint32_t deletion_secs() const; 00067 }; 00068 00069 00073 template <typename A> 00074 class RouteRedistributor : 00075 public NONCOPYABLE 00076 { 00077 public: 00078 typedef A Addr; 00079 typedef IPNet<A> Net; 00080 00081 public: 00087 RouteRedistributor(RouteDB<A>& route_db); 00088 00089 ~RouteRedistributor(); 00090 00104 bool add_route(const Net& net, 00105 const Addr& nexthop, 00106 const string& ifname, 00107 const string& vifname, 00108 uint16_t cost, 00109 uint16_t tag, 00110 const PolicyTags& policytags); 00111 00120 bool expire_route(const Net& net); 00121 00127 uint32_t route_count() const; 00128 00133 void withdraw_routes(); 00134 00138 bool withdrawing_routes() const; 00139 00140 private: 00145 bool withdraw_batch(); 00146 00147 protected: 00148 RouteDB<A>& _route_db; 00149 RedistRouteOrigin<A>* _rt_origin; 00150 00151 RouteWalker<A>* _wdrawer; // Route Withdrawl Walker 00152 XorpTimer _wtimer; // Clock for Withdrawls 00153 }; 00154 00155 #endif // __RIP_REDIST_HH__