netkitty 0.0.34 → 1.0.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 +13 -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 -57
- 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 -975
- 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 -497
- 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 -899
- 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 -35
- package/dist/lib/schema/ProtocolFieldJSONSchema.d.ts.map +0 -1
- package/dist/lib/schema/ProtocolFieldJSONSchema.js +0 -2
- package/dist/lib/schema/ProtocolFieldJSONSchemaDefinition.d.ts +0 -3
- package/dist/lib/schema/ProtocolFieldJSONSchemaDefinition.d.ts.map +0 -1
- package/dist/lib/schema/ProtocolFieldJSONSchemaDefinition.js +0 -2
- package/dist/lib/schema/ProtocolJSONSchema.d.ts +0 -32
- package/dist/lib/schema/ProtocolJSONSchema.d.ts.map +0 -1
- package/dist/lib/schema/ProtocolJSONSchema.js +0 -2
- package/dist/tests/Test.spec.d.ts +0 -2
- package/dist/tests/Test.spec.d.ts.map +0 -1
- package/dist/tests/Test.spec.js +0 -25
- package/dist/tests/units/CaptureTest.spec.d.ts +0 -2
- package/dist/tests/units/CaptureTest.spec.d.ts.map +0 -1
- package/dist/tests/units/CaptureTest.spec.js +0 -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 -1003
- 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 -532
- package/src/lib/codec/headers/RawData.ts +0 -38
- package/src/lib/codec/headers/TCP.ts +0 -934
- 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 -45
- 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,331 +0,0 @@
|
|
|
1
|
-
import {ProtocolJSONSchema} from '../../schema/ProtocolJSONSchema'
|
|
2
|
-
import {BaseHeader} from '../abstracts/BaseHeader'
|
|
3
|
-
import {UInt16ToHex} from '../../helper/NumberToHex'
|
|
4
|
-
import {CodecModule} from '../types/CodecModule'
|
|
5
|
-
import {StringContentEncodingEnum} from '../lib/StringContentEncodingEnum'
|
|
6
|
-
import {BufferToUInt16, BufferToUInt8} from '../../helper/BufferToNumber'
|
|
7
|
-
import {UInt16ToBuffer, UInt8ToBuffer} from '../../helper/NumberToBuffer'
|
|
8
|
-
import {BufferToHex} from '../../helper/BufferToHex'
|
|
9
|
-
import {IPv4ToBuffer} from '../../helper/IPToBuffer'
|
|
10
|
-
import {BufferToIPv4} from '../../helper/BufferToIP'
|
|
11
|
-
import {HexToBuffer} from '../../helper/HexToBuffer'
|
|
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
|
-
const 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
|
-
const 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.IPv4,
|
|
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.IPv4,
|
|
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 = HexToBuffer(this.instance.options.getValue(''))
|
|
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 readonly id: string = 'ipv4'
|
|
322
|
-
|
|
323
|
-
public readonly name: string = 'Internet Protocol Version 4'
|
|
324
|
-
|
|
325
|
-
public readonly nickname: string = 'IPv4'
|
|
326
|
-
|
|
327
|
-
public match(): boolean {
|
|
328
|
-
if (!this.prevCodecModule) return false
|
|
329
|
-
return this.prevCodecModule.instance.etherType.getValue() === UInt16ToHex(0x0800)
|
|
330
|
-
}
|
|
331
|
-
}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import {ProtocolJSONSchema} from '../../schema/ProtocolJSONSchema'
|
|
2
|
-
import {BaseHeader} from '../abstracts/BaseHeader'
|
|
3
|
-
import {UInt16ToHex} from '../../helper/NumberToHex'
|
|
4
|
-
import {StringContentEncodingEnum} from '../lib/StringContentEncodingEnum'
|
|
5
|
-
import {BufferToUInt16, BufferToUInt8} from '../../helper/BufferToNumber'
|
|
6
|
-
import {UInt16ToBuffer, UInt8ToBuffer} from '../../helper/NumberToBuffer'
|
|
7
|
-
import {BufferToIPv6} from '../../helper/BufferToIP'
|
|
8
|
-
import {IPv6ToBuffer} from '../../helper/IPToBuffer'
|
|
9
|
-
import {CodecModule} from '../types/CodecModule'
|
|
10
|
-
|
|
11
|
-
export class IPv6 extends BaseHeader {
|
|
12
|
-
|
|
13
|
-
public SCHEMA: ProtocolJSONSchema = {
|
|
14
|
-
type: 'object',
|
|
15
|
-
properties: {
|
|
16
|
-
version: {
|
|
17
|
-
type: 'integer',
|
|
18
|
-
label: 'Version',
|
|
19
|
-
minimum: 0,
|
|
20
|
-
maximum: 15,
|
|
21
|
-
decode: (): void => {
|
|
22
|
-
this.instance.version.setValue(this.readBits(0, 1, 0, 4))
|
|
23
|
-
},
|
|
24
|
-
encode: (): void => {
|
|
25
|
-
const version: number = this.instance.version.getValue(6, (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
26
|
-
this.instance.version.setValue(version)
|
|
27
|
-
this.writeBits(0, 1, 0, 4, version)
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
tclass: {
|
|
31
|
-
type: 'object',
|
|
32
|
-
label: 'Traffic Class',
|
|
33
|
-
properties: {
|
|
34
|
-
dscp: {
|
|
35
|
-
type: 'integer',
|
|
36
|
-
minimum: 0,
|
|
37
|
-
maximum: 63,
|
|
38
|
-
label: 'Differentiated Services Codepoint',
|
|
39
|
-
decode: (): void => {
|
|
40
|
-
this.instance.tclass.dscp.setValue(this.readBits(0, 4, 4, 6))
|
|
41
|
-
},
|
|
42
|
-
encode: (): void => {
|
|
43
|
-
const dscp: number = this.instance.tclass.dscp.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
44
|
-
this.instance.tclass.dscp.setValue(dscp)
|
|
45
|
-
this.writeBits(0, 4, 4, 6, dscp)
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
ecn: {
|
|
49
|
-
type: 'integer',
|
|
50
|
-
label: 'Explicit Congestion Notification',
|
|
51
|
-
minimum: 0,
|
|
52
|
-
maximum: 3,
|
|
53
|
-
decode: (): void => {
|
|
54
|
-
this.instance.tclass.ecn.setValue(this.readBits(0, 4, 10, 2))
|
|
55
|
-
},
|
|
56
|
-
encode: (): void => {
|
|
57
|
-
const ecn: number = this.instance.tclass.ecn.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
58
|
-
this.instance.tclass.ecn.setValue(ecn)
|
|
59
|
-
this.writeBits(0, 4, 10, 2, ecn)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
flow: {
|
|
65
|
-
type: 'integer',
|
|
66
|
-
label: 'Flow Label',
|
|
67
|
-
minimum: 0,
|
|
68
|
-
maximum: 1048575,
|
|
69
|
-
decode: (): void => {
|
|
70
|
-
this.instance.flow.setValue(this.readBits(1, 3, 4, 20))
|
|
71
|
-
},
|
|
72
|
-
encode: (): void => {
|
|
73
|
-
const flow: number = this.instance.flow.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
74
|
-
this.instance.flow.setValue(flow)
|
|
75
|
-
this.writeBits(1, 3, 4, 20, flow)
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
plen: {
|
|
79
|
-
type: 'integer',
|
|
80
|
-
label: 'Payload Length',
|
|
81
|
-
minimum: 0,
|
|
82
|
-
maximum: 65535,
|
|
83
|
-
decode: (): void => {
|
|
84
|
-
this.instance.plen.setValue(BufferToUInt16(this.readBytes(4, 2)))
|
|
85
|
-
},
|
|
86
|
-
encode: (): void => {
|
|
87
|
-
const plen: number = this.instance.plen.getValue(0)
|
|
88
|
-
this.instance.plen.setValue(plen)
|
|
89
|
-
this.writeBytes(4, UInt16ToBuffer(plen))
|
|
90
|
-
if (!plen) {
|
|
91
|
-
this.addPostPacketEncodeHandler((): void => {
|
|
92
|
-
let startCount: boolean = false
|
|
93
|
-
let totalLength: number = 0
|
|
94
|
-
this.codecModules.forEach((codecModule: CodecModule): void => {
|
|
95
|
-
if (codecModule === this) startCount = true
|
|
96
|
-
if (startCount) totalLength += codecModule.length
|
|
97
|
-
})
|
|
98
|
-
let payloadLength: number = totalLength - 40
|
|
99
|
-
//The length is set to zero when a Hop-by-Hop extension header carries a Jumbo Payload option
|
|
100
|
-
if (payloadLength > 65535) payloadLength = 0
|
|
101
|
-
this.instance.plen.setValue(payloadLength)
|
|
102
|
-
this.writeBytes(4, UInt16ToBuffer(payloadLength))
|
|
103
|
-
|
|
104
|
-
})
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
nxt: {
|
|
109
|
-
type: 'integer',
|
|
110
|
-
label: 'Next Header',
|
|
111
|
-
minimum: 0,
|
|
112
|
-
maximum: 255,
|
|
113
|
-
decode: (): void => {
|
|
114
|
-
this.instance.nxt.setValue(BufferToUInt8(this.readBytes(6, 1)))
|
|
115
|
-
},
|
|
116
|
-
encode: (): void => {
|
|
117
|
-
const nxt: number = this.instance.nxt.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
118
|
-
this.instance.nxt.setValue(nxt)
|
|
119
|
-
this.writeBytes(6, UInt8ToBuffer(nxt))
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
hllm: {
|
|
123
|
-
type: 'integer',
|
|
124
|
-
label: 'Hop Limit',
|
|
125
|
-
minimum: 0,
|
|
126
|
-
maximum: 255,
|
|
127
|
-
decode: (): void => {
|
|
128
|
-
this.instance.hllm.setValue(BufferToUInt8(this.readBytes(7, 1)))
|
|
129
|
-
},
|
|
130
|
-
encode: (): void => {
|
|
131
|
-
const hllm: number = this.instance.hllm.getValue(0, (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
132
|
-
this.instance.hllm.setValue(hllm)
|
|
133
|
-
this.writeBytes(7, UInt8ToBuffer(hllm))
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
sip: {
|
|
137
|
-
type: 'string',
|
|
138
|
-
label: 'Source Address',
|
|
139
|
-
contentEncoding: StringContentEncodingEnum.IPv6,
|
|
140
|
-
decode: (): void => {
|
|
141
|
-
this.instance.sip.setValue(BufferToIPv6(this.readBytes(8, 16)))
|
|
142
|
-
},
|
|
143
|
-
encode: (): void => {
|
|
144
|
-
const sip: string = this.instance.sip.getValue('0000:0000:0000:0000:0000:0000:0000:0000', (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
145
|
-
this.instance.sip.setValue(sip)
|
|
146
|
-
this.writeBytes(8, IPv6ToBuffer(sip))
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
dip: {
|
|
150
|
-
type: 'string',
|
|
151
|
-
label: 'Destination Address',
|
|
152
|
-
contentEncoding: StringContentEncodingEnum.IPv6,
|
|
153
|
-
decode: (): void => {
|
|
154
|
-
this.instance.dip.setValue(BufferToIPv6(this.readBytes(24, 16)))
|
|
155
|
-
},
|
|
156
|
-
encode: (): void => {
|
|
157
|
-
const dip: string = this.instance.dip.getValue('0000:0000:0000:0000:0000:0000:0000:0000', (nodePath: string): void => this.recordError(nodePath, 'Not Found'))
|
|
158
|
-
this.instance.dip.setValue(dip)
|
|
159
|
-
this.writeBytes(24, IPv6ToBuffer(dip))
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
public id: string = 'ipv6'
|
|
166
|
-
|
|
167
|
-
public name: string = 'Internet Protocol Version 6'
|
|
168
|
-
|
|
169
|
-
public nickname: string = 'IPv6'
|
|
170
|
-
|
|
171
|
-
public match(): boolean {
|
|
172
|
-
if (!this.prevCodecModule) return false
|
|
173
|
-
return this.prevCodecModule.instance.etherType.getValue() === UInt16ToHex(0x86dd)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
}
|