xorp

pim_mrt.hh

00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
00002 
00003 // Copyright (c) 2001-2011 XORP, Inc and Others-2009 XORP, Inc.
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 __PIM_PIM_MRT_HH__
00022 #define __PIM_PIM_MRT_HH__
00023 
00024 
00025 //
00026 // PIM Multicast Routing Table header file.
00027 //
00028 
00029 
00030 #include "libproto/proto_unit.hh"
00031 #include "mrt/mifset.hh"
00032 #include "mrt/mrt.hh"
00033 #include "pim_mre_track_state.hh"
00034 
00035 
00036 class IPvX;
00037 class PimMfc;
00038 class PimMre;
00039 class PimMreTask;
00040 class PimMrt;
00041 class PimNode;
00042 class PimVif;
00043 class PimMribTable;
00044 
00045 //
00046 // PIM-specific (S,G) Multicast Routing Table
00047 //
00048 class PimMrtSg : public Mrt<PimMre> {
00049 public:
00050     PimMrtSg(PimMrt& pim_mrt);
00051     virtual ~PimMrtSg();
00052     
00053     PimMrt& pim_mrt() const { return (_pim_mrt); }
00054     
00055 private:
00056     PimMrt& _pim_mrt;   // The PIM Multicast Routing Table
00057 };
00058 
00059 //
00060 // PIM-specific (*,G) Multicast Routing Table
00061 //
00062 class PimMrtG : public Mrt<PimMre> {
00063 public:
00064     PimMrtG(PimMrt& pim_mrt);
00065     virtual ~PimMrtG();
00066     
00067     PimMrt& pim_mrt() const { return (_pim_mrt); }
00068     
00069 private:
00070     PimMrt& _pim_mrt;   // The PIM Multicast Routing Table
00071 };
00072 
00073 //
00074 // PIM-specific (*,*,RP) Multicast Routing Table
00075 //
00076 class PimMrtRp : public Mrt<PimMre> {
00077 public:
00078     PimMrtRp(PimMrt& pim_mrt);
00079     virtual ~PimMrtRp();
00080     
00081     PimMrt& pim_mrt() const { return (_pim_mrt); }
00082     
00083 private:
00084     PimMrt& _pim_mrt;   // The PIM Multicast Routing Table
00085 };
00086 
00087 //
00088 // PIM-specific Multicast Forwarding Cache Table
00089 //
00090 class PimMrtMfc : public Mrt<PimMfc> {
00091 public:
00092     PimMrtMfc(PimMrt& pim_mrt);
00093     virtual ~PimMrtMfc();
00094     
00095     PimMrt& pim_mrt() const { return (_pim_mrt); }
00096     
00097 private:
00098     PimMrt& _pim_mrt;   // The PIM Multicast Routing Table
00099 };
00100 
00101 //
00102 // PIM-specific Multicast Routing Table
00103 //
00104 class PimMrt : public BugCatcher {
00105 public:
00106     PimMrt(PimNode* pim_node);
00107     virtual ~PimMrt();
00108     
00109     PimNode*    pim_node() const    { return (_pim_node);       }
00110     PimMrtSg&   pim_mrt_sg()        { return (_pim_mrt_sg);     }
00111     PimMrtSg&   pim_mrt_sg_rpt()    { return (_pim_mrt_sg_rpt); }
00112     PimMrtG&    pim_mrt_g()     { return (_pim_mrt_g);      }
00113     PimMrtRp&   pim_mrt_rp()        { return (_pim_mrt_rp);     }
00114     PimMrtMfc&  pim_mrt_mfc()       { return (_pim_mrt_mfc);    }
00115     
00116     void    clear();
00117     PimMre  *pim_mre_find(const IPvX& source, const IPvX& group,
00118                   uint32_t lookup_flags, uint32_t create_flags);
00119     PimMfc  *pim_mfc_find(const IPvX& source, const IPvX& group,
00120                   bool is_creation_allowed);
00121     int     remove_pim_mre(PimMre *pim_mre);
00122     int     remove_pim_mfc(PimMfc *pim_mfc);
00123     
00124     //
00125     // MFC-related methods
00126     //
00127     int signal_message_nocache_recv(const string& src_module_instance_name,
00128                     uint32_t vif_index,
00129                     const IPvX& src,
00130                     const IPvX& dst);
00131     int signal_message_wrongvif_recv(const string& src_module_instance_name,
00132                      uint32_t vif_index,
00133                      const IPvX& src,
00134                      const IPvX& dst);
00135     int signal_message_wholepkt_recv(const string& src_module_instance_name,
00136                      uint32_t vif_index,
00137                      const IPvX& src,
00138                      const IPvX& dst,
00139                      const uint8_t *rcvbuf,
00140                      size_t rcvlen);
00141     void receive_data(uint32_t iif_vif_index, const IPvX& src,
00142               const IPvX& dst);
00143     
00144     int signal_dataflow_recv(const IPvX& source_addr,
00145                  const IPvX& group_addr,
00146                  uint32_t threshold_interval_sec,
00147                  uint32_t threshold_interval_usec,
00148                  uint32_t measured_interval_sec,
00149                  uint32_t measured_interval_usec,
00150                  uint32_t threshold_packets,
00151                  uint32_t threshold_bytes,
00152                  uint32_t measured_packets,
00153                  uint32_t measured_bytes,
00154                  bool is_threshold_in_packets,
00155                  bool is_threshold_in_bytes,
00156                  bool is_geq_upcall,
00157                  bool is_leq_upcall);
00158     
00159     // Redirection functions (to the pim_node)
00160     int     family() const;
00161     PimMribTable& pim_mrib_table();
00162     Mifset& i_am_dr();
00163     PimVif  *vif_find_by_vif_index(uint32_t vif_index);
00164     PimVif  *vif_find_pim_register();
00165     uint32_t    pim_register_vif_index() const;
00166     
00167     //
00168     // Track-state related methods
00169     //
00170     const PimMreTrackState& pim_mre_track_state() const {
00171     return (_pim_mre_track_state);
00172     }
00173     void    track_state_print_actions_name() const {
00174     _pim_mre_track_state.print_actions_name();
00175     }
00176     void    track_state_print_actions_num() const {
00177     _pim_mre_track_state.print_actions_num();
00178     }
00179     
00180     //
00181     // Tasks related methods
00182     //
00183     void    add_task(PimMreTask *pim_mre_task);
00184     void    delete_task(PimMreTask *pim_mre_task);
00185     void    schedule_task();
00186     //
00187     // The "add_task_*" methods
00188     //
00189     void add_task_rp_changed(const IPvX& affected_rp_addr);
00190     void add_task_mrib_changed(const IPvXNet& modified_prefix_addr);
00191     void add_task_delete_mrib_entries(const list<Mrib *>& mrib_list);
00192     void add_task_nbr_mrib_next_hop_changed(const IPvXNet& modified_prefix_addr);
00193     void add_task_nbr_mrib_next_hop_rp_gen_id_changed(const IPvX& rp_addr);
00194     void add_task_pim_nbr_changed(uint32_t vif_index,
00195                   const IPvX& pim_nbr_addr);
00196     void add_task_pim_nbr_gen_id_changed(uint32_t vif_index,
00197                      const IPvX& pim_nbr_addr);
00198     void add_task_assert_rpf_interface_wc(uint32_t old_rpf_interface_rp,
00199                       const IPvX& group_addr);
00200     void add_task_assert_rpf_interface_sg(uint32_t old_rpf_interface_s,
00201                       const IPvX& source_addr,
00202                       const IPvX& group_addr);
00203     void add_task_receive_join_rp(uint32_t vif_index, const IPvX& rp_addr);
00204     void add_task_receive_join_wc(uint32_t vif_index, const IPvX& group_addr);
00205     void add_task_receive_join_sg(uint32_t vif_index, const IPvX& source_addr,
00206                   const IPvX& group_addr);
00207     void add_task_receive_join_sg_rpt(uint32_t vif_index,
00208                       const IPvX& source_addr,
00209                       const IPvX& group_addr);
00210     void add_task_receive_prune_rp(uint32_t vif_index, const IPvX& rp_addr);
00211     void add_task_receive_prune_wc(uint32_t vif_index, const IPvX& group_addr);
00212     void add_task_see_prune_wc(uint32_t vif_index, const IPvX& group_addr,
00213                    const IPvX& target_nbr_addr);
00214     void add_task_receive_prune_sg(uint32_t vif_index, const IPvX& source_addr,
00215                    const IPvX& group_addr);
00216     void add_task_receive_prune_sg_rpt(uint32_t vif_index,
00217                        const IPvX& source_addr,
00218                        const IPvX& group_addr);
00219     void add_task_receive_end_of_message_sg_rpt(uint32_t vif_index,
00220                         const IPvX& group_addr);
00221     void add_task_downstream_jp_state_rp(uint32_t vif_index,
00222                      const IPvX& rp_addr);
00223     void add_task_downstream_jp_state_wc(uint32_t vif_index,
00224                      const IPvX& group_addr);
00225     void add_task_downstream_jp_state_sg(uint32_t vif_index,
00226                      const IPvX& source_addr,
00227                      const IPvX& group_addr);
00228     void add_task_downstream_jp_state_sg_rpt(uint32_t vif_index,
00229                          const IPvX& source_addr,
00230                          const IPvX& group_addr);
00231     void add_task_upstream_jp_state_sg(const IPvX& source_addr,
00232                        const IPvX& group_addr);
00233     void add_task_local_receiver_include_wc(uint32_t vif_index,
00234                         const IPvX& group_addr);
00235     void add_task_local_receiver_include_sg(uint32_t vif_index,
00236                         const IPvX& source_addr,
00237                         const IPvX& group_addr);
00238     void add_task_local_receiver_exclude_sg(uint32_t vif_index,
00239                         const IPvX& source_addr,
00240                         const IPvX& group_addr);
00241     void add_task_assert_state_wc(uint32_t vif_index, const IPvX& group_addr);
00242     void add_task_assert_state_sg(uint32_t vif_index,
00243                   const IPvX& source_addr,
00244                   const IPvX& group_addr);
00245     void add_task_i_am_dr(uint32_t vif_index);
00246     void add_task_my_ip_address(uint32_t vif_index);
00247     void add_task_my_ip_subnet_address(uint32_t vif_index);
00248     void add_task_spt_switch_threshold_changed();
00249     void add_task_was_switch_to_spt_desired_sg(const IPvX& source_addr,
00250                            const IPvX& group_addr);
00251     void add_task_keepalive_timer_sg(const IPvX& source_addr,
00252                      const IPvX& group_addr);
00253     void add_task_sptbit_sg(const IPvX& source_addr, const IPvX& group_addr);
00254     void add_task_start_vif(uint32_t vif_index);
00255     void add_task_stop_vif(uint32_t vif_index);
00256     void add_task_add_pim_mre(PimMre *pim_mre);
00257     void add_task_delete_pim_mre(PimMre *pim_mre);
00258     
00259     void add_task_delete_pim_mfc(PimMfc *pim_mfc);
00260     
00261     list<PimMreTask *>& pim_mre_task_list() { return (_pim_mre_task_list); }
00262     
00263     
00264 private:
00265     void pim_mre_task_timer_timeout();
00266 
00267     PimNode* _pim_node; // The PIM node
00268     
00269     //
00270     // The lookup tables
00271     //
00272     // XXX: all entries in the (*,G) table have source address = IPvX::ZERO()
00273     // XXX: all entries in the (*,*,RP) table have group address = IPvX::ZERO()
00274     //
00275     PimMrtSg    _pim_mrt_sg;        // The PIM-specific (S,G) MRT
00276     PimMrtSg    _pim_mrt_sg_rpt;    // The PIM-specific (S,G,rpt) MRT
00277     PimMrtG _pim_mrt_g;     // The PIM-specific (*,G) MRT
00278     PimMrtRp    _pim_mrt_rp;        // The PIM-specific (*,*,RP) MRT
00279     PimMrtMfc   _pim_mrt_mfc;       // The PIM-specific MFC MRT
00280     
00281     PimMreTrackState _pim_mre_track_state; // The state-tracking information
00282     list<PimMreTask *> _pim_mre_task_list; // The list of tasks
00283 
00284     // Timer to schedule the processing for the next task or time slice.
00285     XorpTimer   _pim_mre_task_timer;
00286 };
00287 
00288 
00289 #endif // __PIM_PIM_MRT_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations