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,359 @@
|
|
|
1
|
+
import {ProtocolJSONSchema} from '../../schema/ProtocolJSONSchema'
|
|
2
|
+
import {BaseHeader} from '../abstracts/BaseHeader'
|
|
3
|
+
import TLV from 'node-tlv'
|
|
4
|
+
import {HexToUInt16} from '../lib/HexToNumber'
|
|
5
|
+
import {UInt16ToBERHex} from '../lib/NumberToBERHex'
|
|
6
|
+
import {UInt16ToHex, UInt32ToHex, UInt8ToHex} from '../lib/NumberToHex'
|
|
7
|
+
import {StringContentEncodingEnum} from '../lib/StringContentEncodingEnum'
|
|
8
|
+
import {BufferToUInt16, BufferToUInt32, BufferToUInt64, BufferToUInt8} from '../lib/BufferToNumber'
|
|
9
|
+
import {UInt16ToBuffer} from '../lib/NumberToBuffer'
|
|
10
|
+
|
|
11
|
+
type ASDUItem = {
|
|
12
|
+
svID: string
|
|
13
|
+
dataSet?: string
|
|
14
|
+
smpCnt: number
|
|
15
|
+
confRev: number
|
|
16
|
+
refrTm?: string
|
|
17
|
+
smpSynch: number
|
|
18
|
+
smpRate?: number
|
|
19
|
+
sample: string
|
|
20
|
+
smpMod?: number
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class IEC61850SampledValues extends BaseHeader {
|
|
24
|
+
|
|
25
|
+
protected TLVInstance: TLV
|
|
26
|
+
|
|
27
|
+
protected TLVChild: TLV[] = []
|
|
28
|
+
|
|
29
|
+
public SCHEMA: ProtocolJSONSchema = {
|
|
30
|
+
type: 'object',
|
|
31
|
+
properties: {
|
|
32
|
+
appid: {
|
|
33
|
+
type: 'integer',
|
|
34
|
+
minimum: 0,
|
|
35
|
+
maximum: 65535,
|
|
36
|
+
label: 'APPID',
|
|
37
|
+
decode: (): void => {
|
|
38
|
+
this.instance.appid.setValue(BufferToUInt16(this.readBytes(0, 2)))
|
|
39
|
+
},
|
|
40
|
+
encode: (): void => {
|
|
41
|
+
const APPID: number = this.instance.appid.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
42
|
+
this.instance.appid.setValue(APPID)
|
|
43
|
+
this.writeBytes(0, UInt16ToBuffer(APPID))
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
length: {
|
|
47
|
+
type: 'integer',
|
|
48
|
+
label: 'Length',
|
|
49
|
+
decode: (): void => {
|
|
50
|
+
this.instance.length.setValue(BufferToUInt16(this.readBytes(2, 2)))
|
|
51
|
+
},
|
|
52
|
+
encode: (): void => {
|
|
53
|
+
const length: number = this.instance.length.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
54
|
+
if (length > 0) {
|
|
55
|
+
this.instance.length.setValue(length)
|
|
56
|
+
this.writeBytes(2, UInt16ToBuffer(length))
|
|
57
|
+
} else {
|
|
58
|
+
this.addPostSelfEncodeHandler((): void => {
|
|
59
|
+
const finalLength: number = parseInt(this.instance.length.getValue().toString())
|
|
60
|
+
this.writeBytes(2, UInt16ToBuffer(finalLength))
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
reserved1: {
|
|
66
|
+
type: 'object',
|
|
67
|
+
label: 'Reserved1',
|
|
68
|
+
properties: {
|
|
69
|
+
simulated: {
|
|
70
|
+
type: 'boolean',
|
|
71
|
+
label: 'Simulated',
|
|
72
|
+
decode: (): void => {
|
|
73
|
+
this.instance.reserved1.simulated.setValue(!!this.readBits(4, 2, 0, 1))
|
|
74
|
+
},
|
|
75
|
+
encode: (): void => {
|
|
76
|
+
const simulated: boolean = !!this.instance.reserved1.simulated.getValue()
|
|
77
|
+
this.writeBits(4, 2, 0, 1, simulated ? 1 : 0)
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
reserved: {
|
|
81
|
+
type: 'number',
|
|
82
|
+
minimum: 0,
|
|
83
|
+
maximum: 32767,
|
|
84
|
+
label: 'Reserved',
|
|
85
|
+
decode: (): void => {
|
|
86
|
+
this.instance.reserved1.reserved.setValue(this.readBits(4, 2, 1, 16))
|
|
87
|
+
},
|
|
88
|
+
encode: (): void => {
|
|
89
|
+
const reserved: number = this.instance.reserved1.reserved.getValue(0)
|
|
90
|
+
this.writeBits(4, 2, 1, 16, reserved)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
reserved2: {
|
|
96
|
+
type: 'object',
|
|
97
|
+
label: 'Reserved2',
|
|
98
|
+
properties: {
|
|
99
|
+
reserved: {
|
|
100
|
+
type: 'number',
|
|
101
|
+
minimum: 0,
|
|
102
|
+
maximum: 65535,
|
|
103
|
+
label: 'Reserved',
|
|
104
|
+
decode: (): void => {
|
|
105
|
+
this.instance.reserved2.reserved.setValue(this.readBits(4, 2, 0, 16))
|
|
106
|
+
},
|
|
107
|
+
encode: (): void => {
|
|
108
|
+
const reserved: number = this.instance.reserved2.reserved.getValue(0)
|
|
109
|
+
this.writeBits(4, 2, 0, 16, reserved)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
svPdu: {
|
|
115
|
+
type: 'object',
|
|
116
|
+
label: 'Sampled Values PDU',
|
|
117
|
+
decode: (): void => {
|
|
118
|
+
const buffer: Buffer = this.readBytes(8, (this.instance.length.getValue()) - 8)
|
|
119
|
+
this.TLVInstance = TLV.parse(buffer)
|
|
120
|
+
this.TLVChild = this.TLVInstance.getChild()
|
|
121
|
+
this.instance.svPdu.setValue({})
|
|
122
|
+
},
|
|
123
|
+
encode: (): void => {
|
|
124
|
+
let buffer: Buffer = Buffer.from([])
|
|
125
|
+
this.TLVChild.forEach(TLVItem => buffer = Buffer.concat([buffer, TLVItem.bTag, TLVItem.bLength, TLVItem.bValue]))
|
|
126
|
+
const svPduTLV: TLV = new TLV(0x60, buffer)
|
|
127
|
+
let svPduBuffer: Buffer = Buffer.concat([svPduTLV.bTag, svPduTLV.bLength, svPduTLV.bValue])
|
|
128
|
+
this.writeBytes(8, svPduBuffer)
|
|
129
|
+
/**
|
|
130
|
+
* Update the length only if it is not set
|
|
131
|
+
* Update length(APPID's length + Length's length + Reserved1's length + Reserved2's length + svPdu's length)
|
|
132
|
+
*/
|
|
133
|
+
if (this.instance.length.getValue() > 0) return
|
|
134
|
+
this.instance.length.setValue(2 + 2 + 2 + 2 + svPduBuffer.length)
|
|
135
|
+
},
|
|
136
|
+
properties: {
|
|
137
|
+
noASDU: {
|
|
138
|
+
type: 'integer',
|
|
139
|
+
minimum: 1,
|
|
140
|
+
maximum: 65535,
|
|
141
|
+
label: 'Number of ASDU',
|
|
142
|
+
decode: (): void => {
|
|
143
|
+
const noASDUTLV: TLV | undefined = this.TLVChild.find(tlv => tlv.getTag('number') === 0x80)
|
|
144
|
+
if (!noASDUTLV) return this.recordError(this.instance.svPdu.noASDU.getPath(), 'Not Found')
|
|
145
|
+
const noASDUNum: number = HexToUInt16(noASDUTLV.getValue('hex'))
|
|
146
|
+
if (!noASDUNum) this.recordError(this.instance.svPdu.noASDU.getPath(), 'Number of ASDU should be greater or equal to 1')
|
|
147
|
+
this.instance.svPdu.noASDU.setValue(noASDUNum)
|
|
148
|
+
},
|
|
149
|
+
encode: (): void => {
|
|
150
|
+
const noASDU: number = this.instance.svPdu.noASDU.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'noASDU is not set'))
|
|
151
|
+
this.TLVChild.push(new TLV(0x80, UInt16ToBERHex(noASDU)))
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
seqASDU: {
|
|
155
|
+
type: 'array',
|
|
156
|
+
label: 'Sequence ASDU',
|
|
157
|
+
items: {
|
|
158
|
+
type: 'object',
|
|
159
|
+
properties: {
|
|
160
|
+
svID: {
|
|
161
|
+
type: 'string',
|
|
162
|
+
contentEncoding: StringContentEncodingEnum.ASCII,
|
|
163
|
+
label: 'SvID'
|
|
164
|
+
},
|
|
165
|
+
dataSet: {
|
|
166
|
+
type: 'string',
|
|
167
|
+
contentEncoding: StringContentEncodingEnum.ASCII,
|
|
168
|
+
label: 'DatSet'
|
|
169
|
+
},
|
|
170
|
+
smpCnt: {
|
|
171
|
+
type: 'integer',
|
|
172
|
+
label: 'SmpCnt'
|
|
173
|
+
},
|
|
174
|
+
confRev: {
|
|
175
|
+
type: 'integer',
|
|
176
|
+
label: 'ConfRev'
|
|
177
|
+
},
|
|
178
|
+
refrTm: {
|
|
179
|
+
type: 'string',
|
|
180
|
+
contentEncoding: StringContentEncodingEnum.BIGINT,
|
|
181
|
+
label: 'RefrTm'
|
|
182
|
+
},
|
|
183
|
+
smpSynch: {
|
|
184
|
+
type: 'integer',
|
|
185
|
+
label: 'SmpSynch'
|
|
186
|
+
},
|
|
187
|
+
smpRate: {
|
|
188
|
+
type: 'integer',
|
|
189
|
+
label: 'SmpRate'
|
|
190
|
+
},
|
|
191
|
+
sample: {
|
|
192
|
+
type: 'string',
|
|
193
|
+
contentEncoding: StringContentEncodingEnum.HEX,
|
|
194
|
+
label: 'Sample'
|
|
195
|
+
},
|
|
196
|
+
smpMod: {
|
|
197
|
+
type: 'integer',
|
|
198
|
+
label: 'SmpMod'
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
decode: (): void => {
|
|
203
|
+
const seqASDU: ASDUItem[] = []
|
|
204
|
+
const seqASDUTLV: TLV | undefined = this.TLVChild.find(tlv => tlv.getTag('number') === 0xa2)
|
|
205
|
+
if (!seqASDUTLV) {
|
|
206
|
+
this.instance.svPdu.seqASDU.setValue(seqASDU)
|
|
207
|
+
return
|
|
208
|
+
}
|
|
209
|
+
const ASDUTLVs: TLV[] = seqASDUTLV.getChild()
|
|
210
|
+
ASDUTLVs.forEach((ASDUTLV: TLV, index: number): void => {
|
|
211
|
+
const errorNodePath: string = this.instance.svPdu.seqASDU.getPath(index)
|
|
212
|
+
if (ASDUTLV.getTag('number') !== 0x30) this.recordError(errorNodePath, 'Invalid ASDU item tag')
|
|
213
|
+
const ASDUAttributeTLVs: TLV[] = ASDUTLV.getChild()
|
|
214
|
+
let svID: string
|
|
215
|
+
let dataSet: string
|
|
216
|
+
let smpCnt: number
|
|
217
|
+
let confRev: number
|
|
218
|
+
let refrTm: string
|
|
219
|
+
let smpSynch: number
|
|
220
|
+
let smpRate: number
|
|
221
|
+
let sample: string
|
|
222
|
+
let smpMod: number
|
|
223
|
+
//svID
|
|
224
|
+
const svIDTLV: TLV | undefined = ASDUAttributeTLVs.find(tlv => tlv.getTag('number') === 0x80)
|
|
225
|
+
if (svIDTLV) {
|
|
226
|
+
svID = svIDTLV.getValue('buffer').toString('ascii')
|
|
227
|
+
} else {
|
|
228
|
+
this.recordError(errorNodePath, 'svID Not Found')
|
|
229
|
+
}
|
|
230
|
+
//dataSet (optional)
|
|
231
|
+
const dataSetTLV: TLV | undefined = ASDUAttributeTLVs.find(tlv => tlv.getTag('number') === 0x81)
|
|
232
|
+
if (dataSetTLV) {
|
|
233
|
+
dataSet = dataSetTLV.getValue('buffer').toString('ascii')
|
|
234
|
+
}
|
|
235
|
+
//smpCnt
|
|
236
|
+
const smpCntTLV: TLV | undefined = ASDUAttributeTLVs.find(tlv => tlv.getTag('number') === 0x82)
|
|
237
|
+
if (smpCntTLV) {
|
|
238
|
+
smpCnt = BufferToUInt16(smpCntTLV.getValue('buffer'))
|
|
239
|
+
} else {
|
|
240
|
+
this.recordError(errorNodePath, 'smpCnt Not Found')
|
|
241
|
+
}
|
|
242
|
+
//confRev
|
|
243
|
+
const confRevTLV: TLV | undefined = ASDUAttributeTLVs.find(tlv => tlv.getTag('number') === 0x83)
|
|
244
|
+
if (confRevTLV) {
|
|
245
|
+
confRev = BufferToUInt32(confRevTLV.getValue('buffer'))
|
|
246
|
+
} else {
|
|
247
|
+
this.recordError(errorNodePath, 'confRev Not Found')
|
|
248
|
+
}
|
|
249
|
+
//refrTm (optional)
|
|
250
|
+
const refrTmTLV: TLV | undefined = ASDUAttributeTLVs.find(tlv => tlv.getTag('number') === 0x84)
|
|
251
|
+
if (refrTmTLV) {
|
|
252
|
+
refrTm = BufferToUInt64(refrTmTLV.getValue('buffer')).toString()
|
|
253
|
+
}
|
|
254
|
+
//smpSynch
|
|
255
|
+
const smpSynchTLV: TLV | undefined = ASDUAttributeTLVs.find(tlv => tlv.getTag('number') === 0x85)
|
|
256
|
+
if (smpSynchTLV) {
|
|
257
|
+
smpSynch = BufferToUInt8(smpSynchTLV.getValue('buffer'))
|
|
258
|
+
} else {
|
|
259
|
+
this.recordError(errorNodePath, 'smpSynch Not Found')
|
|
260
|
+
}
|
|
261
|
+
//smpRate (optional)
|
|
262
|
+
const smpRateTLV: TLV | undefined = ASDUAttributeTLVs.find(tlv => tlv.getTag('number') === 0x86)
|
|
263
|
+
if (smpRateTLV) {
|
|
264
|
+
smpRate = BufferToUInt16(smpRateTLV.getValue('buffer'))
|
|
265
|
+
}
|
|
266
|
+
//sample
|
|
267
|
+
const sampleTLV: TLV | undefined = ASDUAttributeTLVs.find(tlv => tlv.getTag('number') === 0x87)
|
|
268
|
+
if (sampleTLV) {
|
|
269
|
+
sample = sampleTLV.getValue('hex')
|
|
270
|
+
} else {
|
|
271
|
+
this.recordError(errorNodePath, 'sample Not Found')
|
|
272
|
+
}
|
|
273
|
+
//smpMod (optional)
|
|
274
|
+
const smpModTLV: TLV | undefined = ASDUAttributeTLVs.find(tlv => tlv.getTag('number') === 0x86)
|
|
275
|
+
if (smpModTLV) {
|
|
276
|
+
smpMod = BufferToUInt16(smpModTLV.getValue('buffer'))
|
|
277
|
+
}
|
|
278
|
+
seqASDU.push({
|
|
279
|
+
svID: svID!,
|
|
280
|
+
dataSet: dataSet!,
|
|
281
|
+
smpCnt: smpCnt!,
|
|
282
|
+
confRev: confRev!,
|
|
283
|
+
refrTm: refrTm!,
|
|
284
|
+
smpSynch: smpSynch!,
|
|
285
|
+
smpRate: smpRate!,
|
|
286
|
+
sample: sample!,
|
|
287
|
+
smpMod: smpMod!
|
|
288
|
+
})
|
|
289
|
+
})
|
|
290
|
+
this.instance.svPdu.seqASDU.setValue(seqASDU)
|
|
291
|
+
},
|
|
292
|
+
encode: (): void => {
|
|
293
|
+
const seqASDU: ASDUItem[] = this.instance.svPdu.seqASDU.isUndefined() ? [] : this.instance.svPdu.seqASDU.getValue()
|
|
294
|
+
const seqASDUTLVs: TLV[] = []
|
|
295
|
+
seqASDU.forEach((seqASDUItem: ASDUItem, index: number): void => {
|
|
296
|
+
const errorNodePath: string = this.instance.svPdu.seqASDU.getPath(index)
|
|
297
|
+
const seqASDUItemTLVs: TLV[] = []
|
|
298
|
+
//svID
|
|
299
|
+
if (seqASDUItem.svID !== undefined) {
|
|
300
|
+
seqASDUItemTLVs.push(new TLV(0x80, Buffer.from(seqASDUItem.svID ? seqASDUItem.svID : '', 'ascii')))
|
|
301
|
+
} else {
|
|
302
|
+
this.recordError(errorNodePath, 'No svID')
|
|
303
|
+
}
|
|
304
|
+
//dataSet
|
|
305
|
+
if (seqASDUItem.dataSet !== undefined) seqASDUItemTLVs.push(new TLV(0x81, Buffer.from(seqASDUItem.dataSet ? seqASDUItem.dataSet : '', 'ascii')))
|
|
306
|
+
// smpCnt
|
|
307
|
+
if (seqASDUItem.smpCnt !== undefined) {
|
|
308
|
+
seqASDUItemTLVs.push(new TLV(0x82, UInt16ToHex(seqASDUItem.smpCnt)))
|
|
309
|
+
} else {
|
|
310
|
+
this.recordError(errorNodePath, 'No smpCnt')
|
|
311
|
+
}
|
|
312
|
+
// confRev
|
|
313
|
+
if (seqASDUItem.confRev !== undefined) {
|
|
314
|
+
seqASDUItemTLVs.push(new TLV(0x83, UInt32ToHex(seqASDUItem.confRev)))
|
|
315
|
+
} else {
|
|
316
|
+
this.recordError(errorNodePath, 'No confRev')
|
|
317
|
+
}
|
|
318
|
+
// refrTm
|
|
319
|
+
if (seqASDUItem.refrTm !== undefined) seqASDUItemTLVs.push(new TLV(0x84, Buffer.from(BigInt(seqASDUItem.refrTm).toString(16).padStart(8 * 2, '0'), 'hex')))
|
|
320
|
+
// smpSynch
|
|
321
|
+
if (seqASDUItem.smpSynch !== undefined) {
|
|
322
|
+
seqASDUItemTLVs.push(new TLV(0x85, UInt8ToHex(seqASDUItem.smpSynch)))
|
|
323
|
+
} else {
|
|
324
|
+
this.recordError(errorNodePath, 'No smpSynch')
|
|
325
|
+
}
|
|
326
|
+
// smpRate
|
|
327
|
+
if (seqASDUItem.smpRate !== undefined) seqASDUItemTLVs.push(new TLV(0x86, UInt16ToHex(seqASDUItem.smpRate)))
|
|
328
|
+
// sample
|
|
329
|
+
if (seqASDUItem.sample !== undefined) {
|
|
330
|
+
seqASDUItemTLVs.push(new TLV(0x87, Buffer.from(seqASDUItem.sample, 'hex')))
|
|
331
|
+
} else {
|
|
332
|
+
this.recordError(errorNodePath, 'No sample')
|
|
333
|
+
}
|
|
334
|
+
// smpMod
|
|
335
|
+
if (seqASDUItem.smpMod !== undefined) seqASDUItemTLVs.push(new TLV(0x88, UInt16ToHex(seqASDUItem.smpMod)))
|
|
336
|
+
if (!seqASDUItemTLVs.length) return
|
|
337
|
+
let seqASDUItemBuffer: Buffer = Buffer.from([])
|
|
338
|
+
seqASDUItemTLVs.forEach(seqASDUItemTLV => seqASDUItemBuffer = Buffer.concat([seqASDUItemBuffer, seqASDUItemTLV.bTag, seqASDUItemTLV.bLength, seqASDUItemTLV.bValue]))
|
|
339
|
+
seqASDUTLVs.push(new TLV(0x30, seqASDUItemBuffer))
|
|
340
|
+
})
|
|
341
|
+
let seqASDUBuffer: Buffer = Buffer.from([])
|
|
342
|
+
seqASDUTLVs.forEach(seqASDUTLV => seqASDUBuffer = Buffer.concat([seqASDUBuffer, seqASDUTLV.bTag, seqASDUTLV.bLength, seqASDUTLV.bValue]))
|
|
343
|
+
this.TLVChild.push(new TLV(0xa2, seqASDUBuffer))
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
public id: string = 'sv'
|
|
352
|
+
|
|
353
|
+
public name: string = 'IEC61850 Sampled Values'
|
|
354
|
+
|
|
355
|
+
public match(): boolean {
|
|
356
|
+
if (!this.prevCodecModule) return false
|
|
357
|
+
return this.prevCodecModule.instance.etherType.getValue() === UInt16ToHex(0x88ba)
|
|
358
|
+
}
|
|
359
|
+
}
|