summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/bsdp
AgeCommit message (Collapse)Author
2019-05-08[CI] Added lintersAndrea Barberio
Now the CI will also run golangci-lint Signed-off-by: Andrea Barberio <insomniac@slackware.it>
2019-01-28update bsdpPablo Mazzini
2019-01-28update bsdpPablo Mazzini
2019-01-28update bsdpPablo Mazzini
2019-01-28dhcpv4: moved client into dhcpv4/client4Andrea Barberio
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-19dhcpv4: build more packets with modifiersChristopher Koch
Also drop unnecessary return value of Modifier.
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
2019-01-11dhcpv4: remove unused Option.Length function.Christopher Koch
2019-01-11dhcpv4: simplify marshaling options to binary.Christopher Koch
- Consolidate writing the option code and length to Options.Marshal rather than doing it in each individual option. - Use uio in marshaling code.
2019-01-10dhcpv4: remote OptionGetter interface in favor of Options type.Christopher Koch
2019-01-10dhcpv4: simplify option parsing.Christopher Koch
option's codes and lengths were being parsed twice: once in ParseOption and once in each option type's Parse implementation. Consolidate such that it only happens once. Additionally, only pass data to options that they should parse -- we know the length before the Parse function is called, so the option only gets to see the data it needs to see. Also, use uio.Lexer to simplify parsing code in general. Easier to read and reason about.
2019-01-09dhcpv4: export packet members; remove setters and getters.Christopher Koch
2019-01-09dhcpv4: simplify host name and boot file handling.Christopher Koch
2018-11-27simplify client interface (#181)Pablo Mazzini
2018-11-21remove deprecated functions (#182)Pablo Mazzini
2018-10-07DHCPv4: syscall -> x/sys/unixSean Karlage
Fixes #156 Build a simple client like so: ``` package main import ( "fmt" "time" "github.com/insomniacslk/dhcp/dhcpv4" ) func main() { client := dhcpv4.Client{ReadTimeout: 5 * time.Second, WriteTimeout: 5 * time.Second} conversation, err := client.Exchange("en0", nil) if err != nil { fmt.Println(err) } for _, m := range conversation { fmt.Println(m.Summary()) } } ``` and run: ``` $ sudo ./main Password: DHCPv4 opcode=BootRequest hwtype=Ethernet hwaddrlen=6 hopcount=0 transactionid=0xabfad715 numseconds=0 flags=Broadcast (0x8000) clientipaddr=0.0.0.0 youripaddr=0.0.0.0 serveripaddr=0.0.0.0 gatewayipaddr=0.0.0.0 clienthwaddr=8c:85:90:20:2e:33 serverhostname= bootfilename= options= DHCP Message Type -> DISCOVER Parameter Request List -> [Subnet Mask, Router, Domain Name, Domain Name Server] End -> [] DHCPv4 opcode=BootReply hwtype=Ethernet hwaddrlen=6 hopcount=0 transactionid=0xabfad715 numseconds=0 flags=Broadcast (0x8000) clientipaddr=0.0.0.0 youripaddr=192.168.0.105 serveripaddr=0.0.0.0 gatewayipaddr=0.0.0.0 clienthwaddr=8c:85:90:20:2e:33 serverhostname= bootfilename= options= DHCP Message Type -> OFFER Server Identifier -> 192.168.0.1 IP Addresses Lease Time -> 5648 Subnet Mask -> ffffff00 Routers -> 192.168.0.1 Domain Name Servers -> 8.8.8.8, 8.8.4.4 End -> [] DHCPv4 opcode=BootRequest hwtype=Ethernet hwaddrlen=6 hopcount=0 transactionid=0xabfad715 numseconds=0 flags=Broadcast (0x8000) clientipaddr=0.0.0.0 youripaddr=0.0.0.0 serveripaddr=192.168.0.1 gatewayipaddr=0.0.0.0 clienthwaddr=8c:85:90:20:2e:33 serverhostname= bootfilename= options= DHCP Message Type -> REQUEST Requested IP Address -> 192.168.0.105 Server Identifier -> 192.168.0.1 End -> [] DHCPv4 opcode=BootReply hwtype=Ethernet hwaddrlen=6 hopcount=0 transactionid=0xabfad715 numseconds=0 flags=Broadcast (0x8000) clientipaddr=0.0.0.0 youripaddr=192.168.0.105 serveripaddr=0.0.0.0 gatewayipaddr=0.0.0.0 clienthwaddr=8c:85:90:20:2e:33 serverhostname= bootfilename= options= DHCP Message Type -> ACK Server Identifier -> 192.168.0.1 IP Addresses Lease Time -> 7200 Subnet Mask -> ffffff00 Routers -> 192.168.0.1 Domain Name Servers -> 8.8.8.8, 8.8.4.4 End -> [] ```
2018-10-03BSDP: Fix MessageTypeFromPacket to return a pointerSean Karlage
As @insomiacslk pointed out in #161, it's probably better to return a pointer rather than a (MessageType, bool) combo.
2018-10-01add commentSean Karlage
2018-10-01BSDP: Add MessageTypeFromPacket helperSean Karlage
This is a helper function to extract the BSDP message type from a given `dhcpv4.DHCPv4` packet structure. It's useful in helping to identify what kind of BSDP packet you're dealing with (since the distinction is only made in one of the vendor-specific options encapsulated in Option 43).
2018-09-29BSDP: Fix parsing offset for boot image listsSean Karlage
While parsing boot images, the current code reads to the end of the data stream; however, this could lead to reading past the boot image option and reading into the next option. Instead, contain how far the option parsing code reads by only looking at the max length specified in the option.
2018-08-19Added String methods for types (#140)insomniac
* Added String methods for types * Reverted change on bsdp.OptionCode
2018-08-15refactor tests to take advantage of new helper functionsSean Karlage
2018-08-15Merge branch 'master' into bsdp-acksSean Karlage
2018-08-15Put back NewInformListForInterface to maintain compatSean Karlage
2018-08-15Merge branch 'master' into dhcpv4-moar-testsSean Karlage
2018-08-15Add nil check for Images sliceSean Karlage
2018-08-14BSDP: Add code to generate ACKs for INFORMsSean Karlage
2018-08-13BSDP: Exchange returns list of pointers, not list of objectsAndrea Barberio
2018-07-29Add some helper tools for testsSean Karlage
Adds new `OptionGetter` interface that helps when asserting that certain packets/vendor-specific opts contain specific options.
2018-07-29DHCPv4: Refactor methods for easier testingSean Karlage
This refactors the input parameters for construction DISCOVER/INFORM* packets so that it's easier to write unit tests for DHCPv4 and BSDP methods. It also adds a bunch of unit tests for both packages and rounds out their test coverage.
2018-07-29add NewReplyFromRequest (#100)Pablo Mazzini
2018-07-27[DHCPv4] BroadcastSendReceive now can wait for specific reply types (#95)insomniac
2018-07-27BSDP: Refactor to use dhcpv4.GetOneOption (#94)Sean Karlage
Refactors BSDP code to use `dhcpv4.GetOneOption` instead of manually searching through the list of options.
2018-04-18Fixed DHCPv4 listener (#37)insomniac
Fixed DHCPv4 listener There were two bugs in the DHCPv4 client: * the listener was called *after* the sender * the listener was not binding to the same interface as the sender, but listening for every UDP packet This is now fixed.
2018-03-30Remove build tags (#27)Sean Karlage
Removes build tags from BSDP and breaks vendor class identifier into OS-specific implementations so it is easier to integrate bsdp with other libs.
2018-03-26Add some more specific bsdp options + vendor specific implementation (#21)Sean Karlage
Add some more specific options + vendor specific implementation
2018-03-22Add vendor specific information optionSean Karlage
2018-03-22Add specific BSDP optionsSean Karlage
2018-03-16Add more specific dhcpv4 options (#17)Sean Karlage
Added several DHCPv4 options
2018-03-13Add OptionGeneric, comment out other code so tests compile/passSean Karlage
2018-03-10Move Exchange back to method on client, rebaseSean Karlage
2018-03-10Refactor client code, add timeout capabilitiesSean Karlage
2018-03-07Fixed build tag for darwin-only bsdp packageAndrea Barberio
2018-03-06Refactor tests to use stretchr/testify/requireSean Karlage