func (avp *avp) getType() avpType {
	return avp.header.AvpType
}
type returns the type identifier for the AVP.
package l2tp
import (
	"bytes"
	"encoding/binary"
	"errors"
	"fmt"
	"io"
	"strings"
)
type avpFlagLen uint16
type avpVendorID uint16
type avpType uint16
type avpMsgType uint16
type avpDataType int
type avpInfo struct {
	avpType     avpType
	VendorID    avpVendorID
	isMandatory bool
	dataType    avpDataType
}
type avpHeader struct {
	FlagLen  avpFlagLen
	VendorID avpVendorID
	AvpType  avpType
}
type avpPayload struct {
	dataType avpDataType
	data     []byte
}
type avp struct {
	header  avpHeader
	payload avpPayload
}
type avpResultCode uint16
type avpErrorCode uint16
type resultCode struct {
	result  avpResultCode
	errCode avpErrorCode
	errMsg  string
}
const (
	avpHeaderLen = 6
	vendorIDIetf = 0
)
const (
	avpDataTypeEmpty avpDataType = iota
	avpDataTypeUint16 avpDataType = iota
	avpDataTypeUint32 avpDataType = iota
	avpDataTypeUint64 avpDataType = iota
	avpDataTypeString avpDataType = iota
	avpDataTypeBytes avpDataType = iota
	avpDataTypeResultCode avpDataType = iota
	avpDataTypeMsgID avpDataType = iota
	avpDataTypeUnimplemented avpDataType = iota
	avpDataTypeIllegal avpDataType = iota
	avpDataTypeMax avpDataType = iota
)
var avpInfoTable = [...]avpInfo{
	{avpType: avpTypeMessage, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeMsgID},
	{avpType: avpTypeResultCode, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeResultCode},
	{avpType: avpTypeProtocolVersion, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeBytes},
	{avpType: avpTypeFramingCap, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeUint32},
	{avpType: avpTypeBearerCap, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeUint32},
	{avpType: avpTypeTiebreaker, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeBytes},
	{avpType: avpTypeFirmwareRevision, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeUint16},
	{avpType: avpTypeHostName, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeString},
	{avpType: avpTypeVendorName, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeString},
	{avpType: avpTypeTunnelID, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeUint16},
	{avpType: avpTypeRxWindowSize, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeUint16},
	{avpType: avpTypeChallenge, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeBytes},
	{avpType: avpTypeQ931CauseCode, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeUnimplemented},  
	{avpType: avpTypeChallengeResponse, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeBytes},
	{avpType: avpTypeSessionID, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeUint16},
	{avpType: avpTypeCallSerialNumber, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeUint32},
	{avpType: avpTypeMinimumBps, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeUint32},
	{avpType: avpTypeMaximumBps, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeUint32},
	{avpType: avpTypeBearerType, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeUint32},
	{avpType: avpTypeFramingType, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeUint32},
	{avpType: avpTypePacketProcDelay, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeUnimplemented},  
	{avpType: avpTypeCalledNumber, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeString},
	{avpType: avpTypeCallingNumber, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeString},
	{avpType: avpTypeSubAddress, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeString},
	{avpType: avpTypeConnectSpeed, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeUint32},
	{avpType: avpTypePhysicalChannelID, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeUint32},
	{avpType: avpTypeInitialRcvdLcpConfreq, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeBytes},
	{avpType: avpTypeLastSentLcpConfreq, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeBytes},
	{avpType: avpTypeLastRcvdLcpConfreq, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeBytes},
	{avpType: avpTypeProxyAuthType, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeUint16},
	{avpType: avpTypeProxyAuthName, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeString},
	{avpType: avpTypeProxyAuthChallenge, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeBytes},
	{avpType: avpTypeProxyAuthID, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeBytes},
	{avpType: avpTypeProxyAuthResponse, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeBytes},
	{avpType: avpTypeCallErrors, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeUnimplemented},  
	{avpType: avpTypeAccm, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeUnimplemented},        
	{avpType: avpTypeRandomVector, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeBytes},
	{avpType: avpTypePrivGroupID, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeString},
	{avpType: avpTypeRxConnectSpeed, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeUint32},
	{avpType: avpTypeSequencingRequired, VendorID: vendorIDIetf, isMandatory: true, dataType: avpDataTypeEmpty},
	{avpType: avpTypeUnused40, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeIllegal},
	{avpType: avpTypeUnused41, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeIllegal},
	{avpType: avpTypeUnused42, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeIllegal},
	{avpType: avpTypeUnused43, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeIllegal},
	{avpType: avpTypeUnused44, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeIllegal},
	{avpType: avpTypeUnused45, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeIllegal},
	{avpType: avpTypeUnused46, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeIllegal},
	{avpType: avpTypeUnused47, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeIllegal},
	{avpType: avpTypeUnused48, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeIllegal},
	{avpType: avpTypeUnused49, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeIllegal},
	{avpType: avpTypeUnused50, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeIllegal},
	{avpType: avpTypeUnused51, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeIllegal},
	{avpType: avpTypeUnused52, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeIllegal},
	{avpType: avpTypeUnused53, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeIllegal},
	{avpType: avpTypeUnused54, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeIllegal},
	{avpType: avpTypeUnused55, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeIllegal},
	{avpType: avpTypeUnused56, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeIllegal},
	{avpType: avpTypeUnused57, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeIllegal},
	{avpType: avpTypeExtended, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeIllegal},
	{avpType: avpTypeMessageDigest, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeBytes},
	{avpType: avpTypeRouterID, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeUint32},
	{avpType: avpTypeAssignedConnID, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeUint32},
	{avpType: avpTypePseudowireCaps, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeUnimplemented},
	{avpType: avpTypeLocalSessionID, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeUint32},
	{avpType: avpTypeRemoteSessionID, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeUint32},
	{avpType: avpTypeAssignedCookie, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeBytes},
	{avpType: avpTypeRemoteEndID, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeBytes},
	{avpType: avpTypeUnused67, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeIllegal},
	{avpType: avpTypePseudowireType, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeUint16},
	{avpType: avpTypeL2specificSublayer, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeUint16},
	{avpType: avpTypeDataSequencing, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeUint16},
	{avpType: avpTypeCircuitStatus, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeUint16},
	{avpType: avpTypePreferredLanguage, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeBytes},
	{avpType: avpTypeControlAuthNonce, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeBytes},
	{avpType: avpTypeTxConnectSpeedBps, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeUint64},
	{avpType: avpTypeRxConnectSpeedBps, VendorID: vendorIDIetf, isMandatory: false, dataType: avpDataTypeUint64},
}
const (
	avpTypeMessage               avpType = 0
	avpTypeResultCode            avpType = 1
	avpTypeProtocolVersion       avpType = 2
	avpTypeFramingCap            avpType = 3
	avpTypeBearerCap             avpType = 4
	avpTypeTiebreaker            avpType = 5
	avpTypeFirmwareRevision      avpType = 6
	avpTypeHostName              avpType = 7
	avpTypeVendorName            avpType = 8
	avpTypeTunnelID              avpType = 9
	avpTypeRxWindowSize          avpType = 10
	avpTypeChallenge             avpType = 11
	avpTypeQ931CauseCode         avpType = 12
	avpTypeChallengeResponse     avpType = 13
	avpTypeSessionID             avpType = 14
	avpTypeCallSerialNumber      avpType = 15
	avpTypeMinimumBps            avpType = 16
	avpTypeMaximumBps            avpType = 17
	avpTypeBearerType            avpType = 18
	avpTypeFramingType           avpType = 19
	avpTypePacketProcDelay       avpType = 20  
	avpTypeCalledNumber          avpType = 21
	avpTypeCallingNumber         avpType = 22
	avpTypeSubAddress            avpType = 23
	avpTypeConnectSpeed          avpType = 24
	avpTypePhysicalChannelID     avpType = 25
	avpTypeInitialRcvdLcpConfreq avpType = 26
	avpTypeLastSentLcpConfreq    avpType = 27
	avpTypeLastRcvdLcpConfreq    avpType = 28
	avpTypeProxyAuthType         avpType = 29
	avpTypeProxyAuthName         avpType = 30
	avpTypeProxyAuthChallenge    avpType = 31
	avpTypeProxyAuthID           avpType = 32
	avpTypeProxyAuthResponse     avpType = 33
	avpTypeCallErrors            avpType = 34
	avpTypeAccm                  avpType = 35
	avpTypeRandomVector          avpType = 36
	avpTypePrivGroupID           avpType = 37
	avpTypeRxConnectSpeed        avpType = 38
	avpTypeSequencingRequired    avpType = 39
	avpTypeUnused40              avpType = 40
	avpTypeUnused41              avpType = 41
	avpTypeUnused42              avpType = 42
	avpTypeUnused43              avpType = 43
	avpTypeUnused44              avpType = 44
	avpTypeUnused45              avpType = 45
	avpTypeUnused46              avpType = 46
	avpTypeUnused47              avpType = 47
	avpTypeUnused48              avpType = 48
	avpTypeUnused49              avpType = 49
	avpTypeUnused50              avpType = 50
	avpTypeUnused51              avpType = 51
	avpTypeUnused52              avpType = 52
	avpTypeUnused53              avpType = 53
	avpTypeUnused54              avpType = 54
	avpTypeUnused55              avpType = 55
	avpTypeUnused56              avpType = 56
	avpTypeUnused57              avpType = 57
	avpTypeExtended              avpType = 58
	avpTypeMessageDigest         avpType = 59
	avpTypeRouterID              avpType = 60
	avpTypeAssignedConnID        avpType = 61
	avpTypePseudowireCaps        avpType = 62
	avpTypeLocalSessionID        avpType = 63
	avpTypeRemoteSessionID       avpType = 64
	avpTypeAssignedCookie        avpType = 65
	avpTypeRemoteEndID           avpType = 66
	avpTypeUnused67              avpType = 67
	avpTypePseudowireType        avpType = 68
	avpTypeL2specificSublayer    avpType = 69
	avpTypeDataSequencing        avpType = 70
	avpTypeCircuitStatus         avpType = 71
	avpTypePreferredLanguage     avpType = 72
	avpTypeControlAuthNonce      avpType = 73
	avpTypeTxConnectSpeedBps     avpType = 74
	avpTypeRxConnectSpeedBps     avpType = 75
	avpTypeMax                   avpType = 76
)
const (
	avpMsgTypeIllegal    avpMsgType = 0
	avpMsgTypeSccrq      avpMsgType = 1
	avpMsgTypeSccrp      avpMsgType = 2
	avpMsgTypeScccn      avpMsgType = 3
	avpMsgTypeStopccn    avpMsgType = 4
	avpMsgTypeReserved5  avpMsgType = 5
	avpMsgTypeHello      avpMsgType = 6
	avpMsgTypeOcrq       avpMsgType = 7
	avpMsgTypeOcrp       avpMsgType = 8
	avpMsgTypeOccn       avpMsgType = 9
	avpMsgTypeIcrq       avpMsgType = 10
	avpMsgTypeIcrp       avpMsgType = 11
	avpMsgTypeIccn       avpMsgType = 12
	avpMsgTypeReserved13 avpMsgType = 13
	avpMsgTypeCdn        avpMsgType = 14
	avpMsgTypeWen        avpMsgType = 15
	avpMsgTypeSli        avpMsgType = 16
	avpMsgTypeMdmst      avpMsgType = 17
	avpMsgTypeSrrq       avpMsgType = 18
	avpMsgTypeSrrp       avpMsgType = 19
	avpMsgTypeAck        avpMsgType = 20
	avpMsgTypeFsq        avpMsgType = 21
	avpMsgTypeFsr        avpMsgType = 22
	avpMsgTypeMsrq       avpMsgType = 23
	avpMsgTypeMsrp       avpMsgType = 24
	avpMsgTypeMse        avpMsgType = 25
	avpMsgTypeMsi        avpMsgType = 26
	avpMsgTypeMsen       avpMsgType = 27
	avpMsgTypeCsun       avpMsgType = 28
	avpMsgTypeCsurq      avpMsgType = 29
	avpMsgTypeMax        avpMsgType = 30
)
const (
	avpStopCCNResultCodeReserved                          avpResultCode = 0
	avpStopCCNResultCodeClearConnection                   avpResultCode = 1
	avpStopCCNResultCodeGeneralError                      avpResultCode = 2
	avpStopCCNResultCodeChannelExists                     avpResultCode = 3
	avpStopCCNResultCodeChannelNotAuthorized              avpResultCode = 4
	avpStopCCNResultCodeChannelProtocolVersionUnsupported avpResultCode = 5
	avpStopCCNResultCodeChannelShuttingDown               avpResultCode = 6
	avpStopCCNResultCodeChannelFSMError                   avpResultCode = 7
	avpCDNResultCodeReserved                              avpResultCode = 0
	avpCDNResultCodeLostCarrier                           avpResultCode = 1
	avpCDNResultCodeGeneralError                          avpResultCode = 2
	avpCDNResultCodeAdminDisconnect                       avpResultCode = 3
	avpCDNResultCodeNoResources                           avpResultCode = 4
	avpCDNResultCodeNotAvailable                          avpResultCode = 5
	avpCDNResultCodeInvalidDestination                    avpResultCode = 6
	avpCDNResultCodeNoAnswer                              avpResultCode = 7
	avpCDNResultCodeBusy                                  avpResultCode = 8
	avpCDNResultCodeNoDialTone                            avpResultCode = 9
	avpCDNResultCodeTimeout                               avpResultCode = 10
	avpCDNResultCodeBadTransport                          avpResultCode = 11
)
const (
	avpErrorCodeNoError             avpErrorCode = 0
	avpErrorCodeNoControlConnection avpErrorCode = 1
	avpErrorCodeBadLength           avpErrorCode = 2
	avpErrorCodeBadValue            avpErrorCode = 3
	avpErrorCodeNoResource          avpErrorCode = 4
	avpErrorCodeInvalidSessionID    avpErrorCode = 5
	avpErrorCodeVendorSpecificError avpErrorCode = 6
	avpErrorCodeTryAnother          avpErrorCode = 7
	avpErrorCodeMBitShutdown        avpErrorCode = 8
)
var _ fmt.Stringer = (*avpType)(nil)
func (t avpType) String() string {
	switch t {
	case avpTypeMessage:
		return "avpTypeMessage"
	case avpTypeResultCode:
		return "avpTypeResultCode"
	case avpTypeProtocolVersion:
		return "avpTypeProtocolVersion"
	case avpTypeFramingCap:
		return "avpTypeFramingCap"
	case avpTypeBearerCap:
		return "avpTypeBearerCap"
	case avpTypeTiebreaker:
		return "avpTypeTiebreaker"
	case avpTypeFirmwareRevision:
		return "avpTypeFirmwareRevision"
	case avpTypeHostName:
		return "avpTypeHostName"
	case avpTypeVendorName:
		return "avpTypeVendorName"
	case avpTypeTunnelID:
		return "avpTypeTunnelID"
	case avpTypeRxWindowSize:
		return "avpTypeRxWindowSize"
	case avpTypeChallenge:
		return "avpTypeChallenge"
	case avpTypeQ931CauseCode:
		return "avpTypeQ931CauseCode"
	case avpTypeChallengeResponse:
		return "avpTypeChallengeResponse"
	case avpTypeSessionID:
		return "avpTypeSessionID"
	case avpTypeCallSerialNumber:
		return "avpTypeCallSerialNumber"
	case avpTypeMinimumBps:
		return "avpTypeMinimumBps"
	case avpTypeMaximumBps:
		return "avpTypeMaximumBps"
	case avpTypeBearerType:
		return "avpTypeBearerType"
	case avpTypeFramingType:
		return "avpTypeFramingType"
	case avpTypePacketProcDelay:
		return "avpTypePacketProcDelay"
	case avpTypeCalledNumber:
		return "avpTypeCalledNumber"
	case avpTypeCallingNumber:
		return "avpTypeCallingNumber"
	case avpTypeSubAddress:
		return "avpTypeSubAddress"
	case avpTypeConnectSpeed:
		return "avpTypeConnectSpeed"
	case avpTypePhysicalChannelID:
		return "avpTypePhysicalChannelID"
	case avpTypeInitialRcvdLcpConfreq:
		return "avpTypeInitialRcvdLcpConfreq"
	case avpTypeLastSentLcpConfreq:
		return "avpTypeLastSentLcpConfreq"
	case avpTypeLastRcvdLcpConfreq:
		return "avpTypeLastRcvdLcpConfreq"
	case avpTypeProxyAuthType:
		return "avpTypeProxyAuthType"
	case avpTypeProxyAuthName:
		return "avpTypeProxyAuthName"
	case avpTypeProxyAuthChallenge:
		return "avpTypeProxyAuthChallenge"
	case avpTypeProxyAuthID:
		return "avpTypeProxyAuthID"
	case avpTypeProxyAuthResponse:
		return "avpTypeProxyAuthResponse"
	case avpTypeCallErrors:
		return "avpTypeCallErrors"
	case avpTypeAccm:
		return "avpTypeAccm"
	case avpTypeRandomVector:
		return "avpTypeRandomVector"
	case avpTypePrivGroupID:
		return "avpTypePrivGroupID"
	case avpTypeRxConnectSpeed:
		return "avpTypeRxConnectSpeed"
	case avpTypeSequencingRequired:
		return "avpTypeSequencingRequired"
	case avpTypeUnused40:
		return "avpTypeUnused40"
	case avpTypeUnused41:
		return "avpTypeUnused41"
	case avpTypeUnused42:
		return "avpTypeUnused42"
	case avpTypeUnused43:
		return "avpTypeUnused43"
	case avpTypeUnused44:
		return "avpTypeUnused44"
	case avpTypeUnused45:
		return "avpTypeUnused45"
	case avpTypeUnused46:
		return "avpTypeUnused46"
	case avpTypeUnused47:
		return "avpTypeUnused47"
	case avpTypeUnused48:
		return "avpTypeUnused48"
	case avpTypeUnused49:
		return "avpTypeUnused49"
	case avpTypeUnused50:
		return "avpTypeUnused50"
	case avpTypeUnused51:
		return "avpTypeUnused51"
	case avpTypeUnused52:
		return "avpTypeUnused52"
	case avpTypeUnused53:
		return "avpTypeUnused53"
	case avpTypeUnused54:
		return "avpTypeUnused54"
	case avpTypeUnused55:
		return "avpTypeUnused55"
	case avpTypeUnused56:
		return "avpTypeUnused56"
	case avpTypeUnused57:
		return "avpTypeUnused57"
	case avpTypeExtended:
		return "avpTypeExtended"
	case avpTypeMessageDigest:
		return "avpTypeMessageDigest"
	case avpTypeRouterID:
		return "avpTypeRouterID"
	case avpTypeAssignedConnID:
		return "avpTypeAssignedConnID"
	case avpTypePseudowireCaps:
		return "avpTypePseudowireCaps"
	case avpTypeLocalSessionID:
		return "avpTypeLocalSessionID"
	case avpTypeRemoteSessionID:
		return "avpTypeRemoteSessionID"
	case avpTypeAssignedCookie:
		return "avpTypeAssignedCookie"
	case avpTypeRemoteEndID:
		return "avpTypeRemoteEndID"
	case avpTypeUnused67:
		return "avpTypeUnused67"
	case avpTypePseudowireType:
		return "avpTypePseudowireType"
	case avpTypeL2specificSublayer:
		return "avpTypeL2specificSublayer"
	case avpTypeDataSequencing:
		return "avpTypeDataSequencing"
	case avpTypeCircuitStatus:
		return "avpTypeCircuitStatus"
	case avpTypePreferredLanguage:
		return "avpTypePreferredLanguage"
	case avpTypeControlAuthNonce:
		return "avpTypeControlAuthNonce"
	case avpTypeTxConnectSpeedBps:
		return "avpTypeTxConnectSpeedBps"
	case avpTypeRxConnectSpeedBps:
		return "avpTypeRxConnectSpeedBps"
	}
	return ""
}
var _ fmt.Stringer = (*avpMsgType)(nil)
func (t avpMsgType) String() string {
	switch t {
	case avpMsgTypeIllegal:
		return "avpMsgTypeIllegal"
	case avpMsgTypeSccrq:
		return "avpMsgTypeSccrq"
	case avpMsgTypeSccrp:
		return "avpMsgTypeSccrp"
	case avpMsgTypeScccn:
		return "avpMsgTypeScccn"
	case avpMsgTypeStopccn:
		return "avpMsgTypeStopccn"
	case avpMsgTypeReserved5:
		return "avpMsgTypeReserved5"
	case avpMsgTypeHello:
		return "avpMsgTypeHello"
	case avpMsgTypeOcrq:
		return "avpMsgTypeOcrq"
	case avpMsgTypeOcrp:
		return "avpMsgTypeOcrp"
	case avpMsgTypeOccn:
		return "avpMsgTypeOccn"
	case avpMsgTypeIcrq:
		return "avpMsgTypeIcrq"
	case avpMsgTypeIcrp:
		return "avpMsgTypeIcrp"
	case avpMsgTypeIccn:
		return "avpMsgTypeIccn"
	case avpMsgTypeReserved13:
		return "avpMsgTypeReserved13"
	case avpMsgTypeCdn:
		return "avpMsgTypeCdn"
	case avpMsgTypeWen:
		return "avpMsgTypeWen"
	case avpMsgTypeSli:
		return "avpMsgTypeSli"
	case avpMsgTypeMdmst:
		return "avpMsgTypeMdmst"
	case avpMsgTypeSrrq:
		return "avpMsgTypeSrrq"
	case avpMsgTypeSrrp:
		return "avpMsgTypeSrrp"
	case avpMsgTypeAck:
		return "avpMsgTypeAck"
	case avpMsgTypeFsq:
		return "avpMsgTypeFsq"
	case avpMsgTypeFsr:
		return "avpMsgTypeFsr"
	case avpMsgTypeMsrq:
		return "avpMsgTypeMsrq"
	case avpMsgTypeMsrp:
		return "avpMsgTypeMsrp"
	case avpMsgTypeMse:
		return "avpMsgTypeMse"
	case avpMsgTypeMsi:
		return "avpMsgTypeMsi"
	case avpMsgTypeMsen:
		return "avpMsgTypeMsen"
	case avpMsgTypeCsun:
		return "avpMsgTypeCsun"
	case avpMsgTypeCsurq:
		return "avpMsgTypeCsurq"
	}
	return ""
}
var _ fmt.Stringer = (*avp)(nil)
func (avp avp) String() string {
	return fmt.Sprintf("%s %s", avp.header, avp.payload)
}
var _ fmt.Stringer = (*avpVendorID)(nil)
func (v avpVendorID) String() string {
	if v == vendorIDIetf {
		return "IETF"
	}
	return fmt.Sprintf("Vendor %d", v)
}
var _ fmt.Stringer = (*avpDataType)(nil)
func (t avpDataType) String() string {
	switch t {
	case avpDataTypeEmpty:
		return "no data"
	case avpDataTypeUint16:
		return "uint16"
	case avpDataTypeUint32:
		return "uint32"
	case avpDataTypeUint64:
		return "uint64"
	case avpDataTypeString:
		return "string"
	case avpDataTypeBytes:
		return "byte array"
	case avpDataTypeResultCode:
		return "result code"
	case avpDataTypeMsgID:
		return "message ID"
	case avpDataTypeUnimplemented:
		return "unimplemented AVP data type"
	case avpDataTypeIllegal:
		return "illegal AVP"
	}
	return "Unrecognised AVP data type"
}
var _ fmt.Stringer = (*avpHeader)(nil)
func (hdr avpHeader) String() string {
	m := "-"
	h := "-"
	var t string
	if hdr.VendorID == vendorIDIetf {
		t = hdr.AvpType.String()
	} else {
		t = fmt.Sprintf("Vendor %d AVP %d", hdr.VendorID, uint16(hdr.AvpType))
	}
	if hdr.isMandatory() {
		m = "M"
	}
	if hdr.isHidden() {
		h = "H"
	}
	return fmt.Sprintf("%s [%s%s]", t, m, h)
}
var _ fmt.Stringer = (*avpPayload)(nil)
func (p avpPayload) String() string {
	var str strings.Builder
	str.WriteString(fmt.Sprintf("(%s) ", p.dataType))
	switch p.dataType {
	case avpDataTypeUint16:
		v, _ := p.toUint16()
		str.WriteString(fmt.Sprintf("%d", v))
	case avpDataTypeUint32:
		v, _ := p.toUint32()
		str.WriteString(fmt.Sprintf("%d", v))
	case avpDataTypeUint64:
		v, _ := p.toUint64()
		str.WriteString(fmt.Sprintf("%d", v))
	case avpDataTypeString:
		s, _ := p.toString()
		str.WriteString(s)
	case avpDataTypeBytes:
		str.WriteString(fmt.Sprintf("%s", p.data))
	case avpDataTypeEmpty, avpDataTypeUnimplemented, avpDataTypeIllegal:
		str.WriteString("")
	}
	return str.String()
}
func (hdr *avpHeader) isMandatory() bool {
	return (0x8000 & hdr.FlagLen) == 0x8000
}
func (hdr *avpHeader) isHidden() bool {
	return (0x4000 & hdr.FlagLen) == 0x4000
}
func (hdr *avpHeader) totalLen() int {
	return int(0x3ff & hdr.FlagLen)
}
func (hdr *avpHeader) dataLen() int {
	return hdr.totalLen() - avpHeaderLen
}
func newAvpHeader(isMandatory, isHidden bool,
	payloadBytes uint,
	vid avpVendorID,
	typ avpType) *avpHeader {
	var flagLen avpFlagLen = 0x0
	if isMandatory {
		flagLen = flagLen ^ 0x8000
	}
	if isHidden {
		flagLen = flagLen ^ 0x4000
	}
	flagLen = flagLen ^ avpFlagLen(0x3ff&(payloadBytes+avpHeaderLen))
	return &avpHeader{
		FlagLen:  flagLen,
		VendorID: vid,
		AvpType:  typ,
	}
}
func (avp *avp) isMandatory() bool {
	return avp.header.isMandatory()
}
func (avp *avp) isHidden() bool {
	return avp.header.isHidden()
}