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 // $XORP: xorp/contrib/mld6igmp_lite/mld6igmp_node.hh,v 1.3 2008/10/02 21:56:32 bms Exp $
00021 
00022 #ifndef __MLD6IGMP_MLD6IGMP_NODE_HH__
00023 #define __MLD6IGMP_MLD6IGMP_NODE_HH__
00024 
00025 
00026 //
00027 // IGMP and MLD node definition.
00028 //
00029 
00030 
00031 
00032 
00033 #include "libxorp/vif.hh"
00034 #include "libproto/proto_node.hh"
00035 #include "libfeaclient/ifmgr_xrl_mirror.hh"
00036 #include "mrt/buffer.h"
00037 #include "mrt/multicast_defs.h"
00038 
00039 
00040 //
00041 // Constants definitions
00042 //
00043 
00044 
00045 //
00046 // Structures/classes, typedefs and macros
00047 //
00048 
00049 class EventLoop;
00050 class IPvX;
00051 class IPvXNet;
00052 class Mld6igmpVif;
00053 
00060 class Mld6igmpNode : public ProtoNode<Mld6igmpVif>,
00061              public IfMgrHintObserver,
00062              public ServiceChangeObserverBase {
00063 public:
00073     Mld6igmpNode(int family, xorp_module_id module_id, EventLoop& eventloop);
00074     
00078     virtual ~Mld6igmpNode();
00079     
00090     int     start();
00091     
00102     int     stop();
00103 
00112     int     final_start();
00113 
00122     int     final_stop();
00123     
00129     void    enable();
00130     
00137     void    disable();
00138 
00144     uint8_t ip_protocol_number() const;
00145 
00153     int     add_vif(const Vif& vif, string& error_msg);
00154     
00163     int     add_vif(const string& vif_name, uint32_t vif_index,
00164             string& error_msg);
00165     
00173     int     delete_vif(const string& vif_name, string& error_msg);
00174     
00189     int     set_vif_flags(const string& vif_name,
00190                   bool is_pim_register, bool is_p2p,
00191                   bool is_loopback, bool is_multicast,
00192                   bool is_broadcast, bool is_up, uint32_t mtu,
00193                   string& error_msg);
00194     
00206     int     add_vif_addr(const string& vif_name,
00207                  const IPvX& addr,
00208                  const IPvXNet& subnet_addr,
00209                  const IPvX& broadcast_addr,
00210                  const IPvX& peer_addr,
00211                  string& error_msg);
00212     
00221     int     delete_vif_addr(const string& vif_name,
00222                 const IPvX& addr,
00223                 string& error_msg);
00224     
00232     int     enable_vif(const string& vif_name, string& error_msg);
00233 
00241     int     disable_vif(const string& vif_name, string& error_msg);
00242 
00250     int     start_vif(const string& vif_name, string& error_msg);
00251     
00259     int     stop_vif(const string& vif_name, string& error_msg);
00260     
00266     int     start_all_vifs();
00267     
00273     int     stop_all_vifs();
00274     
00280     int     enable_all_vifs();
00281     
00287     int     disable_all_vifs();
00288     
00292     void    delete_all_vifs();
00293 
00299     void    vif_shutdown_completed(const string& vif_name);
00300 
00320     int     proto_recv(const string& if_name,
00321                const string& vif_name,
00322                const IPvX& src_address,
00323                const IPvX& dst_address,
00324                uint8_t ip_protocol,
00325                int32_t ip_ttl,
00326                int32_t ip_tos,
00327                bool ip_router_alert,
00328                bool ip_internet_control,
00329                const vector<uint8_t>& payload,
00330                string& error_msg);
00331     
00355     int     mld6igmp_send(const string& if_name,
00356                   const string& vif_name,
00357                   const IPvX& src_address,
00358                   const IPvX& dst_address,
00359                   uint8_t ip_protocol,
00360                   int32_t ip_ttl,
00361                   int32_t ip_tos,
00362                   bool ip_router_alert,
00363                   bool ip_internet_control,
00364                   buffer_t *buffer,
00365                   string& error_msg);
00366     
00370     int signal_message_recv(const string&   , // src_module_instance_name,
00371                 int         , // message_type,
00372                 uint32_t        , // vif_index,
00373                 const IPvX&     , // src,
00374                 const IPvX&     , // dst,
00375                 const uint8_t * , // rcvbuf,
00376                 size_t        // rcvlen
00377     ) { XLOG_UNREACHABLE(); return (XORP_ERROR); }
00378     
00382     int signal_message_send(const string&   , // dst_module_instance_name,
00383                 int         , // message_type,
00384                 uint32_t        , // vif_index,
00385                 const IPvX&     , // src,
00386                 const IPvX&     , // dst,
00387                 const uint8_t * , // sndbuf,
00388                 size_t        // sndlen
00389     ) { XLOG_UNREACHABLE(); return (XORP_ERROR); }
00390     
00407     virtual int register_receiver(const string& if_name,
00408                   const string& vif_name,
00409                   uint8_t ip_protocol,
00410                   bool enable_multicast_loopback) = 0;
00411 
00426     virtual int unregister_receiver(const string& if_name,
00427                     const string& vif_name,
00428                     uint8_t ip_protocol) = 0;
00429 
00445     virtual int join_multicast_group(const string& if_name,
00446                      const string& vif_name,
00447                      uint8_t ip_protocol,
00448                      const IPvX& group_address) = 0;
00464     virtual int leave_multicast_group(const string& if_name,
00465                       const string& vif_name,
00466                       uint8_t ip_protocol,
00467                       const IPvX& group_address) = 0;
00468 
00483     int add_protocol(const string& module_instance_name,
00484              xorp_module_id module_id,
00485              uint32_t vif_index);
00486     
00502     int delete_protocol(const string& module_instance_name,
00503             xorp_module_id module_id,
00504             uint32_t vif_index);
00505     
00523     virtual int send_add_membership(const string& dst_module_instance_name,
00524                     xorp_module_id dst_module_id,
00525                     uint32_t vif_index,
00526                     const IPvX& source,
00527                     const IPvX& group) = 0;
00546     virtual int send_delete_membership(const string& dst_module_instance_name,
00547                        xorp_module_id dst_module_id,
00548                        uint32_t vif_index,
00549                        const IPvX& source,
00550                        const IPvX& group) = 0;
00551     
00568     int join_prune_notify_routing(const string& module_instance_name,
00569                   xorp_module_id module_id,
00570                   uint32_t vif_index,
00571                   const IPvX& source,
00572                   const IPvX& group,
00573                   action_jp_t action_jp);
00574 
00587     bool is_directly_connected(const Mld6igmpVif& mld6igmp_vif,
00588                    const IPvX& ipaddr_test) const;
00589 
00590     //
00591     // Configuration methods
00592     //
00593 
00600     int     set_config_all_vifs_done(string& error_msg);
00601 
00610     int     get_vif_proto_version(const string& vif_name,
00611                       int& proto_version,
00612                       string& error_msg);
00613     
00622     int     set_vif_proto_version(const string& vif_name,
00623                       int proto_version,
00624                       string& error_msg);
00625     
00634     int     reset_vif_proto_version(const string& vif_name,
00635                     string& error_msg);
00636 
00646     int     get_vif_ip_router_alert_option_check(const string& vif_name,
00647                              bool& enabled,
00648                              string& error_msg);
00649     
00660     int     set_vif_ip_router_alert_option_check(const string& vif_name,
00661                              bool enable,
00662                              string& error_msg);
00663     
00672     int     reset_vif_ip_router_alert_option_check(const string& vif_name,
00673                                string& error_msg);
00674 
00683     int     get_vif_query_interval(const string& vif_name,
00684                        TimeVal& interval,
00685                        string& error_msg);
00686     
00695     int     set_vif_query_interval(const string& vif_name,
00696                        const TimeVal& interval,
00697                        string& error_msg);
00698     
00706     int     reset_vif_query_interval(const string& vif_name,
00707                      string& error_msg);
00708 
00717     int     get_vif_query_last_member_interval(const string& vif_name,
00718                            TimeVal& interval,
00719                            string& error_msg);
00720     
00729     int     set_vif_query_last_member_interval(const string& vif_name,
00730                            const TimeVal& interval,
00731                            string& error_msg);
00732     
00740     int     reset_vif_query_last_member_interval(const string& vif_name,
00741                              string& error_msg);
00742 
00751     int     get_vif_query_response_interval(const string& vif_name,
00752                         TimeVal& interval,
00753                         string& error_msg);
00754     
00763     int     set_vif_query_response_interval(const string& vif_name,
00764                         const TimeVal& interval,
00765                         string& error_msg);
00766     
00774     int     reset_vif_query_response_interval(const string& vif_name,
00775                           string& error_msg);
00776 
00785     int     get_vif_robust_count(const string& vif_name,
00786                      uint32_t& robust_count,
00787                      string& error_msg);
00788     
00797     int     set_vif_robust_count(const string& vif_name,
00798                      uint32_t robust_count,
00799                      string& error_msg);
00800     
00808     int     reset_vif_robust_count(const string& vif_name,
00809                        string& error_msg);
00810     
00811     //
00812     // Debug-related methods
00813     //
00814     
00822     bool    is_log_trace() const { return (_is_log_trace); }
00823     
00831     void    set_log_trace(bool is_enabled) { _is_log_trace = is_enabled; }
00832 
00833 protected:
00834     //
00835     // IfMgrHintObserver methods
00836     //
00837     void tree_complete();
00838     void updates_made();
00839 
00840 private:
00848     void status_change(ServiceBase*  service,
00849                ServiceStatus old_status,
00850                ServiceStatus new_status);
00851 
00860     virtual const ServiceBase* ifmgr_mirror_service_base() const = 0;
00861 
00870     virtual const IfMgrIfTree&  ifmgr_iftree() const = 0;
00871 
00878     virtual void fea_register_startup() = 0;
00879 
00886     virtual void mfea_register_startup() = 0;
00887 
00894     virtual void fea_register_shutdown() = 0;
00895 
00902     virtual void mfea_register_shutdown() = 0;
00903 
00904     buffer_t    *_buffer_recv;      // Buffer for receiving messages
00905     
00906     //
00907     // Status-related state
00908     //
00909     size_t  _waiting_for_mfea_startup_events;
00910 
00911     //
00912     // A local copy with the interface state information
00913     //
00914     IfMgrIfTree _iftree;
00915     
00916     //
00917     // Debug and test-related state
00918     //
00919     bool    _is_log_trace;      // If true, enable XLOG_TRACE()
00920 };
00921 
00922 
00923 //
00924 // Global variables
00925 //
00926 
00927 
00928 //
00929 // Global functions prototypes
00930 //
00931 
00932 #endif // __MLD6IGMP_MLD6IGMP_NODE_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations