File: option_serverid.go

package info (click to toggle)
golang-github-insomniacslk-dhcp 0.0~git20200621.d74cd86-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,132 kB
  • sloc: makefile: 9
file content (33 lines) | stat: -rw-r--r-- 695 bytes parent folder | download | duplicates (2)
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
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("ServerID: %v", op.Duid.String())
}

// parseOptServerID builds an optServerID structure from a sequence of bytes.
// The input data does not include option code and length bytes.
func parseOptServerID(data []byte) (*optServerID, error) {
	sid, err := DuidFromBytes(data)
	if err != nil {
		return nil, err
	}
	return &optServerID{*sid}, nil
}