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 //
00021 // The Lightweight IGMP/MLD modifications to this file are copyrighted by:
00022 //
00023 // Copyright (c) 2008 Huawei Technologies Co. Ltd
00024 //
00025 
00026 // $XORP: xorp/contrib/mld6igmp_lite/mld6igmp_group_record.hh,v 1.5 2008/10/02 21:56:32 bms Exp $
00027 
00028 #ifndef __MLD6IGMP_MLD6IGMP_GROUP_RECORD_HH__
00029 #define __MLD6IGMP_MLD6IGMP_GROUP_RECORD_HH__
00030 
00031 
00032 //
00033 // IGMP and MLD group record.
00034 //
00035 
00036 
00037 
00038 
00039 
00040 #include "libxorp/ipvx.hh"
00041 #include "libxorp/timer.hh"
00042 
00043 #include "mld6igmp_source_record.hh"
00044 
00045 
00046 //
00047 // Constants definitions
00048 //
00049 
00050 //
00051 // Structures/classes, typedefs and macros
00052 //
00053 
00054 class Mld6igmpVif;
00055 
00059 class Mld6igmpGroupRecord {
00060 public:
00067     Mld6igmpGroupRecord(Mld6igmpVif& mld6igmp_vif, const IPvX& group);
00068     
00072     ~Mld6igmpGroupRecord();
00073 
00079     Mld6igmpVif& mld6igmp_vif() const   { return (_mld6igmp_vif);   }
00080     
00086     const IPvX& group() const       { return (_group); }
00087 
00093     EventLoop& eventloop();
00094 
00100     bool is_include_mode() const    { return (this->timeout_sec() == 0); }
00101 
00107     bool is_asm_mode() const    { return (! (this->timeout_sec() == 0)); }
00108 
00112     void set_include_mode()     { }
00113 
00117     void set_exclude_mode()     { }
00118 
00124     bool is_unused() const;
00125 
00133     Mld6igmpSourceRecord* find_do_forward_source(const IPvX& source);
00134 
00142     Mld6igmpSourceRecord* find_dont_forward_source(const IPvX& source);
00143 
00149     const Mld6igmpSourceSet& do_forward_sources() const { return (_do_forward_sources); }
00150 
00164     void process_mode_is_include(const set<IPvX>& sources,
00165                  const IPvX& last_reported_host);
00166 
00174     void process_mode_is_exclude(const set<IPvX>& sources,
00175                  const IPvX& last_reported_host);
00176 
00184     void process_change_to_include_mode(const set<IPvX>& sources,
00185                     const IPvX& last_reported_host);
00186 
00194     void process_change_to_exclude_mode(const set<IPvX>& sources,
00195                     const IPvX& last_reported_host);
00196 
00204     void process_allow_new_sources(const set<IPvX>& sources,
00205                    const IPvX& last_reported_host);
00206 
00214     void process_block_old_sources(const set<IPvX>& sources,
00215                    const IPvX& last_reported_host);
00216 
00222     void lower_group_timer(const TimeVal& timeval);
00223 
00230     void lower_source_timer(const set<IPvX>& sources, const TimeVal& timeval);
00231 
00237     void source_expired(Mld6igmpSourceRecord* source_record);
00238 
00244     uint32_t    timeout_sec()   const;
00245 
00252     uint32_t    igmpv1_host_present_timer_timeout_sec() const;
00253 
00261     uint32_t    igmpv2_mldv1_host_present_timer_timeout_sec()   const;
00262 
00268     const IPvX& last_reported_host() const { return (_last_reported_host); }
00269 
00275     XorpTimer& group_timer() { return _group_timer; }
00276 
00286     void schedule_periodic_group_query(const set<IPvX>& sources);
00287 
00294     void received_older_membership_report(int message_version);
00295 
00301     bool    is_igmpv1_mode() const;
00302 
00308     bool    is_igmpv2_mode() const;
00309 
00315     bool    is_igmpv3_mode() const;
00316 
00322     bool    is_mldv1_mode() const;
00323 
00329     bool    is_mldv2_mode() const;
00330 
00336     int     family() const { return _group.af(); }
00337 
00338 private:
00347     void calculate_forwarding_changes(bool old_is_include_mode,
00348                       const set<IPvX>& old_do_forward_sources) const; 
00352     void    older_version_host_present_timer_timeout();
00353 
00357     void    group_timer_timeout();
00358 
00365     bool    group_query_periodic_timeout();
00366 
00372     void set_last_reported_host(const IPvX& v) { _last_reported_host = v; }
00373 
00374     Mld6igmpVif& _mld6igmp_vif;     // The interface this entry belongs to
00375     IPvX    _group;         // The multicast group address
00376     Mld6igmpSourceSet _do_forward_sources;  // Sources to forward
00377     IPvX    _last_reported_host;    // The host that last reported as member
00378 
00379     // Timers indicating that hosts running older protocol version are present
00380     XorpTimer   _igmpv1_host_present_timer;
00381     XorpTimer   _igmpv2_mldv1_host_present_timer;
00382 
00383     XorpTimer   _group_timer;       // Group timer for filter mode switch
00384     XorpTimer   _group_query_timer; // Timer for periodic Queries
00385     size_t  _query_retransmission_count; // Count for periodic Queries
00386 };
00387 
00391 class Mld6igmpGroupSet : public map<IPvX, Mld6igmpGroupRecord *> {
00392 public:
00398     Mld6igmpGroupSet(Mld6igmpVif& mld6igmp_vif);
00399     
00403     ~Mld6igmpGroupSet();
00404 
00412     Mld6igmpGroupRecord* find_group_record(const IPvX& group);
00413 
00417     void delete_payload_and_clear();
00418 
00427     void process_mode_is_include(const IPvX& group, const set<IPvX>& sources,
00428                  const IPvX& last_reported_host);
00429 
00438     void process_mode_is_exclude(const IPvX& group, const set<IPvX>& sources,
00439                  const IPvX& last_reported_host);
00440 
00449     void process_change_to_include_mode(const IPvX& group,
00450                     const set<IPvX>& sources,
00451                     const IPvX& last_reported_host);
00452 
00461     void process_change_to_exclude_mode(const IPvX& group,
00462                     const set<IPvX>& sources,
00463                     const IPvX& last_reported_host);
00464 
00473     void process_allow_new_sources(const IPvX& group,
00474                    const set<IPvX>& sources,
00475                    const IPvX& last_reported_host);
00476 
00485     void process_block_old_sources(const IPvX& group,
00486                    const set<IPvX>& sources,
00487                    const IPvX& last_reported_host);
00488 
00495     void lower_group_timer(const IPvX& group, const TimeVal& timeval);
00496 
00504     void lower_source_timer(const IPvX& group, const set<IPvX>& sources,
00505                 const TimeVal& timeval);
00506 
00507 private:
00508     Mld6igmpVif& _mld6igmp_vif;     // The interface this set belongs to
00509 };
00510 
00511 //
00512 // Global variables
00513 //
00514 
00515 //
00516 // Global functions prototypes
00517 //
00518 
00519 #endif // __MLD6IGMP_MLD6IGMP_GROUP_RECORD_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations