summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/option_class_identifier.go
blob: 286cb59c3f8e392613c6c97ba763f8f0d04d7d34 (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"
)

// OptClassIdentifier implements the vendor class identifier option described
// in RFC 2132, Section 9.13.
type OptClassIdentifier struct {
	Identifier string
}

// ParseOptClassIdentifier constructs an OptClassIdentifier struct from a sequence of
// bytes and returns it, or an error.
func ParseOptClassIdentifier(data []byte) (*OptClassIdentifier, error) {
	return &OptClassIdentifier{Identifier: string(data)}, nil
}

// Code returns the option code.
func (o *OptClassIdentifier) Code() OptionCode {
	return OptionClassIdentifier
}

// ToBytes returns a serialized stream of bytes for this option.
func (o *OptClassIdentifier) ToBytes() []byte {
	return []byte(o.Identifier)
}

// String returns a human-readable string for this option.
func (o *OptClassIdentifier) String() string {
	return fmt.Sprintf("Class Identifier -> %v", o.Identifier)
}