|
xorp
|
00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- 00002 00003 // Copyright (c) 2001-2011 XORP, Inc and Others 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/fib2mrib/xrl_fib2mrib_node.hh,v 1.24 2008/10/02 21:57:14 bms Exp $ 00021 00022 #ifndef __FIB2MRIB_XRL_FIB2MRIB_NODE_HH__ 00023 #define __FIB2MRIB_XRL_FIB2MRIB_NODE_HH__ 00024 00025 00026 // 00027 // Fib2mrib XRL-aware node definition. 00028 // 00029 00030 #include "libxipc/xrl_std_router.hh" 00031 00032 #include "libfeaclient/ifmgr_xrl_mirror.hh" 00033 00034 #include "xrl/interfaces/finder_event_notifier_xif.hh" 00035 #include "xrl/interfaces/fti_xif.hh" 00036 #include "xrl/interfaces/fea_fib_xif.hh" 00037 #include "xrl/interfaces/rib_xif.hh" 00038 #include "xrl/targets/fib2mrib_base.hh" 00039 00040 #include "fib2mrib_node.hh" 00041 00042 00043 // 00044 // The top-level class that wraps-up everything together under one roof 00045 // 00046 class XrlFib2mribNode : public Fib2mribNode, 00047 public XrlStdRouter, 00048 public XrlFib2mribTargetBase { 00049 public: 00050 XrlFib2mribNode(EventLoop& eventloop, 00051 const string& class_name, 00052 const string& finder_hostname, 00053 uint16_t finder_port, 00054 const string& finder_target, 00055 const string& fea_target, 00056 const string& rib_target); 00057 ~XrlFib2mribNode(); 00058 00064 int startup(); 00065 00071 int shutdown(); 00072 00078 XrlRouter& xrl_router() { return *this; } 00079 00080 protected: 00081 // 00082 // XRL target methods 00083 // 00084 00088 XrlCmdError common_0_1_get_target_name( 00089 // Output values, 00090 string& name); 00091 00095 XrlCmdError common_0_1_get_version( 00096 // Output values, 00097 string& version); 00098 00102 XrlCmdError common_0_1_get_status( 00103 // Output values, 00104 uint32_t& status, 00105 string& reason); 00106 00110 XrlCmdError common_0_1_shutdown(); 00111 00112 XrlCmdError common_0_1_startup(); 00113 00121 XrlCmdError finder_event_observer_0_1_xrl_target_birth( 00122 // Input values, 00123 const string& target_class, 00124 const string& target_instance); 00125 00133 XrlCmdError finder_event_observer_0_1_xrl_target_death( 00134 // Input values, 00135 const string& target_class, 00136 const string& target_instance); 00137 00162 XrlCmdError fea_fib_client_0_1_add_route4( 00163 // Input values, 00164 const IPv4Net& network, 00165 const IPv4& nexthop, 00166 const string& ifname, 00167 const string& vifname, 00168 const uint32_t& metric, 00169 const uint32_t& admin_distance, 00170 const string& protocol_origin, 00171 const bool& xorp_route); 00172 00197 XrlCmdError fea_fib_client_0_1_replace_route4( 00198 // Input values, 00199 const IPv4Net& network, 00200 const IPv4& nexthop, 00201 const string& ifname, 00202 const string& vifname, 00203 const uint32_t& metric, 00204 const uint32_t& admin_distance, 00205 const string& protocol_origin, 00206 const bool& xorp_route); 00207 00219 XrlCmdError fea_fib_client_0_1_delete_route4( 00220 // Input values, 00221 const IPv4Net& network, 00222 const string& ifname, 00223 const string& vifname); 00224 00232 XrlCmdError fea_fib_client_0_1_resolve_route4( 00233 // Input values, 00234 const IPv4Net& network); 00235 00241 XrlCmdError fib2mrib_0_1_enable_fib2mrib( 00242 // Input values, 00243 const bool& enable); 00244 00245 XrlCmdError fib2mrib_0_1_start_fib2mrib(); 00246 00247 XrlCmdError fib2mrib_0_1_stop_fib2mrib(); 00248 00254 XrlCmdError fib2mrib_0_1_enable_log_trace_all( 00255 // Input values, 00256 const bool& enable); 00257 00264 XrlCmdError policy_backend_0_1_configure( 00265 // Input values, 00266 const uint32_t& filter, 00267 const string& conf); 00268 00274 XrlCmdError policy_backend_0_1_reset( 00275 // Input values, 00276 const uint32_t& filter); 00277 00281 XrlCmdError policy_backend_0_1_push_routes(); 00282 00283 00284 #ifdef HAVE_IPV6 00285 XrlCmdError fea_fib_client_0_1_add_route6( 00286 // Input values, 00287 const IPv6Net& network, 00288 const IPv6& nexthop, 00289 const string& ifname, 00290 const string& vifname, 00291 const uint32_t& metric, 00292 const uint32_t& admin_distance, 00293 const string& protocol_origin, 00294 const bool& xorp_route); 00295 00296 00297 XrlCmdError fea_fib_client_0_1_replace_route6( 00298 // Input values, 00299 const IPv6Net& network, 00300 const IPv6& nexthop, 00301 const string& ifname, 00302 const string& vifname, 00303 const uint32_t& metric, 00304 const uint32_t& admin_distance, 00305 const string& protocol_origin, 00306 const bool& xorp_route); 00307 00308 XrlCmdError fea_fib_client_0_1_delete_route6( 00309 // Input values, 00310 const IPv6Net& network, 00311 const string& ifname, 00312 const string& vifname); 00313 00314 XrlCmdError fea_fib_client_0_1_resolve_route6( 00315 // Input values, 00316 const IPv6Net& network); 00317 00318 #endif 00319 00320 private: 00321 const ServiceBase* ifmgr_mirror_service_base() const { 00322 return dynamic_cast<const ServiceBase*>(&_ifmgr); 00323 } 00324 const IfMgrIfTree& ifmgr_iftree() const { return _ifmgr.iftree(); } 00325 00331 virtual void finder_connect_event(); 00332 00338 virtual void finder_disconnect_event(); 00339 00340 void fea_register_startup(); 00341 void finder_register_interest_fea_cb(const XrlError& xrl_error); 00342 void fea_register_shutdown(); 00343 void finder_deregister_interest_fea_cb(const XrlError& xrl_error); 00344 00345 void send_fea_add_fib_client(); 00346 void fea_fti_client_send_have_ipv4_cb(const XrlError& xrl_error, 00347 const bool* result); 00348 #ifdef HAVE_IPV6 00349 void fea_fti_client_send_have_ipv6_cb(const XrlError& xrl_error, 00350 const bool* result); 00351 void fea_fib_client_send_add_fib_client6_cb(const XrlError& xrl_error); 00352 void fea_fib_client_send_delete_fib_client6_cb(const XrlError& xrl_error); 00353 void rib_client_send_add_igp_table6_cb(const XrlError& xrl_error); 00354 void rib_client_send_delete_igp_table6_cb(const XrlError& xrl_error); 00355 #endif 00356 00357 void fea_fib_client_send_add_fib_client4_cb(const XrlError& xrl_error); 00358 void send_fea_delete_fib_client(); 00359 void fea_fib_client_send_delete_fib_client4_cb(const XrlError& xrl_error); 00360 00361 void rib_register_startup(); 00362 void finder_register_interest_rib_cb(const XrlError& xrl_error); 00363 void rib_register_shutdown(); 00364 void finder_deregister_interest_rib_cb(const XrlError& xrl_error); 00365 void send_rib_add_tables(); 00366 void rib_client_send_add_igp_table4_cb(const XrlError& xrl_error); 00367 void send_rib_delete_tables(); 00368 void rib_client_send_delete_igp_table4_cb(const XrlError& xrl_error); 00369 00375 void inform_rib_route_change(const Fib2mribRoute& fib2mrib_route); 00376 00382 void cancel_rib_route_change(const Fib2mribRoute& fib2mrib_route); 00383 00384 void send_rib_route_change(); 00385 void send_rib_route_change_cb(const XrlError& xrl_error); 00386 00387 EventLoop& _eventloop; 00388 XrlFtiV0p2Client _xrl_fea_fti_client; 00389 XrlFeaFibV0p1Client _xrl_fea_fib_client; 00390 XrlRibV0p1Client _xrl_rib_client; 00391 const string _finder_target; 00392 const string _fea_target; 00393 const string _rib_target; 00394 00395 IfMgrXrlMirror _ifmgr; 00396 list<Fib2mribRoute> _inform_rib_queue; 00397 XorpTimer _inform_rib_queue_timer; 00398 XrlFinderEventNotifierV0p1Client _xrl_finder_client; 00399 00400 static const TimeVal RETRY_TIMEVAL; 00401 00402 bool _is_finder_alive; 00403 00404 bool _is_fea_alive; 00405 bool _is_fea_registered; 00406 bool _is_fea_registering; 00407 bool _is_fea_deregistering; 00408 XorpTimer _fea_register_startup_timer; 00409 XorpTimer _fea_register_shutdown_timer; 00410 00411 #ifdef HAVE_IPV6 00412 bool _is_fea_have_ipv6_tested; 00413 bool _fea_have_ipv6; 00414 bool _is_fea_fib_client6_registered; 00415 bool _is_rib_igp_table6_registered; 00416 #endif 00417 00418 bool _is_fea_have_ipv4_tested; 00419 bool _fea_have_ipv4; 00420 bool _is_fea_fib_client4_registered; 00421 XorpTimer _fea_fib_client_registration_timer; 00422 00423 bool _is_rib_alive; 00424 bool _is_rib_registered; 00425 bool _is_rib_registering; 00426 bool _is_rib_deregistering; 00427 bool _is_rib_igp_table4_registered; 00428 XorpTimer _rib_register_startup_timer; 00429 XorpTimer _rib_register_shutdown_timer; 00430 XorpTimer _rib_igp_table_registration_timer; 00431 }; 00432 00433 #endif // __FIB2MRIB_XRL_FIB2MRIB_NODE_HH__