netkitty 0.0.1
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/.eslintrc.json +53 -0
- package/.idea/codeStyles/Project.xml +18 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +10 -0
- package/.idea/modules.xml +8 -0
- package/.idea/netkitty.iml +13 -0
- package/.idea/vcs.xml +6 -0
- package/LICENSE +21 -0
- package/README.md +2 -0
- package/binding.gyp +5 -0
- package/build/NetKitty.d.ts +31 -0
- package/build/NetKitty.d.ts.map +1 -0
- package/build/NetKitty.js +33 -0
- package/build/errors/ActionNotFoundError.d.ts +5 -0
- package/build/errors/ActionNotFoundError.d.ts.map +1 -0
- package/build/errors/ActionNotFoundError.js +12 -0
- package/build/errors/CodecSchemaValidateError.d.ts +5 -0
- package/build/errors/CodecSchemaValidateError.d.ts.map +1 -0
- package/build/errors/CodecSchemaValidateError.js +12 -0
- package/build/errors/DeviceNotFoundError.d.ts +5 -0
- package/build/errors/DeviceNotFoundError.d.ts.map +1 -0
- package/build/errors/DeviceNotFoundError.js +12 -0
- package/build/errors/NoAvailableCodecError.d.ts +5 -0
- package/build/errors/NoAvailableCodecError.d.ts.map +1 -0
- package/build/errors/NoAvailableCodecError.js +12 -0
- package/build/errors/NpcapLoadError.d.ts +5 -0
- package/build/errors/NpcapLoadError.d.ts.map +1 -0
- package/build/errors/NpcapLoadError.js +12 -0
- package/build/errors/SocketDownError.d.ts +5 -0
- package/build/errors/SocketDownError.d.ts.map +1 -0
- package/build/errors/SocketDownError.js +12 -0
- package/build/errors/UnknownPipeMessageTypeError.d.ts +5 -0
- package/build/errors/UnknownPipeMessageTypeError.d.ts.map +1 -0
- package/build/errors/UnknownPipeMessageTypeError.js +12 -0
- package/build/errors/common/ErrorCode.d.ts +31 -0
- package/build/errors/common/ErrorCode.d.ts.map +1 -0
- package/build/errors/common/ErrorCode.js +33 -0
- package/build/lib/GeneratePipeAddress.d.ts +7 -0
- package/build/lib/GeneratePipeAddress.d.ts.map +1 -0
- package/build/lib/GeneratePipeAddress.js +23 -0
- package/build/lib/GetBinding.d.ts +2 -0
- package/build/lib/GetBinding.d.ts.map +1 -0
- package/build/lib/GetBinding.js +6 -0
- package/build/lib/GetCaptureTemporaryDirectory.d.ts +7 -0
- package/build/lib/GetCaptureTemporaryDirectory.d.ts.map +1 -0
- package/build/lib/GetCaptureTemporaryDirectory.js +15 -0
- package/build/lib/GetDeviceCaptureTemporaryFilename.d.ts +8 -0
- package/build/lib/GetDeviceCaptureTemporaryFilename.d.ts.map +1 -0
- package/build/lib/GetDeviceCaptureTemporaryFilename.js +18 -0
- package/build/lib/codec/Codec.d.ts +33 -0
- package/build/lib/codec/Codec.d.ts.map +1 -0
- package/build/lib/codec/Codec.js +166 -0
- package/build/lib/codec/abstracts/BaseHeader.d.ts +204 -0
- package/build/lib/codec/abstracts/BaseHeader.d.ts.map +1 -0
- package/build/lib/codec/abstracts/BaseHeader.js +339 -0
- package/build/lib/codec/headers/ARP.d.ts +9 -0
- package/build/lib/codec/headers/ARP.d.ts.map +1 -0
- package/build/lib/codec/headers/ARP.js +223 -0
- package/build/lib/codec/headers/EthernetII.d.ts +9 -0
- package/build/lib/codec/headers/EthernetII.d.ts.map +1 -0
- package/build/lib/codec/headers/EthernetII.js +80 -0
- package/build/lib/codec/headers/Goose.d.ts +12 -0
- package/build/lib/codec/headers/Goose.d.ts.map +1 -0
- package/build/lib/codec/headers/Goose.js +701 -0
- package/build/lib/codec/headers/IEC61850SampledValues.d.ts +12 -0
- package/build/lib/codec/headers/IEC61850SampledValues.d.ts.map +1 -0
- package/build/lib/codec/headers/IEC61850SampledValues.js +369 -0
- package/build/lib/codec/headers/IPv4.d.ts +15 -0
- package/build/lib/codec/headers/IPv4.d.ts.map +1 -0
- package/build/lib/codec/headers/IPv4.js +338 -0
- package/build/lib/codec/headers/RawData.d.ts +9 -0
- package/build/lib/codec/headers/RawData.d.ts.map +1 -0
- package/build/lib/codec/headers/RawData.js +34 -0
- package/build/lib/codec/headers/TCP.d.ts +15 -0
- package/build/lib/codec/headers/TCP.d.ts.map +1 -0
- package/build/lib/codec/headers/TCP.js +897 -0
- package/build/lib/codec/headers/UDP.d.ts +15 -0
- package/build/lib/codec/headers/UDP.d.ts.map +1 -0
- package/build/lib/codec/headers/UDP.js +191 -0
- package/build/lib/codec/headers/VLAN_802dot1Q.d.ts +9 -0
- package/build/lib/codec/headers/VLAN_802dot1Q.d.ts.map +1 -0
- package/build/lib/codec/headers/VLAN_802dot1Q.js +77 -0
- package/build/lib/codec/lib/BufferToHex.d.ts +2 -0
- package/build/lib/codec/lib/BufferToHex.d.ts.map +1 -0
- package/build/lib/codec/lib/BufferToHex.js +6 -0
- package/build/lib/codec/lib/BufferToIP.d.ts +13 -0
- package/build/lib/codec/lib/BufferToIP.d.ts.map +1 -0
- package/build/lib/codec/lib/BufferToIP.js +21 -0
- package/build/lib/codec/lib/BufferToNumber.d.ts +10 -0
- package/build/lib/codec/lib/BufferToNumber.d.ts.map +1 -0
- package/build/lib/codec/lib/BufferToNumber.js +22 -0
- package/build/lib/codec/lib/FixHexString.d.ts +7 -0
- package/build/lib/codec/lib/FixHexString.d.ts.map +1 -0
- package/build/lib/codec/lib/FixHexString.js +11 -0
- package/build/lib/codec/lib/FlexibleObject.d.ts +28 -0
- package/build/lib/codec/lib/FlexibleObject.d.ts.map +1 -0
- package/build/lib/codec/lib/FlexibleObject.js +102 -0
- package/build/lib/codec/lib/HexToNumber.d.ts +10 -0
- package/build/lib/codec/lib/HexToNumber.d.ts.map +1 -0
- package/build/lib/codec/lib/HexToNumber.js +39 -0
- package/build/lib/codec/lib/IPToBuffer.d.ts +13 -0
- package/build/lib/codec/lib/IPToBuffer.d.ts.map +1 -0
- package/build/lib/codec/lib/IPToBuffer.js +28 -0
- package/build/lib/codec/lib/NumberToBERBuffer.d.ts +9 -0
- package/build/lib/codec/lib/NumberToBERBuffer.d.ts.map +1 -0
- package/build/lib/codec/lib/NumberToBERBuffer.js +20 -0
- package/build/lib/codec/lib/NumberToBERHex.d.ts +9 -0
- package/build/lib/codec/lib/NumberToBERHex.d.ts.map +1 -0
- package/build/lib/codec/lib/NumberToBERHex.js +23 -0
- package/build/lib/codec/lib/NumberToBuffer.d.ts +10 -0
- package/build/lib/codec/lib/NumberToBuffer.d.ts.map +1 -0
- package/build/lib/codec/lib/NumberToBuffer.js +22 -0
- package/build/lib/codec/lib/NumberToHex.d.ts +10 -0
- package/build/lib/codec/lib/NumberToHex.d.ts.map +1 -0
- package/build/lib/codec/lib/NumberToHex.js +26 -0
- package/build/lib/codec/lib/ProcessPacketPostHandlers.d.ts +14 -0
- package/build/lib/codec/lib/ProcessPacketPostHandlers.d.ts.map +1 -0
- package/build/lib/codec/lib/ProcessPacketPostHandlers.js +53 -0
- package/build/lib/codec/lib/SortPostHandlers.d.ts +8 -0
- package/build/lib/codec/lib/SortPostHandlers.d.ts.map +1 -0
- package/build/lib/codec/lib/SortPostHandlers.js +11 -0
- package/build/lib/codec/lib/StringContentEncodingEnum.d.ts +8 -0
- package/build/lib/codec/lib/StringContentEncodingEnum.d.ts.map +1 -0
- package/build/lib/codec/lib/StringContentEncodingEnum.js +11 -0
- package/build/lib/codec/types/CodecData.d.ts +7 -0
- package/build/lib/codec/types/CodecData.d.ts.map +1 -0
- package/build/lib/codec/types/CodecData.js +2 -0
- package/build/lib/codec/types/CodecDecodeResult.d.ts +9 -0
- package/build/lib/codec/types/CodecDecodeResult.d.ts.map +1 -0
- package/build/lib/codec/types/CodecDecodeResult.js +2 -0
- package/build/lib/codec/types/CodecEncodeInput.d.ts +5 -0
- package/build/lib/codec/types/CodecEncodeInput.d.ts.map +1 -0
- package/build/lib/codec/types/CodecEncodeInput.js +2 -0
- package/build/lib/codec/types/CodecEncodeResult.d.ts +6 -0
- package/build/lib/codec/types/CodecEncodeResult.d.ts.map +1 -0
- package/build/lib/codec/types/CodecEncodeResult.js +2 -0
- package/build/lib/codec/types/CodecErrorInfo.d.ts +6 -0
- package/build/lib/codec/types/CodecErrorInfo.d.ts.map +1 -0
- package/build/lib/codec/types/CodecErrorInfo.js +2 -0
- package/build/lib/codec/types/CodecModule.d.ts +3 -0
- package/build/lib/codec/types/CodecModule.d.ts.map +1 -0
- package/build/lib/codec/types/CodecModule.js +2 -0
- package/build/lib/codec/types/CodecModuleConstructor.d.ts +3 -0
- package/build/lib/codec/types/CodecModuleConstructor.d.ts.map +1 -0
- package/build/lib/codec/types/CodecModuleConstructor.js +2 -0
- package/build/lib/codec/types/CodecSchema.d.ts +7 -0
- package/build/lib/codec/types/CodecSchema.d.ts.map +1 -0
- package/build/lib/codec/types/CodecSchema.js +2 -0
- package/build/lib/codec/types/HeaderTreeNode.d.ts +5 -0
- package/build/lib/codec/types/HeaderTreeNode.d.ts.map +1 -0
- package/build/lib/codec/types/HeaderTreeNode.js +2 -0
- package/build/lib/codec/types/PostHandlerItem.d.ts +5 -0
- package/build/lib/codec/types/PostHandlerItem.d.ts.map +1 -0
- package/build/lib/codec/types/PostHandlerItem.js +2 -0
- package/build/lib/nodepcap/Capture.d.ts +75 -0
- package/build/lib/nodepcap/Capture.d.ts.map +1 -0
- package/build/lib/nodepcap/Capture.js +309 -0
- package/build/lib/nodepcap/GetNetworkInterfaces.d.ts +7 -0
- package/build/lib/nodepcap/GetNetworkInterfaces.d.ts.map +1 -0
- package/build/lib/nodepcap/GetNetworkInterfaces.js +22 -0
- package/build/lib/nodepcap/interfaces/IBindingCapture.d.ts +16 -0
- package/build/lib/nodepcap/interfaces/IBindingCapture.d.ts.map +1 -0
- package/build/lib/nodepcap/interfaces/IBindingCapture.js +2 -0
- package/build/lib/nodepcap/interfaces/IBindingCaptureOptions.d.ts +5 -0
- package/build/lib/nodepcap/interfaces/IBindingCaptureOptions.d.ts.map +1 -0
- package/build/lib/nodepcap/interfaces/IBindingCaptureOptions.js +2 -0
- package/build/lib/nodepcap/interfaces/ICaptureOptions.d.ts +19 -0
- package/build/lib/nodepcap/interfaces/ICaptureOptions.d.ts.map +1 -0
- package/build/lib/nodepcap/interfaces/ICaptureOptions.js +2 -0
- package/build/lib/nodepcap/interfaces/INetworkInterface.d.ts +5 -0
- package/build/lib/nodepcap/interfaces/INetworkInterface.d.ts.map +1 -0
- package/build/lib/nodepcap/interfaces/INetworkInterface.js +2 -0
- package/build/lib/nodepcap/lib/BindingCapture.d.ts +15 -0
- package/build/lib/nodepcap/lib/BindingCapture.d.ts.map +1 -0
- package/build/lib/nodepcap/lib/BindingCapture.js +35 -0
- package/build/lib/nodepcap/lib/GetNodePcapBinding.d.ts +2 -0
- package/build/lib/nodepcap/lib/GetNodePcapBinding.d.ts.map +1 -0
- package/build/lib/nodepcap/lib/GetNodePcapBinding.js +55 -0
- package/build/lib/nodepcap/lib/GetNodePcapBindingCapture.d.ts +3 -0
- package/build/lib/nodepcap/lib/GetNodePcapBindingCapture.d.ts.map +1 -0
- package/build/lib/nodepcap/lib/GetNodePcapBindingCapture.js +18 -0
- package/build/lib/nodepcap/workers/CaptureWorker.d.ts +2 -0
- package/build/lib/nodepcap/workers/CaptureWorker.d.ts.map +1 -0
- package/build/lib/nodepcap/workers/CaptureWorker.js +25 -0
- package/build/lib/pcap/PCAPGenerator.d.ts +34 -0
- package/build/lib/pcap/PCAPGenerator.d.ts.map +1 -0
- package/build/lib/pcap/PCAPGenerator.js +95 -0
- package/build/lib/pcap/PcapParser.d.ts +27 -0
- package/build/lib/pcap/PcapParser.d.ts.map +1 -0
- package/build/lib/pcap/PcapParser.js +149 -0
- package/build/lib/pcap/PcapReader.d.ts +87 -0
- package/build/lib/pcap/PcapReader.d.ts.map +1 -0
- package/build/lib/pcap/PcapReader.js +207 -0
- package/build/lib/pcap/PcapWriter.d.ts +29 -0
- package/build/lib/pcap/PcapWriter.d.ts.map +1 -0
- package/build/lib/pcap/PcapWriter.js +80 -0
- package/build/lib/pcap/interfaces/IPcapPacketInfo.d.ts +13 -0
- package/build/lib/pcap/interfaces/IPcapPacketInfo.d.ts.map +1 -0
- package/build/lib/pcap/interfaces/IPcapPacketInfo.js +2 -0
- package/build/lib/pipe/PipeClient.d.ts +35 -0
- package/build/lib/pipe/PipeClient.d.ts.map +1 -0
- package/build/lib/pipe/PipeClient.js +71 -0
- package/build/lib/pipe/PipeClientSocket.d.ts +39 -0
- package/build/lib/pipe/PipeClientSocket.d.ts.map +1 -0
- package/build/lib/pipe/PipeClientSocket.js +82 -0
- package/build/lib/pipe/PipeMessage.d.ts +27 -0
- package/build/lib/pipe/PipeMessage.d.ts.map +1 -0
- package/build/lib/pipe/PipeMessage.js +61 -0
- package/build/lib/pipe/PipeMessageHandler.d.ts +16 -0
- package/build/lib/pipe/PipeMessageHandler.d.ts.map +1 -0
- package/build/lib/pipe/PipeMessageHandler.js +95 -0
- package/build/lib/pipe/PipeServer.d.ts +25 -0
- package/build/lib/pipe/PipeServer.d.ts.map +1 -0
- package/build/lib/pipe/PipeServer.js +59 -0
- package/build/lib/schema/ProtocolFieldJSONSchema.d.ts +35 -0
- package/build/lib/schema/ProtocolFieldJSONSchema.d.ts.map +1 -0
- package/build/lib/schema/ProtocolFieldJSONSchema.js +2 -0
- package/build/lib/schema/ProtocolFieldJSONSchemaDefinition.d.ts +3 -0
- package/build/lib/schema/ProtocolFieldJSONSchemaDefinition.d.ts.map +1 -0
- package/build/lib/schema/ProtocolFieldJSONSchemaDefinition.js +2 -0
- package/build/lib/schema/ProtocolJSONSchema.d.ts +32 -0
- package/build/lib/schema/ProtocolJSONSchema.d.ts.map +1 -0
- package/build/lib/schema/ProtocolJSONSchema.js +2 -0
- package/build/tests/Test.spec.d.ts +2 -0
- package/build/tests/Test.spec.d.ts.map +1 -0
- package/build/tests/Test.spec.js +25 -0
- package/build/tests/units/CaptureTest.spec.d.ts +2 -0
- package/build/tests/units/CaptureTest.spec.d.ts.map +1 -0
- package/build/tests/units/CaptureTest.spec.js +31 -0
- package/build/tests/units/Codec.spec.d.ts +2 -0
- package/build/tests/units/Codec.spec.d.ts.map +1 -0
- package/build/tests/units/Codec.spec.js +70 -0
- package/cpp/nodepcap/deps/include/Packet32.h +429 -0
- package/cpp/nodepcap/deps/include/pcap/bluetooth.h +56 -0
- package/cpp/nodepcap/deps/include/pcap/bpf.h +292 -0
- package/cpp/nodepcap/deps/include/pcap/can_socketcan.h +56 -0
- package/cpp/nodepcap/deps/include/pcap/compiler-tests.h +163 -0
- package/cpp/nodepcap/deps/include/pcap/dlt.h +1514 -0
- package/cpp/nodepcap/deps/include/pcap/funcattrs.h +325 -0
- package/cpp/nodepcap/deps/include/pcap/ipnet.h +43 -0
- package/cpp/nodepcap/deps/include/pcap/namedb.h +84 -0
- package/cpp/nodepcap/deps/include/pcap/nflog.h +94 -0
- package/cpp/nodepcap/deps/include/pcap/pcap-inttypes.h +101 -0
- package/cpp/nodepcap/deps/include/pcap/pcap.h +1219 -0
- package/cpp/nodepcap/deps/include/pcap/sll.h +149 -0
- package/cpp/nodepcap/deps/include/pcap/socket.h +84 -0
- package/cpp/nodepcap/deps/include/pcap/usb.h +143 -0
- package/cpp/nodepcap/deps/include/pcap/vlan.h +46 -0
- package/cpp/nodepcap/deps/include/pcap-bpf.h +45 -0
- package/cpp/nodepcap/deps/include/pcap-namedb.h +40 -0
- package/cpp/nodepcap/deps/include/pcap.h +43 -0
- package/cpp/nodepcap/deps/lib/ARM64/Packet.lib +0 -0
- package/cpp/nodepcap/deps/lib/Packet.lib +0 -0
- package/cpp/nodepcap/deps/lib/wpcap.lib +0 -0
- package/cpp/nodepcap/deps/lib/x64/Packet.lib +0 -0
- package/cpp/nodepcap/deps/lib/x64/wpcap.lib +0 -0
- package/cpp/nodepcap/nodepcap.gypi +104 -0
- package/cpp/nodepcap/src/binding.cc +14 -0
- package/cpp/nodepcap/src/capture.cc +400 -0
- package/cpp/nodepcap/src/capture.h +53 -0
- package/cpp/nodepcap/src/utils.cc +218 -0
- package/cpp/nodepcap/src/utils.h +13 -0
- package/package.json +65 -0
- package/src/NetKitty.ts +31 -0
- package/src/errors/ActionNotFoundError.ts +6 -0
- package/src/errors/CodecSchemaValidateError.ts +6 -0
- package/src/errors/DeviceNotFoundError.ts +6 -0
- package/src/errors/NoAvailableCodecError.ts +6 -0
- package/src/errors/NpcapLoadError.ts +6 -0
- package/src/errors/SocketDownError.ts +6 -0
- package/src/errors/UnknownPipeMessageTypeError.ts +6 -0
- package/src/errors/common/ErrorCode.ts +30 -0
- package/src/lib/GeneratePipeAddress.ts +17 -0
- package/src/lib/GetBinding.ts +3 -0
- package/src/lib/GetCaptureTemporaryDirectory.ts +12 -0
- package/src/lib/GetDeviceCaptureTemporaryFilename.ts +13 -0
- package/src/lib/codec/Codec.ts +181 -0
- package/src/lib/codec/abstracts/BaseHeader.ts +413 -0
- package/src/lib/codec/headers/ARP.ts +218 -0
- package/src/lib/codec/headers/EthernetII.ts +77 -0
- package/src/lib/codec/headers/Goose.ts +658 -0
- package/src/lib/codec/headers/IEC61850SampledValues.ts +359 -0
- package/src/lib/codec/headers/IPv4.ts +329 -0
- package/src/lib/codec/headers/RawData.ts +34 -0
- package/src/lib/codec/headers/TCP.ts +931 -0
- package/src/lib/codec/headers/UDP.ts +180 -0
- package/src/lib/codec/headers/VLAN_802dot1Q.ts +74 -0
- package/src/lib/codec/lib/BufferToHex.ts +3 -0
- package/src/lib/codec/lib/BufferToIP.ts +19 -0
- package/src/lib/codec/lib/BufferToNumber.ts +31 -0
- package/src/lib/codec/lib/FixHexString.ts +8 -0
- package/src/lib/codec/lib/FlexibleObject.ts +100 -0
- package/src/lib/codec/lib/HexToNumber.ts +25 -0
- package/src/lib/codec/lib/IPToBuffer.ts +25 -0
- package/src/lib/codec/lib/NumberToBERBuffer.ts +19 -0
- package/src/lib/codec/lib/NumberToBERHex.ts +13 -0
- package/src/lib/codec/lib/NumberToBuffer.ts +21 -0
- package/src/lib/codec/lib/NumberToHex.ts +15 -0
- package/src/lib/codec/lib/ProcessPacketPostHandlers.ts +53 -0
- package/src/lib/codec/lib/SortPostHandlers.ts +10 -0
- package/src/lib/codec/lib/StringContentEncodingEnum.ts +7 -0
- package/src/lib/codec/types/CodecData.ts +7 -0
- package/src/lib/codec/types/CodecDecodeResult.ts +9 -0
- package/src/lib/codec/types/CodecEncodeInput.ts +5 -0
- package/src/lib/codec/types/CodecEncodeResult.ts +6 -0
- package/src/lib/codec/types/CodecErrorInfo.ts +5 -0
- package/src/lib/codec/types/CodecModule.ts +3 -0
- package/src/lib/codec/types/CodecModuleConstructor.ts +3 -0
- package/src/lib/codec/types/CodecSchema.ts +7 -0
- package/src/lib/codec/types/HeaderTreeNode.ts +5 -0
- package/src/lib/codec/types/PostHandlerItem.ts +4 -0
- package/src/lib/nodepcap/Capture.ts +291 -0
- package/src/lib/nodepcap/GetNetworkInterfaces.ts +18 -0
- package/src/lib/nodepcap/interfaces/IBindingCapture.ts +27 -0
- package/src/lib/nodepcap/interfaces/IBindingCaptureOptions.ts +4 -0
- package/src/lib/nodepcap/interfaces/ICaptureOptions.ts +19 -0
- package/src/lib/nodepcap/interfaces/INetworkInterface.ts +4 -0
- package/src/lib/nodepcap/lib/BindingCapture.ts +46 -0
- package/src/lib/nodepcap/lib/GetNodePcapBinding.ts +17 -0
- package/src/lib/nodepcap/lib/GetNodePcapBindingCapture.ts +15 -0
- package/src/lib/nodepcap/workers/CaptureWorker.ts +30 -0
- package/src/lib/pcap/PCAPGenerator.ts +118 -0
- package/src/lib/pcap/PcapParser.ts +170 -0
- package/src/lib/pcap/PcapReader.ts +239 -0
- package/src/lib/pcap/PcapWriter.ts +93 -0
- package/src/lib/pcap/interfaces/IPcapPacketInfo.ts +12 -0
- package/src/lib/pipe/PipeClient.ts +91 -0
- package/src/lib/pipe/PipeClientSocket.ts +99 -0
- package/src/lib/pipe/PipeMessage.ts +74 -0
- package/src/lib/pipe/PipeMessageHandler.ts +91 -0
- package/src/lib/pipe/PipeServer.ts +74 -0
- package/src/lib/schema/ProtocolFieldJSONSchema.ts +45 -0
- package/src/lib/schema/ProtocolFieldJSONSchemaDefinition.ts +3 -0
- package/src/lib/schema/ProtocolJSONSchema.ts +37 -0
- package/src/tests/Test.spec.ts +22 -0
- package/src/tests/units/CaptureTest.spec.ts +30 -0
- package/src/tests/units/Codec.spec.ts +85 -0
- package/tsconfig.json +41 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import {ProtocolJSONSchema} from '../../schema/ProtocolJSONSchema'
|
|
2
|
+
import {BaseHeader} from '../abstracts/BaseHeader'
|
|
3
|
+
import {UInt16ToHex} from '../lib/NumberToHex'
|
|
4
|
+
import {CodecModule} from '../types/CodecModule'
|
|
5
|
+
import {StringContentEncodingEnum} from '../lib/StringContentEncodingEnum'
|
|
6
|
+
import {FixHexString} from '../lib/FixHexString'
|
|
7
|
+
import {BufferToUInt16, BufferToUInt8} from '../lib/BufferToNumber'
|
|
8
|
+
import {UInt16ToBuffer, UInt8ToBuffer} from '../lib/NumberToBuffer'
|
|
9
|
+
import {BufferToHex} from '../lib/BufferToHex'
|
|
10
|
+
import {IPv4ToBuffer} from '../lib/IPToBuffer'
|
|
11
|
+
import {BufferToIPv4} from '../lib/BufferToIP'
|
|
12
|
+
|
|
13
|
+
export class IPv4 extends BaseHeader {
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Calculate IPv4 header checksum
|
|
17
|
+
* @param headerBuffer
|
|
18
|
+
* @protected
|
|
19
|
+
*/
|
|
20
|
+
protected calculateIPv4Checksum(headerBuffer: Buffer): number {
|
|
21
|
+
const header: Uint8Array = Uint8Array.from(headerBuffer)
|
|
22
|
+
let sum: number = 0
|
|
23
|
+
for (let i: number = 0; i < header.length; i += 2) {
|
|
24
|
+
let word = (header[i] << 8) + (header[i + 1] || 0)
|
|
25
|
+
sum += word
|
|
26
|
+
}
|
|
27
|
+
while (sum >>> 16) {
|
|
28
|
+
sum = (sum & 0xFFFF) + (sum >>> 16)
|
|
29
|
+
}
|
|
30
|
+
return (~sum) & 0xFFFF
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public SCHEMA: ProtocolJSONSchema = {
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
version: {
|
|
37
|
+
type: 'integer',
|
|
38
|
+
label: 'Version',
|
|
39
|
+
minimum: 0,
|
|
40
|
+
maximum: 15,
|
|
41
|
+
decode: (): void => {
|
|
42
|
+
this.instance.version.setValue(this.readBits(0, 1, 0, 4))
|
|
43
|
+
if (this.instance.version.getValue() !== 4) this.recordError(this.instance.version.getPath(), 'IPv4 version should be 4')
|
|
44
|
+
},
|
|
45
|
+
encode: (): void => {
|
|
46
|
+
let version: number = this.instance.version.getValue(4)
|
|
47
|
+
version = version > 15 ? 15 : version
|
|
48
|
+
version = version < 0 ? 0 : version
|
|
49
|
+
if (version !== 4) this.recordError(this.instance.version.getPath(), 'IPv4 version should be 4')
|
|
50
|
+
this.instance.version.setValue(version)
|
|
51
|
+
this.writeBits(0, 1, 0, 4, version)
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
hdrLen: {
|
|
55
|
+
type: 'integer',
|
|
56
|
+
label: 'Header Length',
|
|
57
|
+
minimum: 20,
|
|
58
|
+
maximum: 60,
|
|
59
|
+
decode: (): void => {
|
|
60
|
+
this.instance.hdrLen.setValue(this.readBits(0, 1, 4, 4) * 4)
|
|
61
|
+
},
|
|
62
|
+
encode: (): void => {
|
|
63
|
+
let headerLength: number = this.instance.hdrLen.getValue(0)
|
|
64
|
+
if (headerLength) headerLength = headerLength ? Math.floor(headerLength / 4) : 0
|
|
65
|
+
this.writeBits(0, 1, 4, 4, headerLength)
|
|
66
|
+
if (!headerLength) this.addPostSelfEncodeHandler((): void => {
|
|
67
|
+
this.instance.hdrLen.setValue(this.length)
|
|
68
|
+
this.writeBits(0, 1, 4, 4, Math.floor(this.length / 4))
|
|
69
|
+
}, 10)
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
dsfield: {
|
|
73
|
+
type: 'object',
|
|
74
|
+
label: 'Differentiated Services Field',
|
|
75
|
+
properties: {
|
|
76
|
+
dscp: {
|
|
77
|
+
type: 'integer',
|
|
78
|
+
minimum: 0,
|
|
79
|
+
maximum: 63,
|
|
80
|
+
label: 'Differentiated Services Codepoint',
|
|
81
|
+
decode: (): void => {
|
|
82
|
+
this.instance.dsfield.dscp.setValue(this.readBits(1, 1, 0, 6))
|
|
83
|
+
},
|
|
84
|
+
encode: (): void => {
|
|
85
|
+
const dscp: number = this.instance.dsfield.dscp.getValue(0)
|
|
86
|
+
this.instance.dsfield.dscp.setValue(dscp)
|
|
87
|
+
this.writeBits(1, 1, 0, 6, dscp)
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
ecn: {
|
|
91
|
+
type: 'integer',
|
|
92
|
+
label: 'Explicit Congestion Notification',
|
|
93
|
+
decode: (): void => {
|
|
94
|
+
this.instance.dsfield.ecn.setValue(this.readBits(1, 1, 6, 2))
|
|
95
|
+
},
|
|
96
|
+
encode: (): void => {
|
|
97
|
+
const ecn: number = this.instance.dsfield.ecn.getValue(0)
|
|
98
|
+
this.instance.dsfield.ecn.setValue(ecn)
|
|
99
|
+
this.writeBits(1, 1, 6, 2, ecn)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
length: {
|
|
105
|
+
type: 'integer',
|
|
106
|
+
label: 'Total Length',
|
|
107
|
+
minimum: 0,
|
|
108
|
+
maximum: 65535,
|
|
109
|
+
decode: (): void => {
|
|
110
|
+
this.instance.length.setValue(BufferToUInt16(this.readBytes(2, 2)))
|
|
111
|
+
},
|
|
112
|
+
encode: (): void => {
|
|
113
|
+
//This field's real value needs down stream codec invoke recode to fill
|
|
114
|
+
let length: number = this.instance.length.getValue(0)
|
|
115
|
+
if (length) {
|
|
116
|
+
this.writeBytes(2, UInt16ToBuffer(length))
|
|
117
|
+
} else {
|
|
118
|
+
this.writeBytes(2, UInt16ToBuffer(length))
|
|
119
|
+
this.addPostPacketEncodeHandler((): void => {
|
|
120
|
+
let startCount: boolean = false
|
|
121
|
+
let totalLength: number = 0
|
|
122
|
+
this.codecModules.forEach((codecModule: CodecModule): void => {
|
|
123
|
+
if (codecModule === this) startCount = true
|
|
124
|
+
if (startCount) totalLength += codecModule.length
|
|
125
|
+
})
|
|
126
|
+
this.instance.length.setValue(totalLength)
|
|
127
|
+
this.writeBytes(2, UInt16ToBuffer(totalLength))
|
|
128
|
+
}, 1)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
id: {
|
|
133
|
+
type: 'integer',
|
|
134
|
+
label: 'Identification',
|
|
135
|
+
minimum: 0,
|
|
136
|
+
maximum: 65535,
|
|
137
|
+
decode: (): void => {
|
|
138
|
+
this.instance.id.setValue(BufferToUInt16(this.readBytes(4, 2)))
|
|
139
|
+
},
|
|
140
|
+
encode: (): void => {
|
|
141
|
+
const id: number = this.instance.id.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
142
|
+
this.instance.id.setValue(id)
|
|
143
|
+
this.writeBytes(4, UInt16ToBuffer(id))
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
flags: {
|
|
147
|
+
type: 'object',
|
|
148
|
+
label: 'Flags',
|
|
149
|
+
properties: {
|
|
150
|
+
rb: {
|
|
151
|
+
type: 'integer',
|
|
152
|
+
enum: [0, 1],
|
|
153
|
+
label: 'Reserved bit',
|
|
154
|
+
decode: (): void => {
|
|
155
|
+
this.instance.flags.rb.setValue(this.readBits(6, 1, 0, 1))
|
|
156
|
+
},
|
|
157
|
+
encode: (): void => {
|
|
158
|
+
const rb: number = this.instance.flags.rb.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
159
|
+
this.instance.flags.rb.setValue(rb)
|
|
160
|
+
this.writeBits(6, 1, 0, 1, rb)
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
df: {
|
|
164
|
+
type: 'integer',
|
|
165
|
+
enum: [0, 1],
|
|
166
|
+
label: 'Don\'t fragment',
|
|
167
|
+
decode: (): void => {
|
|
168
|
+
this.instance.flags.df.setValue(this.readBits(6, 1, 1, 1))
|
|
169
|
+
},
|
|
170
|
+
encode: (): void => {
|
|
171
|
+
const df: number = this.instance.flags.df.getValue(1, (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
172
|
+
this.instance.flags.df.setValue(df)
|
|
173
|
+
this.writeBits(6, 1, 1, 1, df)
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
mf: {
|
|
177
|
+
type: 'integer',
|
|
178
|
+
enum: [0, 1],
|
|
179
|
+
label: 'More fragments',
|
|
180
|
+
decode: (): void => {
|
|
181
|
+
this.instance.flags.mf.setValue(this.readBits(6, 1, 2, 1))
|
|
182
|
+
},
|
|
183
|
+
encode: (): void => {
|
|
184
|
+
const mf: number = this.instance.flags.mf.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
185
|
+
this.instance.flags.mf.setValue(mf)
|
|
186
|
+
this.writeBits(6, 1, 2, 1, mf)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
fragOffset: {
|
|
192
|
+
type: 'integer',
|
|
193
|
+
minimum: 0,
|
|
194
|
+
maximum: 8191,
|
|
195
|
+
label: 'Fragment Offset',
|
|
196
|
+
decode: (): void => {
|
|
197
|
+
this.instance.fragOffset.setValue(this.readBits(6, 2, 3, 13))
|
|
198
|
+
},
|
|
199
|
+
encode: (): void => {
|
|
200
|
+
const fragOffset: number = this.instance.fragOffset.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
201
|
+
this.instance.fragOffset.setValue(fragOffset)
|
|
202
|
+
this.writeBits(6, 2, 3, 13, fragOffset)
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
ttl: {
|
|
206
|
+
type: 'integer',
|
|
207
|
+
minimum: 0,
|
|
208
|
+
maximum: 255,
|
|
209
|
+
label: 'Time to Live',
|
|
210
|
+
decode: (): void => {
|
|
211
|
+
this.instance.ttl.setValue(BufferToUInt8(this.readBytes(8, 1)))
|
|
212
|
+
},
|
|
213
|
+
encode: (): void => {
|
|
214
|
+
const ttl: number = this.instance.ttl.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
215
|
+
this.instance.ttl.setValue(ttl)
|
|
216
|
+
this.writeBytes(8, UInt8ToBuffer(ttl))
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
protocol: {
|
|
220
|
+
type: 'integer',
|
|
221
|
+
label: 'Protocol',
|
|
222
|
+
minimum: 0,
|
|
223
|
+
maximum: 255,
|
|
224
|
+
decode: (): void => {
|
|
225
|
+
this.instance.protocol.setValue(BufferToUInt8(this.readBytes(9, 1)))
|
|
226
|
+
},
|
|
227
|
+
encode: (): void => {
|
|
228
|
+
const protocol: number = this.instance.protocol.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
229
|
+
this.instance.protocol.setValue(protocol)
|
|
230
|
+
this.writeBytes(9, UInt8ToBuffer(protocol))
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
checksum: {
|
|
234
|
+
type: 'integer',
|
|
235
|
+
label: 'Header Checksum',
|
|
236
|
+
minimum: 0,
|
|
237
|
+
maximum: 65535,
|
|
238
|
+
decode: (): void => {
|
|
239
|
+
this.instance.checksum.setValue(BufferToUInt16(this.readBytes(10, 2)))
|
|
240
|
+
},
|
|
241
|
+
encode: (): void => {
|
|
242
|
+
let checksum: number = this.instance.checksum.getValue(0)
|
|
243
|
+
checksum = checksum > 65535 ? 65535 : checksum
|
|
244
|
+
checksum = checksum < 0 ? 0 : checksum
|
|
245
|
+
if (checksum) {
|
|
246
|
+
this.instance.checksum.setValue(checksum)
|
|
247
|
+
this.writeBytes(10, UInt16ToBuffer(checksum))
|
|
248
|
+
} else {
|
|
249
|
+
this.instance.checksum.setValue(checksum)
|
|
250
|
+
this.writeBytes(10, UInt16ToBuffer(checksum))
|
|
251
|
+
this.addPostPacketEncodeHandler((): void => {
|
|
252
|
+
const calcChecksum: number = this.calculateIPv4Checksum(this.packet.subarray(this.startPos, this.endPos))
|
|
253
|
+
this.instance.checksum.setValue(calcChecksum)
|
|
254
|
+
this.writeBytes(10, UInt16ToBuffer(calcChecksum))
|
|
255
|
+
}, 2)
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
sip: {
|
|
260
|
+
type: 'string',
|
|
261
|
+
label: 'Source Address',
|
|
262
|
+
minLength: 7,
|
|
263
|
+
maxLength: 15,
|
|
264
|
+
contentEncoding: StringContentEncodingEnum.UTF8,
|
|
265
|
+
decode: (): void => {
|
|
266
|
+
const sipBuffer: Buffer = this.readBytes(12, 4)
|
|
267
|
+
this.instance.sip.setValue(BufferToIPv4(sipBuffer))
|
|
268
|
+
},
|
|
269
|
+
encode: (): void => {
|
|
270
|
+
const sipStr: string = this.instance.sip.getValue('0.0.0.0', (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
271
|
+
this.instance.sip.setValue(sipStr)
|
|
272
|
+
this.writeBytes(12, IPv4ToBuffer(sipStr))
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
dip: {
|
|
276
|
+
type: 'string',
|
|
277
|
+
minLength: 7,
|
|
278
|
+
maxLength: 15,
|
|
279
|
+
label: 'Destination Address',
|
|
280
|
+
contentEncoding: StringContentEncodingEnum.UTF8,
|
|
281
|
+
decode: (): void => {
|
|
282
|
+
const dipBuffer: Buffer = this.readBytes(16, 4)
|
|
283
|
+
this.instance.dip.setValue(BufferToIPv4(dipBuffer))
|
|
284
|
+
},
|
|
285
|
+
encode: (): void => {
|
|
286
|
+
const dipStr: string = this.instance.dip.getValue('0.0.0.0', (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
287
|
+
this.instance.dip.setValue(dipStr)
|
|
288
|
+
this.writeBytes(16, IPv4ToBuffer(dipStr))
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
options: {
|
|
292
|
+
type: 'string',
|
|
293
|
+
label: 'Options',
|
|
294
|
+
minLength: 0,
|
|
295
|
+
maxLength: 40 * 2,
|
|
296
|
+
contentEncoding: StringContentEncodingEnum.HEX,
|
|
297
|
+
decode: (): void => {
|
|
298
|
+
if (this.length < (this.instance.hdrLen.getValue())) {
|
|
299
|
+
this.instance.options.setValue(BufferToHex(this.readBytes(this.length, (this.instance.hdrLen.getValue()) - this.length)))
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
encode: (): void => {
|
|
303
|
+
if (!this.instance.options.isUndefined()) {
|
|
304
|
+
let optionsBuffer: Buffer = Buffer.from(FixHexString(this.instance.options.getValue()), 'hex')
|
|
305
|
+
if (optionsBuffer.length > 40) optionsBuffer = optionsBuffer.subarray(0, 40)
|
|
306
|
+
const estimateHdrLen: number = this.length + optionsBuffer.length
|
|
307
|
+
if (estimateHdrLen % 4) {
|
|
308
|
+
/**
|
|
309
|
+
* IPv4 Header should have a length that a multiple of 32 bits
|
|
310
|
+
* @see https://learningnetwork.cisco.com/s/question/0D53i00000Kt6hHCAR/padding-field-on-ipv4-header
|
|
311
|
+
*/
|
|
312
|
+
optionsBuffer = Buffer.concat([optionsBuffer, Buffer.from([0x00])])
|
|
313
|
+
}
|
|
314
|
+
this.writeBytes(this.length, optionsBuffer)
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
public id: string = 'ipv4'
|
|
322
|
+
|
|
323
|
+
public name: string = 'Internet Protocol Version 4'
|
|
324
|
+
|
|
325
|
+
public match(): boolean {
|
|
326
|
+
if (!this.prevCodecModule) return false
|
|
327
|
+
return this.prevCodecModule.instance.etherType.getValue() === UInt16ToHex(0x0800)
|
|
328
|
+
}
|
|
329
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {ProtocolJSONSchema} from '../../schema/ProtocolJSONSchema'
|
|
2
|
+
import {BaseHeader} from '../abstracts/BaseHeader'
|
|
3
|
+
import {StringContentEncodingEnum} from '../lib/StringContentEncodingEnum'
|
|
4
|
+
import {BufferToHex} from '../lib/BufferToHex'
|
|
5
|
+
|
|
6
|
+
export class RawData extends BaseHeader {
|
|
7
|
+
|
|
8
|
+
public readonly SCHEMA: ProtocolJSONSchema = {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
data: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
label: 'Raw',
|
|
14
|
+
contentEncoding: StringContentEncodingEnum.HEX,
|
|
15
|
+
decode: (): void => {
|
|
16
|
+
const dataLength: number = this.packet.length - this.startPos
|
|
17
|
+
this.instance.data.setValue(BufferToHex(this.readBytes(0, dataLength)))
|
|
18
|
+
},
|
|
19
|
+
encode: (): void => {
|
|
20
|
+
this.writeBytes(0, Buffer.from(this.instance.data.getValue().toString(), 'hex'))
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public readonly id: string = 'raw'
|
|
27
|
+
|
|
28
|
+
public readonly name: string = 'Raw Data'
|
|
29
|
+
|
|
30
|
+
public match(): boolean {
|
|
31
|
+
return !!this.prevCodecModule
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|