コード例 #1
0
/*------------------------------------------------------------------------
 *  icerrok -  is it ok to send an error response?
 *------------------------------------------------------------------------
 */
Bool
icerrok(struct ep *pep)
{
	struct	ip	*pip = (struct ip *)pep->ep_data;
	struct	icmp	*pic = (struct icmp *)pip->ip_data;

	/* don't send errors about error packets... */

	if (pip->ip_proto == IPT_ICMP)
		switch(pic->ic_type) {
		case ICT_DESTUR:
		case ICT_REDIRECT:
		case ICT_SRCQ:
		case ICT_TIMEX:
		case ICT_PARAMP:
			return FALSE;
		default:
			break;
		}
	/* ...or other than the first of a fragment */

	if (pip->ip_fragoff & IP_FRAGOFF)
		return FALSE;
	/* ...or broadcast or multicast packets */

	if (isbrc(pip->ip_dst) || IP_CLASSD(pip->ip_dst))
		return FALSE;
	return TRUE;
}
コード例 #2
0
ファイル: hgjoin.c プロジェクト: m3y54m/32bitmicro
/*------------------------------------------------------------------------
 *  hgjoin  -  handle application request to join a host group
 *------------------------------------------------------------------------
 */
int
hgjoin(unsigned ifnum, IPaddr ipa, Bool islocal)
{
	struct	hg	*phg;
	int		i;

	if (!IP_CLASSD(ipa))
		return SYSERR;
	/* restrict multicast in multi-homed host to primary interface */
	if (ifnum != NI_PRIMARY)
		return SYSERR;
	wait(HostGroup.hi_mutex);
	if (phg = hglookup(ifnum, ipa)) {
		phg->hg_refs++;
		signal(HostGroup.hi_mutex);
		return OK;	/* already in it */
	}
	signal(HostGroup.hi_mutex);
	/* add to host group and routing tables */
	if (hgadd(ifnum, ipa, islocal) == SYSERR)
		return SYSERR;
	rtadd(ipa, ip_maskall, ipa, 0, NI_LOCAL, RT_INF);
	/*
	 * advertise membership to multicast router(s); don't advertise
	 * 224.0.0.1 (all multicast hosts) membership.
	 */
	if (ipa != ig_allhosts)
		for (i=0; i < IG_NSEND; ++i) {
			igmp(IGT_HREPORT, ifnum, ipa);
			sleep10(IG_DELAY);
		}
	return OK;
}