VOL-4473: Fix for incorrect/cryptic MIB Upload Next response decode failure error message

Change-Id: Idb3570909963b8e8e73570ca01a456e390adf0f2
diff --git a/VERSION b/VERSION
index eca07e4..ac2cdeb 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.1.2
+2.1.3
diff --git a/generated/attribute.go b/generated/attribute.go
index de20130..4956e89 100644
--- a/generated/attribute.go
+++ b/generated/attribute.go
@@ -377,7 +377,8 @@
 	// either Read and/or Write, never Set-by-Create
 	switch msgType {
 	default:
-		return nil, fmt.Errorf("unsupported Message Type '%v' for table serialization", msgType)
+		return nil, fmt.Errorf("unsupported Message Type '%v/0x%02x' for table decode",
+			MsgType(msgType&MsgTypeMask), msgType)
 
 	case byte(Get) | AK: // Get Response
 		// Size
@@ -434,7 +435,8 @@
 	// either Read and/or Write, never Set-by-Create
 	switch msgType {
 	default:
-		return 0, fmt.Errorf("unsupported Message Type '%v' for table serialization", msgType)
+		return 0, fmt.Errorf("unsupported Message Type '%v/0x%02x' for table serialization",
+			MsgType(msgType&MsgTypeMask), msgType)
 
 	case byte(Get) | AK: // Get Response
 		// Size
diff --git a/generated/medef.go b/generated/medef.go
index 6d2c2dd..4b2061a 100644
--- a/generated/medef.go
+++ b/generated/medef.go
@@ -117,7 +117,8 @@
 			if attrDef.IsTableAttribute() {
 				switch msgType {
 				default:
-					return nil, fmt.Errorf("unsupported Message Type '%v' for table serialization", msgType)
+					return nil, fmt.Errorf("unsupported Message Type '%v/0x%02x' for table decode",
+						MsgType(msgType&MsgTypeMask), msgType)
 
 				case byte(Get) | AK: // Get Response
 					attrMap[name] = value
diff --git a/mibupload_test.go b/mibupload_test.go
index 4341263..dd67813 100644
--- a/mibupload_test.go
+++ b/mibupload_test.go
@@ -1745,3 +1745,47 @@
 	reconstituted := packetToString(outgoingPacket)
 	assert.Equal(t, strings.ToLower(mibUpload), reconstituted)
 }
+
+func TestMibUploadNextResponseDecodeAdtn401orBFWS(t *testing.T) {
+	// Next is ADTN 401 issue (note the very strange length field)
+	// goodMessage := "801f2e0a00020000009e000020000000000000000000000000000000000000000000000000000000943200281c98ff60"
+	// Next is BFWS that Ozge & Andrea saw
+	goodMessage := "82fd2e0a00020000011f0000c000000000040000000400000000000000000000000000000000000000000028cd1de3e4"
+	data, err := stringToPacket(goodMessage)
+	assert.NoError(t, err)
+
+	packet := gopacket.NewPacket(data, LayerTypeOMCI, gopacket.NoCopy)
+	assert.NotNil(t, packet)
+
+	// Can decode this layer
+	omciLayer := packet.Layer(LayerTypeOMCI)
+	assert.NotNil(t, omciLayer)
+
+	omciMsg, ok := omciLayer.(*OMCI)
+	assert.True(t, ok)
+	assert.NotNil(t, omciMsg)
+	assert.Equal(t, LayerTypeOMCI, omciMsg.LayerType())
+	assert.Equal(t, LayerTypeOMCI, omciMsg.CanDecode())
+	assert.Equal(t, LayerTypeMibUploadNextResponse, omciMsg.NextLayerType())
+	assert.Equal(t, uint16(0x82fd), omciMsg.TransactionID)
+	assert.Equal(t, MibUploadNextResponseType, omciMsg.MessageType)
+	assert.Equal(t, BaselineIdent, omciMsg.DeviceIdentifier)
+	assert.Equal(t, uint16(40), omciMsg.Length)
+
+	// Cannot decode this layer yet. Hope to in future partially with relaxed decoding
+	msgLayer := packet.Layer(LayerTypeMibUploadNextResponse)
+	assert.Nil(t, msgLayer)
+
+	// Look closer
+	errLayer := packet.Layer(gopacket.LayerTypeDecodeFailure)
+	assert.NotNil(t, errLayer)
+	decodeFailure, ok := errLayer.(*gopacket.DecodeFailure)
+	assert.NotNil(t, decodeFailure)
+	assert.True(t, ok)
+	errorMessage := decodeFailure.String()
+	assert.NotNil(t, errorMessage)
+	assert.True(t, len(errorMessage) > 0)
+
+	// Make sure that 'decode' shows up, not 'serialization'
+	assert.True(t, strings.Contains(strings.ToLower(errorMessage), "decode"))
+}