summaryrefslogtreecommitdiffstats
path: root/sys/netinet/sctp_uio.h
blob: 89a81ccac9dbabb46e077ce51182e8dc92ae1ed1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
/*-
 * Copyright (c) 2001-2006, Cisco Systems, Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * a) Redistributions of source code must retain the above copyright notice,
 *   this list of conditions and the following disclaimer.
 *
 * b) Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *   the documentation and/or other materials provided with the distribution.
 *
 * c) Neither the name of Cisco Systems, Inc. nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */

/* $KAME: sctp_uio.h,v 1.11 2005/03/06 16:04:18 itojun Exp $	 */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");

#ifndef __sctp_uio_h__
#define __sctp_uio_h__




#if ! defined(_KERNEL)
#include <stdint.h>
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>

typedef uint32_t sctp_assoc_t;

/* On/Off setup for subscription to events */
struct sctp_event_subscribe {
	uint8_t sctp_data_io_event;
	uint8_t sctp_association_event;
	uint8_t sctp_address_event;
	uint8_t sctp_send_failure_event;
	uint8_t sctp_peer_error_event;
	uint8_t sctp_shutdown_event;
	uint8_t sctp_partial_delivery_event;
	uint8_t sctp_adaptation_layer_event;
	uint8_t sctp_authentication_event;
	uint8_t sctp_stream_reset_events;
};

/* ancillary data types */
#define SCTP_INIT	0x0001
#define SCTP_SNDRCV	0x0002
#define SCTP_EXTRCV	0x0003
/*
 * ancillary data structures
 */
struct sctp_initmsg {
	uint32_t sinit_num_ostreams;
	uint32_t sinit_max_instreams;
	uint16_t sinit_max_attempts;
	uint16_t sinit_max_init_timeo;
};

/* We add 96 bytes to the size of sctp_sndrcvinfo.
 * This makes the current structure 128 bytes long
 * which is nicely 64 bit aligned but also has room
 * for us to add more and keep ABI compatability.
 * For example, already we have the sctp_extrcvinfo
 * when enabled which is 48 bytes.
 */

/*
 * The assoc up needs a verfid
 * all sendrcvinfo's need a verfid for SENDING only.
 */


#define SCTP_ALIGN_RESV_PAD 96
#define SCTP_ALIGN_RESV_PAD_SHORT 80

struct sctp_sndrcvinfo {
	uint16_t sinfo_stream;
	uint16_t sinfo_ssn;
	uint16_t sinfo_flags;
	uint32_t sinfo_ppid;
	uint32_t sinfo_context;
	uint32_t sinfo_timetolive;
	uint32_t sinfo_tsn;
	uint32_t sinfo_cumtsn;
	sctp_assoc_t sinfo_assoc_id;
	uint8_t __reserve_pad[SCTP_ALIGN_RESV_PAD];
};

struct sctp_extrcvinfo {
	uint16_t sinfo_stream;
	uint16_t sinfo_ssn;
	uint16_t sinfo_flags;
	uint32_t sinfo_ppid;
	uint32_t sinfo_context;
	uint32_t sinfo_timetolive;
	uint32_t sinfo_tsn;
	uint32_t sinfo_cumtsn;
	sctp_assoc_t sinfo_assoc_id;
	uint16_t next_flags;
	uint16_t next_stream;
	uint32_t next_asocid;
	uint32_t next_length;
	uint32_t next_ppid;
	uint8_t __reserve_pad[SCTP_ALIGN_RESV_PAD_SHORT];
};

#define SCTP_NO_NEXT_MSG           0x0000
#define SCTP_NEXT_MSG_AVAIL        0x0001
#define SCTP_NEXT_MSG_ISCOMPLETE   0x0002
#define SCTP_NEXT_MSG_IS_UNORDERED 0x0004
#define SCTP_NEXT_MSG_IS_NOTIFICATION 0x0008

struct sctp_snd_all_completes {
	uint16_t sall_stream;
	uint16_t sall_flags;
	uint32_t sall_ppid;
	uint32_t sall_context;
	uint32_t sall_num_sent;
	uint32_t sall_num_failed;
};

/* Flags that go into the sinfo->sinfo_flags field */
#define SCTP_EOF 	  0x0100/* Start shutdown procedures */
#define SCTP_ABORT	  0x0200/* Send an ABORT to peer */
#define SCTP_UNORDERED 	  0x0400/* Message is un-ordered */
#define SCTP_ADDR_OVER	  0x0800/* Override the primary-address */
#define SCTP_SENDALL      0x1000/* Send this on all associations */
#define SCTP_EOR          0x2000/* end of message signal */
#define INVALID_SINFO_FLAG(x) (((x) & 0xffffff00 \
                                    & ~(SCTP_EOF | SCTP_ABORT | SCTP_UNORDERED |\
				        SCTP_ADDR_OVER | SCTP_SENDALL | SCTP_EOR)) != 0)
/* for the endpoint */

/* The lower byte is an enumeration of PR-SCTP policies */
#define SCTP_PR_SCTP_TTL  0x0001/* Time based PR-SCTP */
#define SCTP_PR_SCTP_BUF  0x0002/* Buffer based PR-SCTP */
#define SCTP_PR_SCTP_RTX  0x0003/* Number of retransmissions based PR-SCTP */

#define PR_SCTP_POLICY(x)         ((x) & 0xff)
#define PR_SCTP_ENABLED(x)        (PR_SCTP_POLICY(x) != 0)
#define PR_SCTP_TTL_ENABLED(x)    (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_TTL)
#define PR_SCTP_BUF_ENABLED(x)    (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_BUF)
#define PR_SCTP_RTX_ENABLED(x)    (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_RTX)
#define PR_SCTP_INVALID_POLICY(x) (PR_SCTP_POLICY(x) > SCTP_PR_SCTP_RTX)
/* Stat's */
struct sctp_pcbinfo {
	uint32_t ep_count;
	uint32_t asoc_count;
	uint32_t laddr_count;
	uint32_t raddr_count;
	uint32_t chk_count;
	uint32_t readq_count;
	uint32_t free_chunks;
	uint32_t stream_oque;
};

struct sctp_sockstat {
	sctp_assoc_t ss_assoc_id;
	uint32_t ss_total_sndbuf;
	uint32_t ss_total_recv_buf;
};

/*
 * notification event structures
 */

/*
 * association change event
 */
struct sctp_assoc_change {
	uint16_t sac_type;
	uint16_t sac_flags;
	uint32_t sac_length;
	uint16_t sac_state;
	uint16_t sac_error;
	uint16_t sac_outbound_streams;
	uint16_t sac_inbound_streams;
	sctp_assoc_t sac_assoc_id;
};

/* sac_state values */
#define SCTP_COMM_UP		0x0001
#define SCTP_COMM_LOST		0x0002
#define SCTP_RESTART		0x0003
#define SCTP_SHUTDOWN_COMP	0x0004
#define SCTP_CANT_STR_ASSOC	0x0005


/*
 * Address event
 */
struct sctp_paddr_change {
	uint16_t spc_type;
	uint16_t spc_flags;
	uint32_t spc_length;
	struct sockaddr_storage spc_aaddr;
	uint32_t spc_state;
	uint32_t spc_error;
	sctp_assoc_t spc_assoc_id;
};

/* paddr state values */
#define SCTP_ADDR_AVAILABLE	0x0001
#define SCTP_ADDR_UNREACHABLE	0x0002
#define SCTP_ADDR_REMOVED	0x0003
#define SCTP_ADDR_ADDED		0x0004
#define SCTP_ADDR_MADE_PRIM	0x0005
#define SCTP_ADDR_CONFIRMED	0x0006

/*
 * CAUTION: these are user exposed SCTP addr reachability states must be
 * compatible with SCTP_ADDR states in sctp_constants.h
 */
#ifdef SCTP_ACTIVE
#undef SCTP_ACTIVE
#endif
#define SCTP_ACTIVE		0x0001	/* SCTP_ADDR_REACHABLE */

#ifdef SCTP_INACTIVE
#undef SCTP_INACTIVE
#endif
#define SCTP_INACTIVE		0x0002	/* SCTP_ADDR_NOT_REACHABLE */

#ifdef SCTP_UNCONFIRMED
#undef SCTP_UNCONFIRMED
#endif
#define SCTP_UNCONFIRMED	0x0200	/* SCTP_ADDR_UNCONFIRMED */

#ifdef SCTP_NOHEARTBEAT
#undef SCTP_NOHEARTBEAT
#endif
#define SCTP_NOHEARTBEAT	0x0040	/* SCTP_ADDR_NOHB */


/* remote error events */
struct sctp_remote_error {
	uint16_t sre_type;
	uint16_t sre_flags;
	uint32_t sre_length;
	uint16_t sre_error;
	sctp_assoc_t sre_assoc_id;
	uint8_t sre_data[4];
};

/* data send failure event */
struct sctp_send_failed {
	uint16_t ssf_type;
	uint16_t ssf_flags;
	uint32_t ssf_length;
	uint32_t ssf_error;
	struct sctp_sndrcvinfo ssf_info;
	sctp_assoc_t ssf_assoc_id;
	uint8_t ssf_data[4];
};

/* flag that indicates state of data */
#define SCTP_DATA_UNSENT	0x0001	/* inqueue never on wire */
#define SCTP_DATA_SENT		0x0002	/* on wire at failure */

/* shutdown event */
struct sctp_shutdown_event {
	uint16_t sse_type;
	uint16_t sse_flags;
	uint32_t sse_length;
	sctp_assoc_t sse_assoc_id;
};

/* Adaptation layer indication stuff */
struct sctp_adaptation_event {
	uint16_t sai_type;
	uint16_t sai_flags;
	uint32_t sai_length;
	uint32_t sai_adaptation_ind;
	sctp_assoc_t sai_assoc_id;
};

struct sctp_setadaptation {
	uint32_t ssb_adaptation_ind;
};

/* compatable old spelling */
struct sctp_adaption_event {
	uint16_t sai_type;
	uint16_t sai_flags;
	uint32_t sai_length;
	uint32_t sai_adaption_ind;
	sctp_assoc_t sai_assoc_id;
};

struct sctp_setadaption {
	uint32_t ssb_adaption_ind;
};


/*
 * Partial Delivery API event
 */
struct sctp_pdapi_event {
	uint16_t pdapi_type;
	uint16_t pdapi_flags;
	uint32_t pdapi_length;
	uint32_t pdapi_indication;
	sctp_assoc_t pdapi_assoc_id;
};

/* indication values */
#define SCTP_PARTIAL_DELIVERY_ABORTED	0x0001


/*
 * authentication key event
 */
struct sctp_authkey_event {
	uint16_t auth_type;
	uint16_t auth_flags;
	uint32_t auth_length;
	uint16_t auth_keynumber;
	uint16_t auth_altkeynumber;
	uint32_t auth_indication;
	sctp_assoc_t auth_assoc_id;
};

/* indication values */
#define SCTP_AUTH_NEWKEY	0x0001


/*
 * stream reset event
 */
struct sctp_stream_reset_event {
	uint16_t strreset_type;
	uint16_t strreset_flags;
	uint32_t strreset_length;
	sctp_assoc_t strreset_assoc_id;
	uint16_t strreset_list[0];
};

/* flags in strreset_flags field */
#define SCTP_STRRESET_INBOUND_STR  0x0001
#define SCTP_STRRESET_OUTBOUND_STR 0x0002
#define SCTP_STRRESET_ALL_STREAMS  0x0004
#define SCTP_STRRESET_STREAM_LIST  0x0008
#define SCTP_STRRESET_FAILED       0x0010


/* SCTP notification event */
struct sctp_tlv {
	uint16_t sn_type;
	uint16_t sn_flags;
	uint32_t sn_length;
};

union sctp_notification {
	struct sctp_tlv sn_header;
	struct sctp_assoc_change sn_assoc_change;
	struct sctp_paddr_change sn_paddr_change;
	struct sctp_remote_error sn_remote_error;
	struct sctp_send_failed sn_send_failed;
	struct sctp_shutdown_event sn_shutdown_event;
	struct sctp_adaptation_event sn_adaptation_event;
	/* compatability same as above */
	struct sctp_adaption_event sn_adaption_event;
	struct sctp_pdapi_event sn_pdapi_event;
	struct sctp_authkey_event sn_auth_event;
	struct sctp_stream_reset_event sn_strreset_event;
};

/* notification types */
#define SCTP_ASSOC_CHANGE		0x0001
#define SCTP_PEER_ADDR_CHANGE		0x0002
#define SCTP_REMOTE_ERROR		0x0003
#define SCTP_SEND_FAILED		0x0004
#define SCTP_SHUTDOWN_EVENT		0x0005
#define SCTP_ADAPTATION_INDICATION	0x0006
/* same as above */
#define SCTP_ADAPTION_INDICATION	0x0006
#define SCTP_PARTIAL_DELIVERY_EVENT	0x0007
#define SCTP_AUTHENTICATION_EVENT	0x0008
#define SCTP_STREAM_RESET_EVENT		0x0009


/*
 * socket option structs
 */

struct sctp_paddrparams {
	sctp_assoc_t spp_assoc_id;
	struct sockaddr_storage spp_address;
	uint32_t spp_hbinterval;
	uint16_t spp_pathmaxrxt;
	uint32_t spp_pathmtu;
	uint32_t spp_sackdelay;
	uint32_t spp_flags;
	uint32_t spp_ipv6_flowlabel;
	uint8_t spp_ipv4_tos;

};

#define SPP_HB_ENABLE		0x00000001
#define SPP_HB_DISABLE		0x00000002
#define SPP_HB_DEMAND		0x00000004
#define SPP_PMTUD_ENABLE	0x00000008
#define SPP_PMTUD_DISABLE	0x00000010
#define SPP_SACKDELAY_ENABLE	0x00000020
#define SPP_SACKDELAY_DISABLE	0x00000040
#define SPP_HB_TIME_IS_ZERO     0x00000080
#define SPP_IPV6_FLOWLABEL      0x00000100
#define SPP_IPV4_TOS            0x00000200

struct sctp_paddrinfo {
	sctp_assoc_t spinfo_assoc_id;
	struct sockaddr_storage spinfo_address;
	int32_t spinfo_state;
	uint32_t spinfo_cwnd;
	uint32_t spinfo_srtt;
	uint32_t spinfo_rto;
	uint32_t spinfo_mtu;
};

struct sctp_rtoinfo {
	sctp_assoc_t srto_assoc_id;
	uint32_t srto_initial;
	uint32_t srto_max;
	uint32_t srto_min;
};

struct sctp_assocparams {
	sctp_assoc_t sasoc_assoc_id;
	uint16_t sasoc_asocmaxrxt;
	uint16_t sasoc_number_peer_destinations;
	uint32_t sasoc_peer_rwnd;
	uint32_t sasoc_local_rwnd;
	uint32_t sasoc_cookie_life;
};

struct sctp_setprim {
	sctp_assoc_t ssp_assoc_id;
	struct sockaddr_storage ssp_addr;
};

struct sctp_setpeerprim {
	sctp_assoc_t sspp_assoc_id;
	struct sockaddr_storage sspp_addr;
};

struct sctp_getaddresses {
	sctp_assoc_t sget_assoc_id;
	/* addr is filled in for N * sockaddr_storage */
	struct sockaddr addr[1];
};

struct sctp_setstrm_timeout {
	sctp_assoc_t ssto_assoc_id;
	uint32_t ssto_timeout;
	uint32_t ssto_streamid_start;
	uint32_t ssto_streamid_end;
};

struct sctp_status {
	sctp_assoc_t sstat_assoc_id;
	int32_t sstat_state;
	uint32_t sstat_rwnd;
	uint16_t sstat_unackdata;
	uint16_t sstat_penddata;
	uint16_t sstat_instrms;
	uint16_t sstat_outstrms;
	uint32_t sstat_fragmentation_point;
	struct sctp_paddrinfo sstat_primary;
};

/*
 * AUTHENTICATION support
 */
/* SCTP_AUTH_CHUNK */
struct sctp_authchunk {
	uint8_t sauth_chunk;
};

/* SCTP_AUTH_KEY */
struct sctp_authkey {
	sctp_assoc_t sca_assoc_id;
	uint16_t sca_keynumber;
	uint8_t sca_key[0];
};

/* SCTP_HMAC_IDENT */
struct sctp_hmacalgo {
	uint16_t shmac_idents[0];
};

/* AUTH hmac_id */
#define SCTP_AUTH_HMAC_ID_RSVD		0x0000
#define SCTP_AUTH_HMAC_ID_SHA1		0x0001	/* default, mandatory */
#define SCTP_AUTH_HMAC_ID_MD5		0x0002	/* deprecated */
#define SCTP_AUTH_HMAC_ID_SHA256	0x0003
#define SCTP_AUTH_HMAC_ID_SHA224	0x8001
#define SCTP_AUTH_HMAC_ID_SHA384	0x8002
#define SCTP_AUTH_HMAC_ID_SHA512	0x8003


/* SCTP_AUTH_ACTIVE_KEY / SCTP_AUTH_DELETE_KEY */
struct sctp_authkeyid {
	sctp_assoc_t scact_assoc_id;
	uint16_t scact_keynumber;
};

/* SCTP_PEER_AUTH_CHUNKS / SCTP_LOCAL_AUTH_CHUNKS */
struct sctp_authchunks {
	sctp_assoc_t gauth_assoc_id;
	uint8_t gauth_chunks[0];
};

struct sctp_assoc_value {
	sctp_assoc_t assoc_id;
	uint32_t assoc_value;
};

#define MAX_ASOC_IDS_RET 255
struct sctp_assoc_ids {
	uint16_t asls_assoc_start;	/* array of index's start at 0 */
	uint8_t asls_numb_present;
	uint8_t asls_more_to_get;
	sctp_assoc_t asls_assoc_id[MAX_ASOC_IDS_RET];
};

struct sctp_cwnd_args {
	struct sctp_nets *net;	/* network to */
	uint32_t cwnd_new_value;/* cwnd in k */
	uint32_t inflight;	/* flightsize in k */
	uint32_t pseudo_cumack;
	int cwnd_augment;	/* increment to it */
	uint8_t meets_pseudo_cumack;
	uint8_t need_new_pseudo_cumack;
	uint8_t cnt_in_send;
	uint8_t cnt_in_str;
};

struct sctp_blk_args {
	uint32_t onsb;		/* in 1k bytes */
	uint32_t sndlen;	/* len of send being attempted */
	uint32_t peer_rwnd;	/* rwnd of peer */
	uint16_t send_sent_qcnt;/* chnk cnt */
	uint16_t stream_qcnt;	/* chnk cnt */
	uint16_t chunks_on_oque;/* chunks out */
	uint16_t flight_size;	/* flight size in k */
};

/*
 * Max we can reset in one setting, note this is dictated not by the define
 * but the size of a mbuf cluster so don't change this define and think you
 * can specify more. You must do multiple resets if you want to reset more
 * than SCTP_MAX_EXPLICIT_STR_RESET.
 */
#define SCTP_MAX_EXPLICT_STR_RESET   1000

#define SCTP_RESET_LOCAL_RECV  0x0001
#define SCTP_RESET_LOCAL_SEND  0x0002
#define SCTP_RESET_BOTH        0x0003
#define SCTP_RESET_TSN         0x0004

struct sctp_stream_reset {
	sctp_assoc_t strrst_assoc_id;
	uint16_t strrst_flags;
	uint16_t strrst_num_streams;	/* 0 == ALL */
	uint16_t strrst_list[0];/* list if strrst_num_streams is not 0 */
};


struct sctp_get_nonce_values {
	sctp_assoc_t gn_assoc_id;
	uint32_t gn_peers_tag;
	uint32_t gn_local_tag;
};

/* Debugging logs */
struct sctp_str_log {
	void *stcb;
	uint32_t n_tsn;
	uint32_t e_tsn;
	uint16_t n_sseq;
	uint16_t e_sseq;
	uint16_t strm;
};

struct sctp_sb_log {
	void *stcb;
	uint32_t so_sbcc;
	uint32_t stcb_sbcc;
	uint32_t incr;
};

struct sctp_fr_log {
	uint32_t largest_tsn;
	uint32_t largest_new_tsn;
	uint32_t tsn;
};

struct sctp_fr_map {
	uint32_t base;
	uint32_t cum;
	uint32_t high;
};

struct sctp_rwnd_log {
	uint32_t rwnd;
	uint32_t send_size;
	uint32_t overhead;
	uint32_t new_rwnd;
};

struct sctp_mbcnt_log {
	uint32_t total_queue_size;
	uint32_t size_change;
	uint32_t total_queue_mb_size;
	uint32_t mbcnt_change;
};

struct sctp_sack_log {
	uint32_t cumack;
	uint32_t oldcumack;
	uint32_t tsn;
	uint16_t numGaps;
	uint16_t numDups;
};

struct sctp_lock_log {
	void *sock;
	void *inp;
	uint8_t tcb_lock;
	uint8_t inp_lock;
	uint8_t info_lock;
	uint8_t sock_lock;
	uint8_t sockrcvbuf_lock;
	uint8_t socksndbuf_lock;
	uint8_t create_lock;
	uint8_t resv;
};

struct sctp_rto_log {
	void *net;
	uint32_t rtt;
	uint32_t rttvar;
	uint8_t direction;
};

struct sctp_nagle_log {
	void *stcb;
	uint32_t total_flight;
	uint32_t total_in_queue;
	uint16_t count_in_queue;
	uint16_t count_in_flight;
};

struct sctp_sbwake_log {
	void *stcb;
	uint16_t send_q;
	uint16_t sent_q;
	uint16_t flight;
	uint16_t wake_cnt;
	uint8_t stream_qcnt;	/* chnk cnt */
	uint8_t chunks_on_oque;	/* chunks out */
	uint8_t sbflags;
	uint8_t sctpflags;
};

struct sctp_misc_info {
	uint32_t log1;
	uint32_t log2;
	uint32_t log3;
	uint32_t log4;
};

struct sctp_log_closing {
	void *inp;
	void *stcb;
	uint32_t sctp_flags;
	uint16_t state;
	int16_t loc;
};

struct sctp_mbuf_log {
	struct mbuf *mp;
	caddr_t ext;
	caddr_t data;
	uint16_t size;
	uint8_t refcnt;
	uint8_t mbuf_flags;
};

struct sctp_cwnd_log {
	uint32_t time_event;
	uint8_t from;
	uint8_t event_type;
	uint8_t resv[2];
	union {
		struct sctp_log_closing close;
		struct sctp_blk_args blk;
		struct sctp_cwnd_args cwnd;
		struct sctp_str_log strlog;
		struct sctp_fr_log fr;
		struct sctp_fr_map map;
		struct sctp_rwnd_log rwnd;
		struct sctp_mbcnt_log mbcnt;
		struct sctp_sack_log sack;
		struct sctp_lock_log lock;
		struct sctp_rto_log rto;
		struct sctp_sb_log sb;
		struct sctp_nagle_log nagle;
		struct sctp_sbwake_log wake;
		struct sctp_mbuf_log mb;
		struct sctp_misc_info misc;
	}     x;
};

struct sctp_cwnd_log_req {
	int num_in_log;		/* Number in log */
	int num_ret;		/* Number returned */
	int start_at;		/* start at this one */
	int end_at;		/* end at this one */
	struct sctp_cwnd_log log[0];
};

struct sctpstat {
	/* MIB according to RFC 3873 */
	u_long sctps_currestab;	/* sctpStats  1   (Gauge32) */
	u_long sctps_activeestab;	/* sctpStats  2 (Counter32) */
	u_long sctps_restartestab;
	u_long sctps_collisionestab;
	u_long sctps_passiveestab;	/* sctpStats  3 (Counter32) */
	u_long sctps_aborted;	/* sctpStats  4 (Counter32) */
	u_long sctps_shutdown;	/* sctpStats  5 (Counter32) */
	u_long sctps_outoftheblue;	/* sctpStats  6 (Counter32) */
	u_long sctps_checksumerrors;	/* sctpStats  7 (Counter32) */
	u_long sctps_outcontrolchunks;	/* sctpStats  8 (Counter64) */
	u_long sctps_outorderchunks;	/* sctpStats  9 (Counter64) */
	u_long sctps_outunorderchunks;	/* sctpStats 10 (Counter64) */
	u_long sctps_incontrolchunks;	/* sctpStats 11 (Counter64) */
	u_long sctps_inorderchunks;	/* sctpStats 12 (Counter64) */
	u_long sctps_inunorderchunks;	/* sctpStats 13 (Counter64) */
	u_long sctps_fragusrmsgs;	/* sctpStats 14 (Counter64) */
	u_long sctps_reasmusrmsgs;	/* sctpStats 15 (Counter64) */
	u_long sctps_outpackets;/* sctpStats 16 (Counter64) */
	u_long sctps_inpackets;	/* sctpStats 17 (Counter64) */
	struct timeval sctps_discontinuitytime;	/* sctpStats 18 (TimeStamp) */
	/* input statistics: */
	u_long sctps_recvpackets;	/* total input packets        */
	u_long sctps_recvdatagrams;	/* total input datagrams      */
	u_long sctps_recvpktwithdata;
	u_long sctps_recvsacks;	/* total input SACK chunks    */
	u_long sctps_recvdata;	/* total input DATA chunks    */
	u_long sctps_recvdupdata;	/* total input duplicate DATA chunks */
	u_long sctps_recvheartbeat;	/* total input HB chunks      */
	u_long sctps_recvheartbeatack;	/* total input HB-ACK chunks  */
	u_long sctps_recvecne;	/* total input ECNE chunks    */
	u_long sctps_recvauth;	/* total input AUTH chunks    */
	u_long sctps_recvauthmissing;	/* total input chunks missing AUTH */
	u_long sctps_recvivalhmacid;	/* total number of invalid HMAC ids
					 * received */
	u_long sctps_recvivalkeyid;	/* total number of invalid secret ids
					 * received */
	u_long sctps_recvauthfailed;	/* total number of auth failed */
	u_long sctps_recvexpress;	/* total fast path receives all one
					 * chunk */
	u_long sctps_recvexpressm;	/* total fast path multi-part data */
	/* output statistics: */
	u_long sctps_sendpackets;	/* total output packets       */
	u_long sctps_sendsacks;	/* total output SACKs         */
	u_long sctps_senddata;	/* total output DATA chunks   */
	u_long sctps_sendretransdata;	/* total output retransmitted DATA
					 * chunks */
	u_long sctps_sendfastretrans;	/* total output fast retransmitted
					 * DATA chunks */
	u_long sctps_sendmultfastretrans;	/* U-del */
	u_long sctps_sendheartbeat;	/* total output HB chunks     */
	u_long sctps_sendecne;	/* total output ECNE chunks    */
	u_long sctps_sendauth;	/* total output AUTH chunks FIXME   */
	u_long sctps_senderrors;/* ip_output error counter */
	/* PCKDROPREP statistics: */
	u_long sctps_pdrpfmbox;	/* */
	u_long sctps_pdrpfehos;	/* */
	u_long sctps_pdrpmbda;	/* */
	u_long sctps_pdrpmbct;	/* */
	u_long sctps_pdrpbwrpt;	/* */
	u_long sctps_pdrpcrupt;	/* */
	u_long sctps_pdrpnedat;	/* */
	u_long sctps_pdrppdbrk;	/* */
	u_long sctps_pdrptsnnf;	/* */
	u_long sctps_pdrpdnfnd;	/* */
	u_long sctps_pdrpdiwnp;	/* */
	u_long sctps_pdrpdizrw;	/* */
	u_long sctps_pdrpbadd;	/* */
	u_long sctps_pdrpmark;	/* */
	/* timeouts */
	u_long sctps_timoiterator;	/* */
	u_long sctps_timodata;	/* */
	u_long sctps_timowindowprobe;	/* */
	u_long sctps_timoinit;	/* */
	u_long sctps_timosack;	/* */
	u_long sctps_timoshutdown;	/* */
	u_long sctps_timoheartbeat;	/* */
	u_long sctps_timocookie;/* */
	u_long sctps_timosecret;/* */
	u_long sctps_timopathmtu;	/* */
	u_long sctps_timoshutdownack;	/* */
	u_long sctps_timoshutdownguard;	/* */
	u_long sctps_timostrmrst;	/* */
	u_long sctps_timoearlyfr;	/* */
	u_long sctps_timoasconf;/* */
	u_long sctps_timoautoclose;	/* */
	u_long sctps_timoassockill;	/* */
	u_long sctps_timoinpkill;	/* */
	/* Early fast retransmission counters */
	u_long sctps_earlyfrstart;
	u_long sctps_earlyfrstop;
	u_long sctps_earlyfrmrkretrans;
	u_long sctps_earlyfrstpout;
	u_long sctps_earlyfrstpidsck1;
	u_long sctps_earlyfrstpidsck2;
	u_long sctps_earlyfrstpidsck3;
	u_long sctps_earlyfrstpidsck4;
	u_long sctps_earlyfrstrid;
	u_long sctps_earlyfrstrout;
	u_long sctps_earlyfrstrtmr;
	/* otheres */
	u_long sctps_hdrops;	/* packet shorter than header */
	u_long sctps_badsum;	/* checksum error             */
	u_long sctps_noport;	/* no endpoint for port       */
	u_long sctps_badvtag;	/* bad v-tag                  */
	u_long sctps_badsid;	/* bad SID                    */
	u_long sctps_nomem;	/* no memory                  */
	u_long sctps_fastretransinrtt;	/* number of multiple FR in a RTT
					 * window */
	u_long sctps_markedretrans;
	u_long sctps_naglesent;	/* nagle allowed sending      */
	u_long sctps_naglequeued;	/* nagle does't allow sending */
	u_long sctps_maxburstqueued;	/* max burst dosn't allow sending */
	u_long sctps_ifnomemqueued;	/* */
	u_long sctps_windowprobed;	/* total number of window probes sent */
	u_long sctps_lowlevelerr;
	u_long sctps_lowlevelerrusr;
	u_long sctps_datadropchklmt;
	u_long sctps_datadroprwnd;
	u_long sctps_ecnereducedcwnd;
	u_long sctps_vtagexpress;	/* Used express lookup via vtag */
	u_long sctps_vtagbogus;	/* Collision in express lookup. */
	u_long sctps_primary_randry;	/* Number of times the sender ran dry
					 * of user data on primary */
	u_long sctps_cmt_randry;/* Same for above */
	u_long sctps_slowpath_sack;	/* Sacks the slow way */
	u_long sctps_wu_sacks_sent;	/* Window Update only sacks sent */
	u_long sctps_sends_with_flags;	/* number of sends with sinfo_flags
					 * !=0 */
	u_long sctps_sends_with_unord;
	u_long sctps_sends_with_eof;
	u_long sctps_sends_with_abort;
	u_long sctps_protocol_drain_calls;
	u_long sctps_protocol_drains_done;
};

#define SCTP_STAT_INCR(_x) SCTP_STAT_INCR_BY(_x,1)
#define SCTP_STAT_DECR(_x) SCTP_STAT_DECR_BY(_x,1)
#define SCTP_STAT_INCR_BY(_x,_d) atomic_add_long(&sctpstat._x, _d)
#define SCTP_STAT_DECR_BY(_x,_d) atomic_add_long(&sctpstat._x, -(_d))
/* The following macros are for handling MIB values, */
#define SCTP_STAT_INCR_COUNTER32(_x) SCTP_STAT_INCR(_x)
#define SCTP_STAT_INCR_COUNTER64(_x) SCTP_STAT_INCR(_x)
#define SCTP_STAT_INCR_GAUGE32(_x) SCTP_STAT_INCR(_x)
#define SCTP_STAT_DECR_COUNTER32(_x) SCTP_STAT_DECR(_x)
#define SCTP_STAT_DECR_COUNTER64(_x) SCTP_STAT_DECR(_x)
#define SCTP_STAT_DECR_GAUGE32(_x) SCTP_STAT_DECR(_x)

union sctp_sockstore {
#ifdef AF_INET
	struct sockaddr_in sin;
#endif
#ifdef AF_INET6
	struct sockaddr_in6 sin6;
#endif
	struct sockaddr sa;
};

struct xsctp_inpcb {
	uint32_t last;
	uint16_t local_port;
	uint16_t number_local_addresses;
	uint32_t number_associations;
	uint32_t flags;
	uint32_t features;
	uint32_t total_sends;
	uint32_t total_recvs;
	uint32_t total_nospaces;
	/* add more endpoint specific data here */
};

struct xsctp_tcb {
	uint16_t LocalPort;	/* sctpAssocEntry 3   */
	uint16_t RemPort;	/* sctpAssocEntry 4   */
	union sctp_sockstore RemPrimAddr;	/* sctpAssocEntry 5/6 */
	uint32_t HeartBeatInterval;	/* sctpAssocEntry 7   */
	uint32_t State;		/* sctpAssocEntry 8   */
	uint32_t InStreams;	/* sctpAssocEntry 9   */
	uint32_t OutStreams;	/* sctpAssocEntry 10  */
	uint32_t MaxRetr;	/* sctpAssocEntry 11  */
	uint32_t PrimProcess;	/* sctpAssocEntry 12  */
	uint32_t T1expireds;	/* sctpAssocEntry 13  */
	uint32_t T2expireds;	/* sctpAssocEntry 14  */
	uint32_t RtxChunks;	/* sctpAssocEntry 15  */
	struct timeval StartTime;	/* sctpAssocEntry 16  */
	struct timeval DiscontinuityTime;	/* sctpAssocEntry 17  */
	uint32_t total_sends;
	uint32_t total_recvs;
	uint32_t local_tag;
	uint32_t remote_tag;
	uint32_t initial_tsn;
	uint32_t highest_tsn;
	uint32_t cumulative_tsn;
	uint32_t cumulative_tsn_ack;
	/* add more association specific data here */
	uint16_t number_local_addresses;
	uint16_t number_remote_addresses;
};

struct xsctp_laddr {
	union sctp_sockstore LocalAddr;	/* sctpAssocLocalAddrEntry 1/2 */
	struct timeval LocalStartTime;	/* sctpAssocLocalAddrEntry 3   */
	/* add more local address specific data */
};

struct xsctp_raddr {
	union sctp_sockstore RemAddr;	/* sctpAssocLocalRemEntry 1/2 */
	uint8_t RemAddrActive;	/* sctpAssocLocalRemEntry 3   */
	uint8_t RemAddrConfirmed;	/* */
	uint8_t RemAddrHBActive;/* sctpAssocLocalRemEntry 4   */
	uint32_t RemAddrRTO;	/* sctpAssocLocalRemEntry 5   */
	uint32_t RemAddrMaxPathRtx;	/* sctpAssocLocalRemEntry 6   */
	uint32_t RemAddrRtx;	/* sctpAssocLocalRemEntry 7   */
	uint32_t RemAddrErrorCounter;	/* */
	uint32_t RemAddrCwnd;	/* */
	uint32_t RemAddrFlightSize;	/* */
	struct timeval RemAddrStartTime;	/* sctpAssocLocalRemEntry 8   */
	/* add more remote address specific data */
};

/*
 * Kernel defined for sctp_send
 */
#if defined(_KERNEL)
int
sctp_lower_sosend(struct socket *so,
    struct sockaddr *addr,
    struct uio *uio,
    struct mbuf *top,
    struct mbuf *control,
    int flags,
    int use_rcvinfo,
    struct sctp_sndrcvinfo *srcv,
    struct thread *p
);

int
sctp_sorecvmsg(struct socket *so,
    struct uio *uio,
    struct mbuf **mp,
    struct sockaddr *from,
    int fromlen,
    int *msg_flags,
    struct sctp_sndrcvinfo *sinfo,
    int filling_sinfo);


#endif

/*
 * API system calls
 */

#if !(defined(_KERNEL))

__BEGIN_DECLS
int sctp_peeloff __P((int, sctp_assoc_t));
int sctp_bindx __P((int, struct sockaddr *, int, int));
int sctp_connectx __P((int, const struct sockaddr *, int));
int sctp_getaddrlen __P((sa_family_t));
int sctp_getpaddrs __P((int, sctp_assoc_t, struct sockaddr **));
void sctp_freepaddrs __P((struct sockaddr *));
int sctp_getladdrs __P((int, sctp_assoc_t, struct sockaddr **));
void sctp_freeladdrs __P((struct sockaddr *));
int sctp_opt_info __P((int, sctp_assoc_t, int, void *, socklen_t *));

ssize_t sctp_sendmsg
__P((int, const void *, size_t,
    const struct sockaddr *,
    socklen_t, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t));

	ssize_t sctp_send __P((int sd, const void *msg, size_t len,
              const struct sctp_sndrcvinfo *sinfo, int flags));

	ssize_t
	sctp_sendx __P((int sd, const void *msg, size_t len,
               struct sockaddr *addrs, int addrcnt,
               struct sctp_sndrcvinfo *sinfo, int flags));
	ssize_t
	sctp_sendmsgx __P((int sd, const void *, size_t,
                  struct sockaddr *, int,
                  uint32_t, uint32_t, uint16_t, uint32_t, uint32_t));

sctp_assoc_t
sctp_getassocid __P((int sd, struct sockaddr *sa));

	ssize_t sctp_recvmsg __P((int, void *, size_t, struct sockaddr *,
                 socklen_t *, struct sctp_sndrcvinfo *, int *));

__END_DECLS

#endif				/* !_KERNEL */
#endif				/* !__sctp_uio_h__ */
OpenPOWER on IntegriCloud