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

package sctp

import (
	
)

/*
This error cause MAY be included in ABORT chunks that are sent
because of an upper-layer request.  The upper layer can specify an
Upper Layer Abort Reason that is transported by SCTP transparently
and MAY be delivered to the upper-layer protocol at the peer.

	 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
	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	|         Cause Code=12         |      Cause Length=Variable    |
	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	/                    Upper Layer Abort Reason                   /
	\                                                               \
	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
type errorCauseUserInitiatedAbort struct {
	errorCauseHeader
	upperLayerAbortReason []byte
}

func ( *errorCauseUserInitiatedAbort) () ([]byte, error) {
	.code = userInitiatedAbort
	.errorCauseHeader.raw = .upperLayerAbortReason

	return .errorCauseHeader.marshal()
}

func ( *errorCauseUserInitiatedAbort) ( []byte) error {
	 := .errorCauseHeader.unmarshal()
	if  != nil {
		return 
	}

	.upperLayerAbortReason = .errorCauseHeader.raw

	return nil
}

// String makes errorCauseUserInitiatedAbort printable.
func ( *errorCauseUserInitiatedAbort) () string {
	return fmt.Sprintf("%s: %s", .errorCauseHeader.String(), .upperLayerAbortReason)
}