Closed eugennicoara closed 2 years ago
Here's what I did to solve this problem:
Sample code:
// Encode creates a 2 bytes slice encoding an uint16 value. func Encode(i uint16) []byte { v := make([]byte, 2) binary.BigEndian.PutUint16(v, i) return v } // Decode creates a uint16 value from a 2 bytes slice. func Decode(v []byte)uint16 { return binary.BigEndian.Uint16(v) } func _Starent_AddVendor(p *radius.Packet, typ uint16, attr radius.Attribute) (err error) {// typ is unit16 now instead of byte var vsa radius.Attribute vendor := make(radius.Attribute, 2+2+len(attr)) // this is 2+2+attribute length bytes now copy(vendor[0:], Encode(typ)) // this is 2 bytes now copy(vendor[2:], Encode(uint16(len(vendor)))) // this is 2 bytes now copy(vendor[4:], attr) vsa, err = radius.NewVendorSpecific(_Starent_VendorID, vendor) if err != nil { return } p.Add(rfc2865.VendorSpecific_Type, vsa) return }
I'm trying to generate code from Starent vendor-specific dictionary stored on the local fs as dictionary.starent and I'm getting the following error:
radius-dict-gen -output starent_generated.go -package dictionary dictionary.starent
radius-dict-gen: dictionarygen: cannot generate code for Starent
However, the same operation from Starent VSA1 vendor specific dictionary as well as 3GPP vendor-specific dictionary works perfectly fine.
I tried adding that format=2,2 to the 3GPP dictionary and I got a similar error.
radius-dict-gen -output tgpp_generated.go -package dictionary dictionary.3gpp
radius-dict-gen: dictionarygen: cannot generate code for 3GPP
Can you please confirm that is what's breaking radius-dict-gen? If yes, is there any workaround I can use to generate my code and maybe manually change it after that to still generate the proper Starent VSA encoding?
Thanks