kea-manage/lib/types/types.go
Matthew Stobbs c8ff16ec22 set generated strings to the line comment values
- keeps the name consistent with what is being looked up in the map
2024-09-24 17:10:39 -06:00

41 lines
961 B
Go

package types
import "strings"
// Identifier as defined by the kea database entries. Values are hardcoded from
// a running instance of schema version 22.1
type Identifier int
func (i Identifier) Int() int {
return int(i)
}
//go:generate stringer -linecomment -type=Identifier
const (
HwAddress Identifier = 0 // hwaddr
DuID Identifier = 1 // duid
CircuitId Identifier = 2 // circuit-id
ClientId Identifier = 3 // client-id
FlexId Identifier = 4 // flex-id
Invalid Identifier = 255 // invalid
)
// TODO: is there a generator that can create the lookup table for me?
var types = map[string]Identifier{
"macaddr": HwAddress,
"hwaddr": HwAddress,
"duid": DuID,
"circuit-id": CircuitId,
"client-id": ClientId,
"flex-id": FlexId,
"invalid": Invalid,
}
func LookupIdentifier(rtype string) Identifier {
rtype = strings.ToLower(rtype)
if t, ok := types[rtype]; ok == true {
return t
}
return Invalid
}