summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6
diff options
context:
space:
mode:
Diffstat (limited to 'dhcpv6')
-rw-r--r--dhcpv6/option_4rd.go14
-rw-r--r--dhcpv6/option_4rd_test.go30
2 files changed, 24 insertions, 20 deletions
diff --git a/dhcpv6/option_4rd.go b/dhcpv6/option_4rd.go
index 13d672a..d9ac0a4 100644
--- a/dhcpv6/option_4rd.go
+++ b/dhcpv6/option_4rd.go
@@ -8,7 +8,9 @@ import (
)
// Opt4RD represents a 4RD option. It is only a container for 4RD_*_RULE options
-type Opt4RD Options
+type Opt4RD struct {
+ Options
+}
// Code returns the Option Code for this option
func (op *Opt4RD) Code() OptionCode {
@@ -17,20 +19,20 @@ func (op *Opt4RD) Code() OptionCode {
// ToBytes serializes this option
func (op *Opt4RD) ToBytes() []byte {
- return (*Options)(op).ToBytes()
+ return op.Options.ToBytes()
}
// String returns a human-readable representation of the option
func (op *Opt4RD) String() string {
- return fmt.Sprintf("Opt4RD{%v}", (*Options)(op))
+ return fmt.Sprintf("Opt4RD{%v}", op.Options)
}
// ParseOpt4RD builds an Opt4RD structure from a sequence of bytes.
// The input data does not include option code and length bytes
func ParseOpt4RD(data []byte) (*Opt4RD, error) {
- var opt Options
- err := opt.FromBytes(data)
- return (*Opt4RD)(&opt), err
+ var opt Opt4RD
+ err := opt.Options.FromBytes(data)
+ return &opt, err
}
// Opt4RDMapRule represents a 4RD Mapping Rule option
diff --git a/dhcpv6/option_4rd_test.go b/dhcpv6/option_4rd_test.go
index 1251b13..ad72445 100644
--- a/dhcpv6/option_4rd_test.go
+++ b/dhcpv6/option_4rd_test.go
@@ -141,22 +141,24 @@ func TestOpt4RDMapRuleString(t *testing.T) {
func TestOpt4RDRoundTrip(t *testing.T) {
var tClass uint8 = 0xaa
opt := Opt4RD{
- &Opt4RDMapRule{
- Prefix4: net.IPNet{
- IP: net.IPv4(100, 64, 0, 238).To4(),
- Mask: net.CIDRMask(24, 32),
+ Options: Options{
+ &Opt4RDMapRule{
+ Prefix4: net.IPNet{
+ IP: net.IPv4(100, 64, 0, 238).To4(),
+ Mask: net.CIDRMask(24, 32),
+ },
+ Prefix6: net.IPNet{
+ IP: net.ParseIP("2001:db8::1234:5678:0:aabb"),
+ Mask: net.CIDRMask(80, 128),
+ },
+ EABitsLength: 32,
+ WKPAuthorized: true,
},
- Prefix6: net.IPNet{
- IP: net.ParseIP("2001:db8::1234:5678:0:aabb"),
- Mask: net.CIDRMask(80, 128),
+ &Opt4RDNonMapRule{
+ HubAndSpoke: true,
+ TrafficClass: &tClass,
+ DomainPMTU: 9000,
},
- EABitsLength: 32,
- WKPAuthorized: true,
- },
- &Opt4RDNonMapRule{
- HubAndSpoke: true,
- TrafficClass: &tClass,
- DomainPMTU: 9000,
},
}