xorp

rib_manager.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-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/rib/rib_manager.hh,v 1.39 2008/10/02 21:58:11 bms Exp $
00022 
00023 #ifndef __RIB_RIB_MANAGER_HH__
00024 #define __RIB_RIB_MANAGER_HH__
00025 
00026 #include "libxorp/xorp.h"
00027 #include "libxorp/eventloop.hh"
00028 #include "libxorp/status_codes.h"
00029 #include "libxipc/xrl_std_router.hh"
00030 #include "libxorp/profile.hh"
00031 
00032 #include "libproto/proto_state.hh"
00033 
00034 #include "rib.hh"
00035 #include "register_server.hh"
00036 #include "vifmanager.hh"
00037 #include "xrl_target.hh"
00038 
00039 
00040 class EventLoop;
00041 
00051 class RibManager : public ProtoState {
00052 public:
00060     RibManager(EventLoop& eventloop, XrlStdRouter& xrl_std_router,
00061            const string& fea_target);
00062 
00066     ~RibManager();
00067 
00073     int start();
00074 
00082     int stop();
00083 
00089     bool status_updater();
00090 
00097     ProcessStatus status(string& reason) const
00098     {
00099     reason = _status_reason;
00100     return _status_code;
00101     }
00102 
00115     int new_vif(const string& vifname, const Vif& vif, string& err);
00116 
00127     int delete_vif(const string& vifname, string& err);
00128 
00145     int     set_vif_flags(const string& vifname,
00146                   bool is_p2p,
00147                   bool is_loopback,
00148                   bool is_multicast,
00149                   bool is_broadcast,
00150                   bool is_up,
00151                   uint32_t mtu,
00152                   string& err);
00153 
00169     int add_vif_address(const string& vifname,
00170             const IPv4& addr,
00171             const IPv4Net& subnet,
00172             const IPv4& broadcast_addr,
00173             const IPv4& peer_addr,
00174             string& err);
00175 
00188     int delete_vif_address(const string& vifname,
00189                const IPv4& addr,
00190                string& err);
00191 
00196     void make_errors_fatal();
00197 
00204     void register_interest_in_target(const string& target_class);
00205 
00211     void register_interest_in_target_done(const XrlError& e);
00212 
00220     void deregister_interest_in_target(const string& target_class);
00221 
00227     void deregister_interest_in_target_done(const XrlError& e);
00228 
00236     void target_death(const string& target_class,
00237               const string& target_instance);
00238 
00239 
00256     int add_redist_xrl_output4(const string&    target_name,
00257                    const string&    from_protocol,
00258                    bool     unicast,
00259                    bool     multicast,
00260                    const IPv4Net&   network_prefix,
00261                    const string&    cookie,
00262                    bool     is_xrl_transaction_output);
00263 
00278     int delete_redist_xrl_output4(const string& target_name,
00279                   const string& from_protocol,
00280                   bool      unicast,
00281                   bool      multicast,
00282                   const string& cookie,
00283                   bool      is_xrl_transaction_output);
00284 
00285     XrlStdRouter& xrl_router() {    return _xrl_router; }
00286 
00290     void push_routes();
00291 
00303     void configure_filter(const uint32_t& filter, const string& conf);
00304 
00310     void reset_filter(const uint32_t& filter);
00311 
00315     PolicyFilters&  policy_filters()    { return _policy_filters; }
00316 
00320     PolicyRedistMap&    policy_redist_map() { return _policy_redist_map; }
00321 
00322 
00332     void insert_policy_redist_tags(const string& protocol, 
00333                    const PolicyTags& tags);
00334 
00342     void reset_policy_redist_tags();
00343 
00347     Profile& profile() {return _profile;}
00348 
00352     RIB<IPv4>& urib4() { return _urib4; }
00353 
00357     RIB<IPv4>& mrib4() { return _mrib4; }
00358 
00362     XrlRibTarget& xrl_rib_target() { return _xrl_rib_target; }
00363 
00364 #ifdef HAVE_IPV6
00365 
00380     int add_vif_address(const string& vifname,
00381             const IPv6& addr,
00382             const IPv6Net& subnet,
00383             const IPv6& peer,
00384             string& err);
00385 
00398     int delete_vif_address(const string& vifname,
00399                const IPv6& addr,
00400                string& err);
00401 
00418     int add_redist_xrl_output6(const string&    target_name,
00419                    const string&    from_protocol,
00420                    bool     unicast,
00421                    bool     multicast,
00422                    const IPv6Net&   network_prefix,
00423                    const string&    cookie,
00424                    bool     is_xrl_transaction_output);
00425 
00426 
00441     int delete_redist_xrl_output6(const string& target_name,
00442                   const string& from_protocol,
00443                   bool      unicast,
00444                   bool      multicast,
00445                   const string& cookie,
00446                   bool      is_xrl_transaction_output);
00447 
00448 
00452     RIB<IPv6>& urib6() { return _urib6; }
00453 
00457     RIB<IPv6>& mrib6() { return _mrib6; }
00458 
00459 
00460 #endif //ipv6
00461 
00462 private:
00463     ProcessStatus       _status_code;
00464     string              _status_reason;
00465     EventLoop&      _eventloop;     // The event loop to use
00466     XrlStdRouter&   _xrl_router;        // The XRL router to use
00467     RegisterServer  _register_server;    // To notify clients about route change
00468 
00469     RIB<IPv4>       _urib4;         // The IPv4 unicast RIB
00470     RIB<IPv4>       _mrib4;         // The IPv4 multicast RIB
00471 #ifdef HAVE_IPV6
00472     RIB<IPv6>       _urib6;         // The IPv6 unicast RIB
00473     RIB<IPv6>       _mrib6;         // The IPv6 multicast RIB
00474 #endif
00475     VifManager      _vif_manager;       // The VIF manager
00476     XrlRibTarget    _xrl_rib_target;
00477     set<string>     _targets_of_interest;   // Monitored XRL targets
00478     XorpTimer       _status_update_timer;   // Timer for periodic checks of RIB status
00479 
00480     const string    _fea_target;
00481 
00482     PolicyFilters   _policy_filters;    // Connected routes filter.
00483                         // only one should be present.
00484 
00485     PolicyRedistMap _policy_redist_map; // Policy registribution map
00486                         // [links policy-tags to
00487                         // targets].
00488                         // only one should be present.
00489     Profile _profile;               // Profiling logs.
00490 
00491 };
00492 
00493 #endif // __RIB_RIB_MANAGER_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations