xorp

pim_nbr.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/pim/pim_nbr.hh,v 1.20 2008/10/02 21:57:54 bms Exp $
00021 
00022 
00023 #ifndef __PIM_PIM_NBR_HH__
00024 #define __PIM_PIM_NBR_HH__
00025 
00026 
00027 //
00028 // PIM router neighbors definitions.
00029 //
00030 
00031 
00032 #include "libxorp/ipvx.hh"
00033 #include "libxorp/timer.hh"
00034 #include "pim_proto_join_prune_message.hh"
00035 
00036 
00037 //
00038 // Constants definitions
00039 //
00040 
00041 //
00042 // Structures/classes, typedefs and macros
00043 //
00044 
00045 class PimVif;
00046 
00047 class PimNbr {
00048 public:
00049     PimNbr(PimVif* pim_vif, const IPvX& primary_addr, int proto_version);
00050     ~PimNbr();
00051     
00052     void    reset_received_options();
00053     PimNode*    pim_node()  const   { return _pim_node; }
00054     PimVif* pim_vif()   const   { return _pim_vif; }
00055     uint32_t    vif_index() const;
00056     const IPvX& primary_addr()  const   { return (_primary_addr); }
00057     void    set_primary_addr(const IPvX& v) { _primary_addr = v; }
00058     const list<IPvX>& secondary_addr_list() const { return _secondary_addr_list; }
00059     void    add_secondary_addr(const IPvX& v);
00060     void    delete_secondary_addr(const IPvX& v);
00061     void    clear_secondary_addr_list() { _secondary_addr_list.clear(); }
00062     bool    has_secondary_addr(const IPvX& secondary_addr) const;
00063     bool    is_my_addr(const IPvX& addr) const;
00064     int     proto_version() const { return (_proto_version); }
00065     void    set_proto_version(int v) { _proto_version = v; }
00066     
00067     uint16_t    hello_holdtime() const { return (_hello_holdtime); }
00068     void    set_hello_holdtime(uint16_t v) { _hello_holdtime = v; }
00069     
00070     uint32_t    genid()     const   { return (_genid);  }
00071     void    set_genid(uint32_t v) { _genid = v; }
00072     bool    is_genid_present() const { return (_is_genid_present); }
00073     void    set_is_genid_present(bool v) { _is_genid_present = v; }
00074     
00075     uint32_t    dr_priority() const { return (_dr_priority); }
00076     void    set_dr_priority(uint32_t v) { _dr_priority = v; }
00077     bool    is_dr_priority_present() const {
00078     return (_is_dr_priority_present);
00079     }
00080     void    set_is_dr_priority_present(bool v) {
00081     _is_dr_priority_present = v;
00082     }
00083     
00084     bool    is_tracking_support_disabled() const {
00085     return (_is_tracking_support_disabled);
00086     }
00087     void    set_is_tracking_support_disabled(bool v) {
00088     _is_tracking_support_disabled = v;
00089     }
00090     
00091     uint16_t    propagation_delay() const { return (_propagation_delay); }
00092     void    set_propagation_delay(uint16_t v) { _propagation_delay = v; }
00093     
00094     uint16_t    override_interval() const { return (_override_interval); }
00095     void    set_override_interval(uint16_t v) { _override_interval = v; }
00096     
00097     bool    is_lan_prune_delay_present() const {
00098     return (_is_lan_prune_delay_present);
00099     }
00100     void    set_is_lan_prune_delay_present(bool v) {
00101     _is_lan_prune_delay_present = v;
00102     }
00103     
00104     void    pim_hello_holdtime_process(uint16_t holdtime);
00105     void    pim_hello_lan_prune_delay_process(bool lan_prune_delay_tbit,
00106                           uint16_t propagation_delay,
00107                           uint16_t override_interval);
00108     void    pim_hello_dr_priority_process(uint32_t dr_priority);
00109     void    pim_hello_genid_process(uint32_t genid);
00110     
00111     bool    is_nohello_neighbor() const { return (_is_nohello_neighbor); }
00112     void    set_is_nohello_neighbor(bool v) { _is_nohello_neighbor = v; }
00113     
00114     int     jp_entry_add(const IPvX& source_addr, const IPvX& group_addr,
00115                  uint8_t group_mask_len,
00116                  mrt_entry_type_t mrt_entry_type,
00117                  action_jp_t action_jp, uint16_t holdtime,
00118                  bool is_new_group);
00119     
00120     const XorpTimer& const_neighbor_liveness_timer() const {
00121     return (_neighbor_liveness_timer);
00122     }
00123     
00124     const TimeVal& startup_time() const { return _startup_time; }
00125     void    set_startup_time(const TimeVal& v) { _startup_time = v; }
00126     
00127     list<PimMre *>& pim_mre_rp_list()   { return (_pim_mre_rp_list); }
00128     list<PimMre *>& pim_mre_wc_list()   { return (_pim_mre_wc_list); }
00129     list<PimMre *>& pim_mre_sg_list()   { return (_pim_mre_sg_list); }
00130     list<PimMre *>& pim_mre_sg_rpt_list() { return (_pim_mre_sg_rpt_list); }
00131     list<PimMre *>& processing_pim_mre_rp_list() {
00132     return (_processing_pim_mre_rp_list);
00133     }
00134     list<PimMre *>& processing_pim_mre_wc_list() {
00135     return (_processing_pim_mre_wc_list);
00136     }
00137     list<PimMre *>& processing_pim_mre_sg_list() {
00138     return (_processing_pim_mre_sg_list);
00139     }
00140     list<PimMre *>& processing_pim_mre_sg_rpt_list() {
00141     return (_processing_pim_mre_sg_rpt_list);
00142     }
00143     void    init_processing_pim_mre_rp();
00144     void    init_processing_pim_mre_wc();
00145     void    init_processing_pim_mre_sg();
00146     void    init_processing_pim_mre_sg_rpt();
00147     void    add_pim_mre(PimMre *pim_mre);
00148     void    delete_pim_mre(PimMre *pim_mre);
00149     
00150 private:
00151     friend class PimVif;
00152     
00153     void    neighbor_liveness_timer_timeout();
00154     void    jp_send_timer_timeout();
00155     
00156     // Fields to hold information from the PIM_HELLO messages
00157     PimNode*    _pim_node;      // The associated PIM node
00158     PimVif* _pim_vif;       // The corresponding PIM vif
00159     IPvX    _primary_addr;      // The primary address of the neighbor
00160     list<IPvX>  _secondary_addr_list;   // The secondary addresses of the neighbor
00161     int     _proto_version;     // The protocol version of the neighbor
00162     uint32_t    _genid;         // The Gen-ID of the neighbor
00163     bool    _is_genid_present;  // Is the Gen-ID field is present
00164     uint32_t    _dr_priority;       // The DR priority of the neighbor
00165     bool    _is_dr_priority_present;// Is the DR priority field present
00166     uint16_t    _hello_holdtime;    // The Holdtime from/for this nbr
00167     XorpTimer   _neighbor_liveness_timer; // Timer to expire the neighbor
00168     // LAN Prune Delay option related info
00169     bool    _is_tracking_support_disabled; // The T-bit
00170     uint16_t    _propagation_delay; // The Propagation_Delay
00171     uint16_t    _override_interval; // The Override_Interval
00172     bool    _is_lan_prune_delay_present;// Is the LAN Prune Delay present
00173     bool    _is_nohello_neighbor;   // True if no-Hello neighbor
00174     
00175     XorpTimer   _jp_send_timer;     // Timer to send the accumulated JP msg
00176     
00177     PimJpHeader _jp_header;
00178     
00179     TimeVal _startup_time;      // Start-up time of this neighbor
00180     
00181     //
00182     // The lists of all related PimMre entries.
00183     // XXX: note that we don't have a list for PimMfc entries, because
00184     // they don't depend directly on PimNbr. For example, PimMfc has
00185     // a field for the RP address, therefore PimRp contains a list of
00186     // PimMfc entries related to that RP.
00187     //
00188     list<PimMre *> _pim_mre_rp_list;    // List of all related (*,*,RP) entries
00189                     // for this PimNbr.
00190     list<PimMre *> _pim_mre_wc_list;    // List of all related (*,G) entries
00191                     // for this PimNbr.
00192     list<PimMre *> _pim_mre_sg_list;    // List of all related (S,G) entries
00193                     // for this PimNbr.
00194     list<PimMre *> _pim_mre_sg_rpt_list;// List of all related (S,G,rpt)
00195                     // entries for this PimNbr.
00196     list<PimMre *> _processing_pim_mre_rp_list; // List of all related
00197                     // (*,*,RP) entries for this PimNbr
00198                     // that are awaiting to be processed.
00199     list<PimMre *> _processing_pim_mre_wc_list; // List of all related
00200                     // (*,G) entries for this PimNbr
00201                     // that are awaiting to be processed.
00202     list<PimMre *> _processing_pim_mre_sg_list; // List of all related
00203                     // (S,G) entries for this PimNbr that
00204                     // are awaiting to be processed.
00205     list<PimMre *> _processing_pim_mre_sg_rpt_list;// List of all related
00206                     // (S,G,rpt) entries for this PimNbr
00207                     // that are awaiting to be processed.
00208 };
00209 
00210 
00211 //
00212 // Global variables
00213 //
00214 
00215 //
00216 // Global functions prototypes
00217 //
00218 
00219 #endif // __PIM_PIM_NBR_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations