hgadd.c,v
来自「TCP-IP红宝书源代码」· C,V 代码 · 共 76 行
C,V
76 行
head 1.1;
access;
symbols;
locks
dls:1.1; strict;
comment @ * @;
1.1
date 97.09.21.19.26.58; author dls; state Dist;
branches;
next ;
desc
@@
1.1
log
@pre-3e code
@
text
@/* hgadd.c - hgadd */
#include <conf.h>
#include <kernel.h>
#include <network.h>
#include <igmp.h>
/*------------------------------------------------------------------------
* hgadd - add a host group entry for a group
*------------------------------------------------------------------------
*/
int hgadd(ifnum, ipa, islocal)
int ifnum; /* interface for the host group */
IPaddr ipa; /* IP multicast address */
Bool islocal; /* true if this group is local */
{
struct hg *phg;
static int start;
int i;
wait(HostGroup.hi_mutex);
for (i=0; i < HG_TSIZE; ++i) {
if (++start >= HG_TSIZE)
start = 0;
if (hgtable[start].hg_state == HGS_FREE)
break;
}
phg = &hgtable[start];
if (phg->hg_state != HGS_FREE) {
signal(HostGroup.hi_mutex);
return SYSERR; /* table full */
}
if (hgarpadd(ifnum, ipa) == SYSERR) {
signal(HostGroup.hi_mutex);
return SYSERR;
}
phg->hg_ifnum = ifnum;
phg->hg_refs = 1;
if (islocal)
phg->hg_ttl = 1;
else
phg->hg_ttl = IP_TTL;
phg->hg_ipa = ipa;
if (ipa == ig_allhosts)
phg->hg_state = HGS_STATIC;
else
phg->hg_state = HGS_IDLE;
signal(HostGroup.hi_mutex);
return OK;
}
@
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?