summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/async
diff options
context:
space:
mode:
authorAndrea Barberio <insomniac@slackware.it>2019-01-27 23:48:44 +0000
committerinsomniac <insomniacslk@users.noreply.github.com>2019-01-28 11:21:18 +0000
commit82434691f0602844a2156a4d2037d43c51900b73 (patch)
tree87219ad692783ca5487affc728d12d38b3388b1b /dhcpv6/async
parent64f29461718b0dac77d8156ceceacce086fe14b2 (diff)
dhcpv6: moved client into dhcpv6/client6
Diffstat (limited to 'dhcpv6/async')
-rw-r--r--dhcpv6/async/client.go11
-rw-r--r--dhcpv6/async/client_test.go7
2 files changed, 10 insertions, 8 deletions
diff --git a/dhcpv6/async/client.go b/dhcpv6/async/client.go
index 7a8b9ec..4c73383 100644
--- a/dhcpv6/async/client.go
+++ b/dhcpv6/async/client.go
@@ -7,8 +7,9 @@ import (
"sync"
"time"
- "github.com/fanliao/go-promise"
+ promise "github.com/fanliao/go-promise"
"github.com/insomniacslk/dhcp/dhcpv6"
+ "github.com/insomniacslk/dhcp/dhcpv6/client6"
)
// Client implements an asynchronous DHCPv6 client
@@ -32,8 +33,8 @@ type Client struct {
// NewClient creates an asynchronous client
func NewClient() *Client {
return &Client{
- ReadTimeout: dhcpv6.DefaultReadTimeout,
- WriteTimeout: dhcpv6.DefaultWriteTimeout,
+ ReadTimeout: client6.DefaultReadTimeout,
+ WriteTimeout: client6.DefaultWriteTimeout,
}
}
@@ -164,7 +165,7 @@ func (c *Client) receive(_ dhcpv6.DHCPv6) {
c.connection.SetReadDeadline(time.Now().Add(c.ReadTimeout))
for {
- buffer := make([]byte, dhcpv6.MaxUDPReceivedPacketSize)
+ buffer := make([]byte, client6.MaxUDPReceivedPacketSize)
n, _, _, _, err := c.connection.ReadMsgUDP(buffer, oobdata)
if err != nil {
if err, ok := err.(net.Error); !ok || !err.Timeout() {
@@ -196,7 +197,7 @@ func (c *Client) receive(_ dhcpv6.DHCPv6) {
func (c *Client) remoteAddr() (*net.UDPAddr, error) {
if c.RemoteAddr == nil {
- return &net.UDPAddr{IP: dhcpv6.AllDHCPRelayAgentsAndServers, Port: dhcpv6.DefaultServerPort}, nil
+ return &net.UDPAddr{IP: client6.AllDHCPRelayAgentsAndServers, Port: dhcpv6.DefaultServerPort}, nil
}
if addr, ok := c.RemoteAddr.(*net.UDPAddr); ok {
diff --git a/dhcpv6/async/client_test.go b/dhcpv6/async/client_test.go
index 25a71a8..a49623e 100644
--- a/dhcpv6/async/client_test.go
+++ b/dhcpv6/async/client_test.go
@@ -7,6 +7,7 @@ import (
"time"
"github.com/insomniacslk/dhcp/dhcpv6"
+ "github.com/insomniacslk/dhcp/dhcpv6/client6"
"github.com/insomniacslk/dhcp/iana"
"github.com/stretchr/testify/require"
)
@@ -37,7 +38,7 @@ func serve(ctx context.Context, addr *net.UDPAddr, response dhcpv6.DHCPv6) error
go func() {
defer conn.Close()
oobdata := []byte{}
- buffer := make([]byte, dhcpv6.MaxUDPReceivedPacketSize)
+ buffer := make([]byte, client6.MaxUDPReceivedPacketSize)
for {
select {
case <-ctx.Done():
@@ -66,8 +67,8 @@ func serve(ctx context.Context, addr *net.UDPAddr, response dhcpv6.DHCPv6) error
func TestNewClient(t *testing.T) {
c := NewClient()
require.NotNil(t, c)
- require.Equal(t, c.ReadTimeout, dhcpv6.DefaultReadTimeout)
- require.Equal(t, c.ReadTimeout, dhcpv6.DefaultWriteTimeout)
+ require.Equal(t, c.ReadTimeout, client6.DefaultReadTimeout)
+ require.Equal(t, c.ReadTimeout, client6.DefaultWriteTimeout)
}
func TestOpenInvalidAddrFailes(t *testing.T) {