|
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-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 Lesser General Public License, Version 00008 // 2.1, June 1999 as published by the Free Software Foundation. 00009 // Redistribution and/or modification of this program under the terms of 00010 // any other version of the GNU Lesser General Public License is not 00011 // permitted. 00012 // 00013 // This program is distributed in the hope that it will be useful, but 00014 // WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, 00016 // see the GNU Lesser General Public License, Version 2.1, a copy of 00017 // which can be found in the XORP LICENSE.lgpl file. 00018 // 00019 // XORP, Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; 00020 // http://xorp.net 00021 00022 // $XORP: xorp/libfeaclient/ifmgr_xrl_replicator.hh,v 1.15 2008/10/02 21:57:16 bms Exp $ 00023 00024 #ifndef __LIBFEACLIENT_IFMGR_XRL_REPLICATOR_HH__ 00025 #define __LIBFEACLIENT_IFMGR_XRL_REPLICATOR_HH__ 00026 00027 #include "ifmgr_atoms.hh" 00028 #include "ifmgr_cmd_base.hh" 00029 #include "ifmgr_cmd_queue.hh" 00030 00031 #include "libxorp/eventloop.hh" 00032 #include "libxorp/safe_callback_obj.hh" 00033 #include "libxipc/xrl_error.hh" 00034 00053 class IfMgrXrlReplicator : 00054 public IfMgrCommandSinkBase, public CallbackSafeObject { 00055 public: 00056 typedef IfMgrCommandSinkBase::Cmd Cmd; 00057 00058 public: 00062 IfMgrXrlReplicator(XrlSender& sender, 00063 const string& xrl_target_name); 00064 00068 void push(const Cmd& cmd); 00069 00073 void crank_replicator(); 00074 00078 const string& xrl_target_name() const { return _tgt; } 00079 00085 bool is_empty_queue() const { return (_queue.empty() == true); } 00086 00087 protected: 00091 virtual void crank_manager(); 00092 00096 virtual void crank_manager_cb(); 00097 00101 virtual void push_manager_queue(); 00102 00106 virtual void xrl_error_event(const XrlError& e); 00107 00108 protected: 00112 IfMgrXrlReplicator(); 00113 00117 IfMgrXrlReplicator(const IfMgrXrlReplicator&); 00118 00122 IfMgrXrlReplicator& operator=(const IfMgrXrlReplicator&); 00123 00124 private: 00125 void xrl_cb(const XrlError& e); 00126 00127 protected: 00128 XrlSender& _s; 00129 string _tgt; 00130 00131 IfMgrCommandFifoQueue _queue; 00132 bool _pending; 00133 }; 00134 00135 00136 class IfMgrXrlReplicationManager; 00137 00147 class IfMgrManagedXrlReplicator : 00148 public IfMgrXrlReplicator { 00149 public: 00150 IfMgrManagedXrlReplicator(IfMgrXrlReplicationManager& manager, 00151 XrlSender& sender, 00152 const string& target_name); 00153 00154 protected: 00158 void crank_manager(); 00159 00163 void crank_manager_cb(); 00164 00168 void push_manager_queue(); 00169 00170 void xrl_error_event(const XrlError& e); 00171 00172 private: 00173 IfMgrXrlReplicationManager& _mgr; 00174 }; 00175 00176 00177 class XrlRouter; 00178 00183 class IfMgrXrlReplicationManager : public IfMgrCommandSinkBase { 00184 public: 00185 typedef IfMgrCommandSinkBase::Cmd Cmd; 00186 00187 public: 00188 IfMgrXrlReplicationManager(XrlRouter& rtr); 00189 00190 ~IfMgrXrlReplicationManager(); 00191 00200 bool add_mirror(const string& xrl_target_name); 00201 00206 bool remove_mirror(const string& xrl_target_name); 00207 00213 void push(const Cmd& c); 00214 00218 void crank_replicators_queue(); 00219 00223 void crank_replicators_queue_cb(); 00224 00228 void push_manager_queue(IfMgrManagedXrlReplicator* r); 00229 00230 const IfMgrIfTree& iftree() const { return _iftree; } 00231 00232 private: 00233 typedef list<IfMgrManagedXrlReplicator*> Outputs; 00234 00235 IfMgrIfTree _iftree; 00236 XrlRouter& _rtr; 00237 Outputs _outputs; 00238 Outputs _replicators_queue; // Cmd queue with ordered replicators 00239 }; 00240 00241 #endif // __LIBFEACLIENT_IFMGR_XRL_REPLICATOR_HH__