hgleave.c

来自「TCP-IP红宝书源代码」· C语言 代码 · 共 33 行

C
33
字号
/* hgleave.c - hgleave */

#include <conf.h>
#include <kernel.h>
#include <network.h>
#include <igmp.h>

/*------------------------------------------------------------------------
 *  hgleave  -  handle application request to leave a host group
 *------------------------------------------------------------------------
 */
int
hgleave(unsigned ifnum, IPaddr ipa)
{
	struct	hg	*phg;

	if (!IP_CLASSD(ipa))
		return SYSERR;
	wait(HostGroup.hi_mutex);
	if (!(phg = hglookup(ifnum, ipa)) || --(phg->hg_refs)) {
		signal(HostGroup.hi_mutex);
		return OK;
	}
	/* else, it exists & last reference */
	rtdel(ipa, ip_maskall);
	hgarpdel(ifnum, ipa);
	if (phg->hg_state == HGS_DELAYING)
		tmclear(HostGroup.hi_uport, phg);
	phg->hg_state = HGS_FREE;
	signal(HostGroup.hi_mutex);
	return OK;
}

⌨️ 快捷键说明

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