func (s *SCTPUnknownChunkType) Error() error {
	return fmt.Errorf("No decode method available for SCTP chunk type %s", s.Type)
}
Error implements ErrorLayer.
package layers
import (
	"encoding/binary"
	"errors"
	"fmt"
	"hash/crc32"
	"github.com/google/gopacket"
)
type SCTP struct {
	BaseLayer
	SrcPort, DstPort SCTPPort
	VerificationTag  uint32
	Checksum         uint32
	sPort, dPort     []byte
}
func (s *SCTP) LayerType() gopacket.LayerType { return LayerTypeSCTP }
func decodeSCTP(data []byte, p gopacket.PacketBuilder) error {
	sctp := &SCTP{}
	err := sctp.DecodeFromBytes(data, p)
	p.AddLayer(sctp)
	p.SetTransportLayer(sctp)
	if err != nil {
		return err
	}
	return p.NextDecoder(sctpChunkTypePrefixDecoder)
}
var sctpChunkTypePrefixDecoder = gopacket.DecodeFunc(decodeWithSCTPChunkTypePrefix)
func (s *SCTP) TransportFlow() gopacket.Flow {
	return gopacket.NewFlow(EndpointSCTPPort, s.sPort, s.dPort)
}
func decodeWithSCTPChunkTypePrefix(data []byte, p gopacket.PacketBuilder) error {
	chunkType := SCTPChunkType(data[0])
	return chunkType.Decode(data, p)
}
func (s SCTP) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
	bytes, err := b.PrependBytes(12)
	if err != nil {
		return err
	}
	binary.BigEndian.PutUint16(bytes[0:2], uint16(s.SrcPort))
	binary.BigEndian.PutUint16(bytes[2:4], uint16(s.DstPort))
	binary.BigEndian.PutUint32(bytes[4:8], s.VerificationTag)
	if opts.ComputeChecksums {
		binary.LittleEndian.PutUint32(bytes[8:12], crc32.Checksum(b.Bytes(), crc32.MakeTable(crc32.Castagnoli)))
	}
	return nil
}
func (sctp *SCTP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
	if len(data) < 12 {
		return errors.New("Invalid SCTP common header length")
	}
	sctp.SrcPort = SCTPPort(binary.BigEndian.Uint16(data[:2]))
	sctp.sPort = data[:2]
	sctp.DstPort = SCTPPort(binary.BigEndian.Uint16(data[2:4]))
	sctp.dPort = data[2:4]
	sctp.VerificationTag = binary.BigEndian.Uint32(data[4:8])
	sctp.Checksum = binary.BigEndian.Uint32(data[8:12])
	sctp.BaseLayer = BaseLayer{data[:12], data[12:]}
	return nil
}
func (t *SCTP) CanDecode() gopacket.LayerClass {
	return LayerTypeSCTP
}
func (t *SCTP) NextLayerType() gopacket.LayerType {
	return gopacket.LayerTypePayload
}
type SCTPChunk struct {
	BaseLayer
	Type   SCTPChunkType
	Flags  uint8
	Length uint16
	ActualLength int
}
func roundUpToNearest4(i int) int {
	if i%4 == 0 {
		return i
	}
	return i + 4 - (i % 4)
}
func decodeSCTPChunk(data []byte) (SCTPChunk, error) {
	length := binary.BigEndian.Uint16(data[2:4])
	if length < 4 {
		return SCTPChunk{}, errors.New("invalid SCTP chunk length")
	}
	actual := roundUpToNearest4(int(length))
	ct := SCTPChunkType(data[0])
	delta := 0
	if ct == SCTPChunkTypeData {
		delta = int(actual) - int(length)
		actual = 16
	}
	return SCTPChunk{
		Type:         ct,
		Flags:        data[1],
		Length:       length,
		ActualLength: actual,
		BaseLayer:    BaseLayer{data[:actual], data[actual : len(data)-delta]},
	}, nil
}
type SCTPParameter struct {
	Type         uint16
	Length       uint16
	ActualLength int
	Value        []byte
}
func decodeSCTPParameter(data []byte) SCTPParameter {
	length := binary.BigEndian.Uint16(data[2:4])
	return SCTPParameter{
		Type:         binary.BigEndian.Uint16(data[0:2]),
		Length:       length,
		Value:        data[4:length],
		ActualLength: roundUpToNearest4(int(length)),
	}
}
func (p SCTPParameter) Bytes() []byte {
	length := 4 + len(p.Value)
	data := make([]byte, roundUpToNearest4(length))
	binary.BigEndian.PutUint16(data[0:2], p.Type)
	binary.BigEndian.PutUint16(data[2:4], uint16(length))
	copy(data[4:], p.Value)
	return data
}
type SCTPUnknownChunkType struct {
	SCTPChunk
	bytes []byte
}
func decodeSCTPChunkTypeUnknown(data []byte, p gopacket.PacketBuilder) error {
	chunk, err := decodeSCTPChunk(data)
	if err != nil {
		return err
	}
	sc := &SCTPUnknownChunkType{SCTPChunk: chunk}
	sc.bytes = data[:sc.ActualLength]
	p.AddLayer(sc)
	p.SetErrorLayer(sc)
	return p.NextDecoder(gopacket.DecodeFunc(decodeWithSCTPChunkTypePrefix))
}
func (s SCTPUnknownChunkType) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
	bytes, err := b.PrependBytes(s.ActualLength)
	if err != nil {
		return err
	}
	copy(bytes, s.bytes)
	return nil
}
func (s *SCTPUnknownChunkType) LayerType() gopacket.LayerType { return LayerTypeSCTPUnknownChunkType }
func (s *SCTPUnknownChunkType) Payload() []byte { return s.bytes }