package cosine

import (
	"net"
	"strconv"

	"layeh.com/radius"
	"layeh.com/radius/rfc2865"
)

const (
	_Cosine_VendorID = 3085
)

func _Cosine_AddVendor(p *radius.Packet, typ byte, attr radius.Attribute) (err error) {
	var vsa radius.Attribute
	vendor := make(radius.Attribute, 2+len(attr))
	vendor[0] = typ
	vendor[1] = byte(len(vendor))
	copy(vendor[2:], attr)
	vsa, err = radius.NewVendorSpecific(_Cosine_VendorID, vendor)
	if err != nil {
		return
	}
	p.Add(rfc2865.VendorSpecific_Type, vsa)
	return
}

func _Cosine_GetsVendor(p *radius.Packet, typ byte) (values []radius.Attribute) {
	for _, avp := range p.Attributes {
		if avp.Type != rfc2865.VendorSpecific_Type {
			continue
		}
		attr := avp.Attribute
		vendorID, vsa, err := radius.VendorSpecific(attr)
		if err != nil || vendorID != _Cosine_VendorID {
			continue
		}
		for len(vsa) >= 3 {
			vsaTyp, vsaLen := vsa[0], vsa[1]
			if int(vsaLen) > len(vsa) || vsaLen < 3 {
				break
			}
			if vsaTyp == typ {
				values = append(values, vsa[2:int(vsaLen)])
			}
			vsa = vsa[int(vsaLen):]
		}
	}
	return
}

func _Cosine_LookupVendor(p *radius.Packet, typ byte) (attr radius.Attribute, ok bool) {
	for _, avp := range p.Attributes {
		if avp.Type != rfc2865.VendorSpecific_Type {
			continue
		}
		attr := avp.Attribute
		vendorID, vsa, err := radius.VendorSpecific(attr)
		if err != nil || vendorID != _Cosine_VendorID {
			continue
		}
		for len(vsa) >= 3 {
			vsaTyp, vsaLen := vsa[0], vsa[1]
			if int(vsaLen) > len(vsa) || vsaLen < 3 {
				break
			}
			if vsaTyp == typ {
				return vsa[2:int(vsaLen)], true
			}
			vsa = vsa[int(vsaLen):]
		}
	}
	return
}

func _Cosine_SetVendor(p *radius.Packet, typ byte, attr radius.Attribute) (err error) {
	for i := 0; i < len(p.Attributes); {
		avp := p.Attributes[i]
		if avp.Type != rfc2865.VendorSpecific_Type {
			i++
			continue
		}
		vendorID, vsa, err := radius.VendorSpecific(avp.Attribute)
		if err != nil || vendorID != _Cosine_VendorID {
			i++
			continue
		}
		for j := 0; len(vsa[j:]) >= 3; {
			vsaTyp, vsaLen := vsa[0], vsa[1]
			if int(vsaLen) > len(vsa[j:]) || vsaLen < 3 {
				i++
				break
			}
			if vsaTyp == typ {
				vsa = append(vsa[:j], vsa[j+int(vsaLen):]...)
			}
			j += int(vsaLen)
		}
		if len(vsa) > 0 {
			copy(avp.Attribute[4:], vsa)
			i++
		} else {
			p.Attributes = append(p.Attributes[:i], p.Attributes[i+i:]...)
		}
	}
	return _Cosine_AddVendor(p, typ, attr)
}

func _Cosine_DelVendor(p *radius.Packet, typ byte) {
vsaLoop:
	for i := 0; i < len(p.Attributes); {
		avp := p.Attributes[i]
		if avp.Type != rfc2865.VendorSpecific_Type {
			i++
			continue
		}
		vendorID, vsa, err := radius.VendorSpecific(avp.Attribute)
		if err != nil || vendorID != _Cosine_VendorID {
			i++
			continue
		}
		offset := 0
		for len(vsa[offset:]) >= 3 {
			vsaTyp, vsaLen := vsa[offset], vsa[offset+1]
			if int(vsaLen) > len(vsa) || vsaLen < 3 {
				continue vsaLoop
			}
			if vsaTyp == typ {
				copy(vsa[offset:], vsa[offset+int(vsaLen):])
				vsa = vsa[:len(vsa)-int(vsaLen)]
			} else {
				offset += int(vsaLen)
			}
		}
		if offset == 0 {
			p.Attributes = append(p.Attributes[:i], p.Attributes[i+1:]...)
		} else {
			i++
		}
	}
	return
}

func CosineConnectionProfileName_Add(p *radius.Packet, value []byte) (err error) {
	var a radius.Attribute
	a, err = radius.NewBytes(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 1, a)
}

func CosineConnectionProfileName_AddString(p *radius.Packet, value string) (err error) {
	var a radius.Attribute
	a, err = radius.NewString(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 1, a)
}

func CosineConnectionProfileName_Get(p *radius.Packet) (value []byte) {
	value, _ = CosineConnectionProfileName_Lookup(p)
	return
}

func CosineConnectionProfileName_GetString(p *radius.Packet) (value string) {
	value, _ = CosineConnectionProfileName_LookupString(p)
	return
}

func CosineConnectionProfileName_Gets(p *radius.Packet) (values [][]byte, err error) {
	var i []byte
	for _, attr := range _Cosine_GetsVendor(p, 1) {
		i = radius.Bytes(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineConnectionProfileName_GetStrings(p *radius.Packet) (values []string, err error) {
	var i string
	for _, attr := range _Cosine_GetsVendor(p, 1) {
		i = radius.String(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineConnectionProfileName_Lookup(p *radius.Packet) (value []byte, err error) {
	a, ok := _Cosine_LookupVendor(p, 1)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value = radius.Bytes(a)
	return
}

func CosineConnectionProfileName_LookupString(p *radius.Packet) (value string, err error) {
	a, ok := _Cosine_LookupVendor(p, 1)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value = radius.String(a)
	return
}

func CosineConnectionProfileName_Set(p *radius.Packet, value []byte) (err error) {
	var a radius.Attribute
	a, err = radius.NewBytes(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 1, a)
}

func CosineConnectionProfileName_SetString(p *radius.Packet, value string) (err error) {
	var a radius.Attribute
	a, err = radius.NewString(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 1, a)
}

func CosineConnectionProfileName_Del(p *radius.Packet) {
	_Cosine_DelVendor(p, 1)
}

func CosineEnterpriseID_Add(p *radius.Packet, value []byte) (err error) {
	var a radius.Attribute
	a, err = radius.NewBytes(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 2, a)
}

func CosineEnterpriseID_AddString(p *radius.Packet, value string) (err error) {
	var a radius.Attribute
	a, err = radius.NewString(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 2, a)
}

func CosineEnterpriseID_Get(p *radius.Packet) (value []byte) {
	value, _ = CosineEnterpriseID_Lookup(p)
	return
}

func CosineEnterpriseID_GetString(p *radius.Packet) (value string) {
	value, _ = CosineEnterpriseID_LookupString(p)
	return
}

func CosineEnterpriseID_Gets(p *radius.Packet) (values [][]byte, err error) {
	var i []byte
	for _, attr := range _Cosine_GetsVendor(p, 2) {
		i = radius.Bytes(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineEnterpriseID_GetStrings(p *radius.Packet) (values []string, err error) {
	var i string
	for _, attr := range _Cosine_GetsVendor(p, 2) {
		i = radius.String(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineEnterpriseID_Lookup(p *radius.Packet) (value []byte, err error) {
	a, ok := _Cosine_LookupVendor(p, 2)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value = radius.Bytes(a)
	return
}

func CosineEnterpriseID_LookupString(p *radius.Packet) (value string, err error) {
	a, ok := _Cosine_LookupVendor(p, 2)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value = radius.String(a)
	return
}

func CosineEnterpriseID_Set(p *radius.Packet, value []byte) (err error) {
	var a radius.Attribute
	a, err = radius.NewBytes(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 2, a)
}

func CosineEnterpriseID_SetString(p *radius.Packet, value string) (err error) {
	var a radius.Attribute
	a, err = radius.NewString(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 2, a)
}

func CosineEnterpriseID_Del(p *radius.Packet) {
	_Cosine_DelVendor(p, 2)
}

func CosineAddressPoolName_Add(p *radius.Packet, value []byte) (err error) {
	var a radius.Attribute
	a, err = radius.NewBytes(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 3, a)
}

func CosineAddressPoolName_AddString(p *radius.Packet, value string) (err error) {
	var a radius.Attribute
	a, err = radius.NewString(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 3, a)
}

func CosineAddressPoolName_Get(p *radius.Packet) (value []byte) {
	value, _ = CosineAddressPoolName_Lookup(p)
	return
}

func CosineAddressPoolName_GetString(p *radius.Packet) (value string) {
	value, _ = CosineAddressPoolName_LookupString(p)
	return
}

func CosineAddressPoolName_Gets(p *radius.Packet) (values [][]byte, err error) {
	var i []byte
	for _, attr := range _Cosine_GetsVendor(p, 3) {
		i = radius.Bytes(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineAddressPoolName_GetStrings(p *radius.Packet) (values []string, err error) {
	var i string
	for _, attr := range _Cosine_GetsVendor(p, 3) {
		i = radius.String(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineAddressPoolName_Lookup(p *radius.Packet) (value []byte, err error) {
	a, ok := _Cosine_LookupVendor(p, 3)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value = radius.Bytes(a)
	return
}

func CosineAddressPoolName_LookupString(p *radius.Packet) (value string, err error) {
	a, ok := _Cosine_LookupVendor(p, 3)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value = radius.String(a)
	return
}

func CosineAddressPoolName_Set(p *radius.Packet, value []byte) (err error) {
	var a radius.Attribute
	a, err = radius.NewBytes(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 3, a)
}

func CosineAddressPoolName_SetString(p *radius.Packet, value string) (err error) {
	var a radius.Attribute
	a, err = radius.NewString(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 3, a)
}

func CosineAddressPoolName_Del(p *radius.Packet) {
	_Cosine_DelVendor(p, 3)
}

type CosineDSByte uint32

var CosineDSByte_Strings = map[CosineDSByte]string{}

func (a CosineDSByte) String() string {
	if str, ok := CosineDSByte_Strings[a]; ok {
		return str
	}
	return "CosineDSByte(" + strconv.FormatUint(uint64(a), 10) + ")"
}

func CosineDSByte_Add(p *radius.Packet, value CosineDSByte) (err error) {
	a := radius.NewInteger(uint32(value))
	return _Cosine_AddVendor(p, 4, a)
}

func CosineDSByte_Get(p *radius.Packet) (value CosineDSByte) {
	value, _ = CosineDSByte_Lookup(p)
	return
}

func CosineDSByte_Gets(p *radius.Packet) (values []CosineDSByte, err error) {
	var i uint32
	for _, attr := range _Cosine_GetsVendor(p, 4) {
		i, err = radius.Integer(attr)
		if err != nil {
			return
		}
		values = append(values, CosineDSByte(i))
	}
	return
}

func CosineDSByte_Lookup(p *radius.Packet) (value CosineDSByte, err error) {
	a, ok := _Cosine_LookupVendor(p, 4)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	var i uint32
	i, err = radius.Integer(a)
	if err != nil {
		return
	}
	value = CosineDSByte(i)
	return
}

func CosineDSByte_Set(p *radius.Packet, value CosineDSByte) (err error) {
	a := radius.NewInteger(uint32(value))
	return _Cosine_SetVendor(p, 4, a)
}

func CosineDSByte_Del(p *radius.Packet) {
	_Cosine_DelVendor(p, 4)
}

func CosineVPIVCI_Add(p *radius.Packet, value []byte) (err error) {
	var a radius.Attribute
	a, err = radius.NewBytes(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 5, a)
}

func CosineVPIVCI_AddString(p *radius.Packet, value string) (err error) {
	var a radius.Attribute
	a, err = radius.NewString(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 5, a)
}

func CosineVPIVCI_Get(p *radius.Packet) (value []byte) {
	value, _ = CosineVPIVCI_Lookup(p)
	return
}

func CosineVPIVCI_GetString(p *radius.Packet) (value string) {
	value, _ = CosineVPIVCI_LookupString(p)
	return
}

func CosineVPIVCI_Gets(p *radius.Packet) (values [][]byte, err error) {
	var i []byte
	for _, attr := range _Cosine_GetsVendor(p, 5) {
		i = radius.Bytes(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineVPIVCI_GetStrings(p *radius.Packet) (values []string, err error) {
	var i string
	for _, attr := range _Cosine_GetsVendor(p, 5) {
		i = radius.String(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineVPIVCI_Lookup(p *radius.Packet) (value []byte, err error) {
	a, ok := _Cosine_LookupVendor(p, 5)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value = radius.Bytes(a)
	return
}

func CosineVPIVCI_LookupString(p *radius.Packet) (value string, err error) {
	a, ok := _Cosine_LookupVendor(p, 5)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value = radius.String(a)
	return
}

func CosineVPIVCI_Set(p *radius.Packet, value []byte) (err error) {
	var a radius.Attribute
	a, err = radius.NewBytes(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 5, a)
}

func CosineVPIVCI_SetString(p *radius.Packet, value string) (err error) {
	var a radius.Attribute
	a, err = radius.NewString(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 5, a)
}

func CosineVPIVCI_Del(p *radius.Packet) {
	_Cosine_DelVendor(p, 5)
}

type CosineDLCI uint32

var CosineDLCI_Strings = map[CosineDLCI]string{}

func (a CosineDLCI) String() string {
	if str, ok := CosineDLCI_Strings[a]; ok {
		return str
	}
	return "CosineDLCI(" + strconv.FormatUint(uint64(a), 10) + ")"
}

func CosineDLCI_Add(p *radius.Packet, value CosineDLCI) (err error) {
	a := radius.NewInteger(uint32(value))
	return _Cosine_AddVendor(p, 6, a)
}

func CosineDLCI_Get(p *radius.Packet) (value CosineDLCI) {
	value, _ = CosineDLCI_Lookup(p)
	return
}

func CosineDLCI_Gets(p *radius.Packet) (values []CosineDLCI, err error) {
	var i uint32
	for _, attr := range _Cosine_GetsVendor(p, 6) {
		i, err = radius.Integer(attr)
		if err != nil {
			return
		}
		values = append(values, CosineDLCI(i))
	}
	return
}

func CosineDLCI_Lookup(p *radius.Packet) (value CosineDLCI, err error) {
	a, ok := _Cosine_LookupVendor(p, 6)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	var i uint32
	i, err = radius.Integer(a)
	if err != nil {
		return
	}
	value = CosineDLCI(i)
	return
}

func CosineDLCI_Set(p *radius.Packet, value CosineDLCI) (err error) {
	a := radius.NewInteger(uint32(value))
	return _Cosine_SetVendor(p, 6, a)
}

func CosineDLCI_Del(p *radius.Packet) {
	_Cosine_DelVendor(p, 6)
}

func CosineLNSIPAddress_Add(p *radius.Packet, value net.IP) (err error) {
	var a radius.Attribute
	a, err = radius.NewIPAddr(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 7, a)
}

func CosineLNSIPAddress_Get(p *radius.Packet) (value net.IP) {
	value, _ = CosineLNSIPAddress_Lookup(p)
	return
}

func CosineLNSIPAddress_Gets(p *radius.Packet) (values []net.IP, err error) {
	var i net.IP
	for _, attr := range _Cosine_GetsVendor(p, 7) {
		i, err = radius.IPAddr(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineLNSIPAddress_Lookup(p *radius.Packet) (value net.IP, err error) {
	a, ok := _Cosine_LookupVendor(p, 7)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value, err = radius.IPAddr(a)
	return
}

func CosineLNSIPAddress_Set(p *radius.Packet, value net.IP) (err error) {
	var a radius.Attribute
	a, err = radius.NewIPAddr(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 7, a)
}

func CosineLNSIPAddress_Del(p *radius.Packet) {
	_Cosine_DelVendor(p, 7)
}

func CosineCLIUserPermissionID_Add(p *radius.Packet, value []byte) (err error) {
	var a radius.Attribute
	a, err = radius.NewBytes(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 8, a)
}

func CosineCLIUserPermissionID_AddString(p *radius.Packet, value string) (err error) {
	var a radius.Attribute
	a, err = radius.NewString(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 8, a)
}

func CosineCLIUserPermissionID_Get(p *radius.Packet) (value []byte) {
	value, _ = CosineCLIUserPermissionID_Lookup(p)
	return
}

func CosineCLIUserPermissionID_GetString(p *radius.Packet) (value string) {
	value, _ = CosineCLIUserPermissionID_LookupString(p)
	return
}

func CosineCLIUserPermissionID_Gets(p *radius.Packet) (values [][]byte, err error) {
	var i []byte
	for _, attr := range _Cosine_GetsVendor(p, 8) {
		i = radius.Bytes(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineCLIUserPermissionID_GetStrings(p *radius.Packet) (values []string, err error) {
	var i string
	for _, attr := range _Cosine_GetsVendor(p, 8) {
		i = radius.String(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineCLIUserPermissionID_Lookup(p *radius.Packet) (value []byte, err error) {
	a, ok := _Cosine_LookupVendor(p, 8)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value = radius.Bytes(a)
	return
}

func CosineCLIUserPermissionID_LookupString(p *radius.Packet) (value string, err error) {
	a, ok := _Cosine_LookupVendor(p, 8)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value = radius.String(a)
	return
}

func CosineCLIUserPermissionID_Set(p *radius.Packet, value []byte) (err error) {
	var a radius.Attribute
	a, err = radius.NewBytes(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 8, a)
}

func CosineCLIUserPermissionID_SetString(p *radius.Packet, value string) (err error) {
	var a radius.Attribute
	a, err = radius.NewString(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 8, a)
}

func CosineCLIUserPermissionID_Del(p *radius.Packet) {
	_Cosine_DelVendor(p, 8)
}
// Code generated by radius-dict-gen. DO NOT EDIT.

package cosine

import (
	"net"
	"strconv"

	"layeh.com/radius"
	"layeh.com/radius/rfc2865"
)

const (
	_Cosine_VendorID = 3085
)

func _Cosine_AddVendor(p *radius.Packet, typ byte, attr radius.Attribute) (err error) {
	var vsa radius.Attribute
	vendor := make(radius.Attribute, 2+len(attr))
	vendor[0] = typ
	vendor[1] = byte(len(vendor))
	copy(vendor[2:], attr)
	vsa, err = radius.NewVendorSpecific(_Cosine_VendorID, vendor)
	if err != nil {
		return
	}
	p.Add(rfc2865.VendorSpecific_Type, vsa)
	return
}

func _Cosine_GetsVendor(p *radius.Packet, typ byte) (values []radius.Attribute) {
	for _, avp := range p.Attributes {
		if avp.Type != rfc2865.VendorSpecific_Type {
			continue
		}
		attr := avp.Attribute
		vendorID, vsa, err := radius.VendorSpecific(attr)
		if err != nil || vendorID != _Cosine_VendorID {
			continue
		}
		for len(vsa) >= 3 {
			vsaTyp, vsaLen := vsa[0], vsa[1]
			if int(vsaLen) > len(vsa) || vsaLen < 3 {
				break
			}
			if vsaTyp == typ {
				values = append(values, vsa[2:int(vsaLen)])
			}
			vsa = vsa[int(vsaLen):]
		}
	}
	return
}

func _Cosine_LookupVendor(p *radius.Packet, typ byte) (attr radius.Attribute, ok bool) {
	for _, avp := range p.Attributes {
		if avp.Type != rfc2865.VendorSpecific_Type {
			continue
		}
		attr := avp.Attribute
		vendorID, vsa, err := radius.VendorSpecific(attr)
		if err != nil || vendorID != _Cosine_VendorID {
			continue
		}
		for len(vsa) >= 3 {
			vsaTyp, vsaLen := vsa[0], vsa[1]
			if int(vsaLen) > len(vsa) || vsaLen < 3 {
				break
			}
			if vsaTyp == typ {
				return vsa[2:int(vsaLen)], true
			}
			vsa = vsa[int(vsaLen):]
		}
	}
	return
}

func _Cosine_SetVendor(p *radius.Packet, typ byte, attr radius.Attribute) (err error) {
	for i := 0; i < len(p.Attributes); {
		avp := p.Attributes[i]
		if avp.Type != rfc2865.VendorSpecific_Type {
			i++
			continue
		}
		vendorID, vsa, err := radius.VendorSpecific(avp.Attribute)
		if err != nil || vendorID != _Cosine_VendorID {
			i++
			continue
		}
		for j := 0; len(vsa[j:]) >= 3; {
			vsaTyp, vsaLen := vsa[0], vsa[1]
			if int(vsaLen) > len(vsa[j:]) || vsaLen < 3 {
				i++
				break
			}
			if vsaTyp == typ {
				vsa = append(vsa[:j], vsa[j+int(vsaLen):]...)
			}
			j += int(vsaLen)
		}
		if len(vsa) > 0 {
			copy(avp.Attribute[4:], vsa)
			i++
		} else {
			p.Attributes = append(p.Attributes[:i], p.Attributes[i+i:]...)
		}
	}
	return _Cosine_AddVendor(p, typ, attr)
}

func _Cosine_DelVendor(p *radius.Packet, typ byte) {
vsaLoop:
	for i := 0; i < len(p.Attributes); {
		avp := p.Attributes[i]
		if avp.Type != rfc2865.VendorSpecific_Type {
			i++
			continue
		}
		vendorID, vsa, err := radius.VendorSpecific(avp.Attribute)
		if err != nil || vendorID != _Cosine_VendorID {
			i++
			continue
		}
		offset := 0
		for len(vsa[offset:]) >= 3 {
			vsaTyp, vsaLen := vsa[offset], vsa[offset+1]
			if int(vsaLen) > len(vsa) || vsaLen < 3 {
				continue vsaLoop
			}
			if vsaTyp == typ {
				copy(vsa[offset:], vsa[offset+int(vsaLen):])
				vsa = vsa[:len(vsa)-int(vsaLen)]
			} else {
				offset += int(vsaLen)
			}
		}
		if offset == 0 {
			p.Attributes = append(p.Attributes[:i], p.Attributes[i+1:]...)
		} else {
			i++
		}
	}
	return
}

func CosineConnectionProfileName_Add(p *radius.Packet, value []byte) (err error) {
	var a radius.Attribute
	a, err = radius.NewBytes(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 1, a)
}

func CosineConnectionProfileName_AddString(p *radius.Packet, value string) (err error) {
	var a radius.Attribute
	a, err = radius.NewString(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 1, a)
}

func CosineConnectionProfileName_Get(p *radius.Packet) (value []byte) {
	value, _ = CosineConnectionProfileName_Lookup(p)
	return
}

func CosineConnectionProfileName_GetString(p *radius.Packet) (value string) {
	value, _ = CosineConnectionProfileName_LookupString(p)
	return
}

func CosineConnectionProfileName_Gets(p *radius.Packet) (values [][]byte, err error) {
	var i []byte
	for _, attr := range _Cosine_GetsVendor(p, 1) {
		i = radius.Bytes(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineConnectionProfileName_GetStrings(p *radius.Packet) (values []string, err error) {
	var i string
	for _, attr := range _Cosine_GetsVendor(p, 1) {
		i = radius.String(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineConnectionProfileName_Lookup(p *radius.Packet) (value []byte, err error) {
	a, ok := _Cosine_LookupVendor(p, 1)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value = radius.Bytes(a)
	return
}

func CosineConnectionProfileName_LookupString(p *radius.Packet) (value string, err error) {
	a, ok := _Cosine_LookupVendor(p, 1)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value = radius.String(a)
	return
}

func CosineConnectionProfileName_Set(p *radius.Packet, value []byte) (err error) {
	var a radius.Attribute
	a, err = radius.NewBytes(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 1, a)
}

func CosineConnectionProfileName_SetString(p *radius.Packet, value string) (err error) {
	var a radius.Attribute
	a, err = radius.NewString(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 1, a)
}

func CosineConnectionProfileName_Del(p *radius.Packet) {
	_Cosine_DelVendor(p, 1)
}

func CosineEnterpriseID_Add(p *radius.Packet, value []byte) (err error) {
	var a radius.Attribute
	a, err = radius.NewBytes(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 2, a)
}

func CosineEnterpriseID_AddString(p *radius.Packet, value string) (err error) {
	var a radius.Attribute
	a, err = radius.NewString(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 2, a)
}

func CosineEnterpriseID_Get(p *radius.Packet) (value []byte) {
	value, _ = CosineEnterpriseID_Lookup(p)
	return
}

func CosineEnterpriseID_GetString(p *radius.Packet) (value string) {
	value, _ = CosineEnterpriseID_LookupString(p)
	return
}

func CosineEnterpriseID_Gets(p *radius.Packet) (values [][]byte, err error) {
	var i []byte
	for _, attr := range _Cosine_GetsVendor(p, 2) {
		i = radius.Bytes(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineEnterpriseID_GetStrings(p *radius.Packet) (values []string, err error) {
	var i string
	for _, attr := range _Cosine_GetsVendor(p, 2) {
		i = radius.String(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineEnterpriseID_Lookup(p *radius.Packet) (value []byte, err error) {
	a, ok := _Cosine_LookupVendor(p, 2)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value = radius.Bytes(a)
	return
}

func CosineEnterpriseID_LookupString(p *radius.Packet) (value string, err error) {
	a, ok := _Cosine_LookupVendor(p, 2)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value = radius.String(a)
	return
}

func CosineEnterpriseID_Set(p *radius.Packet, value []byte) (err error) {
	var a radius.Attribute
	a, err = radius.NewBytes(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 2, a)
}

func CosineEnterpriseID_SetString(p *radius.Packet, value string) (err error) {
	var a radius.Attribute
	a, err = radius.NewString(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 2, a)
}

func CosineEnterpriseID_Del(p *radius.Packet) {
	_Cosine_DelVendor(p, 2)
}

func CosineAddressPoolName_Add(p *radius.Packet, value []byte) (err error) {
	var a radius.Attribute
	a, err = radius.NewBytes(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 3, a)
}

func CosineAddressPoolName_AddString(p *radius.Packet, value string) (err error) {
	var a radius.Attribute
	a, err = radius.NewString(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 3, a)
}

func CosineAddressPoolName_Get(p *radius.Packet) (value []byte) {
	value, _ = CosineAddressPoolName_Lookup(p)
	return
}

func CosineAddressPoolName_GetString(p *radius.Packet) (value string) {
	value, _ = CosineAddressPoolName_LookupString(p)
	return
}

func CosineAddressPoolName_Gets(p *radius.Packet) (values [][]byte, err error) {
	var i []byte
	for _, attr := range _Cosine_GetsVendor(p, 3) {
		i = radius.Bytes(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineAddressPoolName_GetStrings(p *radius.Packet) (values []string, err error) {
	var i string
	for _, attr := range _Cosine_GetsVendor(p, 3) {
		i = radius.String(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineAddressPoolName_Lookup(p *radius.Packet) (value []byte, err error) {
	a, ok := _Cosine_LookupVendor(p, 3)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value = radius.Bytes(a)
	return
}

func CosineAddressPoolName_LookupString(p *radius.Packet) (value string, err error) {
	a, ok := _Cosine_LookupVendor(p, 3)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value = radius.String(a)
	return
}

func CosineAddressPoolName_Set(p *radius.Packet, value []byte) (err error) {
	var a radius.Attribute
	a, err = radius.NewBytes(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 3, a)
}

func CosineAddressPoolName_SetString(p *radius.Packet, value string) (err error) {
	var a radius.Attribute
	a, err = radius.NewString(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 3, a)
}

func CosineAddressPoolName_Del(p *radius.Packet) {
	_Cosine_DelVendor(p, 3)
}

type CosineDSByte uint32

var CosineDSByte_Strings = map[CosineDSByte]string{}

func (a CosineDSByte) String() string {
	if str, ok := CosineDSByte_Strings[a]; ok {
		return str
	}
	return "CosineDSByte(" + strconv.FormatUint(uint64(a), 10) + ")"
}

func CosineDSByte_Add(p *radius.Packet, value CosineDSByte) (err error) {
	a := radius.NewInteger(uint32(value))
	return _Cosine_AddVendor(p, 4, a)
}

func CosineDSByte_Get(p *radius.Packet) (value CosineDSByte) {
	value, _ = CosineDSByte_Lookup(p)
	return
}

func CosineDSByte_Gets(p *radius.Packet) (values []CosineDSByte, err error) {
	var i uint32
	for _, attr := range _Cosine_GetsVendor(p, 4) {
		i, err = radius.Integer(attr)
		if err != nil {
			return
		}
		values = append(values, CosineDSByte(i))
	}
	return
}

func CosineDSByte_Lookup(p *radius.Packet) (value CosineDSByte, err error) {
	a, ok := _Cosine_LookupVendor(p, 4)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	var i uint32
	i, err = radius.Integer(a)
	if err != nil {
		return
	}
	value = CosineDSByte(i)
	return
}

func CosineDSByte_Set(p *radius.Packet, value CosineDSByte) (err error) {
	a := radius.NewInteger(uint32(value))
	return _Cosine_SetVendor(p, 4, a)
}

func CosineDSByte_Del(p *radius.Packet) {
	_Cosine_DelVendor(p, 4)
}

func CosineVPIVCI_Add(p *radius.Packet, value []byte) (err error) {
	var a radius.Attribute
	a, err = radius.NewBytes(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 5, a)
}

func CosineVPIVCI_AddString(p *radius.Packet, value string) (err error) {
	var a radius.Attribute
	a, err = radius.NewString(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 5, a)
}

func CosineVPIVCI_Get(p *radius.Packet) (value []byte) {
	value, _ = CosineVPIVCI_Lookup(p)
	return
}

func CosineVPIVCI_GetString(p *radius.Packet) (value string) {
	value, _ = CosineVPIVCI_LookupString(p)
	return
}

func CosineVPIVCI_Gets(p *radius.Packet) (values [][]byte, err error) {
	var i []byte
	for _, attr := range _Cosine_GetsVendor(p, 5) {
		i = radius.Bytes(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineVPIVCI_GetStrings(p *radius.Packet) (values []string, err error) {
	var i string
	for _, attr := range _Cosine_GetsVendor(p, 5) {
		i = radius.String(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineVPIVCI_Lookup(p *radius.Packet) (value []byte, err error) {
	a, ok := _Cosine_LookupVendor(p, 5)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value = radius.Bytes(a)
	return
}

func CosineVPIVCI_LookupString(p *radius.Packet) (value string, err error) {
	a, ok := _Cosine_LookupVendor(p, 5)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value = radius.String(a)
	return
}

func CosineVPIVCI_Set(p *radius.Packet, value []byte) (err error) {
	var a radius.Attribute
	a, err = radius.NewBytes(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 5, a)
}

func CosineVPIVCI_SetString(p *radius.Packet, value string) (err error) {
	var a radius.Attribute
	a, err = radius.NewString(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 5, a)
}

func CosineVPIVCI_Del(p *radius.Packet) {
	_Cosine_DelVendor(p, 5)
}

type CosineDLCI uint32

var CosineDLCI_Strings = map[CosineDLCI]string{}

func (a CosineDLCI) String() string {
	if str, ok := CosineDLCI_Strings[a]; ok {
		return str
	}
	return "CosineDLCI(" + strconv.FormatUint(uint64(a), 10) + ")"
}

func CosineDLCI_Add(p *radius.Packet, value CosineDLCI) (err error) {
	a := radius.NewInteger(uint32(value))
	return _Cosine_AddVendor(p, 6, a)
}

func CosineDLCI_Get(p *radius.Packet) (value CosineDLCI) {
	value, _ = CosineDLCI_Lookup(p)
	return
}

func CosineDLCI_Gets(p *radius.Packet) (values []CosineDLCI, err error) {
	var i uint32
	for _, attr := range _Cosine_GetsVendor(p, 6) {
		i, err = radius.Integer(attr)
		if err != nil {
			return
		}
		values = append(values, CosineDLCI(i))
	}
	return
}

func CosineDLCI_Lookup(p *radius.Packet) (value CosineDLCI, err error) {
	a, ok := _Cosine_LookupVendor(p, 6)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	var i uint32
	i, err = radius.Integer(a)
	if err != nil {
		return
	}
	value = CosineDLCI(i)
	return
}

func CosineDLCI_Set(p *radius.Packet, value CosineDLCI) (err error) {
	a := radius.NewInteger(uint32(value))
	return _Cosine_SetVendor(p, 6, a)
}

func CosineDLCI_Del(p *radius.Packet) {
	_Cosine_DelVendor(p, 6)
}

func CosineLNSIPAddress_Add(p *radius.Packet, value net.IP) (err error) {
	var a radius.Attribute
	a, err = radius.NewIPAddr(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 7, a)
}

func CosineLNSIPAddress_Get(p *radius.Packet) (value net.IP) {
	value, _ = CosineLNSIPAddress_Lookup(p)
	return
}

func CosineLNSIPAddress_Gets(p *radius.Packet) (values []net.IP, err error) {
	var i net.IP
	for _, attr := range _Cosine_GetsVendor(p, 7) {
		i, err = radius.IPAddr(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineLNSIPAddress_Lookup(p *radius.Packet) (value net.IP, err error) {
	a, ok := _Cosine_LookupVendor(p, 7)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value, err = radius.IPAddr(a)
	return
}

func CosineLNSIPAddress_Set(p *radius.Packet, value net.IP) (err error) {
	var a radius.Attribute
	a, err = radius.NewIPAddr(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 7, a)
}

func CosineLNSIPAddress_Del(p *radius.Packet) {
	_Cosine_DelVendor(p, 7)
}

func CosineCLIUserPermissionID_Add(p *radius.Packet, value []byte) (err error) {
	var a radius.Attribute
	a, err = radius.NewBytes(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 8, a)
}

func CosineCLIUserPermissionID_AddString(p *radius.Packet, value string) (err error) {
	var a radius.Attribute
	a, err = radius.NewString(value)
	if err != nil {
		return
	}
	return _Cosine_AddVendor(p, 8, a)
}

func CosineCLIUserPermissionID_Get(p *radius.Packet) (value []byte) {
	value, _ = CosineCLIUserPermissionID_Lookup(p)
	return
}

func CosineCLIUserPermissionID_GetString(p *radius.Packet) (value string) {
	value, _ = CosineCLIUserPermissionID_LookupString(p)
	return
}

func CosineCLIUserPermissionID_Gets(p *radius.Packet) (values [][]byte, err error) {
	var i []byte
	for _, attr := range _Cosine_GetsVendor(p, 8) {
		i = radius.Bytes(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineCLIUserPermissionID_GetStrings(p *radius.Packet) (values []string, err error) {
	var i string
	for _, attr := range _Cosine_GetsVendor(p, 8) {
		i = radius.String(attr)
		if err != nil {
			return
		}
		values = append(values, i)
	}
	return
}

func CosineCLIUserPermissionID_Lookup(p *radius.Packet) (value []byte, err error) {
	a, ok := _Cosine_LookupVendor(p, 8)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value = radius.Bytes(a)
	return
}

func CosineCLIUserPermissionID_LookupString(p *radius.Packet) (value string, err error) {
	a, ok := _Cosine_LookupVendor(p, 8)
	if !ok {
		err = radius.ErrNoAttribute
		return
	}
	value = radius.String(a)
	return
}

func CosineCLIUserPermissionID_Set(p *radius.Packet, value []byte) (err error) {
	var a radius.Attribute
	a, err = radius.NewBytes(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 8, a)
}

func CosineCLIUserPermissionID_SetString(p *radius.Packet, value string) (err error) {
	var a radius.Attribute
	a, err = radius.NewString(value)
	if err != nil {
		return
	}
	return _Cosine_SetVendor(p, 8, a)
}

func CosineCLIUserPermissionID_Del(p *radius.Packet) {
	_Cosine_DelVendor(p, 8)
}
