VOL-3769: Bugfix - inconsistencies when accepting attributeMask with error codes

Change-Id: Iaec0bc6df6cc641657172340ce017cecfa612c06
diff --git a/VERSION b/VERSION
index dffa40e..c37136a 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.13.4
+0.13.5
diff --git a/messagetypes.go b/messagetypes.go
index 553b7f3..614204d 100644
--- a/messagetypes.go
+++ b/messagetypes.go
@@ -725,7 +725,12 @@
 	//                   octets for data if the status code == 0.  So accommodate
 	//                   this behaviour in favor of greater interoperability.
 	lastOctet := 36
-	if omci.Result == me.AttributeFailure {
+
+	switch omci.Result {
+	case me.ProcessingError, me.NotSupported, me.UnknownEntity, me.UnknownInstance, me.DeviceBusy:
+		return nil // Done (do not try and decode attributes)
+
+	case me.AttributeFailure:
 		lastOctet = 32
 	}
 	omci.Attributes, err = meDefinition.DecodeAttributes(omci.AttributeMask, data[7:lastOctet], p, byte(GetResponseType))
@@ -3368,6 +3373,10 @@
 	}
 	omci.AttributeMask = binary.BigEndian.Uint16(data[4:6])
 
+	switch omci.Result {
+	case me.ProcessingError, me.NotSupported, me.UnknownEntity, me.UnknownInstance, me.DeviceBusy:
+		return nil // Done (do not try and decode attributes)
+	}
 	// Attribute decode
 	omci.Attributes, err = meDefinition.DecodeAttributes(omci.AttributeMask, data[6:], p, byte(GetCurrentDataResponseType))
 	if err != nil {
diff --git a/messagetypes_test.go b/messagetypes_test.go
index 4047ddd..c3ad0df 100644
--- a/messagetypes_test.go
+++ b/messagetypes_test.go
@@ -2688,5 +2688,36 @@
 	assert.Equal(t, strings.ToLower(goodMessage), reconstituted)
 }
 
+
+func TestJira3769(t *testing.T) {
+	// VOL-3769.  Error parsing get response with processing error and large mask
+	sampleMessage := "035e290a0101000001FFFC000000000000000000000000000000000000000000000000000000000000000028"
+	data, err := stringToPacket(sampleMessage)
+	assert.NoError(t, err)
+
+	packet := gopacket.NewPacket(data, LayerTypeOMCI, gopacket.NoCopy)
+	assert.NotNil(t, packet)
+
+	omciLayer := packet.Layer(LayerTypeOMCI)
+	assert.NotNil(t, omciLayer)
+
+	omciMsg, ok := omciLayer.(*OMCI)
+	assert.True(t, ok)
+	assert.Equal(t, omciMsg.TransactionID, uint16(0x035e))
+	assert.Equal(t, omciMsg.MessageType, GetResponseType)
+	assert.Equal(t, omciMsg.DeviceIdentifier, BaselineIdent)
+	assert.Equal(t, omciMsg.Length, uint16(40))
+
+	// before bugfix for this JIRA, the following call returned 'nil'  Failure was
+	// occuring before this at during getResposne decoding.
+	msgLayer := packet.Layer(LayerTypeGetResponse)
+	assert.NotNil(t, msgLayer)
+
+	response, ok2 := msgLayer.(*GetResponse)
+	assert.True(t, ok2)
+	assert.NotNil(t, response)
+	assert.Equal(t, response.Result, me.ProcessingError)
+	assert.Equal(t, response.AttributeMask, uint16(0xFFFC))
+}
 // TODO: Create notification tests for all of the following types
 //TestResult,