Run of fresh-releases for golang-github-insomniacslk-dhcp

Merge these changes:

Summary

Merged new upstream version: 0.0~git20220504.1ca156e (was: 0.0~git20220119.3c283ff).

Diff

diff --git a/README.md b/README.md
index ef2fffa..b6d41f7 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
 # dhcp
-[![Build Status](https://travis-ci.org/insomniacslk/dhcp.svg?branch=master)](https://travis-ci.org/insomniacslk/dhcp)
+[![Build Status](https://img.shields.io/github/workflow/status/insomniacslk/dhcp/Tests/master)](https://github.com/insomniacslk/dhcp/actions?query=branch%3Amaster)
 [![GoDoc](https://godoc.org/github.com/insomniacslk/dhcp?status.svg)](https://godoc.org/github.com/insomniacslk/dhcp)
 [![codecov](https://codecov.io/gh/insomniacslk/dhcp/branch/master/graph/badge.svg)](https://codecov.io/gh/insomniacslk/dhcp)
 [![Go Report Card](https://goreportcard.com/badge/github.com/insomniacslk/dhcp)](https://goreportcard.com/report/github.com/insomniacslk/dhcp)
diff --git a/debian/changelog b/debian/changelog
index 7ae283b..6602e81 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+golang-github-insomniacslk-dhcp (0.0~git20220504.1ca156e-1) UNRELEASED; urgency=low
+
+  * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Sun, 15 May 2022 10:37:31 -0000
+
 golang-github-insomniacslk-dhcp (0.0~git20220119.3c283ff-1) unstable; urgency=medium
 
   [ Debian Janitor ]
diff --git a/dhcpv4/dhcpv4.go b/dhcpv4/dhcpv4.go
index fae08fb..b894fbb 100644
--- a/dhcpv4/dhcpv4.go
+++ b/dhcpv4/dhcpv4.go
@@ -278,7 +278,7 @@ func NewReleaseFromACK(ack *DHCPv4, modifiers ...Modifier) (*DHCPv4, error) {
 	)...)
 }
 
-// FromBytes encodes the DHCPv4 packet into a sequence of bytes, and returns an
+// FromBytes decodes a DHCPv4 packet from a sequence of bytes, and returns an
 // error if the packet is not valid.
 func FromBytes(q []byte) (*DHCPv4, error) {
 	var p DHCPv4
diff --git a/dhcpv6/ztpv6/README.md b/dhcpv6/ztpv6/README.md
index f44191b..a3e16f8 100644
--- a/dhcpv6/ztpv6/README.md
+++ b/dhcpv6/ztpv6/README.md
@@ -3,6 +3,7 @@
 ## Currently Supported Vendors For DHCPv6 ZTP
  - Arista
  - ZPE
+ - Ciena
 
 ## Why Do We Need This?
 Many network hardware vendors support features that allow network devices to provision themselves with proper supporting automation/tools. Network devices can rely on DHCP and other methods to gather bootfile info, IPs, etc. DHCPv6 Vendor options provides us Vendor Name, Make, Model, and Serial Number data. This data can be used to uniquely identify individual network devices at provisioning time and can be used by tooling to make decisions necessary to correctly and reliably provision a network device.
diff --git a/dhcpv6/ztpv6/parse_vendor_options.go b/dhcpv6/ztpv6/parse_vendor_options.go
index 212733c..3d1fd01 100644
--- a/dhcpv6/ztpv6/parse_vendor_options.go
+++ b/dhcpv6/ztpv6/parse_vendor_options.go
@@ -2,9 +2,11 @@ package ztpv6
 
 import (
 	"errors"
+	"strconv"
 	"strings"
 
 	"github.com/insomniacslk/dhcp/dhcpv6"
+	"github.com/insomniacslk/dhcp/iana"
 )
 
 var (
@@ -66,6 +68,23 @@ func ParseVendorData(packet dhcpv6.DHCPv6) (*VendorData, error) {
 			vd.Model = p[1]
 			vd.Serial = p[2]
 			return &vd, nil
+
+		// For Ciena the class identifier (opt 60) is written in the following format:
+		//    {vendor iana code}-{product}-{type}
+		// For Ciena the iana code is 1271
+		// The product type is a number that maps to a Ciena product
+		// The type is used to identified different subtype of the product.
+		// An example can be ‘1271-23422Z11-123’.
+		case strings.HasPrefix(d, strconv.Itoa(int(iana.EnterpriseIDCienaCorporation))):
+			v := strings.Split(d, "-")
+			if len(v) < 3 {
+				return nil, errVendorOptionMalformed
+			}
+			duid := packet.(*dhcpv6.Message).Options.ClientID()
+			vd.VendorName = iana.EnterpriseIDCienaCorporation.String()
+			vd.Model = v[1] + "-" + v[2]
+			vd.Serial = string(duid.EnterpriseIdentifier)
+			return &vd, nil
 		}
 	}
 	return nil, errors.New("failed to parse vendor option data")
diff --git a/dhcpv6/ztpv6/parse_vendor_options_test.go b/dhcpv6/ztpv6/parse_vendor_options_test.go
index 45b42d6..cd2fb3d 100644
--- a/dhcpv6/ztpv6/parse_vendor_options_test.go
+++ b/dhcpv6/ztpv6/parse_vendor_options_test.go
@@ -4,6 +4,7 @@ import (
 	"testing"
 
 	"github.com/insomniacslk/dhcp/dhcpv6"
+	"github.com/insomniacslk/dhcp/iana"
 	"github.com/stretchr/testify/require"
 )
 
@@ -56,10 +57,11 @@ func TestParseVendorDataWithVendorOpts(t *testing.T) {
 
 func TestParseVendorDataWithVendorClass(t *testing.T) {
 	tt := []struct {
-		name string
-		vc   string
-		want *VendorData
-		fail bool
+		name     string
+		vc       string
+		clientId *dhcpv6.Duid
+		want     *VendorData
+		fail     bool
 	}{
 		{name: "empty", fail: true},
 		{name: "unknownVendor", vc: "VendorX;BFR10K;XX12345", fail: true, want: nil},
@@ -74,6 +76,15 @@ func TestParseVendorDataWithVendorClass(t *testing.T) {
 			vc:   "ZPESystems:NSC:001234567",
 			want: &VendorData{VendorName: "ZPESystems", Model: "NSC", Serial: "001234567"},
 		},
+		{
+			name: "Ciena",
+			vc:   "1271-23422Z11-123",
+			clientId: &dhcpv6.Duid{
+				Type:                 dhcpv6.DUID_EN,
+				EnterpriseIdentifier: []byte("001234567"),
+			},
+			want: &VendorData{VendorName: iana.EnterpriseIDCienaCorporation.String(), Model: "23422Z11-123", Serial: "001234567"},
+		},
 	}
 
 	for _, tc := range tt {
@@ -85,7 +96,9 @@ func TestParseVendorDataWithVendorClass(t *testing.T) {
 
 			packet.AddOption(&dhcpv6.OptVendorClass{
 				EnterpriseNumber: 0000, Data: [][]byte{[]byte(tc.vc)}})
-
+			if tc.clientId != nil {
+				packet.AddOption(dhcpv6.OptClientID(*tc.clientId))
+			}
 			vd, err := ParseVendorData(packet)
 			if err != nil && !tc.fail {
 				t.Errorf("unexpected failure: %v", err)

Publish Blockers

  • ☑ run was successful
  • ☑ package has not been removed from the archive
  • ☑ command has not changed
  • ☒ not yet reviewed, but review needed
  • ☑ 0 publish attempts so far.not currently attempting to back off
  • ☒ merge proposals for the package maintainer are currently being rate-limited (open: 1257, max open: 300)
  • ☑ change set dbca2f73-940c-490f-8323-95ab58fc4876 is ready

Resulting package

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-releases golang-github-insomniacslk-dhcp-dev

Lintian Result

Full worker log Full build log