2 * ============LICENSE_START=======================================================
3 * dcaegen2-collectors-veshv
4 * ================================================================================
5 * Copyright (C) 2018 NOKIA
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.dcae.collectors.veshv.domain
24 * Wire frame structure is presented bellow using ASN.1 notation. Please note that official supported specification
25 * should be available on
26 * [RTD documentation](https://onap.readthedocs.io/en/latest/submodules/dcaegen2.git/docs/sections/apis/ves-hv.html).
29 * -- Wire Transfer Protocol (binary, defined using ASN.1 notation)
30 * -- Encoding: use "direct encoding" to the number of octets indicated in the comment [n], using network byte order.
32 * WTP DEFINITIONS ::= BEGIN
34 * -- Used to sent data from the data provider
35 * WtpData ::= SEQUENCE {
36 * magic INTEGER (0..255), -- [1] always 0xAA
37 * versionMajor INTEGER (0..255), -- [1] major interface version, forward incompatible
38 * -- with previous major version, current value: 1
39 * versionMinor INTEGER (0..255), -- [1] minor interface version, forward compatible
40 * -- with previous minor version, current value: 0
41 * reserved OCTET STRING (SIZE (3)), -- [3] reserved for future use (ignored, but use 0)
42 * payloadId INTEGER (0..65535), -- [2] payload type: 0x0000=undefined, 0x0001=ONAP VesEvent (protobuf)
43 * payloadLength INTEGER (0..4294967295). -- [4] payload length in octets
44 * payload OCTET STRING -- [length as per payloadLength]
50 * @author Piotr Jaszczyk <piotr.jaszczyk@nokia.com>
53 data class WireFrameMessage(val payload: ByteData,
54 val versionMajor: Short,
55 val versionMinor: Short,
59 constructor(payload: ByteArray) : this(
61 SUPPORTED_VERSION_MAJOR,
62 SUPPORTED_VERSION_MINOR,
63 PayloadContentType.GOOGLE_PROTOCOL_BUFFER.hexValue,
66 fun isValid(): Boolean =
67 versionMajor == SUPPORTED_VERSION_MAJOR
68 && PayloadContentType.isValidHexValue(payloadType)
69 && payload.size() == payloadSize
72 const val MARKER_BYTE: Short = 0xAA
73 const val RESERVED_BYTE_COUNT: Int = 3
75 const val SUPPORTED_VERSION_MAJOR: Short = 1
76 const val SUPPORTED_VERSION_MINOR: Short = 0
78 const val HEADER_SIZE =
79 1 * java.lang.Byte.BYTES + // marker
80 2 * java.lang.Byte.BYTES + // single byte fields
81 1 * java.lang.Short.BYTES + // double byte fields
82 RESERVED_BYTE_COUNT * java.lang.Byte.BYTES + // reserved bytes
83 1 * java.lang.Integer.BYTES // payload length
85 const val DEFAULT_MAX_PAYLOAD_SIZE_BYTES = 1024 * 1024