summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/modifiers.go
diff options
context:
space:
mode:
authorAndrea Barberio <insomniac@slackware.it>2018-12-08 22:17:28 +0000
committerAndrea Barberio <insomniac@slackware.it>2018-12-08 22:17:28 +0000
commit08c8b272d33662a5448d4b789466a3de79050ed8 (patch)
tree19ba7036e1e57a3f8505a9eb2d7cacbcf9843889 /dhcpv4/modifiers.go
parent4dabb19b0ae8c2c0287807d4454eedee46d39a2d (diff)
Added netconf v4 tests and required modifiers
Diffstat (limited to 'dhcpv4/modifiers.go')
-rw-r--r--dhcpv4/modifiers.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/dhcpv4/modifiers.go b/dhcpv4/modifiers.go
index 188d91f..033718e 100644
--- a/dhcpv4/modifiers.go
+++ b/dhcpv4/modifiers.go
@@ -2,6 +2,8 @@ package dhcpv4
import (
"net"
+
+ "github.com/insomniacslk/dhcp/rfc1035label"
)
// WithTransactionID sets the Transaction ID for the DHCPv4 packet
@@ -114,3 +116,55 @@ func WithRelay(ip net.IP) Modifier {
return d
}
}
+
+// WithNetmask adds or updates an OptSubnetMask
+func WithNetmask(mask net.IPMask) Modifier {
+ return func(d *DHCPv4) *DHCPv4 {
+ osm := OptSubnetMask{
+ SubnetMask: mask,
+ }
+ d.UpdateOption(&osm)
+ return d
+ }
+}
+
+// WithLeaseTime adds or updates an OptIPAddressLeaseTime
+func WithLeaseTime(leaseTime uint32) Modifier {
+ return func(d *DHCPv4) *DHCPv4 {
+ olt := OptIPAddressLeaseTime{
+ LeaseTime: leaseTime,
+ }
+ d.UpdateOption(&olt)
+ return d
+ }
+}
+
+// WithDNS adds or updates an OptionDomainNameServer
+func WithDNS(dnses ...net.IP) Modifier {
+ return func(d *DHCPv4) *DHCPv4 {
+ odns := OptDomainNameServer{NameServers: dnses}
+ d.UpdateOption(&odns)
+ return d
+ }
+}
+
+// WithDomainSearchList adds or updates an OptionDomainSearch
+func WithDomainSearchList(searchList ...string) Modifier {
+ return func(d *DHCPv4) *DHCPv4 {
+ labels := rfc1035label.Labels{
+ Labels: searchList,
+ }
+ odsl := OptDomainSearch{DomainSearch: &labels}
+ d.UpdateOption(&odsl)
+ return d
+ }
+}
+
+// WithRouter adds or updates an OptionRouter
+func WithRouter(routers ...net.IP) Modifier {
+ return func(d *DHCPv4) *DHCPv4 {
+ ortr := OptRouter{Routers: routers}
+ d.UpdateOption(&ortr)
+ return d
+ }
+}