VOL-3884: Add missing Result field Commit Software response
Change-Id: I75b168100bf87463daaf86e15f6f6b436d0b7d13
diff --git a/VERSION b/VERSION
index 2a0970c..201a22c 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.16.1
+0.16.2
diff --git a/messagetypes.go b/messagetypes.go
index 42a0d42..f0ff447 100644
--- a/messagetypes.go
+++ b/messagetypes.go
@@ -271,7 +271,7 @@
// DecodeFromBytes decodes the given bytes of a Create Response into this layer
func (omci *CreateResponse) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 3)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+3)
if err != nil {
return err
}
@@ -397,7 +397,7 @@
// DecodeFromBytes decodes the given bytes of a Delete Response into this layer
func (omci *DeleteResponse) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 1)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+1)
if err != nil {
return err
}
@@ -460,7 +460,7 @@
// DecodeFromBytes decodes the given bytes of a Set Request into this layer
func (omci *SetRequest) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 2)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+2)
if err != nil {
return err
}
@@ -567,7 +567,7 @@
// DecodeFromBytes decodes the given bytes of a Set Response into this layer
func (omci *SetResponse) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 5)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+5)
if err != nil {
return err
}
@@ -636,7 +636,7 @@
// DecodeFromBytes decodes the given bytes of a Get Request into this layer
func (omci *GetRequest) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 2)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+2)
if err != nil {
return err
}
@@ -703,7 +703,7 @@
// DecodeFromBytes decodes the given bytes of a Get Response into this layer
func (omci *GetResponse) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 3)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+3)
if err != nil {
return err
}
@@ -870,7 +870,7 @@
// DecodeFromBytes decodes the given bytes of a Get All Alarms Request into this layer
func (omci *GetAllAlarmsRequest) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 1)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+1)
if err != nil {
return err
}
@@ -948,7 +948,7 @@
// DecodeFromBytes decodes the given bytes of a Get All Alarms Response into this layer
func (omci *GetAllAlarmsResponse) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 2)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+2)
if err != nil {
return err
}
@@ -1021,7 +1021,7 @@
// DecodeFromBytes decodes the given bytes of a Get All Alarms Next Request into this layer
func (omci *GetAllAlarmsNextRequest) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 2)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+2)
if err != nil {
return err
}
@@ -1097,7 +1097,7 @@
// DecodeFromBytes decodes the given bytes of a Get All Alarms Next Response into this layer
func (omci *GetAllAlarmsNextResponse) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 4 + 28)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+4+28)
if err != nil {
return err
}
@@ -1240,7 +1240,7 @@
// DecodeFromBytes decodes the given bytes of a MIB Upload Response into this layer
func (omci *MibUploadResponse) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 2)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+2)
if err != nil {
return err
}
@@ -1313,7 +1313,7 @@
// DecodeFromBytes decodes the given bytes of a MIB Upload Next Request into this layer
func (omci *MibUploadNextRequest) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 2)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+2)
if err != nil {
return err
}
@@ -1386,7 +1386,7 @@
// DecodeFromBytes decodes the given bytes of a MIB Upload Next Response into this layer
func (omci *MibUploadNextResponse) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 6)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+6)
if err != nil {
return err
}
@@ -1511,7 +1511,7 @@
// DecodeFromBytes decodes the given bytes of a MIB Reset Response into this layer
func (omci *MibResetResponse) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 1)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+1)
if err != nil {
return err
}
@@ -1684,7 +1684,7 @@
// DecodeFromBytes decodes the given bytes of an Alarm Notification into this layer
func (omci *AlarmNotificationMsg) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 28)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+28)
if err != nil {
return err
}
@@ -1770,7 +1770,7 @@
// DecodeFromBytes decodes the given bytes of an Attribute Value Change notification into this layer
func (omci *AttributeValueChangeMsg) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 2)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+2)
if err != nil {
return err
}
@@ -1855,7 +1855,7 @@
// DecodeFromBytes decodes the given bytes of a Test Request into this layer
func (omci *TestRequest) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 5)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+5)
if err != nil {
return err
}
@@ -1891,7 +1891,7 @@
// DecodeFromBytes decodes the given bytes of a Test Response into this layer
func (omci *TestResponse) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 1)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+1)
if err != nil {
return err
}
@@ -1931,7 +1931,7 @@
// DecodeFromBytes decodes the given bytes of a Start Software Download Request into this layer
func (omci *StartSoftwareDownloadRequest) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 4)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+4)
if err != nil {
return err
}
@@ -2033,7 +2033,7 @@
// DecodeFromBytes decodes the given bytes of a Start Software Download Response into this layer
func (omci *StartSoftwareDownloadResponse) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 3)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+3)
if err != nil {
return err
}
@@ -2155,7 +2155,7 @@
// DecodeFromBytes decodes the given bytes of a Download Section Request into this layer
func (omci *DownloadSectionRequest) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 1)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+1)
if err != nil {
return err
}
@@ -2228,7 +2228,7 @@
// DecodeFromBytes decodes the given bytes of a Download Section Response into this layer
func (omci *DownloadSectionResponse) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 2)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+2)
if err != nil {
return err
}
@@ -2313,7 +2313,7 @@
// DecodeFromBytes decodes the given bytes of an End Software Download Request into this layer
func (omci *EndSoftwareDownloadRequest) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 7)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+7)
if err != nil {
return err
}
@@ -2406,7 +2406,7 @@
// DecodeFromBytes decodes the given bytes of an End Software Download Response into this layer
func (omci *EndSoftwareDownloadResponse) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 2)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+2)
if err != nil {
return err
}
@@ -2525,7 +2525,7 @@
// DecodeFromBytes decodes the given bytes of an Activate Software Request into this layer
func (omci *ActivateSoftwareRequest) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 1)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+1)
if err != nil {
return err
}
@@ -2604,7 +2604,7 @@
// DecodeFromBytes decodes the given bytes of an Activate Softwre Response into this layer
func (omci *ActivateSoftwareResponse) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 1)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+1)
if err != nil {
return err
}
@@ -2735,6 +2735,7 @@
//
type CommitSoftwareResponse struct {
MeBasePacket
+ Result me.Results
}
func (omci *CommitSoftwareResponse) String() string {
@@ -2744,7 +2745,7 @@
// DecodeFromBytes decodes the given bytes of a Commit Softwar Response into this layer
func (omci *CommitSoftwareResponse) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 1)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+1)
if err != nil {
return err
}
@@ -2753,7 +2754,7 @@
if omciErr.StatusCode() != me.Success {
return omciErr.GetError()
}
- // ME needs to support End Software Download
+ // ME needs to support Commit Software
if !me.SupportsMsgType(meDefinition, me.CommitSoftware) {
return me.NewProcessingError("managed entity does not support Commit Software Message-Type")
}
@@ -2761,6 +2762,12 @@
if omci.EntityClass != me.SoftwareImageClassID {
return me.NewProcessingError("invalid Entity Class for Commit Software response")
}
+ omci.Result = me.Results(data[4])
+ if omci.Result > me.Results(6) {
+ msg := fmt.Sprintf("invalid results for Commit Software response: %v, must be 0..6",
+ omci.Result)
+ return errors.New(msg)
+ }
return nil
}
@@ -2782,7 +2789,7 @@
if omciErr.StatusCode() != me.Success {
return omciErr.GetError()
}
- // ME needs to support End Software Download
+ // ME needs to support Commit Software
if !me.SupportsMsgType(meDefinition, me.CommitSoftware) {
return me.NewProcessingError("managed entity does not support Commit Message-Type")
}
@@ -2790,6 +2797,16 @@
if omci.EntityClass != me.SoftwareImageClassID {
return me.NewProcessingError("invalid Entity Class for Commit Software response")
}
+ bytes, err := b.AppendBytes(1)
+ if err != nil {
+ return err
+ }
+ bytes[0] = byte(omci.Result)
+ if omci.Result > me.Results(6) {
+ msg := fmt.Sprintf("invalid results for Commit Software response: %v, must be 0..6",
+ omci.Result)
+ return errors.New(msg)
+ }
return nil
}
@@ -2813,7 +2830,7 @@
// DecodeFromBytes decodes the given bytes of a Synchronize Time Request into this layer
func (omci *SynchronizeTimeRequest) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 7)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+7)
if err != nil {
return err
}
@@ -2893,7 +2910,7 @@
// DecodeFromBytes decodes the given bytes of a Synchronize Time Response into this layer
func (omci *SynchronizeTimeResponse) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 2)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+2)
if err != nil {
return err
}
@@ -2981,7 +2998,7 @@
// DecodeFromBytes decodes the given bytes of a Reboot Request into this layer
func (omci *RebootRequest) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 1)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+1)
if err != nil {
return err
}
@@ -3052,7 +3069,7 @@
// DecodeFromBytes decodes the given bytes of a Reboot Response into this layer
func (omci *RebootResponse) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 1)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+1)
if err != nil {
return err
}
@@ -3123,7 +3140,7 @@
// DecodeFromBytes decodes the given bytes of a Get Next Request into this layer
func (omci *GetNextRequest) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 4)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+4)
if err != nil {
return err
}
@@ -3194,7 +3211,7 @@
// DecodeFromBytes decodes the given bytes of a Get Next Response into this layer
func (omci *GetNextResponse) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 3)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+3)
if err != nil {
return err
}
@@ -3350,7 +3367,7 @@
// DecodeFromBytes decodes the given bytes of a Get Current Data Request into this layer
func (omci *GetCurrentDataRequest) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 2)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+2)
if err != nil {
return err
}
@@ -3416,7 +3433,7 @@
// DecodeFromBytes decodes the given bytes of a Get Current Data Respnse into this layer
func (omci *GetCurrentDataResponse) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 4 + 3)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 4+3)
if err != nil {
return err
}
@@ -3503,7 +3520,7 @@
// DecodeFromBytes decodes the given bytes of a Set Table Request into this layer
func (omci *SetTableRequest) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 6 + 2)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 6+2)
if err != nil {
return err
}
@@ -3540,7 +3557,7 @@
// DecodeFromBytes decodes the given bytes of a Set Table Response into this layer
func (omci *SetTableResponse) DecodeFromBytes(data []byte, p gopacket.PacketBuilder) error {
// Common ClassID/EntityID decode in msgBase
- err := omci.MeBasePacket.DecodeFromBytes(data, p, 6 + 1)
+ err := omci.MeBasePacket.DecodeFromBytes(data, p, 6+1)
if err != nil {
return err
}
diff --git a/messagetypes_test.go b/messagetypes_test.go
index 4604f40..64b3be3 100644
--- a/messagetypes_test.go
+++ b/messagetypes_test.go
@@ -2130,124 +2130,124 @@
}
func TestCommitSoftwareRequestDecode(t *testing.T) {
- // TODO: Need to complete implementation & debug this
- //goodMessage := "0000570a00070001000000000000000000000000000000000000000000000000000000000000000000000028"
- //data, err := stringToPacket(goodMessage)
- //assert.NoError(t, err)
- //
- //packet := gopacket.NewPacket(data, LayerTypeOMCI, gopacket.NoCopy)
- //assert.NotNil(t, packet)
- //
- //omciLayer := packet.Layer(LayerTypeOMCI)
- //assert.NotNil(t, packet)
- //
- //omciMsg, ok := omciLayer.(*OMCI)
- //assert.True(t, ok)
- //assert.Equal(t, omciMsg.TransactionID, uint16(0x0))
- //assert.Equal(t, omciMsg.MessageType, CommitSoftwareRequestType)
- //assert.Equal(t, omciMsg.DeviceIdentifier, BaselineIdent)
- //assert.Equal(t, omciMsg.Length, uint16(40))
- //
- //msgLayer := packet.Layer(LayerTypeCommitSoftwareRequest)
- //assert.NotNil(t, msgLayer)
- //
- //request, ok2 := msgLayer.(*CommitSoftwareRequest)
- //assert.True(t, ok2)
- //assert.NotNil(t, request)
- //
- //// Verify string output for message
- //packetString := packet.String()
- //assert.NotZero(t, len(packetString))
+ goodMessage := "0011570a00070001000000000000000000000000000000000000000000000000000000000000000000000028"
+ data, err := stringToPacket(goodMessage)
+ assert.NoError(t, err)
+
+ packet := gopacket.NewPacket(data, LayerTypeOMCI, gopacket.NoCopy)
+ assert.NotNil(t, packet)
+
+ omciLayer := packet.Layer(LayerTypeOMCI)
+ assert.NotNil(t, packet)
+
+ omciMsg, ok := omciLayer.(*OMCI)
+ assert.True(t, ok)
+ assert.Equal(t, omciMsg.TransactionID, uint16(0x11))
+ assert.Equal(t, omciMsg.MessageType, CommitSoftwareRequestType)
+ assert.Equal(t, omciMsg.DeviceIdentifier, BaselineIdent)
+ assert.Equal(t, omciMsg.Length, uint16(40))
+
+ msgLayer := packet.Layer(LayerTypeCommitSoftwareRequest)
+ assert.NotNil(t, msgLayer)
+
+ request, ok2 := msgLayer.(*CommitSoftwareRequest)
+ assert.True(t, ok2)
+ assert.NotNil(t, request)
+ assert.Equal(t, uint16(1), request.MeBasePacket.EntityInstance)
+
+ // Verify string output for message
+ packetString := packet.String()
+ assert.NotZero(t, len(packetString))
}
func TestCommitSoftwareRequestSerialize(t *testing.T) {
- // TODO: Need to complete implementation & debug this
- //goodMessage := "0000570a00070001000000000000000000000000000000000000000000000000000000000000000000000028"
- //
- //omciLayer := &OMCI{
- // TransactionID: 0x01,
- // MessageType: CommitSoftwareRequestType,
- // // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
- // // Length: 0x28, // Optional, defaults to 40 octets
- //}
- //request := &CommitSoftwareRequest{
- // MeBasePacket: MeBasePacket{
- // EntityClass: OnuDataClassID,
- // // Default Instance ID is 0
- // },
- //}
- //// Test serialization back to former string
- //var options gopacket.SerializeOptions
- //options.FixLengths = true
- //
- //buffer := gopacket.NewSerializeBuffer()
- //err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
- //assert.NoError(t, err)
- //
- //outgoingPacket := buffer.Bytes()
- //reconstituted := packetToString(outgoingPacket)
- //assert.Equal(t, strings.ToLower(goodMessage), reconstituted)
+ goodMessage := "0044570a00070001000000000000000000000000000000000000000000000000000000000000000000000028"
+
+ omciLayer := &OMCI{
+ TransactionID: 0x44,
+ MessageType: CommitSoftwareRequestType,
+ // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
+ // Length: 0x28, // Optional, defaults to 40 octets
+ }
+ request := &CommitSoftwareRequest{
+ MeBasePacket: MeBasePacket{
+ EntityClass: me.SoftwareImageClassID,
+ EntityInstance: 1, // Default Instance ID is 0
+ },
+ }
+ // Test serialization back to former string
+ var options gopacket.SerializeOptions
+ options.FixLengths = true
+
+ buffer := gopacket.NewSerializeBuffer()
+ err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
+ assert.NoError(t, err)
+
+ outgoingPacket := buffer.Bytes()
+ reconstituted := packetToString(outgoingPacket)
+ assert.Equal(t, strings.ToLower(goodMessage), reconstituted)
}
func TestCommitSoftwareResponseDecode(t *testing.T) {
- // TODO: Need to complete implementation & debug this
- //goodMessage := ""
- //data, err := stringToPacket(goodMessage)
- //assert.NoError(t, err)
- //
- //packet := gopacket.NewPacket(data, LayerTypeOMCI, gopacket.NoCopy)
- //assert.NotNil(t, packet)
- //
- //omciLayer := packet.Layer(LayerTypeOMCI)
- //assert.NotNil(t, packet)
- //
- //omciMsg, ok := omciLayer.(*OMCI)
- //assert.True(t, ok)
- //assert.Equal(t, omciMsg.TransactionID, uint16(0x0))
- //assert.Equal(t, omciMsg.MessageType, CommitSoftwareResponseType)
- //assert.Equal(t, omciMsg.DeviceIdentifier, BaselineIdent)
- //assert.Equal(t, omciMsg.Length, uint16(40))
- //
- //msgLayer := packet.Layer(LayerTypeCommitSoftwareResponse)
- //
- //assert.NotNil(t, msgLayer)
- //
- //response, ok2 := msgLayer.(*CommitSoftwareResponse)
- //assert.True(t, ok2)
- //assert.NotNil(t, response)
- //
- //// Verify string output for message
- //packetString := packet.String()
- //assert.NotZero(t, len(packetString))
+ goodMessage := "00aa370a00070001060000000000000000000000000000000000000000000000000000000000000000000028"
+ data, err := stringToPacket(goodMessage)
+ assert.NoError(t, err)
+
+ packet := gopacket.NewPacket(data, LayerTypeOMCI, gopacket.NoCopy)
+ assert.NotNil(t, packet)
+
+ omciLayer := packet.Layer(LayerTypeOMCI)
+ assert.NotNil(t, packet)
+
+ omciMsg, ok := omciLayer.(*OMCI)
+ assert.True(t, ok)
+ assert.Equal(t, omciMsg.TransactionID, uint16(0xaa))
+ assert.Equal(t, omciMsg.MessageType, CommitSoftwareResponseType)
+ assert.Equal(t, omciMsg.DeviceIdentifier, BaselineIdent)
+ assert.Equal(t, omciMsg.Length, uint16(40))
+
+ msgLayer := packet.Layer(LayerTypeCommitSoftwareResponse)
+
+ assert.NotNil(t, msgLayer)
+
+ response, ok2 := msgLayer.(*CommitSoftwareResponse)
+ assert.True(t, ok2)
+ assert.NotNil(t, response)
+ assert.Equal(t, uint16(1), response.MeBasePacket.EntityInstance)
+ assert.Equal(t, me.DeviceBusy, response.Result)
+
+ // Verify string output for message
+ packetString := packet.String()
+ assert.NotZero(t, len(packetString))
}
func TestCommitSoftwareResponseSerialize(t *testing.T) {
- // TODO: Need to complete implementation & debug this
- //goodMessage := ""
- //
- //omciLayer := &OMCI{
- // TransactionID: 0x01,
- // MessageType: CommitSoftwareResponseType,
- // // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
- // // Length: 0x28, // Optional, defaults to 40 octets
- //}
- //request := &CommitSoftwareResponse{
- // MeBasePacket: MeBasePacket{
- // EntityClass: OnuDataClassID,
- // // Default Instance ID is 0
- // },
- //}
- //// Test serialization back to former string
- //var options gopacket.SerializeOptions
- //options.FixLengths = true
- //
- //buffer := gopacket.NewSerializeBuffer()
- //err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
- //assert.NoError(t, err)
- //
- //outgoingPacket := buffer.Bytes()
- //reconstituted := packetToString(outgoingPacket)
- //assert.Equal(t, strings.ToLower(goodMessage), reconstituted)
+ goodMessage := "8001370a00070001060000000000000000000000000000000000000000000000000000000000000000000028"
+
+ omciLayer := &OMCI{
+ TransactionID: 0x8001,
+ MessageType: CommitSoftwareResponseType,
+ // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
+ // Length: 0x28, // Optional, defaults to 40 octets
+ }
+ request := &CommitSoftwareResponse{
+ MeBasePacket: MeBasePacket{
+ EntityClass: me.SoftwareImageClassID,
+ EntityInstance: 1, // Default Instance ID is 0
+ },
+ Result: me.DeviceBusy,
+ }
+ // Test serialization back to former string
+ var options gopacket.SerializeOptions
+ options.FixLengths = true
+
+ buffer := gopacket.NewSerializeBuffer()
+ err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
+ assert.NoError(t, err)
+
+ outgoingPacket := buffer.Bytes()
+ reconstituted := packetToString(outgoingPacket)
+ assert.Equal(t, strings.ToLower(goodMessage), reconstituted)
}
func TestMibResetResponseDecode(t *testing.T) {