mirror of
https://github.com/jwetzell/acn-js.git
synced 2026-09-10 07:49:26 +00:00
decode SDT data in RLP if found
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { RootLayerPDU } from '../models';
|
import pdu from '.';
|
||||||
|
import { Protocols, RootLayerPDU, SessionDataTransportPDU } from '../models';
|
||||||
import { toHex } from '../utils';
|
import { toHex } from '../utils';
|
||||||
|
|
||||||
function decode(bytes: Uint8Array): RootLayerPDU {
|
function decode(bytes: Uint8Array): RootLayerPDU {
|
||||||
@@ -49,7 +50,11 @@ function decode(bytes: Uint8Array): RootLayerPDU {
|
|||||||
const dataOffset = headerOffset + 16;
|
const dataOffset = headerOffset + 16;
|
||||||
// NOTE(jwetzell): flags/lengthH + lengthL + lengthX + vector + header
|
// NOTE(jwetzell): flags/lengthH + lengthL + lengthX + vector + header
|
||||||
const dataLength = length - (1 + 1 + (lengthFlag ? 1 : 0) + 4 + 16);
|
const dataLength = length - (1 + 1 + (lengthFlag ? 1 : 0) + 4 + 16);
|
||||||
const data = bytes.subarray(dataOffset, dataOffset + dataLength);
|
let data: SessionDataTransportPDU | Uint8Array = bytes.subarray(dataOffset, dataOffset + dataLength);
|
||||||
|
|
||||||
|
if (vector === Protocols.SDT) {
|
||||||
|
data = pdu.sdt.decode(data);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
vector,
|
vector,
|
||||||
|
|||||||
Reference in New Issue
Block a user