f-25: dhcp: fill db with dhcp data
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
cd22185ddb
commit
5ee2ba1669
5 changed files with 41 additions and 13 deletions
19
internal/dhcp/db.go
Normal file
19
internal/dhcp/db.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package dhcp
|
||||
|
||||
import (
|
||||
"git.g3e.fr/syonad/two/pkg/db/kv"
|
||||
"github.com/dgraph-io/badger/v4"
|
||||
)
|
||||
|
||||
func StoreDHCPEntries(db *badger.DB, subnetName string, entries map[string]string) error {
|
||||
for ip, mac := range entries {
|
||||
if err := kv.AddInDB(db, "subnet/"+subnetName+"/dhcp/"+ip, mac); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetMACForIP(db *badger.DB, subnetName, ip string) (string, error) {
|
||||
return kv.GetFromDB(db, "subnet/"+subnetName+"/dhcp/"+ip)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue