kea-manage/lib/types/types.go

38 lines
665 B
Go
Raw Normal View History

2024-09-14 04:21:14 +00:00
package types
import "strings"
2024-09-14 04:21:14 +00:00
type Identifier int
func (i Identifier) Int() int {
return int(i)
}
//go:generate stringer -type=Identifier
const (
HwAddress Identifier = 0
DuID Identifier = 1
CircuitId Identifier = 2
ClientId Identifier = 3
FlexId Identifier = 4
Invalid Identifier = 255
)
var types = map[string]Identifier{
"macaddr": HwAddress,
"hwaddr": HwAddress,
"duid": DuID,
"circuit-id": CircuitId,
"client-id": ClientId,
"flex-id": FlexId,
"invalid": Invalid,
}
func Lookup(rtype string) Identifier {
rtype = strings.ToLower(rtype)
if t, ok := types[rtype]; ok == true {
return t
}
return Invalid
}