FreeBSD/sbin/routed/rdisc.c
/* check the IP header of a possible Router Discovery ICMP packet */
check the IP header of a possible Router Discovery ICMP packet
check the IP header of a possible Router Discovery ICMP packet
static struct interface *		
ck_icmp(const char *act,
	naddr	from,
	struct interface *ifp,
	naddr	to,
	union ad_u *p,
	u_int	len)
{
	const char *type;
	if (p->icmp.icmp_type == ICMP_ROUTERADVERT) {
		type = "advertisement";
	} else if (p->icmp.icmp_type == ICMP_ROUTERSOLICIT) {
		type = "solicitation";
	} else {
		return 0;
	}
	if (p->icmp.icmp_code != 0) {
		trace_pkt("unrecognized ICMP Router %s code=%d from %s to %s",
			  type, p->icmp.icmp_code,
			  naddr_ntoa(from), naddr_ntoa(to));
		return 0;
	}
	trace_rdisc(act, from, to, ifp, p, len);
	if (ifp == NULL)
		trace_pkt("unknown interface for router-discovery %s"
			  " from %s to %s",
			  type, naddr_ntoa(from), naddr_ntoa(to));
	return ifp;
}
static struct interface * ck_icmp ( const char * act , naddr from , struct interface * ifp , naddr to , union ad_u * p , u_int len ) { const char * type ; if ( p -> icmp . icmp_type == ICMP_ROUTERADVERT ) { type = " " ; } else if ( p -> icmp . icmp_type == ICMP_ROUTERSOLICIT ) { type = " " ; } else { return 0 ; } if ( p -> icmp . icmp_code != 0 ) { trace_pkt ( " " , type , p -> icmp . icmp_code , naddr_ntoa ( from ) , naddr_ntoa ( to ) ) ; return 0 ; } trace_rdisc ( act , from , to , ifp , p , len ) ; if ( ifp == NULL ) trace_pkt ( " " " " , type , naddr_ntoa ( from ) , naddr_ntoa ( to ) ) ; return ifp ; }
check the IP header of a possible Router Discovery ICMP packet
check the IP header of a possible Router Discovery ICMP packet
/* 0 if bad */