xorp

mld6igmp_group_record.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/mld6igmp/mld6igmp_group_record.hh,v 1.23 2008/10/02 21:57:43 bms Exp $
00021 
00022 #ifndef __MLD6IGMP_MLD6IGMP_GROUP_RECORD_HH__
00023 #define __MLD6IGMP_MLD6IGMP_GROUP_RECORD_HH__
00024 
00025 
00026 //
00027 // IGMP and MLD group record.
00028 //
00029 
00030 
00031 
00032 
00033 
00034 #include "libxorp/ipvx.hh"
00035 #include "libxorp/timer.hh"
00036 
00037 #include "mld6igmp_source_record.hh"
00038 
00039 
00040 //
00041 // Constants definitions
00042 //
00043 
00044 //
00045 // Structures/classes, typedefs and macros
00046 //
00047 
00048 class Mld6igmpVif;
00049 
00053 class Mld6igmpGroupRecord {
00054 public:
00061     Mld6igmpGroupRecord(Mld6igmpVif& mld6igmp_vif, const IPvX& group);
00062     
00066     ~Mld6igmpGroupRecord();
00067 
00073     Mld6igmpVif& mld6igmp_vif() const   { return (_mld6igmp_vif);   }
00074     
00080     const IPvX& group() const       { return (_group); }
00081 
00087     EventLoop& eventloop();
00088 
00094     bool is_include_mode() const    { return (_is_include_mode); }
00095 
00101     bool is_exclude_mode() const    { return (! _is_include_mode); }
00102 
00106     void set_include_mode()     { _is_include_mode = true; }
00107 
00111     void set_exclude_mode()     { _is_include_mode = false; }
00112 
00118     bool is_unused() const;
00119 
00127     Mld6igmpSourceRecord* find_do_forward_source(const IPvX& source);
00128 
00136     Mld6igmpSourceRecord* find_dont_forward_source(const IPvX& source);
00137 
00143     const Mld6igmpSourceSet& do_forward_sources() const { return (_do_forward_sources); }
00144 
00150     const Mld6igmpSourceSet& dont_forward_sources() const { return (_dont_forward_sources); }
00151 
00159     void process_mode_is_include(const set<IPvX>& sources,
00160                  const IPvX& last_reported_host);
00161 
00169     void process_mode_is_exclude(const set<IPvX>& sources,
00170                  const IPvX& last_reported_host);
00171 
00179     void process_change_to_include_mode(const set<IPvX>& sources,
00180                     const IPvX& last_reported_host);
00181 
00189     void process_change_to_exclude_mode(const set<IPvX>& sources,
00190                     const IPvX& last_reported_host);
00191 
00199     void process_allow_new_sources(const set<IPvX>& sources,
00200                    const IPvX& last_reported_host);
00201 
00209     void process_block_old_sources(const set<IPvX>& sources,
00210                    const IPvX& last_reported_host);
00211 
00217     void lower_group_timer(const TimeVal& timeval);
00218 
00225     void lower_source_timer(const set<IPvX>& sources, const TimeVal& timeval);
00226 
00232     void source_expired(Mld6igmpSourceRecord* source_record);
00233 
00239     uint32_t    timeout_sec()   const;
00240     
00246     const IPvX& last_reported_host() const { return (_last_reported_host); }
00247 
00253     XorpTimer& group_timer() { return _group_timer; }
00254 
00264     void schedule_periodic_group_query(const set<IPvX>& sources);
00265 
00272     void received_older_membership_report(int message_version);
00273 
00279     bool    is_igmpv1_mode() const;
00280 
00286     bool    is_igmpv2_mode() const;
00287 
00293     bool    is_igmpv3_mode() const;
00294 
00300     bool    is_mldv1_mode() const;
00301 
00307     bool    is_mldv2_mode() const;
00308 
00314     int     family() const { return _group.af(); }
00315 
00316 private:
00325     void calculate_forwarding_changes(bool old_is_include_mode,
00326                       const set<IPvX>& old_do_forward_sources,
00327                       const set<IPvX>& old_dont_forward_sources) const;
00328 
00332     void    older_version_host_present_timer_timeout();
00333 
00337     void    group_timer_timeout();
00338 
00345     bool    group_query_periodic_timeout();
00346 
00352     void set_last_reported_host(const IPvX& v) { _last_reported_host = v; }
00353 
00354     Mld6igmpVif& _mld6igmp_vif;     // The interface this entry belongs to
00355     IPvX    _group;         // The multicast group address
00356     bool    _is_include_mode;   // Flag for INCLUDE/EXCLUDE filter mode
00357     Mld6igmpSourceSet _do_forward_sources;  // Sources to forward
00358     Mld6igmpSourceSet _dont_forward_sources;    // Sources not to forward
00359 
00360     IPvX    _last_reported_host;    // The host that last reported as member
00361 
00362     // Timers indicating that hosts running older protocol version are present
00363     XorpTimer   _igmpv1_host_present_timer;
00364     XorpTimer   _igmpv2_mldv1_host_present_timer;
00365 
00366     XorpTimer   _group_timer;       // Group timer for filter mode switch
00367     XorpTimer   _group_query_timer; // Timer for periodic Queries
00368     size_t  _query_retransmission_count; // Count for periodic Queries
00369 };
00370 
00374 class Mld6igmpGroupSet : public map<IPvX, Mld6igmpGroupRecord *> {
00375 public:
00381     Mld6igmpGroupSet(Mld6igmpVif& mld6igmp_vif);
00382     
00386     ~Mld6igmpGroupSet();
00387 
00395     Mld6igmpGroupRecord* find_group_record(const IPvX& group);
00396 
00400     void delete_payload_and_clear();
00401 
00410     void process_mode_is_include(const IPvX& group, const set<IPvX>& sources,
00411                  const IPvX& last_reported_host);
00412 
00421     void process_mode_is_exclude(const IPvX& group, const set<IPvX>& sources,
00422                  const IPvX& last_reported_host);
00423 
00432     void process_change_to_include_mode(const IPvX& group,
00433                     const set<IPvX>& sources,
00434                     const IPvX& last_reported_host);
00435 
00444     void process_change_to_exclude_mode(const IPvX& group,
00445                     const set<IPvX>& sources,
00446                     const IPvX& last_reported_host);
00447 
00456     void process_allow_new_sources(const IPvX& group,
00457                    const set<IPvX>& sources,
00458                    const IPvX& last_reported_host);
00459 
00468     void process_block_old_sources(const IPvX& group,
00469                    const set<IPvX>& sources,
00470                    const IPvX& last_reported_host);
00471 
00478     void lower_group_timer(const IPvX& group, const TimeVal& timeval);
00479 
00487     void lower_source_timer(const IPvX& group, const set<IPvX>& sources,
00488                 const TimeVal& timeval);
00489 
00490 private:
00491     Mld6igmpVif& _mld6igmp_vif;     // The interface this set belongs to
00492 };
00493 
00494 //
00495 // Global variables
00496 //
00497 
00498 //
00499 // Global functions prototypes
00500 //
00501 
00502 #endif // __MLD6IGMP_MLD6IGMP_GROUP_RECORD_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations