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.
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 -57
  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 -975
  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 -497
  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 -899
  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 -35
  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 -1003
  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 -532
  366. package/src/lib/codec/headers/RawData.ts +0 -38
  367. package/src/lib/codec/headers/TCP.ts +0 -934
  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 -45
  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,975 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Goose = void 0;
7
- const BaseHeader_1 = require("../abstracts/BaseHeader");
8
- const node_tlv_1 = __importDefault(require("node-tlv"));
9
- const HexToNumber_1 = require("../../helper/HexToNumber");
10
- const NumberToBERHex_1 = require("../../helper/NumberToBERHex");
11
- const NumberToHex_1 = require("../../helper/NumberToHex");
12
- const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
13
- const NumberToBERBuffer_1 = require("../../helper/NumberToBERBuffer");
14
- const BufferToNumber_1 = require("../../helper/BufferToNumber");
15
- const NumberToBuffer_1 = require("../../helper/NumberToBuffer");
16
- const GetBERIntegerLengthFromBuffer_1 = require("../lib/GetBERIntegerLengthFromBuffer");
17
- var ItemDataType;
18
- (function (ItemDataType) {
19
- ItemDataType["Boolean"] = "Boolean";
20
- ItemDataType["INT8"] = "INT8";
21
- ItemDataType["INT16"] = "INT16";
22
- ItemDataType["INT32"] = "INT32";
23
- ItemDataType["INT64"] = "INT64";
24
- ItemDataType["INT8U"] = "INT8U";
25
- ItemDataType["INT16U"] = "INT16U";
26
- ItemDataType["INT32U"] = "INT32U";
27
- ItemDataType["FLOAT32"] = "FLOAT32";
28
- ItemDataType["CODEDENUM"] = "CODED-ENUM";
29
- ItemDataType["OCTETSTRING"] = "OCTET-STRING";
30
- ItemDataType["VISIBLESTRING"] = "VISIBLE-STRING";
31
- ItemDataType["TimeStamp"] = "TimeStamp";
32
- ItemDataType["Quality"] = "Quality";
33
- ItemDataType["Structure"] = "Structure";
34
- })(ItemDataType || (ItemDataType = {}));
35
- class Goose extends BaseHeader_1.BaseHeader {
36
- constructor() {
37
- super(...arguments);
38
- this.TLVChild = [];
39
- this.SCHEMA = {
40
- type: 'object',
41
- properties: {
42
- appid: {
43
- type: 'integer',
44
- minimum: 0,
45
- maximum: 65535,
46
- label: 'APPID',
47
- decode: () => {
48
- this.instance.appid.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(0, 2)));
49
- },
50
- encode: () => {
51
- const APPID = this.instance.appid.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
52
- this.instance.appid.setValue(APPID);
53
- this.writeBytes(0, (0, NumberToBuffer_1.UInt16ToBuffer)(APPID));
54
- }
55
- },
56
- length: {
57
- type: 'integer',
58
- minimum: 0,
59
- maximum: 65535,
60
- label: 'Length',
61
- decode: () => {
62
- this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
63
- },
64
- encode: () => {
65
- const length = this.instance.length.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
66
- if (length > 0) {
67
- this.instance.length.setValue(length);
68
- this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(length));
69
- }
70
- else {
71
- this.addPostSelfEncodeHandler(() => {
72
- const finalLength = parseInt(this.instance.length.getValue().toString());
73
- this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(finalLength));
74
- });
75
- }
76
- }
77
- },
78
- reserved1: {
79
- type: 'object',
80
- label: 'Reserved1',
81
- properties: {
82
- simulated: {
83
- type: 'boolean',
84
- label: 'Simulated',
85
- decode: () => {
86
- this.instance.reserved1.simulated.setValue(!!this.readBits(4, 2, 0, 1));
87
- },
88
- encode: () => {
89
- const simulated = this.instance.reserved1.simulated.getValue(false);
90
- this.writeBits(4, 2, 0, 1, simulated ? 1 : 0);
91
- }
92
- },
93
- reserved: {
94
- type: 'number',
95
- minimum: 0,
96
- maximum: 32767,
97
- label: 'Reserved',
98
- decode: () => {
99
- this.instance.reserved1.reserved.setValue(this.readBits(4, 2, 1, 16));
100
- },
101
- encode: () => {
102
- const reserved = this.instance.reserved1.reserved.getValue(0);
103
- this.writeBits(4, 2, 1, 16, reserved);
104
- }
105
- }
106
- }
107
- },
108
- reserved2: {
109
- type: 'object',
110
- label: 'Reserved2',
111
- properties: {
112
- reserved: {
113
- type: 'number',
114
- minimum: 0,
115
- maximum: 65535,
116
- label: 'Reserved',
117
- decode: () => {
118
- this.instance.reserved2.reserved.setValue(this.readBits(4, 2, 0, 16));
119
- },
120
- encode: () => {
121
- const reserved = this.instance.reserved2.reserved.getValue(0);
122
- this.writeBits(4, 2, 0, 16, reserved);
123
- }
124
- }
125
- }
126
- },
127
- goosePdu: {
128
- type: 'object',
129
- label: 'GOOSE PDU',
130
- decode: () => {
131
- let readTLVBufferLength = this.packet.length - this.startPos - 8;
132
- while (!this.TLVInstance) {
133
- try {
134
- const buffer = this.readBytes(8, readTLVBufferLength, true);
135
- this.TLVInstance = node_tlv_1.default.parse(buffer);
136
- const tagWithLength = buffer.toString('hex').replace(this.TLVInstance.bValue.toString('hex'), '#').split('#');
137
- const tagWithLengthBytes = Math.max(...tagWithLength.map((value) => Math.ceil(value.length / 2)));
138
- const TLVBufferLength = this.TLVInstance.bValue.length + tagWithLengthBytes;
139
- this.TLVInstance = node_tlv_1.default.parse(this.readBytes(8, TLVBufferLength, false));
140
- }
141
- catch (e) {
142
- readTLVBufferLength -= 1;
143
- if (!readTLVBufferLength)
144
- break;
145
- }
146
- }
147
- this.TLVChild = this.TLVInstance ? this.TLVInstance.getChild() : [];
148
- },
149
- encode: () => {
150
- let buffers = Buffer.from([]);
151
- this.TLVChild.forEach(item => buffers = Buffer.concat([buffers, item.bTag, item.bLength, item.bValue]));
152
- const goosePduTLV = new node_tlv_1.default(0x61, buffers);
153
- const goosePduBuffer = Buffer.concat([goosePduTLV.bTag, goosePduTLV.bLength, goosePduTLV.bValue]);
154
- this.writeBytes(8, goosePduBuffer);
155
- /**
156
- * Update the length only if it is not set
157
- * Update length(APPID's length + Length's length + Reserved1's length + Reserved2's length + goosePdu's length)
158
- */
159
- if (this.instance.length.getValue() > 0)
160
- return;
161
- this.instance.length.setValue(2 + 2 + 2 + 2 + goosePduBuffer.length);
162
- },
163
- properties: {
164
- gocbRef: {
165
- type: 'string',
166
- maxLength: 129,
167
- label: 'GoCBReference',
168
- contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.ASCII,
169
- decode: () => {
170
- const gocbRefTLV = this.TLVChild.find(tlv => tlv.getTag('number') === 0x80);
171
- if (!gocbRefTLV)
172
- return this.recordError(this.instance.goosePdu.gocbRef.getPath(), 'Not Found');
173
- this.instance.goosePdu.gocbRef.setValue(gocbRefTLV.getValue('buffer').toString('ascii'));
174
- },
175
- encode: () => {
176
- const gocbRefValue = this.instance.goosePdu.gocbRef.getValue('', (nodePath) => this.recordError(nodePath, 'Not Found'));
177
- if (!gocbRefValue)
178
- return;
179
- let gocbRefBuffer = Buffer.from(gocbRefValue, 'ascii');
180
- if (gocbRefBuffer.length > 129) {
181
- this.recordError(this.instance.goosePdu.gocbRef.getPath(), 'This VisibleString shall have a maximum size of 129 octets');
182
- gocbRefBuffer = gocbRefBuffer.subarray(0, 129);
183
- }
184
- this.TLVChild.push(new node_tlv_1.default(0x80, gocbRefBuffer));
185
- }
186
- },
187
- timeAllowedtoLive: {
188
- type: 'number',
189
- minimum: 0,
190
- maximum: 4294967295,
191
- label: 'TimeAllowedtoLive',
192
- decode: () => {
193
- const timeAllowedtoLiveString = this.TLVChild.find(tlv => tlv.getTag('number') === 0x81)?.getValue('hex');
194
- if (!timeAllowedtoLiveString)
195
- return this.recordError(this.instance.goosePdu.timeAllowedtoLive.getPath(), 'Not Found');
196
- this.instance.goosePdu.timeAllowedtoLive.setValue((0, HexToNumber_1.HexToUInt32)(timeAllowedtoLiveString));
197
- },
198
- encode: () => {
199
- let timeAllowedtoLiveValue = this.instance.goosePdu.timeAllowedtoLive.getValue(-1, (nodePath) => this.recordError(nodePath, 'Not Found'));
200
- if (timeAllowedtoLiveValue === -1)
201
- return;
202
- if (timeAllowedtoLiveValue < 1 || timeAllowedtoLiveValue > 4294967295) {
203
- this.recordError(this.instance.goosePdu.timeAllowedtoLive.getPath(), 'This INTEGER value shall have a range of 1 to 4294967295');
204
- timeAllowedtoLiveValue = 4294967295;
205
- }
206
- const timeAllowedtoLiveTLV = new node_tlv_1.default(0x81, (0, NumberToBERBuffer_1.UInt32ToBERBuffer)(timeAllowedtoLiveValue));
207
- this.TLVChild.push(timeAllowedtoLiveTLV);
208
- }
209
- },
210
- datSet: {
211
- type: 'string',
212
- maxLength: 129,
213
- label: 'DatSet',
214
- contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.ASCII,
215
- decode: () => {
216
- const datSetTLV = this.TLVChild.find(tlv => tlv.getTag('number') === 0x82);
217
- if (!datSetTLV)
218
- return this.recordError(this.instance.goosePdu.datSet.getPath(), 'Not Found');
219
- this.instance.goosePdu.datSet.setValue(datSetTLV.getValue('buffer').toString('ascii'));
220
- },
221
- encode: () => {
222
- const datSetValue = this.instance.goosePdu.datSet.getValue('', (nodePath) => this.recordError(nodePath, 'Not Found'));
223
- if (!datSetValue)
224
- return;
225
- let datSetBuffer = Buffer.from(datSetValue, 'ascii');
226
- if (datSetBuffer.length > 129) {
227
- this.recordError(this.instance.goosePdu.datSet.getPath(), 'This VisibleString shall have a maximum size of 129 octets');
228
- datSetBuffer = datSetBuffer.subarray(0, 129);
229
- }
230
- this.TLVChild.push(new node_tlv_1.default(0x82, datSetBuffer));
231
- }
232
- },
233
- goID: {
234
- type: 'string',
235
- maxLength: 65,
236
- label: 'GoID',
237
- contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.ASCII,
238
- decode: () => {
239
- const goIDTLV = this.TLVChild.find(tlv => tlv.getTag('number') === 0x83);
240
- if (!goIDTLV)
241
- return this.recordError(this.instance.goosePdu.goID.getPath(), 'Not Found');
242
- this.instance.goosePdu.goID.setValue(goIDTLV.getValue('buffer').toString('ascii'));
243
- },
244
- encode: () => {
245
- const goIDValue = this.instance.goosePdu.goID.getValue('', (nodePath) => this.recordError(nodePath, 'Not Found'));
246
- if (!goIDValue)
247
- return;
248
- let goIDBuffer = Buffer.from(goIDValue, 'ascii');
249
- if (goIDBuffer.length > 65) {
250
- this.recordError(this.instance.goosePdu.goID.getPath(), 'This VisibleString shall have a maximum size of 65 octets');
251
- goIDBuffer = goIDBuffer.subarray(0, 65);
252
- }
253
- this.TLVChild.push(new node_tlv_1.default(0x83, goIDBuffer));
254
- }
255
- },
256
- t: {
257
- type: 'string',
258
- label: 'TimeStamp',
259
- contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.BIGINT,
260
- decode: () => {
261
- const tStr = this.TLVChild.find(tlv => tlv.getTag('number') === 0x84)?.getValue('hex');
262
- if (!tStr)
263
- return this.recordError(this.instance.goosePdu.t.getPath(), 'Not Found');
264
- this.instance.goosePdu.t.setValue(BigInt(`0x${tStr}`).toString());
265
- },
266
- encode: () => {
267
- const tStr = this.instance.goosePdu.t.getValue('', (nodePath) => this.recordError(nodePath, 'Not Found'));
268
- if (!tStr)
269
- return;
270
- const tBigIntValue = BigInt(tStr);
271
- const tTLV = new node_tlv_1.default(0x84, Buffer.from(tBigIntValue.toString(16).padStart(8 * 2, '0'), 'hex'));
272
- this.TLVChild.push(tTLV);
273
- }
274
- },
275
- stNum: {
276
- type: 'integer',
277
- minimum: 0,
278
- maximum: 4294967295,
279
- label: 'StNum',
280
- decode: () => {
281
- const stNumStr = this.TLVChild.find(tlv => tlv.getTag('number') === 0x85)?.getValue('hex');
282
- if (!stNumStr)
283
- return this.recordError(this.instance.goosePdu.stNum.getPath(), 'Not Found');
284
- this.instance.goosePdu.stNum.setValue((0, HexToNumber_1.HexToUInt32)(stNumStr));
285
- if (this.instance.goosePdu.stNum.getValue() < 1 || this.instance.goosePdu.stNum.getValue() > 4294967295)
286
- this.recordError(this.instance.goosePdu.stNum.getPath(), 'This INTEGER value shall have a range of 1 to 4294967295');
287
- },
288
- encode: () => {
289
- let stNumValue = this.instance.goosePdu.stNum.getValue(-1, (nodePath) => this.recordError(nodePath, 'Not Found'));
290
- if (stNumValue < 0)
291
- return;
292
- if (stNumValue > 4294967295) {
293
- stNumValue = 4294967295;
294
- this.recordError(this.instance.goosePdu.stNum.getPath(), 'This INTEGER value shall have a range of 1 to 4294967295');
295
- }
296
- if (stNumValue === undefined)
297
- return this.recordError(this.instance.goosePdu.stNum.getPath(), 'Not Found');
298
- const stNumTLV = new node_tlv_1.default(0x85, (0, NumberToBERBuffer_1.UInt32ToBERBuffer)(stNumValue));
299
- this.TLVChild.push(stNumTLV);
300
- }
301
- },
302
- sqNum: {
303
- type: 'integer',
304
- minimum: 0,
305
- maximum: 4294967295,
306
- label: 'SqNum',
307
- decode: () => {
308
- const sqNumStr = this.TLVChild.find(tlv => tlv.getTag('number') === 0x86)?.getValue('hex');
309
- if (!sqNumStr)
310
- return this.recordError(this.instance.goosePdu.sqNum.getPath(), 'Not Found');
311
- this.instance.goosePdu.sqNum.setValue((0, HexToNumber_1.HexToUInt32)(sqNumStr));
312
- },
313
- encode: () => {
314
- let sqNumValue = this.instance.goosePdu.sqNum.getValue(-1, (nodePath) => this.recordError(nodePath, 'Not Found'));
315
- if (sqNumValue < 0)
316
- return;
317
- if (sqNumValue > 4294967295) {
318
- sqNumValue = 4294967295;
319
- this.recordError(this.instance.goosePdu.sqNum.getPath(), 'This INTEGER value shall have a range of 1 to 4294967295');
320
- }
321
- if (sqNumValue === undefined)
322
- return this.recordError(this.instance.goosePdu.sqNum.getPath(), 'Not Found');
323
- const sqNumTLV = new node_tlv_1.default(0x86, (0, NumberToBERBuffer_1.UInt32ToBERBuffer)(sqNumValue));
324
- this.TLVChild.push(sqNumTLV);
325
- }
326
- },
327
- simulation: {
328
- type: 'boolean',
329
- label: 'Simulation',
330
- decode: () => {
331
- const simulationStr = this.TLVChild.find(tlv => tlv.getTag('number') === 0x87)?.getValue('hex');
332
- if (!simulationStr)
333
- return this.recordError(this.instance.goosePdu.simulation.getPath(), 'Not Found');
334
- const simulationNum = parseInt(simulationStr, 16);
335
- if (simulationNum > 1)
336
- this.recordError(this.instance.goosePdu.simulation.getPath(), 'This Boolean shall have a range of TRUE, FALSE');
337
- this.instance.goosePdu.simulation.setValue(!!simulationNum);
338
- },
339
- encode: () => {
340
- const simulationValue = this.instance.goosePdu.simulation.getValue(undefined, (nodePath) => this.recordError(nodePath, 'Not Found'));
341
- if (simulationValue === undefined)
342
- return;
343
- const simulationNum = simulationValue ? 1 : 0;
344
- const simulationTLV = new node_tlv_1.default(0x87, Buffer.from(simulationNum.toString(16).padStart(2, '0'), 'hex'));
345
- this.TLVChild.push(simulationTLV);
346
- }
347
- },
348
- confRev: {
349
- type: 'integer',
350
- label: 'ConfRev',
351
- decode: () => {
352
- const confRevStr = this.TLVChild.find(tlv => tlv.getTag('number') === 0x88)?.getValue('hex');
353
- if (!confRevStr)
354
- return this.recordError(this.instance.goosePdu.confRev.getPath(), 'Not Found');
355
- this.instance.goosePdu.confRev.setValue((0, HexToNumber_1.HexToUInt32)(confRevStr));
356
- },
357
- encode: () => {
358
- let confRevValue = this.instance.goosePdu.confRev.getValue(-1, (nodePath) => this.recordError(nodePath, 'Not Found'));
359
- if (confRevValue > 4294967295) {
360
- confRevValue = 4294967295;
361
- this.recordError(this.instance.goosePdu.confRev.getPath(), 'This INTEGER value shall have a range of 0 to 4294967295');
362
- }
363
- if (confRevValue === -1)
364
- return;
365
- const confRevTLV = new node_tlv_1.default(0x88, (0, NumberToBERBuffer_1.UInt32ToBERBuffer)(confRevValue));
366
- this.TLVChild.push(confRevTLV);
367
- }
368
- },
369
- ndsCom: {
370
- type: 'boolean',
371
- label: 'NdsCom',
372
- decode: () => {
373
- const ndsComStr = this.TLVChild.find(tlv => tlv.getTag('number') === 0x89)?.getValue('hex');
374
- if (!ndsComStr)
375
- return this.recordError(this.instance.goosePdu.ndsCom.getPath(), 'Not Found');
376
- const ndsComNum = parseInt(ndsComStr, 16);
377
- if (ndsComNum > 1)
378
- this.recordError(this.instance.goosePdu.ndsCom.getPath(), 'This Boolean shall have a range of TRUE, FALSE');
379
- this.instance.goosePdu.ndsCom.setValue(!!ndsComNum);
380
- },
381
- encode: () => {
382
- const ndsComValue = this.instance.goosePdu.ndsCom.getValue(undefined, (nodePath) => this.recordError(nodePath, 'Not Found'));
383
- if (ndsComValue === undefined)
384
- return;
385
- const ndsComNum = ndsComValue ? 1 : 0;
386
- const ndsComTLV = new node_tlv_1.default(0x89, Buffer.from(ndsComNum.toString(16).padStart(2, '0'), 'hex'));
387
- this.TLVChild.push(ndsComTLV);
388
- }
389
- },
390
- numDatSetEntries: {
391
- type: 'integer',
392
- label: 'NumDatSetEntries',
393
- decode: () => {
394
- const numDatSetEntriesStr = this.TLVChild.find(tlv => tlv.getTag('number') === 0x8A)?.getValue('hex');
395
- if (!numDatSetEntriesStr)
396
- return this.recordError(this.instance.goosePdu.numDatSetEntries.getPath(), 'Not Found');
397
- this.instance.goosePdu.numDatSetEntries.setValue(parseInt(numDatSetEntriesStr, 16));
398
- },
399
- encode: () => {
400
- const numDatSetEntriesValue = this.instance.goosePdu.numDatSetEntries.getValue(undefined, (nodePath) => this.recordError(nodePath, 'Not Found'));
401
- if (numDatSetEntriesValue === undefined)
402
- return;
403
- const numDatSetEntriesTLV = new node_tlv_1.default(0x8A, (0, NumberToBERBuffer_1.UInt32ToBERBuffer)(numDatSetEntriesValue));
404
- this.TLVChild.push(numDatSetEntriesTLV);
405
- }
406
- },
407
- allData: {
408
- type: 'array',
409
- label: 'AllData',
410
- items: {
411
- anyOf: [
412
- {
413
- type: 'object',
414
- label: ItemDataType.Boolean,
415
- properties: {
416
- dataType: {
417
- type: 'string',
418
- label: 'DataType',
419
- enum: [ItemDataType.Boolean]
420
- },
421
- value: {
422
- type: 'boolean',
423
- label: 'Value'
424
- }
425
- }
426
- },
427
- {
428
- type: 'object',
429
- label: ItemDataType.INT8,
430
- properties: {
431
- dataType: {
432
- type: 'string',
433
- label: 'DataType',
434
- enum: [ItemDataType.INT8]
435
- },
436
- value: {
437
- type: 'integer',
438
- label: 'Value'
439
- }
440
- }
441
- },
442
- {
443
- type: 'object',
444
- label: ItemDataType.INT16,
445
- properties: {
446
- dataType: {
447
- type: 'string',
448
- label: 'DataType',
449
- enum: [ItemDataType.INT16]
450
- },
451
- value: {
452
- type: 'integer',
453
- label: 'Value'
454
- }
455
- }
456
- },
457
- {
458
- type: 'object',
459
- label: ItemDataType.INT32,
460
- properties: {
461
- dataType: {
462
- type: 'string',
463
- label: 'DataType',
464
- enum: [ItemDataType.INT32]
465
- },
466
- value: {
467
- type: 'integer',
468
- label: 'Value'
469
- }
470
- }
471
- },
472
- {
473
- type: 'object',
474
- label: ItemDataType.INT64,
475
- properties: {
476
- dataType: {
477
- type: 'string',
478
- label: 'DataType',
479
- enum: [ItemDataType.INT64]
480
- },
481
- value: {
482
- type: 'string',
483
- label: 'Value',
484
- contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.BIGINT
485
- }
486
- }
487
- },
488
- {
489
- type: 'object',
490
- label: ItemDataType.INT8U,
491
- properties: {
492
- dataType: {
493
- type: 'string',
494
- label: 'DataType',
495
- enum: [ItemDataType.INT8U]
496
- },
497
- value: {
498
- type: 'integer',
499
- label: 'Value'
500
- }
501
- }
502
- },
503
- {
504
- type: 'object',
505
- label: ItemDataType.INT16U,
506
- properties: {
507
- dataType: {
508
- type: 'string',
509
- label: 'DataType',
510
- enum: [ItemDataType.INT16U]
511
- },
512
- value: {
513
- type: 'integer',
514
- label: 'Value'
515
- }
516
- }
517
- },
518
- {
519
- type: 'object',
520
- label: ItemDataType.INT32U,
521
- properties: {
522
- dataType: {
523
- type: 'string',
524
- label: 'DataType',
525
- enum: [ItemDataType.INT32U]
526
- },
527
- value: {
528
- type: 'integer',
529
- label: 'Value'
530
- }
531
- }
532
- },
533
- {
534
- type: 'object',
535
- label: ItemDataType.FLOAT32,
536
- properties: {
537
- dataType: {
538
- type: 'string',
539
- label: 'DataType',
540
- enum: [ItemDataType.FLOAT32]
541
- },
542
- value: {
543
- type: 'number',
544
- label: 'Value'
545
- }
546
- }
547
- },
548
- {
549
- type: 'object',
550
- label: ItemDataType.CODEDENUM,
551
- properties: {
552
- dataType: {
553
- type: 'string',
554
- label: 'DataType',
555
- enum: [ItemDataType.CODEDENUM]
556
- },
557
- value: {
558
- type: 'integer',
559
- label: 'Value'
560
- }
561
- }
562
- },
563
- {
564
- type: 'object',
565
- label: ItemDataType.OCTETSTRING,
566
- properties: {
567
- dataType: {
568
- type: 'string',
569
- label: 'DataType',
570
- enum: [ItemDataType.OCTETSTRING]
571
- },
572
- value: {
573
- type: 'string',
574
- label: 'Value',
575
- contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX
576
- }
577
- }
578
- },
579
- {
580
- type: 'object',
581
- label: ItemDataType.VISIBLESTRING,
582
- properties: {
583
- dataType: {
584
- type: 'string',
585
- label: 'DataType',
586
- enum: [ItemDataType.VISIBLESTRING]
587
- },
588
- value: {
589
- type: 'string',
590
- label: 'Value',
591
- contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.ASCII
592
- }
593
- }
594
- },
595
- {
596
- type: 'object',
597
- label: ItemDataType.TimeStamp,
598
- properties: {
599
- dataType: {
600
- type: 'string',
601
- label: 'DataType',
602
- enum: [ItemDataType.TimeStamp]
603
- },
604
- value: {
605
- type: 'string',
606
- label: 'Value'
607
- }
608
- }
609
- },
610
- {
611
- type: 'object',
612
- label: ItemDataType.Quality,
613
- properties: {
614
- dataType: {
615
- type: 'string',
616
- label: 'DataType',
617
- enum: [ItemDataType.Quality]
618
- },
619
- value: {
620
- type: 'string',
621
- label: 'Value',
622
- contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.BINARY
623
- }
624
- }
625
- },
626
- {
627
- type: 'object',
628
- label: ItemDataType.Structure,
629
- properties: {
630
- dataType: {
631
- type: 'string',
632
- label: 'DataType',
633
- enum: [ItemDataType.Structure]
634
- },
635
- value: {
636
- $ref: '#/properties/goosePdu/properties/allData',
637
- label: 'Value'
638
- }
639
- }
640
- }
641
- ]
642
- },
643
- /**
644
- * +-----------------------------------+-------------------+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
645
- * | Data types according to IEC 61850-7-2 | ASN.1 Tag for Data | ASN.1 Length | Comments |
646
- * +-----------------------------------+-------------------+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
647
- * | Boolean | 0x83 | 1 | 8 Bit set to 0 FALSE; anything else = TRUE |
648
- * | INT8 | 0x85 | 2 | 8 Bit Big Endian; signed |
649
- * | INT16 | 0x85 | 3 | 16 Bit Big Endian; signed |
650
- * | INT32 | 0x85 | 5 | 32 Bit Big Endian; signed |
651
- * | INT64 | 0x85 | 9 | 64Bit Big Endian; signed |
652
- * | INT8U | 0x86 | 2 | 8 Bit Big Endian; unsigned |
653
- * | INT16U | 0x86 | 3 | 16 Bit Big Endian; unsigned |
654
- * | INT24U | - | - | Not used |
655
- * | INT32U | 0x86 | 5 | 32 Bit Big Endian; unsigned |
656
- * | FLOAT32 | 0x87 | 4 | 32 Bit IEEE Floating Point (IEEE 754) |
657
- * | CODED-ENUM | 0x84 | 2 | Bit-string; depending on CODED ENUM definition – most of the time, can be encoded with 2 bytes (1st Byte = number of unused bit, 2nd Byte = Value) |
658
- * | OCTET-STRING | 0x89 | 20 | 20 Bytes ASCII Text, Null terminated |
659
- * | VISIBLE-STRING | 0x8a | 35 | 35 Bytes ASCII Text, Null terminated |
660
- * | TimeStamp | 0x91 | 8 | 64 Bit TimeStamp as defined in 8.1.3.7 IEC 6 |
661
- * | Quality | 0x84 | 3 | Bit-string |
662
- * +-----------------------------------+-------------------+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
663
- */
664
- decode: () => {
665
- const allDataTLV = this.TLVChild.find(tlv => tlv.getTag('number') === 0xAB);
666
- const dataTLVs = allDataTLV ? allDataTLV.getChild() : [];
667
- const allData = this.decodeDataTLVItem(dataTLVs);
668
- if (allData.length)
669
- this.instance.goosePdu.allData.setValue(allData);
670
- },
671
- encode: () => {
672
- const allData = this.instance.goosePdu.allData.getValue([], (nodePath) => this.recordError(nodePath, 'Not Found'));
673
- const dataItemTLVs = this.encodeDataTLVItem(allData);
674
- if (dataItemTLVs.length) {
675
- const allDataTLV = new node_tlv_1.default(0xAB, Buffer.concat(dataItemTLVs.map((dataItemTLV) => Buffer.concat([dataItemTLV.bTag, dataItemTLV.bLength, dataItemTLV.bValue]))));
676
- this.TLVChild.push(allDataTLV);
677
- }
678
- }
679
- }
680
- }
681
- }
682
- }
683
- };
684
- this.id = 'goose';
685
- this.name = 'IEC61850 GOOSE';
686
- this.nickname = 'GOOSE';
687
- }
688
- /**
689
- * Decode data TLV items
690
- * @param dataTLVs
691
- * @protected
692
- */
693
- decodeDataTLVItem(dataTLVs) {
694
- const dataItems = [];
695
- dataTLVs.forEach((dataTLV) => {
696
- const length = dataTLV.getLength('number');
697
- const value = dataTLV.getValue('buffer');
698
- switch (dataTLV.getTag('number')) {
699
- case 0x83:
700
- {
701
- dataItems.push({
702
- dataType: ItemDataType.Boolean,
703
- value: !!parseInt(value.toString('hex'), 16)
704
- });
705
- }
706
- break;
707
- case 0x84:
708
- {
709
- switch (length) {
710
- case 2:
711
- {
712
- dataItems.push({
713
- dataType: ItemDataType.CODEDENUM,
714
- value: parseInt(value.toString('hex'), 16)
715
- });
716
- }
717
- break;
718
- case 3:
719
- {
720
- dataItems.push({
721
- dataType: ItemDataType.Quality,
722
- value: parseInt(value.toString('hex'), 16).toString(2).padStart(24, '0')
723
- });
724
- }
725
- break;
726
- }
727
- }
728
- break;
729
- case 0x85:
730
- {
731
- const integerRealLength = (0, GetBERIntegerLengthFromBuffer_1.GetBERIntegerLengthFromBuffer)(value);
732
- if (integerRealLength === 1) {
733
- dataItems.push({
734
- dataType: ItemDataType.INT8,
735
- value: (0, HexToNumber_1.HexToInt8)(value.toString('hex'))
736
- });
737
- }
738
- else if (integerRealLength === 2) {
739
- dataItems.push({
740
- dataType: ItemDataType.INT16,
741
- value: (0, HexToNumber_1.HexToInt16)(value.toString('hex'))
742
- });
743
- }
744
- else if (integerRealLength === 4) {
745
- dataItems.push({
746
- dataType: ItemDataType.INT32,
747
- value: (0, HexToNumber_1.HexToInt32)(value.toString('hex'))
748
- });
749
- }
750
- else if (integerRealLength === 8) {
751
- dataItems.push({
752
- dataType: ItemDataType.INT64,
753
- value: (0, HexToNumber_1.HexToInt64)(value.toString('hex'))
754
- });
755
- }
756
- }
757
- break;
758
- case 0x86:
759
- {
760
- const unsignedIntegerRealLength = (0, GetBERIntegerLengthFromBuffer_1.GetBERIntegerLengthFromBuffer)(value);
761
- switch (unsignedIntegerRealLength) {
762
- case 1:
763
- {
764
- dataItems.push({
765
- dataType: ItemDataType.INT8U,
766
- value: (0, HexToNumber_1.HexToUInt8)(value.toString('hex'))
767
- });
768
- }
769
- break;
770
- case 2:
771
- {
772
- dataItems.push({
773
- dataType: ItemDataType.INT16U,
774
- value: (0, HexToNumber_1.HexToUInt16)(value.toString('hex'))
775
- });
776
- }
777
- break;
778
- case 4:
779
- {
780
- dataItems.push({
781
- dataType: ItemDataType.INT32U,
782
- value: (0, HexToNumber_1.HexToUInt32)(value.toString('hex'))
783
- });
784
- }
785
- break;
786
- }
787
- }
788
- break;
789
- case 0x87:
790
- {
791
- dataItems.push({
792
- dataType: ItemDataType.FLOAT32,
793
- value: (0, HexToNumber_1.HexToFloat32)(value.toString('hex'))
794
- });
795
- }
796
- break;
797
- case 0x89:
798
- {
799
- dataItems.push({
800
- dataType: ItemDataType.OCTETSTRING,
801
- value: value.toString('hex')
802
- });
803
- }
804
- break;
805
- case 0x8a:
806
- {
807
- dataItems.push({
808
- dataType: ItemDataType.VISIBLESTRING,
809
- value: value.toString('ascii')
810
- });
811
- }
812
- break;
813
- case 0x91:
814
- {
815
- dataItems.push({
816
- dataType: ItemDataType.TimeStamp,
817
- value: parseInt(value.toString('hex'), 16).toString()
818
- });
819
- }
820
- break;
821
- case 0xa2:
822
- {
823
- const subDataTLVs = node_tlv_1.default.parseList(value);
824
- dataItems.push({
825
- dataType: ItemDataType.Structure,
826
- value: this.decodeDataTLVItem(subDataTLVs)
827
- });
828
- }
829
- break;
830
- }
831
- });
832
- return dataItems;
833
- }
834
- /**
835
- * Encode data TLV items
836
- * @param dataItems
837
- * @protected
838
- */
839
- encodeDataTLVItem(dataItems) {
840
- return dataItems
841
- .map((dataItem, index) => {
842
- const errorNodePath = this.instance.goosePdu.allData.getPath(index);
843
- switch (dataItem.dataType) {
844
- case ItemDataType.Boolean: {
845
- const booleanIntValue = dataItem.value ? 1 : 0;
846
- return new node_tlv_1.default(0x83, Buffer.from(booleanIntValue.toString(16).padStart(2, '0'), 'hex'));
847
- }
848
- case ItemDataType.INT8: {
849
- let intValue = dataItem.value;
850
- if (isNaN(intValue))
851
- this.recordError(errorNodePath, 'Invalid INT8 value');
852
- intValue = intValue ? intValue : 0;
853
- if (intValue < -128 || intValue > 127)
854
- this.recordError(errorNodePath, 'Invalid INT8 value');
855
- return new node_tlv_1.default(0x85, Buffer.from((0, NumberToBERHex_1.Int8ToBERHex)(intValue), 'hex'));
856
- }
857
- case ItemDataType.INT16: {
858
- let intValue = dataItem.value;
859
- if (isNaN(intValue))
860
- this.recordError(errorNodePath, 'Invalid INT16 value');
861
- intValue = intValue ? intValue : 0;
862
- if (intValue < -32768 || intValue > 32767)
863
- this.recordError(errorNodePath, 'Invalid INT16 value');
864
- return new node_tlv_1.default(0x85, Buffer.from((0, NumberToBERHex_1.Int16ToBERHex)(intValue), 'hex'));
865
- }
866
- case ItemDataType.INT32: {
867
- let intValue = dataItem.value;
868
- if (isNaN(intValue))
869
- this.recordError(errorNodePath, 'Invalid INT32 value');
870
- intValue = intValue ? intValue : 0;
871
- if (intValue < -2147483648 || intValue > 2147483647)
872
- this.recordError(errorNodePath, 'Invalid INT32 value');
873
- return new node_tlv_1.default(0x85, Buffer.from((0, NumberToBERHex_1.Int32ToBERHex)(intValue), 'hex'));
874
- }
875
- case ItemDataType.INT64: {
876
- const intValue = BigInt(dataItem.value);
877
- if (intValue < BigInt('-9223372036854775808') || intValue > BigInt('9223372036854775807'))
878
- this.recordError(errorNodePath, 'Invalid INT64 value');
879
- return new node_tlv_1.default(0x85, Buffer.from((0, NumberToBERHex_1.Int64ToBERHex)(intValue), 'hex'));
880
- }
881
- case ItemDataType.INT8U: {
882
- let uintValue = dataItem.value;
883
- if (isNaN(uintValue))
884
- this.recordError(errorNodePath, 'Invalid INT8U value');
885
- uintValue = uintValue ? uintValue : 0;
886
- if (uintValue < 0 || uintValue > 255)
887
- this.recordError(errorNodePath, 'Invalid INT8U value');
888
- return new node_tlv_1.default(0x86, Buffer.from((0, NumberToBERHex_1.UInt8ToBERHex)(uintValue), 'hex'));
889
- }
890
- case ItemDataType.INT16U: {
891
- let uintValue = dataItem.value;
892
- if (isNaN(uintValue))
893
- this.recordError(errorNodePath, 'Invalid INT16U value');
894
- uintValue = uintValue ? uintValue : 0;
895
- if (uintValue < 0 || uintValue > 65535)
896
- this.recordError(errorNodePath, 'Invalid INT16U value');
897
- return new node_tlv_1.default(0x86, Buffer.from((0, NumberToBERHex_1.UInt16ToBERHex)(uintValue), 'hex'));
898
- }
899
- case ItemDataType.INT32U: {
900
- let uintValue = dataItem.value;
901
- if (isNaN(uintValue))
902
- this.recordError(errorNodePath, 'Invalid INT32U value');
903
- uintValue = uintValue ? uintValue : 0;
904
- if (uintValue < 0 || uintValue > 4294967295)
905
- this.recordError(errorNodePath, 'Invalid INT32U value');
906
- return new node_tlv_1.default(0x86, Buffer.from((0, NumberToBERHex_1.UInt32ToBERHex)(uintValue), 'hex'));
907
- }
908
- case ItemDataType.FLOAT32: {
909
- let float32Value = dataItem.value;
910
- if (isNaN(float32Value))
911
- this.recordError(errorNodePath, 'Invalid FLOAT32 value');
912
- float32Value = float32Value ? float32Value : 0;
913
- return new node_tlv_1.default(0x87, Buffer.from((0, NumberToBERHex_1.Float32ToBERHex)(float32Value), 'hex'));
914
- }
915
- case ItemDataType.CODEDENUM: {
916
- let codedEnumValue = dataItem.value;
917
- if (isNaN(codedEnumValue))
918
- this.recordError(errorNodePath, 'Invalid CODED-ENUM value');
919
- codedEnumValue = codedEnumValue ? codedEnumValue : 0;
920
- return new node_tlv_1.default(0x84, Buffer.from((0, NumberToBERHex_1.UInt16ToBERHex)(codedEnumValue), 'hex'));
921
- }
922
- case ItemDataType.OCTETSTRING: {
923
- const hexText = dataItem.value;
924
- if (!hexText) {
925
- this.recordError(errorNodePath, 'Empty OCTET-STRING, ignored');
926
- return null;
927
- }
928
- if (hexText.length > 20)
929
- this.recordError(errorNodePath, 'OCTET-STRING too long');
930
- return new node_tlv_1.default(0x89, Buffer.from(hexText, 'hex').subarray(0, 20));
931
- }
932
- case ItemDataType.VISIBLESTRING: {
933
- const asciiText = dataItem.value;
934
- if (!asciiText) {
935
- this.recordError(errorNodePath, 'Empty VISIBLE-STRING, ignored');
936
- return null;
937
- }
938
- if (asciiText.length > 35)
939
- this.recordError(errorNodePath, 'VISIBLE-STRING too long');
940
- const hex = Buffer.from(asciiText, 'ascii').toString('hex').padStart(35 * 2);
941
- return new node_tlv_1.default(0x8a, Buffer.from(hex, 'hex').subarray(0, 35));
942
- }
943
- case ItemDataType.TimeStamp: {
944
- let timestamp = parseInt(dataItem.value);
945
- if (isNaN(timestamp))
946
- this.recordError(errorNodePath, 'Invalid TimeStamp value');
947
- timestamp = timestamp ? timestamp : 0;
948
- return new node_tlv_1.default(0x91, Buffer.from(timestamp.toString(16), 'hex'));
949
- }
950
- case ItemDataType.Quality: {
951
- const bitString = dataItem.value;
952
- let intValue = parseInt(bitString, 2);
953
- if (isNaN(intValue))
954
- this.recordError(errorNodePath, 'Invalid Quality value');
955
- intValue = intValue ? intValue : 0;
956
- return new node_tlv_1.default(0x84, Buffer.from(intValue.toString(16).padStart(3 * 2, '0'), 'hex'));
957
- }
958
- case ItemDataType.Structure: {
959
- return new node_tlv_1.default(0xa2, Buffer.concat(this.encodeDataTLVItem(dataItem.value).map((tlv) => Buffer.concat([tlv.bTag, tlv.bLength, tlv.bValue]))));
960
- }
961
- default: {
962
- this.recordError(errorNodePath, 'Invalid dataType, ignored');
963
- return null;
964
- }
965
- }
966
- })
967
- .filter((value) => !!value);
968
- }
969
- match() {
970
- if (!this.prevCodecModule)
971
- return false;
972
- return this.prevCodecModule.instance.etherType.getValue() === (0, NumberToHex_1.UInt16ToHex)(0x88b8);
973
- }
974
- }
975
- exports.Goose = Goose;