xorp

ifmgr_xrl_mirror.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 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 
00023 #ifndef __LIBFEACLIENT_XRL_IFMGR_MIRROR_HH__
00024 #define __LIBFEACLIENT_XRL_IFMGR_MIRROR_HH__
00025 
00026 #include "libxorp/xorp.h"
00027 #include "libxorp/ipv4.hh"
00028 #include "libxorp/timer.hh"
00029 #include "libxorp/service.hh"
00030 #include "libxipc/finder_constants.hh"
00031 
00032 #include "xrl/targets/fea_ifmgr_mirror_base.hh"
00033 
00034 #include "ifmgr_atoms.hh"
00035 #include "ifmgr_cmd_queue.hh"
00036 
00037 
00038 class XrlStdRouter;
00039 class EventLoop;
00040 class IfMgrCommandBase;
00041 class IfMgrXrlMirrorRouter;
00042 class IfMgrXrlMirrorTarget;
00043 
00048 class IfMgrXrlMirrorRouterObserver {
00049 public:
00050     virtual ~IfMgrXrlMirrorRouterObserver() = 0;
00051     virtual void finder_disconnect_event() = 0;
00052     virtual void finder_ready_event() = 0;
00053 };
00054 
00059 class IfMgrHintObserver {
00060 public:
00061     virtual ~IfMgrHintObserver() = 0;
00062     virtual void tree_complete() = 0;
00063     virtual void updates_made() = 0;
00064 };
00065 
00093 class IfMgrXrlMirror
00094     : public    ServiceBase,
00095       protected IfMgrXrlMirrorRouterObserver,
00096       protected IfMgrHintObserver
00097 {
00098 public:
00099     typedef IfMgrCommandSinkBase::Cmd Cmd;
00100 
00101 public:
00111     IfMgrXrlMirror(EventLoop&   e,
00112            const char*  rtarget,
00113            IPv4     finder_addr,
00114            uint16_t finder_port);
00115 
00125     IfMgrXrlMirror(EventLoop&   e,
00126            const char*  rtarget,
00127            const char*  finder_hostname,
00128            uint16_t finder_port);
00129 
00130     ~IfMgrXrlMirror();
00131 
00141     int startup();
00142 
00149     int shutdown();
00150 
00155     const IfMgrIfTree& iftree() const       { return _iftree; }
00156 
00162     bool attach_hint_observer(IfMgrHintObserver* o);
00163 
00169     bool detach_hint_observer(IfMgrHintObserver* o);
00170 
00176     void delay_updates(const TimeVal& delay);
00177 
00178 protected:
00179     void finder_ready_event();
00180     void finder_disconnect_event();
00181     void register_with_ifmgr();
00182     void unregister_with_ifmgr();
00183 
00184 protected:
00185     void tree_complete();
00186     void updates_made();
00187 
00188 protected:
00189     void register_cb(const XrlError& e);
00190     void unregister_cb(const XrlError& e);
00191 
00192 protected:
00193     EventLoop&          _e;
00194     IPv4            _finder_addr;
00195     string          _finder_hostname;
00196     uint16_t            _finder_port;
00197     IfMgrIfTree         _iftree;
00198     IfMgrCommandDispatcher  _dispatcher;
00199     string          _rtarget;   // registration target (ifmgr)
00200 
00201     IfMgrXrlMirrorRouter*   _rtr;
00202     IfMgrXrlMirrorTarget*   _xrl_tgt;
00203 
00204     list<IfMgrHintObserver*>    _hint_observers;
00205 
00206     XorpTimer           _reg_timer; // registration timer
00207 
00208 private:
00212     void do_updates();
00213 
00214     TimeVal         _updates_delay;
00215     XorpTimer           _updates_timer;
00216 };
00217 
00218 #endif // __LIBFEACLIENT_XRL_IFMGR_MIRROR_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations