-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
miscoptions: add miscellaneous options file, add Preference type, upd…
…ate tests
- Loading branch information
Showing
4 changed files
with
46 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package dhcp6 | ||
|
||
import ( | ||
"io" | ||
) | ||
|
||
// A Preference is a preference value, as defined in RFC 3315, Section 22.8. | ||
// | ||
// A preference value is sent by a server to a client to affect the selection | ||
// of a server by the client. | ||
type Preference uint8 | ||
|
||
// MarshalBinary allocates a byte slice containing the data from a Preference. | ||
func (p Preference) MarshalBinary() ([]byte, error) { | ||
return []byte{byte(p)}, nil | ||
} | ||
|
||
// UnmarshalBinary unmarshals a raw byte slice into a Preference. | ||
// | ||
// If the byte slice is not exactly 1 byte in length, io.ErrUnexpectedEOF is | ||
// returned. | ||
func (p *Preference) UnmarshalBinary(b []byte) error { | ||
if len(b) != 1 { | ||
return io.ErrUnexpectedEOF | ||
} | ||
|
||
*p = Preference(b[0]) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters