1 /*- 2 * Copyright (c) 2001-2007, Cisco Systems, Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * 7 * a) Redistributions of source code must retain the above copyright notice, 8 * this list of conditions and the following disclaimer. 9 * 10 * b) Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in 12 * the documentation and/or other materials provided with the distribution. 13 * 14 * c) Neither the name of Cisco Systems, Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived 16 * from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 28 * THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 /* $KAME: sctp6_usrreq.c,v 1.38 2005/08/24 08:08:56 suz Exp $ */ 31 #include <sys/cdefs.h> 32 __FBSDID("$FreeBSD$"); 33 34 35 #include <netinet/sctp_os.h> 36 #include <sys/proc.h> 37 #include <netinet/sctp_pcb.h> 38 #include <netinet/sctp_header.h> 39 #include <netinet/sctp_var.h> 40 #if defined(INET6) 41 #include <netinet6/sctp6_var.h> 42 #endif 43 #include <netinet/sctp_sysctl.h> 44 #include <netinet/sctp_output.h> 45 #include <netinet/sctp_uio.h> 46 #include <netinet/sctp_asconf.h> 47 #include <netinet/sctputil.h> 48 #include <netinet/sctp_indata.h> 49 #include <netinet/sctp_timer.h> 50 #include <netinet/sctp_auth.h> 51 #include <netinet/sctp_input.h> 52 #include <netinet/sctp_output.h> 53 54 55 extern struct protosw inetsw[]; 56 57 58 59 60 int 61 sctp6_input(i_pak, offp, proto) 62 struct mbuf **i_pak; 63 int *offp; 64 int proto; 65 { 66 struct mbuf *m; 67 struct ip6_hdr *ip6; 68 struct sctphdr *sh; 69 struct sctp_inpcb *in6p = NULL; 70 struct sctp_nets *net; 71 int refcount_up = 0; 72 uint32_t check, calc_check, vrf_id; 73 struct inpcb *in6p_ip; 74 struct sctp_chunkhdr *ch; 75 int length, mlen, offset, iphlen; 76 uint8_t ecn_bits; 77 struct sctp_tcb *stcb = NULL; 78 int off = *offp; 79 80 vrf_id = SCTP_DEFAULT_VRFID; 81 m = SCTP_HEADER_TO_CHAIN(*i_pak); 82 83 84 ip6 = mtod(m, struct ip6_hdr *); 85 /* Ensure that (sctphdr + sctp_chunkhdr) in a row. */ 86 IP6_EXTHDR_GET(sh, struct sctphdr *, m, off, sizeof(*sh) + sizeof(*ch)); 87 if (sh == NULL) { 88 SCTP_STAT_INCR(sctps_hdrops); 89 return IPPROTO_DONE; 90 } 91 ch = (struct sctp_chunkhdr *)((caddr_t)sh + sizeof(struct sctphdr)); 92 iphlen = off; 93 offset = iphlen + sizeof(*sh) + sizeof(*ch); 94 95 #if defined(NFAITH) && NFAITH > 0 96 97 if (faithprefix_p != NULL && (*faithprefix_p) (&ip6->ip6_dst)) { 98 /* XXX send icmp6 host/port unreach? */ 99 goto bad; 100 } 101 #endif /* NFAITH defined and > 0 */ 102 SCTP_STAT_INCR(sctps_recvpackets); 103 SCTP_STAT_INCR_COUNTER64(sctps_inpackets); 104 #ifdef SCTP_DEBUG 105 if (sctp_debug_on & SCTP_DEBUG_INPUT1) { 106 printf("V6 input gets a packet iphlen:%d pktlen:%d\n", iphlen, 107 SCTP_HEADER_LEN((*i_pak)) 108 ); 109 } 110 #endif 111 if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) { 112 /* No multi-cast support in SCTP */ 113 goto bad; 114 } 115 /* destination port of 0 is illegal, based on RFC2960. */ 116 if (sh->dest_port == 0) 117 goto bad; 118 if ((sctp_no_csum_on_loopback == 0) || 119 (!SCTP_IS_IT_LOOPBACK(m))) { 120 /* 121 * we do NOT validate things from the loopback if the sysctl 122 * is set to 1. 123 */ 124 check = sh->checksum; /* save incoming checksum */ 125 if ((check == 0) && (sctp_no_csum_on_loopback)) { 126 /* 127 * special hook for where we got a local address 128 * somehow routed across a non IFT_LOOP type 129 * interface 130 */ 131 if (IN6_ARE_ADDR_EQUAL(&ip6->ip6_src, &ip6->ip6_dst)) 132 goto sctp_skip_csum; 133 } 134 sh->checksum = 0; /* prepare for calc */ 135 calc_check = sctp_calculate_sum(m, &mlen, iphlen); 136 if (calc_check != check) { 137 #ifdef SCTP_DEBUG 138 if (sctp_debug_on & SCTP_DEBUG_INPUT1) { 139 printf("Bad CSUM on SCTP packet calc_check:%x check:%x m:%p mlen:%d iphlen:%d\n", 140 calc_check, check, m, 141 mlen, iphlen); 142 } 143 #endif 144 stcb = sctp_findassociation_addr(m, iphlen, offset - sizeof(*ch), 145 sh, ch, &in6p, &net, vrf_id); 146 /* in6p's ref-count increased && stcb locked */ 147 if ((in6p) && (stcb)) { 148 sctp_send_packet_dropped(stcb, net, m, iphlen, 1); 149 sctp_chunk_output((struct sctp_inpcb *)in6p, stcb, 2); 150 } else if ((in6p != NULL) && (stcb == NULL)) { 151 refcount_up = 1; 152 } 153 SCTP_STAT_INCR(sctps_badsum); 154 SCTP_STAT_INCR_COUNTER32(sctps_checksumerrors); 155 goto bad; 156 } 157 sh->checksum = calc_check; 158 } 159 sctp_skip_csum: 160 net = NULL; 161 /* 162 * Locate pcb and tcb for datagram sctp_findassociation_addr() wants 163 * IP/SCTP/first chunk header... 164 */ 165 stcb = sctp_findassociation_addr(m, iphlen, offset - sizeof(*ch), 166 sh, ch, &in6p, &net, vrf_id); 167 /* in6p's ref-count increased */ 168 if (in6p == NULL) { 169 struct sctp_init_chunk *init_chk, chunk_buf; 170 171 SCTP_STAT_INCR(sctps_noport); 172 if (ch->chunk_type == SCTP_INITIATION) { 173 /* 174 * we do a trick here to get the INIT tag, dig in 175 * and get the tag from the INIT and put it in the 176 * common header. 177 */ 178 init_chk = (struct sctp_init_chunk *)sctp_m_getptr(m, 179 iphlen + sizeof(*sh), sizeof(*init_chk), 180 (uint8_t *) & chunk_buf); 181 sh->v_tag = init_chk->init.initiate_tag; 182 } 183 if (ch->chunk_type == SCTP_SHUTDOWN_ACK) { 184 sctp_send_shutdown_complete2(m, iphlen, sh); 185 goto bad; 186 } 187 if (ch->chunk_type == SCTP_SHUTDOWN_COMPLETE) { 188 goto bad; 189 } 190 if (ch->chunk_type != SCTP_ABORT_ASSOCIATION) 191 sctp_send_abort(m, iphlen, sh, 0, NULL); 192 goto bad; 193 } else if (stcb == NULL) { 194 refcount_up = 1; 195 } 196 in6p_ip = (struct inpcb *)in6p; 197 #ifdef IPSEC 198 /* 199 * Check AH/ESP integrity. 200 */ 201 if (in6p_ip && (ipsec6_in_reject(m, in6p_ip))) { 202 /* XXX */ 203 ipsec6stat.in_polvio++; 204 goto bad; 205 } 206 #endif /* IPSEC */ 207 208 /* 209 * CONTROL chunk processing 210 */ 211 offset -= sizeof(*ch); 212 ecn_bits = ((ntohl(ip6->ip6_flow) >> 20) & 0x000000ff); 213 214 /* Length now holds the total packet length payload + iphlen */ 215 length = ntohs(ip6->ip6_plen) + iphlen; 216 217 (void)sctp_common_input_processing(&m, iphlen, offset, length, sh, ch, 218 in6p, stcb, net, ecn_bits); 219 /* inp's ref-count reduced && stcb unlocked */ 220 /* XXX this stuff below gets moved to appropriate parts later... */ 221 if (m) 222 m_freem(m); 223 if ((in6p) && refcount_up) { 224 /* reduce ref-count */ 225 SCTP_INP_WLOCK(in6p); 226 SCTP_INP_DECR_REF(in6p); 227 SCTP_INP_WUNLOCK(in6p); 228 } 229 return IPPROTO_DONE; 230 231 bad: 232 if (stcb) 233 SCTP_TCB_UNLOCK(stcb); 234 235 if ((in6p) && refcount_up) { 236 /* reduce ref-count */ 237 SCTP_INP_WLOCK(in6p); 238 SCTP_INP_DECR_REF(in6p); 239 SCTP_INP_WUNLOCK(in6p); 240 } 241 if (m) 242 m_freem(m); 243 return IPPROTO_DONE; 244 } 245 246 247 static void 248 sctp6_notify_mbuf(struct sctp_inpcb *inp, 249 struct icmp6_hdr *icmp6, 250 struct sctphdr *sh, 251 struct sctp_tcb *stcb, 252 struct sctp_nets *net) 253 { 254 uint32_t nxtsz; 255 256 if ((inp == NULL) || (stcb == NULL) || (net == NULL) || 257 (icmp6 == NULL) || (sh == NULL)) { 258 goto out; 259 } 260 /* First do we even look at it? */ 261 if (ntohl(sh->v_tag) != (stcb->asoc.peer_vtag)) 262 goto out; 263 264 if (icmp6->icmp6_type != ICMP6_PACKET_TOO_BIG) { 265 /* not PACKET TO BIG */ 266 goto out; 267 } 268 /* 269 * ok we need to look closely. We could even get smarter and look at 270 * anyone that we sent to in case we get a different ICMP that tells 271 * us there is no way to reach a host, but for this impl, all we 272 * care about is MTU discovery. 273 */ 274 nxtsz = ntohl(icmp6->icmp6_mtu); 275 /* Stop any PMTU timer */ 276 sctp_timer_stop(SCTP_TIMER_TYPE_PATHMTURAISE, inp, stcb, NULL, SCTP_FROM_SCTP6_USRREQ + SCTP_LOC_1); 277 278 /* Adjust destination size limit */ 279 if (net->mtu > nxtsz) { 280 net->mtu = nxtsz; 281 } 282 /* now what about the ep? */ 283 if (stcb->asoc.smallest_mtu > nxtsz) { 284 struct sctp_tmit_chunk *chk; 285 286 /* Adjust that too */ 287 stcb->asoc.smallest_mtu = nxtsz; 288 /* now off to subtract IP_DF flag if needed */ 289 290 TAILQ_FOREACH(chk, &stcb->asoc.send_queue, sctp_next) { 291 if ((uint32_t) (chk->send_size + IP_HDR_SIZE) > nxtsz) { 292 chk->flags |= CHUNK_FLAGS_FRAGMENT_OK; 293 } 294 } 295 TAILQ_FOREACH(chk, &stcb->asoc.sent_queue, sctp_next) { 296 if ((uint32_t) (chk->send_size + IP_HDR_SIZE) > nxtsz) { 297 /* 298 * For this guy we also mark for immediate 299 * resend since we sent to big of chunk 300 */ 301 chk->flags |= CHUNK_FLAGS_FRAGMENT_OK; 302 if (chk->sent != SCTP_DATAGRAM_RESEND) 303 stcb->asoc.sent_queue_retran_cnt++; 304 chk->sent = SCTP_DATAGRAM_RESEND; 305 chk->rec.data.doing_fast_retransmit = 0; 306 307 chk->sent = SCTP_DATAGRAM_RESEND; 308 /* Clear any time so NO RTT is being done */ 309 chk->sent_rcv_time.tv_sec = 0; 310 chk->sent_rcv_time.tv_usec = 0; 311 stcb->asoc.total_flight -= chk->send_size; 312 net->flight_size -= chk->send_size; 313 } 314 } 315 } 316 sctp_timer_start(SCTP_TIMER_TYPE_PATHMTURAISE, inp, stcb, NULL); 317 out: 318 if (stcb) 319 SCTP_TCB_UNLOCK(stcb); 320 } 321 322 323 void 324 sctp6_ctlinput(cmd, pktdst, d) 325 int cmd; 326 struct sockaddr *pktdst; 327 void *d; 328 { 329 struct sctphdr sh; 330 struct ip6ctlparam *ip6cp = NULL; 331 uint32_t vrf_id; 332 int cm; 333 334 vrf_id = SCTP_DEFAULT_VRFID; 335 336 if (pktdst->sa_family != AF_INET6 || 337 pktdst->sa_len != sizeof(struct sockaddr_in6)) 338 return; 339 340 if ((unsigned)cmd >= PRC_NCMDS) 341 return; 342 if (PRC_IS_REDIRECT(cmd)) { 343 d = NULL; 344 } else if (inet6ctlerrmap[cmd] == 0) { 345 return; 346 } 347 /* if the parameter is from icmp6, decode it. */ 348 if (d != NULL) { 349 ip6cp = (struct ip6ctlparam *)d; 350 } else { 351 ip6cp = (struct ip6ctlparam *)NULL; 352 } 353 354 if (ip6cp) { 355 /* 356 * XXX: We assume that when IPV6 is non NULL, M and OFF are 357 * valid. 358 */ 359 /* check if we can safely examine src and dst ports */ 360 struct sctp_inpcb *inp = NULL; 361 struct sctp_tcb *stcb = NULL; 362 struct sctp_nets *net = NULL; 363 struct sockaddr_in6 final; 364 365 if (ip6cp->ip6c_m == NULL) 366 return; 367 368 bzero(&sh, sizeof(sh)); 369 bzero(&final, sizeof(final)); 370 inp = NULL; 371 net = NULL; 372 m_copydata(ip6cp->ip6c_m, ip6cp->ip6c_off, sizeof(sh), 373 (caddr_t)&sh); 374 ip6cp->ip6c_src->sin6_port = sh.src_port; 375 final.sin6_len = sizeof(final); 376 final.sin6_family = AF_INET6; 377 final.sin6_addr = ((struct sockaddr_in6 *)pktdst)->sin6_addr; 378 final.sin6_port = sh.dest_port; 379 stcb = sctp_findassociation_addr_sa((struct sockaddr *)ip6cp->ip6c_src, 380 (struct sockaddr *)&final, 381 &inp, &net, 1, vrf_id); 382 /* inp's ref-count increased && stcb locked */ 383 if (stcb != NULL && inp && (inp->sctp_socket != NULL)) { 384 if (cmd == PRC_MSGSIZE) { 385 sctp6_notify_mbuf(inp, 386 ip6cp->ip6c_icmp6, 387 &sh, 388 stcb, 389 net); 390 /* inp's ref-count reduced && stcb unlocked */ 391 } else { 392 if (cmd == PRC_HOSTDEAD) { 393 cm = EHOSTUNREACH; 394 } else { 395 cm = inet6ctlerrmap[cmd]; 396 } 397 sctp_notify(inp, cm, &sh, 398 (struct sockaddr *)&final, 399 stcb, net); 400 /* inp's ref-count reduced && stcb unlocked */ 401 } 402 } else { 403 if (PRC_IS_REDIRECT(cmd) && inp) { 404 in6_rtchange((struct in6pcb *)inp, 405 inet6ctlerrmap[cmd]); 406 } 407 if (inp) { 408 /* reduce inp's ref-count */ 409 SCTP_INP_WLOCK(inp); 410 SCTP_INP_DECR_REF(inp); 411 SCTP_INP_WUNLOCK(inp); 412 } 413 if (stcb) 414 SCTP_TCB_UNLOCK(stcb); 415 } 416 } 417 } 418 419 /* 420 * this routine can probably be collasped into the one in sctp_userreq.c 421 * since they do the same thing and now we lookup with a sockaddr 422 */ 423 static int 424 sctp6_getcred(SYSCTL_HANDLER_ARGS) 425 { 426 struct xucred xuc; 427 struct sockaddr_in6 addrs[2]; 428 struct sctp_inpcb *inp; 429 struct sctp_nets *net; 430 struct sctp_tcb *stcb; 431 int error; 432 uint32_t vrf_id; 433 434 vrf_id = SCTP_DEFAULT_VRFID; 435 436 /* 437 * XXXRW: Other instances of getcred use SUSER_ALLOWJAIL, as socket 438 * visibility is scoped using cr_canseesocket(), which it is not 439 * here. 440 */ 441 error = priv_check_cred(req->td->td_ucred, PRIV_NETINET_RESERVEDPORT, 442 0); 443 if (error) 444 return (error); 445 446 if (req->newlen != sizeof(addrs)) 447 return (EINVAL); 448 if (req->oldlen != sizeof(struct ucred)) 449 return (EINVAL); 450 error = SYSCTL_IN(req, addrs, sizeof(addrs)); 451 if (error) 452 return (error); 453 454 stcb = sctp_findassociation_addr_sa(sin6tosa(&addrs[0]), 455 sin6tosa(&addrs[1]), 456 &inp, &net, 1, vrf_id); 457 if (stcb == NULL || inp == NULL || inp->sctp_socket == NULL) { 458 if ((inp != NULL) && (stcb == NULL)) { 459 /* reduce ref-count */ 460 SCTP_INP_WLOCK(inp); 461 SCTP_INP_DECR_REF(inp); 462 goto cred_can_cont; 463 } 464 error = ENOENT; 465 goto out; 466 } 467 SCTP_TCB_UNLOCK(stcb); 468 /* 469 * We use the write lock here, only since in the error leg we need 470 * it. If we used RLOCK, then we would have to 471 * wlock/decr/unlock/rlock. Which in theory could create a hole. 472 * Better to use higher wlock. 473 */ 474 SCTP_INP_WLOCK(inp); 475 cred_can_cont: 476 error = cr_canseesocket(req->td->td_ucred, inp->sctp_socket); 477 if (error) { 478 SCTP_INP_WUNLOCK(inp); 479 goto out; 480 } 481 cru2x(inp->sctp_socket->so_cred, &xuc); 482 SCTP_INP_WUNLOCK(inp); 483 error = SYSCTL_OUT(req, &xuc, sizeof(struct xucred)); 484 out: 485 return (error); 486 } 487 488 SYSCTL_PROC(_net_inet6_sctp6, OID_AUTO, getcred, CTLTYPE_OPAQUE | CTLFLAG_RW, 489 0, 0, 490 sctp6_getcred, "S,ucred", "Get the ucred of a SCTP6 connection"); 491 492 493 /* This is the same as the sctp_abort() could be made common */ 494 static void 495 sctp6_abort(struct socket *so) 496 { 497 struct sctp_inpcb *inp; 498 uint32_t flags; 499 500 inp = (struct sctp_inpcb *)so->so_pcb; 501 if (inp == 0) 502 return; 503 sctp_must_try_again: 504 flags = inp->sctp_flags; 505 #ifdef SCTP_LOG_CLOSING 506 sctp_log_closing(inp, NULL, 17); 507 #endif 508 if (((flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) && 509 (atomic_cmpset_int(&inp->sctp_flags, flags, (flags | SCTP_PCB_FLAGS_SOCKET_GONE | SCTP_PCB_FLAGS_CLOSE_IP)))) { 510 #ifdef SCTP_LOG_CLOSING 511 sctp_log_closing(inp, NULL, 16); 512 #endif 513 sctp_inpcb_free(inp, 1, 0); 514 SOCK_LOCK(so); 515 SCTP_SB_CLEAR(so->so_snd); 516 /* 517 * same for the rcv ones, they are only here for the 518 * accounting/select. 519 */ 520 SCTP_SB_CLEAR(so->so_rcv); 521 /* Now null out the reference, we are completely detached. */ 522 so->so_pcb = NULL; 523 SOCK_UNLOCK(so); 524 } else { 525 flags = inp->sctp_flags; 526 if ((flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) { 527 goto sctp_must_try_again; 528 } 529 } 530 return; 531 } 532 533 static int 534 sctp6_attach(struct socket *so, int proto, struct thread *p) 535 { 536 struct in6pcb *inp6; 537 int error; 538 struct sctp_inpcb *inp; 539 540 inp = (struct sctp_inpcb *)so->so_pcb; 541 if (inp != NULL) 542 return EINVAL; 543 544 if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) { 545 error = SCTP_SORESERVE(so, sctp_sendspace, sctp_recvspace); 546 if (error) 547 return error; 548 } 549 error = sctp_inpcb_alloc(so); 550 if (error) 551 return error; 552 inp = (struct sctp_inpcb *)so->so_pcb; 553 inp->sctp_flags |= SCTP_PCB_FLAGS_BOUND_V6; /* I'm v6! */ 554 inp6 = (struct in6pcb *)inp; 555 556 inp6->inp_vflag |= INP_IPV6; 557 inp6->in6p_hops = -1; /* use kernel default */ 558 inp6->in6p_cksum = -1; /* just to be sure */ 559 #ifdef INET 560 /* 561 * XXX: ugly!! IPv4 TTL initialization is necessary for an IPv6 562 * socket as well, because the socket may be bound to an IPv6 563 * wildcard address, which may match an IPv4-mapped IPv6 address. 564 */ 565 inp6->inp_ip_ttl = ip_defttl; 566 #endif 567 /* 568 * Hmm what about the IPSEC stuff that is missing here but in 569 * sctp_attach()? 570 */ 571 return 0; 572 } 573 574 static int 575 sctp6_bind(struct socket *so, struct sockaddr *addr, struct thread *p) 576 { 577 struct sctp_inpcb *inp; 578 struct in6pcb *inp6; 579 int error; 580 581 inp = (struct sctp_inpcb *)so->so_pcb; 582 if (inp == 0) 583 return EINVAL; 584 585 inp6 = (struct in6pcb *)inp; 586 inp6->inp_vflag &= ~INP_IPV4; 587 inp6->inp_vflag |= INP_IPV6; 588 if ((addr != NULL) && (SCTP_IPV6_V6ONLY(inp6) == 0)) { 589 if (addr->sa_family == AF_INET) { 590 /* binding v4 addr to v6 socket, so reset flags */ 591 inp6->inp_vflag |= INP_IPV4; 592 inp6->inp_vflag &= ~INP_IPV6; 593 } else { 594 struct sockaddr_in6 *sin6_p; 595 596 sin6_p = (struct sockaddr_in6 *)addr; 597 598 if (IN6_IS_ADDR_UNSPECIFIED(&sin6_p->sin6_addr)) { 599 inp6->inp_vflag |= INP_IPV4; 600 } else if (IN6_IS_ADDR_V4MAPPED(&sin6_p->sin6_addr)) { 601 struct sockaddr_in sin; 602 603 in6_sin6_2_sin(&sin, sin6_p); 604 inp6->inp_vflag |= INP_IPV4; 605 inp6->inp_vflag &= ~INP_IPV6; 606 error = sctp_inpcb_bind(so, (struct sockaddr *)&sin, p); 607 return error; 608 } 609 } 610 } else if (addr != NULL) { 611 /* IPV6_V6ONLY socket */ 612 if (addr->sa_family == AF_INET) { 613 /* can't bind v4 addr to v6 only socket! */ 614 return EINVAL; 615 } else { 616 struct sockaddr_in6 *sin6_p; 617 618 sin6_p = (struct sockaddr_in6 *)addr; 619 620 if (IN6_IS_ADDR_V4MAPPED(&sin6_p->sin6_addr)) 621 /* can't bind v4-mapped addrs either! */ 622 /* NOTE: we don't support SIIT */ 623 return EINVAL; 624 } 625 } 626 error = sctp_inpcb_bind(so, addr, p); 627 return error; 628 } 629 630 631 static void 632 sctp6_close(struct socket *so) 633 { 634 struct sctp_inpcb *inp; 635 uint32_t flags; 636 637 inp = (struct sctp_inpcb *)so->so_pcb; 638 if (inp == 0) 639 return; 640 641 /* 642 * Inform all the lower layer assoc that we are done. 643 */ 644 sctp_must_try_again: 645 flags = inp->sctp_flags; 646 #ifdef SCTP_LOG_CLOSING 647 sctp_log_closing(inp, NULL, 17); 648 #endif 649 if (((flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) && 650 (atomic_cmpset_int(&inp->sctp_flags, flags, (flags | SCTP_PCB_FLAGS_SOCKET_GONE | SCTP_PCB_FLAGS_CLOSE_IP)))) { 651 if (((so->so_options & SO_LINGER) && (so->so_linger == 0)) || 652 (so->so_rcv.sb_cc > 0)) { 653 #ifdef SCTP_LOG_CLOSING 654 sctp_log_closing(inp, NULL, 13); 655 #endif 656 sctp_inpcb_free(inp, 1, 1); 657 } else { 658 #ifdef SCTP_LOG_CLOSING 659 sctp_log_closing(inp, NULL, 14); 660 #endif 661 sctp_inpcb_free(inp, 0, 1); 662 } 663 /* 664 * The socket is now detached, no matter what the state of 665 * the SCTP association. 666 */ 667 SOCK_LOCK(so); 668 SCTP_SB_CLEAR(so->so_snd); 669 /* 670 * same for the rcv ones, they are only here for the 671 * accounting/select. 672 */ 673 SCTP_SB_CLEAR(so->so_rcv); 674 /* Now null out the reference, we are completely detached. */ 675 so->so_pcb = NULL; 676 SOCK_UNLOCK(so); 677 } else { 678 flags = inp->sctp_flags; 679 if ((flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) { 680 goto sctp_must_try_again; 681 } 682 } 683 return; 684 685 } 686 687 /* This could be made common with sctp_detach() since they are identical */ 688 689 static 690 int 691 sctp6_disconnect(struct socket *so) 692 { 693 struct sctp_inpcb *inp; 694 695 inp = (struct sctp_inpcb *)so->so_pcb; 696 if (inp == NULL) { 697 return (ENOTCONN); 698 } 699 SCTP_INP_RLOCK(inp); 700 if (inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) { 701 if (SCTP_LIST_EMPTY(&inp->sctp_asoc_list)) { 702 /* No connection */ 703 SCTP_INP_RUNLOCK(inp); 704 return (ENOTCONN); 705 } else { 706 int some_on_streamwheel = 0; 707 struct sctp_association *asoc; 708 struct sctp_tcb *stcb; 709 710 stcb = LIST_FIRST(&inp->sctp_asoc_list); 711 if (stcb == NULL) { 712 SCTP_INP_RUNLOCK(inp); 713 return (EINVAL); 714 } 715 SCTP_TCB_LOCK(stcb); 716 asoc = &stcb->asoc; 717 if (((so->so_options & SO_LINGER) && 718 (so->so_linger == 0)) || 719 (so->so_rcv.sb_cc > 0)) { 720 if (SCTP_GET_STATE(asoc) != 721 SCTP_STATE_COOKIE_WAIT) { 722 /* Left with Data unread */ 723 struct mbuf *op_err; 724 725 op_err = sctp_generate_invmanparam(SCTP_CAUSE_USER_INITIATED_ABT); 726 sctp_send_abort_tcb(stcb, op_err); 727 SCTP_STAT_INCR_COUNTER32(sctps_aborted); 728 } 729 SCTP_INP_RUNLOCK(inp); 730 if ((SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_OPEN) || 731 (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) { 732 SCTP_STAT_DECR_GAUGE32(sctps_currestab); 733 } 734 sctp_free_assoc(inp, stcb, SCTP_DONOT_SETSCOPE, 735 SCTP_FROM_SCTP6_USRREQ + SCTP_LOC_2); 736 /* No unlock tcb assoc is gone */ 737 return (0); 738 } 739 if (!TAILQ_EMPTY(&asoc->out_wheel)) { 740 /* Check to see if some data queued */ 741 struct sctp_stream_out *outs; 742 743 TAILQ_FOREACH(outs, &asoc->out_wheel, 744 next_spoke) { 745 if (!TAILQ_EMPTY(&outs->outqueue)) { 746 some_on_streamwheel = 1; 747 break; 748 } 749 } 750 } 751 if (TAILQ_EMPTY(&asoc->send_queue) && 752 TAILQ_EMPTY(&asoc->sent_queue) && 753 (some_on_streamwheel == 0)) { 754 /* nothing queued to send, so I'm done... */ 755 if ((SCTP_GET_STATE(asoc) != 756 SCTP_STATE_SHUTDOWN_SENT) && 757 (SCTP_GET_STATE(asoc) != 758 SCTP_STATE_SHUTDOWN_ACK_SENT)) { 759 /* only send SHUTDOWN the first time */ 760 sctp_send_shutdown(stcb, stcb->asoc.primary_destination); 761 sctp_chunk_output(stcb->sctp_ep, stcb, 1); 762 if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) || 763 (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) { 764 SCTP_STAT_DECR_GAUGE32(sctps_currestab); 765 } 766 asoc->state = SCTP_STATE_SHUTDOWN_SENT; 767 sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, 768 stcb->sctp_ep, stcb, 769 asoc->primary_destination); 770 sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, 771 stcb->sctp_ep, stcb, 772 asoc->primary_destination); 773 } 774 } else { 775 /* 776 * we still got (or just got) data to send, 777 * so set SHUTDOWN_PENDING 778 */ 779 /* 780 * XXX sockets draft says that MSG_EOF 781 * should be sent with no data. currently, 782 * we will allow user data to be sent first 783 * and move to SHUTDOWN-PENDING 784 */ 785 asoc->state |= SCTP_STATE_SHUTDOWN_PENDING; 786 } 787 SCTP_TCB_UNLOCK(stcb); 788 SCTP_INP_RUNLOCK(inp); 789 return (0); 790 } 791 } else { 792 /* UDP model does not support this */ 793 SCTP_INP_RUNLOCK(inp); 794 return EOPNOTSUPP; 795 } 796 } 797 798 799 int 800 sctp_sendm(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, 801 struct mbuf *control, struct thread *p); 802 803 804 805 static int 806 sctp6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, 807 struct mbuf *control, struct thread *p) 808 { 809 struct sctp_inpcb *inp; 810 struct inpcb *in_inp; 811 struct in6pcb *inp6; 812 813 #ifdef INET 814 struct sockaddr_in6 *sin6; 815 816 #endif /* INET */ 817 /* No SPL needed since sctp_output does this */ 818 819 inp = (struct sctp_inpcb *)so->so_pcb; 820 if (inp == NULL) { 821 if (control) { 822 m_freem(control); 823 control = NULL; 824 } 825 m_freem(m); 826 return EINVAL; 827 } 828 in_inp = (struct inpcb *)inp; 829 inp6 = (struct in6pcb *)inp; 830 /* 831 * For the TCP model we may get a NULL addr, if we are a connected 832 * socket thats ok. 833 */ 834 if ((inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) && 835 (addr == NULL)) { 836 goto connected_type; 837 } 838 if (addr == NULL) { 839 m_freem(m); 840 if (control) { 841 m_freem(control); 842 control = NULL; 843 } 844 return (EDESTADDRREQ); 845 } 846 #ifdef INET 847 sin6 = (struct sockaddr_in6 *)addr; 848 if (SCTP_IPV6_V6ONLY(inp6)) { 849 /* 850 * if IPV6_V6ONLY flag, we discard datagrams destined to a 851 * v4 addr or v4-mapped addr 852 */ 853 if (addr->sa_family == AF_INET) { 854 return EINVAL; 855 } 856 if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { 857 return EINVAL; 858 } 859 } 860 if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { 861 if (!ip6_v6only) { 862 struct sockaddr_in sin; 863 864 /* convert v4-mapped into v4 addr and send */ 865 in6_sin6_2_sin(&sin, sin6); 866 return sctp_sendm(so, flags, m, (struct sockaddr *)&sin, 867 control, p); 868 } else { 869 /* mapped addresses aren't enabled */ 870 return EINVAL; 871 } 872 } 873 #endif /* INET */ 874 connected_type: 875 /* now what about control */ 876 if (control) { 877 if (inp->control) { 878 printf("huh? control set?\n"); 879 m_freem(inp->control); 880 inp->control = NULL; 881 } 882 inp->control = control; 883 } 884 /* Place the data */ 885 if (inp->pkt) { 886 SCTP_BUF_NEXT(inp->pkt_last) = m; 887 inp->pkt_last = m; 888 } else { 889 inp->pkt_last = inp->pkt = m; 890 } 891 if ( 892 /* FreeBSD and MacOSX uses a flag passed */ 893 ((flags & PRUS_MORETOCOME) == 0) 894 ) { 895 /* 896 * note with the current version this code will only be used 897 * by OpenBSD, NetBSD and FreeBSD have methods for 898 * re-defining sosend() to use sctp_sosend(). One can 899 * optionaly switch back to this code (by changing back the 900 * defininitions but this is not advisable. 901 */ 902 int ret; 903 904 ret = sctp_output(inp, inp->pkt, addr, inp->control, p, flags); 905 inp->pkt = NULL; 906 inp->control = NULL; 907 return (ret); 908 } else { 909 return (0); 910 } 911 } 912 913 static int 914 sctp6_connect(struct socket *so, struct sockaddr *addr, struct thread *p) 915 { 916 uint32_t vrf_id; 917 int error = 0; 918 struct sctp_inpcb *inp; 919 struct in6pcb *inp6; 920 struct sctp_tcb *stcb; 921 922 #ifdef INET 923 struct sockaddr_in6 *sin6; 924 struct sockaddr_storage ss; 925 926 #endif /* INET */ 927 928 inp6 = (struct in6pcb *)so->so_pcb; 929 inp = (struct sctp_inpcb *)so->so_pcb; 930 if (inp == 0) { 931 return (ECONNRESET); /* I made the same as TCP since we are 932 * not setup? */ 933 } 934 vrf_id = inp->def_vrf_id; 935 SCTP_ASOC_CREATE_LOCK(inp); 936 SCTP_INP_RLOCK(inp); 937 if ((inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) == 938 SCTP_PCB_FLAGS_UNBOUND) { 939 /* Bind a ephemeral port */ 940 SCTP_INP_RUNLOCK(inp); 941 error = sctp6_bind(so, NULL, p); 942 if (error) { 943 SCTP_ASOC_CREATE_UNLOCK(inp); 944 945 return (error); 946 } 947 SCTP_INP_RLOCK(inp); 948 } 949 if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) && 950 (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED)) { 951 /* We are already connected AND the TCP model */ 952 SCTP_INP_RUNLOCK(inp); 953 SCTP_ASOC_CREATE_UNLOCK(inp); 954 return (EADDRINUSE); 955 } 956 #ifdef INET 957 sin6 = (struct sockaddr_in6 *)addr; 958 if (SCTP_IPV6_V6ONLY(inp6)) { 959 /* 960 * if IPV6_V6ONLY flag, ignore connections destined to a v4 961 * addr or v4-mapped addr 962 */ 963 if (addr->sa_family == AF_INET) { 964 SCTP_INP_RUNLOCK(inp); 965 SCTP_ASOC_CREATE_UNLOCK(inp); 966 return EINVAL; 967 } 968 if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { 969 SCTP_INP_RUNLOCK(inp); 970 SCTP_ASOC_CREATE_UNLOCK(inp); 971 return EINVAL; 972 } 973 } 974 if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { 975 if (!ip6_v6only) { 976 /* convert v4-mapped into v4 addr */ 977 in6_sin6_2_sin((struct sockaddr_in *)&ss, sin6); 978 addr = (struct sockaddr *)&ss; 979 } else { 980 /* mapped addresses aren't enabled */ 981 SCTP_INP_RUNLOCK(inp); 982 SCTP_ASOC_CREATE_UNLOCK(inp); 983 return EINVAL; 984 } 985 } else 986 #endif /* INET */ 987 addr = addr; /* for true v6 address case */ 988 989 /* Now do we connect? */ 990 if (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) { 991 stcb = LIST_FIRST(&inp->sctp_asoc_list); 992 if (stcb) 993 SCTP_TCB_UNLOCK(stcb); 994 SCTP_INP_RUNLOCK(inp); 995 } else { 996 SCTP_INP_RUNLOCK(inp); 997 SCTP_INP_WLOCK(inp); 998 SCTP_INP_INCR_REF(inp); 999 SCTP_INP_WUNLOCK(inp); 1000 stcb = sctp_findassociation_ep_addr(&inp, addr, NULL, NULL, NULL); 1001 if (stcb == NULL) { 1002 SCTP_INP_WLOCK(inp); 1003 SCTP_INP_DECR_REF(inp); 1004 SCTP_INP_WUNLOCK(inp); 1005 } 1006 } 1007 1008 if (stcb != NULL) { 1009 /* Already have or am bring up an association */ 1010 SCTP_ASOC_CREATE_UNLOCK(inp); 1011 SCTP_TCB_UNLOCK(stcb); 1012 return (EALREADY); 1013 } 1014 /* We are GOOD to go */ 1015 stcb = sctp_aloc_assoc(inp, addr, 1, &error, 0, vrf_id); 1016 SCTP_ASOC_CREATE_UNLOCK(inp); 1017 if (stcb == NULL) { 1018 /* Gak! no memory */ 1019 return (error); 1020 } 1021 if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) { 1022 stcb->sctp_ep->sctp_flags |= SCTP_PCB_FLAGS_CONNECTED; 1023 /* Set the connected flag so we can queue data */ 1024 soisconnecting(so); 1025 } 1026 stcb->asoc.state = SCTP_STATE_COOKIE_WAIT; 1027 SCTP_GETTIME_TIMEVAL(&stcb->asoc.time_entered); 1028 1029 /* initialize authentication parameters for the assoc */ 1030 sctp_initialize_auth_params(inp, stcb); 1031 1032 sctp_send_initiate(inp, stcb); 1033 SCTP_TCB_UNLOCK(stcb); 1034 return error; 1035 } 1036 1037 static int 1038 sctp6_getaddr(struct socket *so, struct sockaddr **addr) 1039 { 1040 struct sockaddr_in6 *sin6; 1041 struct sctp_inpcb *inp; 1042 uint32_t vrf_id; 1043 struct sctp_ifa *sctp_ifa; 1044 1045 int error; 1046 1047 /* 1048 * Do the malloc first in case it blocks. 1049 */ 1050 SCTP_MALLOC_SONAME(sin6, struct sockaddr_in6 *, sizeof *sin6); 1051 sin6->sin6_family = AF_INET6; 1052 sin6->sin6_len = sizeof(*sin6); 1053 1054 inp = (struct sctp_inpcb *)so->so_pcb; 1055 if (inp == NULL) { 1056 SCTP_FREE_SONAME(sin6); 1057 return ECONNRESET; 1058 } 1059 SCTP_INP_RLOCK(inp); 1060 sin6->sin6_port = inp->sctp_lport; 1061 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { 1062 /* For the bound all case you get back 0 */ 1063 if (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) { 1064 struct sctp_tcb *stcb; 1065 struct sockaddr_in6 *sin_a6; 1066 struct sctp_nets *net; 1067 int fnd; 1068 1069 stcb = LIST_FIRST(&inp->sctp_asoc_list); 1070 if (stcb == NULL) { 1071 goto notConn6; 1072 } 1073 fnd = 0; 1074 sin_a6 = NULL; 1075 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { 1076 sin_a6 = (struct sockaddr_in6 *)&net->ro._l_addr; 1077 if (sin_a6 == NULL) 1078 /* this will make coverity happy */ 1079 continue; 1080 1081 if (sin_a6->sin6_family == AF_INET6) { 1082 fnd = 1; 1083 break; 1084 } 1085 } 1086 if ((!fnd) || (sin_a6 == NULL)) { 1087 /* punt */ 1088 goto notConn6; 1089 } 1090 vrf_id = inp->def_vrf_id; 1091 sctp_ifa = sctp_source_address_selection(inp, stcb, (sctp_route_t *) & net->ro, net, 0, vrf_id); 1092 if (sctp_ifa) { 1093 sin6->sin6_addr = sctp_ifa->address.sin6.sin6_addr; 1094 } 1095 } else { 1096 /* For the bound all case you get back 0 */ 1097 notConn6: 1098 memset(&sin6->sin6_addr, 0, sizeof(sin6->sin6_addr)); 1099 } 1100 } else { 1101 /* Take the first IPv6 address in the list */ 1102 struct sctp_laddr *laddr; 1103 int fnd = 0; 1104 1105 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) { 1106 if (laddr->ifa->address.sa.sa_family == AF_INET6) { 1107 struct sockaddr_in6 *sin_a; 1108 1109 sin_a = (struct sockaddr_in6 *)&laddr->ifa->address.sin6; 1110 sin6->sin6_addr = sin_a->sin6_addr; 1111 fnd = 1; 1112 break; 1113 } 1114 } 1115 if (!fnd) { 1116 SCTP_FREE_SONAME(sin6); 1117 SCTP_INP_RUNLOCK(inp); 1118 return ENOENT; 1119 } 1120 } 1121 SCTP_INP_RUNLOCK(inp); 1122 /* Scoping things for v6 */ 1123 if ((error = sa6_recoverscope(sin6)) != 0) { 1124 SCTP_FREE_SONAME(sin6); 1125 return (error); 1126 } 1127 (*addr) = (struct sockaddr *)sin6; 1128 return (0); 1129 } 1130 1131 static int 1132 sctp6_peeraddr(struct socket *so, struct sockaddr **addr) 1133 { 1134 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)*addr; 1135 int fnd; 1136 struct sockaddr_in6 *sin_a6; 1137 struct sctp_inpcb *inp; 1138 struct sctp_tcb *stcb; 1139 struct sctp_nets *net; 1140 1141 int error; 1142 1143 /* 1144 * Do the malloc first in case it blocks. 1145 */ 1146 inp = (struct sctp_inpcb *)so->so_pcb; 1147 if ((inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) == 0) { 1148 /* UDP type and listeners will drop out here */ 1149 return (ENOTCONN); 1150 } 1151 SCTP_MALLOC_SONAME(sin6, struct sockaddr_in6 *, sizeof *sin6); 1152 sin6->sin6_family = AF_INET6; 1153 sin6->sin6_len = sizeof(*sin6); 1154 1155 /* We must recapture incase we blocked */ 1156 inp = (struct sctp_inpcb *)so->so_pcb; 1157 if (inp == NULL) { 1158 SCTP_FREE_SONAME(sin6); 1159 return ECONNRESET; 1160 } 1161 SCTP_INP_RLOCK(inp); 1162 stcb = LIST_FIRST(&inp->sctp_asoc_list); 1163 if (stcb) 1164 SCTP_TCB_LOCK(stcb); 1165 SCTP_INP_RUNLOCK(inp); 1166 if (stcb == NULL) { 1167 SCTP_FREE_SONAME(sin6); 1168 return ECONNRESET; 1169 } 1170 fnd = 0; 1171 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { 1172 sin_a6 = (struct sockaddr_in6 *)&net->ro._l_addr; 1173 if (sin_a6->sin6_family == AF_INET6) { 1174 fnd = 1; 1175 sin6->sin6_port = stcb->rport; 1176 sin6->sin6_addr = sin_a6->sin6_addr; 1177 break; 1178 } 1179 } 1180 SCTP_TCB_UNLOCK(stcb); 1181 if (!fnd) { 1182 /* No IPv4 address */ 1183 SCTP_FREE_SONAME(sin6); 1184 return ENOENT; 1185 } 1186 if ((error = sa6_recoverscope(sin6)) != 0) 1187 return (error); 1188 *addr = (struct sockaddr *)sin6; 1189 return (0); 1190 } 1191 1192 static int 1193 sctp6_in6getaddr(struct socket *so, struct sockaddr **nam) 1194 { 1195 struct sockaddr *addr; 1196 struct in6pcb *inp6 = sotoin6pcb(so); 1197 int error; 1198 1199 if (inp6 == NULL) 1200 return EINVAL; 1201 1202 /* allow v6 addresses precedence */ 1203 error = sctp6_getaddr(so, nam); 1204 if (error) { 1205 /* try v4 next if v6 failed */ 1206 error = sctp_ingetaddr(so, nam); 1207 if (error) { 1208 return (error); 1209 } 1210 addr = *nam; 1211 /* if I'm V6ONLY, convert it to v4-mapped */ 1212 if (SCTP_IPV6_V6ONLY(inp6)) { 1213 struct sockaddr_in6 sin6; 1214 1215 in6_sin_2_v4mapsin6((struct sockaddr_in *)addr, &sin6); 1216 memcpy(addr, &sin6, sizeof(struct sockaddr_in6)); 1217 1218 } 1219 } 1220 return (error); 1221 } 1222 1223 1224 static int 1225 sctp6_getpeeraddr(struct socket *so, struct sockaddr **nam) 1226 { 1227 struct sockaddr *addr = *nam; 1228 struct in6pcb *inp6 = sotoin6pcb(so); 1229 int error; 1230 1231 if (inp6 == NULL) 1232 return EINVAL; 1233 1234 /* allow v6 addresses precedence */ 1235 error = sctp6_peeraddr(so, nam); 1236 if (error) { 1237 /* try v4 next if v6 failed */ 1238 error = sctp_peeraddr(so, nam); 1239 if (error) { 1240 return (error); 1241 } 1242 /* if I'm V6ONLY, convert it to v4-mapped */ 1243 if (SCTP_IPV6_V6ONLY(inp6)) { 1244 struct sockaddr_in6 sin6; 1245 1246 in6_sin_2_v4mapsin6((struct sockaddr_in *)addr, &sin6); 1247 memcpy(addr, &sin6, sizeof(struct sockaddr_in6)); 1248 } 1249 } 1250 return error; 1251 } 1252 1253 struct pr_usrreqs sctp6_usrreqs = { 1254 .pru_abort = sctp6_abort, 1255 .pru_accept = sctp_accept, 1256 .pru_attach = sctp6_attach, 1257 .pru_bind = sctp6_bind, 1258 .pru_connect = sctp6_connect, 1259 .pru_control = in6_control, 1260 .pru_close = sctp6_close, 1261 .pru_detach = sctp6_close, 1262 .pru_sopoll = sopoll_generic, 1263 .pru_disconnect = sctp6_disconnect, 1264 .pru_listen = sctp_listen, 1265 .pru_peeraddr = sctp6_getpeeraddr, 1266 .pru_send = sctp6_send, 1267 .pru_shutdown = sctp_shutdown, 1268 .pru_sockaddr = sctp6_in6getaddr, 1269 .pru_sosend = sctp_sosend, 1270 .pru_soreceive = sctp_soreceive 1271 }; 1272