netkitty 0.0.15 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/inspectionProfiles/Project_Default.xml +1 -1
- package/README.md +1 -1
- package/assets/NetKitty.png +0 -0
- package/package.json +28 -4
- package/src/CodecExports.ts +33 -0
- package/src/CodecHeaderExports.ts +1 -0
- package/src/HelperExports.ts +78 -0
- package/src/NetKitty.ts +91 -31
- package/src/NetworkExports.ts +12 -0
- package/src/PcapExports.ts +16 -0
- package/src/lib/codec/Codec.ts +2 -21
- package/src/lib/codec/PacketHeaders.ts +13 -0
- package/src/lib/codec/headers/ARP.ts +7 -7
- package/src/lib/codec/headers/EthernetII.ts +1 -1
- package/src/lib/codec/headers/Goose.ts +6 -6
- package/src/lib/codec/headers/ICMP.ts +151 -0
- package/src/lib/codec/headers/ICMPv6.ts +128 -0
- package/src/lib/codec/headers/IEC61850SampledValues.ts +5 -5
- package/src/lib/codec/headers/IPv4.ts +8 -8
- package/src/lib/codec/headers/IPv6.ts +176 -0
- package/src/lib/codec/headers/IPv6HopByHopOptions.ts +532 -0
- package/src/lib/codec/headers/RawData.ts +1 -1
- package/src/lib/codec/headers/TCP.ts +6 -5
- package/src/lib/codec/headers/UDP.ts +3 -3
- package/src/lib/codec/headers/VLAN_802dot1Q.ts +2 -2
- package/src/lib/helper/HexToBuffer.ts +22 -0
- package/src/tests/units/Codec.spec.ts +13 -14
- package/dist/NetKitty.d.ts +0 -32
- package/dist/NetKitty.d.ts.map +0 -1
- package/dist/NetKitty.js +0 -34
- package/dist/errors/ActionNotFoundError.d.ts +0 -5
- package/dist/errors/ActionNotFoundError.d.ts.map +0 -1
- package/dist/errors/ActionNotFoundError.js +0 -12
- package/dist/errors/CodecSchemaValidateError.d.ts +0 -5
- package/dist/errors/CodecSchemaValidateError.d.ts.map +0 -1
- package/dist/errors/CodecSchemaValidateError.js +0 -12
- package/dist/errors/DeviceNotFoundError.d.ts +0 -5
- package/dist/errors/DeviceNotFoundError.d.ts.map +0 -1
- package/dist/errors/DeviceNotFoundError.js +0 -12
- package/dist/errors/NoAvailableCodecError.d.ts +0 -5
- package/dist/errors/NoAvailableCodecError.d.ts.map +0 -1
- package/dist/errors/NoAvailableCodecError.js +0 -12
- package/dist/errors/NpcapLoadError.d.ts +0 -5
- package/dist/errors/NpcapLoadError.d.ts.map +0 -1
- package/dist/errors/NpcapLoadError.js +0 -12
- package/dist/errors/SocketDownError.d.ts +0 -5
- package/dist/errors/SocketDownError.d.ts.map +0 -1
- package/dist/errors/SocketDownError.js +0 -12
- package/dist/errors/UnknownPipeMessageTypeError.d.ts +0 -5
- package/dist/errors/UnknownPipeMessageTypeError.d.ts.map +0 -1
- package/dist/errors/UnknownPipeMessageTypeError.js +0 -12
- package/dist/errors/common/ErrorCode.d.ts +0 -31
- package/dist/errors/common/ErrorCode.d.ts.map +0 -1
- package/dist/errors/common/ErrorCode.js +0 -33
- package/dist/lib/GeneratePipeAddress.d.ts +0 -7
- package/dist/lib/GeneratePipeAddress.d.ts.map +0 -1
- package/dist/lib/GeneratePipeAddress.js +0 -23
- package/dist/lib/GetBinding.d.ts +0 -2
- package/dist/lib/GetBinding.d.ts.map +0 -1
- package/dist/lib/GetBinding.js +0 -6
- package/dist/lib/GetCaptureTemporaryDirectory.d.ts +0 -7
- package/dist/lib/GetCaptureTemporaryDirectory.d.ts.map +0 -1
- package/dist/lib/GetCaptureTemporaryDirectory.js +0 -15
- package/dist/lib/GetDeviceCaptureTemporaryFilename.d.ts +0 -8
- package/dist/lib/GetDeviceCaptureTemporaryFilename.d.ts.map +0 -1
- package/dist/lib/GetDeviceCaptureTemporaryFilename.js +0 -18
- package/dist/lib/codec/Codec.d.ts +0 -33
- package/dist/lib/codec/Codec.d.ts.map +0 -1
- package/dist/lib/codec/Codec.js +0 -168
- package/dist/lib/codec/abstracts/BaseHeader.d.ts +0 -217
- package/dist/lib/codec/abstracts/BaseHeader.d.ts.map +0 -1
- package/dist/lib/codec/abstracts/BaseHeader.js +0 -356
- package/dist/lib/codec/headers/ARP.d.ts +0 -10
- package/dist/lib/codec/headers/ARP.d.ts.map +0 -1
- package/dist/lib/codec/headers/ARP.js +0 -224
- package/dist/lib/codec/headers/EthernetII.d.ts +0 -10
- package/dist/lib/codec/headers/EthernetII.d.ts.map +0 -1
- package/dist/lib/codec/headers/EthernetII.js +0 -81
- package/dist/lib/codec/headers/Goose.d.ts +0 -13
- package/dist/lib/codec/headers/Goose.d.ts.map +0 -1
- package/dist/lib/codec/headers/Goose.js +0 -720
- package/dist/lib/codec/headers/IEC61850SampledValues.d.ts +0 -13
- package/dist/lib/codec/headers/IEC61850SampledValues.d.ts.map +0 -1
- package/dist/lib/codec/headers/IEC61850SampledValues.js +0 -370
- package/dist/lib/codec/headers/IPv4.d.ts +0 -16
- package/dist/lib/codec/headers/IPv4.d.ts.map +0 -1
- package/dist/lib/codec/headers/IPv4.js +0 -339
- package/dist/lib/codec/headers/RawData.d.ts +0 -11
- package/dist/lib/codec/headers/RawData.d.ts.map +0 -1
- package/dist/lib/codec/headers/RawData.js +0 -36
- package/dist/lib/codec/headers/TCP.d.ts +0 -16
- package/dist/lib/codec/headers/TCP.d.ts.map +0 -1
- package/dist/lib/codec/headers/TCP.js +0 -898
- package/dist/lib/codec/headers/UDP.d.ts +0 -16
- package/dist/lib/codec/headers/UDP.d.ts.map +0 -1
- package/dist/lib/codec/headers/UDP.js +0 -192
- package/dist/lib/codec/headers/VLAN_802dot1Q.d.ts +0 -10
- package/dist/lib/codec/headers/VLAN_802dot1Q.d.ts.map +0 -1
- package/dist/lib/codec/headers/VLAN_802dot1Q.js +0 -78
- package/dist/lib/codec/lib/BufferToHex.d.ts +0 -2
- package/dist/lib/codec/lib/BufferToHex.d.ts.map +0 -1
- package/dist/lib/codec/lib/BufferToHex.js +0 -6
- package/dist/lib/codec/lib/BufferToIP.d.ts +0 -13
- package/dist/lib/codec/lib/BufferToIP.d.ts.map +0 -1
- package/dist/lib/codec/lib/BufferToIP.js +0 -21
- package/dist/lib/codec/lib/BufferToNumber.d.ts +0 -10
- package/dist/lib/codec/lib/BufferToNumber.d.ts.map +0 -1
- package/dist/lib/codec/lib/BufferToNumber.js +0 -22
- package/dist/lib/codec/lib/FixHexString.d.ts +0 -7
- package/dist/lib/codec/lib/FixHexString.d.ts.map +0 -1
- package/dist/lib/codec/lib/FixHexString.js +0 -11
- package/dist/lib/codec/lib/FlexibleObject.d.ts +0 -28
- package/dist/lib/codec/lib/FlexibleObject.d.ts.map +0 -1
- package/dist/lib/codec/lib/FlexibleObject.js +0 -102
- package/dist/lib/codec/lib/HexToNumber.d.ts +0 -10
- package/dist/lib/codec/lib/HexToNumber.d.ts.map +0 -1
- package/dist/lib/codec/lib/HexToNumber.js +0 -39
- package/dist/lib/codec/lib/IPToBuffer.d.ts +0 -13
- package/dist/lib/codec/lib/IPToBuffer.d.ts.map +0 -1
- package/dist/lib/codec/lib/IPToBuffer.js +0 -28
- package/dist/lib/codec/lib/NumberToBERBuffer.d.ts +0 -9
- package/dist/lib/codec/lib/NumberToBERBuffer.d.ts.map +0 -1
- package/dist/lib/codec/lib/NumberToBERBuffer.js +0 -20
- package/dist/lib/codec/lib/NumberToBERHex.d.ts +0 -9
- package/dist/lib/codec/lib/NumberToBERHex.d.ts.map +0 -1
- package/dist/lib/codec/lib/NumberToBERHex.js +0 -23
- package/dist/lib/codec/lib/NumberToBuffer.d.ts +0 -10
- package/dist/lib/codec/lib/NumberToBuffer.d.ts.map +0 -1
- package/dist/lib/codec/lib/NumberToBuffer.js +0 -22
- package/dist/lib/codec/lib/NumberToHex.d.ts +0 -10
- package/dist/lib/codec/lib/NumberToHex.d.ts.map +0 -1
- package/dist/lib/codec/lib/NumberToHex.js +0 -26
- package/dist/lib/codec/lib/ProcessPacketPostHandlers.d.ts +0 -14
- package/dist/lib/codec/lib/ProcessPacketPostHandlers.d.ts.map +0 -1
- package/dist/lib/codec/lib/ProcessPacketPostHandlers.js +0 -53
- package/dist/lib/codec/lib/SortPostHandlers.d.ts +0 -8
- package/dist/lib/codec/lib/SortPostHandlers.d.ts.map +0 -1
- package/dist/lib/codec/lib/SortPostHandlers.js +0 -11
- package/dist/lib/codec/lib/StringContentEncodingEnum.d.ts +0 -11
- package/dist/lib/codec/lib/StringContentEncodingEnum.d.ts.map +0 -1
- package/dist/lib/codec/lib/StringContentEncodingEnum.js +0 -14
- package/dist/lib/codec/types/CodecData.d.ts +0 -7
- package/dist/lib/codec/types/CodecData.d.ts.map +0 -1
- package/dist/lib/codec/types/CodecData.js +0 -2
- package/dist/lib/codec/types/CodecDecodeResult.d.ts +0 -11
- package/dist/lib/codec/types/CodecDecodeResult.d.ts.map +0 -1
- package/dist/lib/codec/types/CodecDecodeResult.js +0 -2
- package/dist/lib/codec/types/CodecEncodeInput.d.ts +0 -9
- package/dist/lib/codec/types/CodecEncodeInput.d.ts.map +0 -1
- package/dist/lib/codec/types/CodecEncodeInput.js +0 -2
- package/dist/lib/codec/types/CodecEncodeResult.d.ts +0 -6
- package/dist/lib/codec/types/CodecEncodeResult.d.ts.map +0 -1
- package/dist/lib/codec/types/CodecEncodeResult.js +0 -2
- package/dist/lib/codec/types/CodecErrorInfo.d.ts +0 -6
- package/dist/lib/codec/types/CodecErrorInfo.d.ts.map +0 -1
- package/dist/lib/codec/types/CodecErrorInfo.js +0 -2
- package/dist/lib/codec/types/CodecModule.d.ts +0 -3
- package/dist/lib/codec/types/CodecModule.d.ts.map +0 -1
- package/dist/lib/codec/types/CodecModule.js +0 -2
- package/dist/lib/codec/types/CodecModuleConstructor.d.ts +0 -3
- package/dist/lib/codec/types/CodecModuleConstructor.d.ts.map +0 -1
- package/dist/lib/codec/types/CodecModuleConstructor.js +0 -2
- package/dist/lib/codec/types/CodecSchema.d.ts +0 -7
- package/dist/lib/codec/types/CodecSchema.d.ts.map +0 -1
- package/dist/lib/codec/types/CodecSchema.js +0 -2
- package/dist/lib/codec/types/HeaderTreeNode.d.ts +0 -5
- package/dist/lib/codec/types/HeaderTreeNode.d.ts.map +0 -1
- package/dist/lib/codec/types/HeaderTreeNode.js +0 -2
- package/dist/lib/codec/types/PostHandlerItem.d.ts +0 -5
- package/dist/lib/codec/types/PostHandlerItem.d.ts.map +0 -1
- package/dist/lib/codec/types/PostHandlerItem.js +0 -2
- package/dist/lib/nodepcap/Capture.d.ts +0 -75
- package/dist/lib/nodepcap/Capture.d.ts.map +0 -1
- package/dist/lib/nodepcap/Capture.js +0 -309
- package/dist/lib/nodepcap/GetNetworkInterfaces.d.ts +0 -7
- package/dist/lib/nodepcap/GetNetworkInterfaces.d.ts.map +0 -1
- package/dist/lib/nodepcap/GetNetworkInterfaces.js +0 -22
- package/dist/lib/nodepcap/interfaces/IBindingCapture.d.ts +0 -16
- package/dist/lib/nodepcap/interfaces/IBindingCapture.d.ts.map +0 -1
- package/dist/lib/nodepcap/interfaces/IBindingCapture.js +0 -2
- package/dist/lib/nodepcap/interfaces/IBindingCaptureOptions.d.ts +0 -5
- package/dist/lib/nodepcap/interfaces/IBindingCaptureOptions.d.ts.map +0 -1
- package/dist/lib/nodepcap/interfaces/IBindingCaptureOptions.js +0 -2
- package/dist/lib/nodepcap/interfaces/ICaptureOptions.d.ts +0 -19
- package/dist/lib/nodepcap/interfaces/ICaptureOptions.d.ts.map +0 -1
- package/dist/lib/nodepcap/interfaces/ICaptureOptions.js +0 -2
- package/dist/lib/nodepcap/interfaces/INetworkInterface.d.ts +0 -5
- package/dist/lib/nodepcap/interfaces/INetworkInterface.d.ts.map +0 -1
- package/dist/lib/nodepcap/interfaces/INetworkInterface.js +0 -2
- package/dist/lib/nodepcap/lib/BindingCapture.d.ts +0 -15
- package/dist/lib/nodepcap/lib/BindingCapture.d.ts.map +0 -1
- package/dist/lib/nodepcap/lib/BindingCapture.js +0 -35
- package/dist/lib/nodepcap/lib/GetNodePcapBinding.d.ts +0 -2
- package/dist/lib/nodepcap/lib/GetNodePcapBinding.d.ts.map +0 -1
- package/dist/lib/nodepcap/lib/GetNodePcapBinding.js +0 -55
- package/dist/lib/nodepcap/lib/GetNodePcapBindingCapture.d.ts +0 -3
- package/dist/lib/nodepcap/lib/GetNodePcapBindingCapture.d.ts.map +0 -1
- package/dist/lib/nodepcap/lib/GetNodePcapBindingCapture.js +0 -18
- package/dist/lib/nodepcap/workers/CaptureWorker.d.ts +0 -2
- package/dist/lib/nodepcap/workers/CaptureWorker.d.ts.map +0 -1
- package/dist/lib/nodepcap/workers/CaptureWorker.js +0 -25
- package/dist/lib/pcap/PCAPGenerator.d.ts +0 -34
- package/dist/lib/pcap/PCAPGenerator.d.ts.map +0 -1
- package/dist/lib/pcap/PCAPGenerator.js +0 -95
- package/dist/lib/pcap/PcapParser.d.ts +0 -27
- package/dist/lib/pcap/PcapParser.d.ts.map +0 -1
- package/dist/lib/pcap/PcapParser.js +0 -149
- package/dist/lib/pcap/PcapReader.d.ts +0 -89
- package/dist/lib/pcap/PcapReader.d.ts.map +0 -1
- package/dist/lib/pcap/PcapReader.js +0 -209
- package/dist/lib/pcap/PcapWriter.d.ts +0 -29
- package/dist/lib/pcap/PcapWriter.d.ts.map +0 -1
- package/dist/lib/pcap/PcapWriter.js +0 -80
- package/dist/lib/pcap/interfaces/IPcapPacketInfo.d.ts +0 -13
- package/dist/lib/pcap/interfaces/IPcapPacketInfo.d.ts.map +0 -1
- package/dist/lib/pcap/interfaces/IPcapPacketInfo.js +0 -2
- package/dist/lib/pipe/PipeClient.d.ts +0 -35
- package/dist/lib/pipe/PipeClient.d.ts.map +0 -1
- package/dist/lib/pipe/PipeClient.js +0 -71
- package/dist/lib/pipe/PipeClientSocket.d.ts +0 -39
- package/dist/lib/pipe/PipeClientSocket.d.ts.map +0 -1
- package/dist/lib/pipe/PipeClientSocket.js +0 -82
- package/dist/lib/pipe/PipeMessage.d.ts +0 -27
- package/dist/lib/pipe/PipeMessage.d.ts.map +0 -1
- package/dist/lib/pipe/PipeMessage.js +0 -61
- package/dist/lib/pipe/PipeMessageHandler.d.ts +0 -16
- package/dist/lib/pipe/PipeMessageHandler.d.ts.map +0 -1
- package/dist/lib/pipe/PipeMessageHandler.js +0 -95
- package/dist/lib/pipe/PipeServer.d.ts +0 -25
- package/dist/lib/pipe/PipeServer.d.ts.map +0 -1
- package/dist/lib/pipe/PipeServer.js +0 -59
- package/dist/lib/schema/ProtocolFieldJSONSchema.d.ts +0 -35
- package/dist/lib/schema/ProtocolFieldJSONSchema.d.ts.map +0 -1
- package/dist/lib/schema/ProtocolFieldJSONSchema.js +0 -2
- package/dist/lib/schema/ProtocolFieldJSONSchemaDefinition.d.ts +0 -3
- package/dist/lib/schema/ProtocolFieldJSONSchemaDefinition.d.ts.map +0 -1
- package/dist/lib/schema/ProtocolFieldJSONSchemaDefinition.js +0 -2
- package/dist/lib/schema/ProtocolJSONSchema.d.ts +0 -32
- package/dist/lib/schema/ProtocolJSONSchema.d.ts.map +0 -1
- package/dist/lib/schema/ProtocolJSONSchema.js +0 -2
- package/dist/tests/Test.spec.d.ts +0 -2
- package/dist/tests/Test.spec.d.ts.map +0 -1
- package/dist/tests/Test.spec.js +0 -25
- package/dist/tests/units/CaptureTest.spec.d.ts +0 -2
- package/dist/tests/units/CaptureTest.spec.d.ts.map +0 -1
- package/dist/tests/units/CaptureTest.spec.js +0 -31
- package/dist/tests/units/Codec.spec.d.ts +0 -2
- package/dist/tests/units/Codec.spec.d.ts.map +0 -1
- package/dist/tests/units/Codec.spec.js +0 -76
- package/dist/tests/units/ReadPCAP.spec.d.ts +0 -2
- package/dist/tests/units/ReadPCAP.spec.d.ts.map +0 -1
- package/dist/tests/units/ReadPCAP.spec.js +0 -14
- package/src/lib/codec/lib/FixHexString.ts +0 -8
- /package/src/lib/{codec/lib → helper}/BufferToHex.ts +0 -0
- /package/src/lib/{codec/lib → helper}/BufferToIP.ts +0 -0
- /package/src/lib/{codec/lib → helper}/BufferToNumber.ts +0 -0
- /package/src/lib/{codec/lib → helper}/HexToNumber.ts +0 -0
- /package/src/lib/{codec/lib → helper}/IPToBuffer.ts +0 -0
- /package/src/lib/{codec/lib → helper}/NumberToBERBuffer.ts +0 -0
- /package/src/lib/{codec/lib → helper}/NumberToBERHex.ts +0 -0
- /package/src/lib/{codec/lib → helper}/NumberToBuffer.ts +0 -0
- /package/src/lib/{codec/lib → helper}/NumberToHex.ts +0 -0
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ProtocolJSONSchema } from '../../schema/ProtocolJSONSchema';
|
|
2
|
-
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
3
|
-
export declare class UDP extends BaseHeader {
|
|
4
|
-
/**
|
|
5
|
-
* Calculate UDP Checksum
|
|
6
|
-
* @protected
|
|
7
|
-
* @param udpHeaderBuffer
|
|
8
|
-
*/
|
|
9
|
-
protected calculateUDPChecksum(udpHeaderBuffer: Buffer): number;
|
|
10
|
-
SCHEMA: ProtocolJSONSchema;
|
|
11
|
-
readonly id: string;
|
|
12
|
-
readonly name: string;
|
|
13
|
-
readonly nickname: string;
|
|
14
|
-
match(): boolean;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=UDP.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UDP.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/headers/UDP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAMlD,qBAAa,GAAI,SAAQ,UAAU;IAE/B;;;;OAIG;IACH,SAAS,CAAC,oBAAoB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM;IA8CxD,MAAM,EAAE,kBAAkB,CA2GhC;IAED,SAAgB,EAAE,EAAE,MAAM,CAAQ;IAElC,SAAgB,IAAI,EAAE,MAAM,CAA2B;IAEvD,SAAgB,QAAQ,EAAE,MAAM,CAAQ;IAEjC,KAAK,IAAI,OAAO;CAM1B"}
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UDP = void 0;
|
|
4
|
-
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
-
const BufferToNumber_1 = require("../lib/BufferToNumber");
|
|
6
|
-
const NumberToBuffer_1 = require("../lib/NumberToBuffer");
|
|
7
|
-
const IPToBuffer_1 = require("../lib/IPToBuffer");
|
|
8
|
-
class UDP extends BaseHeader_1.BaseHeader {
|
|
9
|
-
constructor() {
|
|
10
|
-
super(...arguments);
|
|
11
|
-
this.SCHEMA = {
|
|
12
|
-
type: 'object',
|
|
13
|
-
properties: {
|
|
14
|
-
srcport: {
|
|
15
|
-
type: 'integer',
|
|
16
|
-
label: 'Source Port',
|
|
17
|
-
minimum: 0,
|
|
18
|
-
maximum: 65535,
|
|
19
|
-
decode: () => {
|
|
20
|
-
this.instance.srcport.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(0, 2)));
|
|
21
|
-
},
|
|
22
|
-
encode: () => {
|
|
23
|
-
let srcport = this.instance.srcport.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
24
|
-
if (srcport > 65535) {
|
|
25
|
-
this.recordError(this.instance.srcport.getPath(), 'Maximum value is 65535');
|
|
26
|
-
srcport = 65535;
|
|
27
|
-
}
|
|
28
|
-
if (srcport < 0) {
|
|
29
|
-
this.recordError(this.instance.srcport.getPath(), 'Minimum value is 0');
|
|
30
|
-
srcport = 0;
|
|
31
|
-
}
|
|
32
|
-
this.instance.srcport.setValue(srcport);
|
|
33
|
-
this.writeBytes(0, (0, NumberToBuffer_1.UInt16ToBuffer)(srcport));
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
dstport: {
|
|
37
|
-
type: 'integer',
|
|
38
|
-
label: 'Destination Port',
|
|
39
|
-
minimum: 0,
|
|
40
|
-
maximum: 65535,
|
|
41
|
-
decode: () => {
|
|
42
|
-
this.instance.dstport.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
|
|
43
|
-
},
|
|
44
|
-
encode: () => {
|
|
45
|
-
let dstport = this.instance.dstport.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
46
|
-
if (dstport > 65535) {
|
|
47
|
-
this.recordError(this.instance.dstport.getPath(), 'Maximum value is 65535');
|
|
48
|
-
dstport = 65535;
|
|
49
|
-
}
|
|
50
|
-
if (dstport < 0) {
|
|
51
|
-
this.recordError(this.instance.dstport.getPath(), 'Minimum value is 0');
|
|
52
|
-
dstport = 0;
|
|
53
|
-
}
|
|
54
|
-
this.instance.dstport.setValue(dstport);
|
|
55
|
-
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(dstport));
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
length: {
|
|
59
|
-
type: 'integer',
|
|
60
|
-
label: 'Length',
|
|
61
|
-
minimum: 0,
|
|
62
|
-
maximum: 65535,
|
|
63
|
-
decode: () => {
|
|
64
|
-
this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(4, 2)));
|
|
65
|
-
},
|
|
66
|
-
encode: () => {
|
|
67
|
-
let length = this.instance.length.getValue(0);
|
|
68
|
-
if (length) {
|
|
69
|
-
this.instance.length.setValue(length);
|
|
70
|
-
this.writeBytes(4, (0, NumberToBuffer_1.UInt16ToBuffer)(length));
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
this.instance.length.setValue(length);
|
|
74
|
-
this.writeBytes(4, (0, NumberToBuffer_1.UInt16ToBuffer)(length));
|
|
75
|
-
this.addPostPacketEncodeHandler(() => {
|
|
76
|
-
let startCount = false;
|
|
77
|
-
let udpLength = 0;
|
|
78
|
-
this.codecModules.forEach((codecModule) => {
|
|
79
|
-
if (codecModule === this)
|
|
80
|
-
startCount = true;
|
|
81
|
-
if (startCount)
|
|
82
|
-
udpLength += codecModule.length;
|
|
83
|
-
});
|
|
84
|
-
this.instance.length.setValue(udpLength);
|
|
85
|
-
this.writeBytes(4, (0, NumberToBuffer_1.UInt16ToBuffer)(udpLength));
|
|
86
|
-
}, 1);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
checksum: {
|
|
91
|
-
type: 'integer',
|
|
92
|
-
label: 'Checksum',
|
|
93
|
-
minimum: 0,
|
|
94
|
-
maximum: 65535,
|
|
95
|
-
decode: () => {
|
|
96
|
-
this.instance.checksum.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(6, 2)));
|
|
97
|
-
},
|
|
98
|
-
encode: () => {
|
|
99
|
-
const checksum = this.instance.checksum.getValue(0);
|
|
100
|
-
if (checksum) {
|
|
101
|
-
this.instance.checksum.setValue(checksum);
|
|
102
|
-
this.writeBytes(6, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
this.writeBytes(6, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
106
|
-
this.instance.checksum.setValue(checksum);
|
|
107
|
-
this.addPostPacketEncodeHandler(() => {
|
|
108
|
-
let startCount = false;
|
|
109
|
-
let udpHeaderWithDataLength = 0;
|
|
110
|
-
this.codecModules.forEach((codecModule) => {
|
|
111
|
-
if (codecModule === this)
|
|
112
|
-
startCount = true;
|
|
113
|
-
if (startCount)
|
|
114
|
-
udpHeaderWithDataLength += codecModule.length;
|
|
115
|
-
});
|
|
116
|
-
const calcChecksum = this.calculateUDPChecksum(this.packet.subarray(this.startPos, this.startPos + udpHeaderWithDataLength));
|
|
117
|
-
this.instance.checksum.setValue(calcChecksum);
|
|
118
|
-
this.writeBytes(6, (0, NumberToBuffer_1.UInt16ToBuffer)(calcChecksum));
|
|
119
|
-
}, 2);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
this.id = 'udp';
|
|
126
|
-
this.name = 'User Datagram Protocol';
|
|
127
|
-
this.nickname = 'UDP';
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Calculate UDP Checksum
|
|
131
|
-
* @protected
|
|
132
|
-
* @param udpHeaderBuffer
|
|
133
|
-
*/
|
|
134
|
-
calculateUDPChecksum(udpHeaderBuffer) {
|
|
135
|
-
const udpHeaderLength = udpHeaderBuffer.length;
|
|
136
|
-
const ipVersion = this.prevCodecModule.instance.version.getValue();
|
|
137
|
-
let pseudoHeaderBuffer = Buffer.from([]);
|
|
138
|
-
const sourceIp = this.prevCodecModule.instance.sip.getValue();
|
|
139
|
-
const destinationIp = this.prevCodecModule.instance.dip.getValue();
|
|
140
|
-
if (ipVersion === 4) {
|
|
141
|
-
//4 Bytes
|
|
142
|
-
const sourceIPv4Buffer = Buffer.from(sourceIp.split('.').map((value) => parseInt(value)));
|
|
143
|
-
const destinationIPv4Buffer = Buffer.from(destinationIp.split('.').map((value) => parseInt(value)));
|
|
144
|
-
//IPv4 Pseudo header
|
|
145
|
-
pseudoHeaderBuffer = Buffer.concat([
|
|
146
|
-
sourceIPv4Buffer,
|
|
147
|
-
destinationIPv4Buffer,
|
|
148
|
-
(0, NumberToBuffer_1.UInt8ToBuffer)(0), //Reserved field
|
|
149
|
-
(0, NumberToBuffer_1.UInt8ToBuffer)(17), //Protocol type (UDP = 17)
|
|
150
|
-
Buffer.from([(udpHeaderLength >> 8) & 0xFF]),
|
|
151
|
-
Buffer.from([udpHeaderLength & 0xFF])
|
|
152
|
-
]);
|
|
153
|
-
}
|
|
154
|
-
else if (ipVersion === 6) {
|
|
155
|
-
//16 Bytes
|
|
156
|
-
const sourceIPv6Buffer = (0, IPToBuffer_1.IPv6ToBuffer)(sourceIp);
|
|
157
|
-
const destinationIPv6Buffer = (0, IPToBuffer_1.IPv6ToBuffer)(destinationIp);
|
|
158
|
-
//IPv6 Pseudo header
|
|
159
|
-
pseudoHeaderBuffer = Buffer.concat([
|
|
160
|
-
sourceIPv6Buffer,
|
|
161
|
-
destinationIPv6Buffer,
|
|
162
|
-
(0, NumberToBuffer_1.UInt8ToBuffer)(0), //Reserved field
|
|
163
|
-
(0, NumberToBuffer_1.UInt8ToBuffer)(0), //Reserved field
|
|
164
|
-
(0, NumberToBuffer_1.UInt8ToBuffer)(0), //Reserved field
|
|
165
|
-
(0, NumberToBuffer_1.UInt8ToBuffer)(17), //Protocol type (UDP = 17)
|
|
166
|
-
Buffer.from([(udpHeaderLength >> 8) & 0xFF]),
|
|
167
|
-
Buffer.from([udpHeaderLength & 0xFF])
|
|
168
|
-
]);
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
return 0;
|
|
172
|
-
}
|
|
173
|
-
let dataBuffer = Buffer.concat([pseudoHeaderBuffer, udpHeaderBuffer]);
|
|
174
|
-
if (dataBuffer.length % 2)
|
|
175
|
-
dataBuffer = Buffer.concat([dataBuffer, Buffer.from('00', 'hex')]);
|
|
176
|
-
const data = Uint8Array.from(dataBuffer);
|
|
177
|
-
let sum = 0;
|
|
178
|
-
for (let i = 0; i < data.length; i += 2)
|
|
179
|
-
sum += (data[i] << 8) + (data[i + 1] || 0);
|
|
180
|
-
while (sum > 0xFFFF)
|
|
181
|
-
sum = (sum & 0xFFFF) + (sum >>> 16);
|
|
182
|
-
return (~sum) & 0xFFFF;
|
|
183
|
-
}
|
|
184
|
-
match() {
|
|
185
|
-
if (!this.prevCodecModule)
|
|
186
|
-
return false;
|
|
187
|
-
if (this.prevCodecModule.instance.protocol.getValue() === 0x11)
|
|
188
|
-
return true;
|
|
189
|
-
return false;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
exports.UDP = UDP;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ProtocolJSONSchema } from '../../schema/ProtocolJSONSchema';
|
|
2
|
-
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
3
|
-
export declare class VLAN_802dot1Q extends BaseHeader {
|
|
4
|
-
SCHEMA: ProtocolJSONSchema;
|
|
5
|
-
readonly id: string;
|
|
6
|
-
readonly name: string;
|
|
7
|
-
readonly nickname: string;
|
|
8
|
-
match(): boolean;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=VLAN_802dot1Q.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"VLAN_802dot1Q.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/headers/VLAN_802dot1Q.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAIlD,qBAAa,aAAc,SAAQ,UAAU;IAClC,MAAM,EAAE,kBAAkB,CAwDhC;IAED,SAAgB,EAAE,EAAE,MAAM,CAAS;IAEnC,SAAgB,IAAI,EAAE,MAAM,CAAuB;IAEnD,SAAgB,QAAQ,EAAE,MAAM,CAAS;IAElC,KAAK,IAAI,OAAO;CAI1B"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VLAN_802dot1Q = void 0;
|
|
4
|
-
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
-
const NumberToHex_1 = require("../lib/NumberToHex");
|
|
6
|
-
const BufferToHex_1 = require("../lib/BufferToHex");
|
|
7
|
-
class VLAN_802dot1Q extends BaseHeader_1.BaseHeader {
|
|
8
|
-
constructor() {
|
|
9
|
-
super(...arguments);
|
|
10
|
-
this.SCHEMA = {
|
|
11
|
-
type: 'object',
|
|
12
|
-
properties: {
|
|
13
|
-
priority: {
|
|
14
|
-
type: 'integer',
|
|
15
|
-
minimum: 0,
|
|
16
|
-
maximum: 7,
|
|
17
|
-
default: 0,
|
|
18
|
-
decode: () => {
|
|
19
|
-
this.instance.priority.setValue(this.readBits(0, 2, 0, 3));
|
|
20
|
-
},
|
|
21
|
-
encode: () => {
|
|
22
|
-
const priorityValue = this.instance.priority.getValue(0);
|
|
23
|
-
this.instance.priority.setValue(priorityValue);
|
|
24
|
-
this.writeBits(0, 2, 0, 3, priorityValue);
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
dei: {
|
|
28
|
-
type: 'boolean',
|
|
29
|
-
decode: () => {
|
|
30
|
-
this.instance.dei.setValue(!!this.readBits(0, 2, 3, 1));
|
|
31
|
-
},
|
|
32
|
-
encode: () => {
|
|
33
|
-
const dei = !!this.instance.dei.getValue();
|
|
34
|
-
this.instance.dei.setValue(dei);
|
|
35
|
-
this.writeBits(0, 2, 3, 1, dei ? 1 : 0);
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
id: {
|
|
39
|
-
type: 'integer',
|
|
40
|
-
minimum: 0,
|
|
41
|
-
maximum: 4095,
|
|
42
|
-
decode: () => {
|
|
43
|
-
this.instance.id.setValue(this.readBits(0, 2, 4, 12));
|
|
44
|
-
},
|
|
45
|
-
encode: () => {
|
|
46
|
-
const vlanId = this.instance.id.getValue(0);
|
|
47
|
-
this.instance.id.setValue(vlanId);
|
|
48
|
-
this.writeBits(0, 2, 4, 12, vlanId);
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
etherType: {
|
|
52
|
-
type: 'string',
|
|
53
|
-
minLength: 4,
|
|
54
|
-
maxLength: 4,
|
|
55
|
-
decode: () => {
|
|
56
|
-
this.instance.etherType.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(2, 2)));
|
|
57
|
-
},
|
|
58
|
-
encode: () => {
|
|
59
|
-
let etherType = this.instance.etherType.getValue((0, NumberToHex_1.UInt16ToHex)(0x0000), (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
60
|
-
const typeBuffer = Buffer.from(etherType, 'hex');
|
|
61
|
-
if (typeBuffer.length < 2)
|
|
62
|
-
typeBuffer.fill(0, 0, 1);
|
|
63
|
-
this.writeBytes(2, typeBuffer.subarray(0, 2));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
this.id = 'vlan';
|
|
69
|
-
this.name = '802.1Q Virtual LAN';
|
|
70
|
-
this.nickname = 'VLAN';
|
|
71
|
-
}
|
|
72
|
-
match() {
|
|
73
|
-
if (!this.prevCodecModule)
|
|
74
|
-
return false;
|
|
75
|
-
return this.prevCodecModule.instance.etherType.getValue() === (0, NumberToHex_1.UInt16ToHex)(0x8100);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
exports.VLAN_802dot1Q = VLAN_802dot1Q;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BufferToHex.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/lib/BufferToHex.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAElD"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convert Buffer to IPv4 string
|
|
3
|
-
* @param buffer
|
|
4
|
-
* @constructor
|
|
5
|
-
*/
|
|
6
|
-
export declare function BufferToIPv4(buffer: Buffer): string;
|
|
7
|
-
/**
|
|
8
|
-
* Convert Buffer to IPv6 string
|
|
9
|
-
* @param buffer
|
|
10
|
-
* @constructor
|
|
11
|
-
*/
|
|
12
|
-
export declare function BufferToIPv6(buffer: Buffer): string;
|
|
13
|
-
//# sourceMappingURL=BufferToIP.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BufferToIP.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/lib/BufferToIP.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEnD"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BufferToIPv4 = BufferToIPv4;
|
|
4
|
-
exports.BufferToIPv6 = BufferToIPv6;
|
|
5
|
-
const ip_address_1 = require("ip-address");
|
|
6
|
-
/**
|
|
7
|
-
* Convert Buffer to IPv4 string
|
|
8
|
-
* @param buffer
|
|
9
|
-
* @constructor
|
|
10
|
-
*/
|
|
11
|
-
function BufferToIPv4(buffer) {
|
|
12
|
-
return ip_address_1.Address4.fromBigInt(BigInt(`0x${Buffer.alloc(4, buffer).toString('hex').padStart(8, '0')}`)).address;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Convert Buffer to IPv6 string
|
|
16
|
-
* @param buffer
|
|
17
|
-
* @constructor
|
|
18
|
-
*/
|
|
19
|
-
function BufferToIPv6(buffer) {
|
|
20
|
-
return ip_address_1.Address6.fromBigInt(BigInt(`0x${Buffer.alloc(16, buffer).toString('hex').padStart(32, '0')}`)).address;
|
|
21
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const BufferToInt8: (buffer: Buffer) => number;
|
|
2
|
-
export declare const BufferToInt16: (buffer: Buffer) => number;
|
|
3
|
-
export declare const BufferToInt32: (buffer: Buffer) => number;
|
|
4
|
-
export declare const BufferToInt64: (buffer: Buffer) => bigint;
|
|
5
|
-
export declare const BufferToUInt8: (buffer: Buffer) => number;
|
|
6
|
-
export declare const BufferToUInt16: (buffer: Buffer) => number;
|
|
7
|
-
export declare const BufferToUInt32: (buffer: Buffer) => number;
|
|
8
|
-
export declare const BufferToUInt64: (buffer: Buffer) => bigint;
|
|
9
|
-
export declare const BufferToFloat32: (buffer: Buffer) => number;
|
|
10
|
-
//# sourceMappingURL=BufferToNumber.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BufferToNumber.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/lib/BufferToNumber.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAsE,CAAA;AACrH,eAAO,MAAM,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAuE,CAAA;AACvH,eAAO,MAAM,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAuE,CAAA;AACvH,eAAO,MAAM,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAuE,CAAA;AACvH,eAAO,MAAM,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAuE,CAAA;AACvH,eAAO,MAAM,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAwE,CAAA;AACzH,eAAO,MAAM,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAwE,CAAA;AACzH,eAAO,MAAM,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAwE,CAAA;AACzH,eAAO,MAAM,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAyE,CAAA"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BufferToFloat32 = exports.BufferToUInt64 = exports.BufferToUInt32 = exports.BufferToUInt16 = exports.BufferToUInt8 = exports.BufferToInt64 = exports.BufferToInt32 = exports.BufferToInt16 = exports.BufferToInt8 = void 0;
|
|
4
|
-
const HexToNumber_1 = require("./HexToNumber");
|
|
5
|
-
const BufferToInt8 = (buffer) => (0, HexToNumber_1.HexToInt8)(buffer.toString('hex'));
|
|
6
|
-
exports.BufferToInt8 = BufferToInt8;
|
|
7
|
-
const BufferToInt16 = (buffer) => (0, HexToNumber_1.HexToInt16)(buffer.toString('hex'));
|
|
8
|
-
exports.BufferToInt16 = BufferToInt16;
|
|
9
|
-
const BufferToInt32 = (buffer) => (0, HexToNumber_1.HexToInt32)(buffer.toString('hex'));
|
|
10
|
-
exports.BufferToInt32 = BufferToInt32;
|
|
11
|
-
const BufferToInt64 = (buffer) => (0, HexToNumber_1.HexToInt64)(buffer.toString('hex'));
|
|
12
|
-
exports.BufferToInt64 = BufferToInt64;
|
|
13
|
-
const BufferToUInt8 = (buffer) => (0, HexToNumber_1.HexToUInt8)(buffer.toString('hex'));
|
|
14
|
-
exports.BufferToUInt8 = BufferToUInt8;
|
|
15
|
-
const BufferToUInt16 = (buffer) => (0, HexToNumber_1.HexToUInt16)(buffer.toString('hex'));
|
|
16
|
-
exports.BufferToUInt16 = BufferToUInt16;
|
|
17
|
-
const BufferToUInt32 = (buffer) => (0, HexToNumber_1.HexToUInt32)(buffer.toString('hex'));
|
|
18
|
-
exports.BufferToUInt32 = BufferToUInt32;
|
|
19
|
-
const BufferToUInt64 = (buffer) => (0, HexToNumber_1.HexToUInt64)(buffer.toString('hex'));
|
|
20
|
-
exports.BufferToUInt64 = BufferToUInt64;
|
|
21
|
-
const BufferToFloat32 = (buffer) => (0, HexToNumber_1.HexToFloat32)(buffer.toString('hex'));
|
|
22
|
-
exports.BufferToFloat32 = BufferToFloat32;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FixHexString.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/lib/FixHexString.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,UAE1C"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FixHexString = FixHexString;
|
|
4
|
-
/**
|
|
5
|
-
* Fix Hex string length
|
|
6
|
-
* @param rawHex
|
|
7
|
-
* @constructor
|
|
8
|
-
*/
|
|
9
|
-
function FixHexString(rawHex) {
|
|
10
|
-
return rawHex.length % 2 ? `0${rawHex}` : rawHex;
|
|
11
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export declare class FlexibleObject {
|
|
2
|
-
#private;
|
|
3
|
-
constructor(data?: object, parent?: FlexibleObject, paths?: string[]);
|
|
4
|
-
/**
|
|
5
|
-
* Set object node value
|
|
6
|
-
* @param value
|
|
7
|
-
*/
|
|
8
|
-
setValue(value: any): void;
|
|
9
|
-
/**
|
|
10
|
-
* Get object node value
|
|
11
|
-
* @param defaultValue
|
|
12
|
-
* @param onUndefinedCallback
|
|
13
|
-
* @param getPathIndex
|
|
14
|
-
*/
|
|
15
|
-
getValue<T = any>(defaultValue?: T, onUndefinedCallback?: (nodePath: string) => void, getPathIndex?: number): T;
|
|
16
|
-
/**
|
|
17
|
-
* Is current object's value undefined
|
|
18
|
-
*/
|
|
19
|
-
isUndefined(): boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Get current object path
|
|
22
|
-
* The index parameter indicates array item if this object is an array
|
|
23
|
-
* @param index
|
|
24
|
-
*/
|
|
25
|
-
getPath(index?: number): string;
|
|
26
|
-
[p: string]: FlexibleObject;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=FlexibleObject.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FlexibleObject.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/lib/FlexibleObject.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAc;;gBAgBX,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE;IAiBpE;;;OAGG;IAEI,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI;IAYjC;;;;;OAKG;IAEI,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,YAAY,CAAC,EAAE,CAAC,EAAE,mBAAmB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC;IAqBtH;;OAEG;IAEI,WAAW,IAAI,OAAO;IAI7B;;;;OAIG;IAEI,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM;IAMtC,CAAC,CAAC,EAAE,MAAM,GAAG,cAAc,CAAA;CAC9B"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FlexibleObject = void 0;
|
|
4
|
-
class FlexibleObject {
|
|
5
|
-
#parent;
|
|
6
|
-
#paths;
|
|
7
|
-
#data;
|
|
8
|
-
#undefined = true;
|
|
9
|
-
#markFlexibleObjectDefined() {
|
|
10
|
-
if (!this.#undefined)
|
|
11
|
-
return;
|
|
12
|
-
this.#undefined = false;
|
|
13
|
-
if (this.#parent)
|
|
14
|
-
this.#parent.#markFlexibleObjectDefined();
|
|
15
|
-
}
|
|
16
|
-
constructor(data, parent, paths) {
|
|
17
|
-
this.#parent = parent;
|
|
18
|
-
this.#data = {};
|
|
19
|
-
this.#paths = paths ? paths : [];
|
|
20
|
-
if (data !== undefined)
|
|
21
|
-
this.setValue(data);
|
|
22
|
-
return new Proxy(this, {
|
|
23
|
-
get: (target, p) => {
|
|
24
|
-
if (this[p])
|
|
25
|
-
return (...args) => this[p](...args);
|
|
26
|
-
if (target.#data[p] === undefined)
|
|
27
|
-
target.#data[p] = new FlexibleObject(target.#data[p], this, [...this.#paths, p]);
|
|
28
|
-
return target.#data[p];
|
|
29
|
-
},
|
|
30
|
-
set: (target, p, newValue) => {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Set object node value
|
|
37
|
-
* @param value
|
|
38
|
-
*/
|
|
39
|
-
// @ts-ignore
|
|
40
|
-
setValue(value) {
|
|
41
|
-
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
42
|
-
Object.keys(value).forEach(key => {
|
|
43
|
-
this.#data[key] = new FlexibleObject(this.#data[key], this, [...this.#paths, key]);
|
|
44
|
-
this.#data[key].setValue(value[key]);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
this.#data = value;
|
|
49
|
-
}
|
|
50
|
-
this.#markFlexibleObjectDefined();
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Get object node value
|
|
54
|
-
* @param defaultValue
|
|
55
|
-
* @param onUndefinedCallback
|
|
56
|
-
* @param getPathIndex
|
|
57
|
-
*/
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
getValue(defaultValue, onUndefinedCallback, getPathIndex) {
|
|
60
|
-
if (this.#undefined) {
|
|
61
|
-
if (onUndefinedCallback)
|
|
62
|
-
onUndefinedCallback(this.getPath(getPathIndex));
|
|
63
|
-
if (defaultValue !== undefined) {
|
|
64
|
-
return defaultValue;
|
|
65
|
-
}
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
if (typeof this.#data === 'object' && !Array.isArray(this.#data)) {
|
|
69
|
-
const dumpObject = {};
|
|
70
|
-
Object.keys(this.#data).forEach((key) => {
|
|
71
|
-
const dumpResult = this.#data[key].getValue();
|
|
72
|
-
if (dumpResult === undefined)
|
|
73
|
-
return;
|
|
74
|
-
dumpObject[key] = dumpResult;
|
|
75
|
-
});
|
|
76
|
-
return dumpObject;
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
return this.#undefined ? undefined : this.#data;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Is current object's value undefined
|
|
84
|
-
*/
|
|
85
|
-
// @ts-ignore
|
|
86
|
-
isUndefined() {
|
|
87
|
-
return this.#undefined;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Get current object path
|
|
91
|
-
* The index parameter indicates array item if this object is an array
|
|
92
|
-
* @param index
|
|
93
|
-
*/
|
|
94
|
-
// @ts-ignore
|
|
95
|
-
getPath(index) {
|
|
96
|
-
const objPath = this.#paths.join('.');
|
|
97
|
-
if (index === undefined)
|
|
98
|
-
return objPath;
|
|
99
|
-
return `${objPath}[${index}]`;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
exports.FlexibleObject = FlexibleObject;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const HexToInt8: (hex: string) => number;
|
|
2
|
-
export declare const HexToInt16: (hex: string) => number;
|
|
3
|
-
export declare const HexToInt32: (hex: string) => number;
|
|
4
|
-
export declare const HexToInt64: (hex: string) => bigint;
|
|
5
|
-
export declare const HexToUInt8: (hex: string) => number;
|
|
6
|
-
export declare const HexToUInt16: (hex: string) => number;
|
|
7
|
-
export declare const HexToUInt32: (hex: string) => number;
|
|
8
|
-
export declare const HexToUInt64: (hex: string) => bigint;
|
|
9
|
-
export declare const HexToFloat32: (hex: string) => number;
|
|
10
|
-
//# sourceMappingURL=HexToNumber.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HexToNumber.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/lib/HexToNumber.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAwE,CAAA;AACjH,eAAO,MAAM,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAyE,CAAA;AACnH,eAAO,MAAM,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAyE,CAAA;AACnH,eAAO,MAAM,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAMzC,CAAA;AACD,eAAO,MAAM,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAyE,CAAA;AACnH,eAAO,MAAM,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAA0E,CAAA;AACrH,eAAO,MAAM,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAA0E,CAAA;AACrH,eAAO,MAAM,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAK1C,CAAA;AACD,eAAO,MAAM,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAK3C,CAAA"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HexToFloat32 = exports.HexToUInt64 = exports.HexToUInt32 = exports.HexToUInt16 = exports.HexToUInt8 = exports.HexToInt64 = exports.HexToInt32 = exports.HexToInt16 = exports.HexToInt8 = void 0;
|
|
4
|
-
const HexToInt8 = (hex) => Int8Array.from([parseInt(hex, 16)])[0];
|
|
5
|
-
exports.HexToInt8 = HexToInt8;
|
|
6
|
-
const HexToInt16 = (hex) => Int16Array.from([parseInt(hex, 16)])[0];
|
|
7
|
-
exports.HexToInt16 = HexToInt16;
|
|
8
|
-
const HexToInt32 = (hex) => Int32Array.from([parseInt(hex, 16)])[0];
|
|
9
|
-
exports.HexToInt32 = HexToInt32;
|
|
10
|
-
const HexToInt64 = (hex) => {
|
|
11
|
-
const INT64_MAX = BigInt('9223372036854775807');
|
|
12
|
-
const INT64_MIN = BigInt('-9223372036854775808');
|
|
13
|
-
const bigIntValue = BigInt(`0x${hex}`);
|
|
14
|
-
if (bigIntValue < INT64_MIN || bigIntValue > INT64_MAX)
|
|
15
|
-
return INT64_MAX;
|
|
16
|
-
return bigIntValue;
|
|
17
|
-
};
|
|
18
|
-
exports.HexToInt64 = HexToInt64;
|
|
19
|
-
const HexToUInt8 = (hex) => Uint8Array.from([parseInt(hex, 16)])[0];
|
|
20
|
-
exports.HexToUInt8 = HexToUInt8;
|
|
21
|
-
const HexToUInt16 = (hex) => Uint16Array.from([parseInt(hex, 16)])[0];
|
|
22
|
-
exports.HexToUInt16 = HexToUInt16;
|
|
23
|
-
const HexToUInt32 = (hex) => Uint32Array.from([parseInt(hex, 16)])[0];
|
|
24
|
-
exports.HexToUInt32 = HexToUInt32;
|
|
25
|
-
const HexToUInt64 = (hex) => {
|
|
26
|
-
const INT64_MAX = BigInt('18446744073709551615');
|
|
27
|
-
const bigIntValue = BigInt(`0x${hex}`);
|
|
28
|
-
if (bigIntValue < 0n || bigIntValue > INT64_MAX)
|
|
29
|
-
return INT64_MAX;
|
|
30
|
-
return bigIntValue;
|
|
31
|
-
};
|
|
32
|
-
exports.HexToUInt64 = HexToUInt64;
|
|
33
|
-
const HexToFloat32 = (hex) => {
|
|
34
|
-
const buffer = new ArrayBuffer(4);
|
|
35
|
-
const dataView = new DataView(buffer);
|
|
36
|
-
dataView.setUint32(0, parseInt(hex, 16), false);
|
|
37
|
-
return dataView.getFloat32(0, false);
|
|
38
|
-
};
|
|
39
|
-
exports.HexToFloat32 = HexToFloat32;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convert IPv4 string to Buffer
|
|
3
|
-
* @param ipv4
|
|
4
|
-
* @constructor
|
|
5
|
-
*/
|
|
6
|
-
export declare function IPv4ToBuffer(ipv4: string): Buffer;
|
|
7
|
-
/**
|
|
8
|
-
* Convert IPv6 string to Buffer
|
|
9
|
-
* @param ipv6
|
|
10
|
-
* @constructor
|
|
11
|
-
*/
|
|
12
|
-
export declare function IPv6ToBuffer(ipv6: string): Buffer;
|
|
13
|
-
//# sourceMappingURL=IPToBuffer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IPToBuffer.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/lib/IPToBuffer.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGjD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMjD"}
|