netkitty 0.0.35 → 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.
Files changed (428) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +91 -2
  3. package/README.zh-CN.md +89 -0
  4. package/dist/analysis.d.ts +4 -0
  5. package/dist/{CodecHeaderExports.js → analysis.js} +4 -1
  6. package/dist/capture.d.ts +5 -0
  7. package/dist/capture.js +21 -0
  8. package/dist/codec.d.ts +5 -0
  9. package/dist/codec.js +21 -0
  10. package/dist/iface.d.ts +4 -0
  11. package/dist/iface.js +20 -0
  12. package/dist/pcap.d.ts +10 -0
  13. package/dist/pcap.js +27 -0
  14. package/dist/replay.d.ts +5 -0
  15. package/dist/replay.js +21 -0
  16. package/package.json +65 -59
  17. package/.eslintrc.json +0 -53
  18. package/.idea/codeStyles/Project.xml +0 -18
  19. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  20. package/.idea/inspectionProfiles/Project_Default.xml +0 -11
  21. package/.idea/modules.xml +0 -8
  22. package/.idea/netkitty.iml +0 -12
  23. package/.idea/vcs.xml +0 -6
  24. package/assets/NetKitty.png +0 -0
  25. package/binding.gyp +0 -5
  26. package/cpp/nodepcap/deps/include/Packet32.h +0 -429
  27. package/cpp/nodepcap/deps/include/pcap/bluetooth.h +0 -56
  28. package/cpp/nodepcap/deps/include/pcap/bpf.h +0 -292
  29. package/cpp/nodepcap/deps/include/pcap/can_socketcan.h +0 -56
  30. package/cpp/nodepcap/deps/include/pcap/compiler-tests.h +0 -163
  31. package/cpp/nodepcap/deps/include/pcap/dlt.h +0 -1514
  32. package/cpp/nodepcap/deps/include/pcap/funcattrs.h +0 -325
  33. package/cpp/nodepcap/deps/include/pcap/ipnet.h +0 -43
  34. package/cpp/nodepcap/deps/include/pcap/namedb.h +0 -84
  35. package/cpp/nodepcap/deps/include/pcap/nflog.h +0 -94
  36. package/cpp/nodepcap/deps/include/pcap/pcap-inttypes.h +0 -101
  37. package/cpp/nodepcap/deps/include/pcap/pcap.h +0 -1219
  38. package/cpp/nodepcap/deps/include/pcap/sll.h +0 -149
  39. package/cpp/nodepcap/deps/include/pcap/socket.h +0 -84
  40. package/cpp/nodepcap/deps/include/pcap/usb.h +0 -143
  41. package/cpp/nodepcap/deps/include/pcap/vlan.h +0 -46
  42. package/cpp/nodepcap/deps/include/pcap-bpf.h +0 -45
  43. package/cpp/nodepcap/deps/include/pcap-namedb.h +0 -40
  44. package/cpp/nodepcap/deps/include/pcap.h +0 -43
  45. package/cpp/nodepcap/deps/lib/ARM64/Packet.lib +0 -0
  46. package/cpp/nodepcap/deps/lib/Packet.lib +0 -0
  47. package/cpp/nodepcap/deps/lib/wpcap.lib +0 -0
  48. package/cpp/nodepcap/deps/lib/x64/Packet.lib +0 -0
  49. package/cpp/nodepcap/deps/lib/x64/wpcap.lib +0 -0
  50. package/cpp/nodepcap/nodepcap.gypi +0 -104
  51. package/cpp/nodepcap/src/binding.cc +0 -14
  52. package/cpp/nodepcap/src/capture.cc +0 -400
  53. package/cpp/nodepcap/src/capture.h +0 -53
  54. package/cpp/nodepcap/src/utils.cc +0 -218
  55. package/cpp/nodepcap/src/utils.h +0 -13
  56. package/dist/CodecExports.d.ts +0 -34
  57. package/dist/CodecExports.d.ts.map +0 -1
  58. package/dist/CodecExports.js +0 -23
  59. package/dist/CodecHeaderExports.d.ts +0 -2
  60. package/dist/CodecHeaderExports.d.ts.map +0 -1
  61. package/dist/HelperExports.d.ts +0 -11
  62. package/dist/HelperExports.d.ts.map +0 -1
  63. package/dist/HelperExports.js +0 -72
  64. package/dist/NetworkExports.d.ts +0 -13
  65. package/dist/NetworkExports.d.ts.map +0 -1
  66. package/dist/NetworkExports.js +0 -13
  67. package/dist/PcapExports.d.ts +0 -30
  68. package/dist/PcapExports.d.ts.map +0 -1
  69. package/dist/PcapExports.js +0 -33
  70. package/dist/errors/ActionNotFoundError.d.ts +0 -5
  71. package/dist/errors/ActionNotFoundError.d.ts.map +0 -1
  72. package/dist/errors/ActionNotFoundError.js +0 -12
  73. package/dist/errors/CodecSchemaValidateError.d.ts +0 -5
  74. package/dist/errors/CodecSchemaValidateError.d.ts.map +0 -1
  75. package/dist/errors/CodecSchemaValidateError.js +0 -12
  76. package/dist/errors/DeviceNotFoundError.d.ts +0 -5
  77. package/dist/errors/DeviceNotFoundError.d.ts.map +0 -1
  78. package/dist/errors/DeviceNotFoundError.js +0 -12
  79. package/dist/errors/NoAvailableCodecError.d.ts +0 -5
  80. package/dist/errors/NoAvailableCodecError.d.ts.map +0 -1
  81. package/dist/errors/NoAvailableCodecError.js +0 -12
  82. package/dist/errors/NpcapLoadError.d.ts +0 -5
  83. package/dist/errors/NpcapLoadError.d.ts.map +0 -1
  84. package/dist/errors/NpcapLoadError.js +0 -12
  85. package/dist/errors/SocketDownError.d.ts +0 -5
  86. package/dist/errors/SocketDownError.d.ts.map +0 -1
  87. package/dist/errors/SocketDownError.js +0 -12
  88. package/dist/errors/UnknownPipeMessageTypeError.d.ts +0 -5
  89. package/dist/errors/UnknownPipeMessageTypeError.d.ts.map +0 -1
  90. package/dist/errors/UnknownPipeMessageTypeError.js +0 -12
  91. package/dist/errors/common/ErrorCode.d.ts +0 -31
  92. package/dist/errors/common/ErrorCode.d.ts.map +0 -1
  93. package/dist/errors/common/ErrorCode.js +0 -33
  94. package/dist/lib/GeneratePipeAddress.d.ts +0 -7
  95. package/dist/lib/GeneratePipeAddress.d.ts.map +0 -1
  96. package/dist/lib/GeneratePipeAddress.js +0 -23
  97. package/dist/lib/GetBinding.d.ts +0 -2
  98. package/dist/lib/GetBinding.d.ts.map +0 -1
  99. package/dist/lib/GetBinding.js +0 -6
  100. package/dist/lib/GetCaptureTemporaryDirectory.d.ts +0 -7
  101. package/dist/lib/GetCaptureTemporaryDirectory.d.ts.map +0 -1
  102. package/dist/lib/GetCaptureTemporaryDirectory.js +0 -15
  103. package/dist/lib/GetDeviceCaptureTemporaryFilename.d.ts +0 -8
  104. package/dist/lib/GetDeviceCaptureTemporaryFilename.d.ts.map +0 -1
  105. package/dist/lib/GetDeviceCaptureTemporaryFilename.js +0 -18
  106. package/dist/lib/codec/Codec.d.ts +0 -32
  107. package/dist/lib/codec/Codec.d.ts.map +0 -1
  108. package/dist/lib/codec/Codec.js +0 -183
  109. package/dist/lib/codec/PacketHeaders.d.ts +0 -22
  110. package/dist/lib/codec/PacketHeaders.d.ts.map +0 -1
  111. package/dist/lib/codec/PacketHeaders.js +0 -47
  112. package/dist/lib/codec/abstracts/BaseHeader.d.ts +0 -217
  113. package/dist/lib/codec/abstracts/BaseHeader.d.ts.map +0 -1
  114. package/dist/lib/codec/abstracts/BaseHeader.js +0 -356
  115. package/dist/lib/codec/headers/ARP.d.ts +0 -10
  116. package/dist/lib/codec/headers/ARP.d.ts.map +0 -1
  117. package/dist/lib/codec/headers/ARP.js +0 -224
  118. package/dist/lib/codec/headers/EthernetII.d.ts +0 -10
  119. package/dist/lib/codec/headers/EthernetII.d.ts.map +0 -1
  120. package/dist/lib/codec/headers/EthernetII.js +0 -81
  121. package/dist/lib/codec/headers/Goose.d.ts +0 -104
  122. package/dist/lib/codec/headers/Goose.d.ts.map +0 -1
  123. package/dist/lib/codec/headers/Goose.js +0 -1005
  124. package/dist/lib/codec/headers/ICMP.d.ts +0 -15
  125. package/dist/lib/codec/headers/ICMP.d.ts.map +0 -1
  126. package/dist/lib/codec/headers/ICMP.js +0 -147
  127. package/dist/lib/codec/headers/ICMPv6.d.ts +0 -15
  128. package/dist/lib/codec/headers/ICMPv6.d.ts.map +0 -1
  129. package/dist/lib/codec/headers/ICMPv6.js +0 -128
  130. package/dist/lib/codec/headers/IEC104_I_Frame.d.ts +0 -10
  131. package/dist/lib/codec/headers/IEC104_I_Frame.d.ts.map +0 -1
  132. package/dist/lib/codec/headers/IEC104_I_Frame.js +0 -6411
  133. package/dist/lib/codec/headers/IEC104_S_Frame.d.ts +0 -10
  134. package/dist/lib/codec/headers/IEC104_S_Frame.d.ts.map +0 -1
  135. package/dist/lib/codec/headers/IEC104_S_Frame.js +0 -105
  136. package/dist/lib/codec/headers/IEC104_U_Frame.d.ts +0 -10
  137. package/dist/lib/codec/headers/IEC104_U_Frame.d.ts.map +0 -1
  138. package/dist/lib/codec/headers/IEC104_U_Frame.js +0 -155
  139. package/dist/lib/codec/headers/IEC61850SampledValues.d.ts +0 -13
  140. package/dist/lib/codec/headers/IEC61850SampledValues.d.ts.map +0 -1
  141. package/dist/lib/codec/headers/IEC61850SampledValues.js +0 -370
  142. package/dist/lib/codec/headers/IPv4.d.ts +0 -16
  143. package/dist/lib/codec/headers/IPv4.d.ts.map +0 -1
  144. package/dist/lib/codec/headers/IPv4.js +0 -339
  145. package/dist/lib/codec/headers/IPv6.d.ts +0 -10
  146. package/dist/lib/codec/headers/IPv6.d.ts.map +0 -1
  147. package/dist/lib/codec/headers/IPv6.js +0 -177
  148. package/dist/lib/codec/headers/IPv6HopByHopOptions.d.ts +0 -71
  149. package/dist/lib/codec/headers/IPv6HopByHopOptions.d.ts.map +0 -1
  150. package/dist/lib/codec/headers/IPv6HopByHopOptions.js +0 -517
  151. package/dist/lib/codec/headers/RawData.d.ts +0 -11
  152. package/dist/lib/codec/headers/RawData.d.ts.map +0 -1
  153. package/dist/lib/codec/headers/RawData.js +0 -36
  154. package/dist/lib/codec/headers/TCP.d.ts +0 -16
  155. package/dist/lib/codec/headers/TCP.d.ts.map +0 -1
  156. package/dist/lib/codec/headers/TCP.js +0 -917
  157. package/dist/lib/codec/headers/TLS_Alert.d.ts +0 -10
  158. package/dist/lib/codec/headers/TLS_Alert.d.ts.map +0 -1
  159. package/dist/lib/codec/headers/TLS_Alert.js +0 -624
  160. package/dist/lib/codec/headers/TLS_ApplicationData.d.ts +0 -10
  161. package/dist/lib/codec/headers/TLS_ApplicationData.d.ts.map +0 -1
  162. package/dist/lib/codec/headers/TLS_ApplicationData.js +0 -155
  163. package/dist/lib/codec/headers/TLS_ChangeCipherSpec.d.ts +0 -10
  164. package/dist/lib/codec/headers/TLS_ChangeCipherSpec.d.ts.map +0 -1
  165. package/dist/lib/codec/headers/TLS_ChangeCipherSpec.js +0 -154
  166. package/dist/lib/codec/headers/TLS_Handshake.d.ts +0 -10
  167. package/dist/lib/codec/headers/TLS_Handshake.d.ts.map +0 -1
  168. package/dist/lib/codec/headers/TLS_Handshake.js +0 -339
  169. package/dist/lib/codec/headers/TLS_Heartbeat.d.ts +0 -10
  170. package/dist/lib/codec/headers/TLS_Heartbeat.d.ts.map +0 -1
  171. package/dist/lib/codec/headers/TLS_Heartbeat.js +0 -206
  172. package/dist/lib/codec/headers/UDP.d.ts +0 -16
  173. package/dist/lib/codec/headers/UDP.d.ts.map +0 -1
  174. package/dist/lib/codec/headers/UDP.js +0 -192
  175. package/dist/lib/codec/headers/VLAN_802dot1Q.d.ts +0 -10
  176. package/dist/lib/codec/headers/VLAN_802dot1Q.d.ts.map +0 -1
  177. package/dist/lib/codec/headers/VLAN_802dot1Q.js +0 -82
  178. package/dist/lib/codec/lib/FlexibleObject.d.ts +0 -28
  179. package/dist/lib/codec/lib/FlexibleObject.d.ts.map +0 -1
  180. package/dist/lib/codec/lib/FlexibleObject.js +0 -102
  181. package/dist/lib/codec/lib/GetBERIntegerLengthFromBuffer.d.ts +0 -7
  182. package/dist/lib/codec/lib/GetBERIntegerLengthFromBuffer.d.ts.map +0 -1
  183. package/dist/lib/codec/lib/GetBERIntegerLengthFromBuffer.js +0 -16
  184. package/dist/lib/codec/lib/ProcessPacketPostHandlers.d.ts +0 -14
  185. package/dist/lib/codec/lib/ProcessPacketPostHandlers.d.ts.map +0 -1
  186. package/dist/lib/codec/lib/ProcessPacketPostHandlers.js +0 -53
  187. package/dist/lib/codec/lib/SortPostHandlers.d.ts +0 -8
  188. package/dist/lib/codec/lib/SortPostHandlers.d.ts.map +0 -1
  189. package/dist/lib/codec/lib/SortPostHandlers.js +0 -11
  190. package/dist/lib/codec/lib/StringContentEncodingEnum.d.ts +0 -11
  191. package/dist/lib/codec/lib/StringContentEncodingEnum.d.ts.map +0 -1
  192. package/dist/lib/codec/lib/StringContentEncodingEnum.js +0 -14
  193. package/dist/lib/codec/types/CodecData.d.ts +0 -7
  194. package/dist/lib/codec/types/CodecData.d.ts.map +0 -1
  195. package/dist/lib/codec/types/CodecData.js +0 -2
  196. package/dist/lib/codec/types/CodecDecodeResult.d.ts +0 -11
  197. package/dist/lib/codec/types/CodecDecodeResult.d.ts.map +0 -1
  198. package/dist/lib/codec/types/CodecDecodeResult.js +0 -2
  199. package/dist/lib/codec/types/CodecEncodeInput.d.ts +0 -9
  200. package/dist/lib/codec/types/CodecEncodeInput.d.ts.map +0 -1
  201. package/dist/lib/codec/types/CodecEncodeInput.js +0 -2
  202. package/dist/lib/codec/types/CodecEncodeResult.d.ts +0 -6
  203. package/dist/lib/codec/types/CodecEncodeResult.d.ts.map +0 -1
  204. package/dist/lib/codec/types/CodecEncodeResult.js +0 -2
  205. package/dist/lib/codec/types/CodecErrorInfo.d.ts +0 -6
  206. package/dist/lib/codec/types/CodecErrorInfo.d.ts.map +0 -1
  207. package/dist/lib/codec/types/CodecErrorInfo.js +0 -2
  208. package/dist/lib/codec/types/CodecModule.d.ts +0 -3
  209. package/dist/lib/codec/types/CodecModule.d.ts.map +0 -1
  210. package/dist/lib/codec/types/CodecModule.js +0 -2
  211. package/dist/lib/codec/types/CodecModuleConstructor.d.ts +0 -3
  212. package/dist/lib/codec/types/CodecModuleConstructor.d.ts.map +0 -1
  213. package/dist/lib/codec/types/CodecModuleConstructor.js +0 -2
  214. package/dist/lib/codec/types/CodecSchema.d.ts +0 -7
  215. package/dist/lib/codec/types/CodecSchema.d.ts.map +0 -1
  216. package/dist/lib/codec/types/CodecSchema.js +0 -2
  217. package/dist/lib/codec/types/HeaderTreeNode.d.ts +0 -5
  218. package/dist/lib/codec/types/HeaderTreeNode.d.ts.map +0 -1
  219. package/dist/lib/codec/types/HeaderTreeNode.js +0 -2
  220. package/dist/lib/codec/types/PostHandlerItem.d.ts +0 -5
  221. package/dist/lib/codec/types/PostHandlerItem.d.ts.map +0 -1
  222. package/dist/lib/codec/types/PostHandlerItem.js +0 -2
  223. package/dist/lib/helper/BufferToHex.d.ts +0 -2
  224. package/dist/lib/helper/BufferToHex.d.ts.map +0 -1
  225. package/dist/lib/helper/BufferToHex.js +0 -6
  226. package/dist/lib/helper/BufferToIP.d.ts +0 -13
  227. package/dist/lib/helper/BufferToIP.d.ts.map +0 -1
  228. package/dist/lib/helper/BufferToIP.js +0 -21
  229. package/dist/lib/helper/BufferToNumber.d.ts +0 -10
  230. package/dist/lib/helper/BufferToNumber.d.ts.map +0 -1
  231. package/dist/lib/helper/BufferToNumber.js +0 -22
  232. package/dist/lib/helper/HexToBuffer.d.ts +0 -8
  233. package/dist/lib/helper/HexToBuffer.d.ts.map +0 -1
  234. package/dist/lib/helper/HexToBuffer.js +0 -27
  235. package/dist/lib/helper/HexToNumber.d.ts +0 -10
  236. package/dist/lib/helper/HexToNumber.d.ts.map +0 -1
  237. package/dist/lib/helper/HexToNumber.js +0 -39
  238. package/dist/lib/helper/IPToBuffer.d.ts +0 -13
  239. package/dist/lib/helper/IPToBuffer.d.ts.map +0 -1
  240. package/dist/lib/helper/IPToBuffer.js +0 -28
  241. package/dist/lib/helper/NumberToBERBuffer.d.ts +0 -10
  242. package/dist/lib/helper/NumberToBERBuffer.d.ts.map +0 -1
  243. package/dist/lib/helper/NumberToBERBuffer.js +0 -22
  244. package/dist/lib/helper/NumberToBERHex.d.ts +0 -10
  245. package/dist/lib/helper/NumberToBERHex.d.ts.map +0 -1
  246. package/dist/lib/helper/NumberToBERHex.js +0 -27
  247. package/dist/lib/helper/NumberToBuffer.d.ts +0 -10
  248. package/dist/lib/helper/NumberToBuffer.d.ts.map +0 -1
  249. package/dist/lib/helper/NumberToBuffer.js +0 -22
  250. package/dist/lib/helper/NumberToHex.d.ts +0 -10
  251. package/dist/lib/helper/NumberToHex.d.ts.map +0 -1
  252. package/dist/lib/helper/NumberToHex.js +0 -26
  253. package/dist/lib/nodepcap/Capture.d.ts +0 -81
  254. package/dist/lib/nodepcap/Capture.d.ts.map +0 -1
  255. package/dist/lib/nodepcap/Capture.js +0 -323
  256. package/dist/lib/nodepcap/GetNetworkInterfaces.d.ts +0 -7
  257. package/dist/lib/nodepcap/GetNetworkInterfaces.d.ts.map +0 -1
  258. package/dist/lib/nodepcap/GetNetworkInterfaces.js +0 -22
  259. package/dist/lib/nodepcap/interfaces/IBindingCapture.d.ts +0 -16
  260. package/dist/lib/nodepcap/interfaces/IBindingCapture.d.ts.map +0 -1
  261. package/dist/lib/nodepcap/interfaces/IBindingCapture.js +0 -2
  262. package/dist/lib/nodepcap/interfaces/IBindingCaptureOptions.d.ts +0 -5
  263. package/dist/lib/nodepcap/interfaces/IBindingCaptureOptions.d.ts.map +0 -1
  264. package/dist/lib/nodepcap/interfaces/IBindingCaptureOptions.js +0 -2
  265. package/dist/lib/nodepcap/interfaces/ICaptureOptions.d.ts +0 -23
  266. package/dist/lib/nodepcap/interfaces/ICaptureOptions.d.ts.map +0 -1
  267. package/dist/lib/nodepcap/interfaces/ICaptureOptions.js +0 -2
  268. package/dist/lib/nodepcap/interfaces/INetworkInterface.d.ts +0 -5
  269. package/dist/lib/nodepcap/interfaces/INetworkInterface.d.ts.map +0 -1
  270. package/dist/lib/nodepcap/interfaces/INetworkInterface.js +0 -2
  271. package/dist/lib/nodepcap/lib/BindingCapture.d.ts +0 -15
  272. package/dist/lib/nodepcap/lib/BindingCapture.d.ts.map +0 -1
  273. package/dist/lib/nodepcap/lib/BindingCapture.js +0 -35
  274. package/dist/lib/nodepcap/lib/GetNodePcapBinding.d.ts +0 -2
  275. package/dist/lib/nodepcap/lib/GetNodePcapBinding.d.ts.map +0 -1
  276. package/dist/lib/nodepcap/lib/GetNodePcapBinding.js +0 -55
  277. package/dist/lib/nodepcap/lib/GetNodePcapBindingCapture.d.ts +0 -3
  278. package/dist/lib/nodepcap/lib/GetNodePcapBindingCapture.d.ts.map +0 -1
  279. package/dist/lib/nodepcap/lib/GetNodePcapBindingCapture.js +0 -18
  280. package/dist/lib/nodepcap/workers/CaptureWorker.d.ts +0 -2
  281. package/dist/lib/nodepcap/workers/CaptureWorker.d.ts.map +0 -1
  282. package/dist/lib/nodepcap/workers/CaptureWorker.js +0 -25
  283. package/dist/lib/pcap/PCAPGenerator.d.ts +0 -34
  284. package/dist/lib/pcap/PCAPGenerator.d.ts.map +0 -1
  285. package/dist/lib/pcap/PCAPGenerator.js +0 -101
  286. package/dist/lib/pcap/PcapParser.d.ts +0 -27
  287. package/dist/lib/pcap/PcapParser.d.ts.map +0 -1
  288. package/dist/lib/pcap/PcapParser.js +0 -149
  289. package/dist/lib/pcap/PcapReader.d.ts +0 -112
  290. package/dist/lib/pcap/PcapReader.d.ts.map +0 -1
  291. package/dist/lib/pcap/PcapReader.js +0 -263
  292. package/dist/lib/pcap/PcapWriter.d.ts +0 -29
  293. package/dist/lib/pcap/PcapWriter.d.ts.map +0 -1
  294. package/dist/lib/pcap/PcapWriter.js +0 -86
  295. package/dist/lib/pcap/interfaces/IPcapPacketInfo.d.ts +0 -13
  296. package/dist/lib/pcap/interfaces/IPcapPacketInfo.d.ts.map +0 -1
  297. package/dist/lib/pcap/interfaces/IPcapPacketInfo.js +0 -2
  298. package/dist/lib/pipe/PipeClient.d.ts +0 -35
  299. package/dist/lib/pipe/PipeClient.d.ts.map +0 -1
  300. package/dist/lib/pipe/PipeClient.js +0 -71
  301. package/dist/lib/pipe/PipeClientSocket.d.ts +0 -39
  302. package/dist/lib/pipe/PipeClientSocket.d.ts.map +0 -1
  303. package/dist/lib/pipe/PipeClientSocket.js +0 -82
  304. package/dist/lib/pipe/PipeMessage.d.ts +0 -27
  305. package/dist/lib/pipe/PipeMessage.d.ts.map +0 -1
  306. package/dist/lib/pipe/PipeMessage.js +0 -61
  307. package/dist/lib/pipe/PipeMessageHandler.d.ts +0 -16
  308. package/dist/lib/pipe/PipeMessageHandler.d.ts.map +0 -1
  309. package/dist/lib/pipe/PipeMessageHandler.js +0 -95
  310. package/dist/lib/pipe/PipeServer.d.ts +0 -25
  311. package/dist/lib/pipe/PipeServer.d.ts.map +0 -1
  312. package/dist/lib/pipe/PipeServer.js +0 -59
  313. package/dist/lib/schema/ProtocolFieldJSONSchema.d.ts +0 -36
  314. package/dist/lib/schema/ProtocolFieldJSONSchema.d.ts.map +0 -1
  315. package/dist/lib/schema/ProtocolFieldJSONSchema.js +0 -2
  316. package/dist/lib/schema/ProtocolFieldJSONSchemaDefinition.d.ts +0 -3
  317. package/dist/lib/schema/ProtocolFieldJSONSchemaDefinition.d.ts.map +0 -1
  318. package/dist/lib/schema/ProtocolFieldJSONSchemaDefinition.js +0 -2
  319. package/dist/lib/schema/ProtocolJSONSchema.d.ts +0 -32
  320. package/dist/lib/schema/ProtocolJSONSchema.d.ts.map +0 -1
  321. package/dist/lib/schema/ProtocolJSONSchema.js +0 -2
  322. package/dist/tests/Test.spec.d.ts +0 -2
  323. package/dist/tests/Test.spec.d.ts.map +0 -1
  324. package/dist/tests/Test.spec.js +0 -25
  325. package/dist/tests/units/CaptureTest.spec.d.ts +0 -2
  326. package/dist/tests/units/CaptureTest.spec.d.ts.map +0 -1
  327. package/dist/tests/units/CaptureTest.spec.js +0 -32
  328. package/dist/tests/units/Codec.spec.d.ts +0 -2
  329. package/dist/tests/units/Codec.spec.d.ts.map +0 -1
  330. package/dist/tests/units/Codec.spec.js +0 -86
  331. package/dist/tests/units/ReadPCAP.spec.d.ts +0 -2
  332. package/dist/tests/units/ReadPCAP.spec.d.ts.map +0 -1
  333. package/dist/tests/units/ReadPCAP.spec.js +0 -14
  334. package/src/CodecExports.ts +0 -33
  335. package/src/CodecHeaderExports.ts +0 -1
  336. package/src/HelperExports.ts +0 -78
  337. package/src/NetworkExports.ts +0 -12
  338. package/src/PcapExports.ts +0 -32
  339. package/src/errors/ActionNotFoundError.ts +0 -6
  340. package/src/errors/CodecSchemaValidateError.ts +0 -6
  341. package/src/errors/DeviceNotFoundError.ts +0 -6
  342. package/src/errors/NoAvailableCodecError.ts +0 -6
  343. package/src/errors/NpcapLoadError.ts +0 -6
  344. package/src/errors/SocketDownError.ts +0 -6
  345. package/src/errors/UnknownPipeMessageTypeError.ts +0 -6
  346. package/src/errors/common/ErrorCode.ts +0 -30
  347. package/src/lib/GeneratePipeAddress.ts +0 -17
  348. package/src/lib/GetBinding.ts +0 -3
  349. package/src/lib/GetCaptureTemporaryDirectory.ts +0 -12
  350. package/src/lib/GetDeviceCaptureTemporaryFilename.ts +0 -13
  351. package/src/lib/codec/Codec.ts +0 -164
  352. package/src/lib/codec/PacketHeaders.ts +0 -23
  353. package/src/lib/codec/abstracts/BaseHeader.ts +0 -435
  354. package/src/lib/codec/headers/ARP.ts +0 -220
  355. package/src/lib/codec/headers/EthernetII.ts +0 -79
  356. package/src/lib/codec/headers/Goose.ts +0 -1033
  357. package/src/lib/codec/headers/ICMP.ts +0 -151
  358. package/src/lib/codec/headers/ICMPv6.ts +0 -128
  359. package/src/lib/codec/headers/IEC104_I_Frame.ts +0 -7373
  360. package/src/lib/codec/headers/IEC104_S_Frame.ts +0 -97
  361. package/src/lib/codec/headers/IEC104_U_Frame.ts +0 -139
  362. package/src/lib/codec/headers/IEC61850SampledValues.ts +0 -361
  363. package/src/lib/codec/headers/IPv4.ts +0 -331
  364. package/src/lib/codec/headers/IPv6.ts +0 -176
  365. package/src/lib/codec/headers/IPv6HopByHopOptions.ts +0 -552
  366. package/src/lib/codec/headers/RawData.ts +0 -38
  367. package/src/lib/codec/headers/TCP.ts +0 -952
  368. package/src/lib/codec/headers/TLS_Alert.ts +0 -539
  369. package/src/lib/codec/headers/TLS_ApplicationData.ts +0 -145
  370. package/src/lib/codec/headers/TLS_ChangeCipherSpec.ts +0 -146
  371. package/src/lib/codec/headers/TLS_Handshake.ts +0 -313
  372. package/src/lib/codec/headers/TLS_Heartbeat.ts +0 -188
  373. package/src/lib/codec/headers/UDP.ts +0 -182
  374. package/src/lib/codec/headers/VLAN_802dot1Q.ts +0 -79
  375. package/src/lib/codec/lib/FlexibleObject.ts +0 -100
  376. package/src/lib/codec/lib/GetBERIntegerLengthFromBuffer.ts +0 -12
  377. package/src/lib/codec/lib/ProcessPacketPostHandlers.ts +0 -53
  378. package/src/lib/codec/lib/SortPostHandlers.ts +0 -10
  379. package/src/lib/codec/lib/StringContentEncodingEnum.ts +0 -10
  380. package/src/lib/codec/types/CodecData.ts +0 -7
  381. package/src/lib/codec/types/CodecDecodeResult.ts +0 -11
  382. package/src/lib/codec/types/CodecEncodeInput.ts +0 -9
  383. package/src/lib/codec/types/CodecEncodeResult.ts +0 -6
  384. package/src/lib/codec/types/CodecErrorInfo.ts +0 -5
  385. package/src/lib/codec/types/CodecModule.ts +0 -3
  386. package/src/lib/codec/types/CodecModuleConstructor.ts +0 -3
  387. package/src/lib/codec/types/CodecSchema.ts +0 -7
  388. package/src/lib/codec/types/HeaderTreeNode.ts +0 -5
  389. package/src/lib/codec/types/PostHandlerItem.ts +0 -4
  390. package/src/lib/helper/BufferToHex.ts +0 -3
  391. package/src/lib/helper/BufferToIP.ts +0 -19
  392. package/src/lib/helper/BufferToNumber.ts +0 -31
  393. package/src/lib/helper/HexToBuffer.ts +0 -22
  394. package/src/lib/helper/HexToNumber.ts +0 -25
  395. package/src/lib/helper/IPToBuffer.ts +0 -25
  396. package/src/lib/helper/NumberToBERBuffer.ts +0 -21
  397. package/src/lib/helper/NumberToBERHex.ts +0 -17
  398. package/src/lib/helper/NumberToBuffer.ts +0 -21
  399. package/src/lib/helper/NumberToHex.ts +0 -15
  400. package/src/lib/nodepcap/Capture.ts +0 -304
  401. package/src/lib/nodepcap/GetNetworkInterfaces.ts +0 -18
  402. package/src/lib/nodepcap/interfaces/IBindingCapture.ts +0 -27
  403. package/src/lib/nodepcap/interfaces/IBindingCaptureOptions.ts +0 -4
  404. package/src/lib/nodepcap/interfaces/ICaptureOptions.ts +0 -24
  405. package/src/lib/nodepcap/interfaces/INetworkInterface.ts +0 -4
  406. package/src/lib/nodepcap/lib/BindingCapture.ts +0 -46
  407. package/src/lib/nodepcap/lib/GetNodePcapBinding.ts +0 -17
  408. package/src/lib/nodepcap/lib/GetNodePcapBindingCapture.ts +0 -15
  409. package/src/lib/nodepcap/workers/CaptureWorker.ts +0 -30
  410. package/src/lib/pcap/PCAPGenerator.ts +0 -123
  411. package/src/lib/pcap/PcapParser.ts +0 -170
  412. package/src/lib/pcap/PcapReader.ts +0 -306
  413. package/src/lib/pcap/PcapWriter.ts +0 -98
  414. package/src/lib/pcap/interfaces/IPcapPacketInfo.ts +0 -12
  415. package/src/lib/pipe/PipeClient.ts +0 -91
  416. package/src/lib/pipe/PipeClientSocket.ts +0 -99
  417. package/src/lib/pipe/PipeMessage.ts +0 -74
  418. package/src/lib/pipe/PipeMessageHandler.ts +0 -91
  419. package/src/lib/pipe/PipeServer.ts +0 -74
  420. package/src/lib/schema/ProtocolFieldJSONSchema.ts +0 -47
  421. package/src/lib/schema/ProtocolFieldJSONSchemaDefinition.ts +0 -3
  422. package/src/lib/schema/ProtocolJSONSchema.ts +0 -37
  423. package/src/tests/Test.spec.ts +0 -22
  424. package/src/tests/units/CaptureTest.spec.ts +0 -31
  425. package/src/tests/units/Codec.spec.ts +0 -102
  426. package/src/tests/units/ReadPCAP.spec.ts +0 -13
  427. package/test.pcap +0 -0
  428. package/tsconfig.json +0 -42
@@ -1,917 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TCP = void 0;
4
- const BaseHeader_1 = require("../abstracts/BaseHeader");
5
- const BufferToNumber_1 = require("../../helper/BufferToNumber");
6
- const NumberToBuffer_1 = require("../../helper/NumberToBuffer");
7
- const IPToBuffer_1 = require("../../helper/IPToBuffer");
8
- const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
9
- const NumberToHex_1 = require("../../helper/NumberToHex");
10
- const HexToNumber_1 = require("../../helper/HexToNumber");
11
- var TCPOption;
12
- (function (TCPOption) {
13
- TCPOption["End_of_Option_List"] = "EOL";
14
- TCPOption["No_Operation"] = "NOP";
15
- TCPOption["Maximum_Segment_Size"] = "MSS";
16
- TCPOption["Window_Scale"] = "Window-Scale";
17
- TCPOption["Selective_Acknowledgment_Permitted"] = "SACK-Permitted";
18
- TCPOption["Selective_Acknowledgment"] = "SACK";
19
- TCPOption["Timestamp"] = "TS";
20
- TCPOption["User_Timeout"] = "UTO";
21
- TCPOption["TCP_Authentication_Option"] = "TCP-AO";
22
- })(TCPOption || (TCPOption = {}));
23
- class TCP extends BaseHeader_1.BaseHeader {
24
- constructor() {
25
- super(...arguments);
26
- this.SCHEMA = {
27
- type: 'object',
28
- properties: {
29
- srcport: {
30
- type: 'integer',
31
- label: 'Source Port',
32
- minimum: 0,
33
- maximum: 65535,
34
- decode: () => {
35
- this.instance.srcport.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(0, 2)));
36
- },
37
- encode: () => {
38
- let srcport = this.instance.srcport.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
39
- if (srcport > 65535) {
40
- this.recordError(this.instance.srcport.getPath(), 'Maximum value is 65535');
41
- srcport = 65535;
42
- }
43
- if (srcport < 0) {
44
- this.recordError(this.instance.srcport.getPath(), 'Minimum value is 0');
45
- srcport = 0;
46
- }
47
- this.instance.srcport.setValue(srcport);
48
- this.writeBytes(0, (0, NumberToBuffer_1.UInt16ToBuffer)(srcport));
49
- }
50
- },
51
- dstport: {
52
- type: 'integer',
53
- label: 'Destination Port',
54
- minimum: 0,
55
- maximum: 65535,
56
- decode: () => {
57
- this.instance.dstport.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
58
- },
59
- encode: () => {
60
- let dstport = this.instance.dstport.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
61
- if (dstport > 65535) {
62
- this.recordError(this.instance.dstport.getPath(), 'Maximum value is 65535');
63
- dstport = 65535;
64
- }
65
- if (dstport < 0) {
66
- this.recordError(this.instance.dstport.getPath(), 'Minimum value is 0');
67
- dstport = 0;
68
- }
69
- this.instance.dstport.setValue(dstport);
70
- this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(dstport));
71
- }
72
- },
73
- seq: {
74
- type: 'integer',
75
- label: 'Sequence Number',
76
- minimum: 0,
77
- maximum: 4294967295,
78
- decode: () => {
79
- this.instance.seq.setValue((0, BufferToNumber_1.BufferToUInt32)(this.readBytes(4, 4)));
80
- },
81
- encode: () => {
82
- let seqNum = this.instance.seq.getValue(0);
83
- if (seqNum > 4294967295) {
84
- this.recordError(this.instance.seq.getPath(), 'Maximum value is 4294967295');
85
- seqNum = 4294967295;
86
- }
87
- if (seqNum < 0) {
88
- this.recordError(this.instance.seq.getPath(), 'Minimum value is 0');
89
- seqNum = 0;
90
- }
91
- this.instance.seq.setValue(seqNum);
92
- this.writeBytes(4, (0, NumberToBuffer_1.UInt32ToBuffer)(seqNum));
93
- }
94
- },
95
- ack: {
96
- type: 'integer',
97
- label: 'Acknowledgment Number',
98
- minimum: 0,
99
- maximum: 4294967295,
100
- decode: () => {
101
- this.instance.ack.setValue((0, BufferToNumber_1.BufferToUInt32)(this.readBytes(8, 4)));
102
- },
103
- encode: () => {
104
- let ackNum = this.instance.ack.getValue(0);
105
- if (ackNum > 4294967295) {
106
- this.recordError(this.instance.ack.getPath(), 'Maximum value is 4294967295');
107
- ackNum = 4294967295;
108
- }
109
- if (ackNum < 0) {
110
- this.recordError(this.instance.ack.getPath(), 'Minimum value is 0');
111
- ackNum = 0;
112
- }
113
- this.instance.ack.setValue(ackNum);
114
- this.writeBytes(8, (0, NumberToBuffer_1.UInt32ToBuffer)(ackNum));
115
- }
116
- },
117
- hdrLen: {
118
- type: 'integer',
119
- label: 'Header Length',
120
- minimum: 0,
121
- maximum: 60,
122
- decode: () => {
123
- this.instance.hdrLen.setValue(this.readBits(12, 1, 0, 4) * 4);
124
- },
125
- encode: () => {
126
- let hdrLen = this.instance.hdrLen.getValue(0);
127
- if (hdrLen) {
128
- this.instance.hdrLen.setValue(hdrLen);
129
- this.writeBits(12, 1, 0, 4, hdrLen ? Math.floor(hdrLen / 4) : 0);
130
- }
131
- else {
132
- this.addPostSelfEncodeHandler(() => {
133
- this.instance.hdrLen.setValue(Math.floor(this.length / 4) * 4);
134
- this.writeBits(12, 1, 0, 4, Math.floor(this.length / 4));
135
- }, 1);
136
- }
137
- }
138
- },
139
- flags: {
140
- type: 'object',
141
- label: 'Flags',
142
- properties: {
143
- res: {
144
- type: 'integer',
145
- label: 'Reserved',
146
- minimum: 0,
147
- maximum: 7,
148
- decode: () => {
149
- this.instance.flags.res.setValue(this.readBits(12, 1, 4, 3));
150
- },
151
- encode: () => {
152
- let reserved = this.instance.flags.res.getValue(0);
153
- if (reserved > 7) {
154
- this.recordError(this.instance.flags.res.getPath(), 'Maximum value is 7');
155
- reserved = 7;
156
- }
157
- if (reserved < 0) {
158
- this.recordError(this.instance.flags.res.getPath(), 'Minimum value is 0');
159
- reserved = 0;
160
- }
161
- this.instance.flags.res.setValue(reserved);
162
- this.writeBits(12, 1, 4, 3, reserved);
163
- }
164
- },
165
- ae: {
166
- type: 'boolean',
167
- label: 'Accurate ECN',
168
- decode: () => {
169
- this.instance.flags.ae.setValue(!!this.readBits(12, 1, 7, 1));
170
- },
171
- encode: () => {
172
- const accurateECN = !!this.instance.flags.ae.getValue();
173
- this.instance.flags.ae.setValue(accurateECN);
174
- this.writeBits(12, 1, 7, 1, accurateECN ? 1 : 0);
175
- }
176
- },
177
- cwr: {
178
- type: 'boolean',
179
- label: 'Congestion Window Reduced',
180
- decode: () => {
181
- this.instance.flags.cwr.setValue(!!this.readBits(13, 1, 0, 1));
182
- },
183
- encode: () => {
184
- const congestionWindowReduced = !!this.instance.flags.cwr.getValue();
185
- this.instance.flags.cwr.setValue(congestionWindowReduced);
186
- this.writeBits(13, 1, 0, 1, congestionWindowReduced ? 1 : 0);
187
- }
188
- },
189
- ece: {
190
- type: 'boolean',
191
- label: 'ECN-Echo',
192
- decode: () => {
193
- this.instance.flags.ece.setValue(!!this.readBits(13, 1, 1, 1));
194
- },
195
- encode: () => {
196
- const ECNEcho = !!this.instance.flags.ece.getValue();
197
- this.instance.flags.ece.setValue(ECNEcho);
198
- this.writeBits(13, 1, 1, 1, ECNEcho ? 1 : 0);
199
- }
200
- },
201
- urg: {
202
- type: 'boolean',
203
- label: 'Urgent',
204
- decode: () => {
205
- this.instance.flags.urg.setValue(!!this.readBits(13, 1, 2, 1));
206
- },
207
- encode: () => {
208
- const urgent = !!this.instance.flags.urg.getValue();
209
- this.instance.flags.urg.setValue(urgent);
210
- this.writeBits(13, 1, 2, 1, urgent ? 1 : 0);
211
- }
212
- },
213
- ack: {
214
- type: 'boolean',
215
- label: 'Acknowledgment',
216
- decode: () => {
217
- this.instance.flags.ack.setValue(!!this.readBits(13, 1, 3, 1));
218
- },
219
- encode: () => {
220
- const acknowledgment = !!this.instance.flags.ack.getValue();
221
- this.instance.flags.ack.setValue(acknowledgment);
222
- this.writeBits(13, 1, 3, 1, acknowledgment ? 1 : 0);
223
- }
224
- },
225
- push: {
226
- type: 'boolean',
227
- label: 'Push',
228
- decode: () => {
229
- this.instance.flags.push.setValue(!!this.readBits(13, 1, 4, 1));
230
- },
231
- encode: () => {
232
- const push = !!this.instance.flags.push.getValue();
233
- this.instance.flags.push.setValue(push);
234
- this.writeBits(13, 1, 4, 1, push ? 1 : 0);
235
- }
236
- },
237
- rst: {
238
- type: 'boolean',
239
- label: 'Reset',
240
- decode: () => {
241
- this.instance.flags.rst.setValue(!!this.readBits(13, 1, 5, 1));
242
- },
243
- encode: () => {
244
- const reset = !!this.instance.flags.rst.getValue();
245
- this.instance.flags.rst.setValue(reset);
246
- this.writeBits(13, 1, 5, 1, reset ? 1 : 0);
247
- }
248
- },
249
- syn: {
250
- type: 'boolean',
251
- label: 'Syn',
252
- decode: () => {
253
- this.instance.flags.syn.setValue(!!this.readBits(13, 1, 6, 1));
254
- },
255
- encode: () => {
256
- const syn = !!this.instance.flags.syn.getValue();
257
- this.instance.flags.syn.setValue(syn);
258
- this.writeBits(13, 1, 6, 1, syn ? 1 : 0);
259
- }
260
- },
261
- fin: {
262
- type: 'boolean',
263
- label: 'Fin',
264
- decode: () => {
265
- this.instance.flags.fin.setValue(!!this.readBits(13, 1, 7, 1));
266
- },
267
- encode: () => {
268
- const fin = !!this.instance.flags.fin.getValue();
269
- this.instance.flags.fin.setValue(fin);
270
- this.writeBits(13, 1, 7, 1, fin ? 1 : 0);
271
- }
272
- }
273
- }
274
- },
275
- window: {
276
- type: 'integer',
277
- label: 'Window Size',
278
- minimum: 0,
279
- maximum: 65535,
280
- decode: () => {
281
- this.instance.window.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(14, 2)));
282
- },
283
- encode: () => {
284
- let windowSize = this.instance.window.getValue(0);
285
- if (windowSize > 65535) {
286
- this.recordError(this.instance.window.getPath(), 'Maximum value is 65535');
287
- windowSize = 65535;
288
- }
289
- if (windowSize < 0) {
290
- this.recordError(this.instance.window.getPath(), 'Minimum value is 0');
291
- windowSize = 0;
292
- }
293
- this.instance.window.setValue(windowSize);
294
- this.writeBytes(14, (0, NumberToBuffer_1.UInt16ToBuffer)(windowSize));
295
- }
296
- },
297
- checksum: {
298
- type: 'integer',
299
- label: 'Checksum',
300
- minimum: 0,
301
- maximum: 65535,
302
- decode: () => {
303
- this.instance.checksum.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(16, 2)));
304
- },
305
- encode: () => {
306
- let checksum = this.instance.checksum.getValue(0);
307
- if (checksum) {
308
- this.instance.checksum.setValue(checksum);
309
- this.writeBytes(16, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
310
- }
311
- else {
312
- this.instance.checksum.setValue(checksum);
313
- this.writeBytes(16, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
314
- this.addPostPacketEncodeHandler(() => {
315
- //Calculate checksum after packet encoded
316
- let startPos = 0;
317
- let endPos = 0;
318
- this.codecModules.forEach((codecModule) => {
319
- if (codecModule === this)
320
- startPos = codecModule.startPos;
321
- endPos = codecModule.endPos > endPos ? codecModule.endPos : endPos;
322
- });
323
- const calcChecksum = this.calculateTCPChecksum(this.packet.subarray(startPos, endPos));
324
- this.instance.checksum.setValue(calcChecksum);
325
- this.writeBytes(16, (0, NumberToBuffer_1.UInt16ToBuffer)(calcChecksum));
326
- }, 100);
327
- }
328
- }
329
- },
330
- urgPtr: {
331
- type: 'integer',
332
- label: 'Urgent Pointer',
333
- minimum: 0,
334
- maximum: 65535,
335
- decode: () => {
336
- this.instance.urgPtr.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(18, 2)));
337
- },
338
- encode: () => {
339
- let urgPtr = this.instance.urgPtr.getValue(0);
340
- if (urgPtr > 65535) {
341
- this.recordError(this.instance.urgPtr.getPath(), 'Maximum value is 65535');
342
- urgPtr = 65535;
343
- }
344
- if (urgPtr < 0) {
345
- this.recordError(this.instance.urgPtr.getPath(), 'Minimum value is 0');
346
- urgPtr = 0;
347
- }
348
- this.instance.urgPtr.setValue(urgPtr);
349
- this.writeBytes(18, (0, NumberToBuffer_1.UInt16ToBuffer)(urgPtr));
350
- }
351
- },
352
- options: {
353
- type: 'array',
354
- label: 'Options',
355
- items: {
356
- anyOf: [
357
- //Kind = 0 (End of Option List, EOL)
358
- {
359
- type: 'object',
360
- label: 'End of Option List',
361
- properties: {
362
- option: {
363
- type: 'string',
364
- label: 'Option',
365
- enum: [TCPOption.End_of_Option_List],
366
- const: TCPOption.End_of_Option_List,
367
- hidden: true
368
- }
369
- }
370
- },
371
- //Kind = 1 (No-Operation, NOP)
372
- {
373
- type: 'object',
374
- label: 'No-Operation',
375
- properties: {
376
- option: {
377
- type: 'string',
378
- label: 'Option',
379
- enum: [TCPOption.No_Operation],
380
- const: TCPOption.No_Operation,
381
- hidden: true
382
- }
383
- }
384
- },
385
- //Kind = 2 (Maximum Segment Size, MSS)
386
- {
387
- type: 'object',
388
- label: 'Maximum Segment Size',
389
- properties: {
390
- option: {
391
- type: 'string',
392
- label: 'Option',
393
- enum: [TCPOption.Maximum_Segment_Size],
394
- const: TCPOption.Maximum_Segment_Size,
395
- hidden: true
396
- },
397
- mss: {
398
- type: 'integer',
399
- label: 'MSS',
400
- maximum: 65535,
401
- minimum: 0
402
- }
403
- }
404
- },
405
- //Kind = 3 (Window Scale)
406
- {
407
- type: 'object',
408
- label: 'Window Scale',
409
- properties: {
410
- option: {
411
- type: 'string',
412
- label: 'Option',
413
- enum: [TCPOption.Window_Scale],
414
- const: TCPOption.Window_Scale,
415
- hidden: true
416
- },
417
- shift: {
418
- type: 'integer',
419
- label: 'Shift count',
420
- minimum: 0,
421
- maximum: 14
422
- }
423
- }
424
- },
425
- //Kind = 4 (Selective Acknowledgment Permitted, SACK-Permitted)
426
- {
427
- type: 'object',
428
- label: 'Selective Acknowledgment Permitted',
429
- properties: {
430
- option: {
431
- type: 'string',
432
- label: 'Option',
433
- enum: [TCPOption.Selective_Acknowledgment_Permitted],
434
- const: TCPOption.Selective_Acknowledgment_Permitted,
435
- hidden: true
436
- }
437
- }
438
- },
439
- //Kind = 5 (Selective Acknowledgment, SACK)
440
- {
441
- type: 'object',
442
- label: 'Selective Acknowledgment',
443
- properties: {
444
- option: {
445
- type: 'string',
446
- label: 'Option',
447
- enum: [TCPOption.Selective_Acknowledgment],
448
- const: TCPOption.Selective_Acknowledgment,
449
- hidden: true
450
- },
451
- blocks: {
452
- type: 'array',
453
- label: 'SACK Blocks',
454
- items: {
455
- type: 'string',
456
- maxLength: 16,
457
- minLength: 16,
458
- contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX
459
- }
460
- }
461
- }
462
- },
463
- //Kind = 8 (Timestamp, TS)
464
- {
465
- type: 'object',
466
- label: 'Timestamp',
467
- properties: {
468
- option: {
469
- type: 'string',
470
- label: 'Option',
471
- enum: [TCPOption.Timestamp],
472
- const: TCPOption.Timestamp,
473
- hidden: true
474
- },
475
- tsval: {
476
- type: 'integer',
477
- label: 'TSval',
478
- minimum: 0,
479
- maximum: 4294967295
480
- },
481
- tsecr: {
482
- type: 'integer',
483
- label: 'TSecr',
484
- minimum: 0,
485
- maximum: 4294967295
486
- }
487
- }
488
- },
489
- //Kind = 28 (User Timeout, UTO)
490
- {
491
- type: 'object',
492
- label: 'User Timeout',
493
- properties: {
494
- option: {
495
- type: 'string',
496
- label: 'Option',
497
- enum: [TCPOption.User_Timeout],
498
- const: TCPOption.User_Timeout,
499
- hidden: true
500
- },
501
- timeout: {
502
- type: 'integer',
503
- label: 'Timeout',
504
- minimum: 0,
505
- maximum: 65535
506
- },
507
- granularity: {
508
- type: 'integer',
509
- label: 'Granularity',
510
- enum: [0, 1]
511
- }
512
- }
513
- },
514
- //Kind = 29 (TCP Authentication Option, TCP-AO)
515
- {
516
- type: 'object',
517
- label: 'TCP Authentication Option',
518
- properties: {
519
- option: {
520
- type: 'string',
521
- label: 'Option',
522
- enum: [TCPOption.TCP_Authentication_Option],
523
- const: TCPOption.TCP_Authentication_Option,
524
- hidden: true
525
- },
526
- data: {
527
- type: 'string',
528
- label: 'Data',
529
- contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX
530
- }
531
- }
532
- },
533
- //Default
534
- {
535
- type: 'object',
536
- label: 'Default',
537
- properties: {
538
- kind: {
539
- type: 'integer',
540
- label: 'Kind'
541
- },
542
- data: {
543
- type: 'string',
544
- contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
545
- label: 'Data'
546
- }
547
- }
548
- }
549
- ]
550
- },
551
- decode: () => {
552
- const hdrLen = this.instance.hdrLen.getValue();
553
- const optionsLength = hdrLen - this.length;
554
- if (!optionsLength)
555
- return;
556
- let optionOffset = this.length;
557
- const options = [];
558
- let index = 0;
559
- while (optionOffset < hdrLen) {
560
- const kind = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(optionOffset, 1));
561
- optionOffset += 1;
562
- switch (kind) {
563
- //Kind = 0 (End of Option List, EOL)
564
- case 0:
565
- {
566
- options.push({
567
- option: TCPOption.End_of_Option_List
568
- });
569
- }
570
- break;
571
- //Kind = 1 (No-Operation, NOP)
572
- case 1:
573
- {
574
- options.push({
575
- option: TCPOption.No_Operation
576
- });
577
- }
578
- break;
579
- //Kind = 2 (Maximum Segment Size, MSS)
580
- case 2:
581
- {
582
- let length = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(optionOffset, 1));
583
- if (length !== 4)
584
- this.recordError(this.instance.options.getPath(index), 'MSS option TLV length should be 4');
585
- optionOffset += 1;
586
- let value = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(optionOffset, 2));
587
- optionOffset += 2;
588
- options.push({
589
- option: TCPOption.Maximum_Segment_Size,
590
- mss: value
591
- });
592
- }
593
- break;
594
- //Kind = 3 (Window Scale)
595
- case 3:
596
- {
597
- let length = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(optionOffset, 1));
598
- if (length !== 3)
599
- this.recordError(this.instance.options.getPath(index), 'Window Scale option TLV length should be 3');
600
- optionOffset += 1;
601
- let value = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(optionOffset, 1));
602
- optionOffset += 1;
603
- if (value < 0 || value > 14)
604
- this.recordError(this.instance.options.getPath(index), 'Window Scale option TLV value should between 0 and 14');
605
- options.push({
606
- option: TCPOption.Window_Scale,
607
- shift: value
608
- });
609
- }
610
- break;
611
- //Kind = 4 (Selective Acknowledgment Permitted, SACK-Permitted)
612
- case 4:
613
- {
614
- let length = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(optionOffset, 1));
615
- optionOffset += 1;
616
- if (length !== 2)
617
- this.recordError(this.instance.options.getPath(index), 'SACK-Permitted option TLV length should be 2');
618
- options.push({
619
- option: TCPOption.Selective_Acknowledgment_Permitted
620
- });
621
- }
622
- break;
623
- //Kind = 5 (Selective Acknowledgment, SACK)
624
- case 5:
625
- {
626
- let length = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(optionOffset, 1));
627
- optionOffset += 1;
628
- let sackBlockTotalLength = length - 2;
629
- if (sackBlockTotalLength < 0) {
630
- this.recordError(this.instance.options.getPath(index), 'SACK option block count should not less than 0');
631
- sackBlockTotalLength = 0;
632
- }
633
- let sackBlockCount = sackBlockTotalLength ? Math.floor(sackBlockTotalLength / 8) : 0;
634
- const sackBlocks = [];
635
- while (sackBlockCount > 0) {
636
- sackBlocks.push((0, NumberToHex_1.UInt64ToHex)(BigInt(`0x${(0, BufferToNumber_1.BufferToUInt64)(this.readBytes(optionOffset, 8)).toString(16)}`)));
637
- optionOffset += 8;
638
- sackBlockCount -= 1;
639
- }
640
- options.push({
641
- option: TCPOption.Selective_Acknowledgment,
642
- blocks: sackBlocks
643
- });
644
- }
645
- break;
646
- //Kind = 8 (Timestamp, TS)
647
- case 8:
648
- {
649
- let length = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(optionOffset, 1));
650
- optionOffset += 1;
651
- if (length !== 10)
652
- this.recordError(this.instance.options.getPath(index), 'Timestamp option TLV length should be 10');
653
- let tsval = (0, BufferToNumber_1.BufferToUInt32)(this.readBytes(optionOffset, 4));
654
- optionOffset += 4;
655
- let tsecr = (0, BufferToNumber_1.BufferToUInt32)(this.readBytes(optionOffset, 4));
656
- optionOffset += 4;
657
- options.push({
658
- option: TCPOption.Timestamp,
659
- tsval: tsval,
660
- tsecr: tsecr
661
- });
662
- }
663
- break;
664
- //Kind = 28 (User Timeout, UTO)
665
- case 28:
666
- {
667
- let length = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(optionOffset, 1));
668
- optionOffset += 1;
669
- if (length !== 5)
670
- this.recordError(this.instance.options.getPath(index), 'UTO option TLV length should be 5');
671
- let timeout = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(optionOffset, 2));
672
- optionOffset += 2;
673
- let granularity = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(optionOffset, 1));
674
- optionOffset += 1;
675
- options.push({
676
- option: TCPOption.User_Timeout,
677
- timeout: timeout,
678
- granularity: granularity
679
- });
680
- }
681
- break;
682
- //Kind = 29 (TCP Authentication Option, TCP-AO)
683
- case 29:
684
- {
685
- let length = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(optionOffset, 1));
686
- optionOffset += 1;
687
- let dataLength = length - 2;
688
- if (dataLength < 0) {
689
- this.recordError(this.instance.options.getPath(index), 'TCP Authentication Option TLV length should not less than 2');
690
- dataLength = 0;
691
- }
692
- let data;
693
- if (dataLength) {
694
- data = this.readBytes(optionOffset, dataLength);
695
- optionOffset += dataLength;
696
- }
697
- else {
698
- data = Buffer.from([]);
699
- }
700
- options.push({
701
- option: TCPOption.TCP_Authentication_Option,
702
- data: data.toString('hex')
703
- });
704
- }
705
- break;
706
- default: {
707
- let length = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(optionOffset, 1));
708
- let dataLength = length - 2;
709
- if (dataLength < 0) {
710
- this.recordError(this.instance.options.getPath(index), 'Option TLV length should not less than 2');
711
- dataLength = 0;
712
- }
713
- let data;
714
- if (dataLength) {
715
- data = this.readBytes(optionOffset, dataLength);
716
- optionOffset += dataLength;
717
- }
718
- else {
719
- data = Buffer.from([]);
720
- }
721
- options.push({
722
- kind: kind,
723
- data: data.toString('hex')
724
- });
725
- }
726
- }
727
- index += 1;
728
- }
729
- this.instance.options.setValue(options);
730
- },
731
- encode: () => {
732
- const options = this.instance.options.getValue();
733
- if (!options)
734
- return;
735
- let optionOffset = this.length;
736
- options.forEach((optionItem) => {
737
- const namedOptionItem = optionItem;
738
- switch (namedOptionItem.option) {
739
- case TCPOption.End_of_Option_List: {
740
- const optionEOL = optionItem;
741
- this.writeBytes(optionOffset, (0, NumberToBuffer_1.UInt8ToBuffer)(0));
742
- optionOffset += 1;
743
- return;
744
- }
745
- case TCPOption.No_Operation: {
746
- const optionNOP = optionItem;
747
- this.writeBytes(optionOffset, (0, NumberToBuffer_1.UInt8ToBuffer)(1));
748
- optionOffset += 1;
749
- return;
750
- }
751
- case TCPOption.Maximum_Segment_Size: {
752
- const optionMSS = optionItem;
753
- const mssBuffer = Buffer.concat([
754
- (0, NumberToBuffer_1.UInt8ToBuffer)(2),
755
- (0, NumberToBuffer_1.UInt8ToBuffer)(4),
756
- (0, NumberToBuffer_1.UInt16ToBuffer)(optionMSS.mss)
757
- ]);
758
- this.writeBytes(optionOffset, mssBuffer);
759
- optionOffset += mssBuffer.length;
760
- return;
761
- }
762
- case TCPOption.Window_Scale: {
763
- const optionWS = optionItem;
764
- const wsBuffer = Buffer.concat([
765
- (0, NumberToBuffer_1.UInt8ToBuffer)(3),
766
- (0, NumberToBuffer_1.UInt8ToBuffer)(3),
767
- (0, NumberToBuffer_1.UInt8ToBuffer)(optionWS.shift)
768
- ]);
769
- this.writeBytes(optionOffset, wsBuffer);
770
- optionOffset += wsBuffer.length;
771
- return;
772
- }
773
- case TCPOption.Selective_Acknowledgment_Permitted: {
774
- const optionSackPermitted = optionItem;
775
- const sackPermittedBuffer = Buffer.concat([
776
- (0, NumberToBuffer_1.UInt8ToBuffer)(4),
777
- (0, NumberToBuffer_1.UInt8ToBuffer)(2)
778
- ]);
779
- this.writeBytes(optionOffset, sackPermittedBuffer);
780
- optionOffset += sackPermittedBuffer.length;
781
- return;
782
- }
783
- case TCPOption.Selective_Acknowledgment: {
784
- const optionSack = optionItem;
785
- const kindBuffer = (0, NumberToBuffer_1.UInt8ToBuffer)(5);
786
- let length = 2;
787
- let blocksBuffer = Buffer.from([]);
788
- optionSack.blocks.forEach((block) => {
789
- blocksBuffer = Buffer.concat([blocksBuffer, (0, NumberToBuffer_1.UInt64ToBuffer)((0, HexToNumber_1.HexToUInt64)(block))]);
790
- });
791
- const sackBuffer = Buffer.concat([kindBuffer, (0, NumberToBuffer_1.UInt8ToBuffer)(length + blocksBuffer.length), blocksBuffer]);
792
- this.writeBytes(optionOffset, sackBuffer);
793
- optionOffset += sackBuffer.length;
794
- return;
795
- }
796
- case TCPOption.Timestamp: {
797
- const optionTS = optionItem;
798
- const tsBuffer = Buffer.concat([
799
- (0, NumberToBuffer_1.UInt8ToBuffer)(8),
800
- (0, NumberToBuffer_1.UInt8ToBuffer)(10),
801
- (0, NumberToBuffer_1.UInt32ToBuffer)(optionTS.tsval ? optionTS.tsval : 0),
802
- (0, NumberToBuffer_1.UInt32ToBuffer)(optionTS.tsecr ? optionTS.tsecr : 0)
803
- ]);
804
- this.writeBytes(optionOffset, tsBuffer);
805
- optionOffset += tsBuffer.length;
806
- return;
807
- }
808
- case TCPOption.User_Timeout: {
809
- const optionUTO = optionItem;
810
- const utoBuffer = Buffer.concat([
811
- (0, NumberToBuffer_1.UInt8ToBuffer)(28),
812
- (0, NumberToBuffer_1.UInt8ToBuffer)(5),
813
- (0, NumberToBuffer_1.UInt16ToBuffer)(optionUTO.timeout ? optionUTO.timeout : 0),
814
- (0, NumberToBuffer_1.UInt8ToBuffer)(optionUTO.granularity ? optionUTO.granularity : 0)
815
- ]);
816
- this.writeBytes(optionOffset, utoBuffer);
817
- optionOffset += utoBuffer.length;
818
- return;
819
- }
820
- case TCPOption.TCP_Authentication_Option: {
821
- const optionTcpAo = optionItem;
822
- const kindBuffer = (0, NumberToBuffer_1.UInt8ToBuffer)(29);
823
- const dataBuffer = Buffer.from(optionTcpAo.data, 'hex');
824
- const lengthBuffer = (0, NumberToBuffer_1.UInt8ToBuffer)(dataBuffer.length + 2);
825
- const tcpAoBuffer = Buffer.concat([kindBuffer, lengthBuffer, dataBuffer]);
826
- this.writeBytes(optionOffset, tcpAoBuffer);
827
- optionOffset += tcpAoBuffer.length;
828
- return;
829
- }
830
- default: {
831
- const defaultOptionItem = optionItem;
832
- const kind = defaultOptionItem.kind;
833
- const hexBuffer = Buffer.from(defaultOptionItem.data.toString(), 'hex');
834
- const length = hexBuffer.length + 2;
835
- const defaultOptionBuffer = Buffer.concat([(0, NumberToBuffer_1.UInt8ToBuffer)(kind), (0, NumberToBuffer_1.UInt8ToBuffer)(length), hexBuffer]);
836
- this.writeBytes(optionOffset, defaultOptionBuffer);
837
- optionOffset += defaultOptionBuffer.length;
838
- }
839
- }
840
- });
841
- if (this.length > 60)
842
- return this.recordError(this.instance.options.getPath(), 'Options too large');
843
- const headerBitLength = this.length * 8;
844
- if (headerBitLength % 4) {
845
- //Add Padding
846
- this.writeBytes(this.length, Buffer.from([0x00]));
847
- }
848
- }
849
- }
850
- }
851
- };
852
- this.id = 'tcp';
853
- this.name = 'Transmission Control Protocol';
854
- this.nickname = 'TCP';
855
- }
856
- /**
857
- * Calculate TCP Checksum
858
- * @param tcpHeaderBuffer
859
- * @protected
860
- */
861
- calculateTCPChecksum(tcpHeaderBuffer) {
862
- const tcpHeaderLength = tcpHeaderBuffer.length;
863
- const ipVersion = this.prevCodecModule.instance.version.getValue();
864
- let pseudoHeaderBuffer = Buffer.from([]);
865
- const sourceIp = this.prevCodecModule.instance.sip.getValue();
866
- const destinationIp = this.prevCodecModule.instance.dip.getValue();
867
- if (ipVersion === 4) {
868
- //4 Bytes
869
- const sourceIPv4Buffer = Buffer.from(sourceIp.split('.').map((value) => parseInt(value)));
870
- const destinationIPv4Buffer = Buffer.from(destinationIp.split('.').map((value) => parseInt(value)));
871
- //IPv4 Pseudo header
872
- pseudoHeaderBuffer = Buffer.concat([
873
- sourceIPv4Buffer,
874
- destinationIPv4Buffer,
875
- (0, NumberToBuffer_1.UInt8ToBuffer)(0), //Reserved field
876
- (0, NumberToBuffer_1.UInt8ToBuffer)(6), //Protocol type (TCP = 6)
877
- Buffer.from([(tcpHeaderLength >> 8) & 0xFF]),
878
- Buffer.from([tcpHeaderLength & 0xFF])
879
- ]);
880
- }
881
- else if (ipVersion === 6) {
882
- //16 Bytes
883
- const sourceIPv6Buffer = (0, IPToBuffer_1.IPv6ToBuffer)(sourceIp);
884
- const destinationIPv6Buffer = (0, IPToBuffer_1.IPv6ToBuffer)(destinationIp);
885
- //IPv6 Pseudo header
886
- pseudoHeaderBuffer = Buffer.concat([
887
- sourceIPv6Buffer,
888
- destinationIPv6Buffer,
889
- (0, NumberToBuffer_1.UInt8ToBuffer)(0), //Reserved field
890
- (0, NumberToBuffer_1.UInt8ToBuffer)(0), //Reserved field
891
- (0, NumberToBuffer_1.UInt8ToBuffer)(0), //Reserved field
892
- (0, NumberToBuffer_1.UInt8ToBuffer)(6), //Protocol type (TCP = 6)
893
- Buffer.from([(tcpHeaderLength >> 8) & 0xFF]),
894
- Buffer.from([tcpHeaderLength & 0xFF])
895
- ]);
896
- }
897
- else {
898
- return 0;
899
- }
900
- const dataBuffer = Buffer.concat([pseudoHeaderBuffer, tcpHeaderBuffer]);
901
- const data = Uint8Array.from(dataBuffer);
902
- let sum = 0;
903
- for (let i = 0; i < data.length; i += 2)
904
- sum += (data[i] << 8) + (data[i + 1] || 0);
905
- while (sum >>> 16)
906
- sum = (sum & 0xFFFF) + (sum >>> 16);
907
- return (~sum) & 0xFFFF;
908
- }
909
- match() {
910
- if (!this.prevCodecModule)
911
- return false;
912
- if (this.prevCodecModule.instance.protocol.getValue() === 0x06)
913
- return true;
914
- return false;
915
- }
916
- }
917
- exports.TCP = TCP;