Change magic byte from 0xFF to 0xAA 89/69789/1
authorPiotr Jaszczyk <piotr.jaszczyk@nokia.com>
Thu, 4 Oct 2018 06:04:00 +0000 (08:04 +0200)
committerPiotr Jaszczyk <piotr.jaszczyk@nokia.com>
Thu, 4 Oct 2018 06:04:00 +0000 (08:04 +0200)
In final protocol specification the value has changed to 0xAA.

Change-Id: Id86c15117732b03bca38c674960d5eba8da88a6e
Issue-ID: DCAEGEN2-854
Signed-off-by: Piotr Jaszczyk <piotr.jaszczyk@nokia.com>
hv-collector-domain/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/wire_frame.kt
hv-collector-domain/src/test/kotlin/org/onap/dcae/collectors/veshv/domain/WireFrameCodecsTest.kt
hv-collector-test-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/tests/utils/messages.kt

index 06ca938..036888e 100644 (file)
@@ -26,7 +26,7 @@ package org.onap.dcae.collectors.veshv.domain
  * ```
  * -- Precedes every HV-VES message
  * Header ::= SEQUENCE {
- *   magic           INTEGER (0..255),         – always 0xFF, identifies extended header usage
+ *   magic           INTEGER (0..255),         – always 0xAA, identifies extended header usage
  *   versionMajor    INTEGER (0..255),         – major interface v, forward incompatible with previous major v
  *   versionMinor    INTEGER (0..255),         – minor interface v, forward compatible with previous minor v
  *   reserved        OCTET STRING (SIZE (3)),  – reserved for future use
@@ -58,7 +58,7 @@ data class WireFrameMessage(val payload: ByteData,
                     && payload.size() == payloadSize
 
     companion object {
-        const val MARKER_BYTE: Short = 0xFF
+        const val MARKER_BYTE: Short = 0xAA
         const val RESERVED_BYTE_COUNT: Int = 3
 
         const val SUPPORTED_VERSION_MAJOR: Short = 1
index 988789d..6756bf8 100644 (file)
@@ -183,16 +183,16 @@ object WireFrameCodecsTest : Spek({
 
             it("should return error when payload message header does not fit") {
                 val buff = Unpooled.buffer()
-                        .writeByte(0xFF)
+                        .writeByte(0xAA)
                         .writeBytes("MOMOM".toByteArray())
 
                 decoder.decodeFirst(buff).assertFailedWithError { it.isInstanceOf(MissingWireFrameHeaderBytes::class.java) }
                 assertBufferIntact(buff)
             }
 
-            it("should return error when length looks ok but first byte is not 0xFF") {
+            it("should return error when length looks ok but first byte is not 0xAA") {
                 val buff = Unpooled.buffer()
-                        .writeByte(0x69)
+                        .writeByte(0xFF)
                         .writeBytes("some garbage".toByteArray())
 
                 decoder.decodeFirst(buff).assertFailedWithError { it.isInstanceOf(InvalidWireFrameMarker::class.java) }
@@ -262,7 +262,7 @@ object WireFrameCodecsTest : Spek({
                         payloadSize = payload.size)
 
 
-                assertTrue(decoder.decodeFirst(encoder.encode(input).writeByte(0xFF)).isRight())
+                assertTrue(decoder.decodeFirst(encoder.encode(input).writeByte(0xAA)).isRight())
             }
         }
     }
index 7250443..035d94e 100644 (file)
@@ -35,7 +35,7 @@ import java.util.UUID.randomUUID
 val allocator: ByteBufAllocator = PooledByteBufAllocator.DEFAULT
 
 private fun ByteBuf.writeValidWireFrameHeaders() {
-    writeByte(0xFF)          // always 0xFF
+    writeByte(0xAA)          // always 0xAA
     writeByte(0x01)          // major version
     writeByte(0x00)          // minor version
     writeZero(RESERVED_BYTE_COUNT)  // reserved
@@ -65,7 +65,7 @@ fun garbageFrame(): ByteBuf = allocator.buffer().run {
 }
 
 fun invalidWireFrame(): ByteBuf = allocator.buffer().run {
-    writeByte(0xFF)
+    writeByte(0xAA)
     writeByte(0x01)   // version major
     writeByte(0x01)   // version minor
 }