xorp

vifmanager.hh

00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
00002 
00003 // Copyright (c) 2001-2009 XORP, Inc.
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License, Version 2, June
00007 // 1991 as published by the Free Software Foundation. Redistribution
00008 // and/or modification of this program under the terms of any other
00009 // version of the GNU General Public License is not permitted.
00010 // 
00011 // This program is distributed in the hope that it will be useful, but
00012 // WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
00014 // see the GNU General Public License, Version 2, a copy of which can be
00015 // found in the XORP LICENSE.gpl file.
00016 // 
00017 // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
00018 // http://xorp.net
00019 
00020 // $XORP: xorp/rib/vifmanager.hh,v 1.24 2008/10/02 21:58:14 bms Exp $
00021 
00022 #ifndef __RIB_VIFMANAGER_HH__
00023 #define __RIB_VIFMANAGER_HH__
00024 
00025 #include "libproto/proto_state.hh"
00026 
00027 #include "libfeaclient/ifmgr_xrl_mirror.hh"
00028 
00029 
00030 class EventLoop;
00031 class RibManager;
00032 class XrlRouter;
00033 
00048 class VifManager : public IfMgrHintObserver,
00049            public ServiceChangeObserverBase,
00050            public ProtoState {
00051 public:
00061     VifManager(XrlRouter& xrl_router, EventLoop& eventloop,
00062            RibManager* rib_manager, const string& fea_target);
00063 
00067     ~VifManager();
00068 
00079     int start();
00080 
00091     int stop();
00092 
00101     int     final_start();
00102 
00111     int     final_stop();
00112 
00113 protected:
00114     //
00115     // IfMgrHintObserver methods
00116     //
00117     void tree_complete();
00118     void updates_made();
00119 
00120     void incr_startup_requests_n();
00121     void decr_startup_requests_n();
00122     void incr_shutdown_requests_n();
00123     void decr_shutdown_requests_n();
00124     void update_status();
00125 
00126 private:
00134     void status_change(ServiceBase*  service,
00135                ServiceStatus old_status,
00136                ServiceStatus new_status);
00137 
00143     const ServiceBase* ifmgr_mirror_service_base() const { return dynamic_cast<const ServiceBase*>(&_ifmgr); }
00144 
00150     const IfMgrIfTree&  ifmgr_iftree() const { return _ifmgr.iftree(); }
00151 
00157     int ifmgr_startup();
00158 
00164     int ifmgr_shutdown();
00165 
00166     XrlRouter&      _xrl_router;
00167     EventLoop&      _eventloop;
00168     RibManager*     _rib_manager;
00169 
00170     IfMgrXrlMirror  _ifmgr;
00171     IfMgrIfTree     _iftree;
00172     IfMgrIfTree     _old_iftree;
00173 
00174     //
00175     // Status-related state
00176     //
00177     size_t      _startup_requests_n;
00178     size_t      _shutdown_requests_n;
00179 };
00180 
00181 #endif // __RIB_VIFMANAGER_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations