summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--dhcpv4/option_archtype.go10
-rw-r--r--dhcpv4/option_domain_search_test.go36
-rw-r--r--dhcpv4/option_misc.go (renamed from dhcpv4/option_domain_search.go)6
-rw-r--r--dhcpv4/option_misc_test.go (renamed from dhcpv4/option_archtype_test.go)29
4 files changed, 35 insertions, 46 deletions
diff --git a/dhcpv4/option_archtype.go b/dhcpv4/option_archtype.go
deleted file mode 100644
index c0a901d..0000000
--- a/dhcpv4/option_archtype.go
+++ /dev/null
@@ -1,10 +0,0 @@
-package dhcpv4
-
-import (
- "github.com/insomniacslk/dhcp/iana"
-)
-
-// OptClientArch returns a new Client System Architecture Type option.
-func OptClientArch(archs ...iana.Arch) Option {
- return Option{Code: OptionClientSystemArchitectureType, Value: iana.Archs(archs)}
-}
diff --git a/dhcpv4/option_domain_search_test.go b/dhcpv4/option_domain_search_test.go
deleted file mode 100644
index 508797c..0000000
--- a/dhcpv4/option_domain_search_test.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package dhcpv4
-
-import (
- "testing"
-
- "github.com/insomniacslk/dhcp/rfc1035label"
- "github.com/stretchr/testify/require"
-)
-
-func TestGetDomainSearch(t *testing.T) {
- data := []byte{
- 7, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 3, 'c', 'o', 'm', 0,
- 6, 's', 'u', 'b', 'n', 'e', 't', 7, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 3, 'o', 'r', 'g', 0,
- }
- m, _ := New(WithGeneric(OptionDNSDomainSearchList, data))
- labels := m.DomainSearch()
- require.NotNil(t, labels)
- require.Equal(t, 2, len(labels.Labels))
- require.Equal(t, data, labels.ToBytes())
- require.Equal(t, labels.Labels[0], "example.com")
- require.Equal(t, labels.Labels[1], "subnet.example.org")
-}
-
-func TestOptDomainSearchToBytes(t *testing.T) {
- expected := []byte{
- 7, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 3, 'c', 'o', 'm', 0,
- 6, 's', 'u', 'b', 'n', 'e', 't', 7, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 3, 'o', 'r', 'g', 0,
- }
- opt := OptDomainSearch(&rfc1035label.Labels{
- Labels: []string{
- "example.com",
- "subnet.example.org",
- },
- })
- require.Equal(t, opt.Value.ToBytes(), expected)
-}
diff --git a/dhcpv4/option_domain_search.go b/dhcpv4/option_misc.go
index b57754f..01de95f 100644
--- a/dhcpv4/option_domain_search.go
+++ b/dhcpv4/option_misc.go
@@ -1,6 +1,7 @@
package dhcpv4
import (
+ "github.com/insomniacslk/dhcp/iana"
"github.com/insomniacslk/dhcp/rfc1035label"
)
@@ -10,3 +11,8 @@ import (
func OptDomainSearch(labels *rfc1035label.Labels) Option {
return Option{Code: OptionDNSDomainSearchList, Value: labels}
}
+
+// OptClientArch returns a new Client System Architecture Type option.
+func OptClientArch(archs ...iana.Arch) Option {
+ return Option{Code: OptionClientSystemArchitectureType, Value: iana.Archs(archs)}
+}
diff --git a/dhcpv4/option_archtype_test.go b/dhcpv4/option_misc_test.go
index e5e501a..1e243e9 100644
--- a/dhcpv4/option_archtype_test.go
+++ b/dhcpv4/option_misc_test.go
@@ -4,9 +4,38 @@ import (
"testing"
"github.com/insomniacslk/dhcp/iana"
+ "github.com/insomniacslk/dhcp/rfc1035label"
"github.com/stretchr/testify/require"
)
+func TestGetDomainSearch(t *testing.T) {
+ data := []byte{
+ 7, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 3, 'c', 'o', 'm', 0,
+ 6, 's', 'u', 'b', 'n', 'e', 't', 7, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 3, 'o', 'r', 'g', 0,
+ }
+ m, _ := New(WithGeneric(OptionDNSDomainSearchList, data))
+ labels := m.DomainSearch()
+ require.NotNil(t, labels)
+ require.Equal(t, 2, len(labels.Labels))
+ require.Equal(t, data, labels.ToBytes())
+ require.Equal(t, labels.Labels[0], "example.com")
+ require.Equal(t, labels.Labels[1], "subnet.example.org")
+}
+
+func TestOptDomainSearchToBytes(t *testing.T) {
+ expected := []byte{
+ 7, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 3, 'c', 'o', 'm', 0,
+ 6, 's', 'u', 'b', 'n', 'e', 't', 7, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 3, 'o', 'r', 'g', 0,
+ }
+ opt := OptDomainSearch(&rfc1035label.Labels{
+ Labels: []string{
+ "example.com",
+ "subnet.example.org",
+ },
+ })
+ require.Equal(t, opt.Value.ToBytes(), expected)
+}
+
func TestParseOptClientArchType(t *testing.T) {
m, _ := New(WithGeneric(OptionClientSystemArchitectureType, []byte{
0, 6, // EFI_IA32