blob: 216f53ba7ab296f869ad0a8c44f0c8f65f1bae20 (
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
36
37
38
39
40
41
42
43
44
45
46
|
package dhcpv6
// This module defines the optRelayMsg structure.
// https://www.ietf.org/rfc/rfc3315.txt
import (
"fmt"
)
// OptRelayMessage embeds a message in a relay option.
func OptRelayMessage(msg DHCPv6) Option {
return &optRelayMsg{Msg: msg}
}
type optRelayMsg struct {
Msg DHCPv6
}
func (op *optRelayMsg) Code() OptionCode {
return OptionRelayMsg
}
func (op *optRelayMsg) ToBytes() []byte {
return op.Msg.ToBytes()
}
func (op *optRelayMsg) String() string {
return fmt.Sprintf("%s: %v", op.Code(), op.Msg)
}
// LongString returns a multi-line string representation of the relay message data.
func (op *optRelayMsg) LongString(indent int) string {
return fmt.Sprintf("%s: %v", op.Code(), op.Msg.LongString(indent))
}
// build an optRelayMsg structure from a sequence of bytes.
// The input data does not include option code and length bytes.
func parseOptRelayMsg(data []byte) (*optRelayMsg, error) {
var err error
var opt optRelayMsg
opt.Msg, err = FromBytes(data)
if err != nil {
return nil, err
}
return &opt, nil
}
|