51 Commits

Author SHA1 Message Date
David Anderson
8dfa75434e dhcp4: allow duplication of option 56 (Debug message).
Turns out real DHCP servers can duplicate this message.
2016-06-18 16:44:06 -07:00
David Anderson
7a39e0e685 Actually name the package correctly, so that it can be imported. 2016-05-17 21:52:27 -07:00
David Anderson
3fb28ed0f7 dhcp4: Add tests for the option accessors... and fix a bug.
Turns out tests are useful.
2016-05-15 17:45:54 -07:00
David Anderson
c412f00cb8 dhcp4: add consts for common options, and option getters. 2016-05-15 17:26:35 -07:00
David Anderson
6ff894645a readme: tiny wording tweak. 2016-05-15 15:11:41 -07:00
David Anderson
9f9875cedc Add a marker to mark the APIs as unstable. 2016-05-15 15:06:24 -07:00
David Anderson
458d5eb0e8 Document the new non-interface Conn type. 2016-05-15 15:04:59 -07:00
David Anderson
53e4bfd991 dhcp4: refactor the low-level packet sending.
This lets the implementations share the transmission strategy and
decoding/sanity logic.
2016-05-15 14:56:09 -07:00
David Anderson
6a00ec441b Add badges for license and travis build status. 2016-05-15 13:55:41 -07:00
David Anderson
e46cf1fec1 dhcp4: correct import constraint so that we can actually import. 2016-05-15 13:41:39 -07:00
David Anderson
50f74885e9 dhcp: rename to dhcp4. 2016-05-15 13:39:49 -07:00
David Anderson
e3dd7c6861 dhcp: add documentation file. 2016-05-15 13:39:31 -07:00
David Anderson
ae696d0c3d dhcp: tighten up the exported interface by removing some cruft.
Notably, some of the helpers for implementing Conns are internal now.
2016-05-14 23:44:54 -07:00
David Anderson
45dd5dfe4d dhcp: implement a portable Conn.
Unlike the linux Conn, this one cannot share a port with another
process, but it should work across platforms.
2016-05-14 23:05:23 -07:00
David Anderson
c5449b945c dhcp: implement a linux specific "port sharing" Conn.
This implementation uses a raw IP socket combined with a BPF packet
filter to receive traffic for one UDP port, without having to bind()
to that port. This enables this Conn to coexist on a machine alongside
a DHCP server.
2016-05-14 22:17:10 -07:00
David Anderson
78dd971886 Checkpoint some further hacking on AF_PACKET, before bailing.
AF_PACKET is poorly suited to be the main receiving socket of this
implementation, for a variety of reasons: it bypasses netfilter, you
receive duplicate packets when bridges and aggregated links are involved,
and more generally it's a lot of pain just to get a MAC address out of
the link layer.

Next up, I'm going to try using an AF_INET/SOCK_RAW socket as the main
listening socket, which loses a bit of precision in acquiring packets, but
puts more of the kernel and its desirable semantics between us and the wire.
We'll still have to use an AF_PACKET socket to transmit to unconfigured
clients (although the spec gives us an option to sidestep that as well
if we want).
2016-03-24 23:58:38 -07:00
David Anderson
9c43c0a5c9 Output pcap timestamps as UnixNano.
Stringifying ends up outputting them with a machine-dependent timezone,
and a numeric timestamp is easier to grok in a test like this anyway.
2016-03-24 17:37:34 -07:00
David Anderson
0cca8f4c85 Remove dependency on prettyprint library.
We only really use it to pretty-print pcap.Packet, and it was making
`go vet` angry. So we replaced it with a specialized pretty printer
instead. As a nice side-effect, it shows nicer timestamps now.
2016-03-24 17:26:45 -07:00
David Anderson
247c54b082 Install atftp so that the tftp interop test isn't skipped. 2016-03-24 13:22:53 -07:00
David Anderson
0900f7157c Remove OSX from the build matrix, it's just too slow. 2016-03-24 13:20:23 -07:00
David Anderson
b1dab55266 Tell Travis about the custom import path. 2016-03-24 13:18:10 -07:00
David Anderson
bd7be1a19a Enable custom import paths. 2016-03-24 13:12:10 -07:00
David Anderson
b21d961610 Fix travis build instructions. 2016-03-24 12:20:25 -07:00
David Anderson
b7ae49bdb6 Add a Travis configuration for running tests. 2016-03-24 12:15:37 -07:00
David Anderson
60581f4259 Document dhcp.Options.Uint16. 2016-03-23 23:46:32 -07:00
David Anderson
21d22e747d Make dhcp.Conn also be an io.Closer. 2016-03-23 23:43:52 -07:00
David Anderson
05cf66722e Implement a Conn using linux AF_PACKET/SOCK_RAW sockets and BPF packet filtering.
This is a fairly advanced, linux-specific implementation that lets you run a DHCP
listener on a machine that's already running some other DHCP service.
2016-03-23 23:41:25 -07:00
David Anderson
aa6bf25654 Add a Conn type for sending and receiving DHCP packets. 2016-03-23 23:30:42 -07:00
David Anderson
668c1a3b32 Add a DHCPREQUEST from a DHCP relay to the test dataset. 2016-03-23 23:18:58 -07:00
David Anderson
6f642bb5ed Rename dhcp.go to packet.go in preparation for introduction of server. 2016-03-15 20:25:24 -07:00
David Anderson
55722d2f87 Add skeleton README. 2016-03-05 15:23:37 -08:00
David Anderson
587558e05a Add a contributing doc. 2016-03-05 15:18:01 -08:00
David Anderson
576e70e92c Add copyright/license headers to source. 2016-03-05 15:14:52 -08:00
David Anderson
d0e46c66a9 Add a license file. 2016-03-05 15:08:13 -08:00
David Anderson
8175ab5f5c Add a Copy method to options, and tests for options. 2016-02-29 19:34:07 -08:00
David Anderson
e8fa791c89 Make the debug string function public, so that the pxe package can use it. 2016-02-28 01:08:42 -08:00
David Anderson
d6ac0332dd Strip option 53 out of the options map, as the value is parsed into Type. 2016-02-28 01:08:12 -08:00
David Anderson
621a0c28e5 Implicitly add DHCP option 53 when marshalling. 2016-02-28 01:06:37 -08:00
David Anderson
af2fc8892a Add a Uint16 reader for dhcp.Options. 2016-02-28 01:05:54 -08:00
David Anderson
33e5e06817 Change the separation between packets to help PXE testing. 2016-02-27 23:15:07 -08:00
David Anderson
3cbc2e2788 Add a test for DHCP marshalling.
And fix a bug in DHCP marshalling that the test found :).
2016-02-27 22:51:45 -08:00
David Anderson
e799b6e1ab Correct the parsing of the server IP address.
It's the address of the responding server, not the boot server. Which
makes sense, since there's another field for the boot server name.
2016-02-27 22:36:49 -08:00
David Anderson
fa657ad649 Add a basic regression test for DHCP parsing. 2016-02-27 22:34:18 -08:00
David Anderson
178a83f3e0 Make pcap.Reader's API look like bufio.Scanner's.
The Next/Packet/Err structure makes read loops much
cleaner, and presents a more familiar interface for people
familiar with the stdlib.
2016-02-27 21:21:10 -08:00
David Anderson
6b9cba0085 Add brief package documentation. 2016-02-27 20:31:08 -08:00
David Anderson
7549f62395 Implement a pcap writer. 2016-02-27 20:25:43 -08:00
David Anderson
67755cdc83 Add a basic pcap reader.
Very basic, it only parses the pcap structure to pull out the packets,
nothing more.
2016-02-27 19:11:23 -08:00
David Anderson
133baa88bd Initial implementation of DHCP parsing. 2016-02-27 16:35:40 -08:00
David Anderson
90c89c2bd7 Implement the documented default listening behavior for TFTP. 2016-02-27 16:35:03 -08:00
David Anderson
7f4b62d890 Drop the retransmit timeout on the lossy connection test.
Since this is a test to localhost, a 10ms RTO is more than enough,
and speeds up the test 10x.
2016-02-18 09:36:19 -08:00