diff options
author | Piotr Jaszczyk <piotr.jaszczyk@nokia.com> | 2018-10-05 10:19:57 +0200 |
---|---|---|
committer | Piotr Jaszczyk <piotr.jaszczyk@nokia.com> | 2018-10-05 10:19:57 +0200 |
commit | 344bc193fece33112fc9a323bb4e3e93684bcab4 (patch) | |
tree | 419acecc886df9424910c1b122a40bd50335149c /hv-collector-domain/src/main/kotlin | |
parent | ffe57b5673af80942925eed5b8e793ce2cf750b1 (diff) |
Remove any inconsistencies with specification3.0.0-ONAP1.0.0
* Fix payloadId field issue (was 1 byte, should use 2 byts)
* Copy final version of protobuf and asn definitions (mostly comments)
* Added links to yet-to-be updated RTD documentation
Change-Id: I69bda676423ad601797d95577ff8af6707cacb0c
Issue-ID: DCAEGEN2-857
Signed-off-by: Piotr Jaszczyk <piotr.jaszczyk@nokia.com>
Diffstat (limited to 'hv-collector-domain/src/main/kotlin')
3 files changed, 29 insertions, 17 deletions
diff --git a/hv-collector-domain/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/PayloadContentType.kt b/hv-collector-domain/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/PayloadContentType.kt index 0ba4b81d..7cbf3530 100644 --- a/hv-collector-domain/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/PayloadContentType.kt +++ b/hv-collector-domain/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/PayloadContentType.kt @@ -23,12 +23,12 @@ package org.onap.dcae.collectors.veshv.domain * @author Piotr Jaszczyk <piotr.jaszczyk@nokia.com> * @since June 2018 */ -enum class PayloadContentType(val hexValue: Short) { - GOOGLE_PROTOCOL_BUFFER(0x01); +enum class PayloadContentType(val hexValue: Int) { + GOOGLE_PROTOCOL_BUFFER(0x0001); companion object { private val hexValues = PayloadContentType.values().map { it.hexValue } - fun isValidHexValue(hex: Short) = hexValues.contains(hex) + fun isValidHexValue(hex: Int) = hexValues.contains(hex) } } diff --git a/hv-collector-domain/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/codec.kt b/hv-collector-domain/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/codec.kt index f08ec178..480ec693 100644 --- a/hv-collector-domain/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/codec.kt +++ b/hv-collector-domain/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/codec.kt @@ -39,7 +39,7 @@ class WireFrameEncoder(private val allocator: ByteBufAllocator = ByteBufAllocato writeByte(frame.versionMajor.toInt()) writeByte(frame.versionMinor.toInt()) writeZero(RESERVED_BYTE_COUNT) - writeByte(frame.payloadType.toInt()) + writeShort(frame.payloadType) writeInt(frame.payloadSize) } .also { @@ -81,7 +81,7 @@ class WireFrameDecoder(private val maxPayloadSizeBytes: Int) { val versionMajor = byteBuf.readUnsignedByte() val versionMinor = byteBuf.readUnsignedByte() byteBuf.skipBytes(RESERVED_BYTE_COUNT) - val payloadTypeRaw = byteBuf.readUnsignedByte() + val payloadTypeRaw = byteBuf.readUnsignedShort() val payloadSize = byteBuf.readInt() if (payloadSize > maxPayloadSizeBytes) { diff --git a/hv-collector-domain/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/wire_frame.kt b/hv-collector-domain/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/wire_frame.kt index 5fdc5afe..de6a5045 100644 --- a/hv-collector-domain/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/wire_frame.kt +++ b/hv-collector-domain/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/wire_frame.kt @@ -21,19 +21,30 @@ package org.onap.dcae.collectors.veshv.domain /** - * Wire frame structure is presented bellow using ASN.1 notation. All fields are in network byte order (big-endian). + * Wire frame structure is presented bellow using ASN.1 notation. Please note that official supported specification + * should be available on + * [RTD documentation](https://onap.readthedocs.io/en/latest/submodules/dcaegen2.git/docs/sections/apis/ves-hv.html). * * ``` - * -- Precedes every HV-VES message - * Header ::= SEQUENCE { - * 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 - * payloadId INTEGER (0..255), – message payload type: 0x00=undefined, 0x01=protobuf - * payloadLength INTEGER (0..4294967295) – message payload length - * payload OCTET STRING – length as per payloadLength + * -- Wire Transfer Protocol (binary, defined using ASN.1 notation) + * -- Encoding: use "direct encoding" to the number of octets indicated in the comment [n], using network byte order. + * + * WTP DEFINITIONS ::= BEGIN + * + * -- Used to sent data from the data provider + * WtpData ::= SEQUENCE { + * magic INTEGER (0..255), -- [1] always 0xAA + * versionMajor INTEGER (0..255), -- [1] major interface version, forward incompatible + * -- with previous major version, current value: 1 + * versionMinor INTEGER (0..255), -- [1] minor interface version, forward compatible + * -- with previous minor version, current value: 0 + * reserved OCTET STRING (SIZE (3)), -- [3] reserved for future use (ignored, but use 0) + * payloadId INTEGER (0..65535), -- [2] payload type: 0x0000=undefined, 0x0001=ONAP VesEvent (protobuf) + * payloadLength INTEGER (0..4294967295). -- [4] payload length in octets + * payload OCTET STRING -- [length as per payloadLength] * } + * + * END * ``` * * @author Piotr Jaszczyk <piotr.jaszczyk@nokia.com> @@ -42,7 +53,7 @@ package org.onap.dcae.collectors.veshv.domain data class WireFrameMessage(val payload: ByteData, val versionMajor: Short, val versionMinor: Short, - val payloadType: Short, + val payloadType: Int, val payloadSize: Int ) { constructor(payload: ByteArray) : this( @@ -66,7 +77,8 @@ data class WireFrameMessage(val payload: ByteData, const val HEADER_SIZE = 1 * java.lang.Byte.BYTES + // marker - 3 * java.lang.Byte.BYTES + // single byte fields + 2 * java.lang.Byte.BYTES + // single byte fields + 1 * java.lang.Short.BYTES + // double byte fields RESERVED_BYTE_COUNT * java.lang.Byte.BYTES + // reserved bytes 1 * java.lang.Integer.BYTES // payload length |