summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/option_serverid.go
blob: 4c35cc1cda717cb10d905cca95736a6b78e16e27 (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
package dhcpv6

import (
	"fmt"
)

// OptServerID represents a Server Identifier option as defined by RFC 3315
// Section 22.1.
func OptServerID(d DUID) Option {
	return &optServerID{d}
}

type optServerID struct {
	DUID
}

func (*optServerID) Code() OptionCode {
	return OptionServerID
}

func (op *optServerID) String() string {
	return fmt.Sprintf("%s: %v", op.Code(), op.DUID)
}

// FromBytes builds an optServerID structure from a sequence of bytes. The
// input data does not include option code and length bytes.
func (op *optServerID) FromBytes(data []byte) error {
	var err error
	op.DUID, err = DUIDFromBytes(data)
	return err
}