netwerk/sctp/src/netinet/sctp_uio.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:444bac4512ee
1 /*-
2 * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
4 * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * a) Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 *
12 * b) Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the distribution.
15 *
16 * c) Neither the name of Cisco Systems, Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #ifdef __FreeBSD__
34 #include <sys/cdefs.h>
35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_uio.h 255160 2013-09-02 22:48:41Z tuexen $");
36 #endif
37
38 #ifndef _NETINET_SCTP_UIO_H_
39 #define _NETINET_SCTP_UIO_H_
40
41 #if (defined(__APPLE__) && defined(KERNEL))
42 #ifndef _KERNEL
43 #define _KERNEL
44 #endif
45 #endif
46
47 #if !(defined(__Windows__)) && !defined(__Userspace_os_Windows)
48 #if ! defined(_KERNEL)
49 #include <stdint.h>
50 #endif
51 #include <sys/types.h>
52 #include <sys/socket.h>
53 #include <netinet/in.h>
54 #endif
55 #if defined(__Windows__)
56 #pragma warning(push)
57 #pragma warning(disable: 4200)
58 #if defined(_KERNEL)
59 #include <sys/types.h>
60 #include <sys/socket.h>
61 #include <netinet/in.h>
62 #endif
63 #endif
64
65 typedef uint32_t sctp_assoc_t;
66
67 #define SCTP_FUTURE_ASSOC 0
68 #define SCTP_CURRENT_ASSOC 1
69 #define SCTP_ALL_ASSOC 2
70
71 struct sctp_event {
72 sctp_assoc_t se_assoc_id;
73 uint16_t se_type;
74 uint8_t se_on;
75 };
76
77 /* Compatibility to previous define's */
78 #define sctp_stream_reset_events sctp_stream_reset_event
79
80 /* On/Off setup for subscription to events */
81 struct sctp_event_subscribe {
82 uint8_t sctp_data_io_event;
83 uint8_t sctp_association_event;
84 uint8_t sctp_address_event;
85 uint8_t sctp_send_failure_event;
86 uint8_t sctp_peer_error_event;
87 uint8_t sctp_shutdown_event;
88 uint8_t sctp_partial_delivery_event;
89 uint8_t sctp_adaptation_layer_event;
90 uint8_t sctp_authentication_event;
91 uint8_t sctp_sender_dry_event;
92 uint8_t sctp_stream_reset_event;
93 };
94
95 /* ancillary data types */
96 #define SCTP_INIT 0x0001
97 #define SCTP_SNDRCV 0x0002
98 #define SCTP_EXTRCV 0x0003
99 #define SCTP_SNDINFO 0x0004
100 #define SCTP_RCVINFO 0x0005
101 #define SCTP_NXTINFO 0x0006
102 #define SCTP_PRINFO 0x0007
103 #define SCTP_AUTHINFO 0x0008
104 #define SCTP_DSTADDRV4 0x0009
105 #define SCTP_DSTADDRV6 0x000a
106
107 /*
108 * ancillary data structures
109 */
110 struct sctp_initmsg {
111 #if defined(__FreeBSD__) && __FreeBSD_version < 800000
112 /* This is a bug. Not fixed for ABI compatibility */
113 uint32_t sinit_num_ostreams;
114 uint32_t sinit_max_instreams;
115 #else
116 uint16_t sinit_num_ostreams;
117 uint16_t sinit_max_instreams;
118 #endif
119 uint16_t sinit_max_attempts;
120 uint16_t sinit_max_init_timeo;
121 };
122
123 /* We add 96 bytes to the size of sctp_sndrcvinfo.
124 * This makes the current structure 128 bytes long
125 * which is nicely 64 bit aligned but also has room
126 * for us to add more and keep ABI compatibility.
127 * For example, already we have the sctp_extrcvinfo
128 * when enabled which is 48 bytes.
129 */
130
131 /*
132 * The assoc up needs a verfid
133 * all sendrcvinfo's need a verfid for SENDING only.
134 */
135
136
137 #define SCTP_ALIGN_RESV_PAD 92
138 #define SCTP_ALIGN_RESV_PAD_SHORT 76
139
140 struct sctp_sndrcvinfo {
141 uint16_t sinfo_stream;
142 uint16_t sinfo_ssn;
143 uint16_t sinfo_flags;
144 #if defined(__FreeBSD__) && __FreeBSD_version < 800000
145 uint16_t sinfo_pr_policy;
146 #endif
147 uint32_t sinfo_ppid;
148 uint32_t sinfo_context;
149 uint32_t sinfo_timetolive;
150 uint32_t sinfo_tsn;
151 uint32_t sinfo_cumtsn;
152 sctp_assoc_t sinfo_assoc_id;
153 uint16_t sinfo_keynumber;
154 uint16_t sinfo_keynumber_valid;
155 uint8_t __reserve_pad[SCTP_ALIGN_RESV_PAD];
156 };
157
158 struct sctp_extrcvinfo {
159 uint16_t sinfo_stream;
160 uint16_t sinfo_ssn;
161 uint16_t sinfo_flags;
162 #if defined(__FreeBSD__) && __FreeBSD_version < 800000
163 uint16_t sinfo_pr_policy;
164 #endif
165 uint32_t sinfo_ppid;
166 uint32_t sinfo_context;
167 uint32_t sinfo_timetolive;
168 uint32_t sinfo_tsn;
169 uint32_t sinfo_cumtsn;
170 sctp_assoc_t sinfo_assoc_id;
171 uint16_t sreinfo_next_flags;
172 uint16_t sreinfo_next_stream;
173 uint32_t sreinfo_next_aid;
174 uint32_t sreinfo_next_length;
175 uint32_t sreinfo_next_ppid;
176 uint16_t sinfo_keynumber;
177 uint16_t sinfo_keynumber_valid;
178 uint8_t __reserve_pad[SCTP_ALIGN_RESV_PAD_SHORT];
179 };
180
181 struct sctp_sndinfo {
182 uint16_t snd_sid;
183 uint16_t snd_flags;
184 uint32_t snd_ppid;
185 uint32_t snd_context;
186 sctp_assoc_t snd_assoc_id;
187 };
188
189 struct sctp_prinfo {
190 uint16_t pr_policy;
191 uint32_t pr_value;
192 };
193
194 struct sctp_default_prinfo {
195 uint16_t pr_policy;
196 uint32_t pr_value;
197 sctp_assoc_t pr_assoc_id;
198 };
199
200 struct sctp_authinfo {
201 uint16_t auth_keynumber;
202 };
203
204 struct sctp_rcvinfo {
205 uint16_t rcv_sid;
206 uint16_t rcv_ssn;
207 uint16_t rcv_flags;
208 uint32_t rcv_ppid;
209 uint32_t rcv_tsn;
210 uint32_t rcv_cumtsn;
211 uint32_t rcv_context;
212 sctp_assoc_t rcv_assoc_id;
213 };
214
215 struct sctp_nxtinfo {
216 uint16_t nxt_sid;
217 uint16_t nxt_flags;
218 uint32_t nxt_ppid;
219 uint32_t nxt_length;
220 sctp_assoc_t nxt_assoc_id;
221 };
222
223 #define SCTP_NO_NEXT_MSG 0x0000
224 #define SCTP_NEXT_MSG_AVAIL 0x0001
225 #define SCTP_NEXT_MSG_ISCOMPLETE 0x0002
226 #define SCTP_NEXT_MSG_IS_UNORDERED 0x0004
227 #define SCTP_NEXT_MSG_IS_NOTIFICATION 0x0008
228
229 struct sctp_recvv_rn {
230 struct sctp_rcvinfo recvv_rcvinfo;
231 struct sctp_nxtinfo recvv_nxtinfo;
232 };
233
234 #define SCTP_RECVV_NOINFO 0
235 #define SCTP_RECVV_RCVINFO 1
236 #define SCTP_RECVV_NXTINFO 2
237 #define SCTP_RECVV_RN 3
238
239 #define SCTP_SENDV_NOINFO 0
240 #define SCTP_SENDV_SNDINFO 1
241 #define SCTP_SENDV_PRINFO 2
242 #define SCTP_SENDV_AUTHINFO 3
243 #define SCTP_SENDV_SPA 4
244
245 struct sctp_sendv_spa {
246 uint32_t sendv_flags;
247 struct sctp_sndinfo sendv_sndinfo;
248 struct sctp_prinfo sendv_prinfo;
249 struct sctp_authinfo sendv_authinfo;
250 };
251
252 #define SCTP_SEND_SNDINFO_VALID 0x00000001
253 #define SCTP_SEND_PRINFO_VALID 0x00000002
254 #define SCTP_SEND_AUTHINFO_VALID 0x00000004
255
256 struct sctp_snd_all_completes {
257 uint16_t sall_stream;
258 uint16_t sall_flags;
259 uint32_t sall_ppid;
260 uint32_t sall_context;
261 uint32_t sall_num_sent;
262 uint32_t sall_num_failed;
263 };
264
265 /* Flags that go into the sinfo->sinfo_flags field */
266 #define SCTP_NOTIFICATION 0x0010 /* next message is a notification */
267 #define SCTP_COMPLETE 0x0020 /* next message is complete */
268 #define SCTP_EOF 0x0100 /* Start shutdown procedures */
269 #define SCTP_ABORT 0x0200 /* Send an ABORT to peer */
270 #define SCTP_UNORDERED 0x0400 /* Message is un-ordered */
271 #define SCTP_ADDR_OVER 0x0800 /* Override the primary-address */
272 #define SCTP_SENDALL 0x1000 /* Send this on all associations */
273 #define SCTP_EOR 0x2000 /* end of message signal */
274 #define SCTP_SACK_IMMEDIATELY 0x4000 /* Set I-Bit */
275
276 #define INVALID_SINFO_FLAG(x) (((x) & 0xfffffff0 \
277 & ~(SCTP_EOF | SCTP_ABORT | SCTP_UNORDERED |\
278 SCTP_ADDR_OVER | SCTP_SENDALL | SCTP_EOR |\
279 SCTP_SACK_IMMEDIATELY)) != 0)
280 /* for the endpoint */
281
282 /* The lower byte is an enumeration of PR-SCTP policies */
283 #define SCTP_PR_SCTP_NONE 0x0000 /* Reliable transfer */
284 #define SCTP_PR_SCTP_TTL 0x0001 /* Time based PR-SCTP */
285 #define SCTP_PR_SCTP_BUF 0x0002 /* Buffer based PR-SCTP */
286 #define SCTP_PR_SCTP_RTX 0x0003 /* Number of retransmissions based PR-SCTP */
287
288 #define PR_SCTP_POLICY(x) ((x) & 0x0f)
289 #define PR_SCTP_ENABLED(x) (PR_SCTP_POLICY(x) != SCTP_PR_SCTP_NONE)
290 #define PR_SCTP_TTL_ENABLED(x) (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_TTL)
291 #define PR_SCTP_BUF_ENABLED(x) (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_BUF)
292 #define PR_SCTP_RTX_ENABLED(x) (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_RTX)
293 #define PR_SCTP_INVALID_POLICY(x) (PR_SCTP_POLICY(x) > SCTP_PR_SCTP_RTX)
294 /* Stat's */
295 struct sctp_pcbinfo {
296 uint32_t ep_count;
297 uint32_t asoc_count;
298 uint32_t laddr_count;
299 uint32_t raddr_count;
300 uint32_t chk_count;
301 uint32_t readq_count;
302 uint32_t free_chunks;
303 uint32_t stream_oque;
304 };
305
306 struct sctp_sockstat {
307 sctp_assoc_t ss_assoc_id;
308 uint32_t ss_total_sndbuf;
309 uint32_t ss_total_recv_buf;
310 };
311
312 /*
313 * notification event structures
314 */
315
316 /*
317 * association change event
318 */
319 struct sctp_assoc_change {
320 uint16_t sac_type;
321 uint16_t sac_flags;
322 uint32_t sac_length;
323 uint16_t sac_state;
324 uint16_t sac_error;
325 uint16_t sac_outbound_streams;
326 uint16_t sac_inbound_streams;
327 sctp_assoc_t sac_assoc_id;
328 uint8_t sac_info[];
329 };
330
331 /* sac_state values */
332 #define SCTP_COMM_UP 0x0001
333 #define SCTP_COMM_LOST 0x0002
334 #define SCTP_RESTART 0x0003
335 #define SCTP_SHUTDOWN_COMP 0x0004
336 #define SCTP_CANT_STR_ASSOC 0x0005
337
338 /* sac_info values */
339 #define SCTP_ASSOC_SUPPORTS_PR 0x01
340 #define SCTP_ASSOC_SUPPORTS_AUTH 0x02
341 #define SCTP_ASSOC_SUPPORTS_ASCONF 0x03
342 #define SCTP_ASSOC_SUPPORTS_MULTIBUF 0x04
343 #define SCTP_ASSOC_SUPPORTS_RE_CONFIG 0x05
344 #define SCTP_ASSOC_SUPPORTS_MAX 0x05
345 /*
346 * Address event
347 */
348 struct sctp_paddr_change {
349 uint16_t spc_type;
350 uint16_t spc_flags;
351 uint32_t spc_length;
352 struct sockaddr_storage spc_aaddr;
353 uint32_t spc_state;
354 uint32_t spc_error;
355 sctp_assoc_t spc_assoc_id;
356 uint8_t spc_padding[4];
357 };
358
359 /* paddr state values */
360 #define SCTP_ADDR_AVAILABLE 0x0001
361 #define SCTP_ADDR_UNREACHABLE 0x0002
362 #define SCTP_ADDR_REMOVED 0x0003
363 #define SCTP_ADDR_ADDED 0x0004
364 #define SCTP_ADDR_MADE_PRIM 0x0005
365 #define SCTP_ADDR_CONFIRMED 0x0006
366
367 #define SCTP_ACTIVE 0x0001 /* SCTP_ADDR_REACHABLE */
368 #define SCTP_INACTIVE 0x0002 /* neither SCTP_ADDR_REACHABLE
369 nor SCTP_ADDR_UNCONFIRMED */
370 #define SCTP_UNCONFIRMED 0x0200 /* SCTP_ADDR_UNCONFIRMED */
371
372 /* remote error events */
373 struct sctp_remote_error {
374 uint16_t sre_type;
375 uint16_t sre_flags;
376 uint32_t sre_length;
377 uint16_t sre_error;
378 sctp_assoc_t sre_assoc_id;
379 uint8_t sre_data[4];
380 };
381
382 /* data send failure event (deprecated) */
383 struct sctp_send_failed {
384 uint16_t ssf_type;
385 uint16_t ssf_flags;
386 uint32_t ssf_length;
387 uint32_t ssf_error;
388 struct sctp_sndrcvinfo ssf_info;
389 sctp_assoc_t ssf_assoc_id;
390 uint8_t ssf_data[];
391 };
392
393 /* data send failure event (not deprecated) */
394 struct sctp_send_failed_event {
395 uint16_t ssfe_type;
396 uint16_t ssfe_flags;
397 uint32_t ssfe_length;
398 uint32_t ssfe_error;
399 struct sctp_sndinfo ssfe_info;
400 sctp_assoc_t ssfe_assoc_id;
401 uint8_t ssfe_data[];
402 };
403
404 /* flag that indicates state of data */
405 #define SCTP_DATA_UNSENT 0x0001 /* inqueue never on wire */
406 #define SCTP_DATA_SENT 0x0002 /* on wire at failure */
407
408 /* shutdown event */
409 struct sctp_shutdown_event {
410 uint16_t sse_type;
411 uint16_t sse_flags;
412 uint32_t sse_length;
413 sctp_assoc_t sse_assoc_id;
414 };
415
416 /* Adaptation layer indication stuff */
417 struct sctp_adaptation_event {
418 uint16_t sai_type;
419 uint16_t sai_flags;
420 uint32_t sai_length;
421 uint32_t sai_adaptation_ind;
422 sctp_assoc_t sai_assoc_id;
423 };
424
425 struct sctp_setadaptation {
426 uint32_t ssb_adaptation_ind;
427 };
428
429 /* compatible old spelling */
430 struct sctp_adaption_event {
431 uint16_t sai_type;
432 uint16_t sai_flags;
433 uint32_t sai_length;
434 uint32_t sai_adaption_ind;
435 sctp_assoc_t sai_assoc_id;
436 };
437
438 struct sctp_setadaption {
439 uint32_t ssb_adaption_ind;
440 };
441
442
443 /*
444 * Partial Delivery API event
445 */
446 struct sctp_pdapi_event {
447 uint16_t pdapi_type;
448 uint16_t pdapi_flags;
449 uint32_t pdapi_length;
450 uint32_t pdapi_indication;
451 uint16_t pdapi_stream;
452 uint16_t pdapi_seq;
453 sctp_assoc_t pdapi_assoc_id;
454 };
455
456 /* indication values */
457 #define SCTP_PARTIAL_DELIVERY_ABORTED 0x0001
458
459
460 /*
461 * authentication key event
462 */
463 struct sctp_authkey_event {
464 uint16_t auth_type;
465 uint16_t auth_flags;
466 uint32_t auth_length;
467 uint16_t auth_keynumber;
468 uint16_t auth_altkeynumber;
469 uint32_t auth_indication;
470 sctp_assoc_t auth_assoc_id;
471 };
472
473 /* indication values */
474 #define SCTP_AUTH_NEW_KEY 0x0001
475 #define SCTP_AUTH_NEWKEY SCTP_AUTH_NEW_KEY
476 #define SCTP_AUTH_NO_AUTH 0x0002
477 #define SCTP_AUTH_FREE_KEY 0x0003
478
479
480 struct sctp_sender_dry_event {
481 uint16_t sender_dry_type;
482 uint16_t sender_dry_flags;
483 uint32_t sender_dry_length;
484 sctp_assoc_t sender_dry_assoc_id;
485 };
486
487
488 /*
489 * Stream reset event - subscribe to SCTP_STREAM_RESET_EVENT
490 */
491 struct sctp_stream_reset_event {
492 uint16_t strreset_type;
493 uint16_t strreset_flags;
494 uint32_t strreset_length;
495 sctp_assoc_t strreset_assoc_id;
496 uint16_t strreset_stream_list[];
497 };
498
499 /* flags in stream_reset_event (strreset_flags) */
500 #define SCTP_STREAM_RESET_INCOMING_SSN 0x0001
501 #define SCTP_STREAM_RESET_OUTGOING_SSN 0x0002
502 #define SCTP_STREAM_RESET_DENIED 0x0004
503 #define SCTP_STREAM_RESET_FAILED 0x0008
504
505 /*
506 * Assoc reset event - subscribe to SCTP_ASSOC_RESET_EVENT
507 */
508 struct sctp_assoc_reset_event {
509 uint16_t assocreset_type;
510 uint16_t assocreset_flags;
511 uint32_t assocreset_length;
512 sctp_assoc_t assocreset_assoc_id;
513 uint32_t assocreset_local_tsn;
514 uint32_t assocreset_remote_tsn;
515 };
516
517 #define SCTP_ASSOC_RESET_DENIED 0x0004
518 #define SCTP_ASSOC_RESET_FAILED 0x0008
519
520 /*
521 * Stream change event - subscribe to SCTP_STREAM_CHANGE_EVENT
522 */
523 struct sctp_stream_change_event {
524 uint16_t strchange_type;
525 uint16_t strchange_flags;
526 uint32_t strchange_length;
527 sctp_assoc_t strchange_assoc_id;
528 uint16_t strchange_instrms;
529 uint16_t strchange_outstrms;
530 };
531
532 #define SCTP_STREAM_CHANGE_DENIED 0x0004
533 #define SCTP_STREAM_CHANGE_FAILED 0x0008
534
535
536 /* SCTP notification event */
537 struct sctp_tlv {
538 uint16_t sn_type;
539 uint16_t sn_flags;
540 uint32_t sn_length;
541 };
542
543 union sctp_notification {
544 struct sctp_tlv sn_header;
545 struct sctp_assoc_change sn_assoc_change;
546 struct sctp_paddr_change sn_paddr_change;
547 struct sctp_remote_error sn_remote_error;
548 struct sctp_send_failed sn_send_failed;
549 struct sctp_shutdown_event sn_shutdown_event;
550 struct sctp_adaptation_event sn_adaptation_event;
551 /* compatibility same as above */
552 struct sctp_adaption_event sn_adaption_event;
553 struct sctp_pdapi_event sn_pdapi_event;
554 struct sctp_authkey_event sn_auth_event;
555 struct sctp_sender_dry_event sn_sender_dry_event;
556 struct sctp_send_failed_event sn_send_failed_event;
557 struct sctp_stream_reset_event sn_strreset_event;
558 struct sctp_assoc_reset_event sn_assocreset_event;
559 struct sctp_stream_change_event sn_strchange_event;
560 };
561
562 /* notification types */
563 #define SCTP_ASSOC_CHANGE 0x0001
564 #define SCTP_PEER_ADDR_CHANGE 0x0002
565 #define SCTP_REMOTE_ERROR 0x0003
566 #define SCTP_SEND_FAILED 0x0004
567 #define SCTP_SHUTDOWN_EVENT 0x0005
568 #define SCTP_ADAPTATION_INDICATION 0x0006
569 /* same as above */
570 #define SCTP_ADAPTION_INDICATION 0x0006
571 #define SCTP_PARTIAL_DELIVERY_EVENT 0x0007
572 #define SCTP_AUTHENTICATION_EVENT 0x0008
573 #define SCTP_STREAM_RESET_EVENT 0x0009
574 #define SCTP_SENDER_DRY_EVENT 0x000a
575 #define SCTP_NOTIFICATIONS_STOPPED_EVENT 0x000b /* we don't send this*/
576 #define SCTP_ASSOC_RESET_EVENT 0x000c
577 #define SCTP_STREAM_CHANGE_EVENT 0x000d
578 #define SCTP_SEND_FAILED_EVENT 0x000e
579 /*
580 * socket option structs
581 */
582
583 struct sctp_paddrparams {
584 struct sockaddr_storage spp_address;
585 sctp_assoc_t spp_assoc_id;
586 uint32_t spp_hbinterval;
587 uint32_t spp_pathmtu;
588 uint32_t spp_flags;
589 uint32_t spp_ipv6_flowlabel;
590 uint16_t spp_pathmaxrxt;
591 uint8_t spp_dscp;
592 };
593 #define spp_ipv4_tos spp_dscp
594
595 #define SPP_HB_ENABLE 0x00000001
596 #define SPP_HB_DISABLE 0x00000002
597 #define SPP_HB_DEMAND 0x00000004
598 #define SPP_PMTUD_ENABLE 0x00000008
599 #define SPP_PMTUD_DISABLE 0x00000010
600 #define SPP_HB_TIME_IS_ZERO 0x00000080
601 #define SPP_IPV6_FLOWLABEL 0x00000100
602 #define SPP_DSCP 0x00000200
603 #define SPP_IPV4_TOS SPP_DSCP
604
605 struct sctp_paddrthlds {
606 struct sockaddr_storage spt_address;
607 sctp_assoc_t spt_assoc_id;
608 uint16_t spt_pathmaxrxt;
609 uint16_t spt_pathpfthld;
610 };
611
612 struct sctp_paddrinfo {
613 struct sockaddr_storage spinfo_address;
614 sctp_assoc_t spinfo_assoc_id;
615 int32_t spinfo_state;
616 uint32_t spinfo_cwnd;
617 uint32_t spinfo_srtt;
618 uint32_t spinfo_rto;
619 uint32_t spinfo_mtu;
620 };
621
622 struct sctp_rtoinfo {
623 sctp_assoc_t srto_assoc_id;
624 uint32_t srto_initial;
625 uint32_t srto_max;
626 uint32_t srto_min;
627 };
628
629 struct sctp_assocparams {
630 sctp_assoc_t sasoc_assoc_id;
631 uint32_t sasoc_peer_rwnd;
632 uint32_t sasoc_local_rwnd;
633 uint32_t sasoc_cookie_life;
634 uint16_t sasoc_asocmaxrxt;
635 uint16_t sasoc_number_peer_destinations;
636 };
637
638 struct sctp_setprim {
639 struct sockaddr_storage ssp_addr;
640 sctp_assoc_t ssp_assoc_id;
641 uint8_t ssp_padding[4];
642 };
643
644 struct sctp_setpeerprim {
645 struct sockaddr_storage sspp_addr;
646 sctp_assoc_t sspp_assoc_id;
647 uint8_t sspp_padding[4];
648 };
649
650 struct sctp_getaddresses {
651 sctp_assoc_t sget_assoc_id;
652 /* addr is filled in for N * sockaddr_storage */
653 struct sockaddr addr[1];
654 };
655
656 struct sctp_status {
657 sctp_assoc_t sstat_assoc_id;
658 int32_t sstat_state;
659 uint32_t sstat_rwnd;
660 uint16_t sstat_unackdata;
661 uint16_t sstat_penddata;
662 uint16_t sstat_instrms;
663 uint16_t sstat_outstrms;
664 uint32_t sstat_fragmentation_point;
665 struct sctp_paddrinfo sstat_primary;
666 };
667
668 /*
669 * AUTHENTICATION support
670 */
671 /* SCTP_AUTH_CHUNK */
672 struct sctp_authchunk {
673 uint8_t sauth_chunk;
674 };
675
676 /* SCTP_AUTH_KEY */
677 struct sctp_authkey {
678 sctp_assoc_t sca_assoc_id;
679 uint16_t sca_keynumber;
680 uint16_t sca_keylength;
681 uint8_t sca_key[];
682 };
683
684 /* SCTP_HMAC_IDENT */
685 struct sctp_hmacalgo {
686 uint32_t shmac_number_of_idents;
687 uint16_t shmac_idents[];
688 };
689
690 /* AUTH hmac_id */
691 #define SCTP_AUTH_HMAC_ID_RSVD 0x0000
692 #define SCTP_AUTH_HMAC_ID_SHA1 0x0001 /* default, mandatory */
693 #define SCTP_AUTH_HMAC_ID_SHA256 0x0003
694
695 /* SCTP_AUTH_ACTIVE_KEY / SCTP_AUTH_DELETE_KEY */
696 struct sctp_authkeyid {
697 sctp_assoc_t scact_assoc_id;
698 uint16_t scact_keynumber;
699 };
700
701 /* SCTP_PEER_AUTH_CHUNKS / SCTP_LOCAL_AUTH_CHUNKS */
702 struct sctp_authchunks {
703 sctp_assoc_t gauth_assoc_id;
704 uint32_t gauth_number_of_chunks;
705 uint8_t gauth_chunks[];
706 };
707
708 struct sctp_assoc_value {
709 sctp_assoc_t assoc_id;
710 uint32_t assoc_value;
711 };
712
713 struct sctp_cc_option {
714 int option;
715 struct sctp_assoc_value aid_value;
716 };
717
718 struct sctp_stream_value {
719 sctp_assoc_t assoc_id;
720 uint16_t stream_id;
721 uint16_t stream_value;
722 };
723
724 struct sctp_assoc_ids {
725 uint32_t gaids_number_of_ids;
726 sctp_assoc_t gaids_assoc_id[];
727 };
728
729 struct sctp_sack_info {
730 sctp_assoc_t sack_assoc_id;
731 uint32_t sack_delay;
732 uint32_t sack_freq;
733 };
734
735 struct sctp_timeouts {
736 sctp_assoc_t stimo_assoc_id;
737 uint32_t stimo_init;
738 uint32_t stimo_data;
739 uint32_t stimo_sack;
740 uint32_t stimo_shutdown;
741 uint32_t stimo_heartbeat;
742 uint32_t stimo_cookie;
743 uint32_t stimo_shutdownack;
744 };
745
746 struct sctp_udpencaps {
747 struct sockaddr_storage sue_address;
748 sctp_assoc_t sue_assoc_id;
749 uint16_t sue_port;
750 };
751
752 struct sctp_cwnd_args {
753 struct sctp_nets *net; /* network to */ /* FIXME: LP64 issue */
754 uint32_t cwnd_new_value;/* cwnd in k */
755 uint32_t pseudo_cumack;
756 uint16_t inflight; /* flightsize in k */
757 uint16_t cwnd_augment; /* increment to it */
758 uint8_t meets_pseudo_cumack;
759 uint8_t need_new_pseudo_cumack;
760 uint8_t cnt_in_send;
761 uint8_t cnt_in_str;
762 };
763
764 struct sctp_blk_args {
765 uint32_t onsb; /* in 1k bytes */
766 uint32_t sndlen; /* len of send being attempted */
767 uint32_t peer_rwnd; /* rwnd of peer */
768 uint16_t send_sent_qcnt;/* chnk cnt */
769 uint16_t stream_qcnt; /* chnk cnt */
770 uint16_t chunks_on_oque;/* chunks out */
771 uint16_t flight_size; /* flight size in k */
772 };
773
774 /*
775 * Max we can reset in one setting, note this is dictated not by the define
776 * but the size of a mbuf cluster so don't change this define and think you
777 * can specify more. You must do multiple resets if you want to reset more
778 * than SCTP_MAX_EXPLICIT_STR_RESET.
779 */
780 #define SCTP_MAX_EXPLICT_STR_RESET 1000
781
782 struct sctp_reset_streams {
783 sctp_assoc_t srs_assoc_id;
784 uint16_t srs_flags;
785 uint16_t srs_number_streams; /* 0 == ALL */
786 uint16_t srs_stream_list[];/* list if strrst_num_streams is not 0 */
787 };
788
789 struct sctp_add_streams {
790 sctp_assoc_t sas_assoc_id;
791 uint16_t sas_instrms;
792 uint16_t sas_outstrms;
793 };
794
795 struct sctp_get_nonce_values {
796 sctp_assoc_t gn_assoc_id;
797 uint32_t gn_peers_tag;
798 uint32_t gn_local_tag;
799 };
800
801 /* Debugging logs */
802 struct sctp_str_log {
803 void *stcb; /* FIXME: LP64 issue */
804 uint32_t n_tsn;
805 uint32_t e_tsn;
806 uint16_t n_sseq;
807 uint16_t e_sseq;
808 uint16_t strm;
809 };
810
811 struct sctp_sb_log {
812 void *stcb; /* FIXME: LP64 issue */
813 uint32_t so_sbcc;
814 uint32_t stcb_sbcc;
815 uint32_t incr;
816 };
817
818 struct sctp_fr_log {
819 uint32_t largest_tsn;
820 uint32_t largest_new_tsn;
821 uint32_t tsn;
822 };
823
824 struct sctp_fr_map {
825 uint32_t base;
826 uint32_t cum;
827 uint32_t high;
828 };
829
830 struct sctp_rwnd_log {
831 uint32_t rwnd;
832 uint32_t send_size;
833 uint32_t overhead;
834 uint32_t new_rwnd;
835 };
836
837 struct sctp_mbcnt_log {
838 uint32_t total_queue_size;
839 uint32_t size_change;
840 uint32_t total_queue_mb_size;
841 uint32_t mbcnt_change;
842 };
843
844 struct sctp_sack_log {
845 uint32_t cumack;
846 uint32_t oldcumack;
847 uint32_t tsn;
848 uint16_t numGaps;
849 uint16_t numDups;
850 };
851
852 struct sctp_lock_log {
853 void *sock; /* FIXME: LP64 issue */
854 void *inp; /* FIXME: LP64 issue */
855 uint8_t tcb_lock;
856 uint8_t inp_lock;
857 uint8_t info_lock;
858 uint8_t sock_lock;
859 uint8_t sockrcvbuf_lock;
860 uint8_t socksndbuf_lock;
861 uint8_t create_lock;
862 uint8_t resv;
863 };
864
865 struct sctp_rto_log {
866 void * net; /* FIXME: LP64 issue */
867 uint32_t rtt;
868 };
869
870 struct sctp_nagle_log {
871 void *stcb; /* FIXME: LP64 issue */
872 uint32_t total_flight;
873 uint32_t total_in_queue;
874 uint16_t count_in_queue;
875 uint16_t count_in_flight;
876 };
877
878 struct sctp_sbwake_log {
879 void *stcb; /* FIXME: LP64 issue */
880 uint16_t send_q;
881 uint16_t sent_q;
882 uint16_t flight;
883 uint16_t wake_cnt;
884 uint8_t stream_qcnt; /* chnk cnt */
885 uint8_t chunks_on_oque;/* chunks out */
886 uint8_t sbflags;
887 uint8_t sctpflags;
888 };
889
890 struct sctp_misc_info {
891 uint32_t log1;
892 uint32_t log2;
893 uint32_t log3;
894 uint32_t log4;
895 };
896
897 struct sctp_log_closing {
898 void *inp; /* FIXME: LP64 issue */
899 void *stcb; /* FIXME: LP64 issue */
900 uint32_t sctp_flags;
901 uint16_t state;
902 int16_t loc;
903 };
904
905 struct sctp_mbuf_log {
906 struct mbuf *mp; /* FIXME: LP64 issue */
907 caddr_t ext;
908 caddr_t data;
909 uint16_t size;
910 uint8_t refcnt;
911 uint8_t mbuf_flags;
912 };
913
914 struct sctp_cwnd_log {
915 uint64_t time_event;
916 uint8_t from;
917 uint8_t event_type;
918 uint8_t resv[2];
919 union {
920 struct sctp_log_closing close;
921 struct sctp_blk_args blk;
922 struct sctp_cwnd_args cwnd;
923 struct sctp_str_log strlog;
924 struct sctp_fr_log fr;
925 struct sctp_fr_map map;
926 struct sctp_rwnd_log rwnd;
927 struct sctp_mbcnt_log mbcnt;
928 struct sctp_sack_log sack;
929 struct sctp_lock_log lock;
930 struct sctp_rto_log rto;
931 struct sctp_sb_log sb;
932 struct sctp_nagle_log nagle;
933 struct sctp_sbwake_log wake;
934 struct sctp_mbuf_log mb;
935 struct sctp_misc_info misc;
936 } x;
937 };
938
939 struct sctp_cwnd_log_req {
940 int32_t num_in_log; /* Number in log */
941 int32_t num_ret; /* Number returned */
942 int32_t start_at; /* start at this one */
943 int32_t end_at; /* end at this one */
944 struct sctp_cwnd_log log[];
945 };
946
947 struct sctp_timeval {
948 uint32_t tv_sec;
949 uint32_t tv_usec;
950 };
951
952 struct sctpstat {
953 struct sctp_timeval sctps_discontinuitytime; /* sctpStats 18 (TimeStamp) */
954 /* MIB according to RFC 3873 */
955 uint32_t sctps_currestab; /* sctpStats 1 (Gauge32) */
956 uint32_t sctps_activeestab; /* sctpStats 2 (Counter32) */
957 uint32_t sctps_restartestab;
958 uint32_t sctps_collisionestab;
959 uint32_t sctps_passiveestab; /* sctpStats 3 (Counter32) */
960 uint32_t sctps_aborted; /* sctpStats 4 (Counter32) */
961 uint32_t sctps_shutdown; /* sctpStats 5 (Counter32) */
962 uint32_t sctps_outoftheblue; /* sctpStats 6 (Counter32) */
963 uint32_t sctps_checksumerrors; /* sctpStats 7 (Counter32) */
964 uint32_t sctps_outcontrolchunks; /* sctpStats 8 (Counter64) */
965 uint32_t sctps_outorderchunks; /* sctpStats 9 (Counter64) */
966 uint32_t sctps_outunorderchunks; /* sctpStats 10 (Counter64) */
967 uint32_t sctps_incontrolchunks; /* sctpStats 11 (Counter64) */
968 uint32_t sctps_inorderchunks; /* sctpStats 12 (Counter64) */
969 uint32_t sctps_inunorderchunks; /* sctpStats 13 (Counter64) */
970 uint32_t sctps_fragusrmsgs; /* sctpStats 14 (Counter64) */
971 uint32_t sctps_reasmusrmsgs; /* sctpStats 15 (Counter64) */
972 uint32_t sctps_outpackets; /* sctpStats 16 (Counter64) */
973 uint32_t sctps_inpackets; /* sctpStats 17 (Counter64) */
974
975 /* input statistics: */
976 uint32_t sctps_recvpackets; /* total input packets */
977 uint32_t sctps_recvdatagrams; /* total input datagrams */
978 uint32_t sctps_recvpktwithdata; /* total packets that had data */
979 uint32_t sctps_recvsacks; /* total input SACK chunks */
980 uint32_t sctps_recvdata; /* total input DATA chunks */
981 uint32_t sctps_recvdupdata; /* total input duplicate DATA chunks */
982 uint32_t sctps_recvheartbeat; /* total input HB chunks */
983 uint32_t sctps_recvheartbeatack; /* total input HB-ACK chunks */
984 uint32_t sctps_recvecne; /* total input ECNE chunks */
985 uint32_t sctps_recvauth; /* total input AUTH chunks */
986 uint32_t sctps_recvauthmissing; /* total input chunks missing AUTH */
987 uint32_t sctps_recvivalhmacid; /* total number of invalid HMAC ids received */
988 uint32_t sctps_recvivalkeyid; /* total number of invalid secret ids received */
989 uint32_t sctps_recvauthfailed; /* total number of auth failed */
990 uint32_t sctps_recvexpress; /* total fast path receives all one chunk */
991 uint32_t sctps_recvexpressm; /* total fast path multi-part data */
992 uint32_t sctps_recvnocrc;
993 uint32_t sctps_recvswcrc;
994 uint32_t sctps_recvhwcrc;
995
996 /* output statistics: */
997 uint32_t sctps_sendpackets; /* total output packets */
998 uint32_t sctps_sendsacks; /* total output SACKs */
999 uint32_t sctps_senddata; /* total output DATA chunks */
1000 uint32_t sctps_sendretransdata; /* total output retransmitted DATA chunks */
1001 uint32_t sctps_sendfastretrans; /* total output fast retransmitted DATA chunks */
1002 uint32_t sctps_sendmultfastretrans; /* total FR's that happened more than once
1003 * to same chunk (u-del multi-fr algo).
1004 */
1005 uint32_t sctps_sendheartbeat; /* total output HB chunks */
1006 uint32_t sctps_sendecne; /* total output ECNE chunks */
1007 uint32_t sctps_sendauth; /* total output AUTH chunks FIXME */
1008 uint32_t sctps_senderrors; /* ip_output error counter */
1009 uint32_t sctps_sendnocrc;
1010 uint32_t sctps_sendswcrc;
1011 uint32_t sctps_sendhwcrc;
1012 /* PCKDROPREP statistics: */
1013 uint32_t sctps_pdrpfmbox; /* Packet drop from middle box */
1014 uint32_t sctps_pdrpfehos; /* P-drop from end host */
1015 uint32_t sctps_pdrpmbda; /* P-drops with data */
1016 uint32_t sctps_pdrpmbct; /* P-drops, non-data, non-endhost */
1017 uint32_t sctps_pdrpbwrpt; /* P-drop, non-endhost, bandwidth rep only */
1018 uint32_t sctps_pdrpcrupt; /* P-drop, not enough for chunk header */
1019 uint32_t sctps_pdrpnedat; /* P-drop, not enough data to confirm */
1020 uint32_t sctps_pdrppdbrk; /* P-drop, where process_chunk_drop said break */
1021 uint32_t sctps_pdrptsnnf; /* P-drop, could not find TSN */
1022 uint32_t sctps_pdrpdnfnd; /* P-drop, attempt reverse TSN lookup */
1023 uint32_t sctps_pdrpdiwnp; /* P-drop, e-host confirms zero-rwnd */
1024 uint32_t sctps_pdrpdizrw; /* P-drop, midbox confirms no space */
1025 uint32_t sctps_pdrpbadd; /* P-drop, data did not match TSN */
1026 uint32_t sctps_pdrpmark; /* P-drop, TSN's marked for Fast Retran */
1027 /* timeouts */
1028 uint32_t sctps_timoiterator; /* Number of iterator timers that fired */
1029 uint32_t sctps_timodata; /* Number of T3 data time outs */
1030 uint32_t sctps_timowindowprobe; /* Number of window probe (T3) timers that fired */
1031 uint32_t sctps_timoinit; /* Number of INIT timers that fired */
1032 uint32_t sctps_timosack; /* Number of sack timers that fired */
1033 uint32_t sctps_timoshutdown; /* Number of shutdown timers that fired */
1034 uint32_t sctps_timoheartbeat; /* Number of heartbeat timers that fired */
1035 uint32_t sctps_timocookie; /* Number of times a cookie timeout fired */
1036 uint32_t sctps_timosecret; /* Number of times an endpoint changed its cookie secret*/
1037 uint32_t sctps_timopathmtu; /* Number of PMTU timers that fired */
1038 uint32_t sctps_timoshutdownack; /* Number of shutdown ack timers that fired */
1039 uint32_t sctps_timoshutdownguard; /* Number of shutdown guard timers that fired */
1040 uint32_t sctps_timostrmrst; /* Number of stream reset timers that fired */
1041 uint32_t sctps_timoearlyfr; /* Number of early FR timers that fired */
1042 uint32_t sctps_timoasconf; /* Number of times an asconf timer fired */
1043 uint32_t sctps_timodelprim; /* Number of times a prim_deleted timer fired */
1044 uint32_t sctps_timoautoclose; /* Number of times auto close timer fired */
1045 uint32_t sctps_timoassockill; /* Number of asoc free timers expired */
1046 uint32_t sctps_timoinpkill; /* Number of inp free timers expired */
1047 /* former early FR counters */
1048 uint32_t sctps_spare[11];
1049 /* others */
1050 uint32_t sctps_hdrops; /* packet shorter than header */
1051 uint32_t sctps_badsum; /* checksum error */
1052 uint32_t sctps_noport; /* no endpoint for port */
1053 uint32_t sctps_badvtag; /* bad v-tag */
1054 uint32_t sctps_badsid; /* bad SID */
1055 uint32_t sctps_nomem; /* no memory */
1056 uint32_t sctps_fastretransinrtt; /* number of multiple FR in a RTT window */
1057 uint32_t sctps_markedretrans;
1058 uint32_t sctps_naglesent; /* nagle allowed sending */
1059 uint32_t sctps_naglequeued; /* nagle doesn't allow sending */
1060 uint32_t sctps_maxburstqueued; /* max burst doesn't allow sending */
1061 uint32_t sctps_ifnomemqueued; /* look ahead tells us no memory in
1062 * interface ring buffer OR we had a
1063 * send error and are queuing one send.
1064 */
1065 uint32_t sctps_windowprobed; /* total number of window probes sent */
1066 uint32_t sctps_lowlevelerr; /* total times an output error causes us
1067 * to clamp down on next user send.
1068 */
1069 uint32_t sctps_lowlevelerrusr; /* total times sctp_senderrors were caused from
1070 * a user send from a user invoked send not
1071 * a sack response
1072 */
1073 uint32_t sctps_datadropchklmt; /* Number of in data drops due to chunk limit reached */
1074 uint32_t sctps_datadroprwnd; /* Number of in data drops due to rwnd limit reached */
1075 uint32_t sctps_ecnereducedcwnd; /* Number of times a ECN reduced the cwnd */
1076 uint32_t sctps_vtagexpress; /* Used express lookup via vtag */
1077 uint32_t sctps_vtagbogus; /* Collision in express lookup. */
1078 uint32_t sctps_primary_randry; /* Number of times the sender ran dry of user data on primary */
1079 uint32_t sctps_cmt_randry; /* Same for above */
1080 uint32_t sctps_slowpath_sack; /* Sacks the slow way */
1081 uint32_t sctps_wu_sacks_sent; /* Window Update only sacks sent */
1082 uint32_t sctps_sends_with_flags; /* number of sends with sinfo_flags !=0 */
1083 uint32_t sctps_sends_with_unord; /* number of unordered sends */
1084 uint32_t sctps_sends_with_eof; /* number of sends with EOF flag set */
1085 uint32_t sctps_sends_with_abort; /* number of sends with ABORT flag set */
1086 uint32_t sctps_protocol_drain_calls; /* number of times protocol drain called */
1087 uint32_t sctps_protocol_drains_done; /* number of times we did a protocol drain */
1088 uint32_t sctps_read_peeks; /* Number of times recv was called with peek */
1089 uint32_t sctps_cached_chk; /* Number of cached chunks used */
1090 uint32_t sctps_cached_strmoq; /* Number of cached stream oq's used */
1091 uint32_t sctps_left_abandon; /* Number of unread messages abandoned by close */
1092 uint32_t sctps_send_burst_avoid; /* Unused */
1093 uint32_t sctps_send_cwnd_avoid; /* Send cwnd full avoidance, already max burst inflight to net */
1094 uint32_t sctps_fwdtsn_map_over; /* number of map array over-runs via fwd-tsn's */
1095 uint32_t sctps_queue_upd_ecne; /* Number of times we queued or updated an ECN chunk on send queue */
1096 uint32_t sctps_reserved[31]; /* Future ABI compat - remove int's from here when adding new */
1097 };
1098
1099 #define SCTP_STAT_INCR(_x) SCTP_STAT_INCR_BY(_x,1)
1100 #define SCTP_STAT_DECR(_x) SCTP_STAT_DECR_BY(_x,1)
1101 #if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
1102 #define SCTP_STAT_INCR_BY(_x,_d) (SCTP_BASE_STATS[PCPU_GET(cpuid)]._x += _d)
1103 #define SCTP_STAT_DECR_BY(_x,_d) (SCTP_BASE_STATS[PCPU_GET(cpuid)]._x -= _d)
1104 #else
1105 #define SCTP_STAT_INCR_BY(_x,_d) atomic_add_int(&SCTP_BASE_STAT(_x), _d)
1106 #define SCTP_STAT_DECR_BY(_x,_d) atomic_subtract_int(&SCTP_BASE_STAT(_x), _d)
1107 #endif
1108 /* The following macros are for handling MIB values, */
1109 #define SCTP_STAT_INCR_COUNTER32(_x) SCTP_STAT_INCR(_x)
1110 #define SCTP_STAT_INCR_COUNTER64(_x) SCTP_STAT_INCR(_x)
1111 #define SCTP_STAT_INCR_GAUGE32(_x) SCTP_STAT_INCR(_x)
1112 #define SCTP_STAT_DECR_COUNTER32(_x) SCTP_STAT_DECR(_x)
1113 #define SCTP_STAT_DECR_COUNTER64(_x) SCTP_STAT_DECR(_x)
1114 #define SCTP_STAT_DECR_GAUGE32(_x) SCTP_STAT_DECR(_x)
1115
1116 #if defined(__Userspace__)
1117 union sctp_sockstore {
1118 #if defined(INET)
1119 struct sockaddr_in sin;
1120 #endif
1121 #if defined(INET6)
1122 struct sockaddr_in6 sin6;
1123 #endif
1124 struct sockaddr_conn sconn;
1125 struct sockaddr sa;
1126 };
1127 #else
1128 union sctp_sockstore {
1129 struct sockaddr_in sin;
1130 struct sockaddr_in6 sin6;
1131 struct sockaddr sa;
1132 };
1133 #endif
1134
1135
1136 /***********************************/
1137 /* And something for us old timers */
1138 /***********************************/
1139
1140 #ifndef __APPLE__
1141 #ifndef __Userspace__
1142 #ifndef ntohll
1143 #if defined(__Userspace_os_Linux)
1144 #ifndef _BSD_SOURCE
1145 #define _BSD_SOURCE
1146 #endif
1147 #include <endian.h>
1148 #else
1149 #include <sys/endian.h>
1150 #endif
1151 #define ntohll(x) be64toh(x)
1152 #endif
1153
1154 #ifndef htonll
1155 #if defined(__Userspace_os_Linux)
1156 #ifndef _BSD_SOURCE
1157 #define _BSD_SOURCE
1158 #endif
1159 #include <endian.h>
1160 #else
1161 #include <sys/endian.h>
1162 #endif
1163 #define htonll(x) htobe64(x)
1164 #endif
1165 #endif
1166 #endif
1167 /***********************************/
1168
1169
1170 struct xsctp_inpcb {
1171 uint32_t last;
1172 uint32_t flags;
1173 #if defined(__FreeBSD__) && __FreeBSD_version < 1000048
1174 uint32_t features;
1175 #else
1176 uint64_t features;
1177 #endif
1178 uint32_t total_sends;
1179 uint32_t total_recvs;
1180 uint32_t total_nospaces;
1181 uint32_t fragmentation_point;
1182 uint16_t local_port;
1183 uint16_t qlen;
1184 uint16_t maxqlen;
1185 #if defined(__Windows__)
1186 uint16_t padding;
1187 #endif
1188 #if defined(__FreeBSD__) && __FreeBSD_version < 1000048
1189 uint32_t extra_padding[32]; /* future */
1190 #else
1191 uint32_t extra_padding[31]; /* future */
1192 #endif
1193 };
1194
1195 struct xsctp_tcb {
1196 union sctp_sockstore primary_addr; /* sctpAssocEntry 5/6 */
1197 uint32_t last;
1198 uint32_t heartbeat_interval; /* sctpAssocEntry 7 */
1199 uint32_t state; /* sctpAssocEntry 8 */
1200 uint32_t in_streams; /* sctpAssocEntry 9 */
1201 uint32_t out_streams; /* sctpAssocEntry 10 */
1202 uint32_t max_nr_retrans; /* sctpAssocEntry 11 */
1203 uint32_t primary_process; /* sctpAssocEntry 12 */
1204 uint32_t T1_expireries; /* sctpAssocEntry 13 */
1205 uint32_t T2_expireries; /* sctpAssocEntry 14 */
1206 uint32_t retransmitted_tsns; /* sctpAssocEntry 15 */
1207 uint32_t total_sends;
1208 uint32_t total_recvs;
1209 uint32_t local_tag;
1210 uint32_t remote_tag;
1211 uint32_t initial_tsn;
1212 uint32_t highest_tsn;
1213 uint32_t cumulative_tsn;
1214 uint32_t cumulative_tsn_ack;
1215 uint32_t mtu;
1216 uint32_t refcnt;
1217 uint16_t local_port; /* sctpAssocEntry 3 */
1218 uint16_t remote_port; /* sctpAssocEntry 4 */
1219 struct sctp_timeval start_time; /* sctpAssocEntry 16 */
1220 struct sctp_timeval discontinuity_time; /* sctpAssocEntry 17 */
1221 #if defined(__FreeBSD__)
1222 #if __FreeBSD_version >= 800000
1223 uint32_t peers_rwnd;
1224 sctp_assoc_t assoc_id; /* sctpAssocEntry 1 */
1225 uint32_t extra_padding[32]; /* future */
1226 #else
1227 #endif
1228 #else
1229 uint32_t peers_rwnd;
1230 sctp_assoc_t assoc_id; /* sctpAssocEntry 1 */
1231 uint32_t extra_padding[32]; /* future */
1232 #endif
1233 };
1234
1235 struct xsctp_laddr {
1236 union sctp_sockstore address; /* sctpAssocLocalAddrEntry 1/2 */
1237 uint32_t last;
1238 struct sctp_timeval start_time; /* sctpAssocLocalAddrEntry 3 */
1239 uint32_t extra_padding[32]; /* future */
1240 };
1241
1242 struct xsctp_raddr {
1243 union sctp_sockstore address; /* sctpAssocLocalRemEntry 1/2 */
1244 uint32_t last;
1245 uint32_t rto; /* sctpAssocLocalRemEntry 5 */
1246 uint32_t max_path_rtx; /* sctpAssocLocalRemEntry 6 */
1247 uint32_t rtx; /* sctpAssocLocalRemEntry 7 */
1248 uint32_t error_counter; /* */
1249 uint32_t cwnd; /* */
1250 uint32_t flight_size; /* */
1251 uint32_t mtu; /* */
1252 uint8_t active; /* sctpAssocLocalRemEntry 3 */
1253 uint8_t confirmed; /* */
1254 uint8_t heartbeat_enabled; /* sctpAssocLocalRemEntry 4 */
1255 uint8_t potentially_failed;
1256 struct sctp_timeval start_time; /* sctpAssocLocalRemEntry 8 */
1257 #if defined(__FreeBSD__)
1258 #if __FreeBSD_version >= 800000
1259 uint32_t rtt;
1260 uint32_t heartbeat_interval;
1261 uint32_t extra_padding[31]; /* future */
1262 #endif
1263 #else
1264 uint32_t rtt;
1265 uint32_t heartbeat_interval;
1266 uint32_t extra_padding[31]; /* future */
1267 #endif
1268 };
1269
1270 #define SCTP_MAX_LOGGING_SIZE 30000
1271 #define SCTP_TRACE_PARAMS 6 /* This number MUST be even */
1272
1273 struct sctp_log_entry {
1274 uint64_t timestamp;
1275 uint32_t subsys;
1276 uint32_t padding;
1277 uint32_t params[SCTP_TRACE_PARAMS];
1278 };
1279
1280 struct sctp_log {
1281 struct sctp_log_entry entry[SCTP_MAX_LOGGING_SIZE];
1282 uint32_t index;
1283 uint32_t padding;
1284 };
1285
1286 /*
1287 * Kernel defined for sctp_send
1288 */
1289 #if defined(_KERNEL) || defined(__Userspace__)
1290 int
1291 sctp_lower_sosend(struct socket *so,
1292 struct sockaddr *addr,
1293 struct uio *uio,
1294 #if defined(__Panda__)
1295 pakhandle_type i_pak,
1296 pakhandle_type i_control,
1297 #else
1298 struct mbuf *i_pak,
1299 struct mbuf *control,
1300 #endif
1301 int flags,
1302 struct sctp_sndrcvinfo *srcv
1303 #if !(defined(__Panda__) || defined(__Userspace__))
1304 #if defined(__FreeBSD__) && __FreeBSD_version >= 500000
1305 ,struct thread *p
1306 #elif defined(__Windows__)
1307 , PKTHREAD p
1308 #else
1309 ,struct proc *p
1310 #endif
1311 #endif
1312 );
1313
1314 int
1315 sctp_sorecvmsg(struct socket *so,
1316 struct uio *uio,
1317 #if defined(__Panda__)
1318 particletype **mp,
1319 #else
1320 struct mbuf **mp,
1321 #endif
1322 struct sockaddr *from,
1323 int fromlen,
1324 int *msg_flags,
1325 struct sctp_sndrcvinfo *sinfo,
1326 int filling_sinfo);
1327 #endif
1328
1329 /*
1330 * API system calls
1331 */
1332 #if !(defined(_KERNEL)) && !(defined(__Userspace__))
1333
1334 __BEGIN_DECLS
1335 #if defined(__FreeBSD__) && __FreeBSD_version < 902000
1336 int sctp_peeloff __P((int, sctp_assoc_t));
1337 int sctp_bindx __P((int, struct sockaddr *, int, int));
1338 int sctp_connectx __P((int, const struct sockaddr *, int, sctp_assoc_t *));
1339 int sctp_getaddrlen __P((sa_family_t));
1340 int sctp_getpaddrs __P((int, sctp_assoc_t, struct sockaddr **));
1341 void sctp_freepaddrs __P((struct sockaddr *));
1342 int sctp_getladdrs __P((int, sctp_assoc_t, struct sockaddr **));
1343 void sctp_freeladdrs __P((struct sockaddr *));
1344 int sctp_opt_info __P((int, sctp_assoc_t, int, void *, socklen_t *));
1345
1346 /* deprecated */
1347 ssize_t sctp_sendmsg __P((int, const void *, size_t, const struct sockaddr *,
1348 socklen_t, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t));
1349
1350 /* deprecated */
1351 ssize_t sctp_send __P((int, const void *, size_t,
1352 const struct sctp_sndrcvinfo *, int));
1353
1354 /* deprecated */
1355 ssize_t sctp_sendx __P((int, const void *, size_t, struct sockaddr *,
1356 int, struct sctp_sndrcvinfo *, int));
1357
1358 /* deprecated */
1359 ssize_t sctp_sendmsgx __P((int sd, const void *, size_t, struct sockaddr *,
1360 int, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t));
1361
1362 sctp_assoc_t sctp_getassocid __P((int, struct sockaddr *));
1363
1364 /* deprecated */
1365 ssize_t sctp_recvmsg __P((int, void *, size_t, struct sockaddr *, socklen_t *,
1366 struct sctp_sndrcvinfo *, int *));
1367
1368 ssize_t sctp_sendv __P((int, const struct iovec *, int, struct sockaddr *,
1369 int, void *, socklen_t, unsigned int, int));
1370
1371 ssize_t sctp_recvv __P((int, const struct iovec *, int, struct sockaddr *,
1372 socklen_t *, void *, socklen_t *, unsigned int *, int *));
1373 #else
1374 int sctp_peeloff(int, sctp_assoc_t);
1375 int sctp_bindx(int, struct sockaddr *, int, int);
1376 int sctp_connectx(int, const struct sockaddr *, int, sctp_assoc_t *);
1377 int sctp_getaddrlen(sa_family_t);
1378 int sctp_getpaddrs(int, sctp_assoc_t, struct sockaddr **);
1379 void sctp_freepaddrs(struct sockaddr *);
1380 int sctp_getladdrs(int, sctp_assoc_t, struct sockaddr **);
1381 void sctp_freeladdrs(struct sockaddr *);
1382 int sctp_opt_info(int, sctp_assoc_t, int, void *, socklen_t *);
1383
1384 /* deprecated */
1385 ssize_t sctp_sendmsg(int, const void *, size_t, const struct sockaddr *,
1386 socklen_t, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t);
1387
1388 /* deprecated */
1389 ssize_t sctp_send(int, const void *, size_t,
1390 const struct sctp_sndrcvinfo *, int);
1391
1392 /* deprecated */
1393 ssize_t sctp_sendx(int, const void *, size_t, struct sockaddr *,
1394 int, struct sctp_sndrcvinfo *, int);
1395
1396 /* deprecated */
1397 ssize_t sctp_sendmsgx(int sd, const void *, size_t, struct sockaddr *,
1398 int, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t);
1399
1400 sctp_assoc_t sctp_getassocid(int, struct sockaddr *);
1401
1402 /* deprecated */
1403 ssize_t sctp_recvmsg(int, void *, size_t, struct sockaddr *, socklen_t *,
1404 struct sctp_sndrcvinfo *, int *);
1405
1406 ssize_t sctp_sendv(int, const struct iovec *, int, struct sockaddr *,
1407 int, void *, socklen_t, unsigned int, int);
1408
1409 ssize_t sctp_recvv(int, const struct iovec *, int, struct sockaddr *,
1410 socklen_t *, void *, socklen_t *, unsigned int *, int *);
1411 #endif
1412 __END_DECLS
1413
1414 #endif /* !_KERNEL */
1415 #endif /* !__sctp_uio_h__ */

mercurial