diff options
author | Hu Jun <hujun.work@gmail.com> | 2020-09-05 19:54:16 -0700 |
---|---|---|
committer | Hu Jun <hujun.work@gmail.com> | 2020-09-05 19:54:16 -0700 |
commit | 79aba137cf3ea8e0c1c980cad412cc034e145c0e (patch) | |
tree | 21fba9dc20c4b449a01ddf7810b2af560afc50c1 /dhcpv4/option_relay_agent_information.go | |
parent | 664c04d37abac5eea444ce3987333e4c041126cc (diff) |
- restore OptionGeneric.String()
- add raiValue in option_relay_agent_information.go to implement fmt.Stringer
- change test cases accordingly
Signed-off-by: Hu Jun <hujun.work@gmail.com>
Diffstat (limited to 'dhcpv4/option_relay_agent_information.go')
-rw-r--r-- | dhcpv4/option_relay_agent_information.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/dhcpv4/option_relay_agent_information.go b/dhcpv4/option_relay_agent_information.go index a6a2c34..b2e84d8 100644 --- a/dhcpv4/option_relay_agent_information.go +++ b/dhcpv4/option_relay_agent_information.go @@ -4,6 +4,14 @@ import ( "fmt" ) +type raiValue struct { + val []byte +} + +func (rv raiValue) String() string { + return fmt.Sprintf("%s (%v)", string([]byte(rv.val)), rv.val) +} + // RelayOptions is like Options, but stringifies using the Relay Agent Specific // option space. type RelayOptions struct { @@ -12,7 +20,7 @@ type RelayOptions struct { var relayHumanizer = OptionHumanizer{ ValueHumanizer: func(code OptionCode, data []byte) fmt.Stringer { - return OptionGeneric{data} + return raiValue{val: data} }, CodeHumanizer: func(c uint8) OptionCode { return raiSubOptionCode(c) |