summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/option_rfc1035label.go
diff options
context:
space:
mode:
authorSean Karlage <skarlage@fb.com>2018-08-11 14:30:48 -0700
committerSean Karlage <skarlage@fb.com>2018-08-11 14:32:26 -0700
commit8ea2525c898436a2a935580de67727bbe7035c85 (patch)
tree69d35d17c238feabb07ef07a907aae5520104911 /dhcpv6/option_rfc1035label.go
parent2b05c7d03724d31529886d98f738499ac06ead7e (diff)
parenta6212f1f72e94821a29894fb66656a981bd035d0 (diff)
Merge branch 'master' into dhcpv4-moar-tests
Diffstat (limited to 'dhcpv6/option_rfc1035label.go')
-rw-r--r--dhcpv6/option_rfc1035label.go54
1 files changed, 0 insertions, 54 deletions
diff --git a/dhcpv6/option_rfc1035label.go b/dhcpv6/option_rfc1035label.go
deleted file mode 100644
index 06870b5..0000000
--- a/dhcpv6/option_rfc1035label.go
+++ /dev/null
@@ -1,54 +0,0 @@
-package dhcpv6
-
-import (
- "fmt"
- "strings"
-)
-
-func LabelsFromBytes(buf []byte) ([]string, error) {
- var (
- pos = 0
- domains = make([]string, 0)
- label = ""
- )
- for {
- if pos >= len(buf) {
- return domains, nil
- }
- length := int(buf[pos])
- pos++
- if length == 0 {
- domains = append(domains, label)
- label = ""
- }
- if len(buf)-pos < length {
- return nil, fmt.Errorf("DomainNamesFromBytes: invalid short label length")
- }
- if label != "" {
- label += "."
- }
- label += string(buf[pos : pos+length])
- pos += length
- }
- return domains, nil
-}
-
-func LabelToBytes(label string) []byte {
- var encodedLabel []byte
- if len(label) == 0 {
- return []byte{0}
- }
- for _, part := range strings.Split(label, ".") {
- encodedLabel = append(encodedLabel, byte(len(part)))
- encodedLabel = append(encodedLabel, []byte(part)...)
- }
- return append(encodedLabel, 0)
-}
-
-func LabelsToBytes(labels []string) []byte {
- var encodedLabels []byte
- for _, label := range labels {
- encodedLabels = append(encodedLabels, LabelToBytes(label)...)
- }
- return encodedLabels
-}