From 156c8511744b494c46a1d4e94762bb929325d412 Mon Sep 17 00:00:00 2001 From: Tim Cooper Date: Sat, 1 Aug 2020 13:58:50 -0500 Subject: [PATCH] add rfc5447 --- rfc5447/generate.go | 3 + rfc5447/generated.go | 183 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 186 insertions(+) create mode 100644 rfc5447/generate.go create mode 100644 rfc5447/generated.go diff --git a/rfc5447/generate.go b/rfc5447/generate.go new file mode 100644 index 0000000..6968dd5 --- /dev/null +++ b/rfc5447/generate.go @@ -0,0 +1,3 @@ +//go:generate go run ../cmd/radius-dict-gen/main.go -package rfc5447 -output generated.go /usr/share/freeradius/dictionary.rfc5447 + +package rfc5447 diff --git a/rfc5447/generated.go b/rfc5447/generated.go new file mode 100644 index 0000000..30ac5f3 --- /dev/null +++ b/rfc5447/generated.go @@ -0,0 +1,183 @@ +// Code generated by radius-dict-gen. DO NOT EDIT. + +package rfc5447 + +import ( + "strconv" + + "layeh.com/radius" +) + +const ( + MIP6FeatureVector_Type radius.Type = 124 + MIP6HomeLinkPrefix_Type radius.Type = 125 +) + +type MIP6FeatureVector uint64 + +var MIP6FeatureVector_Strings = map[MIP6FeatureVector]string{} + +func (a MIP6FeatureVector) String() string { + if str, ok := MIP6FeatureVector_Strings[a]; ok { + return str + } + return "MIP6FeatureVector(" + strconv.FormatUint(uint64(a), 10) + ")" +} + +func MIP6FeatureVector_Add(p *radius.Packet, value MIP6FeatureVector) (err error) { + a := radius.NewInteger64(uint64(value)) + p.Add(MIP6FeatureVector_Type, a) + return +} + +func MIP6FeatureVector_Get(p *radius.Packet) (value MIP6FeatureVector) { + value, _ = MIP6FeatureVector_Lookup(p) + return +} + +func MIP6FeatureVector_Gets(p *radius.Packet) (values []MIP6FeatureVector, err error) { + var i uint64 + for _, avp := range p.Attributes { + if avp.Type != MIP6FeatureVector_Type { + continue + } + attr := avp.Attribute + i, err = radius.Integer64(attr) + if err != nil { + return + } + values = append(values, MIP6FeatureVector(i)) + } + return +} + +func MIP6FeatureVector_Lookup(p *radius.Packet) (value MIP6FeatureVector, err error) { + a, ok := p.Lookup(MIP6FeatureVector_Type) + if !ok { + err = radius.ErrNoAttribute + return + } + var i uint64 + i, err = radius.Integer64(a) + if err != nil { + return + } + value = MIP6FeatureVector(i) + return +} + +func MIP6FeatureVector_Set(p *radius.Packet, value MIP6FeatureVector) (err error) { + a := radius.NewInteger64(uint64(value)) + p.Set(MIP6FeatureVector_Type, a) + return +} + +func MIP6FeatureVector_Del(p *radius.Packet) { + p.Attributes.Del(MIP6FeatureVector_Type) +} + +func MIP6HomeLinkPrefix_Add(p *radius.Packet, value []byte) (err error) { + var a radius.Attribute + a, err = radius.NewBytes(value) + if err != nil { + return + } + p.Add(MIP6HomeLinkPrefix_Type, a) + return +} + +func MIP6HomeLinkPrefix_AddString(p *radius.Packet, value string) (err error) { + var a radius.Attribute + a, err = radius.NewString(value) + if err != nil { + return + } + p.Add(MIP6HomeLinkPrefix_Type, a) + return +} + +func MIP6HomeLinkPrefix_Get(p *radius.Packet) (value []byte) { + value, _ = MIP6HomeLinkPrefix_Lookup(p) + return +} + +func MIP6HomeLinkPrefix_GetString(p *radius.Packet) (value string) { + value, _ = MIP6HomeLinkPrefix_LookupString(p) + return +} + +func MIP6HomeLinkPrefix_Gets(p *radius.Packet) (values [][]byte, err error) { + var i []byte + for _, avp := range p.Attributes { + if avp.Type != MIP6HomeLinkPrefix_Type { + continue + } + attr := avp.Attribute + i = radius.Bytes(attr) + if err != nil { + return + } + values = append(values, i) + } + return +} + +func MIP6HomeLinkPrefix_GetStrings(p *radius.Packet) (values []string, err error) { + var i string + for _, avp := range p.Attributes { + if avp.Type != MIP6HomeLinkPrefix_Type { + continue + } + attr := avp.Attribute + i = radius.String(attr) + if err != nil { + return + } + values = append(values, i) + } + return +} + +func MIP6HomeLinkPrefix_Lookup(p *radius.Packet) (value []byte, err error) { + a, ok := p.Lookup(MIP6HomeLinkPrefix_Type) + if !ok { + err = radius.ErrNoAttribute + return + } + value = radius.Bytes(a) + return +} + +func MIP6HomeLinkPrefix_LookupString(p *radius.Packet) (value string, err error) { + a, ok := p.Lookup(MIP6HomeLinkPrefix_Type) + if !ok { + err = radius.ErrNoAttribute + return + } + value = radius.String(a) + return +} + +func MIP6HomeLinkPrefix_Set(p *radius.Packet, value []byte) (err error) { + var a radius.Attribute + a, err = radius.NewBytes(value) + if err != nil { + return + } + p.Set(MIP6HomeLinkPrefix_Type, a) + return +} + +func MIP6HomeLinkPrefix_SetString(p *radius.Packet, value string) (err error) { + var a radius.Attribute + a, err = radius.NewString(value) + if err != nil { + return + } + p.Set(MIP6HomeLinkPrefix_Type, a) + return +} + +func MIP6HomeLinkPrefix_Del(p *radius.Packet) { + p.Attributes.Del(MIP6HomeLinkPrefix_Type) +}