FreeBSD/sys/netinet6/ip6_output.c
/*
 * Set up IP6 options in pcb for insertion in output packets or
 * specifying behavior of outgoing packets.
 */
Set up IP6 options in pcb for insertion in output packets or
specifying behavior of outgoing packets.
Set up IP6 options in pcb for insertion in output packets or specifying behavior of outgoing packets .
static int
ip6_pcbopts(struct ip6_pktopts **pktopt, struct mbuf *m,
    struct socket *so, struct sockopt *sopt)
{
	struct ip6_pktopts *opt = *pktopt;
	int error = 0;
	struct thread *td = sopt->sopt_td;
	if (opt) {
#ifdef DIAGNOSTIC
		if (opt->ip6po_pktinfo || opt->ip6po_nexthop ||
		    opt->ip6po_hbh || opt->ip6po_dest1 || opt->ip6po_dest2 ||
		    opt->ip6po_rhinfo.ip6po_rhi_rthdr)
			printf("ip6_pcbopts: all specified options are cleared.\n");
#endif
		ip6_clearpktopts(opt, -1);
	} else
		opt = malloc(sizeof(*opt), M_IP6OPT, M_WAITOK);
	*pktopt = NULL;
	if (!m || m->m_len == 0) {
		free(opt, M_IP6OPT);
		return (0);
	}
	if ((error = ip6_setpktopts(m, opt, NULL, (td != NULL) ?
	    td->td_ucred : NULL, so->so_proto->pr_protocol)) != 0) {
		ip6_clearpktopts(opt, -1); 
		free(opt, M_IP6OPT);
		return (error);
	}
	*pktopt = opt;
	return (0);
}
static int ip6_pcbopts ( struct ip6_pktopts * * pktopt , struct mbuf * m , struct socket * so , struct sockopt * sopt ) { struct ip6_pktopts * opt = * pktopt ; int error = 0 ; struct thread * td = sopt -> sopt_td ; if ( opt ) { #ifdef DIAGNOSTIC if ( opt -> ip6po_pktinfo || opt -> ip6po_nexthop || opt -> ip6po_hbh || opt -> ip6po_dest1 || opt -> ip6po_dest2 || opt -> ip6po_rhinfo . ip6po_rhi_rthdr ) printf ( " \n " ) ; #endif ip6_clearpktopts ( opt , -1 ) ; } else opt = malloc ( sizeof ( * opt ) , M_IP6OPT , M_WAITOK ) ; * pktopt = NULL ; if ( ! m || m -> m_len == 0 ) { free ( opt , M_IP6OPT ) ; return ( 0 ) ; } if ( ( error = ip6_setpktopts ( m , opt , NULL , ( td != NULL ) ? td -> td_ucred : NULL , so -> so_proto -> pr_protocol ) ) != 0 ) { ip6_clearpktopts ( opt , -1 ) ; free ( opt , M_IP6OPT ) ; return ( error ) ; } * pktopt = opt ; return ( 0 ) ; }
Set up IP6 options in pcb for insertion in output packets or
 specifying behavior of outgoing packets.
Set up IP6 options in pcb for insertion in output packets or specifying behavior of outgoing packets .
/* turn off any old options. */ /*
		 * Only turning off any previous options, regardless of
		 * whether the opt is just created or given.
		 */ /*  set options specified by user. */ /* XXX: discard all options */