summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/client.go
diff options
context:
space:
mode:
authorAndrea Barberio <insomniac@slackware.it>2017-12-06 19:53:13 +0000
committerAndrea Barberio <insomniac@slackware.it>2017-12-06 19:53:13 +0000
commita8db4e3c50790c83f8ba459517cc70481a014d83 (patch)
treea3f114c53d6d7a26ab1d525a51fb70f2b93ceb8e /dhcpv6/client.go
parent5b10d4ccc61b730788ba80a1b1c3640ee1a960e6 (diff)
DHCPv6 is now an interface; DHCPv6Message and DHCPv6RelayMessage are implementations
Diffstat (limited to 'dhcpv6/client.go')
-rw-r--r--dhcpv6/client.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/dhcpv6/client.go b/dhcpv6/client.go
index 787439d..6bb1a91 100644
--- a/dhcpv6/client.go
+++ b/dhcpv6/client.go
@@ -25,29 +25,29 @@ type Client struct {
}
// Make a stateful DHCPv6 request
-func (c *Client) Exchange(ifname string, d *DHCPv6) ([]DHCPv6, error) {
- conversation := make([]DHCPv6, 1)
+func (c *Client) Exchange(ifname string, solicit DHCPv6) ([]DHCPv6, error) {
+ conversation := make([]DHCPv6, 0)
var err error
// Solicit
- if d == nil {
- d, err = NewSolicitForInterface(ifname)
+ if solicit == nil {
+ solicit, err = NewSolicitForInterface(ifname)
if err != nil {
return conversation, err
}
}
- conversation[0] = *d
- advertise, err := c.ExchangeSolicitAdvertise(ifname, d)
+ conversation = append(conversation, solicit)
+ advertise, err := c.ExchangeSolicitAdvertise(ifname, solicit)
if err != nil {
return conversation, err
}
- conversation = append(conversation, *advertise)
+ conversation = append(conversation, advertise)
// TODO request/reply
return conversation, nil
}
-func (c *Client) ExchangeSolicitAdvertise(ifname string, d *DHCPv6) (*DHCPv6, error) {
+func (c *Client) ExchangeSolicitAdvertise(ifname string, solicit DHCPv6) (DHCPv6, error) {
// if no LocalAddr is specified, get the interface's link-local address
var laddr net.UDPAddr
if c.LocalAddr == nil {
@@ -93,7 +93,7 @@ func (c *Client) ExchangeSolicitAdvertise(ifname string, d *DHCPv6) (*DHCPv6, er
conn.SetWriteDeadline(time.Now().Add(wtimeout))
// send the SOLICIT packet out
- _, err = conn.WriteTo(d.ToBytes(), &raddr)
+ _, err = conn.WriteTo(solicit.ToBytes(), &raddr)
if err != nil {
return nil, err
}