blob: 2a6020916fd91e71b4c978c4170d3003102e4477 (
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
38
|
package dhcpv6
import (
"fmt"
)
// OptServerId represents a Server ID option
//
// This module defines the OptServerId and DUID structures.
// https://www.ietf.org/rfc/rfc3315.txt
type OptServerId struct {
Sid Duid
}
func (op *OptServerId) Code() OptionCode {
return OptionServerID
}
// ToBytes serializes this option.
func (op *OptServerId) ToBytes() []byte {
return op.Sid.ToBytes()
}
func (op *OptServerId) String() string {
return fmt.Sprintf("OptServerId{sid=%v}", op.Sid.String())
}
// ParseOptServerId builds an OptServerId structure from a sequence of bytes.
// The input data does not include option code and length bytes.
func ParseOptServerId(data []byte) (*OptServerId, error) {
var opt OptServerId
sid, err := DuidFromBytes(data)
if err != nil {
return nil, err
}
opt.Sid = *sid
return &opt, nil
}
|