blob: f6fcf577e2f04b9bb7a8719e0061a2279db606d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
package bsdp
import (
"fmt"
"github.com/insomniacslk/dhcp/dhcpv4"
"github.com/u-root/u-root/pkg/uio"
)
// OptServerPriority represents an option encapsulating the server priority.
type OptServerPriority struct {
Priority uint16
}
// ParseOptServerPriority returns a new OptServerPriority from a byte stream, or
// error if any.
func ParseOptServerPriority(data []byte) (*OptServerPriority, error) {
buf := uio.NewBigEndianBuffer(data)
return &OptServerPriority{Priority: buf.Read16()}, buf.FinError()
}
// Code returns the option code.
func (o *OptServerPriority) Code() dhcpv4.OptionCode {
return OptionServerPriority
}
// ToBytes returns a serialized stream of bytes for this option.
func (o *OptServerPriority) ToBytes() []byte {
buf := uio.NewBigEndianBuffer(nil)
buf.Write16(o.Priority)
return buf.Data()
}
// String returns a human-readable string.
func (o *OptServerPriority) String() string {
return fmt.Sprintf("BSDP Server Priority -> %v", o.Priority)
}
|