0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 #ifndef __LINUX_SCTP_H__
0036 #define __LINUX_SCTP_H__
0037
0038 #include <linux/in.h> /* We need in_addr. */
0039 #include <linux/in6.h> /* We need in6_addr. */
0040 #include <linux/skbuff.h>
0041
0042 #include <uapi/linux/sctp.h>
0043
0044
0045 struct sctphdr {
0046 __be16 source;
0047 __be16 dest;
0048 __be32 vtag;
0049 __le32 checksum;
0050 };
0051
0052 static inline struct sctphdr *sctp_hdr(const struct sk_buff *skb)
0053 {
0054 return (struct sctphdr *)skb_transport_header(skb);
0055 }
0056
0057
0058 struct sctp_chunkhdr {
0059 __u8 type;
0060 __u8 flags;
0061 __be16 length;
0062 };
0063
0064
0065
0066
0067
0068
0069
0070 enum sctp_cid {
0071 SCTP_CID_DATA = 0,
0072 SCTP_CID_INIT = 1,
0073 SCTP_CID_INIT_ACK = 2,
0074 SCTP_CID_SACK = 3,
0075 SCTP_CID_HEARTBEAT = 4,
0076 SCTP_CID_HEARTBEAT_ACK = 5,
0077 SCTP_CID_ABORT = 6,
0078 SCTP_CID_SHUTDOWN = 7,
0079 SCTP_CID_SHUTDOWN_ACK = 8,
0080 SCTP_CID_ERROR = 9,
0081 SCTP_CID_COOKIE_ECHO = 10,
0082 SCTP_CID_COOKIE_ACK = 11,
0083 SCTP_CID_ECN_ECNE = 12,
0084 SCTP_CID_ECN_CWR = 13,
0085 SCTP_CID_SHUTDOWN_COMPLETE = 14,
0086
0087
0088 SCTP_CID_AUTH = 0x0F,
0089
0090
0091 SCTP_CID_I_DATA = 0x40,
0092
0093
0094 SCTP_CID_FWD_TSN = 0xC0,
0095
0096
0097 SCTP_CID_ASCONF = 0xC1,
0098 SCTP_CID_I_FWD_TSN = 0xC2,
0099 SCTP_CID_ASCONF_ACK = 0x80,
0100 SCTP_CID_RECONF = 0x82,
0101 SCTP_CID_PAD = 0x84,
0102 };
0103
0104
0105
0106
0107
0108
0109
0110 enum {
0111 SCTP_CID_ACTION_DISCARD = 0x00,
0112 SCTP_CID_ACTION_DISCARD_ERR = 0x40,
0113 SCTP_CID_ACTION_SKIP = 0x80,
0114 SCTP_CID_ACTION_SKIP_ERR = 0xc0,
0115 };
0116
0117 enum { SCTP_CID_ACTION_MASK = 0xc0, };
0118
0119
0120
0121
0122
0123
0124
0125 enum { SCTP_CHUNK_FLAG_T = 0x01 };
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149 #define sctp_test_T_bit(c) ((c)->chunk_hdr->flags & SCTP_CHUNK_FLAG_T)
0150
0151
0152
0153
0154
0155 struct sctp_paramhdr {
0156 __be16 type;
0157 __be16 length;
0158 };
0159
0160 enum sctp_param {
0161
0162
0163 SCTP_PARAM_HEARTBEAT_INFO = cpu_to_be16(1),
0164
0165 SCTP_PARAM_IPV4_ADDRESS = cpu_to_be16(5),
0166 SCTP_PARAM_IPV6_ADDRESS = cpu_to_be16(6),
0167 SCTP_PARAM_STATE_COOKIE = cpu_to_be16(7),
0168 SCTP_PARAM_UNRECOGNIZED_PARAMETERS = cpu_to_be16(8),
0169 SCTP_PARAM_COOKIE_PRESERVATIVE = cpu_to_be16(9),
0170 SCTP_PARAM_HOST_NAME_ADDRESS = cpu_to_be16(11),
0171 SCTP_PARAM_SUPPORTED_ADDRESS_TYPES = cpu_to_be16(12),
0172 SCTP_PARAM_ECN_CAPABLE = cpu_to_be16(0x8000),
0173
0174
0175 SCTP_PARAM_RANDOM = cpu_to_be16(0x8002),
0176 SCTP_PARAM_CHUNKS = cpu_to_be16(0x8003),
0177 SCTP_PARAM_HMAC_ALGO = cpu_to_be16(0x8004),
0178
0179
0180 SCTP_PARAM_SUPPORTED_EXT = cpu_to_be16(0x8008),
0181
0182
0183 SCTP_PARAM_FWD_TSN_SUPPORT = cpu_to_be16(0xc000),
0184
0185
0186 SCTP_PARAM_ADD_IP = cpu_to_be16(0xc001),
0187 SCTP_PARAM_DEL_IP = cpu_to_be16(0xc002),
0188 SCTP_PARAM_ERR_CAUSE = cpu_to_be16(0xc003),
0189 SCTP_PARAM_SET_PRIMARY = cpu_to_be16(0xc004),
0190 SCTP_PARAM_SUCCESS_REPORT = cpu_to_be16(0xc005),
0191 SCTP_PARAM_ADAPTATION_LAYER_IND = cpu_to_be16(0xc006),
0192
0193
0194 SCTP_PARAM_RESET_OUT_REQUEST = cpu_to_be16(0x000d),
0195 SCTP_PARAM_RESET_IN_REQUEST = cpu_to_be16(0x000e),
0196 SCTP_PARAM_RESET_TSN_REQUEST = cpu_to_be16(0x000f),
0197 SCTP_PARAM_RESET_RESPONSE = cpu_to_be16(0x0010),
0198 SCTP_PARAM_RESET_ADD_OUT_STREAMS = cpu_to_be16(0x0011),
0199 SCTP_PARAM_RESET_ADD_IN_STREAMS = cpu_to_be16(0x0012),
0200 };
0201
0202
0203
0204
0205
0206
0207
0208
0209 enum {
0210 SCTP_PARAM_ACTION_DISCARD = cpu_to_be16(0x0000),
0211 SCTP_PARAM_ACTION_DISCARD_ERR = cpu_to_be16(0x4000),
0212 SCTP_PARAM_ACTION_SKIP = cpu_to_be16(0x8000),
0213 SCTP_PARAM_ACTION_SKIP_ERR = cpu_to_be16(0xc000),
0214 };
0215
0216 enum { SCTP_PARAM_ACTION_MASK = cpu_to_be16(0xc000), };
0217
0218
0219
0220 struct sctp_datahdr {
0221 __be32 tsn;
0222 __be16 stream;
0223 __be16 ssn;
0224 __u32 ppid;
0225 __u8 payload[];
0226 };
0227
0228 struct sctp_data_chunk {
0229 struct sctp_chunkhdr chunk_hdr;
0230 struct sctp_datahdr data_hdr;
0231 };
0232
0233 struct sctp_idatahdr {
0234 __be32 tsn;
0235 __be16 stream;
0236 __be16 reserved;
0237 __be32 mid;
0238 union {
0239 __u32 ppid;
0240 __be32 fsn;
0241 };
0242 __u8 payload[0];
0243 };
0244
0245 struct sctp_idata_chunk {
0246 struct sctp_chunkhdr chunk_hdr;
0247 struct sctp_idatahdr data_hdr;
0248 };
0249
0250
0251 enum {
0252 SCTP_DATA_MIDDLE_FRAG = 0x00,
0253 SCTP_DATA_LAST_FRAG = 0x01,
0254 SCTP_DATA_FIRST_FRAG = 0x02,
0255 SCTP_DATA_NOT_FRAG = 0x03,
0256 SCTP_DATA_UNORDERED = 0x04,
0257 SCTP_DATA_SACK_IMM = 0x08,
0258 };
0259 enum { SCTP_DATA_FRAG_MASK = 0x03, };
0260
0261
0262
0263
0264
0265
0266
0267 struct sctp_inithdr {
0268 __be32 init_tag;
0269 __be32 a_rwnd;
0270 __be16 num_outbound_streams;
0271 __be16 num_inbound_streams;
0272 __be32 initial_tsn;
0273 __u8 params[];
0274 };
0275
0276 struct sctp_init_chunk {
0277 struct sctp_chunkhdr chunk_hdr;
0278 struct sctp_inithdr init_hdr;
0279 };
0280
0281
0282
0283 struct sctp_ipv4addr_param {
0284 struct sctp_paramhdr param_hdr;
0285 struct in_addr addr;
0286 };
0287
0288
0289 struct sctp_ipv6addr_param {
0290 struct sctp_paramhdr param_hdr;
0291 struct in6_addr addr;
0292 };
0293
0294
0295 struct sctp_cookie_preserve_param {
0296 struct sctp_paramhdr param_hdr;
0297 __be32 lifespan_increment;
0298 };
0299
0300
0301 struct sctp_hostname_param {
0302 struct sctp_paramhdr param_hdr;
0303 uint8_t hostname[];
0304 };
0305
0306
0307 struct sctp_supported_addrs_param {
0308 struct sctp_paramhdr param_hdr;
0309 __be16 types[];
0310 };
0311
0312
0313 struct sctp_adaptation_ind_param {
0314 struct sctp_paramhdr param_hdr;
0315 __be32 adaptation_ind;
0316 };
0317
0318
0319 struct sctp_supported_ext_param {
0320 struct sctp_paramhdr param_hdr;
0321 __u8 chunks[];
0322 };
0323
0324
0325 struct sctp_random_param {
0326 struct sctp_paramhdr param_hdr;
0327 __u8 random_val[];
0328 };
0329
0330
0331 struct sctp_chunks_param {
0332 struct sctp_paramhdr param_hdr;
0333 __u8 chunks[];
0334 };
0335
0336
0337 struct sctp_hmac_algo_param {
0338 struct sctp_paramhdr param_hdr;
0339 __be16 hmac_ids[];
0340 };
0341
0342
0343
0344
0345
0346 struct sctp_initack_chunk {
0347 struct sctp_chunkhdr chunk_hdr;
0348 struct sctp_inithdr init_hdr;
0349 };
0350
0351
0352 struct sctp_cookie_param {
0353 struct sctp_paramhdr p;
0354 __u8 body[];
0355 };
0356
0357
0358 struct sctp_unrecognized_param {
0359 struct sctp_paramhdr param_hdr;
0360 struct sctp_paramhdr unrecognized;
0361 };
0362
0363
0364
0365
0366
0367
0368
0369
0370
0371
0372
0373 struct sctp_gap_ack_block {
0374 __be16 start;
0375 __be16 end;
0376 };
0377
0378 union sctp_sack_variable {
0379 struct sctp_gap_ack_block gab;
0380 __be32 dup;
0381 };
0382
0383 struct sctp_sackhdr {
0384 __be32 cum_tsn_ack;
0385 __be32 a_rwnd;
0386 __be16 num_gap_ack_blocks;
0387 __be16 num_dup_tsns;
0388 union sctp_sack_variable variable[];
0389 };
0390
0391 struct sctp_sack_chunk {
0392 struct sctp_chunkhdr chunk_hdr;
0393 struct sctp_sackhdr sack_hdr;
0394 };
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404 struct sctp_heartbeathdr {
0405 struct sctp_paramhdr info;
0406 };
0407
0408 struct sctp_heartbeat_chunk {
0409 struct sctp_chunkhdr chunk_hdr;
0410 struct sctp_heartbeathdr hb_hdr;
0411 };
0412
0413
0414
0415 struct sctp_pad_chunk {
0416 struct sctp_chunkhdr uh;
0417 };
0418
0419
0420
0421
0422
0423
0424 struct sctp_abort_chunk {
0425 struct sctp_chunkhdr uh;
0426 };
0427
0428
0429
0430
0431
0432 struct sctp_shutdownhdr {
0433 __be32 cum_tsn_ack;
0434 };
0435
0436 struct sctp_shutdown_chunk {
0437 struct sctp_chunkhdr chunk_hdr;
0438 struct sctp_shutdownhdr shutdown_hdr;
0439 };
0440
0441
0442
0443 struct sctp_errhdr {
0444 __be16 cause;
0445 __be16 length;
0446 __u8 variable[];
0447 };
0448
0449 struct sctp_operr_chunk {
0450 struct sctp_chunkhdr chunk_hdr;
0451 struct sctp_errhdr err_hdr;
0452 };
0453
0454
0455
0456
0457
0458
0459
0460
0461
0462
0463
0464
0465
0466
0467
0468
0469
0470
0471
0472
0473 enum sctp_error {
0474
0475 SCTP_ERROR_NO_ERROR = cpu_to_be16(0x00),
0476 SCTP_ERROR_INV_STRM = cpu_to_be16(0x01),
0477 SCTP_ERROR_MISS_PARAM = cpu_to_be16(0x02),
0478 SCTP_ERROR_STALE_COOKIE = cpu_to_be16(0x03),
0479 SCTP_ERROR_NO_RESOURCE = cpu_to_be16(0x04),
0480 SCTP_ERROR_DNS_FAILED = cpu_to_be16(0x05),
0481 SCTP_ERROR_UNKNOWN_CHUNK = cpu_to_be16(0x06),
0482 SCTP_ERROR_INV_PARAM = cpu_to_be16(0x07),
0483 SCTP_ERROR_UNKNOWN_PARAM = cpu_to_be16(0x08),
0484 SCTP_ERROR_NO_DATA = cpu_to_be16(0x09),
0485 SCTP_ERROR_COOKIE_IN_SHUTDOWN = cpu_to_be16(0x0a),
0486
0487
0488
0489
0490
0491
0492
0493
0494
0495 SCTP_ERROR_RESTART = cpu_to_be16(0x0b),
0496 SCTP_ERROR_USER_ABORT = cpu_to_be16(0x0c),
0497 SCTP_ERROR_PROTO_VIOLATION = cpu_to_be16(0x0d),
0498 SCTP_ERROR_NEW_ENCAP_PORT = cpu_to_be16(0x0e),
0499
0500
0501
0502
0503
0504
0505
0506
0507
0508
0509
0510
0511
0512
0513 SCTP_ERROR_DEL_LAST_IP = cpu_to_be16(0x00A0),
0514 SCTP_ERROR_RSRC_LOW = cpu_to_be16(0x00A1),
0515 SCTP_ERROR_DEL_SRC_IP = cpu_to_be16(0x00A2),
0516 SCTP_ERROR_ASCONF_ACK = cpu_to_be16(0x00A3),
0517 SCTP_ERROR_REQ_REFUSED = cpu_to_be16(0x00A4),
0518
0519
0520
0521
0522
0523
0524
0525
0526
0527
0528
0529 SCTP_ERROR_UNSUP_HMAC = cpu_to_be16(0x0105)
0530 };
0531
0532
0533
0534
0535
0536
0537 struct sctp_ecnehdr {
0538 __be32 lowest_tsn;
0539 };
0540
0541 struct sctp_ecne_chunk {
0542 struct sctp_chunkhdr chunk_hdr;
0543 struct sctp_ecnehdr ence_hdr;
0544 };
0545
0546
0547
0548
0549 struct sctp_cwrhdr {
0550 __be32 lowest_tsn;
0551 };
0552
0553
0554
0555
0556
0557
0558
0559
0560
0561
0562
0563
0564
0565
0566
0567
0568
0569
0570
0571
0572
0573
0574
0575
0576
0577
0578
0579
0580
0581
0582
0583
0584
0585
0586
0587
0588
0589
0590
0591
0592
0593
0594
0595
0596
0597
0598
0599 struct sctp_fwdtsn_skip {
0600 __be16 stream;
0601 __be16 ssn;
0602 };
0603
0604 struct sctp_fwdtsn_hdr {
0605 __be32 new_cum_tsn;
0606 struct sctp_fwdtsn_skip skip[];
0607 };
0608
0609 struct sctp_fwdtsn_chunk {
0610 struct sctp_chunkhdr chunk_hdr;
0611 struct sctp_fwdtsn_hdr fwdtsn_hdr;
0612 };
0613
0614 struct sctp_ifwdtsn_skip {
0615 __be16 stream;
0616 __u8 reserved;
0617 __u8 flags;
0618 __be32 mid;
0619 };
0620
0621 struct sctp_ifwdtsn_hdr {
0622 __be32 new_cum_tsn;
0623 struct sctp_ifwdtsn_skip skip[];
0624 };
0625
0626 struct sctp_ifwdtsn_chunk {
0627 struct sctp_chunkhdr chunk_hdr;
0628 struct sctp_ifwdtsn_hdr fwdtsn_hdr;
0629 };
0630
0631
0632
0633
0634
0635
0636
0637
0638
0639
0640
0641
0642
0643
0644
0645
0646
0647
0648
0649
0650
0651
0652
0653
0654
0655
0656
0657
0658
0659
0660
0661
0662
0663 struct sctp_addip_param {
0664 struct sctp_paramhdr param_hdr;
0665 __be32 crr_id;
0666 };
0667
0668 struct sctp_addiphdr {
0669 __be32 serial;
0670 __u8 params[];
0671 };
0672
0673 struct sctp_addip_chunk {
0674 struct sctp_chunkhdr chunk_hdr;
0675 struct sctp_addiphdr addip_hdr;
0676 };
0677
0678
0679
0680
0681
0682
0683
0684
0685
0686
0687
0688
0689
0690
0691
0692
0693
0694
0695
0696
0697
0698
0699
0700
0701
0702
0703
0704
0705
0706
0707
0708
0709
0710
0711
0712
0713
0714
0715
0716
0717
0718
0719
0720
0721
0722
0723
0724
0725
0726
0727 struct sctp_authhdr {
0728 __be16 shkey_id;
0729 __be16 hmac_id;
0730 __u8 hmac[];
0731 };
0732
0733 struct sctp_auth_chunk {
0734 struct sctp_chunkhdr chunk_hdr;
0735 struct sctp_authhdr auth_hdr;
0736 };
0737
0738 struct sctp_infox {
0739 struct sctp_info *sctpinfo;
0740 struct sctp_association *asoc;
0741 };
0742
0743 struct sctp_reconf_chunk {
0744 struct sctp_chunkhdr chunk_hdr;
0745 __u8 params[];
0746 };
0747
0748 struct sctp_strreset_outreq {
0749 struct sctp_paramhdr param_hdr;
0750 __be32 request_seq;
0751 __be32 response_seq;
0752 __be32 send_reset_at_tsn;
0753 __be16 list_of_streams[];
0754 };
0755
0756 struct sctp_strreset_inreq {
0757 struct sctp_paramhdr param_hdr;
0758 __be32 request_seq;
0759 __be16 list_of_streams[];
0760 };
0761
0762 struct sctp_strreset_tsnreq {
0763 struct sctp_paramhdr param_hdr;
0764 __be32 request_seq;
0765 };
0766
0767 struct sctp_strreset_addstrm {
0768 struct sctp_paramhdr param_hdr;
0769 __be32 request_seq;
0770 __be16 number_of_streams;
0771 __be16 reserved;
0772 };
0773
0774 enum {
0775 SCTP_STRRESET_NOTHING_TO_DO = 0x00,
0776 SCTP_STRRESET_PERFORMED = 0x01,
0777 SCTP_STRRESET_DENIED = 0x02,
0778 SCTP_STRRESET_ERR_WRONG_SSN = 0x03,
0779 SCTP_STRRESET_ERR_IN_PROGRESS = 0x04,
0780 SCTP_STRRESET_ERR_BAD_SEQNO = 0x05,
0781 SCTP_STRRESET_IN_PROGRESS = 0x06,
0782 };
0783
0784 struct sctp_strreset_resp {
0785 struct sctp_paramhdr param_hdr;
0786 __be32 response_seq;
0787 __be32 result;
0788 };
0789
0790 struct sctp_strreset_resptsn {
0791 struct sctp_paramhdr param_hdr;
0792 __be32 response_seq;
0793 __be32 result;
0794 __be32 senders_next_tsn;
0795 __be32 receivers_next_tsn;
0796 };
0797
0798 enum {
0799 SCTP_DSCP_SET_MASK = 0x1,
0800 SCTP_DSCP_VAL_MASK = 0xfc,
0801 SCTP_FLOWLABEL_SET_MASK = 0x100000,
0802 SCTP_FLOWLABEL_VAL_MASK = 0xfffff
0803 };
0804
0805
0806
0807
0808
0809
0810
0811
0812
0813
0814
0815
0816
0817
0818 struct sctp_new_encap_port_hdr {
0819 __be16 cur_port;
0820 __be16 new_port;
0821 };
0822
0823 #endif