xorp

xrl_static_routes_node.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 General Public License, Version 2, June
00008 // 1991 as published by the Free Software Foundation. Redistribution
00009 // and/or modification of this program under the terms of any other
00010 // version of the GNU General Public License is not permitted.
00011 // 
00012 // This program is distributed in the hope that it will be useful, but
00013 // WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
00015 // see the GNU General Public License, Version 2, a copy of which can be
00016 // found in the XORP LICENSE.gpl file.
00017 // 
00018 // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
00019 // http://xorp.net
00020 
00021 // $XORP: xorp/static_routes/xrl_static_routes_node.hh,v 1.26 2008/10/02 21:58:29 bms Exp $
00022 
00023 #ifndef __STATIC_ROUTES_XRL_STATIC_ROUTES_NODE_HH__
00024 #define __STATIC_ROUTES_XRL_STATIC_ROUTES_NODE_HH__
00025 
00026 
00027 //
00028 // StaticRoutes XRL-aware node definition.
00029 //
00030 
00031 #include "libxipc/xrl_std_router.hh"
00032 
00033 #include "libfeaclient/ifmgr_xrl_mirror.hh"
00034 
00035 #include "xrl/interfaces/finder_event_notifier_xif.hh"
00036 #include "xrl/interfaces/rib_xif.hh"
00037 #include "xrl/targets/static_routes_base.hh"
00038 
00039 #include "static_routes_node.hh"
00040 
00041 
00042 //
00043 // The top-level class that wraps-up everything together under one roof
00044 //
00045 class XrlStaticRoutesNode : public StaticRoutesNode,
00046                 public XrlStdRouter,
00047                 public XrlStaticRoutesTargetBase {
00048 public:
00049     XrlStaticRoutesNode(EventLoop&  eventloop,
00050             const string&   class_name,
00051             const string&   finder_hostname,
00052             uint16_t    finder_port,
00053             const string&   finder_target,
00054             const string&   fea_target,
00055             const string&   rib_target);
00056     ~XrlStaticRoutesNode();
00057 
00063     int startup();
00064 
00070     int shutdown();
00071 
00077     XrlRouter&  xrl_router() { return *this; }
00078 
00079 protected:
00080     //
00081     // XRL target methods
00082     //
00083 
00087     XrlCmdError common_0_1_get_target_name(
00088     // Output values, 
00089     string& name);
00090 
00094     XrlCmdError common_0_1_get_version(
00095     // Output values, 
00096     string& version);
00097 
00101     XrlCmdError common_0_1_get_status(
00102     // Output values, 
00103     uint32_t&   status, 
00104     string& reason);
00105 
00109     XrlCmdError common_0_1_shutdown();
00110 
00111     XrlCmdError common_0_1_startup();
00112 
00120     XrlCmdError finder_event_observer_0_1_xrl_target_birth(
00121     // Input values,
00122     const string&   target_class,
00123     const string&   target_instance);
00124 
00132     XrlCmdError finder_event_observer_0_1_xrl_target_death(
00133     // Input values,
00134     const string&   target_class,
00135     const string&   target_instance);
00136 
00142     XrlCmdError static_routes_0_1_enable_static_routes(
00143     // Input values,
00144     const bool& enable);
00145 
00146     XrlCmdError static_routes_0_1_start_static_routes();
00147 
00148     XrlCmdError static_routes_0_1_stop_static_routes();
00149 
00166     XrlCmdError static_routes_0_1_add_route4(
00167     // Input values,
00168     const bool& unicast,
00169     const bool& multicast,
00170     const IPv4Net&  network,
00171     const IPv4& nexthop,
00172     const uint32_t& metric);
00173 
00174     XrlCmdError static_routes_0_1_add_route6(
00175     // Input values,
00176     const bool& unicast,
00177     const bool& multicast,
00178     const IPv6Net&  network,
00179     const IPv6& nexthop,
00180     const uint32_t& metric);
00181 
00182     XrlCmdError static_routes_0_1_replace_route4(
00183     // Input values,
00184     const bool& unicast,
00185     const bool& multicast,
00186     const IPv4Net&  network,
00187     const IPv4& nexthop,
00188     const uint32_t& metric);
00189 
00190     XrlCmdError static_routes_0_1_replace_route6(
00191     // Input values,
00192     const bool& unicast,
00193     const bool& multicast,
00194     const IPv6Net&  network,
00195     const IPv6& nexthop,
00196     const uint32_t& metric);
00197 
00198     XrlCmdError static_routes_0_1_delete_route4(
00199     // Input values,
00200     const bool& unicast,
00201     const bool& multicast,
00202     const IPv4Net&  network,
00203     const IPv4& nexthop);
00204 
00205     XrlCmdError static_routes_0_1_delete_route6(
00206     // Input values,
00207     const bool& unicast,
00208     const bool& multicast,
00209     const IPv6Net&  network,
00210     const IPv6& nexthop);
00211 
00228     XrlCmdError static_routes_0_1_add_backup_route4(
00229     // Input values,
00230     const bool& unicast,
00231     const bool& multicast,
00232     const IPv4Net&  network,
00233     const IPv4& nexthop,
00234     const uint32_t& metric);
00235 
00236     XrlCmdError static_routes_0_1_add_backup_route6(
00237     // Input values,
00238     const bool& unicast,
00239     const bool& multicast,
00240     const IPv6Net&  network,
00241     const IPv6& nexthop,
00242     const uint32_t& metric);
00243 
00244     XrlCmdError static_routes_0_1_replace_backup_route4(
00245     // Input values,
00246     const bool& unicast,
00247     const bool& multicast,
00248     const IPv4Net&  network,
00249     const IPv4& nexthop,
00250     const uint32_t& metric);
00251 
00252     XrlCmdError static_routes_0_1_replace_backup_route6(
00253     // Input values,
00254     const bool& unicast,
00255     const bool& multicast,
00256     const IPv6Net&  network,
00257     const IPv6& nexthop,
00258     const uint32_t& metric);
00259 
00260     XrlCmdError static_routes_0_1_delete_backup_route4(
00261     // Input values,
00262     const bool& unicast,
00263     const bool& multicast,
00264     const IPv4Net&  network,
00265     const IPv4& nexthop);
00266 
00267     XrlCmdError static_routes_0_1_delete_backup_route6(
00268     // Input values,
00269     const bool& unicast,
00270     const bool& multicast,
00271     const IPv6Net&  network,
00272     const IPv6& nexthop);
00273 
00297     XrlCmdError static_routes_0_1_add_interface_route4(
00298     // Input values,
00299     const bool& unicast,
00300     const bool& multicast,
00301     const IPv4Net&  network,
00302     const IPv4& nexthop,
00303     const string&   ifname,
00304     const string&   vifname,
00305     const uint32_t& metric);
00306 
00307     XrlCmdError static_routes_0_1_add_interface_route6(
00308     // Input values,
00309     const bool& unicast,
00310     const bool& multicast,
00311     const IPv6Net&  network,
00312     const IPv6& nexthop,
00313     const string&   ifname,
00314     const string&   vifname,
00315     const uint32_t& metric);
00316 
00317     XrlCmdError static_routes_0_1_replace_interface_route4(
00318     // Input values,
00319     const bool& unicast,
00320     const bool& multicast,
00321     const IPv4Net&  network,
00322     const IPv4& nexthop,
00323     const string&   ifname,
00324     const string&   vifname,
00325     const uint32_t& metric);
00326 
00327     XrlCmdError static_routes_0_1_replace_interface_route6(
00328     // Input values,
00329     const bool& unicast,
00330     const bool& multicast,
00331     const IPv6Net&  network,
00332     const IPv6& nexthop,
00333     const string&   ifname,
00334     const string&   vifname,
00335     const uint32_t& metric);
00336 
00337     XrlCmdError static_routes_0_1_delete_interface_route4(
00338     // Input values,
00339     const bool& unicast,
00340     const bool& multicast,
00341     const IPv4Net&  network,
00342     const IPv4& nexthop,
00343     const string&   ifname,
00344     const string&   vifname);
00345 
00346     XrlCmdError static_routes_0_1_delete_interface_route6(
00347     // Input values,
00348     const bool& unicast,
00349     const bool& multicast,
00350     const IPv6Net&  network,
00351     const IPv6& nexthop,
00352     const string&   ifname,
00353     const string&   vifname);
00354 
00378     XrlCmdError static_routes_0_1_add_backup_interface_route4(
00379     // Input values,
00380     const bool& unicast,
00381     const bool& multicast,
00382     const IPv4Net&  network,
00383     const IPv4& nexthop,
00384     const string&   ifname,
00385     const string&   vifname,
00386     const uint32_t& metric);
00387 
00388     XrlCmdError static_routes_0_1_add_backup_interface_route6(
00389     // Input values,
00390     const bool& unicast,
00391     const bool& multicast,
00392     const IPv6Net&  network,
00393     const IPv6& nexthop,
00394     const string&   ifname,
00395     const string&   vifname,
00396     const uint32_t& metric);
00397 
00398     XrlCmdError static_routes_0_1_replace_backup_interface_route4(
00399     // Input values,
00400     const bool& unicast,
00401     const bool& multicast,
00402     const IPv4Net&  network,
00403     const IPv4& nexthop,
00404     const string&   ifname,
00405     const string&   vifname,
00406     const uint32_t& metric);
00407 
00408     XrlCmdError static_routes_0_1_replace_backup_interface_route6(
00409     // Input values,
00410     const bool& unicast,
00411     const bool& multicast,
00412     const IPv6Net&  network,
00413     const IPv6& nexthop,
00414     const string&   ifname,
00415     const string&   vifname,
00416     const uint32_t& metric);
00417 
00418     XrlCmdError static_routes_0_1_delete_backup_interface_route4(
00419     // Input values,
00420     const bool& unicast,
00421     const bool& multicast,
00422     const IPv4Net&  network,
00423     const IPv4& nexthop,
00424     const string&   ifname,
00425     const string&   vifname);
00426 
00427     XrlCmdError static_routes_0_1_delete_backup_interface_route6(
00428     // Input values,
00429     const bool& unicast,
00430     const bool& multicast,
00431     const IPv6Net&  network,
00432     const IPv6& nexthop,
00433     const string&   ifname,
00434     const string&   vifname);
00435 
00441     XrlCmdError static_routes_0_1_enable_log_trace_all(
00442     // Input values,
00443     const bool& enable);
00444 
00451     XrlCmdError policy_backend_0_1_configure(
00452         // Input values,
00453         const uint32_t& filter,
00454         const string&   conf);
00455 
00461     XrlCmdError policy_backend_0_1_reset(
00462         // Input values,
00463         const uint32_t& filter);
00464 
00468     XrlCmdError policy_backend_0_1_push_routes();
00469 
00470 
00471 private:
00472     const ServiceBase* ifmgr_mirror_service_base() const {
00473     return dynamic_cast<const ServiceBase*>(&_ifmgr);
00474     }
00475     const IfMgrIfTree& ifmgr_iftree() const { return _ifmgr.iftree(); }
00476 
00482     virtual void finder_connect_event();
00483 
00489     virtual void finder_disconnect_event();
00490 
00491     void fea_register_startup();
00492     void finder_register_interest_fea_cb(const XrlError& xrl_error);
00493     void fea_register_shutdown();
00494     void finder_deregister_interest_fea_cb(const XrlError& xrl_error);
00495 
00496     void rib_register_startup();
00497     void finder_register_interest_rib_cb(const XrlError& xrl_error);
00498     void rib_register_shutdown();
00499     void finder_deregister_interest_rib_cb(const XrlError& xrl_error);
00500     void send_rib_add_tables();
00501     void rib_client_send_add_igp_table4_cb(const XrlError& xrl_error);
00502 #ifdef HAVE_IPV6
00503     void rib_client_send_add_igp_table6_cb(const XrlError& xrl_error);
00504 #endif
00505     void send_rib_delete_tables();
00506     void rib_client_send_delete_igp_table4_cb(const XrlError& xrl_error);
00507 #ifdef HAVE_IPV6
00508     void rib_client_send_delete_igp_table6_cb(const XrlError& xrl_error);
00509 #endif
00510 
00516     void inform_rib_route_change(const StaticRoute& static_route);
00517 
00523     void cancel_rib_route_change(const StaticRoute& static_route);
00524 
00525     void send_rib_route_change();
00526     void send_rib_route_change_cb(const XrlError& xrl_error);
00527 
00528     EventLoop&      _eventloop;
00529     XrlRibV0p1Client    _xrl_rib_client;
00530     const string    _finder_target;
00531     const string    _fea_target;
00532     const string    _rib_target;
00533 
00534     IfMgrXrlMirror  _ifmgr;
00535     list<StaticRoute>   _inform_rib_queue;
00536     XorpTimer       _inform_rib_queue_timer;
00537     XrlFinderEventNotifierV0p1Client    _xrl_finder_client;
00538 
00539     static const TimeVal RETRY_TIMEVAL;
00540 
00541     bool        _is_finder_alive;
00542 
00543     bool        _is_fea_alive;
00544     bool        _is_fea_registered;
00545     bool        _is_fea_registering;
00546     bool        _is_fea_deregistering;
00547     XorpTimer       _fea_register_startup_timer;
00548     XorpTimer       _fea_register_shutdown_timer;
00549 
00550     bool        _is_rib_alive;
00551     bool        _is_rib_registered;
00552     bool        _is_rib_registering;
00553     bool        _is_rib_deregistering;
00554     bool        _is_rib_igp_table4_registered;
00555 #ifdef HAVE_IPV6
00556     bool        _is_rib_igp_table6_registered;
00557 #endif
00558     XorpTimer       _rib_register_startup_timer;
00559     XorpTimer       _rib_register_shutdown_timer;
00560     XorpTimer       _rib_igp_table_registration_timer;
00561 };
00562 
00563 #endif // __STATIC_ROUTES_XRL_STATIC_ROUTES_NODE_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations