netkitty 0.0.35 → 1.1.0
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/CHANGELOG.md +31 -0
- package/README.md +91 -2
- package/README.zh-CN.md +89 -0
- package/dist/analysis.d.ts +4 -0
- package/dist/{CodecHeaderExports.js → analysis.js} +4 -1
- package/dist/capture.d.ts +5 -0
- package/dist/capture.js +21 -0
- package/dist/codec.d.ts +5 -0
- package/dist/codec.js +21 -0
- package/dist/iface.d.ts +4 -0
- package/dist/iface.js +20 -0
- package/dist/pcap.d.ts +10 -0
- package/dist/pcap.js +27 -0
- package/dist/replay.d.ts +5 -0
- package/dist/replay.js +21 -0
- package/package.json +65 -59
- package/.eslintrc.json +0 -53
- package/.idea/codeStyles/Project.xml +0 -18
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/inspectionProfiles/Project_Default.xml +0 -11
- package/.idea/modules.xml +0 -8
- package/.idea/netkitty.iml +0 -12
- package/.idea/vcs.xml +0 -6
- package/assets/NetKitty.png +0 -0
- package/binding.gyp +0 -5
- package/cpp/nodepcap/deps/include/Packet32.h +0 -429
- package/cpp/nodepcap/deps/include/pcap/bluetooth.h +0 -56
- package/cpp/nodepcap/deps/include/pcap/bpf.h +0 -292
- package/cpp/nodepcap/deps/include/pcap/can_socketcan.h +0 -56
- package/cpp/nodepcap/deps/include/pcap/compiler-tests.h +0 -163
- package/cpp/nodepcap/deps/include/pcap/dlt.h +0 -1514
- package/cpp/nodepcap/deps/include/pcap/funcattrs.h +0 -325
- package/cpp/nodepcap/deps/include/pcap/ipnet.h +0 -43
- package/cpp/nodepcap/deps/include/pcap/namedb.h +0 -84
- package/cpp/nodepcap/deps/include/pcap/nflog.h +0 -94
- package/cpp/nodepcap/deps/include/pcap/pcap-inttypes.h +0 -101
- package/cpp/nodepcap/deps/include/pcap/pcap.h +0 -1219
- package/cpp/nodepcap/deps/include/pcap/sll.h +0 -149
- package/cpp/nodepcap/deps/include/pcap/socket.h +0 -84
- package/cpp/nodepcap/deps/include/pcap/usb.h +0 -143
- package/cpp/nodepcap/deps/include/pcap/vlan.h +0 -46
- package/cpp/nodepcap/deps/include/pcap-bpf.h +0 -45
- package/cpp/nodepcap/deps/include/pcap-namedb.h +0 -40
- package/cpp/nodepcap/deps/include/pcap.h +0 -43
- 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 +0 -104
- package/cpp/nodepcap/src/binding.cc +0 -14
- package/cpp/nodepcap/src/capture.cc +0 -400
- package/cpp/nodepcap/src/capture.h +0 -53
- package/cpp/nodepcap/src/utils.cc +0 -218
- package/cpp/nodepcap/src/utils.h +0 -13
- package/dist/CodecExports.d.ts +0 -34
- package/dist/CodecExports.d.ts.map +0 -1
- package/dist/CodecExports.js +0 -23
- package/dist/CodecHeaderExports.d.ts +0 -2
- package/dist/CodecHeaderExports.d.ts.map +0 -1
- package/dist/HelperExports.d.ts +0 -11
- package/dist/HelperExports.d.ts.map +0 -1
- package/dist/HelperExports.js +0 -72
- package/dist/NetworkExports.d.ts +0 -13
- package/dist/NetworkExports.d.ts.map +0 -1
- package/dist/NetworkExports.js +0 -13
- package/dist/PcapExports.d.ts +0 -30
- package/dist/PcapExports.d.ts.map +0 -1
- package/dist/PcapExports.js +0 -33
- 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 -32
- package/dist/lib/codec/Codec.d.ts.map +0 -1
- package/dist/lib/codec/Codec.js +0 -183
- package/dist/lib/codec/PacketHeaders.d.ts +0 -22
- package/dist/lib/codec/PacketHeaders.d.ts.map +0 -1
- package/dist/lib/codec/PacketHeaders.js +0 -47
- 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 -104
- package/dist/lib/codec/headers/Goose.d.ts.map +0 -1
- package/dist/lib/codec/headers/Goose.js +0 -1005
- package/dist/lib/codec/headers/ICMP.d.ts +0 -15
- package/dist/lib/codec/headers/ICMP.d.ts.map +0 -1
- package/dist/lib/codec/headers/ICMP.js +0 -147
- package/dist/lib/codec/headers/ICMPv6.d.ts +0 -15
- package/dist/lib/codec/headers/ICMPv6.d.ts.map +0 -1
- package/dist/lib/codec/headers/ICMPv6.js +0 -128
- package/dist/lib/codec/headers/IEC104_I_Frame.d.ts +0 -10
- package/dist/lib/codec/headers/IEC104_I_Frame.d.ts.map +0 -1
- package/dist/lib/codec/headers/IEC104_I_Frame.js +0 -6411
- package/dist/lib/codec/headers/IEC104_S_Frame.d.ts +0 -10
- package/dist/lib/codec/headers/IEC104_S_Frame.d.ts.map +0 -1
- package/dist/lib/codec/headers/IEC104_S_Frame.js +0 -105
- package/dist/lib/codec/headers/IEC104_U_Frame.d.ts +0 -10
- package/dist/lib/codec/headers/IEC104_U_Frame.d.ts.map +0 -1
- package/dist/lib/codec/headers/IEC104_U_Frame.js +0 -155
- 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/IPv6.d.ts +0 -10
- package/dist/lib/codec/headers/IPv6.d.ts.map +0 -1
- package/dist/lib/codec/headers/IPv6.js +0 -177
- package/dist/lib/codec/headers/IPv6HopByHopOptions.d.ts +0 -71
- package/dist/lib/codec/headers/IPv6HopByHopOptions.d.ts.map +0 -1
- package/dist/lib/codec/headers/IPv6HopByHopOptions.js +0 -517
- 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 -917
- package/dist/lib/codec/headers/TLS_Alert.d.ts +0 -10
- package/dist/lib/codec/headers/TLS_Alert.d.ts.map +0 -1
- package/dist/lib/codec/headers/TLS_Alert.js +0 -624
- package/dist/lib/codec/headers/TLS_ApplicationData.d.ts +0 -10
- package/dist/lib/codec/headers/TLS_ApplicationData.d.ts.map +0 -1
- package/dist/lib/codec/headers/TLS_ApplicationData.js +0 -155
- package/dist/lib/codec/headers/TLS_ChangeCipherSpec.d.ts +0 -10
- package/dist/lib/codec/headers/TLS_ChangeCipherSpec.d.ts.map +0 -1
- package/dist/lib/codec/headers/TLS_ChangeCipherSpec.js +0 -154
- package/dist/lib/codec/headers/TLS_Handshake.d.ts +0 -10
- package/dist/lib/codec/headers/TLS_Handshake.d.ts.map +0 -1
- package/dist/lib/codec/headers/TLS_Handshake.js +0 -339
- package/dist/lib/codec/headers/TLS_Heartbeat.d.ts +0 -10
- package/dist/lib/codec/headers/TLS_Heartbeat.d.ts.map +0 -1
- package/dist/lib/codec/headers/TLS_Heartbeat.js +0 -206
- 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 -82
- 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/GetBERIntegerLengthFromBuffer.d.ts +0 -7
- package/dist/lib/codec/lib/GetBERIntegerLengthFromBuffer.d.ts.map +0 -1
- package/dist/lib/codec/lib/GetBERIntegerLengthFromBuffer.js +0 -16
- 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/helper/BufferToHex.d.ts +0 -2
- package/dist/lib/helper/BufferToHex.d.ts.map +0 -1
- package/dist/lib/helper/BufferToHex.js +0 -6
- package/dist/lib/helper/BufferToIP.d.ts +0 -13
- package/dist/lib/helper/BufferToIP.d.ts.map +0 -1
- package/dist/lib/helper/BufferToIP.js +0 -21
- package/dist/lib/helper/BufferToNumber.d.ts +0 -10
- package/dist/lib/helper/BufferToNumber.d.ts.map +0 -1
- package/dist/lib/helper/BufferToNumber.js +0 -22
- package/dist/lib/helper/HexToBuffer.d.ts +0 -8
- package/dist/lib/helper/HexToBuffer.d.ts.map +0 -1
- package/dist/lib/helper/HexToBuffer.js +0 -27
- package/dist/lib/helper/HexToNumber.d.ts +0 -10
- package/dist/lib/helper/HexToNumber.d.ts.map +0 -1
- package/dist/lib/helper/HexToNumber.js +0 -39
- package/dist/lib/helper/IPToBuffer.d.ts +0 -13
- package/dist/lib/helper/IPToBuffer.d.ts.map +0 -1
- package/dist/lib/helper/IPToBuffer.js +0 -28
- package/dist/lib/helper/NumberToBERBuffer.d.ts +0 -10
- package/dist/lib/helper/NumberToBERBuffer.d.ts.map +0 -1
- package/dist/lib/helper/NumberToBERBuffer.js +0 -22
- package/dist/lib/helper/NumberToBERHex.d.ts +0 -10
- package/dist/lib/helper/NumberToBERHex.d.ts.map +0 -1
- package/dist/lib/helper/NumberToBERHex.js +0 -27
- package/dist/lib/helper/NumberToBuffer.d.ts +0 -10
- package/dist/lib/helper/NumberToBuffer.d.ts.map +0 -1
- package/dist/lib/helper/NumberToBuffer.js +0 -22
- package/dist/lib/helper/NumberToHex.d.ts +0 -10
- package/dist/lib/helper/NumberToHex.d.ts.map +0 -1
- package/dist/lib/helper/NumberToHex.js +0 -26
- package/dist/lib/nodepcap/Capture.d.ts +0 -81
- package/dist/lib/nodepcap/Capture.d.ts.map +0 -1
- package/dist/lib/nodepcap/Capture.js +0 -323
- 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 -23
- 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 -101
- 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 -112
- package/dist/lib/pcap/PcapReader.d.ts.map +0 -1
- package/dist/lib/pcap/PcapReader.js +0 -263
- 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 -86
- 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 -36
- 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 -32
- 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 -86
- 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/CodecExports.ts +0 -33
- package/src/CodecHeaderExports.ts +0 -1
- package/src/HelperExports.ts +0 -78
- package/src/NetworkExports.ts +0 -12
- package/src/PcapExports.ts +0 -32
- package/src/errors/ActionNotFoundError.ts +0 -6
- package/src/errors/CodecSchemaValidateError.ts +0 -6
- package/src/errors/DeviceNotFoundError.ts +0 -6
- package/src/errors/NoAvailableCodecError.ts +0 -6
- package/src/errors/NpcapLoadError.ts +0 -6
- package/src/errors/SocketDownError.ts +0 -6
- package/src/errors/UnknownPipeMessageTypeError.ts +0 -6
- package/src/errors/common/ErrorCode.ts +0 -30
- package/src/lib/GeneratePipeAddress.ts +0 -17
- package/src/lib/GetBinding.ts +0 -3
- package/src/lib/GetCaptureTemporaryDirectory.ts +0 -12
- package/src/lib/GetDeviceCaptureTemporaryFilename.ts +0 -13
- package/src/lib/codec/Codec.ts +0 -164
- package/src/lib/codec/PacketHeaders.ts +0 -23
- package/src/lib/codec/abstracts/BaseHeader.ts +0 -435
- package/src/lib/codec/headers/ARP.ts +0 -220
- package/src/lib/codec/headers/EthernetII.ts +0 -79
- package/src/lib/codec/headers/Goose.ts +0 -1033
- package/src/lib/codec/headers/ICMP.ts +0 -151
- package/src/lib/codec/headers/ICMPv6.ts +0 -128
- package/src/lib/codec/headers/IEC104_I_Frame.ts +0 -7373
- package/src/lib/codec/headers/IEC104_S_Frame.ts +0 -97
- package/src/lib/codec/headers/IEC104_U_Frame.ts +0 -139
- package/src/lib/codec/headers/IEC61850SampledValues.ts +0 -361
- package/src/lib/codec/headers/IPv4.ts +0 -331
- package/src/lib/codec/headers/IPv6.ts +0 -176
- package/src/lib/codec/headers/IPv6HopByHopOptions.ts +0 -552
- package/src/lib/codec/headers/RawData.ts +0 -38
- package/src/lib/codec/headers/TCP.ts +0 -952
- package/src/lib/codec/headers/TLS_Alert.ts +0 -539
- package/src/lib/codec/headers/TLS_ApplicationData.ts +0 -145
- package/src/lib/codec/headers/TLS_ChangeCipherSpec.ts +0 -146
- package/src/lib/codec/headers/TLS_Handshake.ts +0 -313
- package/src/lib/codec/headers/TLS_Heartbeat.ts +0 -188
- package/src/lib/codec/headers/UDP.ts +0 -182
- package/src/lib/codec/headers/VLAN_802dot1Q.ts +0 -79
- package/src/lib/codec/lib/FlexibleObject.ts +0 -100
- package/src/lib/codec/lib/GetBERIntegerLengthFromBuffer.ts +0 -12
- package/src/lib/codec/lib/ProcessPacketPostHandlers.ts +0 -53
- package/src/lib/codec/lib/SortPostHandlers.ts +0 -10
- package/src/lib/codec/lib/StringContentEncodingEnum.ts +0 -10
- package/src/lib/codec/types/CodecData.ts +0 -7
- package/src/lib/codec/types/CodecDecodeResult.ts +0 -11
- package/src/lib/codec/types/CodecEncodeInput.ts +0 -9
- package/src/lib/codec/types/CodecEncodeResult.ts +0 -6
- package/src/lib/codec/types/CodecErrorInfo.ts +0 -5
- package/src/lib/codec/types/CodecModule.ts +0 -3
- package/src/lib/codec/types/CodecModuleConstructor.ts +0 -3
- package/src/lib/codec/types/CodecSchema.ts +0 -7
- package/src/lib/codec/types/HeaderTreeNode.ts +0 -5
- package/src/lib/codec/types/PostHandlerItem.ts +0 -4
- package/src/lib/helper/BufferToHex.ts +0 -3
- package/src/lib/helper/BufferToIP.ts +0 -19
- package/src/lib/helper/BufferToNumber.ts +0 -31
- package/src/lib/helper/HexToBuffer.ts +0 -22
- package/src/lib/helper/HexToNumber.ts +0 -25
- package/src/lib/helper/IPToBuffer.ts +0 -25
- package/src/lib/helper/NumberToBERBuffer.ts +0 -21
- package/src/lib/helper/NumberToBERHex.ts +0 -17
- package/src/lib/helper/NumberToBuffer.ts +0 -21
- package/src/lib/helper/NumberToHex.ts +0 -15
- package/src/lib/nodepcap/Capture.ts +0 -304
- package/src/lib/nodepcap/GetNetworkInterfaces.ts +0 -18
- package/src/lib/nodepcap/interfaces/IBindingCapture.ts +0 -27
- package/src/lib/nodepcap/interfaces/IBindingCaptureOptions.ts +0 -4
- package/src/lib/nodepcap/interfaces/ICaptureOptions.ts +0 -24
- package/src/lib/nodepcap/interfaces/INetworkInterface.ts +0 -4
- package/src/lib/nodepcap/lib/BindingCapture.ts +0 -46
- package/src/lib/nodepcap/lib/GetNodePcapBinding.ts +0 -17
- package/src/lib/nodepcap/lib/GetNodePcapBindingCapture.ts +0 -15
- package/src/lib/nodepcap/workers/CaptureWorker.ts +0 -30
- package/src/lib/pcap/PCAPGenerator.ts +0 -123
- package/src/lib/pcap/PcapParser.ts +0 -170
- package/src/lib/pcap/PcapReader.ts +0 -306
- package/src/lib/pcap/PcapWriter.ts +0 -98
- package/src/lib/pcap/interfaces/IPcapPacketInfo.ts +0 -12
- package/src/lib/pipe/PipeClient.ts +0 -91
- package/src/lib/pipe/PipeClientSocket.ts +0 -99
- package/src/lib/pipe/PipeMessage.ts +0 -74
- package/src/lib/pipe/PipeMessageHandler.ts +0 -91
- package/src/lib/pipe/PipeServer.ts +0 -74
- package/src/lib/schema/ProtocolFieldJSONSchema.ts +0 -47
- package/src/lib/schema/ProtocolFieldJSONSchemaDefinition.ts +0 -3
- package/src/lib/schema/ProtocolJSONSchema.ts +0 -37
- package/src/tests/Test.spec.ts +0 -22
- package/src/tests/units/CaptureTest.spec.ts +0 -31
- package/src/tests/units/Codec.spec.ts +0 -102
- package/src/tests/units/ReadPCAP.spec.ts +0 -13
- package/test.pcap +0 -0
- package/tsconfig.json +0 -42
|
@@ -1,356 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseHeader = void 0;
|
|
4
|
-
const SortPostHandlers_1 = require("../lib/SortPostHandlers");
|
|
5
|
-
const FlexibleObject_1 = require("../lib/FlexibleObject");
|
|
6
|
-
const ajv_1 = require("ajv");
|
|
7
|
-
const CodecSchemaValidateError_1 = require("../../../errors/CodecSchemaValidateError");
|
|
8
|
-
const CONSTRUCTOR_VALIDATE_KEY = '__validate';
|
|
9
|
-
class BaseHeader {
|
|
10
|
-
static get CODEC_INSTANCE() {
|
|
11
|
-
return new this();
|
|
12
|
-
}
|
|
13
|
-
static CREATE_CODEC_INSTANCE_WITCH_CODEC_MODULES(codecData, codecModules) {
|
|
14
|
-
return this.CREATE_INSTANCE(codecData, codecModules);
|
|
15
|
-
}
|
|
16
|
-
static get PROTOCOL_ID() {
|
|
17
|
-
return this.CODEC_INSTANCE.id;
|
|
18
|
-
}
|
|
19
|
-
static get PROTOCOL_NAME() {
|
|
20
|
-
return this.CODEC_INSTANCE.name;
|
|
21
|
-
}
|
|
22
|
-
static get PROTOCOL_SCHEMA() {
|
|
23
|
-
const schema = JSON.parse(JSON.stringify(this.CODEC_INSTANCE.SCHEMA));
|
|
24
|
-
if (!Object.hasOwn(this, CONSTRUCTOR_VALIDATE_KEY)) {
|
|
25
|
-
const validate = new ajv_1.Ajv({
|
|
26
|
-
strict: false,
|
|
27
|
-
useDefaults: true,
|
|
28
|
-
coerceTypes: true
|
|
29
|
-
}).compile(schema);
|
|
30
|
-
Object.defineProperty(this, CONSTRUCTOR_VALIDATE_KEY, {
|
|
31
|
-
enumerable: false,
|
|
32
|
-
configurable: false,
|
|
33
|
-
value: validate
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return schema;
|
|
37
|
-
}
|
|
38
|
-
static MATCH(codecData, codecModules) {
|
|
39
|
-
return this.CREATE_CODEC_INSTANCE_WITCH_CODEC_MODULES(codecData, codecModules ? codecModules : []).match();
|
|
40
|
-
}
|
|
41
|
-
static CREATE_INSTANCE(codecData, codecModules) {
|
|
42
|
-
return new this(codecData, codecModules);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Entire packet buffer data getter
|
|
46
|
-
*/
|
|
47
|
-
get packet() {
|
|
48
|
-
return this.codecData.packet;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Entire packet buffer data setter
|
|
52
|
-
* @param packet
|
|
53
|
-
*/
|
|
54
|
-
set packet(packet) {
|
|
55
|
-
this.codecData.packet = packet;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* The end position of this header in the entire packet's buffer
|
|
59
|
-
*/
|
|
60
|
-
get endPos() {
|
|
61
|
-
return this.startPos + this.headerLength;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Readonly Header length
|
|
65
|
-
*/
|
|
66
|
-
get length() {
|
|
67
|
-
return this.headerLength;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Post packet handlers
|
|
71
|
-
* @protected
|
|
72
|
-
*/
|
|
73
|
-
get postPacketHandlers() {
|
|
74
|
-
if (this.codecData.postHandlers[this.headerIndex] === undefined)
|
|
75
|
-
this.codecData.postHandlers[this.headerIndex] = [];
|
|
76
|
-
return this.codecData.postHandlers[this.headerIndex];
|
|
77
|
-
}
|
|
78
|
-
constructor(codecData, codecModules) {
|
|
79
|
-
/**
|
|
80
|
-
* Current header is a protocol or not
|
|
81
|
-
*/
|
|
82
|
-
this.isProtocol = true;
|
|
83
|
-
/**
|
|
84
|
-
* Encode/Decode error info objects
|
|
85
|
-
*/
|
|
86
|
-
this.errors = [];
|
|
87
|
-
/**
|
|
88
|
-
* Header schema instance
|
|
89
|
-
*/
|
|
90
|
-
this.instance = new FlexibleObject_1.FlexibleObject();
|
|
91
|
-
/**
|
|
92
|
-
* The start position of this header in the entire packet's buffer
|
|
93
|
-
*/
|
|
94
|
-
this.startPos = 0;
|
|
95
|
-
/**
|
|
96
|
-
* Header length
|
|
97
|
-
* @protected
|
|
98
|
-
*/
|
|
99
|
-
this.headerLength = 0;
|
|
100
|
-
/**
|
|
101
|
-
* Current header index in packet headers
|
|
102
|
-
* @protected
|
|
103
|
-
*/
|
|
104
|
-
this.headerIndex = 0;
|
|
105
|
-
/**
|
|
106
|
-
* Registered post encode handlers (CodecModule)
|
|
107
|
-
* @protected
|
|
108
|
-
*/
|
|
109
|
-
this.postSelfEncodeHandlers = [];
|
|
110
|
-
/**
|
|
111
|
-
* Registered post decode handlers (CodecModule)
|
|
112
|
-
* @protected
|
|
113
|
-
*/
|
|
114
|
-
this.postSelfDecodeHandlers = [];
|
|
115
|
-
this.codecData = codecData;
|
|
116
|
-
this.startPos = codecData?.startPos ? codecData.startPos : 0;
|
|
117
|
-
codecModules = codecModules ? codecModules : [];
|
|
118
|
-
this.codecModules = codecModules;
|
|
119
|
-
this.prevCodecModules = [...codecModules];
|
|
120
|
-
const prevCodecModuleIndex = this.prevCodecModules.length - 1;
|
|
121
|
-
this.prevCodecModule = this.prevCodecModules[prevCodecModuleIndex > -1 ? prevCodecModuleIndex : 0];
|
|
122
|
-
this.headerIndex = this.prevCodecModules.length;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Get packet data offset
|
|
126
|
-
* @param offset
|
|
127
|
-
* @protected
|
|
128
|
-
*/
|
|
129
|
-
getPacketOffset(offset) {
|
|
130
|
-
return this.startPos + offset;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Internal read bytes from buffer
|
|
134
|
-
* @param offset
|
|
135
|
-
* @param length
|
|
136
|
-
* @param expandBufferLength
|
|
137
|
-
* @param changeHeaderLength
|
|
138
|
-
* @private
|
|
139
|
-
*/
|
|
140
|
-
#readBytes(offset, length, expandBufferLength, changeHeaderLength) {
|
|
141
|
-
const packetOffset = this.getPacketOffset(offset);
|
|
142
|
-
let readEndPos = packetOffset + length;
|
|
143
|
-
if (this.packet.length < readEndPos) {
|
|
144
|
-
if (expandBufferLength) {
|
|
145
|
-
this.packet = Buffer.concat([this.packet, Buffer.alloc(readEndPos - this.packet.length, 0)]);
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
readEndPos = this.packet.length;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
const headerLength = readEndPos - this.startPos;
|
|
152
|
-
if (changeHeaderLength)
|
|
153
|
-
this.headerLength = this.headerLength < headerLength ? headerLength : this.headerLength;
|
|
154
|
-
return this.packet.subarray(packetOffset, packetOffset + length);
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Read bytes from buffer
|
|
158
|
-
* @param offset
|
|
159
|
-
* @param length
|
|
160
|
-
* @param dryRun
|
|
161
|
-
* @protected
|
|
162
|
-
*/
|
|
163
|
-
readBytes(offset, length, dryRun = false) {
|
|
164
|
-
return this.#readBytes(offset, length, false, !dryRun);
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Write bytes to buffer
|
|
168
|
-
* @param offset
|
|
169
|
-
* @param buffer
|
|
170
|
-
* @protected
|
|
171
|
-
*/
|
|
172
|
-
writeBytes(offset, buffer) {
|
|
173
|
-
const packetOffset = this.getPacketOffset(offset);
|
|
174
|
-
const writeEndPos = packetOffset + buffer.length;
|
|
175
|
-
this.#readBytes(offset, buffer.length, true, true);
|
|
176
|
-
this.packet.fill(buffer, packetOffset, writeEndPos);
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Read bits from buffer
|
|
180
|
-
* @param offset
|
|
181
|
-
* @param length
|
|
182
|
-
* @param bitOffset
|
|
183
|
-
* @param bitLength
|
|
184
|
-
* @protected
|
|
185
|
-
*/
|
|
186
|
-
readBits(offset, length, bitOffset, bitLength) {
|
|
187
|
-
const buffer = this.#readBytes(offset, length, false, true);
|
|
188
|
-
const bitString = parseInt(buffer.toString('hex'), 16).toString(2).padStart(length * 8, '0');
|
|
189
|
-
return parseInt(bitString.substring(bitOffset, bitOffset + bitLength), 2);
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Write bits to buffer
|
|
193
|
-
* @param offset
|
|
194
|
-
* @param length
|
|
195
|
-
* @param bitOffset
|
|
196
|
-
* @param bitLength
|
|
197
|
-
* @param value
|
|
198
|
-
* @protected
|
|
199
|
-
*/
|
|
200
|
-
writeBits(offset, length, bitOffset, bitLength, value) {
|
|
201
|
-
const buffer = this.#readBytes(offset, length, true, true);
|
|
202
|
-
let bitArray = Array.from(parseInt(buffer.toString('hex'), 16).toString(2).padStart(buffer.length * 8, '0'));
|
|
203
|
-
const valueBitArray = Array.from(value.toString(2).padStart(bitLength, '0'));
|
|
204
|
-
bitArray = bitArray.map((bit, index) => {
|
|
205
|
-
if (index < bitOffset)
|
|
206
|
-
return bit;
|
|
207
|
-
if (index >= (bitOffset + bitLength))
|
|
208
|
-
return bit;
|
|
209
|
-
return valueBitArray[index - bitOffset];
|
|
210
|
-
});
|
|
211
|
-
this.writeBytes(offset, Buffer.from(parseInt(bitArray.join(''), 2).toString(16).padStart(buffer.length * 2, '0'), 'hex'));
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Get field codecs from schema tree
|
|
215
|
-
* @param schema
|
|
216
|
-
* @param codecName
|
|
217
|
-
* @param execBeforeSubCodecs
|
|
218
|
-
* @param codecs
|
|
219
|
-
* @protected
|
|
220
|
-
*/
|
|
221
|
-
getFieldCodecs(schema, codecName, execBeforeSubCodecs, codecs = []) {
|
|
222
|
-
if (!schema.properties)
|
|
223
|
-
return codecs;
|
|
224
|
-
for (const propertyName of Object.keys(schema.properties)) {
|
|
225
|
-
const fieldSchema = schema.properties[propertyName];
|
|
226
|
-
let codec = fieldSchema[codecName];
|
|
227
|
-
if (!codec)
|
|
228
|
-
codec = async () => (void (0));
|
|
229
|
-
if (execBeforeSubCodecs)
|
|
230
|
-
codecs.push(async () => await codec());
|
|
231
|
-
if (fieldSchema.properties)
|
|
232
|
-
this.getFieldCodecs(fieldSchema, codecName, execBeforeSubCodecs, codecs);
|
|
233
|
-
if (!execBeforeSubCodecs)
|
|
234
|
-
codecs.push(async () => await codec());
|
|
235
|
-
}
|
|
236
|
-
return codecs;
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Record encode/decode error
|
|
240
|
-
* @param path
|
|
241
|
-
* @param message
|
|
242
|
-
* @protected
|
|
243
|
-
*/
|
|
244
|
-
recordError(path, message) {
|
|
245
|
-
this.errors.push({
|
|
246
|
-
id: this.id,
|
|
247
|
-
path: path,
|
|
248
|
-
message: message
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Register post encode handler for current codec
|
|
253
|
-
* @param handler
|
|
254
|
-
* @param priority
|
|
255
|
-
* @protected
|
|
256
|
-
*/
|
|
257
|
-
addPostSelfEncodeHandler(handler, priority = 0) {
|
|
258
|
-
this.postSelfEncodeHandlers.push({
|
|
259
|
-
priority: priority,
|
|
260
|
-
handler: handler
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Register post decode handler for current codec
|
|
265
|
-
* @param handler
|
|
266
|
-
* @param priority
|
|
267
|
-
* @protected
|
|
268
|
-
*/
|
|
269
|
-
addPostSelfDecodeHandler(handler, priority = 0) {
|
|
270
|
-
this.postSelfDecodeHandlers.push({
|
|
271
|
-
priority: priority,
|
|
272
|
-
handler: handler
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Register post encode handler for packet
|
|
277
|
-
* @description Registered handler call sequence: LIFO (Last In First Out)
|
|
278
|
-
* @param handler
|
|
279
|
-
* @param priority
|
|
280
|
-
* @protected
|
|
281
|
-
*/
|
|
282
|
-
addPostPacketEncodeHandler(handler, priority = 0) {
|
|
283
|
-
this.postPacketHandlers.push({
|
|
284
|
-
priority: priority,
|
|
285
|
-
handler: handler
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Register post decode handler for packet
|
|
290
|
-
* @description Registered handler call sequence: FIFO (First In First Out)
|
|
291
|
-
* @param handler
|
|
292
|
-
* @param priority
|
|
293
|
-
* @protected
|
|
294
|
-
*/
|
|
295
|
-
addPostPacketDecodeHandler(handler, priority = 0) {
|
|
296
|
-
this.postPacketHandlers.push({
|
|
297
|
-
priority: priority,
|
|
298
|
-
handler: handler
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* Validate input json node is valid
|
|
303
|
-
* @param headerTreeNode
|
|
304
|
-
*/
|
|
305
|
-
validate(headerTreeNode) {
|
|
306
|
-
let validate = this.constructor[CONSTRUCTOR_VALIDATE_KEY];
|
|
307
|
-
if (!validate) {
|
|
308
|
-
validate = new ajv_1.Ajv({
|
|
309
|
-
strict: false,
|
|
310
|
-
useDefaults: true,
|
|
311
|
-
coerceTypes: true
|
|
312
|
-
}).compile(this.SCHEMA);
|
|
313
|
-
this.constructor[CONSTRUCTOR_VALIDATE_KEY] = validate;
|
|
314
|
-
}
|
|
315
|
-
const isValid = validate(headerTreeNode);
|
|
316
|
-
if (!isValid) {
|
|
317
|
-
let errorObject;
|
|
318
|
-
if (validate.errors)
|
|
319
|
-
errorObject = validate.errors[0];
|
|
320
|
-
const errorMessage = errorObject?.message ? errorObject.message : 'Unknown Error';
|
|
321
|
-
throw new CodecSchemaValidateError_1.CodecSchemaValidateError(errorMessage);
|
|
322
|
-
}
|
|
323
|
-
return headerTreeNode;
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* Decode packet header field by field
|
|
327
|
-
*/
|
|
328
|
-
async decode() {
|
|
329
|
-
const decodes = this.getFieldCodecs(this.SCHEMA, 'decode', true);
|
|
330
|
-
for (const decode of decodes) {
|
|
331
|
-
await decode();
|
|
332
|
-
}
|
|
333
|
-
const postSelfDecodeHandlers = (0, SortPostHandlers_1.SortPostHandlers)(this.postSelfDecodeHandlers);
|
|
334
|
-
let postDecodeHandler = postSelfDecodeHandlers.shift();
|
|
335
|
-
while (postDecodeHandler) {
|
|
336
|
-
await postDecodeHandler.handler();
|
|
337
|
-
postDecodeHandler = postSelfDecodeHandlers.shift();
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* Encode packet header field by field
|
|
342
|
-
*/
|
|
343
|
-
async encode() {
|
|
344
|
-
const encodes = this.getFieldCodecs(this.SCHEMA, 'encode', false);
|
|
345
|
-
for (const encode of encodes) {
|
|
346
|
-
await encode();
|
|
347
|
-
}
|
|
348
|
-
const postSelfEncodeHandlers = (0, SortPostHandlers_1.SortPostHandlers)(this.postSelfEncodeHandlers);
|
|
349
|
-
let postEncodeHandler = postSelfEncodeHandlers.shift();
|
|
350
|
-
while (postEncodeHandler) {
|
|
351
|
-
await postEncodeHandler.handler();
|
|
352
|
-
postEncodeHandler = postSelfEncodeHandlers.shift();
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
exports.BaseHeader = BaseHeader;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ProtocolJSONSchema } from '../../schema/ProtocolJSONSchema';
|
|
2
|
-
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
3
|
-
export declare class ARP extends BaseHeader {
|
|
4
|
-
SCHEMA: ProtocolJSONSchema;
|
|
5
|
-
readonly id: string;
|
|
6
|
-
readonly name: string;
|
|
7
|
-
readonly nickname: string;
|
|
8
|
-
match(): boolean;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=ARP.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ARP.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/headers/ARP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAUlD,qBAAa,GAAI,SAAQ,UAAU;IAExB,MAAM,EAAE,kBAAkB,CAiMhC;IAED,SAAgB,EAAE,EAAE,MAAM,CAAQ;IAElC,SAAgB,IAAI,EAAE,MAAM,CAAgC;IAE5D,SAAgB,QAAQ,EAAE,MAAM,CAAQ;IAEjC,KAAK,IAAI,OAAO;CAK1B"}
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ARP = void 0;
|
|
4
|
-
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
-
const NumberToHex_1 = require("../../helper/NumberToHex");
|
|
6
|
-
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
7
|
-
const HexToNumber_1 = require("../../helper/HexToNumber");
|
|
8
|
-
const BufferToNumber_1 = require("../../helper/BufferToNumber");
|
|
9
|
-
const BufferToHex_1 = require("../../helper/BufferToHex");
|
|
10
|
-
const NumberToBuffer_1 = require("../../helper/NumberToBuffer");
|
|
11
|
-
const BufferToIP_1 = require("../../helper/BufferToIP");
|
|
12
|
-
const IPToBuffer_1 = require("../../helper/IPToBuffer");
|
|
13
|
-
class ARP extends BaseHeader_1.BaseHeader {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(...arguments);
|
|
16
|
-
this.SCHEMA = {
|
|
17
|
-
type: 'object',
|
|
18
|
-
properties: {
|
|
19
|
-
hardware: {
|
|
20
|
-
type: 'object',
|
|
21
|
-
label: 'Hardware',
|
|
22
|
-
properties: {
|
|
23
|
-
type: {
|
|
24
|
-
type: 'number',
|
|
25
|
-
label: 'Type',
|
|
26
|
-
minimum: 0,
|
|
27
|
-
maximum: 65535,
|
|
28
|
-
decode: () => {
|
|
29
|
-
this.instance.hardware.type.setValue((0, BufferToNumber_1.BufferToInt16)(this.readBytes(0, 2)));
|
|
30
|
-
},
|
|
31
|
-
encode: () => {
|
|
32
|
-
let hwType = this.instance.hardware.type.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
33
|
-
if (hwType > 65535) {
|
|
34
|
-
this.recordError(this.instance.hardware.type.getPath(), 'Maximum value is 65535');
|
|
35
|
-
hwType = 65535;
|
|
36
|
-
}
|
|
37
|
-
if (hwType < 0) {
|
|
38
|
-
this.recordError(this.instance.hardware.type.getPath(), 'Minimum value is 0');
|
|
39
|
-
hwType = 0;
|
|
40
|
-
}
|
|
41
|
-
this.instance.hardware.type.setValue(hwType);
|
|
42
|
-
this.writeBytes(0, (0, NumberToBuffer_1.UInt16ToBuffer)(hwType));
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
size: {
|
|
46
|
-
type: 'number',
|
|
47
|
-
label: 'Size',
|
|
48
|
-
minimum: 0,
|
|
49
|
-
maximum: 255,
|
|
50
|
-
decode: () => {
|
|
51
|
-
this.instance.hardware.size.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(4, 1)));
|
|
52
|
-
},
|
|
53
|
-
encode: () => {
|
|
54
|
-
let hwSize = this.instance.hardware.size.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
55
|
-
if (hwSize > 255) {
|
|
56
|
-
this.recordError(this.instance.hardware.size.getPath(), 'Maximum value is 255');
|
|
57
|
-
hwSize = 255;
|
|
58
|
-
}
|
|
59
|
-
if (hwSize < 0) {
|
|
60
|
-
this.recordError(this.instance.hardware.size.getPath(), 'Minimum value is 0');
|
|
61
|
-
hwSize = 0;
|
|
62
|
-
}
|
|
63
|
-
this.instance.hardware.size.setValue(hwSize);
|
|
64
|
-
this.writeBytes(4, (0, NumberToBuffer_1.UInt8ToBuffer)(hwSize));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
protocol: {
|
|
70
|
-
type: 'object',
|
|
71
|
-
label: 'Protocol',
|
|
72
|
-
properties: {
|
|
73
|
-
type: {
|
|
74
|
-
type: 'string',
|
|
75
|
-
label: 'Type',
|
|
76
|
-
minLength: 4,
|
|
77
|
-
maxLength: 4,
|
|
78
|
-
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
79
|
-
decode: () => {
|
|
80
|
-
this.instance.protocol.type.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(2, 2)));
|
|
81
|
-
},
|
|
82
|
-
encode: () => {
|
|
83
|
-
let protoTypeHex = this.instance.protocol.type.getValue('0000', (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
84
|
-
let protoType = (0, HexToNumber_1.HexToUInt16)(protoTypeHex);
|
|
85
|
-
if (isNaN(protoType)) {
|
|
86
|
-
this.recordError(this.instance.protocol.type.getPath(), 'Invalid hex value');
|
|
87
|
-
protoType = 0;
|
|
88
|
-
}
|
|
89
|
-
this.instance.protocol.type.setValue(protoType);
|
|
90
|
-
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(protoType));
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
size: {
|
|
94
|
-
type: 'number',
|
|
95
|
-
label: 'Size',
|
|
96
|
-
minimum: 0,
|
|
97
|
-
maximum: 255,
|
|
98
|
-
decode: () => {
|
|
99
|
-
this.instance.protocol.size.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(5, 1)));
|
|
100
|
-
},
|
|
101
|
-
encode: () => {
|
|
102
|
-
let protoSize = this.instance.protocol.size.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
103
|
-
if (protoSize > 255) {
|
|
104
|
-
this.recordError(this.instance.protocol.size.getPath(), 'Maximum value is 255');
|
|
105
|
-
protoSize = 255;
|
|
106
|
-
}
|
|
107
|
-
if (protoSize < 0) {
|
|
108
|
-
this.recordError(this.instance.protocol.size.getPath(), 'Minimum value is 0');
|
|
109
|
-
protoSize = 0;
|
|
110
|
-
}
|
|
111
|
-
this.instance.protocol.size.setValue(protoSize);
|
|
112
|
-
this.writeBytes(5, (0, NumberToBuffer_1.UInt8ToBuffer)(protoSize));
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
opcode: {
|
|
118
|
-
type: 'number',
|
|
119
|
-
label: 'Opcode',
|
|
120
|
-
enum: [1, 2, 3, 4],
|
|
121
|
-
decode: () => {
|
|
122
|
-
this.instance.opcode.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(6, 2)));
|
|
123
|
-
if (![1, 2, 3, 4].includes(this.instance.opcode.getValue()))
|
|
124
|
-
this.recordError(this.instance.opcode.getPath(), 'Opcode should be 1, 2, 3 or 4');
|
|
125
|
-
},
|
|
126
|
-
encode: () => {
|
|
127
|
-
let opcode = this.instance.opcode.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
128
|
-
if (![1, 2, 3, 4].includes(opcode))
|
|
129
|
-
this.recordError(this.instance.opcode.getPath(), 'Opcode should be 1, 2, 3 or 4');
|
|
130
|
-
this.instance.opcode.setValue(opcode);
|
|
131
|
-
this.writeBytes(6, (0, NumberToBuffer_1.UInt16ToBuffer)(opcode));
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
sender: {
|
|
135
|
-
type: 'object',
|
|
136
|
-
label: 'Sender',
|
|
137
|
-
properties: {
|
|
138
|
-
mac: {
|
|
139
|
-
type: 'string',
|
|
140
|
-
label: 'MAC address',
|
|
141
|
-
minLength: 17,
|
|
142
|
-
maxLength: 17,
|
|
143
|
-
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.UTF8,
|
|
144
|
-
decode: () => {
|
|
145
|
-
const macAddrBuffer = Buffer.alloc(6, this.readBytes(8, 6));
|
|
146
|
-
this.instance.sender.mac.setValue(Array.from(macAddrBuffer).map((value) => (0, NumberToHex_1.UInt8ToHex)(value)).join(':'));
|
|
147
|
-
},
|
|
148
|
-
encode: () => {
|
|
149
|
-
let macStr = this.instance.sender.mac.getValue();
|
|
150
|
-
const rawMacBuffer = Buffer.from(macStr.split(':').map((value) => parseInt(value, 16)).map((value) => value ? value : 0));
|
|
151
|
-
if (rawMacBuffer.length !== 6)
|
|
152
|
-
this.recordError(this.instance.sender.mac.getPath(), 'Invalid MAC address length');
|
|
153
|
-
this.writeBytes(8, Buffer.alloc(6, rawMacBuffer));
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
ipv4: {
|
|
157
|
-
type: 'string',
|
|
158
|
-
label: 'IP address',
|
|
159
|
-
minLength: 7,
|
|
160
|
-
maxLength: 15,
|
|
161
|
-
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.UTF8,
|
|
162
|
-
decode: () => {
|
|
163
|
-
const ipv4Buffer = Buffer.alloc(4, this.readBytes(14, 4));
|
|
164
|
-
this.instance.sender.ipv4.setValue((0, BufferToIP_1.BufferToIPv4)(ipv4Buffer));
|
|
165
|
-
},
|
|
166
|
-
encode: () => {
|
|
167
|
-
let ipv4Str = this.instance.sender.ipv4.getValue();
|
|
168
|
-
this.writeBytes(14, (0, IPToBuffer_1.IPv4ToBuffer)(ipv4Str));
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
target: {
|
|
174
|
-
type: 'object',
|
|
175
|
-
label: 'Target',
|
|
176
|
-
properties: {
|
|
177
|
-
mac: {
|
|
178
|
-
type: 'string',
|
|
179
|
-
label: 'MAC address',
|
|
180
|
-
minLength: 17,
|
|
181
|
-
maxLength: 17,
|
|
182
|
-
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.UTF8,
|
|
183
|
-
decode: () => {
|
|
184
|
-
const macAddrBuffer = Buffer.alloc(6, this.readBytes(18, 6));
|
|
185
|
-
this.instance.target.mac.setValue(Array.from(macAddrBuffer).map((value) => (0, NumberToHex_1.UInt8ToHex)(value)).join(':'));
|
|
186
|
-
},
|
|
187
|
-
encode: () => {
|
|
188
|
-
let macStr = this.instance.target.mac.getValue();
|
|
189
|
-
const rawMacBuffer = Buffer.from(macStr.split(':').map((value) => parseInt(value, 16)).map((value) => value ? value : 0));
|
|
190
|
-
if (rawMacBuffer.length !== 6)
|
|
191
|
-
this.recordError(this.instance.target.mac.getPath(), 'Invalid MAC address length');
|
|
192
|
-
this.writeBytes(18, Buffer.alloc(6, rawMacBuffer));
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
ipv4: {
|
|
196
|
-
type: 'string',
|
|
197
|
-
label: 'IP address',
|
|
198
|
-
minLength: 7,
|
|
199
|
-
maxLength: 15,
|
|
200
|
-
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.UTF8,
|
|
201
|
-
decode: () => {
|
|
202
|
-
const ipv4Buffer = Buffer.alloc(4, this.readBytes(24, 4));
|
|
203
|
-
this.instance.target.ipv4.setValue((0, BufferToIP_1.BufferToIPv4)(ipv4Buffer));
|
|
204
|
-
},
|
|
205
|
-
encode: () => {
|
|
206
|
-
let ipv4Str = this.instance.target.ipv4.getValue();
|
|
207
|
-
this.writeBytes(24, (0, IPToBuffer_1.IPv4ToBuffer)(ipv4Str));
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
this.id = 'arp';
|
|
215
|
-
this.name = 'Address Resolution Protocol';
|
|
216
|
-
this.nickname = 'ARP';
|
|
217
|
-
}
|
|
218
|
-
match() {
|
|
219
|
-
if (!this.prevCodecModule)
|
|
220
|
-
return false;
|
|
221
|
-
return this.prevCodecModule.instance.etherType.getValue() === (0, NumberToHex_1.UInt16ToHex)(0x0806);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
exports.ARP = ARP;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
-
import { ProtocolJSONSchema } from '../../schema/ProtocolJSONSchema';
|
|
3
|
-
export declare class EthernetII extends BaseHeader {
|
|
4
|
-
readonly SCHEMA: ProtocolJSONSchema;
|
|
5
|
-
readonly id: string;
|
|
6
|
-
readonly name: string;
|
|
7
|
-
readonly nickname: string;
|
|
8
|
-
match(): boolean;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=EthernetII.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EthernetII.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/headers/EthernetII.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AAIlE,qBAAa,UAAW,SAAQ,UAAU;IAEtC,SAAgB,MAAM,EAAE,kBAAkB,CA0DzC;IAED,SAAgB,EAAE,EAAE,MAAM,CAAQ;IAElC,SAAgB,IAAI,EAAE,MAAM,CAAgB;IAE5C,SAAgB,QAAQ,EAAE,MAAM,CAAQ;IAEjC,KAAK,IAAI,OAAO;CAK1B"}
|