summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4
AgeCommit message (Collapse)Author
2019-07-29server4: set peer to broadcast if client IP is zeroChris Koch
Clients without an IP set their source address to 0.0.0.0, so the peer returned by ReadFrom may not actually be the address to send to. Clients without an IP should have their response broadcast. Signed-off-by: Chris Koch <chrisko@google.com>
2019-07-22Fixed unnecessary conversions (#304)Christian Muehlhaeuser
No need to convert these types.
2019-07-22Fixed typos in dhcpv4 (#303)Christian Muehlhaeuser
Simple, nit-picky typo fixes.
2019-07-05v4 discover: don't ask for broadcastChris Koch
Usually this is used for clients that don't know how to receive any other packets. We can deal with both a unicast or broadcast response packet, so let's let the server decide on its own. Signed-off-by: Chris Koch <chrisko@google.com>
2019-06-27dhcpv4: actually use random number timeoutChris Koch
Signed-off-by: Chris Koch <chrisko@google.com>
2019-06-19dhcpv4: make the short stringer more usefulChris Koch
Nobody gives a hoot about the hardware type. Signed-off-by: Chris Koch <chrisko@google.com>
2019-06-19nclient4: add logging optionsChris Koch
Signed-off-by: Chris Koch <chrisko@google.com>
2019-05-24Changing Arista cid regex forprepended bytes (#293)Akshay Navale
2019-05-22Ignore bytes after end of IP packet in BroadcastRawUDPConn.ReadFrom (#292)lprylli
When reading raw packets from the network, it can happen that the raw ethernet packet read has undefined bytes after the end of the ip packet (either from the network or in some cases from the local stack). Those bytes should not be passed to the dhcp-receiver otherwise the option parser which is picky about final padding byte will silently discard the dhcp-reply. Rename ipLen, udpLen variables with more explicit names to avoid confusion between header, payload, total length possibly considered in this function. Tested: ast2500 bmc reproducing the issue + existing go test for coverage. Signed-off-by: Loic Prylli <lprylli@netflix.com>
2019-05-15Adding Juniper EX pattern for circuit parsing (#291)Akshay Navale
2019-05-14Remove SHIFT IN character bytes from Circuit ID (#289)Akshay Navale
2019-05-14Improve compatibility with some ipv4 networks.Loic Prylli
- dnsmasq has been seen to null-terminate the bootfile option, similar treament can occur for tftp-servername (although tftp-servername option usage is less common). - for the gateway information to be present in final packet, the Router option should be queried again in request as in discover (which matches behavior of udhcpc/dhclient). Tested: pxeboot with u-root on dnsmask/ipv4 client. Signed-off-by: Loic Prylli <lprylli@netflix.com>
2019-05-09NewReplyFromRequest: copy gw ipPablo Mazzini
2019-05-09NewReplyFromRequest: copy gw ipPablo Mazzini
2019-05-09[dhcpv4] Do not Gateway IP address on packets sent by clients (#287)Marco Guerri
Relays might drop packets coming from clients if they have the Gateway IP set. This modifier is supposed to be used by relays: `WithReply` is used only by clients.
2019-05-08[CI] Added lintersAndrea Barberio
Now the CI will also run golangci-lint Signed-off-by: Andrea Barberio <insomniac@slackware.it>
2019-04-17nclient4: fix conn race conditionChristopher Koch
Why did I ever think this would work?? Signed-off-by: Christopher Koch <chrisko@google.com>
2019-04-17[server] Serve returns an error, and closes when doneAndrea Barberio
Server6 and Server4 had Serve methods that return without reporting an error, changed in this PR. Serve now also closes the connection when done. Signed-off-by: Andrea Barberio <insomniac@slackware.it>
2019-04-07nclient4: simplify New interfaceChristopher Koch
Signed-off-by: Christopher Koch <chrisko@google.com>
2019-04-04dhcpv4: add RFC3442 route optionsChristopher Koch
Signed-off-by: Christopher Koch <chrisko@google.com>
2019-04-03Use cancellable crypto RNG from u-rootAndrea Barberio
Fixes #246 Signed-off-by: Andrea Barberio <insomniac@slackware.it>
2019-04-03Allow 0xFF padding in 'End' option (#265)Alexander Tischenko
After investigation on DHCP relaying with BDCOM P3608 GPON OLT switches, i found that 'End' option is not always padded with 0x00, but for some packets is padded by the same 0xFF (End) option. DHCPv4 fails to parse such type of packets and throws an "Invalid options" error. But Wireshark says that all is just fine with 0xFF padding. This commit allows to use 0xFF/0x00 End option padding instead of strict 0x00. This allows BDCOM switches relaying mechanism to work with package.
2019-04-03Modifying the writeIP function to always write IPv4 in 4 byte long format.Akshay Navale
2019-03-29server4 test: pick ports > 32kChris K
2019-03-29dhcpv4: pad v4 messages to a 300 byte minimumChristopher Koch
Certain older DHCP servers and relay agents follow the RFC 951 BOOTP standard in which BOOTP/DHCP messages have a 300 byte minimum length. Signed-off-by: Christopher Koch <chrisko@google.com>
2019-03-27client4: add a new DHCPv4 client.Christopher Koch
- Able to send UDP packets before interface is configured. - Able to use any net.PacketConn. - RFC2131-compliant retransmission logic. - Tests. - Race-condition-averse. Previous clients (both mine and the ones here) are prone to race condition errors. Having one and only one place that calls receive on the socket "continuously" without having to coordinate hand-offs makes the logic way easier to follow, and allows for multiple requests in flux at a time. Signed-off-by: Christopher Koch <chrisko@google.com>
2019-03-13Add partial (client) binding support for BSD (#260)Dmitri Goutnik
2019-03-13Adding CircuitId parsing logic into dhcpv4 lib (#255)Akshay Navale
2019-03-13[dhcpv4] simplify userclass handling (#249)Pablo Mazzini
2019-01-28update bsdpPablo Mazzini
2019-01-28update bsdpPablo Mazzini
2019-01-28update bsdpPablo Mazzini
2019-01-28[dhcpv4] move default to main directoryPablo Mazzini
2019-01-28dhcpv4: moved client into dhcpv4/client4Andrea Barberio
2019-01-26dhcpv6: introduce TransactionID typeChristopher Koch
2019-01-25[async] re-add modifiers to Send method (#239)Pablo Mazzini
2019-01-24dhcpv4: getters instead of gettersChristopher Koch
From: r := GetRouter(d.Options) To: r := d.Router()
2019-01-24dhcpv4: nicer API for option parsing.Christopher Koch
From: r := d.GetOneOption(OptionRouter).(*OptRouter).Routers d.UpdateOption(&OptRouter{Routers: []net.IP{net.IP{192, 168, 0, 1}}}) To: r := GetRouter(d.Options) d.UpdateOption(OptRouter(net.IP{192, 168, 0, 1}, ...))
2019-01-20dhcpv4: fix TransactionID in SummaryChristopher Koch
2019-01-20dhcpv4: add Stringer for XIDChristopher Koch
2019-01-19dhcpv4: consolidate all IP options into one file.Christopher Koch
2019-01-19dhcpv4: consolidate string options into one file.Christopher Koch
2019-01-19dhcpv4: build more packets with modifiersChristopher Koch
Also drop unnecessary return value of Modifier.
2019-01-15dhcpv4: add option code list type for simpler modifiers.Christopher Koch
2019-01-15dhcpv4: print values of unknown types in stringifiers.Christopher Koch
2019-01-15dhcpv4: conform to RFC 2131 with respect to options.Christopher Koch
Removes AddOption and GetOption. RFC 2131 specifies that options may only appear once (Section 4.1). If an option does appear more than once, its byte values must be concatenated. RFC 3396 further specifies that to send options longer than 255 bytes, one option may be split into multiple option codes, which must be concatenated back together by the receiver. Both of these are concerned with the byte representation of options. Fact is, based on both RFCs one can say that an option may only appear once, but may be composed of multiple values. Because an option may appear only once logically in any case, we remove the AddOption and GetOption functions and leave only UpdateOption and GetOneOption. Also remove all additions & checks of the End option - the marshaling and unmarshaling code is exclusively responsible for that now.
2019-01-14bsdp: simplify version type.Christopher Koch
2019-01-14dhcpv4: thoroughly fix type docs. Refer to RFCs.Christopher Koch
2019-01-14dhcpv4: change OptionCode to an interface for humanization.Christopher Koch
Interface'd OptionCodes can print the correct human string. It sucks because option codes are just a byte, but depending on where you use them, they are interpreted differently. BSDP option codes != DHCP option codes.
2019-01-14iana: rename HwTypeType to HWType, add package comment.Christopher Koch