FreeBSD/sys/netinet6/ip6_input.c
/*
 * pull single extension header from mbuf chain.  returns single mbuf that
 * contains the result, or NULL on error.
 */
pull single extension header from mbuf chain.  returns single mbuf that
contains the result, or NULL on error.
pull single extension header from mbuf chain . returns single mbuf that contains the result or NULL on error .
static struct mbuf *
ip6_pullexthdr(struct mbuf *m, size_t off, int nxt)
{
	struct ip6_ext ip6e;
	size_t elen;
	struct mbuf *n;
#ifdef DIAGNOSTIC
	switch (nxt) {
	case IPPROTO_DSTOPTS:
	case IPPROTO_ROUTING:
	case IPPROTO_HOPOPTS:
	case IPPROTO_AH: 
		break;
	default:
		printf("ip6_pullexthdr: invalid nxt=%d\n", nxt);
	}
#endif
	m_copydata(m, off, sizeof(ip6e), (caddr_t)&ip6e);
	if (nxt == IPPROTO_AH)
		elen = (ip6e.ip6e_len + 2) << 2;
	else
		elen = (ip6e.ip6e_len + 1) << 3;
	if (elen > MLEN)
		n = m_getcl(M_NOWAIT, MT_DATA, 0);
	else
		n = m_get(M_NOWAIT, MT_DATA);
	if (n == NULL)
		return NULL;
	m_copydata(m, off, elen, mtod(n, caddr_t));
	n->m_len = elen;
	return n;
}
static struct mbuf * ip6_pullexthdr ( struct mbuf * m , size_t off , int nxt ) { struct ip6_ext ip6e ; size_t elen ; struct mbuf * n ; #ifdef DIAGNOSTIC switch ( nxt ) { case IPPROTO_DSTOPTS : case IPPROTO_ROUTING : case IPPROTO_HOPOPTS : case IPPROTO_AH : break ; default : printf ( " \n " , nxt ) ; } #endif m_copydata ( m , off , sizeof ( ip6e ) , ( caddr_t ) & ip6e ) ; if ( nxt == IPPROTO_AH ) elen = ( ip6e . ip6e_len + 2 ) << 2 ; else elen = ( ip6e . ip6e_len + 1 ) << 3 ; if ( elen > MLEN ) n = m_getcl ( M_NOWAIT , MT_DATA , 0 ) ; else n = m_get ( M_NOWAIT , MT_DATA ) ; if ( n == NULL ) return NULL ; m_copydata ( m , off , elen , mtod ( n , caddr_t ) ) ; n -> m_len = elen ; return n ; }
pull single extension header from mbuf chain.
pull single extension header from mbuf chain .
/* is it possible? */