summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/server_test.go
diff options
context:
space:
mode:
authorChristopher Koch <chrisko@google.com>2019-01-13 15:52:18 -0500
committerinsomniac <insomniacslk@users.noreply.github.com>2019-01-15 14:35:19 +0000
commit916e0d0fc6b84b1be09ed1bb16b8de09943a9921 (patch)
treecd78de83de0c94d3377abf6f34a964b23c94a61b /dhcpv4/server_test.go
parent84a6137d6c7a6de89e1de7010eb6d003290f89c2 (diff)
dhcpv4: conform to RFC 2131 with respect to options.
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.
Diffstat (limited to 'dhcpv4/server_test.go')
-rw-r--r--dhcpv4/server_test.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/dhcpv4/server_test.go b/dhcpv4/server_test.go
index bb2ee11..4307924 100644
--- a/dhcpv4/server_test.go
+++ b/dhcpv4/server_test.go
@@ -41,7 +41,7 @@ func DORAHandler(conn net.PacketConn, peer net.Addr, m *DHCPv4) {
log.Printf("NewReplyFromRequest failed: %v", err)
return
}
- reply.AddOption(&OptServerIdentifier{ServerID: net.IP{1, 2, 3, 4}})
+ reply.UpdateOption(&OptServerIdentifier{ServerID: net.IP{1, 2, 3, 4}})
opt := m.GetOneOption(OptionDHCPMessageType)
if opt == nil {
log.Printf("No message type found!")
@@ -49,9 +49,9 @@ func DORAHandler(conn net.PacketConn, peer net.Addr, m *DHCPv4) {
}
switch opt.(*OptMessageType).MessageType {
case MessageTypeDiscover:
- reply.AddOption(&OptMessageType{MessageType: MessageTypeOffer})
+ reply.UpdateOption(&OptMessageType{MessageType: MessageTypeOffer})
case MessageTypeRequest:
- reply.AddOption(&OptMessageType{MessageType: MessageTypeAck})
+ reply.UpdateOption(&OptMessageType{MessageType: MessageTypeAck})
default:
log.Printf("Unhandled message type: %v", opt.(*OptMessageType).MessageType)
return