netkitty 0.0.35 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (428) hide show
  1. package/CHANGELOG.md +31 -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,1005 +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
- const: ItemDataType.Boolean,
421
- hidden: true
422
- },
423
- value: {
424
- type: 'boolean',
425
- label: 'Value'
426
- }
427
- }
428
- },
429
- {
430
- type: 'object',
431
- label: ItemDataType.INT8,
432
- properties: {
433
- dataType: {
434
- type: 'string',
435
- label: 'DataType',
436
- enum: [ItemDataType.INT8],
437
- const: ItemDataType.INT8,
438
- hidden: true
439
- },
440
- value: {
441
- type: 'integer',
442
- label: 'Value'
443
- }
444
- }
445
- },
446
- {
447
- type: 'object',
448
- label: ItemDataType.INT16,
449
- properties: {
450
- dataType: {
451
- type: 'string',
452
- label: 'DataType',
453
- enum: [ItemDataType.INT16],
454
- const: ItemDataType.INT16,
455
- hidden: true
456
- },
457
- value: {
458
- type: 'integer',
459
- label: 'Value'
460
- }
461
- }
462
- },
463
- {
464
- type: 'object',
465
- label: ItemDataType.INT32,
466
- properties: {
467
- dataType: {
468
- type: 'string',
469
- label: 'DataType',
470
- enum: [ItemDataType.INT32],
471
- const: ItemDataType.INT32,
472
- hidden: true
473
- },
474
- value: {
475
- type: 'integer',
476
- label: 'Value'
477
- }
478
- }
479
- },
480
- {
481
- type: 'object',
482
- label: ItemDataType.INT64,
483
- properties: {
484
- dataType: {
485
- type: 'string',
486
- label: 'DataType',
487
- enum: [ItemDataType.INT64],
488
- const: ItemDataType.INT64,
489
- hidden: true
490
- },
491
- value: {
492
- type: 'string',
493
- label: 'Value',
494
- contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.BIGINT
495
- }
496
- }
497
- },
498
- {
499
- type: 'object',
500
- label: ItemDataType.INT8U,
501
- properties: {
502
- dataType: {
503
- type: 'string',
504
- label: 'DataType',
505
- enum: [ItemDataType.INT8U],
506
- const: ItemDataType.INT8U,
507
- hidden: true
508
- },
509
- value: {
510
- type: 'integer',
511
- label: 'Value'
512
- }
513
- }
514
- },
515
- {
516
- type: 'object',
517
- label: ItemDataType.INT16U,
518
- properties: {
519
- dataType: {
520
- type: 'string',
521
- label: 'DataType',
522
- enum: [ItemDataType.INT16U],
523
- const: ItemDataType.INT16U,
524
- hidden: true
525
- },
526
- value: {
527
- type: 'integer',
528
- label: 'Value'
529
- }
530
- }
531
- },
532
- {
533
- type: 'object',
534
- label: ItemDataType.INT32U,
535
- properties: {
536
- dataType: {
537
- type: 'string',
538
- label: 'DataType',
539
- enum: [ItemDataType.INT32U],
540
- const: ItemDataType.INT32U,
541
- hidden: true
542
- },
543
- value: {
544
- type: 'integer',
545
- label: 'Value'
546
- }
547
- }
548
- },
549
- {
550
- type: 'object',
551
- label: ItemDataType.FLOAT32,
552
- properties: {
553
- dataType: {
554
- type: 'string',
555
- label: 'DataType',
556
- enum: [ItemDataType.FLOAT32],
557
- const: ItemDataType.FLOAT32,
558
- hidden: true
559
- },
560
- value: {
561
- type: 'number',
562
- label: 'Value'
563
- }
564
- }
565
- },
566
- {
567
- type: 'object',
568
- label: ItemDataType.CODEDENUM,
569
- properties: {
570
- dataType: {
571
- type: 'string',
572
- label: 'DataType',
573
- enum: [ItemDataType.CODEDENUM],
574
- const: ItemDataType.CODEDENUM,
575
- hidden: true
576
- },
577
- value: {
578
- type: 'integer',
579
- label: 'Value'
580
- }
581
- }
582
- },
583
- {
584
- type: 'object',
585
- label: ItemDataType.OCTETSTRING,
586
- properties: {
587
- dataType: {
588
- type: 'string',
589
- label: 'DataType',
590
- enum: [ItemDataType.OCTETSTRING],
591
- const: ItemDataType.OCTETSTRING,
592
- hidden: true
593
- },
594
- value: {
595
- type: 'string',
596
- label: 'Value',
597
- contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX
598
- }
599
- }
600
- },
601
- {
602
- type: 'object',
603
- label: ItemDataType.VISIBLESTRING,
604
- properties: {
605
- dataType: {
606
- type: 'string',
607
- label: 'DataType',
608
- enum: [ItemDataType.VISIBLESTRING],
609
- const: ItemDataType.VISIBLESTRING,
610
- hidden: true
611
- },
612
- value: {
613
- type: 'string',
614
- label: 'Value',
615
- contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.ASCII
616
- }
617
- }
618
- },
619
- {
620
- type: 'object',
621
- label: ItemDataType.TimeStamp,
622
- properties: {
623
- dataType: {
624
- type: 'string',
625
- label: 'DataType',
626
- enum: [ItemDataType.TimeStamp],
627
- const: ItemDataType.TimeStamp,
628
- hidden: true
629
- },
630
- value: {
631
- type: 'string',
632
- label: 'Value'
633
- }
634
- }
635
- },
636
- {
637
- type: 'object',
638
- label: ItemDataType.Quality,
639
- properties: {
640
- dataType: {
641
- type: 'string',
642
- label: 'DataType',
643
- enum: [ItemDataType.Quality],
644
- const: ItemDataType.Quality,
645
- hidden: true
646
- },
647
- value: {
648
- type: 'string',
649
- label: 'Value',
650
- contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.BINARY
651
- }
652
- }
653
- },
654
- {
655
- type: 'object',
656
- label: ItemDataType.Structure,
657
- properties: {
658
- dataType: {
659
- type: 'string',
660
- label: 'DataType',
661
- enum: [ItemDataType.Structure],
662
- const: ItemDataType.Structure,
663
- hidden: true
664
- },
665
- value: {
666
- $ref: '#/properties/goosePdu/properties/allData',
667
- label: 'Value'
668
- }
669
- }
670
- }
671
- ]
672
- },
673
- /**
674
- * +-----------------------------------+-------------------+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
675
- * | Data types according to IEC 61850-7-2 | ASN.1 Tag for Data | ASN.1 Length | Comments |
676
- * +-----------------------------------+-------------------+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
677
- * | Boolean | 0x83 | 1 | 8 Bit set to 0 FALSE; anything else = TRUE |
678
- * | INT8 | 0x85 | 2 | 8 Bit Big Endian; signed |
679
- * | INT16 | 0x85 | 3 | 16 Bit Big Endian; signed |
680
- * | INT32 | 0x85 | 5 | 32 Bit Big Endian; signed |
681
- * | INT64 | 0x85 | 9 | 64Bit Big Endian; signed |
682
- * | INT8U | 0x86 | 2 | 8 Bit Big Endian; unsigned |
683
- * | INT16U | 0x86 | 3 | 16 Bit Big Endian; unsigned |
684
- * | INT24U | - | - | Not used |
685
- * | INT32U | 0x86 | 5 | 32 Bit Big Endian; unsigned |
686
- * | FLOAT32 | 0x87 | 4 | 32 Bit IEEE Floating Point (IEEE 754) |
687
- * | 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) |
688
- * | OCTET-STRING | 0x89 | 20 | 20 Bytes ASCII Text, Null terminated |
689
- * | VISIBLE-STRING | 0x8a | 35 | 35 Bytes ASCII Text, Null terminated |
690
- * | TimeStamp | 0x91 | 8 | 64 Bit TimeStamp as defined in 8.1.3.7 IEC 6 |
691
- * | Quality | 0x84 | 3 | Bit-string |
692
- * +-----------------------------------+-------------------+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
693
- */
694
- decode: () => {
695
- const allDataTLV = this.TLVChild.find(tlv => tlv.getTag('number') === 0xAB);
696
- const dataTLVs = allDataTLV ? allDataTLV.getChild() : [];
697
- const allData = this.decodeDataTLVItem(dataTLVs);
698
- if (allData.length)
699
- this.instance.goosePdu.allData.setValue(allData);
700
- },
701
- encode: () => {
702
- const allData = this.instance.goosePdu.allData.getValue([], (nodePath) => this.recordError(nodePath, 'Not Found'));
703
- const dataItemTLVs = this.encodeDataTLVItem(allData);
704
- if (dataItemTLVs.length) {
705
- const allDataTLV = new node_tlv_1.default(0xAB, Buffer.concat(dataItemTLVs.map((dataItemTLV) => Buffer.concat([dataItemTLV.bTag, dataItemTLV.bLength, dataItemTLV.bValue]))));
706
- this.TLVChild.push(allDataTLV);
707
- }
708
- }
709
- }
710
- }
711
- }
712
- }
713
- };
714
- this.id = 'goose';
715
- this.name = 'IEC61850 GOOSE';
716
- this.nickname = 'GOOSE';
717
- }
718
- /**
719
- * Decode data TLV items
720
- * @param dataTLVs
721
- * @protected
722
- */
723
- decodeDataTLVItem(dataTLVs) {
724
- const dataItems = [];
725
- dataTLVs.forEach((dataTLV) => {
726
- const length = dataTLV.getLength('number');
727
- const value = dataTLV.getValue('buffer');
728
- switch (dataTLV.getTag('number')) {
729
- case 0x83:
730
- {
731
- dataItems.push({
732
- dataType: ItemDataType.Boolean,
733
- value: !!parseInt(value.toString('hex'), 16)
734
- });
735
- }
736
- break;
737
- case 0x84:
738
- {
739
- switch (length) {
740
- case 2:
741
- {
742
- dataItems.push({
743
- dataType: ItemDataType.CODEDENUM,
744
- value: parseInt(value.toString('hex'), 16)
745
- });
746
- }
747
- break;
748
- case 3:
749
- {
750
- dataItems.push({
751
- dataType: ItemDataType.Quality,
752
- value: parseInt(value.toString('hex'), 16).toString(2).padStart(24, '0')
753
- });
754
- }
755
- break;
756
- }
757
- }
758
- break;
759
- case 0x85:
760
- {
761
- const integerRealLength = (0, GetBERIntegerLengthFromBuffer_1.GetBERIntegerLengthFromBuffer)(value);
762
- if (integerRealLength === 1) {
763
- dataItems.push({
764
- dataType: ItemDataType.INT8,
765
- value: (0, HexToNumber_1.HexToInt8)(value.toString('hex'))
766
- });
767
- }
768
- else if (integerRealLength === 2) {
769
- dataItems.push({
770
- dataType: ItemDataType.INT16,
771
- value: (0, HexToNumber_1.HexToInt16)(value.toString('hex'))
772
- });
773
- }
774
- else if (integerRealLength === 4) {
775
- dataItems.push({
776
- dataType: ItemDataType.INT32,
777
- value: (0, HexToNumber_1.HexToInt32)(value.toString('hex'))
778
- });
779
- }
780
- else if (integerRealLength === 8) {
781
- dataItems.push({
782
- dataType: ItemDataType.INT64,
783
- value: (0, HexToNumber_1.HexToInt64)(value.toString('hex'))
784
- });
785
- }
786
- }
787
- break;
788
- case 0x86:
789
- {
790
- const unsignedIntegerRealLength = (0, GetBERIntegerLengthFromBuffer_1.GetBERIntegerLengthFromBuffer)(value);
791
- switch (unsignedIntegerRealLength) {
792
- case 1:
793
- {
794
- dataItems.push({
795
- dataType: ItemDataType.INT8U,
796
- value: (0, HexToNumber_1.HexToUInt8)(value.toString('hex'))
797
- });
798
- }
799
- break;
800
- case 2:
801
- {
802
- dataItems.push({
803
- dataType: ItemDataType.INT16U,
804
- value: (0, HexToNumber_1.HexToUInt16)(value.toString('hex'))
805
- });
806
- }
807
- break;
808
- case 4:
809
- {
810
- dataItems.push({
811
- dataType: ItemDataType.INT32U,
812
- value: (0, HexToNumber_1.HexToUInt32)(value.toString('hex'))
813
- });
814
- }
815
- break;
816
- }
817
- }
818
- break;
819
- case 0x87:
820
- {
821
- dataItems.push({
822
- dataType: ItemDataType.FLOAT32,
823
- value: (0, HexToNumber_1.HexToFloat32)(value.toString('hex'))
824
- });
825
- }
826
- break;
827
- case 0x89:
828
- {
829
- dataItems.push({
830
- dataType: ItemDataType.OCTETSTRING,
831
- value: value.toString('hex')
832
- });
833
- }
834
- break;
835
- case 0x8a:
836
- {
837
- dataItems.push({
838
- dataType: ItemDataType.VISIBLESTRING,
839
- value: value.toString('ascii')
840
- });
841
- }
842
- break;
843
- case 0x91:
844
- {
845
- dataItems.push({
846
- dataType: ItemDataType.TimeStamp,
847
- value: parseInt(value.toString('hex'), 16).toString()
848
- });
849
- }
850
- break;
851
- case 0xa2:
852
- {
853
- const subDataTLVs = node_tlv_1.default.parseList(value);
854
- dataItems.push({
855
- dataType: ItemDataType.Structure,
856
- value: this.decodeDataTLVItem(subDataTLVs)
857
- });
858
- }
859
- break;
860
- }
861
- });
862
- return dataItems;
863
- }
864
- /**
865
- * Encode data TLV items
866
- * @param dataItems
867
- * @protected
868
- */
869
- encodeDataTLVItem(dataItems) {
870
- return dataItems
871
- .map((dataItem, index) => {
872
- const errorNodePath = this.instance.goosePdu.allData.getPath(index);
873
- switch (dataItem.dataType) {
874
- case ItemDataType.Boolean: {
875
- const booleanIntValue = dataItem.value ? 1 : 0;
876
- return new node_tlv_1.default(0x83, Buffer.from(booleanIntValue.toString(16).padStart(2, '0'), 'hex'));
877
- }
878
- case ItemDataType.INT8: {
879
- let intValue = dataItem.value;
880
- if (isNaN(intValue))
881
- this.recordError(errorNodePath, 'Invalid INT8 value');
882
- intValue = intValue ? intValue : 0;
883
- if (intValue < -128 || intValue > 127)
884
- this.recordError(errorNodePath, 'Invalid INT8 value');
885
- return new node_tlv_1.default(0x85, Buffer.from((0, NumberToBERHex_1.Int8ToBERHex)(intValue), 'hex'));
886
- }
887
- case ItemDataType.INT16: {
888
- let intValue = dataItem.value;
889
- if (isNaN(intValue))
890
- this.recordError(errorNodePath, 'Invalid INT16 value');
891
- intValue = intValue ? intValue : 0;
892
- if (intValue < -32768 || intValue > 32767)
893
- this.recordError(errorNodePath, 'Invalid INT16 value');
894
- return new node_tlv_1.default(0x85, Buffer.from((0, NumberToBERHex_1.Int16ToBERHex)(intValue), 'hex'));
895
- }
896
- case ItemDataType.INT32: {
897
- let intValue = dataItem.value;
898
- if (isNaN(intValue))
899
- this.recordError(errorNodePath, 'Invalid INT32 value');
900
- intValue = intValue ? intValue : 0;
901
- if (intValue < -2147483648 || intValue > 2147483647)
902
- this.recordError(errorNodePath, 'Invalid INT32 value');
903
- return new node_tlv_1.default(0x85, Buffer.from((0, NumberToBERHex_1.Int32ToBERHex)(intValue), 'hex'));
904
- }
905
- case ItemDataType.INT64: {
906
- const intValue = BigInt(dataItem.value);
907
- if (intValue < BigInt('-9223372036854775808') || intValue > BigInt('9223372036854775807'))
908
- this.recordError(errorNodePath, 'Invalid INT64 value');
909
- return new node_tlv_1.default(0x85, Buffer.from((0, NumberToBERHex_1.Int64ToBERHex)(intValue), 'hex'));
910
- }
911
- case ItemDataType.INT8U: {
912
- let uintValue = dataItem.value;
913
- if (isNaN(uintValue))
914
- this.recordError(errorNodePath, 'Invalid INT8U value');
915
- uintValue = uintValue ? uintValue : 0;
916
- if (uintValue < 0 || uintValue > 255)
917
- this.recordError(errorNodePath, 'Invalid INT8U value');
918
- return new node_tlv_1.default(0x86, Buffer.from((0, NumberToBERHex_1.UInt8ToBERHex)(uintValue), 'hex'));
919
- }
920
- case ItemDataType.INT16U: {
921
- let uintValue = dataItem.value;
922
- if (isNaN(uintValue))
923
- this.recordError(errorNodePath, 'Invalid INT16U value');
924
- uintValue = uintValue ? uintValue : 0;
925
- if (uintValue < 0 || uintValue > 65535)
926
- this.recordError(errorNodePath, 'Invalid INT16U value');
927
- return new node_tlv_1.default(0x86, Buffer.from((0, NumberToBERHex_1.UInt16ToBERHex)(uintValue), 'hex'));
928
- }
929
- case ItemDataType.INT32U: {
930
- let uintValue = dataItem.value;
931
- if (isNaN(uintValue))
932
- this.recordError(errorNodePath, 'Invalid INT32U value');
933
- uintValue = uintValue ? uintValue : 0;
934
- if (uintValue < 0 || uintValue > 4294967295)
935
- this.recordError(errorNodePath, 'Invalid INT32U value');
936
- return new node_tlv_1.default(0x86, Buffer.from((0, NumberToBERHex_1.UInt32ToBERHex)(uintValue), 'hex'));
937
- }
938
- case ItemDataType.FLOAT32: {
939
- let float32Value = dataItem.value;
940
- if (isNaN(float32Value))
941
- this.recordError(errorNodePath, 'Invalid FLOAT32 value');
942
- float32Value = float32Value ? float32Value : 0;
943
- return new node_tlv_1.default(0x87, Buffer.from((0, NumberToBERHex_1.Float32ToBERHex)(float32Value), 'hex'));
944
- }
945
- case ItemDataType.CODEDENUM: {
946
- let codedEnumValue = dataItem.value;
947
- if (isNaN(codedEnumValue))
948
- this.recordError(errorNodePath, 'Invalid CODED-ENUM value');
949
- codedEnumValue = codedEnumValue ? codedEnumValue : 0;
950
- return new node_tlv_1.default(0x84, Buffer.from((0, NumberToBERHex_1.UInt16ToBERHex)(codedEnumValue), 'hex'));
951
- }
952
- case ItemDataType.OCTETSTRING: {
953
- const hexText = dataItem.value;
954
- if (!hexText) {
955
- this.recordError(errorNodePath, 'Empty OCTET-STRING, ignored');
956
- return null;
957
- }
958
- if (hexText.length > 20)
959
- this.recordError(errorNodePath, 'OCTET-STRING too long');
960
- return new node_tlv_1.default(0x89, Buffer.from(hexText, 'hex').subarray(0, 20));
961
- }
962
- case ItemDataType.VISIBLESTRING: {
963
- const asciiText = dataItem.value;
964
- if (!asciiText) {
965
- this.recordError(errorNodePath, 'Empty VISIBLE-STRING, ignored');
966
- return null;
967
- }
968
- if (asciiText.length > 35)
969
- this.recordError(errorNodePath, 'VISIBLE-STRING too long');
970
- const hex = Buffer.from(asciiText, 'ascii').toString('hex').padStart(35 * 2);
971
- return new node_tlv_1.default(0x8a, Buffer.from(hex, 'hex').subarray(0, 35));
972
- }
973
- case ItemDataType.TimeStamp: {
974
- let timestamp = parseInt(dataItem.value);
975
- if (isNaN(timestamp))
976
- this.recordError(errorNodePath, 'Invalid TimeStamp value');
977
- timestamp = timestamp ? timestamp : 0;
978
- return new node_tlv_1.default(0x91, Buffer.from(timestamp.toString(16), 'hex'));
979
- }
980
- case ItemDataType.Quality: {
981
- const bitString = dataItem.value;
982
- let intValue = parseInt(bitString, 2);
983
- if (isNaN(intValue))
984
- this.recordError(errorNodePath, 'Invalid Quality value');
985
- intValue = intValue ? intValue : 0;
986
- return new node_tlv_1.default(0x84, Buffer.from(intValue.toString(16).padStart(3 * 2, '0'), 'hex'));
987
- }
988
- case ItemDataType.Structure: {
989
- return new node_tlv_1.default(0xa2, Buffer.concat(this.encodeDataTLVItem(dataItem.value).map((tlv) => Buffer.concat([tlv.bTag, tlv.bLength, tlv.bValue]))));
990
- }
991
- default: {
992
- this.recordError(errorNodePath, 'Invalid dataType, ignored');
993
- return null;
994
- }
995
- }
996
- })
997
- .filter((value) => !!value);
998
- }
999
- match() {
1000
- if (!this.prevCodecModule)
1001
- return false;
1002
- return this.prevCodecModule.instance.etherType.getValue() === (0, NumberToHex_1.UInt16ToHex)(0x88b8);
1003
- }
1004
- }
1005
- exports.Goose = Goose;