summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/option_bootfileurl.go
blob: 48c49bc3a3a9e076a659cf9175e7118f348787f2 (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"
)

// OptBootFileURL implements the OptionBootfileURL option
//
// This module defines the OptBootFileURL structure.
// https://www.ietf.org/rfc/rfc5970.txt
type OptBootFileURL struct {
	BootFileURL []byte
}

// Code returns the option code
func (op *OptBootFileURL) Code() OptionCode {
	return OptionBootfileURL
}

// ToBytes serializes the option and returns it as a sequence of bytes
func (op *OptBootFileURL) ToBytes() []byte {
	return op.BootFileURL
}

func (op *OptBootFileURL) String() string {
	return fmt.Sprintf("OptBootFileURL{BootFileUrl=%s}", op.BootFileURL)
}

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