|
xorp
|
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/fea/tools/show_interfaces.hh,v 1.11 2008/10/02 21:57:13 bms Exp $ 00021 00022 #ifndef __FEA_TOOLS_SHOW_INTERFACES_HH__ 00023 #define __FEA_TOOLS_SHOW_INTERFACES_HH__ 00024 00025 00026 #include "libxorp/service.hh" 00027 00028 #include "libfeaclient/ifmgr_xrl_mirror.hh" 00029 00030 00031 class EventLoop; 00032 00033 00034 class InterfaceMonitor : public IfMgrHintObserver, 00035 public ServiceBase, 00036 public ServiceChangeObserverBase { 00037 public: 00047 InterfaceMonitor(EventLoop& eventloop, 00048 const string& class_name, 00049 const string& finder_hostname, 00050 uint16_t finder_port, 00051 const string& fea_target); 00052 00056 ~InterfaceMonitor(); 00057 00063 int startup(); 00064 00070 int shutdown(); 00071 00080 void print_interfaces(const string& print_iface_name) const; 00081 00082 protected: 00083 // 00084 // IfMgrHintObserver methods 00085 // 00086 void tree_complete(); 00087 void updates_made(); 00088 00089 void incr_startup_requests_n(); 00090 void decr_startup_requests_n(); 00091 void incr_shutdown_requests_n(); 00092 void decr_shutdown_requests_n(); 00093 void update_status(); 00094 00095 private: 00103 void status_change(ServiceBase* service, 00104 ServiceStatus old_status, 00105 ServiceStatus new_status); 00106 00112 const ServiceBase* ifmgr_mirror_service_base() const { return dynamic_cast<const ServiceBase*>(&_ifmgr); } 00113 00119 const IfMgrIfTree& ifmgr_iftree() const { return _ifmgr.iftree(); } 00120 00126 int ifmgr_startup(); 00127 00133 int ifmgr_shutdown(); 00134 00135 EventLoop& _eventloop; 00136 00137 IfMgrXrlMirror _ifmgr; 00138 00139 // 00140 // Status-related state 00141 // 00142 size_t _startup_requests_n; 00143 size_t _shutdown_requests_n; 00144 }; 00145 00146 #endif // __FEA_TOOLS_SHOW_INTERFACES_HH__