sctp_uio.h revision 218319
1163953Srrs/*-
2169382Srrs * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
3218319Srrs * Copyright (c) 2008-2011, by Randall Stewart. All rights reserved.
4218319Srrs * Copyright (c) 2008-2011, by Michael Tuexen. All rights reserved.
5163953Srrs *
6163953Srrs * Redistribution and use in source and binary forms, with or without
7163953Srrs * modification, are permitted provided that the following conditions are met:
8163953Srrs *
9163953Srrs * a) Redistributions of source code must retain the above copyright notice,
10163953Srrs *   this list of conditions and the following disclaimer.
11163953Srrs *
12163953Srrs * b) Redistributions in binary form must reproduce the above copyright
13163953Srrs *    notice, this list of conditions and the following disclaimer in
14163953Srrs *   the documentation and/or other materials provided with the distribution.
15163953Srrs *
16163953Srrs * c) Neither the name of Cisco Systems, Inc. nor the names of its
17163953Srrs *    contributors may be used to endorse or promote products derived
18163953Srrs *    from this software without specific prior written permission.
19163953Srrs *
20163953Srrs * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21163953Srrs * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22163953Srrs * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23163953Srrs * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24163953Srrs * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25163953Srrs * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26163953Srrs * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27163953Srrs * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28163953Srrs * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29163953Srrs * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30163953Srrs * THE POSSIBILITY OF SUCH DAMAGE.
31163953Srrs */
32163953Srrs
33163953Srrs/* $KAME: sctp_uio.h,v 1.11 2005/03/06 16:04:18 itojun Exp $	 */
34163953Srrs#include <sys/cdefs.h>
35163953Srrs__FBSDID("$FreeBSD: head/sys/netinet/sctp_uio.h 218319 2011-02-05 12:12:51Z rrs $");
36163953Srrs
37163953Srrs#ifndef __sctp_uio_h__
38163953Srrs#define __sctp_uio_h__
39163953Srrs
40163953Srrs
41163953Srrs#if ! defined(_KERNEL)
42163953Srrs#include <stdint.h>
43163953Srrs#endif
44163953Srrs#include <sys/types.h>
45163953Srrs#include <sys/socket.h>
46164085Srrs#include <netinet/in.h>
47163953Srrs
48163953Srrstypedef uint32_t sctp_assoc_t;
49163953Srrs
50202520Srrs/* Compatibility to previous define's */
51202520Srrs#define sctp_stream_reset_events sctp_stream_reset_event
52202520Srrs
53163953Srrs/* On/Off setup for subscription to events */
54163953Srrsstruct sctp_event_subscribe {
55163953Srrs	uint8_t sctp_data_io_event;
56163953Srrs	uint8_t sctp_association_event;
57163953Srrs	uint8_t sctp_address_event;
58163953Srrs	uint8_t sctp_send_failure_event;
59163953Srrs	uint8_t sctp_peer_error_event;
60163953Srrs	uint8_t sctp_shutdown_event;
61163953Srrs	uint8_t sctp_partial_delivery_event;
62163953Srrs	uint8_t sctp_adaptation_layer_event;
63163953Srrs	uint8_t sctp_authentication_event;
64185694Srrs	uint8_t sctp_sender_dry_event;
65202520Srrs	uint8_t sctp_stream_reset_event;
66163953Srrs};
67163953Srrs
68163953Srrs/* ancillary data types */
69163953Srrs#define SCTP_INIT	0x0001
70163953Srrs#define SCTP_SNDRCV	0x0002
71163953Srrs#define SCTP_EXTRCV	0x0003
72163953Srrs/*
73163953Srrs * ancillary data structures
74163953Srrs */
75163953Srrsstruct sctp_initmsg {
76193088Srrs	uint16_t sinit_num_ostreams;
77193088Srrs	uint16_t sinit_max_instreams;
78163953Srrs	uint16_t sinit_max_attempts;
79163953Srrs	uint16_t sinit_max_init_timeo;
80163953Srrs};
81163953Srrs
82163953Srrs/* We add 96 bytes to the size of sctp_sndrcvinfo.
83163953Srrs * This makes the current structure 128 bytes long
84163953Srrs * which is nicely 64 bit aligned but also has room
85215034Sbrucec * for us to add more and keep ABI compatibility.
86163953Srrs * For example, already we have the sctp_extrcvinfo
87163953Srrs * when enabled which is 48 bytes.
88163953Srrs */
89163953Srrs
90166675Srrs/*
91166675Srrs * The assoc up needs a verfid
92166675Srrs * all sendrcvinfo's need a verfid for SENDING only.
93166675Srrs */
94166675Srrs
95166675Srrs
96163953Srrs#define SCTP_ALIGN_RESV_PAD 96
97166675Srrs#define SCTP_ALIGN_RESV_PAD_SHORT 80
98163953Srrs
99163953Srrsstruct sctp_sndrcvinfo {
100163953Srrs	uint16_t sinfo_stream;
101163953Srrs	uint16_t sinfo_ssn;
102163953Srrs	uint16_t sinfo_flags;
103163953Srrs	uint32_t sinfo_ppid;
104163953Srrs	uint32_t sinfo_context;
105163953Srrs	uint32_t sinfo_timetolive;
106163953Srrs	uint32_t sinfo_tsn;
107163953Srrs	uint32_t sinfo_cumtsn;
108163953Srrs	sctp_assoc_t sinfo_assoc_id;
109163953Srrs	uint8_t __reserve_pad[SCTP_ALIGN_RESV_PAD];
110163953Srrs};
111163953Srrs
112163953Srrsstruct sctp_extrcvinfo {
113171745Srrs	uint16_t sinfo_stream;
114171745Srrs	uint16_t sinfo_ssn;
115171745Srrs	uint16_t sinfo_flags;
116171990Srrs	uint16_t sinfo_pr_policy;
117171745Srrs	uint32_t sinfo_ppid;
118171745Srrs	uint32_t sinfo_context;
119171745Srrs	uint32_t sinfo_timetolive;
120171745Srrs	uint32_t sinfo_tsn;
121171745Srrs	uint32_t sinfo_cumtsn;
122171745Srrs	sctp_assoc_t sinfo_assoc_id;
123168943Srrs	uint16_t sreinfo_next_flags;
124168943Srrs	uint16_t sreinfo_next_stream;
125168943Srrs	uint32_t sreinfo_next_aid;
126168943Srrs	uint32_t sreinfo_next_length;
127168943Srrs	uint32_t sreinfo_next_ppid;
128166675Srrs	uint8_t __reserve_pad[SCTP_ALIGN_RESV_PAD_SHORT];
129163953Srrs};
130163953Srrs
131163953Srrs#define SCTP_NO_NEXT_MSG           0x0000
132163953Srrs#define SCTP_NEXT_MSG_AVAIL        0x0001
133163953Srrs#define SCTP_NEXT_MSG_ISCOMPLETE   0x0002
134163953Srrs#define SCTP_NEXT_MSG_IS_UNORDERED 0x0004
135166675Srrs#define SCTP_NEXT_MSG_IS_NOTIFICATION 0x0008
136163953Srrs
137163953Srrsstruct sctp_snd_all_completes {
138163953Srrs	uint16_t sall_stream;
139163953Srrs	uint16_t sall_flags;
140163953Srrs	uint32_t sall_ppid;
141163953Srrs	uint32_t sall_context;
142163953Srrs	uint32_t sall_num_sent;
143163953Srrs	uint32_t sall_num_failed;
144163953Srrs};
145163953Srrs
146163953Srrs/* Flags that go into the sinfo->sinfo_flags field */
147185694Srrs#define SCTP_EOF              0x0100	/* Start shutdown procedures */
148185694Srrs#define SCTP_ABORT            0x0200	/* Send an ABORT to peer */
149185694Srrs#define SCTP_UNORDERED        0x0400	/* Message is un-ordered */
150185694Srrs#define SCTP_ADDR_OVER        0x0800	/* Override the primary-address */
151185694Srrs#define SCTP_SENDALL          0x1000	/* Send this on all associations */
152185694Srrs#define SCTP_EOR              0x2000	/* end of message signal */
153185694Srrs#define SCTP_SACK_IMMEDIATELY 0x4000	/* Set I-Bit */
154171990Srrs
155166023Srrs#define INVALID_SINFO_FLAG(x) (((x) & 0xffffff00 \
156166023Srrs                                    & ~(SCTP_EOF | SCTP_ABORT | SCTP_UNORDERED |\
157185694Srrs				        SCTP_ADDR_OVER | SCTP_SENDALL | SCTP_EOR |\
158185694Srrs					SCTP_SACK_IMMEDIATELY)) != 0)
159163953Srrs/* for the endpoint */
160163953Srrs
161163953Srrs/* The lower byte is an enumeration of PR-SCTP policies */
162163953Srrs#define SCTP_PR_SCTP_TTL  0x0001/* Time based PR-SCTP */
163163953Srrs#define SCTP_PR_SCTP_BUF  0x0002/* Buffer based PR-SCTP */
164163953Srrs#define SCTP_PR_SCTP_RTX  0x0003/* Number of retransmissions based PR-SCTP */
165163953Srrs
166166023Srrs#define PR_SCTP_POLICY(x)         ((x) & 0xff)
167166023Srrs#define PR_SCTP_ENABLED(x)        (PR_SCTP_POLICY(x) != 0)
168166023Srrs#define PR_SCTP_TTL_ENABLED(x)    (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_TTL)
169166023Srrs#define PR_SCTP_BUF_ENABLED(x)    (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_BUF)
170166023Srrs#define PR_SCTP_RTX_ENABLED(x)    (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_RTX)
171166023Srrs#define PR_SCTP_INVALID_POLICY(x) (PR_SCTP_POLICY(x) > SCTP_PR_SCTP_RTX)
172163953Srrs/* Stat's */
173163953Srrsstruct sctp_pcbinfo {
174163953Srrs	uint32_t ep_count;
175163953Srrs	uint32_t asoc_count;
176163953Srrs	uint32_t laddr_count;
177163953Srrs	uint32_t raddr_count;
178163953Srrs	uint32_t chk_count;
179163953Srrs	uint32_t readq_count;
180163953Srrs	uint32_t free_chunks;
181163953Srrs	uint32_t stream_oque;
182163953Srrs};
183163953Srrs
184163953Srrsstruct sctp_sockstat {
185163953Srrs	sctp_assoc_t ss_assoc_id;
186163953Srrs	uint32_t ss_total_sndbuf;
187163953Srrs	uint32_t ss_total_recv_buf;
188163953Srrs};
189163953Srrs
190163953Srrs/*
191163953Srrs * notification event structures
192163953Srrs */
193163953Srrs
194163953Srrs/*
195163953Srrs * association change event
196163953Srrs */
197163953Srrsstruct sctp_assoc_change {
198163953Srrs	uint16_t sac_type;
199163953Srrs	uint16_t sac_flags;
200163953Srrs	uint32_t sac_length;
201163953Srrs	uint16_t sac_state;
202163953Srrs	uint16_t sac_error;
203163953Srrs	uint16_t sac_outbound_streams;
204163953Srrs	uint16_t sac_inbound_streams;
205163953Srrs	sctp_assoc_t sac_assoc_id;
206163953Srrs};
207163953Srrs
208163953Srrs/* sac_state values */
209163953Srrs#define SCTP_COMM_UP		0x0001
210163953Srrs#define SCTP_COMM_LOST		0x0002
211163953Srrs#define SCTP_RESTART		0x0003
212163953Srrs#define SCTP_SHUTDOWN_COMP	0x0004
213163953Srrs#define SCTP_CANT_STR_ASSOC	0x0005
214163953Srrs
215163953Srrs
216163953Srrs/*
217163953Srrs * Address event
218163953Srrs */
219163953Srrsstruct sctp_paddr_change {
220163953Srrs	uint16_t spc_type;
221163953Srrs	uint16_t spc_flags;
222163953Srrs	uint32_t spc_length;
223163953Srrs	struct sockaddr_storage spc_aaddr;
224163953Srrs	uint32_t spc_state;
225163953Srrs	uint32_t spc_error;
226163953Srrs	sctp_assoc_t spc_assoc_id;
227170992Srrs	uint8_t spc_padding[4];
228163953Srrs};
229163953Srrs
230163953Srrs/* paddr state values */
231163953Srrs#define SCTP_ADDR_AVAILABLE	0x0001
232163953Srrs#define SCTP_ADDR_UNREACHABLE	0x0002
233163953Srrs#define SCTP_ADDR_REMOVED	0x0003
234163953Srrs#define SCTP_ADDR_ADDED		0x0004
235163953Srrs#define SCTP_ADDR_MADE_PRIM	0x0005
236163953Srrs#define SCTP_ADDR_CONFIRMED	0x0006
237163953Srrs
238163953Srrs#define SCTP_ACTIVE		0x0001	/* SCTP_ADDR_REACHABLE */
239163953Srrs#define SCTP_INACTIVE		0x0002	/* SCTP_ADDR_NOT_REACHABLE */
240163953Srrs#define SCTP_UNCONFIRMED	0x0200	/* SCTP_ADDR_UNCONFIRMED */
241163953Srrs
242163953Srrs/* remote error events */
243163953Srrsstruct sctp_remote_error {
244163953Srrs	uint16_t sre_type;
245163953Srrs	uint16_t sre_flags;
246163953Srrs	uint32_t sre_length;
247163953Srrs	uint16_t sre_error;
248163953Srrs	sctp_assoc_t sre_assoc_id;
249163953Srrs	uint8_t sre_data[4];
250163953Srrs};
251163953Srrs
252163953Srrs/* data send failure event */
253163953Srrsstruct sctp_send_failed {
254163953Srrs	uint16_t ssf_type;
255163953Srrs	uint16_t ssf_flags;
256163953Srrs	uint32_t ssf_length;
257163953Srrs	uint32_t ssf_error;
258163953Srrs	struct sctp_sndrcvinfo ssf_info;
259163953Srrs	sctp_assoc_t ssf_assoc_id;
260202782Stuexen	uint8_t ssf_data[];
261163953Srrs};
262163953Srrs
263163953Srrs/* flag that indicates state of data */
264163953Srrs#define SCTP_DATA_UNSENT	0x0001	/* inqueue never on wire */
265163953Srrs#define SCTP_DATA_SENT		0x0002	/* on wire at failure */
266163953Srrs
267163953Srrs/* shutdown event */
268163953Srrsstruct sctp_shutdown_event {
269163953Srrs	uint16_t sse_type;
270163953Srrs	uint16_t sse_flags;
271163953Srrs	uint32_t sse_length;
272163953Srrs	sctp_assoc_t sse_assoc_id;
273163953Srrs};
274163953Srrs
275163953Srrs/* Adaptation layer indication stuff */
276163953Srrsstruct sctp_adaptation_event {
277163953Srrs	uint16_t sai_type;
278163953Srrs	uint16_t sai_flags;
279163953Srrs	uint32_t sai_length;
280163953Srrs	uint32_t sai_adaptation_ind;
281163953Srrs	sctp_assoc_t sai_assoc_id;
282163953Srrs};
283163953Srrs
284163953Srrsstruct sctp_setadaptation {
285163953Srrs	uint32_t ssb_adaptation_ind;
286163953Srrs};
287163953Srrs
288215034Sbrucec/* compatible old spelling */
289163953Srrsstruct sctp_adaption_event {
290163953Srrs	uint16_t sai_type;
291163953Srrs	uint16_t sai_flags;
292163953Srrs	uint32_t sai_length;
293163953Srrs	uint32_t sai_adaption_ind;
294163953Srrs	sctp_assoc_t sai_assoc_id;
295163953Srrs};
296163953Srrs
297163953Srrsstruct sctp_setadaption {
298163953Srrs	uint32_t ssb_adaption_ind;
299163953Srrs};
300163953Srrs
301163953Srrs
302163953Srrs/*
303163953Srrs * Partial Delivery API event
304163953Srrs */
305163953Srrsstruct sctp_pdapi_event {
306163953Srrs	uint16_t pdapi_type;
307163953Srrs	uint16_t pdapi_flags;
308163953Srrs	uint32_t pdapi_length;
309163953Srrs	uint32_t pdapi_indication;
310168943Srrs	uint16_t pdapi_stream;
311168943Srrs	uint16_t pdapi_seq;
312163953Srrs	sctp_assoc_t pdapi_assoc_id;
313163953Srrs};
314163953Srrs
315163953Srrs/* indication values */
316163953Srrs#define SCTP_PARTIAL_DELIVERY_ABORTED	0x0001
317163953Srrs
318163953Srrs
319163953Srrs/*
320163953Srrs * authentication key event
321163953Srrs */
322163953Srrsstruct sctp_authkey_event {
323163953Srrs	uint16_t auth_type;
324163953Srrs	uint16_t auth_flags;
325163953Srrs	uint32_t auth_length;
326163953Srrs	uint16_t auth_keynumber;
327163953Srrs	uint16_t auth_altkeynumber;
328163953Srrs	uint32_t auth_indication;
329163953Srrs	sctp_assoc_t auth_assoc_id;
330163953Srrs};
331163953Srrs
332163953Srrs/* indication values */
333163953Srrs#define SCTP_AUTH_NEWKEY	0x0001
334185694Srrs#define SCTP_AUTH_NO_AUTH	0x0002
335185694Srrs#define SCTP_AUTH_FREE_KEY	0x0003
336163953Srrs
337163953Srrs
338185694Srrsstruct sctp_sender_dry_event {
339185694Srrs	uint16_t sender_dry_type;
340185694Srrs	uint16_t sender_dry_flags;
341185694Srrs	uint32_t sender_dry_length;
342185694Srrs	sctp_assoc_t sender_dry_assoc_id;
343185694Srrs};
344185694Srrs
345185694Srrs
346163953Srrs/*
347163953Srrs * stream reset event
348163953Srrs */
349163953Srrsstruct sctp_stream_reset_event {
350163953Srrs	uint16_t strreset_type;
351163953Srrs	uint16_t strreset_flags;
352163953Srrs	uint32_t strreset_length;
353163953Srrs	sctp_assoc_t strreset_assoc_id;
354202782Stuexen	uint16_t strreset_list[];
355163953Srrs};
356163953Srrs
357163953Srrs/* flags in strreset_flags field */
358163953Srrs#define SCTP_STRRESET_INBOUND_STR  0x0001
359163953Srrs#define SCTP_STRRESET_OUTBOUND_STR 0x0002
360163953Srrs#define SCTP_STRRESET_ALL_STREAMS  0x0004
361163953Srrs#define SCTP_STRRESET_STREAM_LIST  0x0008
362163953Srrs#define SCTP_STRRESET_FAILED       0x0010
363188854Srrs#define SCTP_STRRESET_ADD_STREAM   0x0020
364163953Srrs
365163953Srrs/* SCTP notification event */
366163953Srrsstruct sctp_tlv {
367163953Srrs	uint16_t sn_type;
368163953Srrs	uint16_t sn_flags;
369163953Srrs	uint32_t sn_length;
370163953Srrs};
371163953Srrs
372163953Srrsunion sctp_notification {
373163953Srrs	struct sctp_tlv sn_header;
374163953Srrs	struct sctp_assoc_change sn_assoc_change;
375163953Srrs	struct sctp_paddr_change sn_paddr_change;
376163953Srrs	struct sctp_remote_error sn_remote_error;
377163953Srrs	struct sctp_send_failed sn_send_failed;
378163953Srrs	struct sctp_shutdown_event sn_shutdown_event;
379163953Srrs	struct sctp_adaptation_event sn_adaptation_event;
380215034Sbrucec	/* compatibility same as above */
381163953Srrs	struct sctp_adaption_event sn_adaption_event;
382163953Srrs	struct sctp_pdapi_event sn_pdapi_event;
383163953Srrs	struct sctp_authkey_event sn_auth_event;
384185694Srrs	struct sctp_sender_dry_event sn_sender_dry_event;
385163953Srrs	struct sctp_stream_reset_event sn_strreset_event;
386163953Srrs};
387163953Srrs
388163953Srrs/* notification types */
389202520Srrs#define SCTP_ASSOC_CHANGE			0x0001
390202520Srrs#define SCTP_PEER_ADDR_CHANGE			0x0002
391202520Srrs#define SCTP_REMOTE_ERROR			0x0003
392202520Srrs#define SCTP_SEND_FAILED			0x0004
393202520Srrs#define SCTP_SHUTDOWN_EVENT			0x0005
394202520Srrs#define SCTP_ADAPTATION_INDICATION		0x0006
395163953Srrs/* same as above */
396202520Srrs#define SCTP_ADAPTION_INDICATION		0x0006
397202520Srrs#define SCTP_PARTIAL_DELIVERY_EVENT		0x0007
398202520Srrs#define SCTP_AUTHENTICATION_EVENT		0x0008
399202520Srrs#define SCTP_STREAM_RESET_EVENT			0x0009
400202520Srrs#define SCTP_SENDER_DRY_EVENT			0x000a
401216878Stuexen#define SCTP_NOTIFICATIONS_STOPPED_EVENT	0x000b	/* we don't send this */
402163953Srrs/*
403163953Srrs * socket option structs
404163953Srrs */
405163953Srrs
406163953Srrsstruct sctp_paddrparams {
407170992Srrs	struct sockaddr_storage spp_address;
408163953Srrs	sctp_assoc_t spp_assoc_id;
409163953Srrs	uint32_t spp_hbinterval;
410163953Srrs	uint32_t spp_pathmtu;
411163953Srrs	uint32_t spp_flags;
412163953Srrs	uint32_t spp_ipv6_flowlabel;
413170992Srrs	uint16_t spp_pathmaxrxt;
414163953Srrs	uint8_t spp_ipv4_tos;
415163953Srrs};
416163953Srrs
417163953Srrs#define SPP_HB_ENABLE		0x00000001
418163953Srrs#define SPP_HB_DISABLE		0x00000002
419163953Srrs#define SPP_HB_DEMAND		0x00000004
420163953Srrs#define SPP_PMTUD_ENABLE	0x00000008
421163953Srrs#define SPP_PMTUD_DISABLE	0x00000010
422163953Srrs#define SPP_HB_TIME_IS_ZERO     0x00000080
423163953Srrs#define SPP_IPV6_FLOWLABEL      0x00000100
424163953Srrs#define SPP_IPV4_TOS            0x00000200
425163953Srrs
426163953Srrsstruct sctp_paddrinfo {
427170992Srrs	struct sockaddr_storage spinfo_address;
428163953Srrs	sctp_assoc_t spinfo_assoc_id;
429163953Srrs	int32_t spinfo_state;
430163953Srrs	uint32_t spinfo_cwnd;
431163953Srrs	uint32_t spinfo_srtt;
432163953Srrs	uint32_t spinfo_rto;
433163953Srrs	uint32_t spinfo_mtu;
434163953Srrs};
435163953Srrs
436163953Srrsstruct sctp_rtoinfo {
437163953Srrs	sctp_assoc_t srto_assoc_id;
438163953Srrs	uint32_t srto_initial;
439163953Srrs	uint32_t srto_max;
440163953Srrs	uint32_t srto_min;
441163953Srrs};
442163953Srrs
443163953Srrsstruct sctp_assocparams {
444163953Srrs	sctp_assoc_t sasoc_assoc_id;
445163953Srrs	uint32_t sasoc_peer_rwnd;
446163953Srrs	uint32_t sasoc_local_rwnd;
447163953Srrs	uint32_t sasoc_cookie_life;
448170992Srrs	uint16_t sasoc_asocmaxrxt;
449170992Srrs	uint16_t sasoc_number_peer_destinations;
450163953Srrs};
451163953Srrs
452163953Srrsstruct sctp_setprim {
453170992Srrs	struct sockaddr_storage ssp_addr;
454163953Srrs	sctp_assoc_t ssp_assoc_id;
455170992Srrs	uint8_t ssp_padding[4];
456163953Srrs};
457163953Srrs
458163953Srrsstruct sctp_setpeerprim {
459170992Srrs	struct sockaddr_storage sspp_addr;
460163953Srrs	sctp_assoc_t sspp_assoc_id;
461170992Srrs	uint8_t sspp_padding[4];
462163953Srrs};
463163953Srrs
464163953Srrsstruct sctp_getaddresses {
465163953Srrs	sctp_assoc_t sget_assoc_id;
466163953Srrs	/* addr is filled in for N * sockaddr_storage */
467163953Srrs	struct sockaddr addr[1];
468163953Srrs};
469163953Srrs
470163953Srrsstruct sctp_setstrm_timeout {
471163953Srrs	sctp_assoc_t ssto_assoc_id;
472163953Srrs	uint32_t ssto_timeout;
473163953Srrs	uint32_t ssto_streamid_start;
474163953Srrs	uint32_t ssto_streamid_end;
475163953Srrs};
476163953Srrs
477163953Srrsstruct sctp_status {
478163953Srrs	sctp_assoc_t sstat_assoc_id;
479163953Srrs	int32_t sstat_state;
480163953Srrs	uint32_t sstat_rwnd;
481163953Srrs	uint16_t sstat_unackdata;
482163953Srrs	uint16_t sstat_penddata;
483163953Srrs	uint16_t sstat_instrms;
484163953Srrs	uint16_t sstat_outstrms;
485163953Srrs	uint32_t sstat_fragmentation_point;
486163953Srrs	struct sctp_paddrinfo sstat_primary;
487163953Srrs};
488163953Srrs
489163953Srrs/*
490163953Srrs * AUTHENTICATION support
491163953Srrs */
492163953Srrs/* SCTP_AUTH_CHUNK */
493163953Srrsstruct sctp_authchunk {
494163953Srrs	uint8_t sauth_chunk;
495163953Srrs};
496163953Srrs
497163953Srrs/* SCTP_AUTH_KEY */
498163953Srrsstruct sctp_authkey {
499163953Srrs	sctp_assoc_t sca_assoc_id;
500163953Srrs	uint16_t sca_keynumber;
501202782Stuexen	uint8_t sca_key[];
502163953Srrs};
503163953Srrs
504163953Srrs/* SCTP_HMAC_IDENT */
505163953Srrsstruct sctp_hmacalgo {
506179141Srrs	uint32_t shmac_number_of_idents;
507202782Stuexen	uint16_t shmac_idents[];
508163953Srrs};
509163953Srrs
510163953Srrs/* AUTH hmac_id */
511163953Srrs#define SCTP_AUTH_HMAC_ID_RSVD		0x0000
512163953Srrs#define SCTP_AUTH_HMAC_ID_SHA1		0x0001	/* default, mandatory */
513163953Srrs#define SCTP_AUTH_HMAC_ID_SHA256	0x0003
514171745Srrs#define SCTP_AUTH_HMAC_ID_SHA224	0x0004
515171745Srrs#define SCTP_AUTH_HMAC_ID_SHA384	0x0005
516171745Srrs#define SCTP_AUTH_HMAC_ID_SHA512	0x0006
517163953Srrs
518163953Srrs
519163953Srrs/* SCTP_AUTH_ACTIVE_KEY / SCTP_AUTH_DELETE_KEY */
520163953Srrsstruct sctp_authkeyid {
521163953Srrs	sctp_assoc_t scact_assoc_id;
522163953Srrs	uint16_t scact_keynumber;
523163953Srrs};
524163953Srrs
525163953Srrs/* SCTP_PEER_AUTH_CHUNKS / SCTP_LOCAL_AUTH_CHUNKS */
526163953Srrsstruct sctp_authchunks {
527163953Srrs	sctp_assoc_t gauth_assoc_id;
528202782Stuexen	uint8_t gauth_chunks[];
529163953Srrs};
530163953Srrs
531163953Srrsstruct sctp_assoc_value {
532163953Srrs	sctp_assoc_t assoc_id;
533163953Srrs	uint32_t assoc_value;
534163953Srrs};
535163953Srrs
536217760Stuexenstruct sctp_stream_value {
537217760Stuexen	sctp_assoc_t assoc_id;
538217760Stuexen	uint16_t stream_id;
539217760Stuexen	uint16_t stream_value;
540217760Stuexen};
541217760Stuexen
542163953Srrsstruct sctp_assoc_ids {
543185694Srrs	uint32_t gaids_number_of_ids;
544202782Stuexen	sctp_assoc_t gaids_assoc_id[];
545163953Srrs};
546163953Srrs
547170056Srrsstruct sctp_sack_info {
548170056Srrs	sctp_assoc_t sack_assoc_id;
549170056Srrs	uint32_t sack_delay;
550170056Srrs	uint32_t sack_freq;
551170056Srrs};
552170056Srrs
553215410Stuexenstruct sctp_timeouts {
554215410Stuexen	sctp_assoc_t stimo_assoc_id;
555215410Stuexen	uint32_t stimo_init;
556215410Stuexen	uint32_t stimo_data;
557215410Stuexen	uint32_t stimo_sack;
558215410Stuexen	uint32_t stimo_shutdown;
559215410Stuexen	uint32_t stimo_heartbeat;
560215410Stuexen	uint32_t stimo_cookie;
561215410Stuexen	uint32_t stimo_shutdownack;
562215410Stuexen};
563215410Stuexen
564163953Srrsstruct sctp_cwnd_args {
565170992Srrs	struct sctp_nets *net;	/* network to *//* FIXME: LP64 issue */
566163953Srrs	uint32_t cwnd_new_value;/* cwnd in k */
567163953Srrs	uint32_t pseudo_cumack;
568190689Srrs	uint16_t inflight;	/* flightsize in k */
569190689Srrs	uint16_t cwnd_augment;	/* increment to it */
570163953Srrs	uint8_t meets_pseudo_cumack;
571163953Srrs	uint8_t need_new_pseudo_cumack;
572163953Srrs	uint8_t cnt_in_send;
573163953Srrs	uint8_t cnt_in_str;
574163953Srrs};
575163953Srrs
576163953Srrsstruct sctp_blk_args {
577163953Srrs	uint32_t onsb;		/* in 1k bytes */
578163953Srrs	uint32_t sndlen;	/* len of send being attempted */
579163953Srrs	uint32_t peer_rwnd;	/* rwnd of peer */
580163953Srrs	uint16_t send_sent_qcnt;/* chnk cnt */
581163953Srrs	uint16_t stream_qcnt;	/* chnk cnt */
582163953Srrs	uint16_t chunks_on_oque;/* chunks out */
583163953Srrs	uint16_t flight_size;	/* flight size in k */
584163953Srrs};
585163953Srrs
586163953Srrs/*
587163953Srrs * Max we can reset in one setting, note this is dictated not by the define
588163953Srrs * but the size of a mbuf cluster so don't change this define and think you
589163953Srrs * can specify more. You must do multiple resets if you want to reset more
590163953Srrs * than SCTP_MAX_EXPLICIT_STR_RESET.
591163953Srrs */
592163953Srrs#define SCTP_MAX_EXPLICT_STR_RESET   1000
593163953Srrs
594163953Srrs#define SCTP_RESET_LOCAL_RECV  0x0001
595163953Srrs#define SCTP_RESET_LOCAL_SEND  0x0002
596163953Srrs#define SCTP_RESET_BOTH        0x0003
597163953Srrs#define SCTP_RESET_TSN         0x0004
598188854Srrs#define SCTP_RESET_ADD_STREAMS 0x0005
599163953Srrs
600163953Srrsstruct sctp_stream_reset {
601163953Srrs	sctp_assoc_t strrst_assoc_id;
602163953Srrs	uint16_t strrst_flags;
603163953Srrs	uint16_t strrst_num_streams;	/* 0 == ALL */
604202782Stuexen	uint16_t strrst_list[];	/* list if strrst_num_streams is not 0 */
605163953Srrs};
606163953Srrs
607163953Srrs
608163953Srrsstruct sctp_get_nonce_values {
609163953Srrs	sctp_assoc_t gn_assoc_id;
610163953Srrs	uint32_t gn_peers_tag;
611163953Srrs	uint32_t gn_local_tag;
612163953Srrs};
613163953Srrs
614163953Srrs/* Debugging logs */
615163953Srrsstruct sctp_str_log {
616170992Srrs	void *stcb;		/* FIXME: LP64 issue */
617163953Srrs	uint32_t n_tsn;
618163953Srrs	uint32_t e_tsn;
619163953Srrs	uint16_t n_sseq;
620163953Srrs	uint16_t e_sseq;
621164181Srrs	uint16_t strm;
622163953Srrs};
623163953Srrs
624163953Srrsstruct sctp_sb_log {
625170992Srrs	void *stcb;		/* FIXME: LP64 issue */
626163953Srrs	uint32_t so_sbcc;
627163953Srrs	uint32_t stcb_sbcc;
628163953Srrs	uint32_t incr;
629163953Srrs};
630163953Srrs
631163953Srrsstruct sctp_fr_log {
632163953Srrs	uint32_t largest_tsn;
633163953Srrs	uint32_t largest_new_tsn;
634163953Srrs	uint32_t tsn;
635163953Srrs};
636163953Srrs
637163953Srrsstruct sctp_fr_map {
638163953Srrs	uint32_t base;
639163953Srrs	uint32_t cum;
640163953Srrs	uint32_t high;
641163953Srrs};
642163953Srrs
643163953Srrsstruct sctp_rwnd_log {
644163953Srrs	uint32_t rwnd;
645163953Srrs	uint32_t send_size;
646163953Srrs	uint32_t overhead;
647163953Srrs	uint32_t new_rwnd;
648163953Srrs};
649163953Srrs
650163953Srrsstruct sctp_mbcnt_log {
651163953Srrs	uint32_t total_queue_size;
652163953Srrs	uint32_t size_change;
653163953Srrs	uint32_t total_queue_mb_size;
654163953Srrs	uint32_t mbcnt_change;
655163953Srrs};
656163953Srrs
657163953Srrsstruct sctp_sack_log {
658163953Srrs	uint32_t cumack;
659163953Srrs	uint32_t oldcumack;
660163953Srrs	uint32_t tsn;
661163953Srrs	uint16_t numGaps;
662163953Srrs	uint16_t numDups;
663163953Srrs};
664163953Srrs
665163953Srrsstruct sctp_lock_log {
666170992Srrs	void *sock;		/* FIXME: LP64 issue */
667170992Srrs	void *inp;		/* FIXME: LP64 issue */
668163953Srrs	uint8_t tcb_lock;
669163953Srrs	uint8_t inp_lock;
670163953Srrs	uint8_t info_lock;
671163953Srrs	uint8_t sock_lock;
672163953Srrs	uint8_t sockrcvbuf_lock;
673163953Srrs	uint8_t socksndbuf_lock;
674163953Srrs	uint8_t create_lock;
675163953Srrs	uint8_t resv;
676163953Srrs};
677163953Srrs
678163953Srrsstruct sctp_rto_log {
679170992Srrs	void *net;		/* FIXME: LP64 issue */
680163953Srrs	uint32_t rtt;
681163953Srrs};
682163953Srrs
683163953Srrsstruct sctp_nagle_log {
684170992Srrs	void *stcb;		/* FIXME: LP64 issue */
685163953Srrs	uint32_t total_flight;
686163953Srrs	uint32_t total_in_queue;
687163953Srrs	uint16_t count_in_queue;
688163953Srrs	uint16_t count_in_flight;
689163953Srrs};
690163953Srrs
691163953Srrsstruct sctp_sbwake_log {
692170992Srrs	void *stcb;		/* FIXME: LP64 issue */
693163953Srrs	uint16_t send_q;
694163953Srrs	uint16_t sent_q;
695163953Srrs	uint16_t flight;
696163953Srrs	uint16_t wake_cnt;
697163953Srrs	uint8_t stream_qcnt;	/* chnk cnt */
698163953Srrs	uint8_t chunks_on_oque;	/* chunks out */
699163953Srrs	uint8_t sbflags;
700163953Srrs	uint8_t sctpflags;
701163953Srrs};
702163953Srrs
703163953Srrsstruct sctp_misc_info {
704163953Srrs	uint32_t log1;
705163953Srrs	uint32_t log2;
706163953Srrs	uint32_t log3;
707163953Srrs	uint32_t log4;
708163953Srrs};
709163953Srrs
710163953Srrsstruct sctp_log_closing {
711170992Srrs	void *inp;		/* FIXME: LP64 issue */
712170992Srrs	void *stcb;		/* FIXME: LP64 issue */
713163953Srrs	uint32_t sctp_flags;
714163953Srrs	uint16_t state;
715163953Srrs	int16_t loc;
716163953Srrs};
717163953Srrs
718163953Srrsstruct sctp_mbuf_log {
719170992Srrs	struct mbuf *mp;	/* FIXME: LP64 issue */
720163953Srrs	caddr_t ext;
721163953Srrs	caddr_t data;
722163953Srrs	uint16_t size;
723163953Srrs	uint8_t refcnt;
724163953Srrs	uint8_t mbuf_flags;
725163953Srrs};
726163953Srrs
727163953Srrsstruct sctp_cwnd_log {
728170744Srrs	uint64_t time_event;
729163953Srrs	uint8_t from;
730163953Srrs	uint8_t event_type;
731163953Srrs	uint8_t resv[2];
732163953Srrs	union {
733163953Srrs		struct sctp_log_closing close;
734163953Srrs		struct sctp_blk_args blk;
735163953Srrs		struct sctp_cwnd_args cwnd;
736163953Srrs		struct sctp_str_log strlog;
737163953Srrs		struct sctp_fr_log fr;
738163953Srrs		struct sctp_fr_map map;
739163953Srrs		struct sctp_rwnd_log rwnd;
740163953Srrs		struct sctp_mbcnt_log mbcnt;
741163953Srrs		struct sctp_sack_log sack;
742163953Srrs		struct sctp_lock_log lock;
743163953Srrs		struct sctp_rto_log rto;
744163953Srrs		struct sctp_sb_log sb;
745163953Srrs		struct sctp_nagle_log nagle;
746163953Srrs		struct sctp_sbwake_log wake;
747163953Srrs		struct sctp_mbuf_log mb;
748163953Srrs		struct sctp_misc_info misc;
749163953Srrs	}     x;
750163953Srrs};
751163953Srrs
752163953Srrsstruct sctp_cwnd_log_req {
753170992Srrs	int32_t num_in_log;	/* Number in log */
754170992Srrs	int32_t num_ret;	/* Number returned */
755170992Srrs	int32_t start_at;	/* start at this one */
756170992Srrs	int32_t end_at;		/* end at this one */
757202782Stuexen	struct sctp_cwnd_log log[];
758163953Srrs};
759163953Srrs
760172091Srrsstruct sctp_timeval {
761172091Srrs	uint32_t tv_sec;
762172091Srrs	uint32_t tv_usec;
763172091Srrs};
764172091Srrs
765163953Srrsstruct sctpstat {
766191890Srrs	struct sctp_timeval sctps_discontinuitytime;	/* sctpStats 18
767191890Srrs							 * (TimeStamp) */
768163953Srrs	/* MIB according to RFC 3873 */
769170992Srrs	uint32_t sctps_currestab;	/* sctpStats  1   (Gauge32) */
770170992Srrs	uint32_t sctps_activeestab;	/* sctpStats  2 (Counter32) */
771170992Srrs	uint32_t sctps_restartestab;
772170992Srrs	uint32_t sctps_collisionestab;
773170992Srrs	uint32_t sctps_passiveestab;	/* sctpStats  3 (Counter32) */
774170992Srrs	uint32_t sctps_aborted;	/* sctpStats  4 (Counter32) */
775170992Srrs	uint32_t sctps_shutdown;/* sctpStats  5 (Counter32) */
776170992Srrs	uint32_t sctps_outoftheblue;	/* sctpStats  6 (Counter32) */
777170992Srrs	uint32_t sctps_checksumerrors;	/* sctpStats  7 (Counter32) */
778170992Srrs	uint32_t sctps_outcontrolchunks;	/* sctpStats  8 (Counter64) */
779170992Srrs	uint32_t sctps_outorderchunks;	/* sctpStats  9 (Counter64) */
780170992Srrs	uint32_t sctps_outunorderchunks;	/* sctpStats 10 (Counter64) */
781170992Srrs	uint32_t sctps_incontrolchunks;	/* sctpStats 11 (Counter64) */
782170992Srrs	uint32_t sctps_inorderchunks;	/* sctpStats 12 (Counter64) */
783170992Srrs	uint32_t sctps_inunorderchunks;	/* sctpStats 13 (Counter64) */
784170992Srrs	uint32_t sctps_fragusrmsgs;	/* sctpStats 14 (Counter64) */
785170992Srrs	uint32_t sctps_reasmusrmsgs;	/* sctpStats 15 (Counter64) */
786170992Srrs	uint32_t sctps_outpackets;	/* sctpStats 16 (Counter64) */
787170992Srrs	uint32_t sctps_inpackets;	/* sctpStats 17 (Counter64) */
788170992Srrs
789163953Srrs	/* input statistics: */
790170992Srrs	uint32_t sctps_recvpackets;	/* total input packets        */
791170992Srrs	uint32_t sctps_recvdatagrams;	/* total input datagrams      */
792170992Srrs	uint32_t sctps_recvpktwithdata;	/* total packets that had data */
793170992Srrs	uint32_t sctps_recvsacks;	/* total input SACK chunks    */
794170992Srrs	uint32_t sctps_recvdata;/* total input DATA chunks    */
795170992Srrs	uint32_t sctps_recvdupdata;	/* total input duplicate DATA chunks */
796170992Srrs	uint32_t sctps_recvheartbeat;	/* total input HB chunks      */
797170992Srrs	uint32_t sctps_recvheartbeatack;	/* total input HB-ACK chunks  */
798170992Srrs	uint32_t sctps_recvecne;/* total input ECNE chunks    */
799170992Srrs	uint32_t sctps_recvauth;/* total input AUTH chunks    */
800170992Srrs	uint32_t sctps_recvauthmissing;	/* total input chunks missing AUTH */
801170992Srrs	uint32_t sctps_recvivalhmacid;	/* total number of invalid HMAC ids
802163953Srrs					 * received */
803170992Srrs	uint32_t sctps_recvivalkeyid;	/* total number of invalid secret ids
804163953Srrs					 * received */
805170992Srrs	uint32_t sctps_recvauthfailed;	/* total number of auth failed */
806170992Srrs	uint32_t sctps_recvexpress;	/* total fast path receives all one
807163953Srrs					 * chunk */
808170992Srrs	uint32_t sctps_recvexpressm;	/* total fast path multi-part data */
809188067Srrs	uint32_t sctps_recvnocrc;
810188067Srrs	uint32_t sctps_recvswcrc;
811188067Srrs	uint32_t sctps_recvhwcrc;
812188067Srrs
813163953Srrs	/* output statistics: */
814170992Srrs	uint32_t sctps_sendpackets;	/* total output packets       */
815170992Srrs	uint32_t sctps_sendsacks;	/* total output SACKs         */
816170992Srrs	uint32_t sctps_senddata;/* total output DATA chunks   */
817170992Srrs	uint32_t sctps_sendretransdata;	/* total output retransmitted DATA
818163953Srrs					 * chunks */
819170992Srrs	uint32_t sctps_sendfastretrans;	/* total output fast retransmitted
820163953Srrs					 * DATA chunks */
821170992Srrs	uint32_t sctps_sendmultfastretrans;	/* total FR's that happened
822168755Srrs						 * more than once to same
823168755Srrs						 * chunk (u-del multi-fr
824168755Srrs						 * algo). */
825170992Srrs	uint32_t sctps_sendheartbeat;	/* total output HB chunks     */
826170992Srrs	uint32_t sctps_sendecne;/* total output ECNE chunks    */
827170992Srrs	uint32_t sctps_sendauth;/* total output AUTH chunks FIXME   */
828170992Srrs	uint32_t sctps_senderrors;	/* ip_output error counter */
829188067Srrs	uint32_t sctps_sendnocrc;
830188067Srrs	uint32_t sctps_sendswcrc;
831188067Srrs	uint32_t sctps_sendhwcrc;
832163953Srrs	/* PCKDROPREP statistics: */
833170992Srrs	uint32_t sctps_pdrpfmbox;	/* Packet drop from middle box */
834170992Srrs	uint32_t sctps_pdrpfehos;	/* P-drop from end host */
835170992Srrs	uint32_t sctps_pdrpmbda;/* P-drops with data */
836170992Srrs	uint32_t sctps_pdrpmbct;/* P-drops, non-data, non-endhost */
837170992Srrs	uint32_t sctps_pdrpbwrpt;	/* P-drop, non-endhost, bandwidth rep
838170992Srrs					 * only */
839170992Srrs	uint32_t sctps_pdrpcrupt;	/* P-drop, not enough for chunk header */
840170992Srrs	uint32_t sctps_pdrpnedat;	/* P-drop, not enough data to confirm */
841170992Srrs	uint32_t sctps_pdrppdbrk;	/* P-drop, where process_chunk_drop
842170992Srrs					 * said break */
843170992Srrs	uint32_t sctps_pdrptsnnf;	/* P-drop, could not find TSN */
844170992Srrs	uint32_t sctps_pdrpdnfnd;	/* P-drop, attempt reverse TSN lookup */
845170992Srrs	uint32_t sctps_pdrpdiwnp;	/* P-drop, e-host confirms zero-rwnd */
846170992Srrs	uint32_t sctps_pdrpdizrw;	/* P-drop, midbox confirms no space */
847170992Srrs	uint32_t sctps_pdrpbadd;/* P-drop, data did not match TSN */
848170992Srrs	uint32_t sctps_pdrpmark;/* P-drop, TSN's marked for Fast Retran */
849163953Srrs	/* timeouts */
850170992Srrs	uint32_t sctps_timoiterator;	/* Number of iterator timers that
851168755Srrs					 * fired */
852170992Srrs	uint32_t sctps_timodata;/* Number of T3 data time outs */
853170992Srrs	uint32_t sctps_timowindowprobe;	/* Number of window probe (T3) timers
854168755Srrs					 * that fired */
855170992Srrs	uint32_t sctps_timoinit;/* Number of INIT timers that fired */
856170992Srrs	uint32_t sctps_timosack;/* Number of sack timers that fired */
857170992Srrs	uint32_t sctps_timoshutdown;	/* Number of shutdown timers that
858168755Srrs					 * fired */
859170992Srrs	uint32_t sctps_timoheartbeat;	/* Number of heartbeat timers that
860168755Srrs					 * fired */
861170992Srrs	uint32_t sctps_timocookie;	/* Number of times a cookie timeout
862168755Srrs					 * fired */
863170992Srrs	uint32_t sctps_timosecret;	/* Number of times an endpoint changed
864170992Srrs					 * its cookie secret */
865170992Srrs	uint32_t sctps_timopathmtu;	/* Number of PMTU timers that fired */
866170992Srrs	uint32_t sctps_timoshutdownack;	/* Number of shutdown ack timers that
867168755Srrs					 * fired */
868170992Srrs	uint32_t sctps_timoshutdownguard;	/* Number of shutdown guard
869170992Srrs						 * timers that fired */
870170992Srrs	uint32_t sctps_timostrmrst;	/* Number of stream reset timers that
871168755Srrs					 * fired */
872170992Srrs	uint32_t sctps_timoearlyfr;	/* Number of early FR timers that
873168755Srrs					 * fired */
874170992Srrs	uint32_t sctps_timoasconf;	/* Number of times an asconf timer
875170992Srrs					 * fired */
876172091Srrs	uint32_t sctps_timodelprim;	/* Number of times a prim_deleted
877172091Srrs					 * timer fired */
878170992Srrs	uint32_t sctps_timoautoclose;	/* Number of times auto close timer
879170992Srrs					 * fired */
880170992Srrs	uint32_t sctps_timoassockill;	/* Number of asoc free timers expired */
881170992Srrs	uint32_t sctps_timoinpkill;	/* Number of inp free timers expired */
882163953Srrs	/* Early fast retransmission counters */
883170992Srrs	uint32_t sctps_earlyfrstart;
884170992Srrs	uint32_t sctps_earlyfrstop;
885170992Srrs	uint32_t sctps_earlyfrmrkretrans;
886170992Srrs	uint32_t sctps_earlyfrstpout;
887170992Srrs	uint32_t sctps_earlyfrstpidsck1;
888170992Srrs	uint32_t sctps_earlyfrstpidsck2;
889170992Srrs	uint32_t sctps_earlyfrstpidsck3;
890170992Srrs	uint32_t sctps_earlyfrstpidsck4;
891170992Srrs	uint32_t sctps_earlyfrstrid;
892170992Srrs	uint32_t sctps_earlyfrstrout;
893170992Srrs	uint32_t sctps_earlyfrstrtmr;
894215034Sbrucec	/* others */
895170992Srrs	uint32_t sctps_hdrops;	/* packet shorter than header */
896170992Srrs	uint32_t sctps_badsum;	/* checksum error             */
897170992Srrs	uint32_t sctps_noport;	/* no endpoint for port       */
898170992Srrs	uint32_t sctps_badvtag;	/* bad v-tag                  */
899170992Srrs	uint32_t sctps_badsid;	/* bad SID                    */
900170992Srrs	uint32_t sctps_nomem;	/* no memory                  */
901170992Srrs	uint32_t sctps_fastretransinrtt;	/* number of multiple FR in a
902170992Srrs						 * RTT window */
903170992Srrs	uint32_t sctps_markedretrans;
904170992Srrs	uint32_t sctps_naglesent;	/* nagle allowed sending      */
905215034Sbrucec	uint32_t sctps_naglequeued;	/* nagle doesn't allow sending */
906215034Sbrucec	uint32_t sctps_maxburstqueued;	/* max burst doesn't allow sending */
907170992Srrs	uint32_t sctps_ifnomemqueued;	/* look ahead tells us no memory in
908168755Srrs					 * interface ring buffer OR we had a
909168755Srrs					 * send error and are queuing one
910168755Srrs					 * send. */
911170992Srrs	uint32_t sctps_windowprobed;	/* total number of window probes sent */
912170992Srrs	uint32_t sctps_lowlevelerr;	/* total times an output error causes
913168755Srrs					 * us to clamp down on next user send. */
914170992Srrs	uint32_t sctps_lowlevelerrusr;	/* total times sctp_senderrors were
915168755Srrs					 * caused from a user send from a user
916168755Srrs					 * invoked send not a sack response */
917170992Srrs	uint32_t sctps_datadropchklmt;	/* Number of in data drops due to
918168755Srrs					 * chunk limit reached */
919170992Srrs	uint32_t sctps_datadroprwnd;	/* Number of in data drops due to rwnd
920168755Srrs					 * limit reached */
921170992Srrs	uint32_t sctps_ecnereducedcwnd;	/* Number of times a ECN reduced the
922168755Srrs					 * cwnd */
923170992Srrs	uint32_t sctps_vtagexpress;	/* Used express lookup via vtag */
924170992Srrs	uint32_t sctps_vtagbogus;	/* Collision in express lookup. */
925170992Srrs	uint32_t sctps_primary_randry;	/* Number of times the sender ran dry
926163953Srrs					 * of user data on primary */
927170992Srrs	uint32_t sctps_cmt_randry;	/* Same for above */
928170992Srrs	uint32_t sctps_slowpath_sack;	/* Sacks the slow way */
929170992Srrs	uint32_t sctps_wu_sacks_sent;	/* Window Update only sacks sent */
930170992Srrs	uint32_t sctps_sends_with_flags;	/* number of sends with
931170992Srrs						 * sinfo_flags !=0 */
932215817Srrs	uint32_t sctps_sends_with_unord;	/* number of unordered sends */
933170992Srrs	uint32_t sctps_sends_with_eof;	/* number of sends with EOF flag set */
934170992Srrs	uint32_t sctps_sends_with_abort;	/* number of sends with ABORT
935170992Srrs						 * flag set */
936170992Srrs	uint32_t sctps_protocol_drain_calls;	/* number of times protocol
937168755Srrs						 * drain called */
938170992Srrs	uint32_t sctps_protocol_drains_done;	/* number of times we did a
939168755Srrs						 * protocol drain */
940170992Srrs	uint32_t sctps_read_peeks;	/* Number of times recv was called
941170992Srrs					 * with peek */
942170992Srrs	uint32_t sctps_cached_chk;	/* Number of cached chunks used */
943170992Srrs	uint32_t sctps_cached_strmoq;	/* Number of cached stream oq's used */
944215034Sbrucec	uint32_t sctps_left_abandon;	/* Number of unread messages abandoned
945168859Srrs					 * by close */
946188854Srrs	uint32_t sctps_send_burst_avoid;	/* Unused */
947170992Srrs	uint32_t sctps_send_cwnd_avoid;	/* Send cwnd full  avoidance, already
948169352Srrs					 * max burst inflight to net */
949170992Srrs	uint32_t sctps_fwdtsn_map_over;	/* number of map array over-runs via
950170091Srrs					 * fwd-tsn's */
951218037Srrs	uint32_t sctps_queue_upd_ecne;	/* Number of times we queued or
952218037Srrs					 * updated an ECN chunk on send queue */
953218037Srrs	uint32_t sctps_reserved[31];	/* Future ABI compat - remove int's
954191890Srrs					 * from here when adding new */
955163953Srrs};
956163953Srrs
957163953Srrs#define SCTP_STAT_INCR(_x) SCTP_STAT_INCR_BY(_x,1)
958163953Srrs#define SCTP_STAT_DECR(_x) SCTP_STAT_DECR_BY(_x,1)
959205629Srrs#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
960205629Srrs#define SCTP_STAT_INCR_BY(_x,_d) (SCTP_BASE_STATS[PCPU_GET(cpuid)]._x += _d)
961205629Srrs#define SCTP_STAT_DECR_BY(_x,_d) (SCTP_BASE_STATS[PCPU_GET(cpuid)]._x -= _d)
962205629Srrs#else
963179783Srrs#define SCTP_STAT_INCR_BY(_x,_d) atomic_add_int(&SCTP_BASE_STAT(_x), _d)
964179783Srrs#define SCTP_STAT_DECR_BY(_x,_d) atomic_subtract_int(&SCTP_BASE_STAT(_x), _d)
965205629Srrs#endif
966163953Srrs/* The following macros are for handling MIB values, */
967163953Srrs#define SCTP_STAT_INCR_COUNTER32(_x) SCTP_STAT_INCR(_x)
968163953Srrs#define SCTP_STAT_INCR_COUNTER64(_x) SCTP_STAT_INCR(_x)
969163953Srrs#define SCTP_STAT_INCR_GAUGE32(_x) SCTP_STAT_INCR(_x)
970163953Srrs#define SCTP_STAT_DECR_COUNTER32(_x) SCTP_STAT_DECR(_x)
971163953Srrs#define SCTP_STAT_DECR_COUNTER64(_x) SCTP_STAT_DECR(_x)
972163953Srrs#define SCTP_STAT_DECR_GAUGE32(_x) SCTP_STAT_DECR(_x)
973163953Srrs
974164085Srrsunion sctp_sockstore {
975167598Srrs#if defined(INET) || !defined(_KERNEL)
976164085Srrs	struct sockaddr_in sin;
977164085Srrs#endif
978167598Srrs#if defined(INET6) || !defined(_KERNEL)
979164085Srrs	struct sockaddr_in6 sin6;
980164085Srrs#endif
981164085Srrs	struct sockaddr sa;
982164085Srrs};
983164085Srrs
984212242Stuexen
985212242Stuexen/***********************************/
986212242Stuexen/* And something for us old timers */
987212242Stuexen/***********************************/
988212242Stuexen
989212242Stuexen#ifndef ntohll
990212242Stuexen#include <sys/endian.h>
991212242Stuexen#define ntohll(x) be64toh(x)
992212242Stuexen#endif
993212242Stuexen
994212242Stuexen#ifndef htonll
995212242Stuexen#include <sys/endian.h>
996212242Stuexen#define htonll(x) htobe64(x)
997212242Stuexen#endif
998212242Stuexen/***********************************/
999212242Stuexen
1000212242Stuexen
1001165220Srrsstruct xsctp_inpcb {
1002165220Srrs	uint32_t last;
1003165220Srrs	uint32_t flags;
1004165220Srrs	uint32_t features;
1005165220Srrs	uint32_t total_sends;
1006165220Srrs	uint32_t total_recvs;
1007165220Srrs	uint32_t total_nospaces;
1008169352Srrs	uint32_t fragmentation_point;
1009170992Srrs	uint16_t local_port;
1010170056Srrs	uint16_t qlen;
1011170056Srrs	uint16_t maxqlen;
1012190842Srrs	uint32_t extra_padding[32];	/* future */
1013165220Srrs};
1014164085Srrs
1015165220Srrsstruct xsctp_tcb {
1016170992Srrs	union sctp_sockstore primary_addr;	/* sctpAssocEntry 5/6 */
1017170056Srrs	uint32_t last;
1018170056Srrs	uint32_t heartbeat_interval;	/* sctpAssocEntry 7   */
1019170056Srrs	uint32_t state;		/* sctpAssocEntry 8   */
1020170056Srrs	uint32_t in_streams;	/* sctpAssocEntry 9   */
1021170056Srrs	uint32_t out_streams;	/* sctpAssocEntry 10  */
1022170056Srrs	uint32_t max_nr_retrans;/* sctpAssocEntry 11  */
1023170056Srrs	uint32_t primary_process;	/* sctpAssocEntry 12  */
1024170056Srrs	uint32_t T1_expireries;	/* sctpAssocEntry 13  */
1025170056Srrs	uint32_t T2_expireries;	/* sctpAssocEntry 14  */
1026170056Srrs	uint32_t retransmitted_tsns;	/* sctpAssocEntry 15  */
1027165220Srrs	uint32_t total_sends;
1028165220Srrs	uint32_t total_recvs;
1029165220Srrs	uint32_t local_tag;
1030165220Srrs	uint32_t remote_tag;
1031165220Srrs	uint32_t initial_tsn;
1032165220Srrs	uint32_t highest_tsn;
1033165220Srrs	uint32_t cumulative_tsn;
1034165220Srrs	uint32_t cumulative_tsn_ack;
1035169352Srrs	uint32_t mtu;
1036170091Srrs	uint32_t refcnt;
1037170992Srrs	uint16_t local_port;	/* sctpAssocEntry 3   */
1038170992Srrs	uint16_t remote_port;	/* sctpAssocEntry 4   */
1039172091Srrs	struct sctp_timeval start_time;	/* sctpAssocEntry 16  */
1040172091Srrs	struct sctp_timeval discontinuity_time;	/* sctpAssocEntry 17  */
1041188577Srrs	uint32_t peers_rwnd;
1042188067Srrs	sctp_assoc_t assoc_id;	/* sctpAssocEntry 1   */
1043190842Srrs	uint32_t extra_padding[32];	/* future */
1044165220Srrs};
1045165220Srrs
1046165220Srrsstruct xsctp_laddr {
1047170992Srrs	union sctp_sockstore address;	/* sctpAssocLocalAddrEntry 1/2 */
1048170056Srrs	uint32_t last;
1049172091Srrs	struct sctp_timeval start_time;	/* sctpAssocLocalAddrEntry 3   */
1050190842Srrs	uint32_t extra_padding[32];	/* future */
1051165220Srrs};
1052165220Srrs
1053165220Srrsstruct xsctp_raddr {
1054170992Srrs	union sctp_sockstore address;	/* sctpAssocLocalRemEntry 1/2 */
1055170056Srrs	uint32_t last;
1056170056Srrs	uint32_t rto;		/* sctpAssocLocalRemEntry 5   */
1057170056Srrs	uint32_t max_path_rtx;	/* sctpAssocLocalRemEntry 6   */
1058170056Srrs	uint32_t rtx;		/* sctpAssocLocalRemEntry 7   */
1059170056Srrs	uint32_t error_counter;	/* */
1060170056Srrs	uint32_t cwnd;		/* */
1061170056Srrs	uint32_t flight_size;	/* */
1062170056Srrs	uint32_t mtu;		/* */
1063170992Srrs	uint8_t active;		/* sctpAssocLocalRemEntry 3   */
1064170992Srrs	uint8_t confirmed;	/* */
1065170992Srrs	uint8_t heartbeat_enabled;	/* sctpAssocLocalRemEntry 4   */
1066172091Srrs	struct sctp_timeval start_time;	/* sctpAssocLocalRemEntry 8   */
1067190842Srrs	uint32_t rtt;
1068190842Srrs	uint32_t extra_padding[32];	/* future */
1069165220Srrs};
1070165220Srrs
1071172157Srrs#define SCTP_MAX_LOGGING_SIZE 30000
1072172157Srrs#define SCTP_TRACE_PARAMS 6	/* This number MUST be even   */
1073172157Srrs
1074172157Srrsstruct sctp_log_entry {
1075172218Srrs	uint64_t timestamp;
1076172157Srrs	uint32_t subsys;
1077172157Srrs	uint32_t padding;
1078172157Srrs	uint32_t params[SCTP_TRACE_PARAMS];
1079172157Srrs};
1080172157Srrs
1081172157Srrsstruct sctp_log {
1082172157Srrs	struct sctp_log_entry entry[SCTP_MAX_LOGGING_SIZE];
1083172157Srrs	uint32_t index;
1084172157Srrs	uint32_t padding;
1085172157Srrs};
1086172157Srrs
1087163953Srrs/*
1088163953Srrs * Kernel defined for sctp_send
1089163953Srrs */
1090180387Srrs#if defined(_KERNEL) || defined(__Userspace__)
1091163953Srrsint
1092163953Srrssctp_lower_sosend(struct socket *so,
1093163953Srrs    struct sockaddr *addr,
1094163953Srrs    struct uio *uio,
1095169352Srrs    struct mbuf *i_pak,
1096163953Srrs    struct mbuf *control,
1097163953Srrs    int flags,
1098168709Srrs    struct sctp_sndrcvinfo *srcv
1099168709Srrs    ,struct thread *p
1100163953Srrs);
1101163953Srrs
1102163953Srrsint
1103163953Srrssctp_sorecvmsg(struct socket *so,
1104163953Srrs    struct uio *uio,
1105163953Srrs    struct mbuf **mp,
1106163953Srrs    struct sockaddr *from,
1107163953Srrs    int fromlen,
1108163953Srrs    int *msg_flags,
1109163953Srrs    struct sctp_sndrcvinfo *sinfo,
1110163953Srrs    int filling_sinfo);
1111163953Srrs
1112163953Srrs#endif
1113163953Srrs
1114163953Srrs/*
1115163953Srrs * API system calls
1116163953Srrs */
1117180387Srrs#if !(defined(_KERNEL)) && !(defined(__Userspace__))
1118163953Srrs
1119163953Srrs__BEGIN_DECLS
1120163953Srrsint sctp_peeloff __P((int, sctp_assoc_t));
1121163953Srrsint sctp_bindx __P((int, struct sockaddr *, int, int));
1122167598Srrsint sctp_connectx __P((int, const struct sockaddr *, int, sctp_assoc_t *));
1123163953Srrsint sctp_getaddrlen __P((sa_family_t));
1124163953Srrsint sctp_getpaddrs __P((int, sctp_assoc_t, struct sockaddr **));
1125163953Srrsvoid sctp_freepaddrs __P((struct sockaddr *));
1126163953Srrsint sctp_getladdrs __P((int, sctp_assoc_t, struct sockaddr **));
1127163953Srrsvoid sctp_freeladdrs __P((struct sockaddr *));
1128163953Srrsint sctp_opt_info __P((int, sctp_assoc_t, int, void *, socklen_t *));
1129163953Srrs
1130169352Srrsssize_t sctp_sendmsg
1131163953Srrs__P((int, const void *, size_t,
1132163953Srrs    const struct sockaddr *,
1133163953Srrs    socklen_t, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t));
1134163953Srrs
1135163953Srrs	ssize_t sctp_send __P((int sd, const void *msg, size_t len,
1136163953Srrs              const struct sctp_sndrcvinfo *sinfo, int flags));
1137163953Srrs
1138169352Srrs	ssize_t sctp_sendx __P((int sd, const void *msg, size_t len,
1139163953Srrs               struct sockaddr *addrs, int addrcnt,
1140163953Srrs               struct sctp_sndrcvinfo *sinfo, int flags));
1141169352Srrs
1142169352Srrs	ssize_t sctp_sendmsgx __P((int sd, const void *, size_t,
1143163953Srrs                  struct sockaddr *, int,
1144163953Srrs                  uint32_t, uint32_t, uint16_t, uint32_t, uint32_t));
1145163953Srrs
1146169352Srrs	sctp_assoc_t sctp_getassocid __P((int sd, struct sockaddr *sa));
1147163953Srrs
1148163953Srrs	ssize_t sctp_recvmsg __P((int, void *, size_t, struct sockaddr *,
1149163953Srrs                 socklen_t *, struct sctp_sndrcvinfo *, int *));
1150163953Srrs
1151163953Srrs__END_DECLS
1152163953Srrs
1153163953Srrs#endif				/* !_KERNEL */
1154163953Srrs#endif				/* !__sctp_uio_h__ */
1155