sctp_uio.h revision 166675
1/*-
2 * Copyright (c) 2001-2006, Cisco Systems, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * a) Redistributions of source code must retain the above copyright notice,
8 *   this list of conditions and the following disclaimer.
9 *
10 * b) Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in
12 *   the documentation and/or other materials provided with the distribution.
13 *
14 * c) Neither the name of Cisco Systems, Inc. nor the names of its
15 *    contributors may be used to endorse or promote products derived
16 *    from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31/* $KAME: sctp_uio.h,v 1.11 2005/03/06 16:04:18 itojun Exp $	 */
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/netinet/sctp_uio.h 166675 2007-02-12 23:24:31Z rrs $");
34
35#ifndef __sctp_uio_h__
36#define __sctp_uio_h__
37
38
39
40
41#if ! defined(_KERNEL)
42#include <stdint.h>
43#endif
44#include <sys/types.h>
45#include <sys/socket.h>
46#include <sys/time.h>
47#include <netinet/in.h>
48
49typedef uint32_t sctp_assoc_t;
50
51/* On/Off setup for subscription to events */
52struct sctp_event_subscribe {
53	uint8_t sctp_data_io_event;
54	uint8_t sctp_association_event;
55	uint8_t sctp_address_event;
56	uint8_t sctp_send_failure_event;
57	uint8_t sctp_peer_error_event;
58	uint8_t sctp_shutdown_event;
59	uint8_t sctp_partial_delivery_event;
60	uint8_t sctp_adaptation_layer_event;
61	uint8_t sctp_authentication_event;
62	uint8_t sctp_stream_reset_events;
63};
64
65/* ancillary data types */
66#define SCTP_INIT	0x0001
67#define SCTP_SNDRCV	0x0002
68#define SCTP_EXTRCV	0x0003
69/*
70 * ancillary data structures
71 */
72struct sctp_initmsg {
73	uint32_t sinit_num_ostreams;
74	uint32_t sinit_max_instreams;
75	uint16_t sinit_max_attempts;
76	uint16_t sinit_max_init_timeo;
77};
78
79/* We add 96 bytes to the size of sctp_sndrcvinfo.
80 * This makes the current structure 128 bytes long
81 * which is nicely 64 bit aligned but also has room
82 * for us to add more and keep ABI compatability.
83 * For example, already we have the sctp_extrcvinfo
84 * when enabled which is 48 bytes.
85 */
86
87/*
88 * The assoc up needs a verfid
89 * all sendrcvinfo's need a verfid for SENDING only.
90 */
91
92
93#define SCTP_ALIGN_RESV_PAD 96
94#define SCTP_ALIGN_RESV_PAD_SHORT 80
95
96struct sctp_sndrcvinfo {
97	uint16_t sinfo_stream;
98	uint16_t sinfo_ssn;
99	uint16_t sinfo_flags;
100	uint32_t sinfo_ppid;
101	uint32_t sinfo_context;
102	uint32_t sinfo_timetolive;
103	uint32_t sinfo_tsn;
104	uint32_t sinfo_cumtsn;
105	sctp_assoc_t sinfo_assoc_id;
106	uint8_t __reserve_pad[SCTP_ALIGN_RESV_PAD];
107};
108
109struct sctp_extrcvinfo {
110	uint16_t sinfo_stream;
111	uint16_t sinfo_ssn;
112	uint16_t sinfo_flags;
113	uint32_t sinfo_ppid;
114	uint32_t sinfo_context;
115	uint32_t sinfo_timetolive;
116	uint32_t sinfo_tsn;
117	uint32_t sinfo_cumtsn;
118	sctp_assoc_t sinfo_assoc_id;
119	uint16_t next_flags;
120	uint16_t next_stream;
121	uint32_t next_asocid;
122	uint32_t next_length;
123	uint32_t next_ppid;
124	uint8_t __reserve_pad[SCTP_ALIGN_RESV_PAD_SHORT];
125};
126
127#define SCTP_NO_NEXT_MSG           0x0000
128#define SCTP_NEXT_MSG_AVAIL        0x0001
129#define SCTP_NEXT_MSG_ISCOMPLETE   0x0002
130#define SCTP_NEXT_MSG_IS_UNORDERED 0x0004
131#define SCTP_NEXT_MSG_IS_NOTIFICATION 0x0008
132
133struct sctp_snd_all_completes {
134	uint16_t sall_stream;
135	uint16_t sall_flags;
136	uint32_t sall_ppid;
137	uint32_t sall_context;
138	uint32_t sall_num_sent;
139	uint32_t sall_num_failed;
140};
141
142/* Flags that go into the sinfo->sinfo_flags field */
143#define SCTP_EOF 	  0x0100/* Start shutdown procedures */
144#define SCTP_ABORT	  0x0200/* Send an ABORT to peer */
145#define SCTP_UNORDERED 	  0x0400/* Message is un-ordered */
146#define SCTP_ADDR_OVER	  0x0800/* Override the primary-address */
147#define SCTP_SENDALL      0x1000/* Send this on all associations */
148#define SCTP_EOR          0x2000/* end of message signal */
149#define INVALID_SINFO_FLAG(x) (((x) & 0xffffff00 \
150                                    & ~(SCTP_EOF | SCTP_ABORT | SCTP_UNORDERED |\
151				        SCTP_ADDR_OVER | SCTP_SENDALL | SCTP_EOR)) != 0)
152/* for the endpoint */
153
154/* The lower byte is an enumeration of PR-SCTP policies */
155#define SCTP_PR_SCTP_TTL  0x0001/* Time based PR-SCTP */
156#define SCTP_PR_SCTP_BUF  0x0002/* Buffer based PR-SCTP */
157#define SCTP_PR_SCTP_RTX  0x0003/* Number of retransmissions based PR-SCTP */
158
159#define PR_SCTP_POLICY(x)         ((x) & 0xff)
160#define PR_SCTP_ENABLED(x)        (PR_SCTP_POLICY(x) != 0)
161#define PR_SCTP_TTL_ENABLED(x)    (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_TTL)
162#define PR_SCTP_BUF_ENABLED(x)    (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_BUF)
163#define PR_SCTP_RTX_ENABLED(x)    (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_RTX)
164#define PR_SCTP_INVALID_POLICY(x) (PR_SCTP_POLICY(x) > SCTP_PR_SCTP_RTX)
165/* Stat's */
166struct sctp_pcbinfo {
167	uint32_t ep_count;
168	uint32_t asoc_count;
169	uint32_t laddr_count;
170	uint32_t raddr_count;
171	uint32_t chk_count;
172	uint32_t readq_count;
173	uint32_t free_chunks;
174	uint32_t stream_oque;
175};
176
177struct sctp_sockstat {
178	sctp_assoc_t ss_assoc_id;
179	uint32_t ss_total_sndbuf;
180	uint32_t ss_total_recv_buf;
181};
182
183/*
184 * notification event structures
185 */
186
187/*
188 * association change event
189 */
190struct sctp_assoc_change {
191	uint16_t sac_type;
192	uint16_t sac_flags;
193	uint32_t sac_length;
194	uint16_t sac_state;
195	uint16_t sac_error;
196	uint16_t sac_outbound_streams;
197	uint16_t sac_inbound_streams;
198	sctp_assoc_t sac_assoc_id;
199};
200
201/* sac_state values */
202#define SCTP_COMM_UP		0x0001
203#define SCTP_COMM_LOST		0x0002
204#define SCTP_RESTART		0x0003
205#define SCTP_SHUTDOWN_COMP	0x0004
206#define SCTP_CANT_STR_ASSOC	0x0005
207
208
209/*
210 * Address event
211 */
212struct sctp_paddr_change {
213	uint16_t spc_type;
214	uint16_t spc_flags;
215	uint32_t spc_length;
216	struct sockaddr_storage spc_aaddr;
217	uint32_t spc_state;
218	uint32_t spc_error;
219	sctp_assoc_t spc_assoc_id;
220};
221
222/* paddr state values */
223#define SCTP_ADDR_AVAILABLE	0x0001
224#define SCTP_ADDR_UNREACHABLE	0x0002
225#define SCTP_ADDR_REMOVED	0x0003
226#define SCTP_ADDR_ADDED		0x0004
227#define SCTP_ADDR_MADE_PRIM	0x0005
228#define SCTP_ADDR_CONFIRMED	0x0006
229
230/*
231 * CAUTION: these are user exposed SCTP addr reachability states must be
232 * compatible with SCTP_ADDR states in sctp_constants.h
233 */
234#ifdef SCTP_ACTIVE
235#undef SCTP_ACTIVE
236#endif
237#define SCTP_ACTIVE		0x0001	/* SCTP_ADDR_REACHABLE */
238
239#ifdef SCTP_INACTIVE
240#undef SCTP_INACTIVE
241#endif
242#define SCTP_INACTIVE		0x0002	/* SCTP_ADDR_NOT_REACHABLE */
243
244#ifdef SCTP_UNCONFIRMED
245#undef SCTP_UNCONFIRMED
246#endif
247#define SCTP_UNCONFIRMED	0x0200	/* SCTP_ADDR_UNCONFIRMED */
248
249#ifdef SCTP_NOHEARTBEAT
250#undef SCTP_NOHEARTBEAT
251#endif
252#define SCTP_NOHEARTBEAT	0x0040	/* SCTP_ADDR_NOHB */
253
254
255/* remote error events */
256struct sctp_remote_error {
257	uint16_t sre_type;
258	uint16_t sre_flags;
259	uint32_t sre_length;
260	uint16_t sre_error;
261	sctp_assoc_t sre_assoc_id;
262	uint8_t sre_data[4];
263};
264
265/* data send failure event */
266struct sctp_send_failed {
267	uint16_t ssf_type;
268	uint16_t ssf_flags;
269	uint32_t ssf_length;
270	uint32_t ssf_error;
271	struct sctp_sndrcvinfo ssf_info;
272	sctp_assoc_t ssf_assoc_id;
273	uint8_t ssf_data[4];
274};
275
276/* flag that indicates state of data */
277#define SCTP_DATA_UNSENT	0x0001	/* inqueue never on wire */
278#define SCTP_DATA_SENT		0x0002	/* on wire at failure */
279
280/* shutdown event */
281struct sctp_shutdown_event {
282	uint16_t sse_type;
283	uint16_t sse_flags;
284	uint32_t sse_length;
285	sctp_assoc_t sse_assoc_id;
286};
287
288/* Adaptation layer indication stuff */
289struct sctp_adaptation_event {
290	uint16_t sai_type;
291	uint16_t sai_flags;
292	uint32_t sai_length;
293	uint32_t sai_adaptation_ind;
294	sctp_assoc_t sai_assoc_id;
295};
296
297struct sctp_setadaptation {
298	uint32_t ssb_adaptation_ind;
299};
300
301/* compatable old spelling */
302struct sctp_adaption_event {
303	uint16_t sai_type;
304	uint16_t sai_flags;
305	uint32_t sai_length;
306	uint32_t sai_adaption_ind;
307	sctp_assoc_t sai_assoc_id;
308};
309
310struct sctp_setadaption {
311	uint32_t ssb_adaption_ind;
312};
313
314
315/*
316 * Partial Delivery API event
317 */
318struct sctp_pdapi_event {
319	uint16_t pdapi_type;
320	uint16_t pdapi_flags;
321	uint32_t pdapi_length;
322	uint32_t pdapi_indication;
323	sctp_assoc_t pdapi_assoc_id;
324};
325
326/* indication values */
327#define SCTP_PARTIAL_DELIVERY_ABORTED	0x0001
328
329
330/*
331 * authentication key event
332 */
333struct sctp_authkey_event {
334	uint16_t auth_type;
335	uint16_t auth_flags;
336	uint32_t auth_length;
337	uint16_t auth_keynumber;
338	uint16_t auth_altkeynumber;
339	uint32_t auth_indication;
340	sctp_assoc_t auth_assoc_id;
341};
342
343/* indication values */
344#define SCTP_AUTH_NEWKEY	0x0001
345
346
347/*
348 * stream reset event
349 */
350struct sctp_stream_reset_event {
351	uint16_t strreset_type;
352	uint16_t strreset_flags;
353	uint32_t strreset_length;
354	sctp_assoc_t strreset_assoc_id;
355	uint16_t strreset_list[0];
356};
357
358/* flags in strreset_flags field */
359#define SCTP_STRRESET_INBOUND_STR  0x0001
360#define SCTP_STRRESET_OUTBOUND_STR 0x0002
361#define SCTP_STRRESET_ALL_STREAMS  0x0004
362#define SCTP_STRRESET_STREAM_LIST  0x0008
363#define SCTP_STRRESET_FAILED       0x0010
364
365
366/* SCTP notification event */
367struct sctp_tlv {
368	uint16_t sn_type;
369	uint16_t sn_flags;
370	uint32_t sn_length;
371};
372
373union sctp_notification {
374	struct sctp_tlv sn_header;
375	struct sctp_assoc_change sn_assoc_change;
376	struct sctp_paddr_change sn_paddr_change;
377	struct sctp_remote_error sn_remote_error;
378	struct sctp_send_failed sn_send_failed;
379	struct sctp_shutdown_event sn_shutdown_event;
380	struct sctp_adaptation_event sn_adaptation_event;
381	/* compatability same as above */
382	struct sctp_adaption_event sn_adaption_event;
383	struct sctp_pdapi_event sn_pdapi_event;
384	struct sctp_authkey_event sn_auth_event;
385	struct sctp_stream_reset_event sn_strreset_event;
386};
387
388/* notification types */
389#define SCTP_ASSOC_CHANGE		0x0001
390#define SCTP_PEER_ADDR_CHANGE		0x0002
391#define SCTP_REMOTE_ERROR		0x0003
392#define SCTP_SEND_FAILED		0x0004
393#define SCTP_SHUTDOWN_EVENT		0x0005
394#define SCTP_ADAPTATION_INDICATION	0x0006
395/* same as above */
396#define SCTP_ADAPTION_INDICATION	0x0006
397#define SCTP_PARTIAL_DELIVERY_EVENT	0x0007
398#define SCTP_AUTHENTICATION_EVENT	0x0008
399#define SCTP_STREAM_RESET_EVENT		0x0009
400
401
402/*
403 * socket option structs
404 */
405
406struct sctp_paddrparams {
407	sctp_assoc_t spp_assoc_id;
408	struct sockaddr_storage spp_address;
409	uint32_t spp_hbinterval;
410	uint16_t spp_pathmaxrxt;
411	uint32_t spp_pathmtu;
412	uint32_t spp_sackdelay;
413	uint32_t spp_flags;
414	uint32_t spp_ipv6_flowlabel;
415	uint8_t spp_ipv4_tos;
416
417};
418
419#define SPP_HB_ENABLE		0x00000001
420#define SPP_HB_DISABLE		0x00000002
421#define SPP_HB_DEMAND		0x00000004
422#define SPP_PMTUD_ENABLE	0x00000008
423#define SPP_PMTUD_DISABLE	0x00000010
424#define SPP_SACKDELAY_ENABLE	0x00000020
425#define SPP_SACKDELAY_DISABLE	0x00000040
426#define SPP_HB_TIME_IS_ZERO     0x00000080
427#define SPP_IPV6_FLOWLABEL      0x00000100
428#define SPP_IPV4_TOS            0x00000200
429
430struct sctp_paddrinfo {
431	sctp_assoc_t spinfo_assoc_id;
432	struct sockaddr_storage spinfo_address;
433	int32_t spinfo_state;
434	uint32_t spinfo_cwnd;
435	uint32_t spinfo_srtt;
436	uint32_t spinfo_rto;
437	uint32_t spinfo_mtu;
438};
439
440struct sctp_rtoinfo {
441	sctp_assoc_t srto_assoc_id;
442	uint32_t srto_initial;
443	uint32_t srto_max;
444	uint32_t srto_min;
445};
446
447struct sctp_assocparams {
448	sctp_assoc_t sasoc_assoc_id;
449	uint16_t sasoc_asocmaxrxt;
450	uint16_t sasoc_number_peer_destinations;
451	uint32_t sasoc_peer_rwnd;
452	uint32_t sasoc_local_rwnd;
453	uint32_t sasoc_cookie_life;
454};
455
456struct sctp_setprim {
457	sctp_assoc_t ssp_assoc_id;
458	struct sockaddr_storage ssp_addr;
459};
460
461struct sctp_setpeerprim {
462	sctp_assoc_t sspp_assoc_id;
463	struct sockaddr_storage sspp_addr;
464};
465
466struct sctp_getaddresses {
467	sctp_assoc_t sget_assoc_id;
468	/* addr is filled in for N * sockaddr_storage */
469	struct sockaddr addr[1];
470};
471
472struct sctp_setstrm_timeout {
473	sctp_assoc_t ssto_assoc_id;
474	uint32_t ssto_timeout;
475	uint32_t ssto_streamid_start;
476	uint32_t ssto_streamid_end;
477};
478
479struct sctp_status {
480	sctp_assoc_t sstat_assoc_id;
481	int32_t sstat_state;
482	uint32_t sstat_rwnd;
483	uint16_t sstat_unackdata;
484	uint16_t sstat_penddata;
485	uint16_t sstat_instrms;
486	uint16_t sstat_outstrms;
487	uint32_t sstat_fragmentation_point;
488	struct sctp_paddrinfo sstat_primary;
489};
490
491/*
492 * AUTHENTICATION support
493 */
494/* SCTP_AUTH_CHUNK */
495struct sctp_authchunk {
496	uint8_t sauth_chunk;
497};
498
499/* SCTP_AUTH_KEY */
500struct sctp_authkey {
501	sctp_assoc_t sca_assoc_id;
502	uint16_t sca_keynumber;
503	uint8_t sca_key[0];
504};
505
506/* SCTP_HMAC_IDENT */
507struct sctp_hmacalgo {
508	uint16_t shmac_idents[0];
509};
510
511/* AUTH hmac_id */
512#define SCTP_AUTH_HMAC_ID_RSVD		0x0000
513#define SCTP_AUTH_HMAC_ID_SHA1		0x0001	/* default, mandatory */
514#define SCTP_AUTH_HMAC_ID_MD5		0x0002	/* deprecated */
515#define SCTP_AUTH_HMAC_ID_SHA256	0x0003
516#define SCTP_AUTH_HMAC_ID_SHA224	0x8001
517#define SCTP_AUTH_HMAC_ID_SHA384	0x8002
518#define SCTP_AUTH_HMAC_ID_SHA512	0x8003
519
520
521/* SCTP_AUTH_ACTIVE_KEY / SCTP_AUTH_DELETE_KEY */
522struct sctp_authkeyid {
523	sctp_assoc_t scact_assoc_id;
524	uint16_t scact_keynumber;
525};
526
527/* SCTP_PEER_AUTH_CHUNKS / SCTP_LOCAL_AUTH_CHUNKS */
528struct sctp_authchunks {
529	sctp_assoc_t gauth_assoc_id;
530	uint8_t gauth_chunks[0];
531};
532
533struct sctp_assoc_value {
534	sctp_assoc_t assoc_id;
535	uint32_t assoc_value;
536};
537
538#define MAX_ASOC_IDS_RET 255
539struct sctp_assoc_ids {
540	uint16_t asls_assoc_start;	/* array of index's start at 0 */
541	uint8_t asls_numb_present;
542	uint8_t asls_more_to_get;
543	sctp_assoc_t asls_assoc_id[MAX_ASOC_IDS_RET];
544};
545
546struct sctp_cwnd_args {
547	struct sctp_nets *net;	/* network to */
548	uint32_t cwnd_new_value;/* cwnd in k */
549	uint32_t inflight;	/* flightsize in k */
550	uint32_t pseudo_cumack;
551	int cwnd_augment;	/* increment to it */
552	uint8_t meets_pseudo_cumack;
553	uint8_t need_new_pseudo_cumack;
554	uint8_t cnt_in_send;
555	uint8_t cnt_in_str;
556};
557
558struct sctp_blk_args {
559	uint32_t onsb;		/* in 1k bytes */
560	uint32_t sndlen;	/* len of send being attempted */
561	uint32_t peer_rwnd;	/* rwnd of peer */
562	uint16_t send_sent_qcnt;/* chnk cnt */
563	uint16_t stream_qcnt;	/* chnk cnt */
564	uint16_t chunks_on_oque;/* chunks out */
565	uint16_t flight_size;	/* flight size in k */
566};
567
568/*
569 * Max we can reset in one setting, note this is dictated not by the define
570 * but the size of a mbuf cluster so don't change this define and think you
571 * can specify more. You must do multiple resets if you want to reset more
572 * than SCTP_MAX_EXPLICIT_STR_RESET.
573 */
574#define SCTP_MAX_EXPLICT_STR_RESET   1000
575
576#define SCTP_RESET_LOCAL_RECV  0x0001
577#define SCTP_RESET_LOCAL_SEND  0x0002
578#define SCTP_RESET_BOTH        0x0003
579#define SCTP_RESET_TSN         0x0004
580
581struct sctp_stream_reset {
582	sctp_assoc_t strrst_assoc_id;
583	uint16_t strrst_flags;
584	uint16_t strrst_num_streams;	/* 0 == ALL */
585	uint16_t strrst_list[0];/* list if strrst_num_streams is not 0 */
586};
587
588
589struct sctp_get_nonce_values {
590	sctp_assoc_t gn_assoc_id;
591	uint32_t gn_peers_tag;
592	uint32_t gn_local_tag;
593};
594
595/* Debugging logs */
596struct sctp_str_log {
597	void *stcb;
598	uint32_t n_tsn;
599	uint32_t e_tsn;
600	uint16_t n_sseq;
601	uint16_t e_sseq;
602	uint16_t strm;
603};
604
605struct sctp_sb_log {
606	void *stcb;
607	uint32_t so_sbcc;
608	uint32_t stcb_sbcc;
609	uint32_t incr;
610};
611
612struct sctp_fr_log {
613	uint32_t largest_tsn;
614	uint32_t largest_new_tsn;
615	uint32_t tsn;
616};
617
618struct sctp_fr_map {
619	uint32_t base;
620	uint32_t cum;
621	uint32_t high;
622};
623
624struct sctp_rwnd_log {
625	uint32_t rwnd;
626	uint32_t send_size;
627	uint32_t overhead;
628	uint32_t new_rwnd;
629};
630
631struct sctp_mbcnt_log {
632	uint32_t total_queue_size;
633	uint32_t size_change;
634	uint32_t total_queue_mb_size;
635	uint32_t mbcnt_change;
636};
637
638struct sctp_sack_log {
639	uint32_t cumack;
640	uint32_t oldcumack;
641	uint32_t tsn;
642	uint16_t numGaps;
643	uint16_t numDups;
644};
645
646struct sctp_lock_log {
647	void *sock;
648	void *inp;
649	uint8_t tcb_lock;
650	uint8_t inp_lock;
651	uint8_t info_lock;
652	uint8_t sock_lock;
653	uint8_t sockrcvbuf_lock;
654	uint8_t socksndbuf_lock;
655	uint8_t create_lock;
656	uint8_t resv;
657};
658
659struct sctp_rto_log {
660	void *net;
661	uint32_t rtt;
662	uint32_t rttvar;
663	uint8_t direction;
664};
665
666struct sctp_nagle_log {
667	void *stcb;
668	uint32_t total_flight;
669	uint32_t total_in_queue;
670	uint16_t count_in_queue;
671	uint16_t count_in_flight;
672};
673
674struct sctp_sbwake_log {
675	void *stcb;
676	uint16_t send_q;
677	uint16_t sent_q;
678	uint16_t flight;
679	uint16_t wake_cnt;
680	uint8_t stream_qcnt;	/* chnk cnt */
681	uint8_t chunks_on_oque;	/* chunks out */
682	uint8_t sbflags;
683	uint8_t sctpflags;
684};
685
686struct sctp_misc_info {
687	uint32_t log1;
688	uint32_t log2;
689	uint32_t log3;
690	uint32_t log4;
691};
692
693struct sctp_log_closing {
694	void *inp;
695	void *stcb;
696	uint32_t sctp_flags;
697	uint16_t state;
698	int16_t loc;
699};
700
701struct sctp_mbuf_log {
702	struct mbuf *mp;
703	caddr_t ext;
704	caddr_t data;
705	uint16_t size;
706	uint8_t refcnt;
707	uint8_t mbuf_flags;
708};
709
710struct sctp_cwnd_log {
711	uint32_t time_event;
712	uint8_t from;
713	uint8_t event_type;
714	uint8_t resv[2];
715	union {
716		struct sctp_log_closing close;
717		struct sctp_blk_args blk;
718		struct sctp_cwnd_args cwnd;
719		struct sctp_str_log strlog;
720		struct sctp_fr_log fr;
721		struct sctp_fr_map map;
722		struct sctp_rwnd_log rwnd;
723		struct sctp_mbcnt_log mbcnt;
724		struct sctp_sack_log sack;
725		struct sctp_lock_log lock;
726		struct sctp_rto_log rto;
727		struct sctp_sb_log sb;
728		struct sctp_nagle_log nagle;
729		struct sctp_sbwake_log wake;
730		struct sctp_mbuf_log mb;
731		struct sctp_misc_info misc;
732	}     x;
733};
734
735struct sctp_cwnd_log_req {
736	int num_in_log;		/* Number in log */
737	int num_ret;		/* Number returned */
738	int start_at;		/* start at this one */
739	int end_at;		/* end at this one */
740	struct sctp_cwnd_log log[0];
741};
742
743struct sctpstat {
744	/* MIB according to RFC 3873 */
745	u_long sctps_currestab;	/* sctpStats  1   (Gauge32) */
746	u_long sctps_activeestab;	/* sctpStats  2 (Counter32) */
747	u_long sctps_restartestab;
748	u_long sctps_collisionestab;
749	u_long sctps_passiveestab;	/* sctpStats  3 (Counter32) */
750	u_long sctps_aborted;	/* sctpStats  4 (Counter32) */
751	u_long sctps_shutdown;	/* sctpStats  5 (Counter32) */
752	u_long sctps_outoftheblue;	/* sctpStats  6 (Counter32) */
753	u_long sctps_checksumerrors;	/* sctpStats  7 (Counter32) */
754	u_long sctps_outcontrolchunks;	/* sctpStats  8 (Counter64) */
755	u_long sctps_outorderchunks;	/* sctpStats  9 (Counter64) */
756	u_long sctps_outunorderchunks;	/* sctpStats 10 (Counter64) */
757	u_long sctps_incontrolchunks;	/* sctpStats 11 (Counter64) */
758	u_long sctps_inorderchunks;	/* sctpStats 12 (Counter64) */
759	u_long sctps_inunorderchunks;	/* sctpStats 13 (Counter64) */
760	u_long sctps_fragusrmsgs;	/* sctpStats 14 (Counter64) */
761	u_long sctps_reasmusrmsgs;	/* sctpStats 15 (Counter64) */
762	u_long sctps_outpackets;/* sctpStats 16 (Counter64) */
763	u_long sctps_inpackets;	/* sctpStats 17 (Counter64) */
764	struct timeval sctps_discontinuitytime;	/* sctpStats 18 (TimeStamp) */
765	/* input statistics: */
766	u_long sctps_recvpackets;	/* total input packets        */
767	u_long sctps_recvdatagrams;	/* total input datagrams      */
768	u_long sctps_recvpktwithdata;
769	u_long sctps_recvsacks;	/* total input SACK chunks    */
770	u_long sctps_recvdata;	/* total input DATA chunks    */
771	u_long sctps_recvdupdata;	/* total input duplicate DATA chunks */
772	u_long sctps_recvheartbeat;	/* total input HB chunks      */
773	u_long sctps_recvheartbeatack;	/* total input HB-ACK chunks  */
774	u_long sctps_recvecne;	/* total input ECNE chunks    */
775	u_long sctps_recvauth;	/* total input AUTH chunks    */
776	u_long sctps_recvauthmissing;	/* total input chunks missing AUTH */
777	u_long sctps_recvivalhmacid;	/* total number of invalid HMAC ids
778					 * received */
779	u_long sctps_recvivalkeyid;	/* total number of invalid secret ids
780					 * received */
781	u_long sctps_recvauthfailed;	/* total number of auth failed */
782	u_long sctps_recvexpress;	/* total fast path receives all one
783					 * chunk */
784	u_long sctps_recvexpressm;	/* total fast path multi-part data */
785	/* output statistics: */
786	u_long sctps_sendpackets;	/* total output packets       */
787	u_long sctps_sendsacks;	/* total output SACKs         */
788	u_long sctps_senddata;	/* total output DATA chunks   */
789	u_long sctps_sendretransdata;	/* total output retransmitted DATA
790					 * chunks */
791	u_long sctps_sendfastretrans;	/* total output fast retransmitted
792					 * DATA chunks */
793	u_long sctps_sendmultfastretrans;	/* U-del */
794	u_long sctps_sendheartbeat;	/* total output HB chunks     */
795	u_long sctps_sendecne;	/* total output ECNE chunks    */
796	u_long sctps_sendauth;	/* total output AUTH chunks FIXME   */
797	u_long sctps_senderrors;/* ip_output error counter */
798	/* PCKDROPREP statistics: */
799	u_long sctps_pdrpfmbox;	/* */
800	u_long sctps_pdrpfehos;	/* */
801	u_long sctps_pdrpmbda;	/* */
802	u_long sctps_pdrpmbct;	/* */
803	u_long sctps_pdrpbwrpt;	/* */
804	u_long sctps_pdrpcrupt;	/* */
805	u_long sctps_pdrpnedat;	/* */
806	u_long sctps_pdrppdbrk;	/* */
807	u_long sctps_pdrptsnnf;	/* */
808	u_long sctps_pdrpdnfnd;	/* */
809	u_long sctps_pdrpdiwnp;	/* */
810	u_long sctps_pdrpdizrw;	/* */
811	u_long sctps_pdrpbadd;	/* */
812	u_long sctps_pdrpmark;	/* */
813	/* timeouts */
814	u_long sctps_timoiterator;	/* */
815	u_long sctps_timodata;	/* */
816	u_long sctps_timowindowprobe;	/* */
817	u_long sctps_timoinit;	/* */
818	u_long sctps_timosack;	/* */
819	u_long sctps_timoshutdown;	/* */
820	u_long sctps_timoheartbeat;	/* */
821	u_long sctps_timocookie;/* */
822	u_long sctps_timosecret;/* */
823	u_long sctps_timopathmtu;	/* */
824	u_long sctps_timoshutdownack;	/* */
825	u_long sctps_timoshutdownguard;	/* */
826	u_long sctps_timostrmrst;	/* */
827	u_long sctps_timoearlyfr;	/* */
828	u_long sctps_timoasconf;/* */
829	u_long sctps_timoautoclose;	/* */
830	u_long sctps_timoassockill;	/* */
831	u_long sctps_timoinpkill;	/* */
832	/* Early fast retransmission counters */
833	u_long sctps_earlyfrstart;
834	u_long sctps_earlyfrstop;
835	u_long sctps_earlyfrmrkretrans;
836	u_long sctps_earlyfrstpout;
837	u_long sctps_earlyfrstpidsck1;
838	u_long sctps_earlyfrstpidsck2;
839	u_long sctps_earlyfrstpidsck3;
840	u_long sctps_earlyfrstpidsck4;
841	u_long sctps_earlyfrstrid;
842	u_long sctps_earlyfrstrout;
843	u_long sctps_earlyfrstrtmr;
844	/* otheres */
845	u_long sctps_hdrops;	/* packet shorter than header */
846	u_long sctps_badsum;	/* checksum error             */
847	u_long sctps_noport;	/* no endpoint for port       */
848	u_long sctps_badvtag;	/* bad v-tag                  */
849	u_long sctps_badsid;	/* bad SID                    */
850	u_long sctps_nomem;	/* no memory                  */
851	u_long sctps_fastretransinrtt;	/* number of multiple FR in a RTT
852					 * window */
853	u_long sctps_markedretrans;
854	u_long sctps_naglesent;	/* nagle allowed sending      */
855	u_long sctps_naglequeued;	/* nagle does't allow sending */
856	u_long sctps_maxburstqueued;	/* max burst dosn't allow sending */
857	u_long sctps_ifnomemqueued;	/* */
858	u_long sctps_windowprobed;	/* total number of window probes sent */
859	u_long sctps_lowlevelerr;
860	u_long sctps_lowlevelerrusr;
861	u_long sctps_datadropchklmt;
862	u_long sctps_datadroprwnd;
863	u_long sctps_ecnereducedcwnd;
864	u_long sctps_vtagexpress;	/* Used express lookup via vtag */
865	u_long sctps_vtagbogus;	/* Collision in express lookup. */
866	u_long sctps_primary_randry;	/* Number of times the sender ran dry
867					 * of user data on primary */
868	u_long sctps_cmt_randry;/* Same for above */
869	u_long sctps_slowpath_sack;	/* Sacks the slow way */
870	u_long sctps_wu_sacks_sent;	/* Window Update only sacks sent */
871	u_long sctps_sends_with_flags;	/* number of sends with sinfo_flags
872					 * !=0 */
873	u_long sctps_sends_with_unord;
874	u_long sctps_sends_with_eof;
875	u_long sctps_sends_with_abort;
876	u_long sctps_protocol_drain_calls;
877	u_long sctps_protocol_drains_done;
878};
879
880#define SCTP_STAT_INCR(_x) SCTP_STAT_INCR_BY(_x,1)
881#define SCTP_STAT_DECR(_x) SCTP_STAT_DECR_BY(_x,1)
882#define SCTP_STAT_INCR_BY(_x,_d) atomic_add_long(&sctpstat._x, _d)
883#define SCTP_STAT_DECR_BY(_x,_d) atomic_add_long(&sctpstat._x, -(_d))
884/* The following macros are for handling MIB values, */
885#define SCTP_STAT_INCR_COUNTER32(_x) SCTP_STAT_INCR(_x)
886#define SCTP_STAT_INCR_COUNTER64(_x) SCTP_STAT_INCR(_x)
887#define SCTP_STAT_INCR_GAUGE32(_x) SCTP_STAT_INCR(_x)
888#define SCTP_STAT_DECR_COUNTER32(_x) SCTP_STAT_DECR(_x)
889#define SCTP_STAT_DECR_COUNTER64(_x) SCTP_STAT_DECR(_x)
890#define SCTP_STAT_DECR_GAUGE32(_x) SCTP_STAT_DECR(_x)
891
892union sctp_sockstore {
893#ifdef AF_INET
894	struct sockaddr_in sin;
895#endif
896#ifdef AF_INET6
897	struct sockaddr_in6 sin6;
898#endif
899	struct sockaddr sa;
900};
901
902struct xsctp_inpcb {
903	uint32_t last;
904	uint16_t local_port;
905	uint16_t number_local_addresses;
906	uint32_t number_associations;
907	uint32_t flags;
908	uint32_t features;
909	uint32_t total_sends;
910	uint32_t total_recvs;
911	uint32_t total_nospaces;
912	/* add more endpoint specific data here */
913};
914
915struct xsctp_tcb {
916	uint16_t LocalPort;	/* sctpAssocEntry 3   */
917	uint16_t RemPort;	/* sctpAssocEntry 4   */
918	union sctp_sockstore RemPrimAddr;	/* sctpAssocEntry 5/6 */
919	uint32_t HeartBeatInterval;	/* sctpAssocEntry 7   */
920	uint32_t State;		/* sctpAssocEntry 8   */
921	uint32_t InStreams;	/* sctpAssocEntry 9   */
922	uint32_t OutStreams;	/* sctpAssocEntry 10  */
923	uint32_t MaxRetr;	/* sctpAssocEntry 11  */
924	uint32_t PrimProcess;	/* sctpAssocEntry 12  */
925	uint32_t T1expireds;	/* sctpAssocEntry 13  */
926	uint32_t T2expireds;	/* sctpAssocEntry 14  */
927	uint32_t RtxChunks;	/* sctpAssocEntry 15  */
928	struct timeval StartTime;	/* sctpAssocEntry 16  */
929	struct timeval DiscontinuityTime;	/* sctpAssocEntry 17  */
930	uint32_t total_sends;
931	uint32_t total_recvs;
932	uint32_t local_tag;
933	uint32_t remote_tag;
934	uint32_t initial_tsn;
935	uint32_t highest_tsn;
936	uint32_t cumulative_tsn;
937	uint32_t cumulative_tsn_ack;
938	/* add more association specific data here */
939	uint16_t number_local_addresses;
940	uint16_t number_remote_addresses;
941};
942
943struct xsctp_laddr {
944	union sctp_sockstore LocalAddr;	/* sctpAssocLocalAddrEntry 1/2 */
945	struct timeval LocalStartTime;	/* sctpAssocLocalAddrEntry 3   */
946	/* add more local address specific data */
947};
948
949struct xsctp_raddr {
950	union sctp_sockstore RemAddr;	/* sctpAssocLocalRemEntry 1/2 */
951	uint8_t RemAddrActive;	/* sctpAssocLocalRemEntry 3   */
952	uint8_t RemAddrConfirmed;	/* */
953	uint8_t RemAddrHBActive;/* sctpAssocLocalRemEntry 4   */
954	uint32_t RemAddrRTO;	/* sctpAssocLocalRemEntry 5   */
955	uint32_t RemAddrMaxPathRtx;	/* sctpAssocLocalRemEntry 6   */
956	uint32_t RemAddrRtx;	/* sctpAssocLocalRemEntry 7   */
957	uint32_t RemAddrErrorCounter;	/* */
958	uint32_t RemAddrCwnd;	/* */
959	uint32_t RemAddrFlightSize;	/* */
960	struct timeval RemAddrStartTime;	/* sctpAssocLocalRemEntry 8   */
961	/* add more remote address specific data */
962};
963
964/*
965 * Kernel defined for sctp_send
966 */
967#if defined(_KERNEL)
968int
969sctp_lower_sosend(struct socket *so,
970    struct sockaddr *addr,
971    struct uio *uio,
972    struct mbuf *top,
973    struct mbuf *control,
974    int flags,
975    int use_rcvinfo,
976    struct sctp_sndrcvinfo *srcv,
977    struct thread *p
978);
979
980int
981sctp_sorecvmsg(struct socket *so,
982    struct uio *uio,
983    struct mbuf **mp,
984    struct sockaddr *from,
985    int fromlen,
986    int *msg_flags,
987    struct sctp_sndrcvinfo *sinfo,
988    int filling_sinfo);
989
990
991#endif
992
993/*
994 * API system calls
995 */
996
997#if !(defined(_KERNEL))
998
999__BEGIN_DECLS
1000int sctp_peeloff __P((int, sctp_assoc_t));
1001int sctp_bindx __P((int, struct sockaddr *, int, int));
1002int sctp_connectx __P((int, const struct sockaddr *, int));
1003int sctp_getaddrlen __P((sa_family_t));
1004int sctp_getpaddrs __P((int, sctp_assoc_t, struct sockaddr **));
1005void sctp_freepaddrs __P((struct sockaddr *));
1006int sctp_getladdrs __P((int, sctp_assoc_t, struct sockaddr **));
1007void sctp_freeladdrs __P((struct sockaddr *));
1008int sctp_opt_info __P((int, sctp_assoc_t, int, void *, socklen_t *));
1009
1010ssize_t sctp_sendmsg
1011__P((int, const void *, size_t,
1012    const struct sockaddr *,
1013    socklen_t, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t));
1014
1015	ssize_t sctp_send __P((int sd, const void *msg, size_t len,
1016              const struct sctp_sndrcvinfo *sinfo, int flags));
1017
1018	ssize_t
1019	sctp_sendx __P((int sd, const void *msg, size_t len,
1020               struct sockaddr *addrs, int addrcnt,
1021               struct sctp_sndrcvinfo *sinfo, int flags));
1022	ssize_t
1023	sctp_sendmsgx __P((int sd, const void *, size_t,
1024                  struct sockaddr *, int,
1025                  uint32_t, uint32_t, uint16_t, uint32_t, uint32_t));
1026
1027sctp_assoc_t
1028sctp_getassocid __P((int sd, struct sockaddr *sa));
1029
1030	ssize_t sctp_recvmsg __P((int, void *, size_t, struct sockaddr *,
1031                 socklen_t *, struct sctp_sndrcvinfo *, int *));
1032
1033__END_DECLS
1034
1035#endif				/* !_KERNEL */
1036#endif				/* !__sctp_uio_h__ */
1037