VOL-3808: Bugfix for Download Section Request 1 & 2
Change-Id: I93710ecfe111a1f89408fd7e461ce735bd5fc4f3
diff --git a/omci.go b/omci.go
index 7a162d6..3904352 100644
--- a/omci.go
+++ b/omci.go
@@ -112,6 +112,7 @@
TransactionID uint16
MessageType MessageType
DeviceIdentifier DeviceIdent
+ ResponseExpected bool // Significant for Download Section Request only
Payload []byte
padding []byte
Length uint16
@@ -206,6 +207,7 @@
omci.TransactionID = binary.BigEndian.Uint16(data[0:])
omci.MessageType = MessageType(data[2])
omci.DeviceIdentifier = DeviceIdent(data[3])
+ omci.ResponseExpected = byte(omci.MessageType)&me.AR == me.AR
isNotification := (int(omci.MessageType) & ^me.MsgTypeMask) == 0
if omci.TransactionID == 0 && !isNotification {
@@ -298,7 +300,13 @@
return errors.New(msg)
}
binary.BigEndian.PutUint16(bytes, omci.TransactionID)
- bytes[2] = byte(omci.MessageType)
+ // Download section request can optionally have the AR bit set or cleared. If user passes in this
+ // message type and sets download requested, fix up the message type for them.
+ if omci.MessageType == DownloadSectionRequestType && omci.ResponseExpected {
+ bytes[2] = byte(DownloadSectionRequestWithResponseType)
+ } else {
+ bytes[2] = byte(omci.MessageType)
+ }
bytes[3] = byte(omci.DeviceIdentifier)
b.PushLayer(LayerTypeOMCI)