Add a Uint16 reader for dhcp.Options.

This commit is contained in:
David Anderson 2016-02-28 01:05:54 -08:00
parent 33e5e06817
commit af2fc8892a

View File

@ -2,6 +2,7 @@ package dhcp
import ( import (
"bytes" "bytes"
"encoding/binary"
"errors" "errors"
"fmt" "fmt"
"io" "io"
@ -121,3 +122,11 @@ func (o Options) Byte(n int) (byte, bool) {
} }
return v[0], true return v[0], true
} }
func (o Options) Uint16(n int) (uint16, bool) {
v := o[n]
if v == nil || len(v) != 2 {
return 0, false
}
return binary.BigEndian.Uint16(v[:2]), true
}