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

package sctp

import (
	
	
)

//  This parameter is used to inform the receiver that a sender is willing to
//  accept zero as checksum if some other error detection method is used
//  instead.
//
//  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
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// |   Type = 0x8001 (suggested)   |          Length = 8           |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// |           Error Detection Method Identifier (EDMID)           |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

type paramZeroChecksumAcceptable struct {
	paramHeader
	// The Error Detection Method Identifier (EDMID) specifies an alternate
	// error detection method the sender of this parameter is willing to use for
	// received packets.
	edmid uint32
}

// Zero Checksum parameter error.
var (
	ErrZeroChecksumParamTooShort = errors.New("zero checksum parameter too short")
)

const (
	dtlsErrorDetectionMethod uint32 = 1
)

func ( *paramZeroChecksumAcceptable) () ([]byte, error) {
	.typ = zeroChecksumAcceptable
	.raw = make([]byte, 4)
	binary.BigEndian.PutUint32(.raw, .edmid)

	return .paramHeader.marshal()
}

func ( *paramZeroChecksumAcceptable) ( []byte) (param, error) {
	 := .paramHeader.unmarshal()
	if  != nil {
		return nil, 
	}
	if len(.raw) < 4 {
		return nil, ErrZeroChecksumParamTooShort
	}
	.edmid = binary.BigEndian.Uint32(.raw)

	return , nil
}