diff options
author | Christopher Koch <chrisko@google.com> | 2019-03-04 12:47:50 -0800 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2019-04-04 12:49:08 +0100 |
commit | 175868d67987770d2d729186f7676e0b98f925df (patch) | |
tree | 2d56b1cb28fddd14ad935fa3c41dcc368b31e30c /examples | |
parent | b40bd52ae58aee37cec9ef81008e24488350c98f (diff) |
client6: new async DHCPv6 client like #250.
- Race-condition-averse.
- Supports multiple concurrent requests.
- Tested.
- Requires a fully compatible net.PacketConn.
Signed-off-by: Christopher Koch <chrisko@google.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/packetcrafting6/main.go | 7 | ||||
-rw-r--r-- | examples/server6/main.go | 12 | ||||
-rwxr-xr-x | examples/server6/server6 | bin | 2842321 -> 0 bytes |
3 files changed, 12 insertions, 7 deletions
diff --git a/examples/packetcrafting6/main.go b/examples/packetcrafting6/main.go index 7e2fb1b..f2c1855 100644 --- a/examples/packetcrafting6/main.go +++ b/examples/packetcrafting6/main.go @@ -15,9 +15,14 @@ func main() { // that implement the `dhcpv6.DHCPv6` interface. // Then print the wire-format representation of the packet. + iface, err := net.InterfaceByName("eth0") + if err != nil { + log.Fatal(err) + } + // Create the DHCPv6 Solicit first, using the interface "eth0" // to get the MAC address - msg, err := dhcpv6.NewSolicitForInterface("eth0") + msg, err := dhcpv6.NewSolicit(iface.HardwareAddr) if err != nil { log.Fatal(err) } diff --git a/examples/server6/main.go b/examples/server6/main.go index 174f798..318937f 100644 --- a/examples/server6/main.go +++ b/examples/server6/main.go @@ -14,14 +14,14 @@ func handler(conn net.PacketConn, peer net.Addr, m dhcpv6.DHCPv6) { } func main() { - laddr := net.UDPAddr{ + laddr := &net.UDPAddr{ IP: net.ParseIP("::1"), Port: dhcpv6.DefaultServerPort, } - server := server6.NewServer(laddr, handler) - - defer server.Close() - if err := server.ActivateAndServe(); err != nil { - log.Panic(err) + server, err := server6.NewServer(laddr, handler) + if err != nil { + log.Fatal(err) } + + server.Serve() } diff --git a/examples/server6/server6 b/examples/server6/server6 Binary files differdeleted file mode 100755 index 16f6153..0000000 --- a/examples/server6/server6 +++ /dev/null |