|
xorp
|
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_MFC_HH__ 00022 #define __PIM_PIM_MFC_HH__ 00023 00024 00025 // 00026 // PIM Multicast Forwarding Cache definitions. 00027 // 00028 00029 00030 #include "mrt/mifset.hh" 00031 #include "mrt/mrt.hh" 00032 00033 00034 class IPvX; 00035 class PimMre; 00036 class PimMrt; 00037 class PimNode; 00038 00039 00040 // PIM-specific Multicast Forwarding Cache 00041 class PimMfc : public Mre<PimMfc> { 00042 public: 00043 PimMfc(PimMrt* pim_mrt, const IPvX& source, const IPvX& group); 00044 virtual ~PimMfc(); 00045 00046 // General info: PimNode, PimMrt, family, etc. 00047 PimNode* pim_node() const; 00048 PimMrt* pim_mrt() const { return _pim_mrt; } 00049 int family() const; 00050 00051 const IPvX& rp_addr() const { return (_rp_addr); } 00052 void set_rp_addr(const IPvX& v); 00053 void uncond_set_rp_addr(const IPvX& v); 00054 uint32_t iif_vif_index() const { return (_iif_vif_index); } 00055 void set_iif_vif_index(uint32_t v) { _iif_vif_index = v; } 00056 const Mifset& olist() const { return (_olist); } 00057 const Mifset& olist_disable_wrongvif() const { 00058 return (_olist_disable_wrongvif); 00059 } 00060 bool is_set_oif(uint32_t vif_index) const { 00061 return (_olist.test(vif_index)); 00062 } 00063 void set_olist(const Mifset& v) { _olist = v; } 00064 void set_olist_disable_wrongvif(const Mifset& v) { 00065 _olist_disable_wrongvif = v; 00066 } 00067 void set_oif(uint32_t vif_index, bool v) { 00068 if (v) 00069 _olist.set(vif_index); 00070 else 00071 _olist.reset(vif_index); 00072 } 00073 00074 void recompute_rp_mfc(); 00075 void recompute_iif_olist_mfc(); 00076 bool recompute_update_sptbit_mfc(); 00077 void recompute_spt_switch_threshold_changed_mfc(); 00078 void recompute_monitoring_switch_to_spt_desired_mfc(); 00079 void install_spt_switch_dataflow_monitor_mfc(PimMre *pim_mre); 00080 00081 void update_mfc(uint32_t new_iif_vif_index, 00082 const Mifset& new_olist, 00083 const PimMre* pim_mre_sg); 00084 int add_mfc_to_kernel(); 00085 int delete_mfc_from_kernel(); 00086 00087 int add_dataflow_monitor(uint32_t threshold_interval_sec, 00088 uint32_t threshold_interval_usec, 00089 uint32_t threshold_packets, 00090 uint32_t threshold_bytes, 00091 bool is_threshold_in_packets, 00092 bool is_threshold_in_bytes, 00093 bool is_geq_upcall, 00094 bool is_leq_upcall); 00095 int delete_dataflow_monitor(uint32_t threshold_interval_sec, 00096 uint32_t threshold_interval_usec, 00097 uint32_t threshold_packets, 00098 uint32_t threshold_bytes, 00099 bool is_threshold_in_packets, 00100 bool is_threshold_in_bytes, 00101 bool is_geq_upcall, 00102 bool is_leq_upcall); 00103 int delete_all_dataflow_monitor(); 00104 00105 bool entry_try_remove(); 00106 bool entry_can_remove() const; 00107 void remove_pim_mfc_entry_mfc(); 00108 00109 bool is_task_delete_pending() const { return (_flags & PIM_MFC_TASK_DELETE_PENDING); } 00110 void set_is_task_delete_pending(bool v) { 00111 if (v) 00112 _flags |= PIM_MFC_TASK_DELETE_PENDING; 00113 else 00114 _flags &= ~PIM_MFC_TASK_DELETE_PENDING; 00115 } 00116 bool is_task_delete_done() const { return (_flags & PIM_MFC_TASK_DELETE_DONE); } 00117 void set_is_task_delete_done(bool v) { 00118 if (v) 00119 _flags |= PIM_MFC_TASK_DELETE_DONE; 00120 else 00121 _flags &= ~PIM_MFC_TASK_DELETE_DONE; 00122 } 00123 00124 bool has_idle_dataflow_monitor() const { return (_flags & PIM_MFC_HAS_IDLE_DATAFLOW_MONITOR); } 00125 void set_has_idle_dataflow_monitor(bool v) { 00126 if (v) 00127 _flags |= PIM_MFC_HAS_IDLE_DATAFLOW_MONITOR; 00128 else 00129 _flags &= ~PIM_MFC_HAS_IDLE_DATAFLOW_MONITOR; 00130 } 00131 00132 bool has_spt_switch_dataflow_monitor() const { return (_flags & PIM_MFC_HAS_SPT_SWITCH_DATAFLOW_MONITOR); } 00133 void set_has_spt_switch_dataflow_monitor(bool v) { 00134 if (v) 00135 _flags |= PIM_MFC_HAS_SPT_SWITCH_DATAFLOW_MONITOR; 00136 else 00137 _flags &= ~PIM_MFC_HAS_SPT_SWITCH_DATAFLOW_MONITOR; 00138 } 00139 00140 bool has_forced_deletion() const { return (_flags & PIM_MFC_HAS_FORCED_DELETION); } 00141 void set_has_forced_deletion(bool v) { 00142 if (v) 00143 _flags |= PIM_MFC_HAS_FORCED_DELETION; 00144 else 00145 _flags &= ~PIM_MFC_HAS_FORCED_DELETION; 00146 } 00147 00148 private: 00149 PimMrt* _pim_mrt; // The PIM MRT (yuck!) 00150 IPvX _rp_addr; // The RP address 00151 uint32_t _iif_vif_index; // The incoming interface 00152 Mifset _olist; // The outgoing interfaces 00153 Mifset _olist_disable_wrongvif;// The outgoing interfaces for which 00154 // the WRONGVIF kernel signal is 00155 // disabled. 00156 00157 // PimMfc _flags 00158 enum { 00159 PIM_MFC_TASK_DELETE_PENDING = 1 << 0, // Entry is pending deletion 00160 PIM_MFC_TASK_DELETE_DONE = 1 << 1, // Entry is ready to be deleted 00161 PIM_MFC_HAS_IDLE_DATAFLOW_MONITOR = 1 << 2, // Entry has an idle dataflow monitor 00162 PIM_MFC_HAS_SPT_SWITCH_DATAFLOW_MONITOR = 1 << 3, // Entry has a SPT-switch dataflow monitor 00163 PIM_MFC_HAS_FORCED_DELETION = 1 << 4 // Entry is forced to be deleted 00164 }; 00165 00166 uint32_t _flags; // Various flags (see PIM_MFC_* above) 00167 }; 00168 00169 00170 #endif // __PIM_PIM_MFC_HH__