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