FreeBSD/sbin/routed/rdisc.c
/* dump an ICMP Router Discovery Advertisement Message
 */
dump an ICMP Router Discovery Advertisement Message
dump an ICMP Router Discovery Advertisement Message
static void
trace_rdisc(const char	*act,
	    naddr	from,
	    naddr	to,
	    struct interface *ifp,
	    union ad_u	*p,
	    u_int	len)
{
	int i;
	n_long *wp, *lim;
	if (!TRACEPACKETS || ftrace == NULL)
		return;
	lastlog();
	if (p->icmp.icmp_type == ICMP_ROUTERADVERT) {
		(void)fprintf(ftrace, "%s Router Ad"
			      " from %s to %s via %s life=%d\n",
			      act, naddr_ntoa(from), naddr_ntoa(to),
			      ifp ? ifp->int_name : "?",
			      ntohs(p->ad.icmp_ad_life));
		if (!TRACECONTENTS)
			return;
		wp = &p->ad.icmp_ad_info[0].icmp_ad_addr;
		lim = &wp[(len - sizeof(p->ad)) / sizeof(*wp)];
		for (i = 0; i < p->ad.icmp_ad_num && wp <= lim; i++) {
			(void)fprintf(ftrace, "\t%s preference=%d",
				      naddr_ntoa(wp[0]), (int)ntohl(wp[1]));
			wp += p->ad.icmp_ad_asize;
		}
		(void)fputc('\n',ftrace);
	} else {
		trace_act("%s Router Solic. from %s to %s via %s value=%#x",
			  act, naddr_ntoa(from), naddr_ntoa(to),
			  ifp ? ifp->int_name : "?",
			  (int)ntohl(p->so.icmp_so_rsvd));
	}
}
static void trace_rdisc ( const char * act , naddr from , naddr to , struct interface * ifp , union ad_u * p , u_int len ) { int i ; n_long * wp , * lim ; if ( ! TRACEPACKETS || ftrace == NULL ) return ; lastlog ( ) ; if ( p -> icmp . icmp_type == ICMP_ROUTERADVERT ) { ( void ) fprintf ( ftrace , " " " \n " , act , naddr_ntoa ( from ) , naddr_ntoa ( to ) , ifp ? ifp -> int_name : " " , ntohs ( p -> ad . icmp_ad_life ) ) ; if ( ! TRACECONTENTS ) return ; wp = & p -> ad . icmp_ad_info [ 0 ] . icmp_ad_addr ; lim = & wp [ ( len - sizeof ( p -> ad ) ) / sizeof ( * wp ) ] ; for ( i = 0 ; i < p -> ad . icmp_ad_num && wp <= lim ; i ++ ) { ( void ) fprintf ( ftrace , " \t " , naddr_ntoa ( wp [ 0 ] ) , ( int ) ntohl ( wp [ 1 ] ) ) ; wp += p -> ad . icmp_ad_asize ; } ( void ) fputc ( ' \n ' , ftrace ) ; } else { trace_act ( " " , act , naddr_ntoa ( from ) , naddr_ntoa ( to ) , ifp ? ifp -> int_name : " " , ( int ) ntohl ( p -> so . icmp_so_rsvd ) ) ; } }
dump an ICMP Router Discovery Advertisement Message
dump an ICMP Router Discovery Advertisement Message