diff options
author | insomniac <insomniacslk@users.noreply.github.com> | 2018-05-12 02:08:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-12 02:08:20 +0100 |
commit | 5e40d13e338c363f111c326987b14023db25c40d (patch) | |
tree | 3de3f34d8cbf647a6303b2d923fb4c22627c810c /dhcpv6/option_domainsearchlist.go | |
parent | d7cd0594274352de80d86a3bf32b487dfde63629 (diff) |
OptDomainSearchList: made fields public and added unit tests (#64)
Diffstat (limited to 'dhcpv6/option_domainsearchlist.go')
-rw-r--r-- | dhcpv6/option_domainsearchlist.go | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/dhcpv6/option_domainsearchlist.go b/dhcpv6/option_domainsearchlist.go index e3e9c17..402c68e 100644 --- a/dhcpv6/option_domainsearchlist.go +++ b/dhcpv6/option_domainsearchlist.go @@ -8,8 +8,9 @@ import ( "fmt" ) +// OptDomainSearchList list implements a DOMAIN_SEARCH_LIST option type OptDomainSearchList struct { - domainSearchList []string + DomainSearchList []string } func (op *OptDomainSearchList) Code() OptionCode { @@ -20,28 +21,20 @@ func (op *OptDomainSearchList) ToBytes() []byte { buf := make([]byte, 4) binary.BigEndian.PutUint16(buf[0:2], uint16(DOMAIN_SEARCH_LIST)) binary.BigEndian.PutUint16(buf[2:4], uint16(op.Length())) - buf = append(buf, LabelsToBytes(op.domainSearchList)...) + buf = append(buf, LabelsToBytes(op.DomainSearchList)...) return buf } -func (op *OptDomainSearchList) DomainSearchList() []string { - return op.domainSearchList -} - -func (op *OptDomainSearchList) SetDomainSearchList(dsList []string) { - op.domainSearchList = dsList -} - func (op *OptDomainSearchList) Length() int { var length int - for _, label := range op.domainSearchList { + for _, label := range op.DomainSearchList { length += len(label) + 2 // add the first and the last length bytes } return length } func (op *OptDomainSearchList) String() string { - return fmt.Sprintf("OptDomainSearchList{searchlist=%v}", op.domainSearchList) + return fmt.Sprintf("OptDomainSearchList{searchlist=%v}", op.DomainSearchList) } // build an OptDomainSearchList structure from a sequence of bytes. @@ -49,7 +42,7 @@ func (op *OptDomainSearchList) String() string { func ParseOptDomainSearchList(data []byte) (*OptDomainSearchList, error) { opt := OptDomainSearchList{} var err error - opt.domainSearchList, err = LabelsFromBytes(data) + opt.DomainSearchList, err = LabelsFromBytes(data) if err != nil { return nil, err } |