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,339 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IPv4 = void 0;
|
|
4
|
-
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
-
const NumberToHex_1 = require("../lib/NumberToHex");
|
|
6
|
-
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
7
|
-
const FixHexString_1 = require("../lib/FixHexString");
|
|
8
|
-
const BufferToNumber_1 = require("../lib/BufferToNumber");
|
|
9
|
-
const NumberToBuffer_1 = require("../lib/NumberToBuffer");
|
|
10
|
-
const BufferToHex_1 = require("../lib/BufferToHex");
|
|
11
|
-
const IPToBuffer_1 = require("../lib/IPToBuffer");
|
|
12
|
-
const BufferToIP_1 = require("../lib/BufferToIP");
|
|
13
|
-
class IPv4 extends BaseHeader_1.BaseHeader {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(...arguments);
|
|
16
|
-
this.SCHEMA = {
|
|
17
|
-
type: 'object',
|
|
18
|
-
properties: {
|
|
19
|
-
version: {
|
|
20
|
-
type: 'integer',
|
|
21
|
-
label: 'Version',
|
|
22
|
-
minimum: 0,
|
|
23
|
-
maximum: 15,
|
|
24
|
-
decode: () => {
|
|
25
|
-
this.instance.version.setValue(this.readBits(0, 1, 0, 4));
|
|
26
|
-
if (this.instance.version.getValue() !== 4)
|
|
27
|
-
this.recordError(this.instance.version.getPath(), 'IPv4 version should be 4');
|
|
28
|
-
},
|
|
29
|
-
encode: () => {
|
|
30
|
-
let version = this.instance.version.getValue(4);
|
|
31
|
-
version = version > 15 ? 15 : version;
|
|
32
|
-
version = version < 0 ? 0 : version;
|
|
33
|
-
if (version !== 4)
|
|
34
|
-
this.recordError(this.instance.version.getPath(), 'IPv4 version should be 4');
|
|
35
|
-
this.instance.version.setValue(version);
|
|
36
|
-
this.writeBits(0, 1, 0, 4, version);
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
hdrLen: {
|
|
40
|
-
type: 'integer',
|
|
41
|
-
label: 'Header Length',
|
|
42
|
-
minimum: 20,
|
|
43
|
-
maximum: 60,
|
|
44
|
-
decode: () => {
|
|
45
|
-
this.instance.hdrLen.setValue(this.readBits(0, 1, 4, 4) * 4);
|
|
46
|
-
},
|
|
47
|
-
encode: () => {
|
|
48
|
-
let headerLength = this.instance.hdrLen.getValue(0);
|
|
49
|
-
if (headerLength)
|
|
50
|
-
headerLength = headerLength ? Math.floor(headerLength / 4) : 0;
|
|
51
|
-
this.writeBits(0, 1, 4, 4, headerLength);
|
|
52
|
-
if (!headerLength)
|
|
53
|
-
this.addPostSelfEncodeHandler(() => {
|
|
54
|
-
this.instance.hdrLen.setValue(this.length);
|
|
55
|
-
this.writeBits(0, 1, 4, 4, Math.floor(this.length / 4));
|
|
56
|
-
}, 10);
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
dsfield: {
|
|
60
|
-
type: 'object',
|
|
61
|
-
label: 'Differentiated Services Field',
|
|
62
|
-
properties: {
|
|
63
|
-
dscp: {
|
|
64
|
-
type: 'integer',
|
|
65
|
-
minimum: 0,
|
|
66
|
-
maximum: 63,
|
|
67
|
-
label: 'Differentiated Services Codepoint',
|
|
68
|
-
decode: () => {
|
|
69
|
-
this.instance.dsfield.dscp.setValue(this.readBits(1, 1, 0, 6));
|
|
70
|
-
},
|
|
71
|
-
encode: () => {
|
|
72
|
-
const dscp = this.instance.dsfield.dscp.getValue(0);
|
|
73
|
-
this.instance.dsfield.dscp.setValue(dscp);
|
|
74
|
-
this.writeBits(1, 1, 0, 6, dscp);
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
ecn: {
|
|
78
|
-
type: 'integer',
|
|
79
|
-
label: 'Explicit Congestion Notification',
|
|
80
|
-
decode: () => {
|
|
81
|
-
this.instance.dsfield.ecn.setValue(this.readBits(1, 1, 6, 2));
|
|
82
|
-
},
|
|
83
|
-
encode: () => {
|
|
84
|
-
const ecn = this.instance.dsfield.ecn.getValue(0);
|
|
85
|
-
this.instance.dsfield.ecn.setValue(ecn);
|
|
86
|
-
this.writeBits(1, 1, 6, 2, ecn);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
length: {
|
|
92
|
-
type: 'integer',
|
|
93
|
-
label: 'Total Length',
|
|
94
|
-
minimum: 0,
|
|
95
|
-
maximum: 65535,
|
|
96
|
-
decode: () => {
|
|
97
|
-
this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
|
|
98
|
-
},
|
|
99
|
-
encode: () => {
|
|
100
|
-
//This field's real value needs down stream codec invoke recode to fill
|
|
101
|
-
let length = this.instance.length.getValue(0);
|
|
102
|
-
if (length) {
|
|
103
|
-
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(length));
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(length));
|
|
107
|
-
this.addPostPacketEncodeHandler(() => {
|
|
108
|
-
let startCount = false;
|
|
109
|
-
let totalLength = 0;
|
|
110
|
-
this.codecModules.forEach((codecModule) => {
|
|
111
|
-
if (codecModule === this)
|
|
112
|
-
startCount = true;
|
|
113
|
-
if (startCount)
|
|
114
|
-
totalLength += codecModule.length;
|
|
115
|
-
});
|
|
116
|
-
this.instance.length.setValue(totalLength);
|
|
117
|
-
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(totalLength));
|
|
118
|
-
}, 1);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
id: {
|
|
123
|
-
type: 'integer',
|
|
124
|
-
label: 'Identification',
|
|
125
|
-
minimum: 0,
|
|
126
|
-
maximum: 65535,
|
|
127
|
-
decode: () => {
|
|
128
|
-
this.instance.id.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(4, 2)));
|
|
129
|
-
},
|
|
130
|
-
encode: () => {
|
|
131
|
-
const id = this.instance.id.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
132
|
-
this.instance.id.setValue(id);
|
|
133
|
-
this.writeBytes(4, (0, NumberToBuffer_1.UInt16ToBuffer)(id));
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
flags: {
|
|
137
|
-
type: 'object',
|
|
138
|
-
label: 'Flags',
|
|
139
|
-
properties: {
|
|
140
|
-
rb: {
|
|
141
|
-
type: 'integer',
|
|
142
|
-
enum: [0, 1],
|
|
143
|
-
label: 'Reserved bit',
|
|
144
|
-
decode: () => {
|
|
145
|
-
this.instance.flags.rb.setValue(this.readBits(6, 1, 0, 1));
|
|
146
|
-
},
|
|
147
|
-
encode: () => {
|
|
148
|
-
const rb = this.instance.flags.rb.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
149
|
-
this.instance.flags.rb.setValue(rb);
|
|
150
|
-
this.writeBits(6, 1, 0, 1, rb);
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
df: {
|
|
154
|
-
type: 'integer',
|
|
155
|
-
enum: [0, 1],
|
|
156
|
-
label: 'Don\'t fragment',
|
|
157
|
-
decode: () => {
|
|
158
|
-
this.instance.flags.df.setValue(this.readBits(6, 1, 1, 1));
|
|
159
|
-
},
|
|
160
|
-
encode: () => {
|
|
161
|
-
const df = this.instance.flags.df.getValue(1, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
162
|
-
this.instance.flags.df.setValue(df);
|
|
163
|
-
this.writeBits(6, 1, 1, 1, df);
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
mf: {
|
|
167
|
-
type: 'integer',
|
|
168
|
-
enum: [0, 1],
|
|
169
|
-
label: 'More fragments',
|
|
170
|
-
decode: () => {
|
|
171
|
-
this.instance.flags.mf.setValue(this.readBits(6, 1, 2, 1));
|
|
172
|
-
},
|
|
173
|
-
encode: () => {
|
|
174
|
-
const mf = this.instance.flags.mf.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
175
|
-
this.instance.flags.mf.setValue(mf);
|
|
176
|
-
this.writeBits(6, 1, 2, 1, mf);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
fragOffset: {
|
|
182
|
-
type: 'integer',
|
|
183
|
-
minimum: 0,
|
|
184
|
-
maximum: 8191,
|
|
185
|
-
label: 'Fragment Offset',
|
|
186
|
-
decode: () => {
|
|
187
|
-
this.instance.fragOffset.setValue(this.readBits(6, 2, 3, 13));
|
|
188
|
-
},
|
|
189
|
-
encode: () => {
|
|
190
|
-
const fragOffset = this.instance.fragOffset.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
191
|
-
this.instance.fragOffset.setValue(fragOffset);
|
|
192
|
-
this.writeBits(6, 2, 3, 13, fragOffset);
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
ttl: {
|
|
196
|
-
type: 'integer',
|
|
197
|
-
minimum: 0,
|
|
198
|
-
maximum: 255,
|
|
199
|
-
label: 'Time to Live',
|
|
200
|
-
decode: () => {
|
|
201
|
-
this.instance.ttl.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(8, 1)));
|
|
202
|
-
},
|
|
203
|
-
encode: () => {
|
|
204
|
-
const ttl = this.instance.ttl.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
205
|
-
this.instance.ttl.setValue(ttl);
|
|
206
|
-
this.writeBytes(8, (0, NumberToBuffer_1.UInt8ToBuffer)(ttl));
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
|
-
protocol: {
|
|
210
|
-
type: 'integer',
|
|
211
|
-
label: 'Protocol',
|
|
212
|
-
minimum: 0,
|
|
213
|
-
maximum: 255,
|
|
214
|
-
decode: () => {
|
|
215
|
-
this.instance.protocol.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(9, 1)));
|
|
216
|
-
},
|
|
217
|
-
encode: () => {
|
|
218
|
-
const protocol = this.instance.protocol.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
219
|
-
this.instance.protocol.setValue(protocol);
|
|
220
|
-
this.writeBytes(9, (0, NumberToBuffer_1.UInt8ToBuffer)(protocol));
|
|
221
|
-
}
|
|
222
|
-
},
|
|
223
|
-
checksum: {
|
|
224
|
-
type: 'integer',
|
|
225
|
-
label: 'Header Checksum',
|
|
226
|
-
minimum: 0,
|
|
227
|
-
maximum: 65535,
|
|
228
|
-
decode: () => {
|
|
229
|
-
this.instance.checksum.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(10, 2)));
|
|
230
|
-
},
|
|
231
|
-
encode: () => {
|
|
232
|
-
let checksum = this.instance.checksum.getValue(0);
|
|
233
|
-
checksum = checksum > 65535 ? 65535 : checksum;
|
|
234
|
-
checksum = checksum < 0 ? 0 : checksum;
|
|
235
|
-
if (checksum) {
|
|
236
|
-
this.instance.checksum.setValue(checksum);
|
|
237
|
-
this.writeBytes(10, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
this.instance.checksum.setValue(checksum);
|
|
241
|
-
this.writeBytes(10, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
242
|
-
this.addPostPacketEncodeHandler(() => {
|
|
243
|
-
const calcChecksum = this.calculateIPv4Checksum(this.packet.subarray(this.startPos, this.endPos));
|
|
244
|
-
this.instance.checksum.setValue(calcChecksum);
|
|
245
|
-
this.writeBytes(10, (0, NumberToBuffer_1.UInt16ToBuffer)(calcChecksum));
|
|
246
|
-
}, 2);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
sip: {
|
|
251
|
-
type: 'string',
|
|
252
|
-
label: 'Source Address',
|
|
253
|
-
minLength: 7,
|
|
254
|
-
maxLength: 15,
|
|
255
|
-
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.IPv4,
|
|
256
|
-
decode: () => {
|
|
257
|
-
const sipBuffer = this.readBytes(12, 4);
|
|
258
|
-
this.instance.sip.setValue((0, BufferToIP_1.BufferToIPv4)(sipBuffer));
|
|
259
|
-
},
|
|
260
|
-
encode: () => {
|
|
261
|
-
const sipStr = this.instance.sip.getValue('0.0.0.0', (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
262
|
-
this.instance.sip.setValue(sipStr);
|
|
263
|
-
this.writeBytes(12, (0, IPToBuffer_1.IPv4ToBuffer)(sipStr));
|
|
264
|
-
}
|
|
265
|
-
},
|
|
266
|
-
dip: {
|
|
267
|
-
type: 'string',
|
|
268
|
-
minLength: 7,
|
|
269
|
-
maxLength: 15,
|
|
270
|
-
label: 'Destination Address',
|
|
271
|
-
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.IPv4,
|
|
272
|
-
decode: () => {
|
|
273
|
-
const dipBuffer = this.readBytes(16, 4);
|
|
274
|
-
this.instance.dip.setValue((0, BufferToIP_1.BufferToIPv4)(dipBuffer));
|
|
275
|
-
},
|
|
276
|
-
encode: () => {
|
|
277
|
-
const dipStr = this.instance.dip.getValue('0.0.0.0', (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
278
|
-
this.instance.dip.setValue(dipStr);
|
|
279
|
-
this.writeBytes(16, (0, IPToBuffer_1.IPv4ToBuffer)(dipStr));
|
|
280
|
-
}
|
|
281
|
-
},
|
|
282
|
-
options: {
|
|
283
|
-
type: 'string',
|
|
284
|
-
label: 'Options',
|
|
285
|
-
minLength: 0,
|
|
286
|
-
maxLength: 40 * 2,
|
|
287
|
-
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
288
|
-
decode: () => {
|
|
289
|
-
if (this.length < (this.instance.hdrLen.getValue())) {
|
|
290
|
-
this.instance.options.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(this.length, (this.instance.hdrLen.getValue()) - this.length)));
|
|
291
|
-
}
|
|
292
|
-
},
|
|
293
|
-
encode: () => {
|
|
294
|
-
if (!this.instance.options.isUndefined()) {
|
|
295
|
-
let optionsBuffer = Buffer.from((0, FixHexString_1.FixHexString)(this.instance.options.getValue()), 'hex');
|
|
296
|
-
if (optionsBuffer.length > 40)
|
|
297
|
-
optionsBuffer = optionsBuffer.subarray(0, 40);
|
|
298
|
-
const estimateHdrLen = this.length + optionsBuffer.length;
|
|
299
|
-
if (estimateHdrLen % 4) {
|
|
300
|
-
/**
|
|
301
|
-
* IPv4 Header should have a length that a multiple of 32 bits
|
|
302
|
-
* @see https://learningnetwork.cisco.com/s/question/0D53i00000Kt6hHCAR/padding-field-on-ipv4-header
|
|
303
|
-
*/
|
|
304
|
-
optionsBuffer = Buffer.concat([optionsBuffer, Buffer.from([0x00])]);
|
|
305
|
-
}
|
|
306
|
-
this.writeBytes(this.length, optionsBuffer);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
this.id = 'ipv4';
|
|
313
|
-
this.name = 'Internet Protocol Version 4';
|
|
314
|
-
this.nickname = 'IPv4';
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Calculate IPv4 header checksum
|
|
318
|
-
* @param headerBuffer
|
|
319
|
-
* @protected
|
|
320
|
-
*/
|
|
321
|
-
calculateIPv4Checksum(headerBuffer) {
|
|
322
|
-
const header = Uint8Array.from(headerBuffer);
|
|
323
|
-
let sum = 0;
|
|
324
|
-
for (let i = 0; i < header.length; i += 2) {
|
|
325
|
-
let word = (header[i] << 8) + (header[i + 1] || 0);
|
|
326
|
-
sum += word;
|
|
327
|
-
}
|
|
328
|
-
while (sum >>> 16) {
|
|
329
|
-
sum = (sum & 0xFFFF) + (sum >>> 16);
|
|
330
|
-
}
|
|
331
|
-
return (~sum) & 0xFFFF;
|
|
332
|
-
}
|
|
333
|
-
match() {
|
|
334
|
-
if (!this.prevCodecModule)
|
|
335
|
-
return false;
|
|
336
|
-
return this.prevCodecModule.instance.etherType.getValue() === (0, NumberToHex_1.UInt16ToHex)(0x0800);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
exports.IPv4 = IPv4;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ProtocolJSONSchema } from '../../schema/ProtocolJSONSchema';
|
|
2
|
-
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
3
|
-
export declare class RawData extends BaseHeader {
|
|
4
|
-
readonly SCHEMA: ProtocolJSONSchema;
|
|
5
|
-
readonly id: string;
|
|
6
|
-
readonly name: string;
|
|
7
|
-
readonly nickname: string;
|
|
8
|
-
readonly isProtocol: boolean;
|
|
9
|
-
match(): boolean;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=RawData.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RawData.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/headers/RawData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAIlD,qBAAa,OAAQ,SAAQ,UAAU;IAEnC,SAAgB,MAAM,EAAE,kBAAkB,CAgBzC;IAED,SAAgB,EAAE,EAAE,MAAM,CAAQ;IAElC,SAAgB,IAAI,EAAE,MAAM,CAAa;IAEzC,SAAgB,QAAQ,EAAE,MAAM,CAAQ;IAExC,SAAgB,UAAU,EAAE,OAAO,CAAQ;IAEpC,KAAK,IAAI,OAAO;CAI1B"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RawData = void 0;
|
|
4
|
-
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
-
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
6
|
-
const BufferToHex_1 = require("../lib/BufferToHex");
|
|
7
|
-
class RawData extends BaseHeader_1.BaseHeader {
|
|
8
|
-
constructor() {
|
|
9
|
-
super(...arguments);
|
|
10
|
-
this.SCHEMA = {
|
|
11
|
-
type: 'object',
|
|
12
|
-
properties: {
|
|
13
|
-
data: {
|
|
14
|
-
type: 'string',
|
|
15
|
-
label: 'Raw',
|
|
16
|
-
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
17
|
-
decode: () => {
|
|
18
|
-
const dataLength = this.packet.length - this.startPos;
|
|
19
|
-
this.instance.data.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(0, dataLength)));
|
|
20
|
-
},
|
|
21
|
-
encode: () => {
|
|
22
|
-
this.writeBytes(0, Buffer.from(this.instance.data.getValue().toString(), 'hex'));
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
this.id = 'raw';
|
|
28
|
-
this.name = 'Raw Data';
|
|
29
|
-
this.nickname = 'Raw';
|
|
30
|
-
this.isProtocol = false;
|
|
31
|
-
}
|
|
32
|
-
match() {
|
|
33
|
-
return !!this.prevCodecModule;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.RawData = RawData;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ProtocolJSONSchema } from '../../schema/ProtocolJSONSchema';
|
|
2
|
-
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
3
|
-
export declare class TCP extends BaseHeader {
|
|
4
|
-
/**
|
|
5
|
-
* Calculate TCP Checksum
|
|
6
|
-
* @param tcpHeaderBuffer
|
|
7
|
-
* @protected
|
|
8
|
-
*/
|
|
9
|
-
protected calculateTCPChecksum(tcpHeaderBuffer: Buffer): number;
|
|
10
|
-
SCHEMA: ProtocolJSONSchema;
|
|
11
|
-
readonly id: string;
|
|
12
|
-
readonly name: string;
|
|
13
|
-
readonly nickname: string;
|
|
14
|
-
match(): boolean;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=TCP.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TCP.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/headers/TCP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAkFlD,qBAAa,GAAI,SAAQ,UAAU;IAE/B;;;;OAIG;IACH,SAAS,CAAC,oBAAoB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM;IA6CxD,MAAM,EAAE,kBAAkB,CA+wBhC;IAED,SAAgB,EAAE,EAAE,MAAM,CAAQ;IAElC,SAAgB,IAAI,EAAE,MAAM,CAAkC;IAE9D,SAAgB,QAAQ,EAAE,MAAM,CAAQ;IAEjC,KAAK,IAAI,OAAO;CAM1B"}
|