MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sctp6_attach

Function sctp6_attach

freebsd/netinet6/sctp6_usrreq.c:511–549  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

509}
510
511static int
512sctp6_attach(struct socket *so, int proto SCTP_UNUSED, struct thread *p SCTP_UNUSED)
513{
514 int error;
515 struct sctp_inpcb *inp;
516 uint32_t vrf_id = SCTP_DEFAULT_VRFID;
517
518 inp = (struct sctp_inpcb *)so->so_pcb;
519 if (inp != NULL) {
520 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL);
521 return (EINVAL);
522 }
523
524 if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
525 error = SCTP_SORESERVE(so, SCTP_BASE_SYSCTL(sctp_sendspace), SCTP_BASE_SYSCTL(sctp_recvspace));
526 if (error)
527 return (error);
528 }
529 error = sctp_inpcb_alloc(so, vrf_id);
530 if (error)
531 return (error);
532 inp = (struct sctp_inpcb *)so->so_pcb;
533 SCTP_INP_WLOCK(inp);
534 inp->sctp_flags |= SCTP_PCB_FLAGS_BOUND_V6; /* I'm v6! */
535
536 inp->ip_inp.inp.inp_vflag |= INP_IPV6;
537 inp->ip_inp.inp.in6p_hops = -1; /* use kernel default */
538 inp->ip_inp.inp.in6p_cksum = -1; /* just to be sure */
539#ifdef INET
540 /*
541 * XXX: ugly!! IPv4 TTL initialization is necessary for an IPv6
542 * socket as well, because the socket may be bound to an IPv6
543 * wildcard address, which may match an IPv4-mapped IPv6 address.
544 */
545 inp->ip_inp.inp.inp_ip_ttl = MODULE_GLOBAL(ip_defttl);
546#endif
547 SCTP_INP_WUNLOCK(inp);
548 return (0);
549}
550
551static int
552sctp6_bind(struct socket *so, struct sockaddr *addr, struct thread *p)

Callers

nothing calls this directly

Calls 1

sctp_inpcb_allocFunction · 0.85

Tested by

no test coverage detected