FreeBSD/sys/netinet6/ip6_output.c
/*
 * Compute IPv6 extension header length.
 */
Compute IPv6 extension header length.
Compute IPv6 extension header length .
int
ip6_optlen(struct inpcb *in6p)
{
	int len;
	if (!in6p->in6p_outputopts)
		return 0;
	len = 0;
#define elen(x) \
    (((struct ip6_ext *)(x)) ? (((struct ip6_ext *)(x))->ip6e_len + 1) << 3 : 0)
	len += elen(in6p->in6p_outputopts->ip6po_hbh);
	if (in6p->in6p_outputopts->ip6po_rthdr)
		len += elen(in6p->in6p_outputopts->ip6po_dest1);
	len += elen(in6p->in6p_outputopts->ip6po_rthdr);
	len += elen(in6p->in6p_outputopts->ip6po_dest2);
	return len;
#undef elen
}
int ip6_optlen ( struct inpcb * in6p ) { int len ; if ( ! in6p -> in6p_outputopts ) return 0 ; len = 0 ; #define elen ( x )  \
    (((struct ip6_ext *)(x)) ? (((struct ip6_ext *)(x))->ip6e_len + 1) << 3 : 0) len += elen ( in6p -> in6p_outputopts -> ip6po_hbh ) ; if ( in6p -> in6p_outputopts -> ip6po_rthdr ) len += elen ( in6p -> in6p_outputopts -> ip6po_dest1 ) ; len += elen ( in6p -> in6p_outputopts -> ip6po_rthdr ) ; len += elen ( in6p -> in6p_outputopts -> ip6po_dest2 ) ; return len ; #undef  elen }
Compute IPv6 extension header length.
Compute IPv6 extension header length .
/* dest1 is valid with rthdr only */