sctp_uio.h revision 216878
1163953Srrs/*-
2169382Srrs * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
3163953Srrs *
4163953Srrs * Redistribution and use in source and binary forms, with or without
5163953Srrs * modification, are permitted provided that the following conditions are met:
6163953Srrs *
7163953Srrs * a) Redistributions of source code must retain the above copyright notice,
8163953Srrs *   this list of conditions and the following disclaimer.
9163953Srrs *
10163953Srrs * b) Redistributions in binary form must reproduce the above copyright
11163953Srrs *    notice, this list of conditions and the following disclaimer in
12163953Srrs *   the documentation and/or other materials provided with the distribution.
13163953Srrs *
14163953Srrs * c) Neither the name of Cisco Systems, Inc. nor the names of its
15163953Srrs *    contributors may be used to endorse or promote products derived
16163953Srrs *    from this software without specific prior written permission.
17163953Srrs *
18163953Srrs * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19163953Srrs * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20163953Srrs * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21163953Srrs * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22163953Srrs * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23163953Srrs * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24163953Srrs * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25163953Srrs * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26163953Srrs * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27163953Srrs * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28163953Srrs * THE POSSIBILITY OF SUCH DAMAGE.
29163953Srrs */
30163953Srrs
31163953Srrs/* $KAME: sctp_uio.h,v 1.11 2005/03/06 16:04:18 itojun Exp $	 */
32163953Srrs#include <sys/cdefs.h>
33163953Srrs__FBSDID("$FreeBSD: head/sys/netinet/sctp_uio.h 216878 2011-01-01 22:22:57Z tuexen $");
34163953Srrs
35163953Srrs#ifndef __sctp_uio_h__
36163953Srrs#define __sctp_uio_h__
37163953Srrs
38163953Srrs
39163953Srrs#if ! defined(_KERNEL)
40163953Srrs#include <stdint.h>
41163953Srrs#endif
42163953Srrs#include <sys/types.h>
43163953Srrs#include <sys/socket.h>
44164085Srrs#include <netinet/in.h>
45163953Srrs
46163953Srrstypedef uint32_t sctp_assoc_t;
47163953Srrs
48202520Srrs/* Compatibility to previous define's */
49202520Srrs#define sctp_stream_reset_events sctp_stream_reset_event
50202520Srrs
51163953Srrs/* On/Off setup for subscription to events */
52163953Srrsstruct sctp_event_subscribe {
53163953Srrs	uint8_t sctp_data_io_event;
54163953Srrs	uint8_t sctp_association_event;
55163953Srrs	uint8_t sctp_address_event;
56163953Srrs	uint8_t sctp_send_failure_event;
57163953Srrs	uint8_t sctp_peer_error_event;
58163953Srrs	uint8_t sctp_shutdown_event;
59163953Srrs	uint8_t sctp_partial_delivery_event;
60163953Srrs	uint8_t sctp_adaptation_layer_event;
61163953Srrs	uint8_t sctp_authentication_event;
62185694Srrs	uint8_t sctp_sender_dry_event;
63202520Srrs	uint8_t sctp_stream_reset_event;
64163953Srrs};
65163953Srrs
66163953Srrs/* ancillary data types */
67163953Srrs#define SCTP_INIT	0x0001
68163953Srrs#define SCTP_SNDRCV	0x0002
69163953Srrs#define SCTP_EXTRCV	0x0003
70163953Srrs/*
71163953Srrs * ancillary data structures
72163953Srrs */
73163953Srrsstruct sctp_initmsg {
74193088Srrs	uint16_t sinit_num_ostreams;
75193088Srrs	uint16_t sinit_max_instreams;
76163953Srrs	uint16_t sinit_max_attempts;
77163953Srrs	uint16_t sinit_max_init_timeo;
78163953Srrs};
79163953Srrs
80163953Srrs/* We add 96 bytes to the size of sctp_sndrcvinfo.
81163953Srrs * This makes the current structure 128 bytes long
82163953Srrs * which is nicely 64 bit aligned but also has room
83215034Sbrucec * for us to add more and keep ABI compatibility.
84163953Srrs * For example, already we have the sctp_extrcvinfo
85163953Srrs * when enabled which is 48 bytes.
86163953Srrs */
87163953Srrs
88166675Srrs/*
89166675Srrs * The assoc up needs a verfid
90166675Srrs * all sendrcvinfo's need a verfid for SENDING only.
91166675Srrs */
92166675Srrs
93166675Srrs
94163953Srrs#define SCTP_ALIGN_RESV_PAD 96
95166675Srrs#define SCTP_ALIGN_RESV_PAD_SHORT 80
96163953Srrs
97163953Srrsstruct sctp_sndrcvinfo {
98163953Srrs	uint16_t sinfo_stream;
99163953Srrs	uint16_t sinfo_ssn;
100163953Srrs	uint16_t sinfo_flags;
101163953Srrs	uint32_t sinfo_ppid;
102163953Srrs	uint32_t sinfo_context;
103163953Srrs	uint32_t sinfo_timetolive;
104163953Srrs	uint32_t sinfo_tsn;
105163953Srrs	uint32_t sinfo_cumtsn;
106163953Srrs	sctp_assoc_t sinfo_assoc_id;
107163953Srrs	uint8_t __reserve_pad[SCTP_ALIGN_RESV_PAD];
108163953Srrs};
109163953Srrs
110163953Srrsstruct sctp_extrcvinfo {
111171745Srrs	uint16_t sinfo_stream;
112171745Srrs	uint16_t sinfo_ssn;
113171745Srrs	uint16_t sinfo_flags;
114171990Srrs	uint16_t sinfo_pr_policy;
115171745Srrs	uint32_t sinfo_ppid;
116171745Srrs	uint32_t sinfo_context;
117171745Srrs	uint32_t sinfo_timetolive;
118171745Srrs	uint32_t sinfo_tsn;
119171745Srrs	uint32_t sinfo_cumtsn;
120171745Srrs	sctp_assoc_t sinfo_assoc_id;
121168943Srrs	uint16_t sreinfo_next_flags;
122168943Srrs	uint16_t sreinfo_next_stream;
123168943Srrs	uint32_t sreinfo_next_aid;
124168943Srrs	uint32_t sreinfo_next_length;
125168943Srrs	uint32_t sreinfo_next_ppid;
126166675Srrs	uint8_t __reserve_pad[SCTP_ALIGN_RESV_PAD_SHORT];
127163953Srrs};
128163953Srrs
129163953Srrs#define SCTP_NO_NEXT_MSG           0x0000
130163953Srrs#define SCTP_NEXT_MSG_AVAIL        0x0001
131163953Srrs#define SCTP_NEXT_MSG_ISCOMPLETE   0x0002
132163953Srrs#define SCTP_NEXT_MSG_IS_UNORDERED 0x0004
133166675Srrs#define SCTP_NEXT_MSG_IS_NOTIFICATION 0x0008
134163953Srrs
135163953Srrsstruct sctp_snd_all_completes {
136163953Srrs	uint16_t sall_stream;
137163953Srrs	uint16_t sall_flags;
138163953Srrs	uint32_t sall_ppid;
139163953Srrs	uint32_t sall_context;
140163953Srrs	uint32_t sall_num_sent;
141163953Srrs	uint32_t sall_num_failed;
142163953Srrs};
143163953Srrs
144163953Srrs/* Flags that go into the sinfo->sinfo_flags field */
145185694Srrs#define SCTP_EOF              0x0100	/* Start shutdown procedures */
146185694Srrs#define SCTP_ABORT            0x0200	/* Send an ABORT to peer */
147185694Srrs#define SCTP_UNORDERED        0x0400	/* Message is un-ordered */
148185694Srrs#define SCTP_ADDR_OVER        0x0800	/* Override the primary-address */
149185694Srrs#define SCTP_SENDALL          0x1000	/* Send this on all associations */
150185694Srrs#define SCTP_EOR              0x2000	/* end of message signal */
151185694Srrs#define SCTP_SACK_IMMEDIATELY 0x4000	/* Set I-Bit */
152171990Srrs
153166023Srrs#define INVALID_SINFO_FLAG(x) (((x) & 0xffffff00 \
154166023Srrs                                    & ~(SCTP_EOF | SCTP_ABORT | SCTP_UNORDERED |\
155185694Srrs				        SCTP_ADDR_OVER | SCTP_SENDALL | SCTP_EOR |\
156185694Srrs					SCTP_SACK_IMMEDIATELY)) != 0)
157163953Srrs/* for the endpoint */
158163953Srrs
159163953Srrs/* The lower byte is an enumeration of PR-SCTP policies */
160163953Srrs#define SCTP_PR_SCTP_TTL  0x0001/* Time based PR-SCTP */
161163953Srrs#define SCTP_PR_SCTP_BUF  0x0002/* Buffer based PR-SCTP */
162163953Srrs#define SCTP_PR_SCTP_RTX  0x0003/* Number of retransmissions based PR-SCTP */
163163953Srrs
164166023Srrs#define PR_SCTP_POLICY(x)         ((x) & 0xff)
165166023Srrs#define PR_SCTP_ENABLED(x)        (PR_SCTP_POLICY(x) != 0)
166166023Srrs#define PR_SCTP_TTL_ENABLED(x)    (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_TTL)
167166023Srrs#define PR_SCTP_BUF_ENABLED(x)    (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_BUF)
168166023Srrs#define PR_SCTP_RTX_ENABLED(x)    (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_RTX)
169166023Srrs#define PR_SCTP_INVALID_POLICY(x) (PR_SCTP_POLICY(x) > SCTP_PR_SCTP_RTX)
170163953Srrs/* Stat's */
171163953Srrsstruct sctp_pcbinfo {
172163953Srrs	uint32_t ep_count;
173163953Srrs	uint32_t asoc_count;
174163953Srrs	uint32_t laddr_count;
175163953Srrs	uint32_t raddr_count;
176163953Srrs	uint32_t chk_count;
177163953Srrs	uint32_t readq_count;
178163953Srrs	uint32_t free_chunks;
179163953Srrs	uint32_t stream_oque;
180163953Srrs};
181163953Srrs
182163953Srrsstruct sctp_sockstat {
183163953Srrs	sctp_assoc_t ss_assoc_id;
184163953Srrs	uint32_t ss_total_sndbuf;
185163953Srrs	uint32_t ss_total_recv_buf;
186163953Srrs};
187163953Srrs
188163953Srrs/*
189163953Srrs * notification event structures
190163953Srrs */
191163953Srrs
192163953Srrs/*
193163953Srrs * association change event
194163953Srrs */
195163953Srrsstruct sctp_assoc_change {
196163953Srrs	uint16_t sac_type;
197163953Srrs	uint16_t sac_flags;
198163953Srrs	uint32_t sac_length;
199163953Srrs	uint16_t sac_state;
200163953Srrs	uint16_t sac_error;
201163953Srrs	uint16_t sac_outbound_streams;
202163953Srrs	uint16_t sac_inbound_streams;
203163953Srrs	sctp_assoc_t sac_assoc_id;
204163953Srrs};
205163953Srrs
206163953Srrs/* sac_state values */
207163953Srrs#define SCTP_COMM_UP		0x0001
208163953Srrs#define SCTP_COMM_LOST		0x0002
209163953Srrs#define SCTP_RESTART		0x0003
210163953Srrs#define SCTP_SHUTDOWN_COMP	0x0004
211163953Srrs#define SCTP_CANT_STR_ASSOC	0x0005
212163953Srrs
213163953Srrs
214163953Srrs/*
215163953Srrs * Address event
216163953Srrs */
217163953Srrsstruct sctp_paddr_change {
218163953Srrs	uint16_t spc_type;
219163953Srrs	uint16_t spc_flags;
220163953Srrs	uint32_t spc_length;
221163953Srrs	struct sockaddr_storage spc_aaddr;
222163953Srrs	uint32_t spc_state;
223163953Srrs	uint32_t spc_error;
224163953Srrs	sctp_assoc_t spc_assoc_id;
225170992Srrs	uint8_t spc_padding[4];
226163953Srrs};
227163953Srrs
228163953Srrs/* paddr state values */
229163953Srrs#define SCTP_ADDR_AVAILABLE	0x0001
230163953Srrs#define SCTP_ADDR_UNREACHABLE	0x0002
231163953Srrs#define SCTP_ADDR_REMOVED	0x0003
232163953Srrs#define SCTP_ADDR_ADDED		0x0004
233163953Srrs#define SCTP_ADDR_MADE_PRIM	0x0005
234163953Srrs#define SCTP_ADDR_CONFIRMED	0x0006
235163953Srrs
236163953Srrs/*
237163953Srrs * CAUTION: these are user exposed SCTP addr reachability states must be
238163953Srrs * compatible with SCTP_ADDR states in sctp_constants.h
239163953Srrs */
240163953Srrs#ifdef SCTP_ACTIVE
241163953Srrs#undef SCTP_ACTIVE
242163953Srrs#endif
243163953Srrs#define SCTP_ACTIVE		0x0001	/* SCTP_ADDR_REACHABLE */
244163953Srrs
245163953Srrs#ifdef SCTP_INACTIVE
246163953Srrs#undef SCTP_INACTIVE
247163953Srrs#endif
248163953Srrs#define SCTP_INACTIVE		0x0002	/* SCTP_ADDR_NOT_REACHABLE */
249163953Srrs
250163953Srrs#ifdef SCTP_UNCONFIRMED
251163953Srrs#undef SCTP_UNCONFIRMED
252163953Srrs#endif
253163953Srrs#define SCTP_UNCONFIRMED	0x0200	/* SCTP_ADDR_UNCONFIRMED */
254163953Srrs
255163953Srrs#ifdef SCTP_NOHEARTBEAT
256163953Srrs#undef SCTP_NOHEARTBEAT
257163953Srrs#endif
258163953Srrs#define SCTP_NOHEARTBEAT	0x0040	/* SCTP_ADDR_NOHB */
259163953Srrs
260163953Srrs
261163953Srrs/* remote error events */
262163953Srrsstruct sctp_remote_error {
263163953Srrs	uint16_t sre_type;
264163953Srrs	uint16_t sre_flags;
265163953Srrs	uint32_t sre_length;
266163953Srrs	uint16_t sre_error;
267163953Srrs	sctp_assoc_t sre_assoc_id;
268163953Srrs	uint8_t sre_data[4];
269163953Srrs};
270163953Srrs
271163953Srrs/* data send failure event */
272163953Srrsstruct sctp_send_failed {
273163953Srrs	uint16_t ssf_type;
274163953Srrs	uint16_t ssf_flags;
275163953Srrs	uint32_t ssf_length;
276163953Srrs	uint32_t ssf_error;
277163953Srrs	struct sctp_sndrcvinfo ssf_info;
278163953Srrs	sctp_assoc_t ssf_assoc_id;
279202782Stuexen	uint8_t ssf_data[];
280163953Srrs};
281163953Srrs
282163953Srrs/* flag that indicates state of data */
283163953Srrs#define SCTP_DATA_UNSENT	0x0001	/* inqueue never on wire */
284163953Srrs#define SCTP_DATA_SENT		0x0002	/* on wire at failure */
285163953Srrs
286163953Srrs/* shutdown event */
287163953Srrsstruct sctp_shutdown_event {
288163953Srrs	uint16_t sse_type;
289163953Srrs	uint16_t sse_flags;
290163953Srrs	uint32_t sse_length;
291163953Srrs	sctp_assoc_t sse_assoc_id;
292163953Srrs};
293163953Srrs
294163953Srrs/* Adaptation layer indication stuff */
295163953Srrsstruct sctp_adaptation_event {
296163953Srrs	uint16_t sai_type;
297163953Srrs	uint16_t sai_flags;
298163953Srrs	uint32_t sai_length;
299163953Srrs	uint32_t sai_adaptation_ind;
300163953Srrs	sctp_assoc_t sai_assoc_id;
301163953Srrs};
302163953Srrs
303163953Srrsstruct sctp_setadaptation {
304163953Srrs	uint32_t ssb_adaptation_ind;
305163953Srrs};
306163953Srrs
307215034Sbrucec/* compatible old spelling */
308163953Srrsstruct sctp_adaption_event {
309163953Srrs	uint16_t sai_type;
310163953Srrs	uint16_t sai_flags;
311163953Srrs	uint32_t sai_length;
312163953Srrs	uint32_t sai_adaption_ind;
313163953Srrs	sctp_assoc_t sai_assoc_id;
314163953Srrs};
315163953Srrs
316163953Srrsstruct sctp_setadaption {
317163953Srrs	uint32_t ssb_adaption_ind;
318163953Srrs};
319163953Srrs
320163953Srrs
321163953Srrs/*
322163953Srrs * Partial Delivery API event
323163953Srrs */
324163953Srrsstruct sctp_pdapi_event {
325163953Srrs	uint16_t pdapi_type;
326163953Srrs	uint16_t pdapi_flags;
327163953Srrs	uint32_t pdapi_length;
328163953Srrs	uint32_t pdapi_indication;
329168943Srrs	uint16_t pdapi_stream;
330168943Srrs	uint16_t pdapi_seq;
331163953Srrs	sctp_assoc_t pdapi_assoc_id;
332163953Srrs};
333163953Srrs
334163953Srrs/* indication values */
335163953Srrs#define SCTP_PARTIAL_DELIVERY_ABORTED	0x0001
336163953Srrs
337163953Srrs
338163953Srrs/*
339163953Srrs * authentication key event
340163953Srrs */
341163953Srrsstruct sctp_authkey_event {
342163953Srrs	uint16_t auth_type;
343163953Srrs	uint16_t auth_flags;
344163953Srrs	uint32_t auth_length;
345163953Srrs	uint16_t auth_keynumber;
346163953Srrs	uint16_t auth_altkeynumber;
347163953Srrs	uint32_t auth_indication;
348163953Srrs	sctp_assoc_t auth_assoc_id;
349163953Srrs};
350163953Srrs
351163953Srrs/* indication values */
352163953Srrs#define SCTP_AUTH_NEWKEY	0x0001
353185694Srrs#define SCTP_AUTH_NO_AUTH	0x0002
354185694Srrs#define SCTP_AUTH_FREE_KEY	0x0003
355163953Srrs
356163953Srrs
357185694Srrsstruct sctp_sender_dry_event {
358185694Srrs	uint16_t sender_dry_type;
359185694Srrs	uint16_t sender_dry_flags;
360185694Srrs	uint32_t sender_dry_length;
361185694Srrs	sctp_assoc_t sender_dry_assoc_id;
362185694Srrs};
363185694Srrs
364185694Srrs
365163953Srrs/*
366163953Srrs * stream reset event
367163953Srrs */
368163953Srrsstruct sctp_stream_reset_event {
369163953Srrs	uint16_t strreset_type;
370163953Srrs	uint16_t strreset_flags;
371163953Srrs	uint32_t strreset_length;
372163953Srrs	sctp_assoc_t strreset_assoc_id;
373202782Stuexen	uint16_t strreset_list[];
374163953Srrs};
375163953Srrs
376163953Srrs/* flags in strreset_flags field */
377163953Srrs#define SCTP_STRRESET_INBOUND_STR  0x0001
378163953Srrs#define SCTP_STRRESET_OUTBOUND_STR 0x0002
379163953Srrs#define SCTP_STRRESET_ALL_STREAMS  0x0004
380163953Srrs#define SCTP_STRRESET_STREAM_LIST  0x0008
381163953Srrs#define SCTP_STRRESET_FAILED       0x0010
382188854Srrs#define SCTP_STRRESET_ADD_STREAM   0x0020
383163953Srrs
384163953Srrs/* SCTP notification event */
385163953Srrsstruct sctp_tlv {
386163953Srrs	uint16_t sn_type;
387163953Srrs	uint16_t sn_flags;
388163953Srrs	uint32_t sn_length;
389163953Srrs};
390163953Srrs
391163953Srrsunion sctp_notification {
392163953Srrs	struct sctp_tlv sn_header;
393163953Srrs	struct sctp_assoc_change sn_assoc_change;
394163953Srrs	struct sctp_paddr_change sn_paddr_change;
395163953Srrs	struct sctp_remote_error sn_remote_error;
396163953Srrs	struct sctp_send_failed sn_send_failed;
397163953Srrs	struct sctp_shutdown_event sn_shutdown_event;
398163953Srrs	struct sctp_adaptation_event sn_adaptation_event;
399215034Sbrucec	/* compatibility same as above */
400163953Srrs	struct sctp_adaption_event sn_adaption_event;
401163953Srrs	struct sctp_pdapi_event sn_pdapi_event;
402163953Srrs	struct sctp_authkey_event sn_auth_event;
403185694Srrs	struct sctp_sender_dry_event sn_sender_dry_event;
404163953Srrs	struct sctp_stream_reset_event sn_strreset_event;
405163953Srrs};
406163953Srrs
407163953Srrs/* notification types */
408202520Srrs#define SCTP_ASSOC_CHANGE			0x0001
409202520Srrs#define SCTP_PEER_ADDR_CHANGE			0x0002
410202520Srrs#define SCTP_REMOTE_ERROR			0x0003
411202520Srrs#define SCTP_SEND_FAILED			0x0004
412202520Srrs#define SCTP_SHUTDOWN_EVENT			0x0005
413202520Srrs#define SCTP_ADAPTATION_INDICATION		0x0006
414163953Srrs/* same as above */
415202520Srrs#define SCTP_ADAPTION_INDICATION		0x0006
416202520Srrs#define SCTP_PARTIAL_DELIVERY_EVENT		0x0007
417202520Srrs#define SCTP_AUTHENTICATION_EVENT		0x0008
418202520Srrs#define SCTP_STREAM_RESET_EVENT			0x0009
419202520Srrs#define SCTP_SENDER_DRY_EVENT			0x000a
420216878Stuexen#define SCTP_NOTIFICATIONS_STOPPED_EVENT	0x000b	/* we don't send this */
421163953Srrs/*
422163953Srrs * socket option structs
423163953Srrs */
424163953Srrs
425163953Srrsstruct sctp_paddrparams {
426170992Srrs	struct sockaddr_storage spp_address;
427163953Srrs	sctp_assoc_t spp_assoc_id;
428163953Srrs	uint32_t spp_hbinterval;
429163953Srrs	uint32_t spp_pathmtu;
430163953Srrs	uint32_t spp_flags;
431163953Srrs	uint32_t spp_ipv6_flowlabel;
432170992Srrs	uint16_t spp_pathmaxrxt;
433163953Srrs	uint8_t spp_ipv4_tos;
434163953Srrs};
435163953Srrs
436163953Srrs#define SPP_HB_ENABLE		0x00000001
437163953Srrs#define SPP_HB_DISABLE		0x00000002
438163953Srrs#define SPP_HB_DEMAND		0x00000004
439163953Srrs#define SPP_PMTUD_ENABLE	0x00000008
440163953Srrs#define SPP_PMTUD_DISABLE	0x00000010
441163953Srrs#define SPP_HB_TIME_IS_ZERO     0x00000080
442163953Srrs#define SPP_IPV6_FLOWLABEL      0x00000100
443163953Srrs#define SPP_IPV4_TOS            0x00000200
444163953Srrs
445163953Srrsstruct sctp_paddrinfo {
446170992Srrs	struct sockaddr_storage spinfo_address;
447163953Srrs	sctp_assoc_t spinfo_assoc_id;
448163953Srrs	int32_t spinfo_state;
449163953Srrs	uint32_t spinfo_cwnd;
450163953Srrs	uint32_t spinfo_srtt;
451163953Srrs	uint32_t spinfo_rto;
452163953Srrs	uint32_t spinfo_mtu;
453163953Srrs};
454163953Srrs
455163953Srrsstruct sctp_rtoinfo {
456163953Srrs	sctp_assoc_t srto_assoc_id;
457163953Srrs	uint32_t srto_initial;
458163953Srrs	uint32_t srto_max;
459163953Srrs	uint32_t srto_min;
460163953Srrs};
461163953Srrs
462163953Srrsstruct sctp_assocparams {
463163953Srrs	sctp_assoc_t sasoc_assoc_id;
464163953Srrs	uint32_t sasoc_peer_rwnd;
465163953Srrs	uint32_t sasoc_local_rwnd;
466163953Srrs	uint32_t sasoc_cookie_life;
467170992Srrs	uint16_t sasoc_asocmaxrxt;
468170992Srrs	uint16_t sasoc_number_peer_destinations;
469163953Srrs};
470163953Srrs
471163953Srrsstruct sctp_setprim {
472170992Srrs	struct sockaddr_storage ssp_addr;
473163953Srrs	sctp_assoc_t ssp_assoc_id;
474170992Srrs	uint8_t ssp_padding[4];
475163953Srrs};
476163953Srrs
477163953Srrsstruct sctp_setpeerprim {
478170992Srrs	struct sockaddr_storage sspp_addr;
479163953Srrs	sctp_assoc_t sspp_assoc_id;
480170992Srrs	uint8_t sspp_padding[4];
481163953Srrs};
482163953Srrs
483163953Srrsstruct sctp_getaddresses {
484163953Srrs	sctp_assoc_t sget_assoc_id;
485163953Srrs	/* addr is filled in for N * sockaddr_storage */
486163953Srrs	struct sockaddr addr[1];
487163953Srrs};
488163953Srrs
489163953Srrsstruct sctp_setstrm_timeout {
490163953Srrs	sctp_assoc_t ssto_assoc_id;
491163953Srrs	uint32_t ssto_timeout;
492163953Srrs	uint32_t ssto_streamid_start;
493163953Srrs	uint32_t ssto_streamid_end;
494163953Srrs};
495163953Srrs
496163953Srrsstruct sctp_status {
497163953Srrs	sctp_assoc_t sstat_assoc_id;
498163953Srrs	int32_t sstat_state;
499163953Srrs	uint32_t sstat_rwnd;
500163953Srrs	uint16_t sstat_unackdata;
501163953Srrs	uint16_t sstat_penddata;
502163953Srrs	uint16_t sstat_instrms;
503163953Srrs	uint16_t sstat_outstrms;
504163953Srrs	uint32_t sstat_fragmentation_point;
505163953Srrs	struct sctp_paddrinfo sstat_primary;
506163953Srrs};
507163953Srrs
508163953Srrs/*
509163953Srrs * AUTHENTICATION support
510163953Srrs */
511163953Srrs/* SCTP_AUTH_CHUNK */
512163953Srrsstruct sctp_authchunk {
513163953Srrs	uint8_t sauth_chunk;
514163953Srrs};
515163953Srrs
516163953Srrs/* SCTP_AUTH_KEY */
517163953Srrsstruct sctp_authkey {
518163953Srrs	sctp_assoc_t sca_assoc_id;
519163953Srrs	uint16_t sca_keynumber;
520202782Stuexen	uint8_t sca_key[];
521163953Srrs};
522163953Srrs
523163953Srrs/* SCTP_HMAC_IDENT */
524163953Srrsstruct sctp_hmacalgo {
525179141Srrs	uint32_t shmac_number_of_idents;
526202782Stuexen	uint16_t shmac_idents[];
527163953Srrs};
528163953Srrs
529163953Srrs/* AUTH hmac_id */
530163953Srrs#define SCTP_AUTH_HMAC_ID_RSVD		0x0000
531163953Srrs#define SCTP_AUTH_HMAC_ID_SHA1		0x0001	/* default, mandatory */
532163953Srrs#define SCTP_AUTH_HMAC_ID_SHA256	0x0003
533171745Srrs#define SCTP_AUTH_HMAC_ID_SHA224	0x0004
534171745Srrs#define SCTP_AUTH_HMAC_ID_SHA384	0x0005
535171745Srrs#define SCTP_AUTH_HMAC_ID_SHA512	0x0006
536163953Srrs
537163953Srrs
538163953Srrs/* SCTP_AUTH_ACTIVE_KEY / SCTP_AUTH_DELETE_KEY */
539163953Srrsstruct sctp_authkeyid {
540163953Srrs	sctp_assoc_t scact_assoc_id;
541163953Srrs	uint16_t scact_keynumber;
542163953Srrs};
543163953Srrs
544163953Srrs/* SCTP_PEER_AUTH_CHUNKS / SCTP_LOCAL_AUTH_CHUNKS */
545163953Srrsstruct sctp_authchunks {
546163953Srrs	sctp_assoc_t gauth_assoc_id;
547202782Stuexen	uint8_t gauth_chunks[];
548163953Srrs};
549163953Srrs
550163953Srrsstruct sctp_assoc_value {
551163953Srrs	sctp_assoc_t assoc_id;
552163953Srrs	uint32_t assoc_value;
553163953Srrs};
554163953Srrs
555163953Srrsstruct sctp_assoc_ids {
556185694Srrs	uint32_t gaids_number_of_ids;
557202782Stuexen	sctp_assoc_t gaids_assoc_id[];
558163953Srrs};
559163953Srrs
560170056Srrsstruct sctp_sack_info {
561170056Srrs	sctp_assoc_t sack_assoc_id;
562170056Srrs	uint32_t sack_delay;
563170056Srrs	uint32_t sack_freq;
564170056Srrs};
565170056Srrs
566215410Stuexenstruct sctp_timeouts {
567215410Stuexen	sctp_assoc_t stimo_assoc_id;
568215410Stuexen	uint32_t stimo_init;
569215410Stuexen	uint32_t stimo_data;
570215410Stuexen	uint32_t stimo_sack;
571215410Stuexen	uint32_t stimo_shutdown;
572215410Stuexen	uint32_t stimo_heartbeat;
573215410Stuexen	uint32_t stimo_cookie;
574215410Stuexen	uint32_t stimo_shutdownack;
575215410Stuexen};
576215410Stuexen
577163953Srrsstruct sctp_cwnd_args {
578170992Srrs	struct sctp_nets *net;	/* network to *//* FIXME: LP64 issue */
579163953Srrs	uint32_t cwnd_new_value;/* cwnd in k */
580163953Srrs	uint32_t pseudo_cumack;
581190689Srrs	uint16_t inflight;	/* flightsize in k */
582190689Srrs	uint16_t cwnd_augment;	/* increment to it */
583163953Srrs	uint8_t meets_pseudo_cumack;
584163953Srrs	uint8_t need_new_pseudo_cumack;
585163953Srrs	uint8_t cnt_in_send;
586163953Srrs	uint8_t cnt_in_str;
587163953Srrs};
588163953Srrs
589163953Srrsstruct sctp_blk_args {
590163953Srrs	uint32_t onsb;		/* in 1k bytes */
591163953Srrs	uint32_t sndlen;	/* len of send being attempted */
592163953Srrs	uint32_t peer_rwnd;	/* rwnd of peer */
593163953Srrs	uint16_t send_sent_qcnt;/* chnk cnt */
594163953Srrs	uint16_t stream_qcnt;	/* chnk cnt */
595163953Srrs	uint16_t chunks_on_oque;/* chunks out */
596163953Srrs	uint16_t flight_size;	/* flight size in k */
597163953Srrs};
598163953Srrs
599163953Srrs/*
600163953Srrs * Max we can reset in one setting, note this is dictated not by the define
601163953Srrs * but the size of a mbuf cluster so don't change this define and think you
602163953Srrs * can specify more. You must do multiple resets if you want to reset more
603163953Srrs * than SCTP_MAX_EXPLICIT_STR_RESET.
604163953Srrs */
605163953Srrs#define SCTP_MAX_EXPLICT_STR_RESET   1000
606163953Srrs
607163953Srrs#define SCTP_RESET_LOCAL_RECV  0x0001
608163953Srrs#define SCTP_RESET_LOCAL_SEND  0x0002
609163953Srrs#define SCTP_RESET_BOTH        0x0003
610163953Srrs#define SCTP_RESET_TSN         0x0004
611188854Srrs#define SCTP_RESET_ADD_STREAMS 0x0005
612163953Srrs
613163953Srrsstruct sctp_stream_reset {
614163953Srrs	sctp_assoc_t strrst_assoc_id;
615163953Srrs	uint16_t strrst_flags;
616163953Srrs	uint16_t strrst_num_streams;	/* 0 == ALL */
617202782Stuexen	uint16_t strrst_list[];	/* list if strrst_num_streams is not 0 */
618163953Srrs};
619163953Srrs
620163953Srrs
621163953Srrsstruct sctp_get_nonce_values {
622163953Srrs	sctp_assoc_t gn_assoc_id;
623163953Srrs	uint32_t gn_peers_tag;
624163953Srrs	uint32_t gn_local_tag;
625163953Srrs};
626163953Srrs
627163953Srrs/* Debugging logs */
628163953Srrsstruct sctp_str_log {
629170992Srrs	void *stcb;		/* FIXME: LP64 issue */
630163953Srrs	uint32_t n_tsn;
631163953Srrs	uint32_t e_tsn;
632163953Srrs	uint16_t n_sseq;
633163953Srrs	uint16_t e_sseq;
634164181Srrs	uint16_t strm;
635163953Srrs};
636163953Srrs
637163953Srrsstruct sctp_sb_log {
638170992Srrs	void *stcb;		/* FIXME: LP64 issue */
639163953Srrs	uint32_t so_sbcc;
640163953Srrs	uint32_t stcb_sbcc;
641163953Srrs	uint32_t incr;
642163953Srrs};
643163953Srrs
644163953Srrsstruct sctp_fr_log {
645163953Srrs	uint32_t largest_tsn;
646163953Srrs	uint32_t largest_new_tsn;
647163953Srrs	uint32_t tsn;
648163953Srrs};
649163953Srrs
650163953Srrsstruct sctp_fr_map {
651163953Srrs	uint32_t base;
652163953Srrs	uint32_t cum;
653163953Srrs	uint32_t high;
654163953Srrs};
655163953Srrs
656163953Srrsstruct sctp_rwnd_log {
657163953Srrs	uint32_t rwnd;
658163953Srrs	uint32_t send_size;
659163953Srrs	uint32_t overhead;
660163953Srrs	uint32_t new_rwnd;
661163953Srrs};
662163953Srrs
663163953Srrsstruct sctp_mbcnt_log {
664163953Srrs	uint32_t total_queue_size;
665163953Srrs	uint32_t size_change;
666163953Srrs	uint32_t total_queue_mb_size;
667163953Srrs	uint32_t mbcnt_change;
668163953Srrs};
669163953Srrs
670163953Srrsstruct sctp_sack_log {
671163953Srrs	uint32_t cumack;
672163953Srrs	uint32_t oldcumack;
673163953Srrs	uint32_t tsn;
674163953Srrs	uint16_t numGaps;
675163953Srrs	uint16_t numDups;
676163953Srrs};
677163953Srrs
678163953Srrsstruct sctp_lock_log {
679170992Srrs	void *sock;		/* FIXME: LP64 issue */
680170992Srrs	void *inp;		/* FIXME: LP64 issue */
681163953Srrs	uint8_t tcb_lock;
682163953Srrs	uint8_t inp_lock;
683163953Srrs	uint8_t info_lock;
684163953Srrs	uint8_t sock_lock;
685163953Srrs	uint8_t sockrcvbuf_lock;
686163953Srrs	uint8_t socksndbuf_lock;
687163953Srrs	uint8_t create_lock;
688163953Srrs	uint8_t resv;
689163953Srrs};
690163953Srrs
691163953Srrsstruct sctp_rto_log {
692170992Srrs	void *net;		/* FIXME: LP64 issue */
693163953Srrs	uint32_t rtt;
694163953Srrs};
695163953Srrs
696163953Srrsstruct sctp_nagle_log {
697170992Srrs	void *stcb;		/* FIXME: LP64 issue */
698163953Srrs	uint32_t total_flight;
699163953Srrs	uint32_t total_in_queue;
700163953Srrs	uint16_t count_in_queue;
701163953Srrs	uint16_t count_in_flight;
702163953Srrs};
703163953Srrs
704163953Srrsstruct sctp_sbwake_log {
705170992Srrs	void *stcb;		/* FIXME: LP64 issue */
706163953Srrs	uint16_t send_q;
707163953Srrs	uint16_t sent_q;
708163953Srrs	uint16_t flight;
709163953Srrs	uint16_t wake_cnt;
710163953Srrs	uint8_t stream_qcnt;	/* chnk cnt */
711163953Srrs	uint8_t chunks_on_oque;	/* chunks out */
712163953Srrs	uint8_t sbflags;
713163953Srrs	uint8_t sctpflags;
714163953Srrs};
715163953Srrs
716163953Srrsstruct sctp_misc_info {
717163953Srrs	uint32_t log1;
718163953Srrs	uint32_t log2;
719163953Srrs	uint32_t log3;
720163953Srrs	uint32_t log4;
721163953Srrs};
722163953Srrs
723163953Srrsstruct sctp_log_closing {
724170992Srrs	void *inp;		/* FIXME: LP64 issue */
725170992Srrs	void *stcb;		/* FIXME: LP64 issue */
726163953Srrs	uint32_t sctp_flags;
727163953Srrs	uint16_t state;
728163953Srrs	int16_t loc;
729163953Srrs};
730163953Srrs
731163953Srrsstruct sctp_mbuf_log {
732170992Srrs	struct mbuf *mp;	/* FIXME: LP64 issue */
733163953Srrs	caddr_t ext;
734163953Srrs	caddr_t data;
735163953Srrs	uint16_t size;
736163953Srrs	uint8_t refcnt;
737163953Srrs	uint8_t mbuf_flags;
738163953Srrs};
739163953Srrs
740163953Srrsstruct sctp_cwnd_log {
741170744Srrs	uint64_t time_event;
742163953Srrs	uint8_t from;
743163953Srrs	uint8_t event_type;
744163953Srrs	uint8_t resv[2];
745163953Srrs	union {
746163953Srrs		struct sctp_log_closing close;
747163953Srrs		struct sctp_blk_args blk;
748163953Srrs		struct sctp_cwnd_args cwnd;
749163953Srrs		struct sctp_str_log strlog;
750163953Srrs		struct sctp_fr_log fr;
751163953Srrs		struct sctp_fr_map map;
752163953Srrs		struct sctp_rwnd_log rwnd;
753163953Srrs		struct sctp_mbcnt_log mbcnt;
754163953Srrs		struct sctp_sack_log sack;
755163953Srrs		struct sctp_lock_log lock;
756163953Srrs		struct sctp_rto_log rto;
757163953Srrs		struct sctp_sb_log sb;
758163953Srrs		struct sctp_nagle_log nagle;
759163953Srrs		struct sctp_sbwake_log wake;
760163953Srrs		struct sctp_mbuf_log mb;
761163953Srrs		struct sctp_misc_info misc;
762163953Srrs	}     x;
763163953Srrs};
764163953Srrs
765163953Srrsstruct sctp_cwnd_log_req {
766170992Srrs	int32_t num_in_log;	/* Number in log */
767170992Srrs	int32_t num_ret;	/* Number returned */
768170992Srrs	int32_t start_at;	/* start at this one */
769170992Srrs	int32_t end_at;		/* end at this one */
770202782Stuexen	struct sctp_cwnd_log log[];
771163953Srrs};
772163953Srrs
773172091Srrsstruct sctp_timeval {
774172091Srrs	uint32_t tv_sec;
775172091Srrs	uint32_t tv_usec;
776172091Srrs};
777172091Srrs
778163953Srrsstruct sctpstat {
779191890Srrs	struct sctp_timeval sctps_discontinuitytime;	/* sctpStats 18
780191890Srrs							 * (TimeStamp) */
781163953Srrs	/* MIB according to RFC 3873 */
782170992Srrs	uint32_t sctps_currestab;	/* sctpStats  1   (Gauge32) */
783170992Srrs	uint32_t sctps_activeestab;	/* sctpStats  2 (Counter32) */
784170992Srrs	uint32_t sctps_restartestab;
785170992Srrs	uint32_t sctps_collisionestab;
786170992Srrs	uint32_t sctps_passiveestab;	/* sctpStats  3 (Counter32) */
787170992Srrs	uint32_t sctps_aborted;	/* sctpStats  4 (Counter32) */
788170992Srrs	uint32_t sctps_shutdown;/* sctpStats  5 (Counter32) */
789170992Srrs	uint32_t sctps_outoftheblue;	/* sctpStats  6 (Counter32) */
790170992Srrs	uint32_t sctps_checksumerrors;	/* sctpStats  7 (Counter32) */
791170992Srrs	uint32_t sctps_outcontrolchunks;	/* sctpStats  8 (Counter64) */
792170992Srrs	uint32_t sctps_outorderchunks;	/* sctpStats  9 (Counter64) */
793170992Srrs	uint32_t sctps_outunorderchunks;	/* sctpStats 10 (Counter64) */
794170992Srrs	uint32_t sctps_incontrolchunks;	/* sctpStats 11 (Counter64) */
795170992Srrs	uint32_t sctps_inorderchunks;	/* sctpStats 12 (Counter64) */
796170992Srrs	uint32_t sctps_inunorderchunks;	/* sctpStats 13 (Counter64) */
797170992Srrs	uint32_t sctps_fragusrmsgs;	/* sctpStats 14 (Counter64) */
798170992Srrs	uint32_t sctps_reasmusrmsgs;	/* sctpStats 15 (Counter64) */
799170992Srrs	uint32_t sctps_outpackets;	/* sctpStats 16 (Counter64) */
800170992Srrs	uint32_t sctps_inpackets;	/* sctpStats 17 (Counter64) */
801170992Srrs
802163953Srrs	/* input statistics: */
803170992Srrs	uint32_t sctps_recvpackets;	/* total input packets        */
804170992Srrs	uint32_t sctps_recvdatagrams;	/* total input datagrams      */
805170992Srrs	uint32_t sctps_recvpktwithdata;	/* total packets that had data */
806170992Srrs	uint32_t sctps_recvsacks;	/* total input SACK chunks    */
807170992Srrs	uint32_t sctps_recvdata;/* total input DATA chunks    */
808170992Srrs	uint32_t sctps_recvdupdata;	/* total input duplicate DATA chunks */
809170992Srrs	uint32_t sctps_recvheartbeat;	/* total input HB chunks      */
810170992Srrs	uint32_t sctps_recvheartbeatack;	/* total input HB-ACK chunks  */
811170992Srrs	uint32_t sctps_recvecne;/* total input ECNE chunks    */
812170992Srrs	uint32_t sctps_recvauth;/* total input AUTH chunks    */
813170992Srrs	uint32_t sctps_recvauthmissing;	/* total input chunks missing AUTH */
814170992Srrs	uint32_t sctps_recvivalhmacid;	/* total number of invalid HMAC ids
815163953Srrs					 * received */
816170992Srrs	uint32_t sctps_recvivalkeyid;	/* total number of invalid secret ids
817163953Srrs					 * received */
818170992Srrs	uint32_t sctps_recvauthfailed;	/* total number of auth failed */
819170992Srrs	uint32_t sctps_recvexpress;	/* total fast path receives all one
820163953Srrs					 * chunk */
821170992Srrs	uint32_t sctps_recvexpressm;	/* total fast path multi-part data */
822188067Srrs	uint32_t sctps_recvnocrc;
823188067Srrs	uint32_t sctps_recvswcrc;
824188067Srrs	uint32_t sctps_recvhwcrc;
825188067Srrs
826163953Srrs	/* output statistics: */
827170992Srrs	uint32_t sctps_sendpackets;	/* total output packets       */
828170992Srrs	uint32_t sctps_sendsacks;	/* total output SACKs         */
829170992Srrs	uint32_t sctps_senddata;/* total output DATA chunks   */
830170992Srrs	uint32_t sctps_sendretransdata;	/* total output retransmitted DATA
831163953Srrs					 * chunks */
832170992Srrs	uint32_t sctps_sendfastretrans;	/* total output fast retransmitted
833163953Srrs					 * DATA chunks */
834170992Srrs	uint32_t sctps_sendmultfastretrans;	/* total FR's that happened
835168755Srrs						 * more than once to same
836168755Srrs						 * chunk (u-del multi-fr
837168755Srrs						 * algo). */
838170992Srrs	uint32_t sctps_sendheartbeat;	/* total output HB chunks     */
839170992Srrs	uint32_t sctps_sendecne;/* total output ECNE chunks    */
840170992Srrs	uint32_t sctps_sendauth;/* total output AUTH chunks FIXME   */
841170992Srrs	uint32_t sctps_senderrors;	/* ip_output error counter */
842188067Srrs	uint32_t sctps_sendnocrc;
843188067Srrs	uint32_t sctps_sendswcrc;
844188067Srrs	uint32_t sctps_sendhwcrc;
845163953Srrs	/* PCKDROPREP statistics: */
846170992Srrs	uint32_t sctps_pdrpfmbox;	/* Packet drop from middle box */
847170992Srrs	uint32_t sctps_pdrpfehos;	/* P-drop from end host */
848170992Srrs	uint32_t sctps_pdrpmbda;/* P-drops with data */
849170992Srrs	uint32_t sctps_pdrpmbct;/* P-drops, non-data, non-endhost */
850170992Srrs	uint32_t sctps_pdrpbwrpt;	/* P-drop, non-endhost, bandwidth rep
851170992Srrs					 * only */
852170992Srrs	uint32_t sctps_pdrpcrupt;	/* P-drop, not enough for chunk header */
853170992Srrs	uint32_t sctps_pdrpnedat;	/* P-drop, not enough data to confirm */
854170992Srrs	uint32_t sctps_pdrppdbrk;	/* P-drop, where process_chunk_drop
855170992Srrs					 * said break */
856170992Srrs	uint32_t sctps_pdrptsnnf;	/* P-drop, could not find TSN */
857170992Srrs	uint32_t sctps_pdrpdnfnd;	/* P-drop, attempt reverse TSN lookup */
858170992Srrs	uint32_t sctps_pdrpdiwnp;	/* P-drop, e-host confirms zero-rwnd */
859170992Srrs	uint32_t sctps_pdrpdizrw;	/* P-drop, midbox confirms no space */
860170992Srrs	uint32_t sctps_pdrpbadd;/* P-drop, data did not match TSN */
861170992Srrs	uint32_t sctps_pdrpmark;/* P-drop, TSN's marked for Fast Retran */
862163953Srrs	/* timeouts */
863170992Srrs	uint32_t sctps_timoiterator;	/* Number of iterator timers that
864168755Srrs					 * fired */
865170992Srrs	uint32_t sctps_timodata;/* Number of T3 data time outs */
866170992Srrs	uint32_t sctps_timowindowprobe;	/* Number of window probe (T3) timers
867168755Srrs					 * that fired */
868170992Srrs	uint32_t sctps_timoinit;/* Number of INIT timers that fired */
869170992Srrs	uint32_t sctps_timosack;/* Number of sack timers that fired */
870170992Srrs	uint32_t sctps_timoshutdown;	/* Number of shutdown timers that
871168755Srrs					 * fired */
872170992Srrs	uint32_t sctps_timoheartbeat;	/* Number of heartbeat timers that
873168755Srrs					 * fired */
874170992Srrs	uint32_t sctps_timocookie;	/* Number of times a cookie timeout
875168755Srrs					 * fired */
876170992Srrs	uint32_t sctps_timosecret;	/* Number of times an endpoint changed
877170992Srrs					 * its cookie secret */
878170992Srrs	uint32_t sctps_timopathmtu;	/* Number of PMTU timers that fired */
879170992Srrs	uint32_t sctps_timoshutdownack;	/* Number of shutdown ack timers that
880168755Srrs					 * fired */
881170992Srrs	uint32_t sctps_timoshutdownguard;	/* Number of shutdown guard
882170992Srrs						 * timers that fired */
883170992Srrs	uint32_t sctps_timostrmrst;	/* Number of stream reset timers that
884168755Srrs					 * fired */
885170992Srrs	uint32_t sctps_timoearlyfr;	/* Number of early FR timers that
886168755Srrs					 * fired */
887170992Srrs	uint32_t sctps_timoasconf;	/* Number of times an asconf timer
888170992Srrs					 * fired */
889172091Srrs	uint32_t sctps_timodelprim;	/* Number of times a prim_deleted
890172091Srrs					 * timer fired */
891170992Srrs	uint32_t sctps_timoautoclose;	/* Number of times auto close timer
892170992Srrs					 * fired */
893170992Srrs	uint32_t sctps_timoassockill;	/* Number of asoc free timers expired */
894170992Srrs	uint32_t sctps_timoinpkill;	/* Number of inp free timers expired */
895163953Srrs	/* Early fast retransmission counters */
896170992Srrs	uint32_t sctps_earlyfrstart;
897170992Srrs	uint32_t sctps_earlyfrstop;
898170992Srrs	uint32_t sctps_earlyfrmrkretrans;
899170992Srrs	uint32_t sctps_earlyfrstpout;
900170992Srrs	uint32_t sctps_earlyfrstpidsck1;
901170992Srrs	uint32_t sctps_earlyfrstpidsck2;
902170992Srrs	uint32_t sctps_earlyfrstpidsck3;
903170992Srrs	uint32_t sctps_earlyfrstpidsck4;
904170992Srrs	uint32_t sctps_earlyfrstrid;
905170992Srrs	uint32_t sctps_earlyfrstrout;
906170992Srrs	uint32_t sctps_earlyfrstrtmr;
907215034Sbrucec	/* others */
908170992Srrs	uint32_t sctps_hdrops;	/* packet shorter than header */
909170992Srrs	uint32_t sctps_badsum;	/* checksum error             */
910170992Srrs	uint32_t sctps_noport;	/* no endpoint for port       */
911170992Srrs	uint32_t sctps_badvtag;	/* bad v-tag                  */
912170992Srrs	uint32_t sctps_badsid;	/* bad SID                    */
913170992Srrs	uint32_t sctps_nomem;	/* no memory                  */
914170992Srrs	uint32_t sctps_fastretransinrtt;	/* number of multiple FR in a
915170992Srrs						 * RTT window */
916170992Srrs	uint32_t sctps_markedretrans;
917170992Srrs	uint32_t sctps_naglesent;	/* nagle allowed sending      */
918215034Sbrucec	uint32_t sctps_naglequeued;	/* nagle doesn't allow sending */
919215034Sbrucec	uint32_t sctps_maxburstqueued;	/* max burst doesn't allow sending */
920170992Srrs	uint32_t sctps_ifnomemqueued;	/* look ahead tells us no memory in
921168755Srrs					 * interface ring buffer OR we had a
922168755Srrs					 * send error and are queuing one
923168755Srrs					 * send. */
924170992Srrs	uint32_t sctps_windowprobed;	/* total number of window probes sent */
925170992Srrs	uint32_t sctps_lowlevelerr;	/* total times an output error causes
926168755Srrs					 * us to clamp down on next user send. */
927170992Srrs	uint32_t sctps_lowlevelerrusr;	/* total times sctp_senderrors were
928168755Srrs					 * caused from a user send from a user
929168755Srrs					 * invoked send not a sack response */
930170992Srrs	uint32_t sctps_datadropchklmt;	/* Number of in data drops due to
931168755Srrs					 * chunk limit reached */
932170992Srrs	uint32_t sctps_datadroprwnd;	/* Number of in data drops due to rwnd
933168755Srrs					 * limit reached */
934170992Srrs	uint32_t sctps_ecnereducedcwnd;	/* Number of times a ECN reduced the
935168755Srrs					 * cwnd */
936170992Srrs	uint32_t sctps_vtagexpress;	/* Used express lookup via vtag */
937170992Srrs	uint32_t sctps_vtagbogus;	/* Collision in express lookup. */
938170992Srrs	uint32_t sctps_primary_randry;	/* Number of times the sender ran dry
939163953Srrs					 * of user data on primary */
940170992Srrs	uint32_t sctps_cmt_randry;	/* Same for above */
941170992Srrs	uint32_t sctps_slowpath_sack;	/* Sacks the slow way */
942170992Srrs	uint32_t sctps_wu_sacks_sent;	/* Window Update only sacks sent */
943170992Srrs	uint32_t sctps_sends_with_flags;	/* number of sends with
944170992Srrs						 * sinfo_flags !=0 */
945215817Srrs	uint32_t sctps_sends_with_unord;	/* number of unordered sends */
946170992Srrs	uint32_t sctps_sends_with_eof;	/* number of sends with EOF flag set */
947170992Srrs	uint32_t sctps_sends_with_abort;	/* number of sends with ABORT
948170992Srrs						 * flag set */
949170992Srrs	uint32_t sctps_protocol_drain_calls;	/* number of times protocol
950168755Srrs						 * drain called */
951170992Srrs	uint32_t sctps_protocol_drains_done;	/* number of times we did a
952168755Srrs						 * protocol drain */
953170992Srrs	uint32_t sctps_read_peeks;	/* Number of times recv was called
954170992Srrs					 * with peek */
955170992Srrs	uint32_t sctps_cached_chk;	/* Number of cached chunks used */
956170992Srrs	uint32_t sctps_cached_strmoq;	/* Number of cached stream oq's used */
957215034Sbrucec	uint32_t sctps_left_abandon;	/* Number of unread messages abandoned
958168859Srrs					 * by close */
959188854Srrs	uint32_t sctps_send_burst_avoid;	/* Unused */
960170992Srrs	uint32_t sctps_send_cwnd_avoid;	/* Send cwnd full  avoidance, already
961169352Srrs					 * max burst inflight to net */
962170992Srrs	uint32_t sctps_fwdtsn_map_over;	/* number of map array over-runs via
963170091Srrs					 * fwd-tsn's */
964170992Srrs
965191890Srrs	uint32_t sctps_reserved[32];	/* Future ABI compat - remove int's
966191890Srrs					 * from here when adding new */
967163953Srrs};
968163953Srrs
969163953Srrs#define SCTP_STAT_INCR(_x) SCTP_STAT_INCR_BY(_x,1)
970163953Srrs#define SCTP_STAT_DECR(_x) SCTP_STAT_DECR_BY(_x,1)
971205629Srrs#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
972205629Srrs#define SCTP_STAT_INCR_BY(_x,_d) (SCTP_BASE_STATS[PCPU_GET(cpuid)]._x += _d)
973205629Srrs#define SCTP_STAT_DECR_BY(_x,_d) (SCTP_BASE_STATS[PCPU_GET(cpuid)]._x -= _d)
974205629Srrs#else
975179783Srrs#define SCTP_STAT_INCR_BY(_x,_d) atomic_add_int(&SCTP_BASE_STAT(_x), _d)
976179783Srrs#define SCTP_STAT_DECR_BY(_x,_d) atomic_subtract_int(&SCTP_BASE_STAT(_x), _d)
977205629Srrs#endif
978163953Srrs/* The following macros are for handling MIB values, */
979163953Srrs#define SCTP_STAT_INCR_COUNTER32(_x) SCTP_STAT_INCR(_x)
980163953Srrs#define SCTP_STAT_INCR_COUNTER64(_x) SCTP_STAT_INCR(_x)
981163953Srrs#define SCTP_STAT_INCR_GAUGE32(_x) SCTP_STAT_INCR(_x)
982163953Srrs#define SCTP_STAT_DECR_COUNTER32(_x) SCTP_STAT_DECR(_x)
983163953Srrs#define SCTP_STAT_DECR_COUNTER64(_x) SCTP_STAT_DECR(_x)
984163953Srrs#define SCTP_STAT_DECR_GAUGE32(_x) SCTP_STAT_DECR(_x)
985163953Srrs
986164085Srrsunion sctp_sockstore {
987167598Srrs#if defined(INET) || !defined(_KERNEL)
988164085Srrs	struct sockaddr_in sin;
989164085Srrs#endif
990167598Srrs#if defined(INET6) || !defined(_KERNEL)
991164085Srrs	struct sockaddr_in6 sin6;
992164085Srrs#endif
993164085Srrs	struct sockaddr sa;
994164085Srrs};
995164085Srrs
996212242Stuexen
997212242Stuexen/***********************************/
998212242Stuexen/* And something for us old timers */
999212242Stuexen/***********************************/
1000212242Stuexen
1001212242Stuexen#ifndef ntohll
1002212242Stuexen#include <sys/endian.h>
1003212242Stuexen#define ntohll(x) be64toh(x)
1004212242Stuexen#endif
1005212242Stuexen
1006212242Stuexen#ifndef htonll
1007212242Stuexen#include <sys/endian.h>
1008212242Stuexen#define htonll(x) htobe64(x)
1009212242Stuexen#endif
1010212242Stuexen/***********************************/
1011212242Stuexen
1012212242Stuexen
1013165220Srrsstruct xsctp_inpcb {
1014165220Srrs	uint32_t last;
1015165220Srrs	uint32_t flags;
1016165220Srrs	uint32_t features;
1017165220Srrs	uint32_t total_sends;
1018165220Srrs	uint32_t total_recvs;
1019165220Srrs	uint32_t total_nospaces;
1020169352Srrs	uint32_t fragmentation_point;
1021170992Srrs	uint16_t local_port;
1022170056Srrs	uint16_t qlen;
1023170056Srrs	uint16_t maxqlen;
1024190842Srrs	uint32_t extra_padding[32];	/* future */
1025165220Srrs};
1026164085Srrs
1027165220Srrsstruct xsctp_tcb {
1028170992Srrs	union sctp_sockstore primary_addr;	/* sctpAssocEntry 5/6 */
1029170056Srrs	uint32_t last;
1030170056Srrs	uint32_t heartbeat_interval;	/* sctpAssocEntry 7   */
1031170056Srrs	uint32_t state;		/* sctpAssocEntry 8   */
1032170056Srrs	uint32_t in_streams;	/* sctpAssocEntry 9   */
1033170056Srrs	uint32_t out_streams;	/* sctpAssocEntry 10  */
1034170056Srrs	uint32_t max_nr_retrans;/* sctpAssocEntry 11  */
1035170056Srrs	uint32_t primary_process;	/* sctpAssocEntry 12  */
1036170056Srrs	uint32_t T1_expireries;	/* sctpAssocEntry 13  */
1037170056Srrs	uint32_t T2_expireries;	/* sctpAssocEntry 14  */
1038170056Srrs	uint32_t retransmitted_tsns;	/* sctpAssocEntry 15  */
1039165220Srrs	uint32_t total_sends;
1040165220Srrs	uint32_t total_recvs;
1041165220Srrs	uint32_t local_tag;
1042165220Srrs	uint32_t remote_tag;
1043165220Srrs	uint32_t initial_tsn;
1044165220Srrs	uint32_t highest_tsn;
1045165220Srrs	uint32_t cumulative_tsn;
1046165220Srrs	uint32_t cumulative_tsn_ack;
1047169352Srrs	uint32_t mtu;
1048170091Srrs	uint32_t refcnt;
1049170992Srrs	uint16_t local_port;	/* sctpAssocEntry 3   */
1050170992Srrs	uint16_t remote_port;	/* sctpAssocEntry 4   */
1051172091Srrs	struct sctp_timeval start_time;	/* sctpAssocEntry 16  */
1052172091Srrs	struct sctp_timeval discontinuity_time;	/* sctpAssocEntry 17  */
1053188577Srrs	uint32_t peers_rwnd;
1054188067Srrs	sctp_assoc_t assoc_id;	/* sctpAssocEntry 1   */
1055190842Srrs	uint32_t extra_padding[32];	/* future */
1056165220Srrs};
1057165220Srrs
1058165220Srrsstruct xsctp_laddr {
1059170992Srrs	union sctp_sockstore address;	/* sctpAssocLocalAddrEntry 1/2 */
1060170056Srrs	uint32_t last;
1061172091Srrs	struct sctp_timeval start_time;	/* sctpAssocLocalAddrEntry 3   */
1062190842Srrs	uint32_t extra_padding[32];	/* future */
1063165220Srrs};
1064165220Srrs
1065165220Srrsstruct xsctp_raddr {
1066170992Srrs	union sctp_sockstore address;	/* sctpAssocLocalRemEntry 1/2 */
1067170056Srrs	uint32_t last;
1068170056Srrs	uint32_t rto;		/* sctpAssocLocalRemEntry 5   */
1069170056Srrs	uint32_t max_path_rtx;	/* sctpAssocLocalRemEntry 6   */
1070170056Srrs	uint32_t rtx;		/* sctpAssocLocalRemEntry 7   */
1071170056Srrs	uint32_t error_counter;	/* */
1072170056Srrs	uint32_t cwnd;		/* */
1073170056Srrs	uint32_t flight_size;	/* */
1074170056Srrs	uint32_t mtu;		/* */
1075170992Srrs	uint8_t active;		/* sctpAssocLocalRemEntry 3   */
1076170992Srrs	uint8_t confirmed;	/* */
1077170992Srrs	uint8_t heartbeat_enabled;	/* sctpAssocLocalRemEntry 4   */
1078172091Srrs	struct sctp_timeval start_time;	/* sctpAssocLocalRemEntry 8   */
1079190842Srrs	uint32_t rtt;
1080190842Srrs	uint32_t extra_padding[32];	/* future */
1081165220Srrs};
1082165220Srrs
1083172157Srrs#define SCTP_MAX_LOGGING_SIZE 30000
1084172157Srrs#define SCTP_TRACE_PARAMS 6	/* This number MUST be even   */
1085172157Srrs
1086172157Srrsstruct sctp_log_entry {
1087172218Srrs	uint64_t timestamp;
1088172157Srrs	uint32_t subsys;
1089172157Srrs	uint32_t padding;
1090172157Srrs	uint32_t params[SCTP_TRACE_PARAMS];
1091172157Srrs};
1092172157Srrs
1093172157Srrsstruct sctp_log {
1094172157Srrs	struct sctp_log_entry entry[SCTP_MAX_LOGGING_SIZE];
1095172157Srrs	uint32_t index;
1096172157Srrs	uint32_t padding;
1097172157Srrs};
1098172157Srrs
1099163953Srrs/*
1100163953Srrs * Kernel defined for sctp_send
1101163953Srrs */
1102180387Srrs#if defined(_KERNEL) || defined(__Userspace__)
1103163953Srrsint
1104163953Srrssctp_lower_sosend(struct socket *so,
1105163953Srrs    struct sockaddr *addr,
1106163953Srrs    struct uio *uio,
1107169352Srrs    struct mbuf *i_pak,
1108163953Srrs    struct mbuf *control,
1109163953Srrs    int flags,
1110168709Srrs    struct sctp_sndrcvinfo *srcv
1111168709Srrs    ,struct thread *p
1112163953Srrs);
1113163953Srrs
1114163953Srrsint
1115163953Srrssctp_sorecvmsg(struct socket *so,
1116163953Srrs    struct uio *uio,
1117163953Srrs    struct mbuf **mp,
1118163953Srrs    struct sockaddr *from,
1119163953Srrs    int fromlen,
1120163953Srrs    int *msg_flags,
1121163953Srrs    struct sctp_sndrcvinfo *sinfo,
1122163953Srrs    int filling_sinfo);
1123163953Srrs
1124163953Srrs#endif
1125163953Srrs
1126163953Srrs/*
1127163953Srrs * API system calls
1128163953Srrs */
1129180387Srrs#if !(defined(_KERNEL)) && !(defined(__Userspace__))
1130163953Srrs
1131163953Srrs__BEGIN_DECLS
1132163953Srrsint sctp_peeloff __P((int, sctp_assoc_t));
1133163953Srrsint sctp_bindx __P((int, struct sockaddr *, int, int));
1134167598Srrsint sctp_connectx __P((int, const struct sockaddr *, int, sctp_assoc_t *));
1135163953Srrsint sctp_getaddrlen __P((sa_family_t));
1136163953Srrsint sctp_getpaddrs __P((int, sctp_assoc_t, struct sockaddr **));
1137163953Srrsvoid sctp_freepaddrs __P((struct sockaddr *));
1138163953Srrsint sctp_getladdrs __P((int, sctp_assoc_t, struct sockaddr **));
1139163953Srrsvoid sctp_freeladdrs __P((struct sockaddr *));
1140163953Srrsint sctp_opt_info __P((int, sctp_assoc_t, int, void *, socklen_t *));
1141163953Srrs
1142169352Srrsssize_t sctp_sendmsg
1143163953Srrs__P((int, const void *, size_t,
1144163953Srrs    const struct sockaddr *,
1145163953Srrs    socklen_t, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t));
1146163953Srrs
1147163953Srrs	ssize_t sctp_send __P((int sd, const void *msg, size_t len,
1148163953Srrs              const struct sctp_sndrcvinfo *sinfo, int flags));
1149163953Srrs
1150169352Srrs	ssize_t sctp_sendx __P((int sd, const void *msg, size_t len,
1151163953Srrs               struct sockaddr *addrs, int addrcnt,
1152163953Srrs               struct sctp_sndrcvinfo *sinfo, int flags));
1153169352Srrs
1154169352Srrs	ssize_t sctp_sendmsgx __P((int sd, const void *, size_t,
1155163953Srrs                  struct sockaddr *, int,
1156163953Srrs                  uint32_t, uint32_t, uint16_t, uint32_t, uint32_t));
1157163953Srrs
1158169352Srrs	sctp_assoc_t sctp_getassocid __P((int sd, struct sockaddr *sa));
1159163953Srrs
1160163953Srrs	ssize_t sctp_recvmsg __P((int, void *, size_t, struct sockaddr *,
1161163953Srrs                 socklen_t *, struct sctp_sndrcvinfo *, int *));
1162163953Srrs
1163163953Srrs__END_DECLS
1164163953Srrs
1165163953Srrs#endif				/* !_KERNEL */
1166163953Srrs#endif				/* !__sctp_uio_h__ */
1167