xorp

mld6igmp_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 
00021 #ifndef __MLD6IGMP_MLD6IGMP_NODE_HH__
00022 #define __MLD6IGMP_MLD6IGMP_NODE_HH__
00023 
00024 
00025 //
00026 // IGMP and MLD node definition.
00027 //
00028 
00029 #include "libxorp/vif.hh"
00030 #include "libproto/proto_node.hh"
00031 #include "libfeaclient/ifmgr_xrl_mirror.hh"
00032 #include "mrt/buffer.h"
00033 #include "mrt/multicast_defs.h"
00034 
00035 
00036 class EventLoop;
00037 class IPvX;
00038 class IPvXNet;
00039 class Mld6igmpVif;
00040 
00047 class Mld6igmpNode : public ProtoNode<Mld6igmpVif>,
00048              public IfMgrHintObserver,
00049              public ServiceChangeObserverBase {
00050 public:
00060     Mld6igmpNode(int family, xorp_module_id module_id, EventLoop& eventloop);
00061     
00065     virtual ~Mld6igmpNode();
00066     
00077     int     start();
00078     
00089     int     stop();
00090 
00099     int     final_start();
00100 
00109     int     final_stop();
00110     
00116     void    enable();
00117     
00124     void    disable();
00125 
00131     uint8_t ip_protocol_number() const;
00132 
00140     int     add_vif(const Vif& vif, string& error_msg);
00141     
00150     int     add_vif(const string& vif_name, uint32_t vif_index,
00151             string& error_msg);
00152     
00160     int     delete_vif(const string& vif_name, string& error_msg);
00161     
00176     int     set_vif_flags(const string& vif_name,
00177                   bool is_pim_register, bool is_p2p,
00178                   bool is_loopback, bool is_multicast,
00179                   bool is_broadcast, bool is_up, uint32_t mtu,
00180                   string& error_msg);
00181     
00193     int     add_vif_addr(const string& vif_name,
00194                  const IPvX& addr,
00195                  const IPvXNet& subnet_addr,
00196                  const IPvX& broadcast_addr,
00197                  const IPvX& peer_addr,
00198                  string& error_msg);
00199     
00208     int     delete_vif_addr(const string& vif_name,
00209                 const IPvX& addr,
00210                 string& error_msg);
00211     
00219     int     enable_vif(const string& vif_name, string& error_msg);
00220 
00228     int     disable_vif(const string& vif_name, string& error_msg);
00229 
00237     int     start_vif(const string& vif_name, string& error_msg);
00238     
00246     int     stop_vif(const string& vif_name, string& error_msg);
00247     
00253     int     start_all_vifs();
00254     
00260     int     stop_all_vifs();
00261     
00267     int     enable_all_vifs();
00268     
00274     int     disable_all_vifs();
00275     
00279     void    delete_all_vifs();
00280 
00286     void    vif_shutdown_completed(const string& vif_name);
00287 
00307     int     proto_recv(const string& if_name,
00308                const string& vif_name,
00309                const IPvX& src_address,
00310                const IPvX& dst_address,
00311                uint8_t ip_protocol,
00312                int32_t ip_ttl,
00313                int32_t ip_tos,
00314                bool ip_router_alert,
00315                bool ip_internet_control,
00316                const vector<uint8_t>& payload,
00317                string& error_msg);
00318     
00342     int     mld6igmp_send(const string& if_name,
00343                   const string& vif_name,
00344                   const IPvX& src_address,
00345                   const IPvX& dst_address,
00346                   uint8_t ip_protocol,
00347                   int32_t ip_ttl,
00348                   int32_t ip_tos,
00349                   bool ip_router_alert,
00350                   bool ip_internet_control,
00351                   buffer_t *buffer,
00352                   string& error_msg);
00353     
00357     int signal_message_recv(const string&   , // src_module_instance_name,
00358                 int         , // message_type,
00359                 uint32_t        , // vif_index,
00360                 const IPvX&     , // src,
00361                 const IPvX&     , // dst,
00362                 const uint8_t * , // rcvbuf,
00363                 size_t        // rcvlen
00364     ) { XLOG_UNREACHABLE(); return (XORP_ERROR); }
00365     
00369     int signal_message_send(const string&   , // dst_module_instance_name,
00370                 int         , // message_type,
00371                 uint32_t        , // vif_index,
00372                 const IPvX&     , // src,
00373                 const IPvX&     , // dst,
00374                 const uint8_t * , // sndbuf,
00375                 size_t        // sndlen
00376     ) { XLOG_UNREACHABLE(); return (XORP_ERROR); }
00377 
00394     virtual int register_receiver(const string& if_name,
00395                   const string& vif_name,
00396                   uint8_t ip_protocol,
00397                   bool enable_multicast_loopback) = 0;
00398 
00413     virtual int unregister_receiver(const string& if_name,
00414                     const string& vif_name,
00415                     uint8_t ip_protocol) = 0;
00416 
00432     virtual int join_multicast_group(const string& if_name,
00433                      const string& vif_name,
00434                      uint8_t ip_protocol,
00435                      const IPvX& group_address) = 0;
00451     virtual int leave_multicast_group(const string& if_name,
00452                       const string& vif_name,
00453                       uint8_t ip_protocol,
00454                       const IPvX& group_address) = 0;
00455 
00470     int add_protocol(const string& module_instance_name,
00471              xorp_module_id module_id,
00472              uint32_t vif_index);
00473     
00489     int delete_protocol(const string& module_instance_name,
00490             xorp_module_id module_id,
00491             uint32_t vif_index, string& error_msg);
00492     
00510     virtual int send_add_membership(const string& dst_module_instance_name,
00511                     xorp_module_id dst_module_id,
00512                     uint32_t vif_index,
00513                     const IPvX& source,
00514                     const IPvX& group) = 0;
00533     virtual int send_delete_membership(const string& dst_module_instance_name,
00534                        xorp_module_id dst_module_id,
00535                        uint32_t vif_index,
00536                        const IPvX& source,
00537                        const IPvX& group) = 0;
00538     
00555     int join_prune_notify_routing(const string& module_instance_name,
00556                   xorp_module_id module_id,
00557                   uint32_t vif_index,
00558                   const IPvX& source,
00559                   const IPvX& group,
00560                   action_jp_t action_jp);
00561 
00574     bool is_directly_connected(const Mld6igmpVif& mld6igmp_vif,
00575                    const IPvX& ipaddr_test) const;
00576 
00577     //
00578     // Configuration methods
00579     //
00580 
00587     int     set_config_all_vifs_done(string& error_msg);
00588 
00597     int     get_vif_proto_version(const string& vif_name,
00598                       int& proto_version,
00599                       string& error_msg);
00600     
00609     int     set_vif_proto_version(const string& vif_name,
00610                       int proto_version,
00611                       string& error_msg);
00612     
00621     int     reset_vif_proto_version(const string& vif_name,
00622                     string& error_msg);
00623 
00633     int     get_vif_ip_router_alert_option_check(const string& vif_name,
00634                              bool& enabled,
00635                              string& error_msg);
00636     
00647     int     set_vif_ip_router_alert_option_check(const string& vif_name,
00648                              bool enable,
00649                              string& error_msg);
00650     
00659     int     reset_vif_ip_router_alert_option_check(const string& vif_name,
00660                                string& error_msg);
00661 
00670     int     get_vif_query_interval(const string& vif_name,
00671                        TimeVal& interval,
00672                        string& error_msg);
00673     
00682     int     set_vif_query_interval(const string& vif_name,
00683                        const TimeVal& interval,
00684                        string& error_msg);
00685     
00693     int     reset_vif_query_interval(const string& vif_name,
00694                      string& error_msg);
00695 
00704     int     get_vif_query_last_member_interval(const string& vif_name,
00705                            TimeVal& interval,
00706                            string& error_msg);
00707     
00716     int     set_vif_query_last_member_interval(const string& vif_name,
00717                            const TimeVal& interval,
00718                            string& error_msg);
00719     
00727     int     reset_vif_query_last_member_interval(const string& vif_name,
00728                              string& error_msg);
00729 
00738     int     get_vif_query_response_interval(const string& vif_name,
00739                         TimeVal& interval,
00740                         string& error_msg);
00741     
00750     int     set_vif_query_response_interval(const string& vif_name,
00751                         const TimeVal& interval,
00752                         string& error_msg);
00753     
00761     int     reset_vif_query_response_interval(const string& vif_name,
00762                           string& error_msg);
00763 
00772     int     get_vif_robust_count(const string& vif_name,
00773                      uint32_t& robust_count,
00774                      string& error_msg);
00775     
00784     int     set_vif_robust_count(const string& vif_name,
00785                      uint32_t robust_count,
00786                      string& error_msg);
00787     
00795     int     reset_vif_robust_count(const string& vif_name,
00796                        string& error_msg);
00797     
00798     //
00799     // Debug-related methods
00800     //
00801     
00809     bool    is_log_trace() const { return (_is_log_trace); }
00810     
00818     void    set_log_trace(bool is_enabled) { _is_log_trace = is_enabled; }
00819 
00820 protected:
00821     //
00822     // IfMgrHintObserver methods
00823     //
00824     void tree_complete();
00825     void updates_made();
00826 
00827 private:
00835     void status_change(ServiceBase*  service,
00836                ServiceStatus old_status,
00837                ServiceStatus new_status);
00838 
00847     virtual const ServiceBase* ifmgr_mirror_service_base() const = 0;
00848 
00857     virtual const IfMgrIfTree&  ifmgr_iftree() const = 0;
00858 
00865     virtual void fea_register_startup() = 0;
00866 
00873     virtual void mfea_register_startup() = 0;
00874 
00881     virtual void fea_register_shutdown() = 0;
00882 
00889     virtual void mfea_register_shutdown() = 0;
00890 
00891     buffer_t    *_buffer_recv;      // Buffer for receiving messages
00892     
00893     //
00894     // Status-related state
00895     //
00896     size_t  _waiting_for_mfea_startup_events;
00897 
00898     //
00899     // A local copy with the interface state information
00900     //
00901     IfMgrIfTree _iftree;
00902     
00903     //
00904     // Debug and test-related state
00905     //
00906     bool    _is_log_trace;      // If true, enable XLOG_TRACE()
00907 };
00908 
00909 
00910 //
00911 // Global variables
00912 //
00913 
00914 
00915 //
00916 // Global functions prototypes
00917 //
00918 
00919 #endif // __MLD6IGMP_MLD6IGMP_NODE_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations