@@ -1844,6 +1844,7 @@ struct sctp_association *sctp_unpack_cookie(
18441844 retval -> next_tsn = retval -> c .initial_tsn ;
18451845 retval -> ctsn_ack_point = retval -> next_tsn - 1 ;
18461846 retval -> addip_serial = retval -> c .initial_tsn ;
1847+ retval -> strreset_outseq = retval -> c .initial_tsn ;
18471848 retval -> adv_peer_ack_point = retval -> ctsn_ack_point ;
18481849 retval -> peer .prsctp_capable = retval -> c .prsctp_capable ;
18491850 retval -> peer .adaptation_ind = retval -> c .adaptation_ind ;
@@ -2387,6 +2388,8 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk,
23872388 asoc -> peer .i .initial_tsn =
23882389 ntohl (peer_init -> init_hdr .initial_tsn );
23892390
2391+ asoc -> strreset_inseq = asoc -> peer .i .initial_tsn ;
2392+
23902393 /* Apply the upper bounds for output streams based on peer's
23912394 * number of inbound streams.
23922395 */
@@ -3524,3 +3527,121 @@ struct sctp_chunk *sctp_make_fwdtsn(const struct sctp_association *asoc,
35243527
35253528 return retval ;
35263529}
3530+
3531+ /* RE-CONFIG 3.1 (RE-CONFIG chunk)
3532+ * 0 1 2 3
3533+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
3534+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3535+ * | Type = 130 | Chunk Flags | Chunk Length |
3536+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3537+ * \ \
3538+ * / Re-configuration Parameter /
3539+ * \ \
3540+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3541+ * \ \
3542+ * / Re-configuration Parameter (optional) /
3543+ * \ \
3544+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3545+ */
3546+ static struct sctp_chunk * sctp_make_reconf (
3547+ const struct sctp_association * asoc ,
3548+ int length )
3549+ {
3550+ struct sctp_reconf_chunk * reconf ;
3551+ struct sctp_chunk * retval ;
3552+
3553+ retval = sctp_make_control (asoc , SCTP_CID_RECONF , 0 , length ,
3554+ GFP_ATOMIC );
3555+ if (!retval )
3556+ return NULL ;
3557+
3558+ reconf = (struct sctp_reconf_chunk * )retval -> chunk_hdr ;
3559+ retval -> param_hdr .v = reconf -> params ;
3560+
3561+ return retval ;
3562+ }
3563+
3564+ /* RE-CONFIG 4.1 (STREAM OUT RESET)
3565+ * 0 1 2 3
3566+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
3567+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3568+ * | Parameter Type = 13 | Parameter Length = 16 + 2 * N |
3569+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3570+ * | Re-configuration Request Sequence Number |
3571+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3572+ * | Re-configuration Response Sequence Number |
3573+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3574+ * | Sender's Last Assigned TSN |
3575+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3576+ * | Stream Number 1 (optional) | Stream Number 2 (optional) |
3577+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3578+ * / ...... /
3579+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3580+ * | Stream Number N-1 (optional) | Stream Number N (optional) |
3581+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3582+ *
3583+ * RE-CONFIG 4.2 (STREAM IN RESET)
3584+ * 0 1 2 3
3585+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
3586+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3587+ * | Parameter Type = 14 | Parameter Length = 8 + 2 * N |
3588+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3589+ * | Re-configuration Request Sequence Number |
3590+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3591+ * | Stream Number 1 (optional) | Stream Number 2 (optional) |
3592+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3593+ * / ...... /
3594+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3595+ * | Stream Number N-1 (optional) | Stream Number N (optional) |
3596+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3597+ */
3598+ struct sctp_chunk * sctp_make_strreset_req (
3599+ const struct sctp_association * asoc ,
3600+ __u16 stream_num , __u16 * stream_list ,
3601+ bool out , bool in )
3602+ {
3603+ struct sctp_strreset_outreq outreq ;
3604+ __u16 stream_len = stream_num * 2 ;
3605+ struct sctp_strreset_inreq inreq ;
3606+ struct sctp_chunk * retval ;
3607+ __u16 outlen , inlen , i ;
3608+
3609+ outlen = (sizeof (outreq ) + stream_len ) * out ;
3610+ inlen = (sizeof (inreq ) + stream_len ) * in ;
3611+
3612+ retval = sctp_make_reconf (asoc , outlen + inlen );
3613+ if (!retval )
3614+ return NULL ;
3615+
3616+ for (i = 0 ; i < stream_num ; i ++ )
3617+ stream_list [i ] = htons (stream_list [i ]);
3618+
3619+ if (outlen ) {
3620+ outreq .param_hdr .type = SCTP_PARAM_RESET_OUT_REQUEST ;
3621+ outreq .param_hdr .length = htons (outlen );
3622+ outreq .request_seq = htonl (asoc -> strreset_outseq );
3623+ outreq .response_seq = htonl (asoc -> strreset_inseq - 1 );
3624+ outreq .send_reset_at_tsn = htonl (asoc -> next_tsn - 1 );
3625+
3626+ sctp_addto_chunk (retval , sizeof (outreq ), & outreq );
3627+
3628+ if (stream_len )
3629+ sctp_addto_chunk (retval , stream_len , stream_list );
3630+ }
3631+
3632+ if (inlen ) {
3633+ inreq .param_hdr .type = SCTP_PARAM_RESET_IN_REQUEST ;
3634+ inreq .param_hdr .length = htons (inlen );
3635+ inreq .request_seq = htonl (asoc -> strreset_outseq + out );
3636+
3637+ sctp_addto_chunk (retval , sizeof (inreq ), & inreq );
3638+
3639+ if (stream_len )
3640+ sctp_addto_chunk (retval , stream_len , stream_list );
3641+ }
3642+
3643+ for (i = 0 ; i < stream_num ; i ++ )
3644+ stream_list [i ] = ntohs (stream_list [i ]);
3645+
3646+ return retval ;
3647+ }
0 commit comments