summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrea Barberio <insomniac@slackware.it>2018-11-08 12:39:55 +0000
committerAndrea Barberio <insomniac@slackware.it>2018-11-08 12:48:28 +0000
commit70d17f765a63c30440176ca257fbb85c1adf5024 (patch)
tree8eeed44c95767f6ba8f5823a4d1499df780fd560
parent4da458ed1d2abe3eaa398b551d91ac79c03682f9 (diff)
Added DHCPv6 client example
-rw-r--r--README.md97
1 files changed, 95 insertions, 2 deletions
diff --git a/README.md b/README.md
index 9c8c2a8..10969e1 100644
--- a/README.md
+++ b/README.md
@@ -2,9 +2,102 @@
DHCPv4 and DHCPv6 decoding/encoding library with client and server code, written in Go.
-See examples at https://github.com/insomniacslk/exdhcp
+# How to get the library
-## Public projects that use it
+The library is split into several parts:
+* `dhcpv6`: implementation of DHCPv6 packet, client and server
+* `dhcpv4`: implementation of DHCPv4 packet, client and server
+* `netboot`: network booting wrappers on top of `dhcpv6` and `dhcpv4`
+* `iana`: several IANA constants, and helpers used by `dhcpv6` and `dhcpv4`
+* `rfc1035label`: simple implementation of RFC1035 labels, used by `dhcpv6` and
+ `dhcpv4`
+
+You will probably only need `dhcpv6` and/or `dhcpv4` explicitly. The rest is
+pulled in automatically if necessary.
+
+
+So, to get `dhcpv6` and `dhpv4` just run:
+```
+go get github.com/insomniacslk/dhcp/dhcpv{4,6}
+```
+
+
+# Examples
+
+The sections below will illustrate how to use the `dhcpv6` and `dhcpv4`
+packages.
+
+See more example code at https://github.com/insomniacslk/exdhcp
+
+
+## DHCPv6 client
+
+To run a DHCPv6 transaction on the interface "eth0":
+
+```
+package main
+
+import (
+ "log"
+
+ "github.com/insomniacslk/dhcp/dhcpv6"
+)
+
+
+func main() {
+ // NewClient sets up a new DHCPv6 client with default values
+ // for read and write timeouts, for destination address and listening
+ // address
+ client := dhcpv6.NewClient()
+
+ // Exchange runs a Solicit-Advertise-Request-Reply transaction on the
+ // specified network interface, and returns a list of DHCPv6 packets
+ // (a "conversation") and an error if any. Notice that Exchange may
+ // return a non-empty packet list even if there is an error. This is
+ // intended, because the transaction may fail at any point, and we
+ // still want to know what packets were exchanged until then.
+ // The `nil` argument indicates that we want to use a default Solicit
+ // packet, instead of specifying a custom one ourselves.
+ conversation, err := client.Exchange("eth0", nil)
+
+ // Summary() prints a verbose representation of the exchanged packets.
+ for _, packet := range conversation {
+ log.Print(packet.Summary())
+ }
+ // error handling is done *after* printing, so we still print the
+ // exchanged packets if any, as explained above.
+ if err != nil {
+ log.Fatal(err)
+ }
+}
+```
+
+
+## DHCPv6 packet parsing
+
+TODO
+
+
+## DHCPv6 server
+
+TODO
+
+## DHCPv4 client
+
+TODO
+
+
+## DHCPv4 packet parsing
+
+TODO
+
+
+## DHCPv4 server
+
+TODO
+
+
+# Public projects that use it
* Facebook's DHCP load balancer, `dhcplb`, https://github.com/facebookincubator/dhcplb
* Systemboot, a LinuxBoot distribution that runs as system firmware, https://github.com/systemboot/systemboot