summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/option_bootfile_name.go
blob: 9e55bc33bae0f5d759a314a3286e5573d127c533 (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
package dhcpv4

import (
	"fmt"
)

// This option implements the Bootfile name Option.
// https://tools.ietf.org/html/rfc2132

// OptBootfileName implements the BootFile Name option
type OptBootfileName struct {
	BootfileName string
}

// Code returns the option code
func (op *OptBootfileName) Code() OptionCode {
	return OptionBootfileName
}

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

func (op *OptBootfileName) String() string {
	return fmt.Sprintf("Bootfile Name -> %s", op.BootfileName)
}

// ParseOptBootfileName returns a new OptBootfile from a byte stream or error if any
func ParseOptBootfileName(data []byte) (*OptBootfileName, error) {
	return &OptBootfileName{BootfileName: string(data)}, nil
}