mirror of
https://codeberg.org/lauralani/ipam.git
synced 2024-11-24 04:30:02 +01:00
43 lines
692 B
Go
43 lines
692 B
Go
/*
|
|
Copyright © 2023 Laura Kalb <dev@lauka.net>
|
|
*/
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"net/netip"
|
|
)
|
|
|
|
type Subnet struct {
|
|
Subnet netip.Prefix
|
|
Name string
|
|
Vlan string
|
|
Addresses []Address
|
|
}
|
|
|
|
// HasIP checks if a Subnet already contains given netip.Addr.
|
|
// Returns true if the IP already is present, false otherwise.
|
|
func (s Subnet) HasIP(ip netip.Addr) bool {
|
|
iscontained := false
|
|
|
|
for _, element := range s.Addresses {
|
|
if element.IP.Compare(ip) == 0 {
|
|
iscontained = true
|
|
}
|
|
}
|
|
|
|
return iscontained
|
|
}
|
|
|
|
func (s Subnet) RemoveIP(ip netip.Addr) bool {
|
|
return true
|
|
}
|
|
|
|
func (s Subnet) GetIP(ip netip.Addr) bool {
|
|
return true
|
|
}
|
|
|
|
type Address struct {
|
|
IP netip.Addr
|
|
FQDN string
|
|
}
|