summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/options.go
diff options
context:
space:
mode:
authorHu Jun <hujun.work@gmail.com>2020-06-23 17:13:04 -0700
committerHu Jun <hujun.work@gmail.com>2020-06-23 17:13:04 -0700
commit53863bbc3e1a9321931fe2d1187eb04f67ab75f4 (patch)
treea34bffdc80721c45d68acbd2060b23bf98efa203 /dhcpv4/options.go
parent5461cb587315d93b3e9ba193d594df681e05b220 (diff)
parentd74cd86ad5b8d0fbef8217631f7968bd7bab0d72 (diff)
Merge branch 'master' of https://github.com/insomniacslk/dhcp into dhcpv4_release
Diffstat (limited to 'dhcpv4/options.go')
-rw-r--r--dhcpv4/options.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/dhcpv4/options.go b/dhcpv4/options.go
index ea902f6..058c4ad 100644
--- a/dhcpv4/options.go
+++ b/dhcpv4/options.go
@@ -185,12 +185,20 @@ func (o Options) Marshal(b *uio.Lexer) {
code := uint8(c)
// Even if the End option is in there, don't marshal it until
// the end.
- if code == optEnd {
+ // Don't write padding either, since the options are sorted
+ // it would always be written first which isn't useful
+ if code == optEnd || code == optPad {
continue
}
data := o[code]
+ // Ensure even 0-length options are written out
+ if len(data) == 0 {
+ b.Write8(code)
+ b.Write8(0)
+ continue
+ }
// RFC 3396: If more than 256 bytes of data are given, the
// option is simply listed multiple times.
for len(data) > 0 {