summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--dhcpv6/async/client_test.go2
-rw-r--r--dhcpv6/dhcpv6_test.go11
-rw-r--r--dhcpv6/dhcpv6message.go23
-rw-r--r--dhcpv6/dhcpv6relay_test.go1
-rw-r--r--dhcpv6/modifiers.go15
5 files changed, 10 insertions, 42 deletions
diff --git a/dhcpv6/async/client_test.go b/dhcpv6/async/client_test.go
index a3b076c..9b58112 100644
--- a/dhcpv6/async/client_test.go
+++ b/dhcpv6/async/client_test.go
@@ -26,7 +26,7 @@ func solicit(input string) (*dhcpv6.Message, error) {
Time: dhcpv6.GetTime(),
LinkLayerAddr: mac,
}
- return dhcpv6.NewSolicitWithCID(duid, mac, dhcpv6.WithIAID([4]byte{1, 2, 3, 4}))
+ return dhcpv6.NewSolicitWithCID(duid)
}
// server creates a server which responds with a predefined response
diff --git a/dhcpv6/dhcpv6_test.go b/dhcpv6/dhcpv6_test.go
index ac44314..d509572 100644
--- a/dhcpv6/dhcpv6_test.go
+++ b/dhcpv6/dhcpv6_test.go
@@ -144,7 +144,6 @@ func TestNewAdvertiseFromSolicit(t *testing.T) {
cid := OptClientId{}
s.AddOption(&cid)
duid := Duid{}
- WithIAID([4]byte{1, 2, 3, 4})(&s)
a, err := NewAdvertiseFromSolicit(&s, WithServerID(duid))
require.NoError(t, err)
@@ -208,7 +207,7 @@ func TestNewMessageTypeSolicitWithCID(t *testing.T) {
LinkLayerAddr: hwAddr,
}
- s, err := NewSolicitWithCID(duid, hwAddr)
+ s, err := NewSolicitWithCID(duid)
require.NoError(t, err)
require.Equal(t, s.Type(), MessageTypeSolicit)
@@ -228,14 +227,6 @@ func TestNewMessageTypeSolicitWithCID(t *testing.T) {
require.Contains(t, opts, OptionDNSRecursiveNameServer)
require.Contains(t, opts, OptionDomainSearchList)
require.Equal(t, len(opts), 2)
-
- // Check IA_NA
- iaid := [4]byte{hwAddr[2], hwAddr[3], hwAddr[4], hwAddr[5]}
- iaNaOption := s.GetOneOption(OptionIANA)
- require.NotNil(t, iaNaOption)
- iaNa, ok := iaNaOption.(*OptIANA)
- require.True(t, ok)
- require.Equal(t, iaid, iaNa.IaId)
}
func TestIsUsingUEFIArchTypeTrue(t *testing.T) {
diff --git a/dhcpv6/dhcpv6message.go b/dhcpv6/dhcpv6message.go
index bc23156..9237c1b 100644
--- a/dhcpv6/dhcpv6message.go
+++ b/dhcpv6/dhcpv6message.go
@@ -43,7 +43,7 @@ func GetTime() uint32 {
}
// NewSolicitWithCID creates a new SOLICIT message with CID.
-func NewSolicitWithCID(duid Duid, hwaddr net.HardwareAddr, modifiers ...Modifier) (*Message, error) {
+func NewSolicitWithCID(duid Duid, modifiers ...Modifier) (*Message, error) {
m, err := NewMessage()
if err != nil {
return nil, err
@@ -57,13 +57,12 @@ func NewSolicitWithCID(duid Duid, hwaddr net.HardwareAddr, modifiers ...Modifier
})
m.AddOption(oro)
m.AddOption(&OptElapsedTime{})
- if len(hwaddr) < 4 {
- return nil, errors.New("short hardware addrss: less than 4 bytes")
- }
- l := len(hwaddr)
- var iaid [4]byte
- copy(iaid[:], hwaddr[l-4:l])
- modifiers = append([]Modifier{WithIAID(iaid)}, modifiers...)
+ // FIXME use real values for IA_NA
+ iaNa := &OptIANA{}
+ iaNa.IaId = [4]byte{0xfa, 0xce, 0xb0, 0x0c}
+ iaNa.T1 = 0xe10
+ iaNa.T2 = 0x1518
+ m.AddOption(iaNa)
// Apply modifiers
for _, mod := range modifiers {
mod(m)
@@ -80,7 +79,7 @@ func NewSolicit(ifaceHWAddr net.HardwareAddr, modifiers ...Modifier) (*Message,
Time: GetTime(),
LinkLayerAddr: ifaceHWAddr,
}
- return NewSolicitWithCID(duid, ifaceHWAddr, modifiers...)
+ return NewSolicitWithCID(duid, modifiers...)
}
// NewAdvertiseFromSolicit creates a new ADVERTISE packet based on an SOLICIT packet.
@@ -102,12 +101,6 @@ func NewAdvertiseFromSolicit(sol *Message, modifiers ...Modifier) (*Message, err
return nil, errors.New("Client ID cannot be nil in SOLICIT when building ADVERTISE")
}
adv.AddOption(cid)
- // add IA_NA
- iaNa := sol.GetOneOption(OptionIANA)
- if iaNa == nil {
- return nil, fmt.Errorf("IA_NA cannot be nil in SOLICIT when building ADVERTISE")
- }
- adv.AddOption(iaNa)
// apply modifiers
for _, mod := range modifiers {
diff --git a/dhcpv6/dhcpv6relay_test.go b/dhcpv6/dhcpv6relay_test.go
index 6c7f96f..270dd52 100644
--- a/dhcpv6/dhcpv6relay_test.go
+++ b/dhcpv6/dhcpv6relay_test.go
@@ -90,7 +90,6 @@ func TestNewRelayRepFromRelayForw(t *testing.T) {
s, err := NewMessage()
require.NoError(t, err)
s.AddOption(&OptClientId{})
- WithIAID([4]byte{1, 2, 3, 4})(s)
orm := OptRelayMsg{}
orm.SetRelayMessage(s)
rf.AddOption(&orm)
diff --git a/dhcpv6/modifiers.go b/dhcpv6/modifiers.go
index 200a602..eaa370d 100644
--- a/dhcpv6/modifiers.go
+++ b/dhcpv6/modifiers.go
@@ -77,21 +77,6 @@ func WithIANA(addrs ...OptIAAddress) Modifier {
}
}
-// WithIAID updates an OptIANA option with the provided IAID
-func WithIAID(iaid [4]byte) Modifier {
- return func(d DHCPv6) {
- opt := d.GetOneOption(OptionIANA)
- if opt == nil {
- opt = &OptIANA{
- Options: Options{},
- }
- }
- iaNa := opt.(*OptIANA)
- copy(iaNa.IaId[:], iaid[:])
- d.UpdateOption(iaNa)
- }
-}
-
// WithDNS adds or updates an OptDNSRecursiveNameServer
func WithDNS(dnses ...net.IP) Modifier {
return func(d DHCPv6) {