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
23 * Wire frame structure is presented bellow using ASN.1 notation. Please note that official supported specification
24 * should be available on
25 * [RTD documentation](https://onap.readthedocs.io/en/latest/submodules/dcaegen2.git/docs/sections/apis/ves-hv.html).
28 * -- Wire Transfer Protocol (binary, defined using ASN.1 notation)
29 * -- Encoding: use "direct encoding" to the number of octets indicated in the comment [n], using network byte order.
31 * WTP DEFINITIONS ::= BEGIN
33 * -- Used to sent data from the data provider
34 * WtpData ::= SEQUENCE {
35 * magic INTEGER (0..255), -- [1] always 0xAA
36 * versionMajor INTEGER (0..255), -- [1] major interface version, forward incompatible
37 * -- with previous major version, current value: 1
38 * versionMinor INTEGER (0..255), -- [1] minor interface version, forward compatible
39 * -- with previous minor version, current value: 0
40 * reserved OCTET STRING (SIZE (3)), -- [3] reserved for future use (ignored, but use 0)
41 * payloadId INTEGER (0..65535), -- [2] payload type: 0x0000=undefined, 0x0001=ONAP VesEvent (protobuf)
42 * payloadLength INTEGER (0..4294967295). -- [4] payload length in octets
43 * payload OCTET STRING -- [length as per payloadLength]
49 * @author Piotr Jaszczyk <piotr.jaszczyk@nokia.com>
52 data class WireFrameMessage(val payload: ByteData,
53 val versionMajor: Short,
54 val versionMinor: Short,
58 constructor(payload: ByteArray) : this(
60 SUPPORTED_VERSION_MAJOR,
61 SUPPORTED_VERSION_MINOR,
62 PayloadContentType.GOOGLE_PROTOCOL_BUFFER.hexValue,
65 fun isValid(): Boolean =
66 versionMajor == SUPPORTED_VERSION_MAJOR
67 && PayloadContentType.isValidHexValue(payloadType)
68 && payload.size() == payloadSize
71 const val MARKER_BYTE: Short = 0xAA
72 const val RESERVED_BYTE_COUNT: Int = 3
74 const val SUPPORTED_VERSION_MAJOR: Short = 1
75 const val SUPPORTED_VERSION_MINOR: Short = 0
77 const val HEADER_SIZE =
78 1 * java.lang.Byte.BYTES + // marker
79 2 * java.lang.Byte.BYTES + // single byte fields
80 1 * java.lang.Short.BYTES + // double byte fields
81 RESERVED_BYTE_COUNT * java.lang.Byte.BYTES + // reserved bytes
82 1 * java.lang.Integer.BYTES // payload length
84 const val DEFAULT_MAX_PAYLOAD_SIZE_BYTES = 1024 * 1024