summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/option_interfaceid.go
blob: ce8571416679d9d5ad4c599d13c5445909cdd73f (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
package dhcpv6

import (
	"fmt"
)

// OptInterfaceID returns an interface id option as defined by RFC 3315,
// Section 22.18.
func OptInterfaceID(id []byte) Option {
	return &optInterfaceID{ID: id}
}

type optInterfaceID struct {
	ID []byte
}

func (*optInterfaceID) Code() OptionCode {
	return OptionInterfaceID
}

func (op *optInterfaceID) ToBytes() []byte {
	return op.ID
}

func (op *optInterfaceID) String() string {
	return fmt.Sprintf("InterfaceID: %v", op.ID)
}

// build an optInterfaceID structure from a sequence of bytes.
// The input data does not include option code and length bytes.
func parseOptInterfaceID(data []byte) (*optInterfaceID, error) {
	var opt optInterfaceID
	opt.ID = append([]byte(nil), data...)
	return &opt, nil
}