summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/option_dhcpv4_msg.go
diff options
context:
space:
mode:
authorPablo Mazzini <pmazzini@gmail.com>2020-03-09 18:16:37 +0000
committerGitHub <noreply@github.com>2020-03-09 18:16:37 +0000
commitbd34b7c6963c8c124b45759423d41987d428668e (patch)
treeb48d7636ee8a827816653f8c4d6d394d1fe6c3e4 /dhcpv6/option_dhcpv4_msg.go
parent200399fb8fcb0ba141e171ed0ce3ce23758b877a (diff)
parent50dff916c60c6eb81be8be8eab2cd396ad6ccd91 (diff)
Merge pull request #361 from mikma/feature/dhcp4-o-dhcp6
dhcpv6: add DHCPv4-over-DHCPv6 support
Diffstat (limited to 'dhcpv6/option_dhcpv4_msg.go')
-rw-r--r--dhcpv6/option_dhcpv4_msg.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/dhcpv6/option_dhcpv4_msg.go b/dhcpv6/option_dhcpv4_msg.go
new file mode 100644
index 0000000..0a1a2b3
--- /dev/null
+++ b/dhcpv6/option_dhcpv4_msg.go
@@ -0,0 +1,39 @@
+package dhcpv6
+
+import (
+ "fmt"
+
+ "github.com/insomniacslk/dhcp/dhcpv4"
+)
+
+// OptDHCPv4Msg represents a OptionDHCPv4Msg option
+//
+// This module defines the OptDHCPv4Msg structure.
+// https://www.ietf.org/rfc/rfc7341.txt
+type OptDHCPv4Msg struct {
+ Msg *dhcpv4.DHCPv4
+}
+
+// Code returns the option code
+func (op *OptDHCPv4Msg) Code() OptionCode {
+ return OptionDHCPv4Msg
+}
+
+// ToBytes returns the option serialized to bytes.
+func (op *OptDHCPv4Msg) ToBytes() []byte {
+ return op.Msg.ToBytes()
+}
+
+func (op *OptDHCPv4Msg) String() string {
+ return fmt.Sprintf("OptDHCPv4Msg{%v}", op.Msg)
+}
+
+// ParseOptDHCPv4Msg builds an OptDHCPv4Msg structure
+// from a sequence of bytes. The input data does not include option code and length
+// bytes.
+func ParseOptDHCPv4Msg(data []byte) (*OptDHCPv4Msg, error) {
+ var opt OptDHCPv4Msg
+ var err error
+ opt.Msg, err = dhcpv4.FromBytes(data)
+ return &opt, err
+}