xorp

xrl_mfea_node.hh

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 #ifndef __FEA_XRL_MFEA_NODE_HH__
00021 #define __FEA_XRL_MFEA_NODE_HH__
00022 
00023 
00024 //
00025 // MFEA (Multicast Forwarding Engine Abstraction) XRL-aware node definition.
00026 //
00027 
00028 #include "libxipc/xrl_std_router.hh"
00029 #include "xrl/interfaces/finder_event_notifier_xif.hh"
00030 #include "xrl/interfaces/mfea_client_xif.hh"
00031 #include "xrl/interfaces/cli_manager_xif.hh"
00032 #include "xrl/targets/mfea_base.hh"
00033 #include "libfeaclient_bridge.hh"
00034 #include "mfea_node.hh"
00035 #include "mfea_node_cli.hh"
00036 
00037 
00038 //
00039 // The top-level class that wraps-up everything together under one roof
00040 //
00041 class XrlMfeaNode : public MfeaNode,
00042             public XrlStdRouter,
00043             public XrlMfeaTargetBase,
00044             public MfeaNodeCli {
00045 public:
00046     XrlMfeaNode(FeaNode&    fea_node,
00047         int     family,
00048         xorp_module_id  module_id,
00049         EventLoop&  eventloop,
00050         const string&   class_name,
00051         const string&   finder_hostname,
00052         uint16_t    finder_port,
00053         const string&   finder_target);
00054 
00055     virtual ~XrlMfeaNode();
00056 
00062     int startup();
00063 
00069     int shutdown();
00070 
00076     XrlRouter&  xrl_router() { return *this; }
00077 
00083     const XrlRouter& xrl_router() const { return *this; }
00084 
00085     //
00086     // XrlMfeaNode front-end interface
00087     //
00088     int enable_cli();
00089     int disable_cli();
00090     int start_cli();
00091     int stop_cli();
00092     int enable_mfea();
00093     int disable_mfea();
00094     int start_mfea();
00095     int stop_mfea();
00096     
00097     
00098 protected:
00099     //
00100     // XRL target methods
00101     //
00105     XrlCmdError common_0_1_get_target_name(
00106     // Output values, 
00107     string& name);
00108 
00112     XrlCmdError common_0_1_get_version(
00113     // Output values, 
00114     string& version);
00115 
00119     XrlCmdError common_0_1_get_status(
00120     // Output values,
00121         uint32_t& status,
00122     string& reason);
00123 
00127     XrlCmdError common_0_1_shutdown();
00128 
00129     XrlCmdError common_0_1_startup() {
00130     return mfea_0_1_start_mfea();
00131     }
00132 
00140     XrlCmdError finder_event_observer_0_1_xrl_target_birth(
00141     // Input values,
00142     const string&   target_class,
00143     const string&   target_instance);
00144 
00152     XrlCmdError finder_event_observer_0_1_xrl_target_death(
00153     // Input values,
00154     const string&   target_class,
00155     const string&   target_instance);
00156 
00178     XrlCmdError cli_processor_0_1_process_command(
00179     // Input values, 
00180     const string&   processor_name, 
00181     const string&   cli_term_name, 
00182     const uint32_t& cli_session_id,
00183     const string&   command_name, 
00184     const string&   command_args, 
00185     // Output values, 
00186     string& ret_processor_name, 
00187     string& ret_cli_term_name, 
00188     uint32_t& ret_cli_session_id,
00189     string& ret_command_output);
00190 
00194     XrlCmdError ifmgr_replicator_0_1_register_ifmgr_mirror(
00195     // Input values,
00196     const string&   clientname);
00197 
00201     XrlCmdError ifmgr_replicator_0_1_unregister_ifmgr_mirror(
00202     // Input values,
00203     const string&   clientname);
00204 
00211     XrlCmdError mfea_0_1_have_multicast_routing4(
00212     // Output values, 
00213     bool&   result);
00214 
00215 #ifdef HAVE_IPV6
00216 
00222     XrlCmdError mfea_0_1_have_multicast_routing6(
00223     // Output values, 
00224     bool&   result);
00225 #endif
00226 
00242     XrlCmdError mfea_0_1_register_protocol4(
00243     // Input values,
00244     const string&   xrl_sender_name,
00245     const string&   if_name,
00246     const string&   vif_name,
00247     const uint32_t& ip_protocol);
00248 
00249 #ifdef HAVE_IPV6
00250     XrlCmdError mfea_0_1_register_protocol6(
00251     // Input values,
00252     const string&   xrl_sender_name,
00253     const string&   if_name,
00254     const string&   vif_name,
00255     const uint32_t& ip_protocol);
00256 
00257     XrlCmdError mfea_0_1_unregister_protocol6(
00258     // Input values,
00259     const string&   xrl_sender_name,
00260     const string&   if_name,
00261     const string&   vif_name);
00262 
00263     XrlCmdError mfea_0_1_add_mfc6(
00264     // Input values, 
00265     const string&   xrl_sender_name, 
00266     const IPv6& source_address, 
00267     const IPv6& group_address, 
00268     const uint32_t& iif_vif_index, 
00269     const vector<uint8_t>&  oiflist, 
00270     const vector<uint8_t>&  oiflist_disable_wrongvif, 
00271     const uint32_t& max_vifs_oiflist, 
00272     const IPv6& rp_address);
00273 
00274     XrlCmdError mfea_0_1_delete_mfc6(
00275     // Input values, 
00276     const string&   xrl_sender_name, 
00277     const IPv6& source_address, 
00278     const IPv6& group_address);
00279 
00280     XrlCmdError mfea_0_1_add_dataflow_monitor6(
00281     // Input values, 
00282     const string&   xrl_sender_name, 
00283     const IPv6& source_address, 
00284     const IPv6& group_address, 
00285     const uint32_t& threshold_interval_sec, 
00286     const uint32_t& threshold_interval_usec, 
00287     const uint32_t& threshold_packets, 
00288     const uint32_t& threshold_bytes, 
00289     const bool& is_threshold_in_packets, 
00290     const bool& is_threshold_in_bytes, 
00291     const bool& is_geq_upcall, 
00292     const bool& is_leq_upcall);
00293 
00294     XrlCmdError mfea_0_1_delete_dataflow_monitor6(
00295     // Input values, 
00296     const string&   xrl_sender_name, 
00297     const IPv6& source_address, 
00298     const IPv6& group_address, 
00299     const uint32_t& threshold_interval_sec, 
00300     const uint32_t& threshold_interval_usec, 
00301     const uint32_t& threshold_packets, 
00302     const uint32_t& threshold_bytes, 
00303     const bool& is_threshold_in_packets, 
00304     const bool& is_threshold_in_bytes, 
00305     const bool& is_geq_upcall, 
00306     const bool& is_leq_upcall);
00307 
00308     XrlCmdError mfea_0_1_delete_all_dataflow_monitor6(
00309     // Input values, 
00310     const string&   xrl_sender_name, 
00311     const IPv6& source_address, 
00312     const IPv6& group_address);
00313 
00314 #endif //ipv6
00315 
00328     XrlCmdError mfea_0_1_unregister_protocol4(
00329     // Input values,
00330     const string&   xrl_sender_name,
00331     const string&   if_name,
00332     const string&   vif_name);
00333 
00356     XrlCmdError mfea_0_1_add_mfc4(
00357     // Input values, 
00358     const string&   xrl_sender_name, 
00359     const IPv4& source_address, 
00360     const IPv4& group_address, 
00361     const uint32_t& iif_vif_index, 
00362     const vector<uint8_t>&  oiflist, 
00363     const vector<uint8_t>&  oiflist_disable_wrongvif, 
00364     const uint32_t& max_vifs_oiflist, 
00365     const IPv4& rp_address);
00366 
00367     XrlCmdError mfea_0_1_delete_mfc4(
00368     // Input values, 
00369     const string&   xrl_sender_name, 
00370     const IPv4& source_address, 
00371     const IPv4& group_address);
00372 
00404     XrlCmdError mfea_0_1_add_dataflow_monitor4(
00405     // Input values, 
00406     const string&   xrl_sender_name, 
00407     const IPv4& source_address, 
00408     const IPv4& group_address, 
00409     const uint32_t& threshold_interval_sec, 
00410     const uint32_t& threshold_interval_usec, 
00411     const uint32_t& threshold_packets, 
00412     const uint32_t& threshold_bytes, 
00413     const bool& is_threshold_in_packets, 
00414     const bool& is_threshold_in_bytes, 
00415     const bool& is_geq_upcall, 
00416     const bool& is_leq_upcall);
00417 
00418     XrlCmdError mfea_0_1_delete_dataflow_monitor4(
00419     // Input values, 
00420     const string&   xrl_sender_name, 
00421     const IPv4& source_address, 
00422     const IPv4& group_address, 
00423     const uint32_t& threshold_interval_sec, 
00424     const uint32_t& threshold_interval_usec, 
00425     const uint32_t& threshold_packets, 
00426     const uint32_t& threshold_bytes, 
00427     const bool& is_threshold_in_packets, 
00428     const bool& is_threshold_in_bytes, 
00429     const bool& is_geq_upcall, 
00430     const bool& is_leq_upcall);
00431 
00432     XrlCmdError mfea_0_1_delete_all_dataflow_monitor4(
00433     // Input values, 
00434     const string&   xrl_sender_name, 
00435     const IPv4& source_address, 
00436     const IPv4& group_address);
00437 
00445     XrlCmdError mfea_0_1_enable_vif(
00446     // Input values,
00447     const string&   vif_name,
00448     const bool& enable);
00449 
00450     XrlCmdError mfea_0_1_start_vif(
00451     // Input values, 
00452     const string&   vif_name);
00453 
00454     XrlCmdError mfea_0_1_stop_vif(
00455     // Input values, 
00456     const string&   vif_name);
00457 
00463     XrlCmdError mfea_0_1_enable_all_vifs(
00464     // Input values,
00465     const bool& enable);
00466 
00467     XrlCmdError mfea_0_1_start_all_vifs();
00468 
00469     XrlCmdError mfea_0_1_stop_all_vifs();
00470 
00476     XrlCmdError mfea_0_1_enable_mfea(
00477     // Input values,
00478     const bool& enable);
00479 
00480     XrlCmdError mfea_0_1_start_mfea();
00481 
00482     XrlCmdError mfea_0_1_stop_mfea();
00483 
00490     XrlCmdError mfea_0_1_enable_cli(
00491     // Input values,
00492     const bool& enable);
00493 
00494     XrlCmdError mfea_0_1_start_cli();
00495 
00496     XrlCmdError mfea_0_1_stop_cli();
00497 
00503     XrlCmdError mfea_0_1_log_trace_all(
00504     // Input values,
00505     const bool& enable);
00506 
00507 private:
00513     virtual void finder_connect_event();
00514 
00520     virtual void finder_disconnect_event();
00521 
00522     //
00523     // Protocol node methods
00524     //
00525     int signal_message_send(const string& dst_module_instance_name,
00526                 int message_type,
00527                 uint32_t vif_index,
00528                 const IPvX& src, const IPvX& dst,
00529                 const uint8_t *rcvbuf, size_t rcvlen);
00530     //
00531     // XXX: mfea_client_client_send_recv_kernel_signal_message_cb() in fact
00532     // is the callback when signal_message_send() calls
00533     // send_recv_kernel_signal_message()
00534     // so the destination protocol will receive a kernel message.
00535     // Sigh, the 'recv' part in the name is rather confusing, but that
00536     // is in the name of consistency between the XRL calling function
00537     // and the return result callback...
00538     //
00539     void mfea_client_client_send_recv_kernel_signal_message_cb(const XrlError& xrl_error);
00540 
00541     int dataflow_signal_send(const string& dst_module_instance_name,
00542                  const IPvX& source_addr,
00543                  const IPvX& group_addr,
00544                  uint32_t threshold_interval_sec,
00545                  uint32_t threshold_interval_usec,
00546                  uint32_t measured_interval_sec,
00547                  uint32_t measured_interval_usec,
00548                  uint32_t threshold_packets,
00549                  uint32_t threshold_bytes,
00550                  uint32_t measured_packets,
00551                  uint32_t measured_bytes,
00552                  bool is_threshold_in_packets,
00553                  bool is_threshold_in_bytes,
00554                  bool is_geq_upcall,
00555                  bool is_leq_upcall);
00556     
00557     void mfea_client_client_send_recv_dataflow_signal_cb(const XrlError& xrl_error);
00558 
00559     //
00560     // Protocol node CLI methods
00561     //
00562     int add_cli_command_to_cli_manager(const char *command_name,
00563                        const char *command_help,
00564                        bool is_command_cd,
00565                        const char *command_cd_prompt,
00566                        bool is_command_processor);
00567     void cli_manager_client_send_add_cli_command_cb(const XrlError& xrl_error);
00568     int delete_cli_command_from_cli_manager(const char *command_name);
00569     void cli_manager_client_send_delete_cli_command_cb(const XrlError& xrl_error);
00570     
00571     int family() const { return (MfeaNode::family()); }
00572 
00573     EventLoop&          _eventloop;
00574     const string        _finder_target;
00575 
00576     XrlMfeaClientV0p1Client _xrl_mfea_client_client;
00577     XrlCliManagerV0p1Client _xrl_cli_manager_client;
00578     XrlFinderEventNotifierV0p1Client    _xrl_finder_client;
00579 
00580     LibFeaClientBridge      _lib_mfea_client_bridge;    // The MFEA clients
00581 
00582     bool            _is_finder_alive;
00583 };
00584 
00585 #endif // __FEA_XRL_MFEA_NODE_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations