xorp

route_table_policy.hh

00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
00002 // vim:set sts=4 ts=8:
00003 
00004 // Copyright (c) 2001-2009 XORP, Inc.
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/bgp/route_table_policy.hh,v 1.15 2008/11/08 06:14:39 mjh Exp $
00022 
00023 #ifndef __BGP_ROUTE_TABLE_POLICY_HH__
00024 #define __BGP_ROUTE_TABLE_POLICY_HH__
00025 
00026 #include "route_table_base.hh"
00027 #include "bgp_varrw.hh"
00028 #include "policy/backend/policy_filters.hh"
00029 
00039 template <class A>
00040 class PolicyTable : public BGPRouteTable<A> {
00041 public:
00049     PolicyTable(const string& tablename, const Safi& safi, 
00050         BGPRouteTable<A>* parent,
00051         PolicyFilters& pfs,
00052         const filter::Filter& type);
00053 
00054     virtual ~PolicyTable();
00055 
00056     int add_route(InternalMessage<A> &rtmsg,
00057                   BGPRouteTable<A> *caller);
00058     int replace_route(InternalMessage<A> &old_rtmsg,
00059                       InternalMessage<A> &new_rtmsg,
00060                       BGPRouteTable<A> *caller);
00061     int delete_route(InternalMessage<A> &rtmsg,
00062                      BGPRouteTable<A> *caller);
00063     virtual int route_dump(InternalMessage<A> &rtmsg,
00064                    BGPRouteTable<A> *caller,
00065                    const PeerHandler *dump_peer);
00066     int push(BGPRouteTable<A> *caller);
00067 
00068     void route_used(const SubnetRoute<A>* route, bool in_use);
00069     bool get_next_message(BGPRouteTable<A> *next_table);
00070 
00071     const SubnetRoute<A> *lookup_route(const IPNet<A> &net,
00072                        uint32_t& genid,
00073                        FPAListRef& pa_list) const;
00074 
00075     // XXX: keep one table type for now
00076     RouteTableType type() const { return POLICY_TABLE; }
00077    
00078     string str() const;
00079 
00090     bool do_filtering(InternalMessage<A>& rtmsg, 
00091               bool no_modify) const;
00092 
00093     void enable_filtering(bool on);
00094 protected:
00095     virtual void init_varrw();
00096 
00097     const filter::Filter    _filter_type;
00098     BGPVarRW<A>*        _varrw;
00099 
00100 private:
00101     PolicyFilters&      _policy_filters;
00102     bool _enable_filtering;
00103 };
00104 
00105 #endif // __BGP_ROUTE_TABLE_POLICY_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations