xorp

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 // $XORP: xorp/fea/mfea_node.hh,v 1.51 2008/10/02 21:56:49 bms Exp $
00021 
00022 
00023 #ifndef __FEA_MFEA_NODE_HH__
00024 #define __FEA_MFEA_NODE_HH__
00025 
00026 
00027 //
00028 // MFEA (Multicast Forwarding Engine Abstraction) node definition.
00029 //
00030 
00031 #include "libxorp/ipvx.hh"
00032 #include "libxorp/config_param.hh"
00033 #include "libproto/proto_node.hh"
00034 #include "mrt/mifset.hh"
00035 #include "ifconfig_reporter.hh"
00036 #include "iftree.hh"
00037 #include "mfea_dataflow.hh"
00038 #include "mfea_mrouter.hh"
00039 
00040 
00041 //
00042 // Structures/classes, typedefs and macros
00043 //
00044 
00045 class EventLoop;
00046 class FeaNode;
00047 class MfeaVif;
00048 class SgCount;
00049 class VifCount;
00050 
00057 class MfeaNode : public ProtoNode<MfeaVif>,
00058          public IfConfigUpdateReporterBase,
00059          public ServiceChangeObserverBase {
00060 public:
00071     MfeaNode(FeaNode& fea_node, int family, xorp_module_id module_id,
00072          EventLoop& eventloop);
00073     
00077     virtual ~MfeaNode();
00078 
00084     FeaNode&    fea_node() { return (_fea_node); }
00085 
00091     bool    is_dummy() const;
00092 
00102     int     start();
00103 
00113     int     stop();
00114 
00123     int     final_start();
00124 
00133     int     final_stop();
00134 
00140     void    enable();
00141     
00148     void    disable();
00149 
00156     bool have_multicast_routing4() const {
00157     return (_mfea_mrouter.have_multicast_routing4());
00158     }
00159     
00160 #ifdef HAVE_IPV6
00161 
00167     bool have_multicast_routing6() const {
00168     return (_mfea_mrouter.have_multicast_routing6());
00169     }
00170 #endif
00171     
00179     int     add_vif(const Vif& vif, string& error_msg);
00180     
00188     int     delete_vif(const string& vif_name, string& error_msg);
00189     
00197     int add_config_vif(const Vif& vif, string& error_msg);
00198 
00213     int     set_config_vif_flags(const string& vif_name,
00214                      bool is_pim_register,
00215                      bool is_p2p,
00216                      bool is_loopback,
00217                      bool is_multicast,
00218                      bool is_broadcast,
00219                      bool is_up,
00220                      uint32_t mtu,
00221                      string& error_msg);
00222     
00229     int     set_config_all_vifs_done(string& error_msg);
00230     
00238     int     enable_vif(const string& vif_name, string& error_msg);
00239 
00247     int     disable_vif(const string& vif_name, string& error_msg);
00248 
00256     int     start_vif(const string& vif_name, string& error_msg);
00257     
00265     int     stop_vif(const string& vif_name, string& error_msg);
00266     
00272     int     start_all_vifs();
00273     
00279     int     stop_all_vifs();
00280     
00286     int     enable_all_vifs();
00287     
00295     int     disable_all_vifs();
00296     
00300     void    delete_all_vifs();
00301 
00307     void    vif_shutdown_completed(const string& vif_name);
00308 
00325     int register_protocol(const string&     module_instance_name,
00326               const string&     if_name,
00327               const string&     vif_name,
00328               uint8_t       ip_protocol,
00329               string&       error_msg);
00330 
00331 
00336     void unregister_protocols_for_iface(const string& ifname);
00337 
00342     void unregister_protocols_for_vif(const string& ifname, const string& vifname);
00343 
00358     int unregister_protocol(const string&   module_instance_name,
00359                 const string&   if_name,
00360                 const string&   vif_name,
00361                 string&     error_msg);
00362 
00366     int proto_recv(const string&    , // if_name,
00367            const string&    , // vif_name,
00368            const IPvX&      , // src_address,
00369            const IPvX&      , // dst_address,
00370            uint8_t      , // ip_protocol,
00371            int32_t      , // ip_ttl,
00372            int32_t      , // ip_tos,
00373            bool         , // ip_router_alert,
00374            bool         , // ip_internet_control,
00375            const vector<uint8_t>& , // payload,
00376            string&      // error_msg
00377     ) { assert (false); return (XORP_ERROR); }
00378 
00382     int proto_send(const string&    , // if_name,
00383            const string&    , // vif_name,
00384            const IPvX&      , // src_address,
00385            const IPvX&      , // dst_address,
00386            uint8_t      , // ip_protocol,
00387            int32_t      , // ip_ttl,
00388            int32_t      , // ip_tos,
00389            bool         , // ip_router_alert,
00390            bool         , // ip_internet_control,
00391            const uint8_t*   , // sndbuf,
00392            size_t       , // sndlen,
00393            string&        // error_msg
00394     ) { assert (false); return (XORP_ERROR); }
00395 
00427     int     signal_message_recv(const string& src_module_instance_name,
00428                     int message_type,
00429                     uint32_t vif_index,
00430                     const IPvX& src,
00431                     const IPvX& dst,
00432                     const uint8_t *rcvbuf,
00433                     size_t rcvlen);
00434     
00478     int signal_dataflow_message_recv(const IPvX& source,
00479                      const IPvX& group,
00480                      const TimeVal& threshold_interval,
00481                      const TimeVal& measured_interval,
00482                      uint32_t threshold_packets,
00483                      uint32_t threshold_bytes,
00484                      uint32_t measured_packets,
00485                      uint32_t measured_bytes,
00486                      bool is_threshold_in_packets,
00487                      bool is_threshold_in_bytes,
00488                      bool is_geq_upcall,
00489                      bool is_leq_upcall);
00490     
00543     virtual int dataflow_signal_send(const string& dst_module_instance_name,
00544                      const IPvX& source_addr,
00545                      const IPvX& group_addr,
00546                      uint32_t threshold_interval_sec,
00547                      uint32_t threshold_interval_usec,
00548                      uint32_t measured_interval_sec,
00549                      uint32_t measured_interval_usec,
00550                      uint32_t threshold_packets,
00551                      uint32_t threshold_bytes,
00552                      uint32_t measured_packets,
00553                      uint32_t measured_bytes,
00554                      bool is_threshold_in_packets,
00555                      bool is_threshold_in_bytes,
00556                      bool is_geq_upcall,
00557                      bool is_leq_upcall) = 0;
00558     
00583     int     add_mfc(const string& module_instance_name,
00584             const IPvX& source, const IPvX& group,
00585             uint32_t iif_vif_index, const Mifset& oiflist,
00586             const Mifset& oiflist_disable_wrongvif,
00587             uint32_t max_vifs_oiflist,
00588             const IPvX& rp_addr);
00589     
00604     int     delete_mfc(const string& module_instance_name,
00605                const IPvX& source, const IPvX& group);
00606     
00642     int     add_dataflow_monitor(const string& module_instance_name,
00643                      const IPvX& source, const IPvX& group,
00644                      const TimeVal& threshold_interval,
00645                      uint32_t threshold_packets,
00646                      uint32_t threshold_bytes,
00647                      bool is_threshold_in_packets,
00648                      bool is_threshold_in_bytes,
00649                      bool is_geq_upcall,
00650                      bool is_leq_upcall,
00651                      string& error_msg);
00652     
00688     int     delete_dataflow_monitor(const string& module_instance_name,
00689                     const IPvX& source, const IPvX& group,
00690                     const TimeVal& threshold_interval,
00691                     uint32_t threshold_packets,
00692                     uint32_t threshold_bytes,
00693                     bool is_threshold_in_packets,
00694                     bool is_threshold_in_bytes,
00695                     bool is_geq_upcall,
00696                     bool is_leq_upcall,
00697                     string& error_msg);
00698     
00714     int     delete_all_dataflow_monitor(const string& module_instance_name,
00715                         const IPvX& source,
00716                         const IPvX& group,
00717                         string& error_msg);
00718     
00725     int     add_multicast_vif(uint32_t vif_index);
00726     
00733     int     delete_multicast_vif(uint32_t vif_index);
00734     
00749     int     get_sg_count(const IPvX& source, const IPvX& group,
00750                  SgCount& sg_count);
00751     
00764     int     get_vif_count(uint32_t vif_index, VifCount& vif_count);
00765     
00771     MfeaMrouter& mfea_mrouter() { return (_mfea_mrouter); }
00772     
00778     MfeaDft&    mfea_dft() { return (_mfea_dft); }
00779     
00787     bool    is_log_trace() const { return (_is_log_trace); }
00788 
00796     void    set_log_trace(bool is_enabled) { _is_log_trace = is_enabled; }
00797 
00798 protected:
00799     IfConfigUpdateReplicator&   mfea_iftree_update_replicator() {
00800     return (_mfea_iftree_update_replicator);
00801     }
00802 
00803 private:
00804     void interface_update(const string& ifname,
00805               const Update& update);
00806 
00807     void vif_update(const string& ifname,
00808             const string& vifname,
00809             const Update& update);
00810 
00811     void vifaddr4_update(const string& ifname,
00812              const string& vifname,
00813              const IPv4&   addr,
00814              const Update& update);
00815 
00816 #ifdef HAVE_IPV6
00817     void vifaddr6_update(const string& ifname,
00818              const string& vifname,
00819              const IPv6&   addr,
00820              const Update& update);
00821 #endif
00822 
00823     void updates_completed();
00824 
00832     void status_change(ServiceBase*  service,
00833                ServiceStatus old_status,
00834                ServiceStatus new_status);
00835 
00836     int add_pim_register_vif();
00837     
00838     // Private state
00839     FeaNode&        _fea_node;
00840 
00841     MfeaMrouter     _mfea_mrouter;  // The mrouter state
00842     MfeaDft     _mfea_dft;  // The dataflow monitoring table
00843     
00844     //
00845     // The state to register:
00846     //  - Protocol module instance names
00847     //  - IP protocol numbers
00848     set<string>     _registered_module_instance_names;
00849     set<uint8_t>    _registered_ip_protocols;
00850 
00851     //
00852     // Interface tree propagation
00853     //
00854     IfTree          _mfea_iftree;
00855     IfConfigUpdateReplicator    _mfea_iftree_update_replicator;
00856 
00857     //
00858     // Debug and test-related state
00859     //
00860     bool    _is_log_trace;      // If true, enable XLOG_TRACE()
00861 };
00862 
00863 #endif // __FEA_MFEA_NODE_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations