diff --git a/cmd/root.go b/cmd/root.go index 54ea220..9708ab1 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,5 +1,5 @@ /* -Copyright © 2024 NAME HERE +Copyright © 2024 Matthew Stobbs */ package cmd diff --git a/ipv4/reservation/reservation.go b/ipv4/reservation/reservation.go index 9ec955c..5e9f60d 100644 --- a/ipv4/reservation/reservation.go +++ b/ipv4/reservation/reservation.go @@ -18,7 +18,7 @@ type ReservationV4 struct { func ReserveV4MacAddr(identifierType string, identifier string, addr string, hostname string, subnet int) *ReservationV4 { r := &ReservationV4{ - IdentifierType: types.Lookup(identifierType), + IdentifierType: types.LookupIdentifier(identifierType), SubnetID: subnet, Identifier: identifier, Ipv4: addr, diff --git a/lib/types/identifier_string.go b/lib/types/identifier_string.go index 6037e45..c1a1638 100644 --- a/lib/types/identifier_string.go +++ b/lib/types/identifier_string.go @@ -1,4 +1,4 @@ -// Code generated by "stringer -type=Identifier"; DO NOT EDIT. +// Code generated by "stringer -linecomment -type=Identifier"; DO NOT EDIT. package types @@ -17,12 +17,12 @@ func _() { } const ( - _Identifier_name_0 = "HwAddressDuIDCircuitIdClientIdFlexId" - _Identifier_name_1 = "Invalid" + _Identifier_name_0 = "hwaddrduidcircuit-idclient-idflex-id" + _Identifier_name_1 = "invalid" ) var ( - _Identifier_index_0 = [...]uint8{0, 9, 13, 22, 30, 36} + _Identifier_index_0 = [...]uint8{0, 6, 10, 20, 29, 36} ) func (i Identifier) String() string { diff --git a/lib/types/types.go b/lib/types/types.go index c89e2fe..660bfd1 100644 --- a/lib/types/types.go +++ b/lib/types/types.go @@ -2,22 +2,25 @@ 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 -type=Identifier +//go:generate stringer -linecomment -type=Identifier const ( - HwAddress Identifier = 0 - DuID Identifier = 1 - CircuitId Identifier = 2 - ClientId Identifier = 3 - FlexId Identifier = 4 - Invalid Identifier = 255 + 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, @@ -28,7 +31,7 @@ var types = map[string]Identifier{ "invalid": Invalid, } -func Lookup(rtype string) Identifier { +func LookupIdentifier(rtype string) Identifier { rtype = strings.ToLower(rtype) if t, ok := types[rtype]; ok == true { return t