// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT

package sctp

import (
	
	
	
)

// This parameter is used by the receiver of a Re-configuration Request
// Parameter to respond to the request.
//
// 0                   1                   2                   3
// 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
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// |     Parameter Type = 16       |      Parameter Length         |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// |         Re-configuration Response Sequence Number             |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// |                            Result                             |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// |                   Sender's Next TSN (optional)                |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// |                  Receiver's Next TSN (optional)               |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

type paramReconfigResponse struct {
	paramHeader
	// This value is copied from the request parameter and is used by the
	// receiver of the Re-configuration Response Parameter to tie the
	// response to the request.
	reconfigResponseSequenceNumber uint32
	// This value describes the result of the processing of the request.
	result reconfigResult
}

type reconfigResult uint32

const (
	reconfigResultSuccessNOP                    reconfigResult = 0
	reconfigResultSuccessPerformed              reconfigResult = 1
	reconfigResultDenied                        reconfigResult = 2
	reconfigResultErrorWrongSSN                 reconfigResult = 3
	reconfigResultErrorRequestAlreadyInProgress reconfigResult = 4
	reconfigResultErrorBadSequenceNumber        reconfigResult = 5
	reconfigResultInProgress                    reconfigResult = 6
)

// Reconfiguration response errors.
var (
	ErrReconfigRespParamTooShort = errors.New("reconfig response parameter too short")
)

func ( reconfigResult) () string {
	switch  {
	case reconfigResultSuccessNOP:
		return "0: Success - Nothing to do"
	case reconfigResultSuccessPerformed:
		return "1: Success - Performed"
	case reconfigResultDenied:
		return "2: Denied"
	case reconfigResultErrorWrongSSN:
		return "3: Error - Wrong SSN"
	case reconfigResultErrorRequestAlreadyInProgress:
		return "4: Error - Request already in progress"
	case reconfigResultErrorBadSequenceNumber:
		return "5: Error - Bad Sequence Number"
	case reconfigResultInProgress:
		return "6: In progress"
	default:
		return fmt.Sprintf("Unknown reconfigResult: %d", )
	}
}

func ( *paramReconfigResponse) () ([]byte, error) {
	.typ = reconfigResp
	.raw = make([]byte, 8)
	binary.BigEndian.PutUint32(.raw, .reconfigResponseSequenceNumber)
	binary.BigEndian.PutUint32(.raw[4:], uint32(.result))

	return .paramHeader.marshal()
}

func ( *paramReconfigResponse) ( []byte) (param, error) {
	 := .paramHeader.unmarshal()
	if  != nil {
		return nil, 
	}
	if len(.raw) < 8 {
		return nil, ErrReconfigRespParamTooShort
	}
	.reconfigResponseSequenceNumber = binary.BigEndian.Uint32(.raw)
	.result = reconfigResult(binary.BigEndian.Uint32(.raw[4:]))

	return , nil
}