int in6_pcballoc(struct socket *so, void *v) { struct inpcbtable *table = v; struct in6pcb *in6p; int s; #if defined(IPSEC) int error; #endif s = splnet(); in6p = pool_get(&in6pcb_pool, PR_NOWAIT); splx(s); if (in6p == NULL) return (ENOBUFS); memset((void *)in6p, 0, sizeof(*in6p)); in6p->in6p_af = AF_INET6; in6p->in6p_table = table; in6p->in6p_socket = so; in6p->in6p_hops = -1; /* use kernel default */ in6p->in6p_icmp6filt = NULL; in6p->in6p_portalgo = PORTALGO_DEFAULT; in6p->in6p_bindportonsend = false; #if defined(IPSEC) error = ipsec_init_pcbpolicy(so, &in6p->in6p_sp); if (error != 0) { s = splnet(); pool_put(&in6pcb_pool, in6p); splx(s); return error; } #endif /* IPSEC */ s = splnet(); CIRCLEQ_INSERT_HEAD(&table->inpt_queue, (struct inpcb_hdr*)in6p, inph_queue); LIST_INSERT_HEAD(IN6PCBHASH_PORT(table, in6p->in6p_lport), &in6p->in6p_head, inph_lhash); in6_pcbstate(in6p, IN6P_ATTACHED); splx(s); if (ip6_v6only) in6p->in6p_flags |= IN6P_IPV6_V6ONLY; so->so_pcb = (void *)in6p; return (0); }
int in_pcballoc(struct socket *so, void *v) { struct inpcbtable *table = v; struct inpcb *inp; int s; #if defined(KAME_IPSEC) || defined(FAST_IPSEC) int error; #endif s = splnet(); inp = pool_get(&inpcb_pool, PR_NOWAIT); splx(s); if (inp == NULL) return (ENOBUFS); memset(inp, 0, sizeof(*inp)); inp->inp_af = AF_INET; inp->inp_table = table; inp->inp_socket = so; inp->inp_errormtu = -1; inp->inp_rfc6056algo = RFC6056_ALGO_DEFAULT; inp->inp_bindportonsend = false; #if defined(KAME_IPSEC) || defined(FAST_IPSEC) error = ipsec_init_pcbpolicy(so, &inp->inp_sp); if (error != 0) { s = splnet(); pool_put(&inpcb_pool, inp); splx(s); return error; } #endif so->so_pcb = inp; s = splnet(); CIRCLEQ_INSERT_HEAD(&table->inpt_queue, &inp->inp_head, inph_queue); LIST_INSERT_HEAD(INPCBHASH_PORT(table, inp->inp_lport), &inp->inp_head, inph_lhash); in_pcbstate(inp, INP_ATTACHED); splx(s); return (0); }