⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mld6igmp_group_record.cc

📁 MLDv2 support igmpv3 lite
💻 CC
📖 第 1 页 / 共 3 页
字号:
    set<IPvX>::const_iterator iter;    if (old_is_include_mode) {	if (new_is_include_mode) {	    // INCLUDE -> INCLUDE	    // Join all new sources that are to be forwarded	    for (iter = new_do_forward_sources.begin();		 iter != new_do_forward_sources.end();		 ++iter) {		const IPvX& ipvx = *iter;		if (old_do_forward_sources.find(ipvx)		    == old_do_forward_sources.end()) {		    mld6igmp_vif().join_prune_notify_routing(ipvx,							     group(),							     ACTION_JOIN);		}	    }	    // Prune all old sources that were forwarded	    for (iter = old_do_forward_sources.begin();		 iter != old_do_forward_sources.end();		 ++iter) {		const IPvX& ipvx = *iter;		if (new_do_forward_sources.find(ipvx)		    == new_do_forward_sources.end()) {		    mld6igmp_vif().join_prune_notify_routing(ipvx,							     group(),							     ACTION_PRUNE);		}	    }	}	if (! new_is_include_mode) {	    // INCLUDE -> EXCLUDE	    // Prune the old sources that were forwarded	    for (iter = old_do_forward_sources.begin();		 iter != old_do_forward_sources.end();		 ++iter) {		const IPvX& ipvx = *iter;		if (new_do_forward_sources.find(ipvx)		    == new_do_forward_sources.end()) {		    mld6igmp_vif().join_prune_notify_routing(ipvx,							     group(),							     ACTION_PRUNE);		}	    }	    // Join the group itself	    mld6igmp_vif().join_prune_notify_routing(IPvX::ZERO(family()),						     group(),						     ACTION_JOIN);	    // Join all new sources that are to be forwarded	    for (iter = new_do_forward_sources.begin();		 iter != new_do_forward_sources.end();		 ++iter) {		const IPvX& ipvx = *iter;		if (old_do_forward_sources.find(ipvx)		    == old_do_forward_sources.end()) {		    mld6igmp_vif().join_prune_notify_routing(ipvx,							     group(),							     ACTION_JOIN);		}	    }	}    }    if (! old_is_include_mode) {	if (new_is_include_mode) {	    // EXCLUDE -> INCLUDE	    // Prune the group itself	    mld6igmp_vif().join_prune_notify_routing(IPvX::ZERO(family()),						     group(),						     ACTION_PRUNE);	    // Join all new sources that are to be forwarded	    for (iter = new_do_forward_sources.begin();		 iter != new_do_forward_sources.end();		 ++iter) {		const IPvX& ipvx = *iter;		if (old_do_forward_sources.find(ipvx)		    == old_do_forward_sources.end()) {		    mld6igmp_vif().join_prune_notify_routing(ipvx,							     group(),							     ACTION_JOIN);		}	    }	}	if (! new_is_include_mode) {	    // EXCLUDE -> EXCLUDE	    // Join all new sources that are to be forwarded	    for (iter = new_do_forward_sources.begin();		 iter != new_do_forward_sources.end();		 ++iter) {		const IPvX& ipvx = *iter;		if (old_do_forward_sources.find(ipvx)		    == old_do_forward_sources.end()) {		    mld6igmp_vif().join_prune_notify_routing(ipvx,							     group(),							     ACTION_JOIN);		}	    }	    // Prune all old sources that were forwarded	    for (iter = old_do_forward_sources.begin();		 iter != old_do_forward_sources.end();		 ++iter) {		const IPvX& ipvx = *iter;		if (new_do_forward_sources.find(ipvx)		    == new_do_forward_sources.end()) {		    mld6igmp_vif().join_prune_notify_routing(ipvx,							     group(),							     ACTION_PRUNE);		}	    }	}    }}/** * Constructor for a given vif. *  * @param mld6igmp_vif the interface this set belongs to. */Mld6igmpGroupSet::Mld6igmpGroupSet(Mld6igmpVif& mld6igmp_vif)    : _mld6igmp_vif(mld6igmp_vif){    }/** * Destructor. */Mld6igmpGroupSet::~Mld6igmpGroupSet(){    // XXX: don't delete the payload, because it might be used elsewhere}/** * Find a group record. * * @param group the group address. * @return the corresponding group record (@ref Mld6igmpGroupRecord) * if found, otherwise NULL. */Mld6igmpGroupRecord*Mld6igmpGroupSet::find_group_record(const IPvX& group){    Mld6igmpGroupSet::iterator iter = this->find(group);    if (iter != this->end())	return (iter->second);    return (NULL);}/** * Delete the payload of the set, and clear the set itself. */voidMld6igmpGroupSet::delete_payload_and_clear(){    Mld6igmpGroupSet::iterator iter;    //    // Delete the payload of the set    //    for (iter = this->begin(); iter != this->end(); ++iter) {	Mld6igmpGroupRecord* group_record = iter->second;	delete group_record;    }    //    // Clear the set itself    //    this->clear();}/** * Process MODE_IS_INCLUDE report. * * @param group the group address. * @param sources the source addresses. * @param last_reported_host the address of the host that last reported * as member. */voidMld6igmpGroupSet::process_mode_is_include(const IPvX& group,					  const set<IPvX>& sources,					  const IPvX& last_reported_host){    Mld6igmpGroupSet::iterator iter;    Mld6igmpGroupRecord* group_record = NULL;    iter = this->find(group);    if (iter != this->end()) {	group_record = iter->second;    } else {	group_record = new Mld6igmpGroupRecord(_mld6igmp_vif, group);	this->insert(make_pair(group, group_record));    }    XLOG_ASSERT(group_record != NULL);    group_record->process_mode_is_include(sources, last_reported_host);    //    // If the group record is not used anymore, then delete it    //    if (group_record->is_unused()) {	this->erase(group);	delete group_record;    }}/** * Process MODE_IS_EXCLUDE report. * * @param group the group address. * @param sources the source addresses. * @param last_reported_host the address of the host that last reported * as member. */voidMld6igmpGroupSet::process_mode_is_exclude(const IPvX& group,					  const set<IPvX>& sources,					  const IPvX& last_reported_host){    Mld6igmpGroupSet::iterator iter;    Mld6igmpGroupRecord* group_record = NULL;    set<IPvX> nosources;    UNUSED(sources);    iter = this->find(group);    if (iter != this->end()) {	group_record = iter->second;    } else {	group_record = new Mld6igmpGroupRecord(_mld6igmp_vif, group);	this->insert(make_pair(group, group_record));    }    XLOG_ASSERT(group_record != NULL);    group_record->process_mode_is_exclude(nosources, last_reported_host);    //    // If the group record is not used anymore, then delete it    //    if (group_record->is_unused()) {	this->erase(group);	delete group_record;    }}/** * Process CHANGE_TO_INCLUDE_MODE report. * * @param group the group address. * @param sources the source addresses. * @param last_reported_host the address of the host that last reported * as member. */voidMld6igmpGroupSet::process_change_to_include_mode(const IPvX& group,						 const set<IPvX>& sources,						 const IPvX& last_reported_host){    Mld6igmpGroupSet::iterator iter;    Mld6igmpGroupRecord* group_record = NULL;    iter = this->find(group);    if (iter != this->end()) {	group_record = iter->second;    } else {	group_record = new Mld6igmpGroupRecord(_mld6igmp_vif, group);	this->insert(make_pair(group, group_record));    }    XLOG_ASSERT(group_record != NULL);    if (_mld6igmp_vif.is_igmpv1_mode(group_record)) {	//	// XXX: Ignore CHANGE_TO_INCLUDE_MODE messages when in	// IGMPv1 mode.	//    } else {	group_record->process_change_to_include_mode(sources,						     last_reported_host);    }    //    // If the group record is not used anymore, then delete it    //    if (group_record->is_unused()) {	this->erase(group);	delete group_record;    }}/** * Process CHANGE_TO_EXCLUDE_MODE report. * * @param group the group address. * @param sources the source addresses. * @param last_reported_host the address of the host that last reported * as member. */voidMld6igmpGroupSet::process_change_to_exclude_mode(const IPvX& group,						 const set<IPvX>& sources,						 const IPvX& last_reported_host){    Mld6igmpGroupSet::iterator iter;    Mld6igmpGroupRecord* group_record = NULL;    UNUSED(sources);    iter = this->find(group);    if (iter != this->end()) {	group_record = iter->second;    } else {	group_record = new Mld6igmpGroupRecord(_mld6igmp_vif, group);	this->insert(make_pair(group, group_record));    }    XLOG_ASSERT(group_record != NULL);    if (_mld6igmp_vif.is_igmpv1_mode(group_record)	|| _mld6igmp_vif.is_igmpv2_mode(group_record)	|| _mld6igmp_vif.is_mldv1_mode(group_record)) {	//	// XXX: Ignore the source list in the CHANGE_TO_EXCLUDE_MODE	// messages when in IGMPv1, IGMPv2, or MLDv1 mode.	//	set<IPvX> no_sources;		// XXX: empty set	group_record->process_change_to_exclude_mode(no_sources,						     last_reported_host);    } else {	set<IPvX> no_sources;	group_record->process_change_to_exclude_mode(no_sources,						     last_reported_host);    }    //    // If the group record is not used anymore, then delete it    //    if (group_record->is_unused()) {	this->erase(group);	delete group_record;    }}/** * Process ALLOW_NEW_SOURCES report. * * @param group the group address. * @param sources the source addresses. * @param last_reported_host the address of the host that last reported * as member. */voidMld6igmpGroupSet::process_allow_new_sources(const IPvX& group,					    const set<IPvX>& sources,					    const IPvX& last_reported_host){    Mld6igmpGroupSet::iterator iter;    Mld6igmpGroupRecord* group_record = NULL;    iter = this->find(group);    if (iter != this->end()) {	group_record = iter->second;    } else {	group_record = new Mld6igmpGroupRecord(_mld6igmp_vif, group);	this->insert(make_pair(group, group_record));    }    XLOG_ASSERT(group_record != NULL);    group_record->process_allow_new_sources(sources, last_reported_host);    //    // If the group record is not used anymore, then delete it    //    if (group_record->is_unused()) {	this->erase(group);	delete group_record;    }}/** * Process BLOCK_OLD_SOURCES report. * * @param group the group address. * @param sources the source addresses. * @param last_reported_host the address of the host that last reported * as member. */voidMld6igmpGroupSet::process_block_old_sources(const IPvX& group,					    const set<IPvX>& sources,					    const IPvX& last_reported_host){    Mld6igmpGroupSet::iterator iter;    Mld6igmpGroupRecord* group_record = NULL;    iter = this->find(group);    if (iter != this->end()) {	group_record = iter->second;    } else {	group_record = new Mld6igmpGroupRecord(_mld6igmp_vif, group);	this->insert(make_pair(group, group_record));    }    XLOG_ASSERT(group_record != NULL);    if (_mld6igmp_vif.is_igmpv1_mode(group_record)	|| _mld6igmp_vif.is_igmpv2_mode(group_record)	|| _mld6igmp_vif.is_mldv1_mode(group_record)) {	//	// XXX: Ignore BLOCK_OLD_SOURCES messages when in	// IGMPv1, IGMPv2, or MLDv1 mode.	//    } else {	group_record->process_block_old_sources(sources, last_reported_host);    }    //    // If the group record is not used anymore, then delete it    //    if (group_record->is_unused()) {	this->erase(group);	delete group_record;    }}/** * Lower the group timer. * * @param group the group address. * @param timeval the timeout interval the timer should be lowered to. */voidMld6igmpGroupSet::lower_group_timer(const IPvX& group,				    const TimeVal& timeval){    Mld6igmpGroupSet::iterator iter;    iter = this->find(group);    if (iter != this->end()) {	Mld6igmpGroupRecord* group_record = iter->second;	group_record->lower_group_timer(timeval);    }}/** * Lower the source timer for a set of sources. * * @param group the group address. * @param sources the source addresses. * @param timeval the timeout interval the timer should be lowered to. */voidMld6igmpGroupSet::lower_source_timer(const IPvX& group,				     const set<IPvX>& sources,				     const TimeVal& timeval){    Mld6igmpGroupSet::iterator iter;    iter = this->find(group);    if (iter != this->end()) {	Mld6igmpGroupRecord* group_record = iter->second;	group_record->lower_source_timer(sources, timeval);    }}/** * Get the number of seconds until the IGMPv1 host present timer expires. * * @return the number of seconds until the IGMPv1 host present timer * expires. */uint32_tMld6igmpGroupRecord::igmpv1_host_present_timer_timeout_sec() const{    TimeVal tv;        _igmpv1_host_present_timer.time_remaining(tv);        return (tv.sec());}/** * Get the number of seconds until the IGMPv2/MLDv1 host present timer * expires. * * @return the number of seconds until the IGMPv2/MLDv1 host present timer * expires. */uint32_tMld6igmpGroupRecord::igmpv2_mldv1_host_present_timer_timeout_sec() const{    TimeVal tv;        _igmpv2_mldv1_host_present_timer.time_remaining(tv);        return (tv.sec());}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -