igmp.c,v

来自「TCP-IP红宝书源代码」· C,V 代码 · 共 69 行

C,V
69
字号
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
@/* igmp.c - igmp */

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

/*------------------------------------------------------------------------
 *  igmp  -  send IGMP requests/responses
 *------------------------------------------------------------------------
 */
int igmp(typ, ifnum, hga)
int	typ;		/* IGT_* from igmp.h				*/
int	ifnum;		/* interface # this group (currently unused)	*/
IPaddr	hga;		/* host group multicast addr.			*/
{
	struct	ep	*pep;
	struct	ip	*pip;
	struct	igmp	*pig;

	pep = (struct ep *)getbuf(Net.netpool);
	if (pep == (struct ep *)SYSERR)
		return SYSERR;
	pip = (struct ip *)pep->ep_data;
	pig = (struct igmp *) pip->ip_data;
	pig->ig_vertyp = (IG_VERSION<<4) | (typ & 0xf);
	pig->ig_unused = 0;
	pig->ig_cksum = 0;
	pig->ig_gaddr = hga;
	pig->ig_cksum = cksum(pig, IG_HLEN>>1);

	ipsend(hga, pep, IG_HLEN, IPT_IGMP, IPP_INCTL, 1);
	return OK;
}

/* special IGMP-relevant address & mask */

#if	BYTE_ORDER == LITTLE_ENDIAN
IPaddr	ig_allhosts = 0x010000E0; 		/* 224.0.0.1 */
IPaddr  ig_allDmask = 0xF0;		/* 240.0.0.0 */
#else	/* BYTE_ORDER */
IPaddr	ig_allhosts = 0xE0000001; 	/* 224.0.0.1 */
IPaddr  ig_allDmask = 0xF0000000;	/* 240.0.0.0 */
#endif	/* BYTE_ORDER */
@

⌨️ 快捷键说明

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