@netkitty/codec 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 (463) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +21 -0
  3. package/README.md +352 -0
  4. package/README.zh-CN.md +342 -0
  5. package/dist/Codec.d.ts +133 -0
  6. package/dist/Codec.js +632 -0
  7. package/dist/PacketHeaders.d.ts +189 -0
  8. package/dist/PacketHeaders.js +384 -0
  9. package/dist/abstracts/BaseHeader.d.ts +325 -0
  10. package/dist/abstracts/BaseHeader.js +734 -0
  11. package/dist/errors/CodecSchemaValidateError.d.ts +4 -0
  12. package/dist/errors/CodecSchemaValidateError.js +11 -0
  13. package/dist/headers/ADSAMS.d.ts +33 -0
  14. package/dist/headers/ADSAMS.js +208 -0
  15. package/dist/headers/AH.d.ts +28 -0
  16. package/dist/headers/AH.js +137 -0
  17. package/dist/headers/AMQP.d.ts +31 -0
  18. package/dist/headers/AMQP.js +316 -0
  19. package/dist/headers/ARP.d.ts +26 -0
  20. package/dist/headers/ARP.js +243 -0
  21. package/dist/headers/BACnetIP.d.ts +27 -0
  22. package/dist/headers/BACnetIP.js +97 -0
  23. package/dist/headers/BFD.d.ts +28 -0
  24. package/dist/headers/BFD.js +155 -0
  25. package/dist/headers/BGP.d.ts +27 -0
  26. package/dist/headers/BGP.js +111 -0
  27. package/dist/headers/BSAPIP.d.ts +33 -0
  28. package/dist/headers/BSAPIP.js +78 -0
  29. package/dist/headers/Babel.d.ts +32 -0
  30. package/dist/headers/Babel.js +224 -0
  31. package/dist/headers/BitTorrent.d.ts +28 -0
  32. package/dist/headers/BitTorrent.js +72 -0
  33. package/dist/headers/C37118.d.ts +26 -0
  34. package/dist/headers/C37118.js +147 -0
  35. package/dist/headers/CAPWAP.d.ts +38 -0
  36. package/dist/headers/CAPWAP.js +275 -0
  37. package/dist/headers/CDP.d.ts +25 -0
  38. package/dist/headers/CDP.js +117 -0
  39. package/dist/headers/CMS.d.ts +33 -0
  40. package/dist/headers/CMS.js +238 -0
  41. package/dist/headers/COTP.d.ts +30 -0
  42. package/dist/headers/COTP.js +193 -0
  43. package/dist/headers/CassandraCQL.d.ts +28 -0
  44. package/dist/headers/CassandraCQL.js +117 -0
  45. package/dist/headers/CoAP.d.ts +29 -0
  46. package/dist/headers/CoAP.js +140 -0
  47. package/dist/headers/Codesys.d.ts +32 -0
  48. package/dist/headers/Codesys.js +119 -0
  49. package/dist/headers/Collectd.d.ts +29 -0
  50. package/dist/headers/Collectd.js +154 -0
  51. package/dist/headers/DCCP.d.ts +30 -0
  52. package/dist/headers/DCCP.js +204 -0
  53. package/dist/headers/DHCP.d.ts +26 -0
  54. package/dist/headers/DHCP.js +148 -0
  55. package/dist/headers/DHCPFailover.d.ts +30 -0
  56. package/dist/headers/DHCPFailover.js +104 -0
  57. package/dist/headers/DHCPv6.d.ts +25 -0
  58. package/dist/headers/DHCPv6.js +145 -0
  59. package/dist/headers/DNP3.d.ts +27 -0
  60. package/dist/headers/DNP3.js +150 -0
  61. package/dist/headers/DNS.d.ts +55 -0
  62. package/dist/headers/DNS.js +309 -0
  63. package/dist/headers/DTLS.d.ts +33 -0
  64. package/dist/headers/DTLS.js +142 -0
  65. package/dist/headers/Diameter.d.ts +34 -0
  66. package/dist/headers/Diameter.js +229 -0
  67. package/dist/headers/EAPOL.d.ts +32 -0
  68. package/dist/headers/EAPOL.js +135 -0
  69. package/dist/headers/EIGRP.d.ts +28 -0
  70. package/dist/headers/EIGRP.js +165 -0
  71. package/dist/headers/ENIP.d.ts +31 -0
  72. package/dist/headers/ENIP.js +164 -0
  73. package/dist/headers/ESP.d.ts +27 -0
  74. package/dist/headers/ESP.js +140 -0
  75. package/dist/headers/Elasticsearch.d.ts +30 -0
  76. package/dist/headers/Elasticsearch.js +125 -0
  77. package/dist/headers/EtherCAT.d.ts +35 -0
  78. package/dist/headers/EtherCAT.js +150 -0
  79. package/dist/headers/EthernetII.d.ts +28 -0
  80. package/dist/headers/EthernetII.js +117 -0
  81. package/dist/headers/FCoE.d.ts +38 -0
  82. package/dist/headers/FCoE.js +210 -0
  83. package/dist/headers/FTP.d.ts +34 -0
  84. package/dist/headers/FTP.js +158 -0
  85. package/dist/headers/Finger.d.ts +41 -0
  86. package/dist/headers/Finger.js +135 -0
  87. package/dist/headers/FoundationFieldbusHSE.d.ts +43 -0
  88. package/dist/headers/FoundationFieldbusHSE.js +163 -0
  89. package/dist/headers/GELF.d.ts +35 -0
  90. package/dist/headers/GELF.js +261 -0
  91. package/dist/headers/GENEVE.d.ts +26 -0
  92. package/dist/headers/GENEVE.js +209 -0
  93. package/dist/headers/GESRTP.d.ts +32 -0
  94. package/dist/headers/GESRTP.js +141 -0
  95. package/dist/headers/GLBP.d.ts +29 -0
  96. package/dist/headers/GLBP.js +159 -0
  97. package/dist/headers/GRE.d.ts +27 -0
  98. package/dist/headers/GRE.js +181 -0
  99. package/dist/headers/GTPU.d.ts +25 -0
  100. package/dist/headers/GTPU.js +203 -0
  101. package/dist/headers/GTPv2C.d.ts +30 -0
  102. package/dist/headers/GTPv2C.js +281 -0
  103. package/dist/headers/GitProtocol.d.ts +34 -0
  104. package/dist/headers/GitProtocol.js +141 -0
  105. package/dist/headers/Goose.d.ts +115 -0
  106. package/dist/headers/Goose.js +1067 -0
  107. package/dist/headers/Gopher.d.ts +43 -0
  108. package/dist/headers/Gopher.js +182 -0
  109. package/dist/headers/HARTIP.d.ts +30 -0
  110. package/dist/headers/HARTIP.js +145 -0
  111. package/dist/headers/HSR.d.ts +27 -0
  112. package/dist/headers/HSR.js +105 -0
  113. package/dist/headers/HSRP.d.ts +26 -0
  114. package/dist/headers/HSRP.js +173 -0
  115. package/dist/headers/HTTP.d.ts +32 -0
  116. package/dist/headers/HTTP.js +153 -0
  117. package/dist/headers/HTTP2.d.ts +34 -0
  118. package/dist/headers/HTTP2.js +190 -0
  119. package/dist/headers/IAX2.d.ts +33 -0
  120. package/dist/headers/IAX2.js +274 -0
  121. package/dist/headers/ICMP.d.ts +15 -0
  122. package/dist/headers/ICMP.js +148 -0
  123. package/dist/headers/ICMPv6.d.ts +15 -0
  124. package/dist/headers/ICMPv6.js +129 -0
  125. package/dist/headers/IEC104_I_Frame.d.ts +23 -0
  126. package/dist/headers/IEC104_I_Frame.js +6489 -0
  127. package/dist/headers/IEC104_S_Frame.d.ts +26 -0
  128. package/dist/headers/IEC104_S_Frame.js +135 -0
  129. package/dist/headers/IEC104_U_Frame.d.ts +27 -0
  130. package/dist/headers/IEC104_U_Frame.js +176 -0
  131. package/dist/headers/IEC61850SampledValues.d.ts +20 -0
  132. package/dist/headers/IEC61850SampledValues.js +420 -0
  133. package/dist/headers/IGMP.d.ts +31 -0
  134. package/dist/headers/IGMP.js +274 -0
  135. package/dist/headers/IMAP.d.ts +32 -0
  136. package/dist/headers/IMAP.js +185 -0
  137. package/dist/headers/IPFIX.d.ts +29 -0
  138. package/dist/headers/IPFIX.js +156 -0
  139. package/dist/headers/IPv4.d.ts +20 -0
  140. package/dist/headers/IPv4.js +370 -0
  141. package/dist/headers/IPv6.d.ts +29 -0
  142. package/dist/headers/IPv6.js +209 -0
  143. package/dist/headers/IPv6HopByHopOptions.d.ts +81 -0
  144. package/dist/headers/IPv6HopByHopOptions.js +495 -0
  145. package/dist/headers/IRC.d.ts +34 -0
  146. package/dist/headers/IRC.js +175 -0
  147. package/dist/headers/ISAKMP.d.ts +29 -0
  148. package/dist/headers/ISAKMP.js +197 -0
  149. package/dist/headers/ISCSI.d.ts +39 -0
  150. package/dist/headers/ISCSI.js +289 -0
  151. package/dist/headers/ISIS.d.ts +25 -0
  152. package/dist/headers/ISIS.js +79 -0
  153. package/dist/headers/ISOSession.d.ts +27 -0
  154. package/dist/headers/ISOSession.js +343 -0
  155. package/dist/headers/Ident.d.ts +42 -0
  156. package/dist/headers/Ident.js +184 -0
  157. package/dist/headers/KNXnetIP.d.ts +30 -0
  158. package/dist/headers/KNXnetIP.js +135 -0
  159. package/dist/headers/Kafka.d.ts +35 -0
  160. package/dist/headers/Kafka.js +128 -0
  161. package/dist/headers/Kerberos.d.ts +30 -0
  162. package/dist/headers/Kerberos.js +217 -0
  163. package/dist/headers/L2TP.d.ts +26 -0
  164. package/dist/headers/L2TP.js +297 -0
  165. package/dist/headers/LACP.d.ts +31 -0
  166. package/dist/headers/LACP.js +151 -0
  167. package/dist/headers/LDAP.d.ts +31 -0
  168. package/dist/headers/LDAP.js +226 -0
  169. package/dist/headers/LDP.d.ts +31 -0
  170. package/dist/headers/LDP.js +138 -0
  171. package/dist/headers/LISP.d.ts +30 -0
  172. package/dist/headers/LISP.js +103 -0
  173. package/dist/headers/LLC.d.ts +27 -0
  174. package/dist/headers/LLC.js +81 -0
  175. package/dist/headers/LLDP.d.ts +26 -0
  176. package/dist/headers/LLDP.js +126 -0
  177. package/dist/headers/LLMNR.d.ts +23 -0
  178. package/dist/headers/LLMNR.js +40 -0
  179. package/dist/headers/LPD.d.ts +31 -0
  180. package/dist/headers/LPD.js +159 -0
  181. package/dist/headers/MACsec.d.ts +34 -0
  182. package/dist/headers/MACsec.js +178 -0
  183. package/dist/headers/MDNS.d.ts +26 -0
  184. package/dist/headers/MDNS.js +45 -0
  185. package/dist/headers/MGCP.d.ts +30 -0
  186. package/dist/headers/MGCP.js +155 -0
  187. package/dist/headers/MMS.d.ts +29 -0
  188. package/dist/headers/MMS.js +243 -0
  189. package/dist/headers/MPLS.d.ts +31 -0
  190. package/dist/headers/MPLS.js +145 -0
  191. package/dist/headers/MQTT.d.ts +30 -0
  192. package/dist/headers/MQTT.js +173 -0
  193. package/dist/headers/MQTTSN.d.ts +34 -0
  194. package/dist/headers/MQTTSN.js +177 -0
  195. package/dist/headers/MarkerProtocol.d.ts +32 -0
  196. package/dist/headers/MarkerProtocol.js +153 -0
  197. package/dist/headers/Megaco.d.ts +32 -0
  198. package/dist/headers/Megaco.js +144 -0
  199. package/dist/headers/Memcached.d.ts +44 -0
  200. package/dist/headers/Memcached.js +285 -0
  201. package/dist/headers/ModbusTCP.d.ts +25 -0
  202. package/dist/headers/ModbusTCP.js +99 -0
  203. package/dist/headers/ModbusUDP.d.ts +26 -0
  204. package/dist/headers/ModbusUDP.js +100 -0
  205. package/dist/headers/MongoDB.d.ts +33 -0
  206. package/dist/headers/MongoDB.js +143 -0
  207. package/dist/headers/MySQL.d.ts +30 -0
  208. package/dist/headers/MySQL.js +114 -0
  209. package/dist/headers/NATS.d.ts +29 -0
  210. package/dist/headers/NATS.js +135 -0
  211. package/dist/headers/NBDS.d.ts +34 -0
  212. package/dist/headers/NBDS.js +176 -0
  213. package/dist/headers/NBNS.d.ts +34 -0
  214. package/dist/headers/NBNS.js +78 -0
  215. package/dist/headers/NBSS.d.ts +36 -0
  216. package/dist/headers/NBSS.js +137 -0
  217. package/dist/headers/NFS.d.ts +36 -0
  218. package/dist/headers/NFS.js +273 -0
  219. package/dist/headers/NHRP.d.ts +32 -0
  220. package/dist/headers/NHRP.js +154 -0
  221. package/dist/headers/NNTP.d.ts +35 -0
  222. package/dist/headers/NNTP.js +162 -0
  223. package/dist/headers/NTP.d.ts +18 -0
  224. package/dist/headers/NTP.js +73 -0
  225. package/dist/headers/NetFlowV5.d.ts +28 -0
  226. package/dist/headers/NetFlowV5.js +205 -0
  227. package/dist/headers/OLSR.d.ts +31 -0
  228. package/dist/headers/OLSR.js +213 -0
  229. package/dist/headers/OPCUA.d.ts +33 -0
  230. package/dist/headers/OPCUA.js +165 -0
  231. package/dist/headers/OPCUAPubSub.d.ts +33 -0
  232. package/dist/headers/OPCUAPubSub.js +144 -0
  233. package/dist/headers/OSPF.d.ts +31 -0
  234. package/dist/headers/OSPF.js +365 -0
  235. package/dist/headers/OmronFINS.d.ts +31 -0
  236. package/dist/headers/OmronFINS.js +90 -0
  237. package/dist/headers/OpenFlow.d.ts +30 -0
  238. package/dist/headers/OpenFlow.js +113 -0
  239. package/dist/headers/OpenVPN.d.ts +35 -0
  240. package/dist/headers/OpenVPN.js +214 -0
  241. package/dist/headers/PCWorx.d.ts +35 -0
  242. package/dist/headers/PCWorx.js +115 -0
  243. package/dist/headers/PIM.d.ts +27 -0
  244. package/dist/headers/PIM.js +129 -0
  245. package/dist/headers/POP3.d.ts +31 -0
  246. package/dist/headers/POP3.js +152 -0
  247. package/dist/headers/POWERLINK.d.ts +28 -0
  248. package/dist/headers/POWERLINK.js +116 -0
  249. package/dist/headers/PPPoEDiscovery.d.ts +29 -0
  250. package/dist/headers/PPPoEDiscovery.js +198 -0
  251. package/dist/headers/PPPoESession.d.ts +28 -0
  252. package/dist/headers/PPPoESession.js +125 -0
  253. package/dist/headers/PPTP.d.ts +30 -0
  254. package/dist/headers/PPTP.js +122 -0
  255. package/dist/headers/PROFINETRT.d.ts +28 -0
  256. package/dist/headers/PROFINETRT.js +74 -0
  257. package/dist/headers/PTP.d.ts +34 -0
  258. package/dist/headers/PTP.js +213 -0
  259. package/dist/headers/PostgreSQL.d.ts +40 -0
  260. package/dist/headers/PostgreSQL.js +236 -0
  261. package/dist/headers/QUIC.d.ts +34 -0
  262. package/dist/headers/QUIC.js +308 -0
  263. package/dist/headers/RADIUS.d.ts +24 -0
  264. package/dist/headers/RADIUS.js +138 -0
  265. package/dist/headers/RDP.d.ts +27 -0
  266. package/dist/headers/RDP.js +93 -0
  267. package/dist/headers/RFB.d.ts +39 -0
  268. package/dist/headers/RFB.js +151 -0
  269. package/dist/headers/RGoose.d.ts +72 -0
  270. package/dist/headers/RGoose.js +340 -0
  271. package/dist/headers/RIP.d.ts +29 -0
  272. package/dist/headers/RIP.js +133 -0
  273. package/dist/headers/RIPng.d.ts +26 -0
  274. package/dist/headers/RIPng.js +140 -0
  275. package/dist/headers/RMCP.d.ts +26 -0
  276. package/dist/headers/RMCP.js +155 -0
  277. package/dist/headers/RSVP.d.ts +31 -0
  278. package/dist/headers/RSVP.js +263 -0
  279. package/dist/headers/RTCP.d.ts +34 -0
  280. package/dist/headers/RTCP.js +217 -0
  281. package/dist/headers/RTP.d.ts +33 -0
  282. package/dist/headers/RTP.js +291 -0
  283. package/dist/headers/RTPS.d.ts +33 -0
  284. package/dist/headers/RTPS.js +182 -0
  285. package/dist/headers/RTSP.d.ts +36 -0
  286. package/dist/headers/RTSP.js +184 -0
  287. package/dist/headers/RawData.d.ts +17 -0
  288. package/dist/headers/RawData.js +43 -0
  289. package/dist/headers/Redis.d.ts +32 -0
  290. package/dist/headers/Redis.js +202 -0
  291. package/dist/headers/Rlogin.d.ts +42 -0
  292. package/dist/headers/Rlogin.js +139 -0
  293. package/dist/headers/Rsync.d.ts +28 -0
  294. package/dist/headers/Rsync.js +117 -0
  295. package/dist/headers/S7comm.d.ts +36 -0
  296. package/dist/headers/S7comm.js +244 -0
  297. package/dist/headers/SCTP.d.ts +35 -0
  298. package/dist/headers/SCTP.js +174 -0
  299. package/dist/headers/SFlow.d.ts +29 -0
  300. package/dist/headers/SFlow.js +242 -0
  301. package/dist/headers/SIP.d.ts +27 -0
  302. package/dist/headers/SIP.js +146 -0
  303. package/dist/headers/SLMP.d.ts +36 -0
  304. package/dist/headers/SLMP.js +154 -0
  305. package/dist/headers/SLP.d.ts +30 -0
  306. package/dist/headers/SLP.js +207 -0
  307. package/dist/headers/SLPv1.d.ts +32 -0
  308. package/dist/headers/SLPv1.js +138 -0
  309. package/dist/headers/SMB1.d.ts +37 -0
  310. package/dist/headers/SMB1.js +200 -0
  311. package/dist/headers/SMB2.d.ts +36 -0
  312. package/dist/headers/SMB2.js +203 -0
  313. package/dist/headers/SMPP.d.ts +33 -0
  314. package/dist/headers/SMPP.js +119 -0
  315. package/dist/headers/SMTP.d.ts +33 -0
  316. package/dist/headers/SMTP.js +157 -0
  317. package/dist/headers/SNAP.d.ts +22 -0
  318. package/dist/headers/SNAP.js +68 -0
  319. package/dist/headers/SNMP.d.ts +28 -0
  320. package/dist/headers/SNMP.js +302 -0
  321. package/dist/headers/SOCKS4.d.ts +42 -0
  322. package/dist/headers/SOCKS4.js +302 -0
  323. package/dist/headers/SOCKS5.d.ts +45 -0
  324. package/dist/headers/SOCKS5.js +223 -0
  325. package/dist/headers/SSDP.d.ts +27 -0
  326. package/dist/headers/SSDP.js +161 -0
  327. package/dist/headers/SSH.d.ts +44 -0
  328. package/dist/headers/SSH.js +274 -0
  329. package/dist/headers/STOMP.d.ts +48 -0
  330. package/dist/headers/STOMP.js +177 -0
  331. package/dist/headers/STP.d.ts +26 -0
  332. package/dist/headers/STP.js +150 -0
  333. package/dist/headers/STUN.d.ts +25 -0
  334. package/dist/headers/STUN.js +183 -0
  335. package/dist/headers/SercosIII.d.ts +43 -0
  336. package/dist/headers/SercosIII.js +199 -0
  337. package/dist/headers/Skinny.d.ts +32 -0
  338. package/dist/headers/Skinny.js +139 -0
  339. package/dist/headers/StatsD.d.ts +27 -0
  340. package/dist/headers/StatsD.js +134 -0
  341. package/dist/headers/SunRPC.d.ts +34 -0
  342. package/dist/headers/SunRPC.js +268 -0
  343. package/dist/headers/Syslog.d.ts +21 -0
  344. package/dist/headers/Syslog.js +91 -0
  345. package/dist/headers/TCP.d.ts +19 -0
  346. package/dist/headers/TCP.js +905 -0
  347. package/dist/headers/TFTP.d.ts +28 -0
  348. package/dist/headers/TFTP.js +224 -0
  349. package/dist/headers/TLS_Alert.d.ts +24 -0
  350. package/dist/headers/TLS_Alert.js +639 -0
  351. package/dist/headers/TLS_ApplicationData.d.ts +24 -0
  352. package/dist/headers/TLS_ApplicationData.js +170 -0
  353. package/dist/headers/TLS_ChangeCipherSpec.d.ts +23 -0
  354. package/dist/headers/TLS_ChangeCipherSpec.js +168 -0
  355. package/dist/headers/TLS_Handshake.d.ts +65 -0
  356. package/dist/headers/TLS_Handshake.js +860 -0
  357. package/dist/headers/TLS_Heartbeat.d.ts +27 -0
  358. package/dist/headers/TLS_Heartbeat.js +247 -0
  359. package/dist/headers/TPKT.d.ts +26 -0
  360. package/dist/headers/TPKT.js +99 -0
  361. package/dist/headers/TacacsPlus.d.ts +27 -0
  362. package/dist/headers/TacacsPlus.js +133 -0
  363. package/dist/headers/Telnet.d.ts +40 -0
  364. package/dist/headers/Telnet.js +193 -0
  365. package/dist/headers/Teredo.d.ts +40 -0
  366. package/dist/headers/Teredo.js +251 -0
  367. package/dist/headers/TimeProtocol.d.ts +25 -0
  368. package/dist/headers/TimeProtocol.js +53 -0
  369. package/dist/headers/UDP.d.ts +19 -0
  370. package/dist/headers/UDP.js +171 -0
  371. package/dist/headers/VLAN_802dot1Q.d.ts +24 -0
  372. package/dist/headers/VLAN_802dot1Q.js +96 -0
  373. package/dist/headers/VRRP.d.ts +26 -0
  374. package/dist/headers/VRRP.js +309 -0
  375. package/dist/headers/VXLAN.d.ts +24 -0
  376. package/dist/headers/VXLAN.js +75 -0
  377. package/dist/headers/WCCP.d.ts +29 -0
  378. package/dist/headers/WCCP.js +117 -0
  379. package/dist/headers/WHOIS.d.ts +37 -0
  380. package/dist/headers/WHOIS.js +126 -0
  381. package/dist/headers/WSDiscovery.d.ts +29 -0
  382. package/dist/headers/WSDiscovery.js +118 -0
  383. package/dist/headers/WakeOnLAN.d.ts +30 -0
  384. package/dist/headers/WakeOnLAN.js +126 -0
  385. package/dist/headers/WebSocket.d.ts +26 -0
  386. package/dist/headers/WebSocket.js +173 -0
  387. package/dist/headers/WireGuard.d.ts +38 -0
  388. package/dist/headers/WireGuard.js +216 -0
  389. package/dist/headers/XMPP.d.ts +37 -0
  390. package/dist/headers/XMPP.js +149 -0
  391. package/dist/headers/Zabbix.d.ts +35 -0
  392. package/dist/headers/Zabbix.js +153 -0
  393. package/dist/headers/cms/AcsiPdu.d.ts +45 -0
  394. package/dist/headers/cms/AcsiPdu.js +112 -0
  395. package/dist/headers/cms/PerDecoder.d.ts +68 -0
  396. package/dist/headers/cms/PerDecoder.js +211 -0
  397. package/dist/headers/cms/PerReader.d.ts +64 -0
  398. package/dist/headers/cms/PerReader.js +155 -0
  399. package/dist/helper/BufferToHex.d.ts +5 -0
  400. package/dist/helper/BufferToHex.js +10 -0
  401. package/dist/helper/BufferToIP.d.ts +12 -0
  402. package/dist/helper/BufferToIP.js +23 -0
  403. package/dist/helper/BufferToNumber.d.ts +18 -0
  404. package/dist/helper/BufferToNumber.js +47 -0
  405. package/dist/helper/HexToBuffer.d.ts +7 -0
  406. package/dist/helper/HexToBuffer.js +27 -0
  407. package/dist/helper/HexToNumber.d.ts +18 -0
  408. package/dist/helper/HexToNumber.js +48 -0
  409. package/dist/helper/IPToBuffer.d.ts +12 -0
  410. package/dist/helper/IPToBuffer.js +34 -0
  411. package/dist/helper/NumberToBERBuffer.d.ts +18 -0
  412. package/dist/helper/NumberToBERBuffer.js +31 -0
  413. package/dist/helper/NumberToBERHex.d.ts +18 -0
  414. package/dist/helper/NumberToBERHex.js +52 -0
  415. package/dist/helper/NumberToBuffer.d.ts +18 -0
  416. package/dist/helper/NumberToBuffer.js +38 -0
  417. package/dist/helper/NumberToHex.d.ts +18 -0
  418. package/dist/helper/NumberToHex.js +35 -0
  419. package/dist/index.d.ts +52 -0
  420. package/dist/index.js +113 -0
  421. package/dist/lib/FlexibleObject.d.ts +27 -0
  422. package/dist/lib/FlexibleObject.js +113 -0
  423. package/dist/lib/GetBERIntegerLengthFromBuffer.d.ts +6 -0
  424. package/dist/lib/GetBERIntegerLengthFromBuffer.js +16 -0
  425. package/dist/lib/ProcessPacketPostHandlers.d.ts +13 -0
  426. package/dist/lib/ProcessPacketPostHandlers.js +53 -0
  427. package/dist/lib/SortPostHandlers.d.ts +7 -0
  428. package/dist/lib/SortPostHandlers.js +11 -0
  429. package/dist/lib/StringContentEncodingEnum.d.ts +10 -0
  430. package/dist/lib/StringContentEncodingEnum.js +14 -0
  431. package/dist/schema/ProtocolFieldJSONSchema.d.ts +35 -0
  432. package/dist/schema/ProtocolFieldJSONSchema.js +2 -0
  433. package/dist/schema/ProtocolFieldJSONSchemaDefinition.d.ts +2 -0
  434. package/dist/schema/ProtocolFieldJSONSchemaDefinition.js +2 -0
  435. package/dist/schema/ProtocolJSONSchema.d.ts +32 -0
  436. package/dist/schema/ProtocolJSONSchema.js +2 -0
  437. package/dist/types/CodecData.d.ts +7 -0
  438. package/dist/types/CodecData.js +2 -0
  439. package/dist/types/CodecDecodeResult.d.ts +10 -0
  440. package/dist/types/CodecDecodeResult.js +2 -0
  441. package/dist/types/CodecEncodeInput.d.ts +2 -0
  442. package/dist/types/CodecEncodeInput.js +2 -0
  443. package/dist/types/CodecEncodeResult.d.ts +5 -0
  444. package/dist/types/CodecEncodeResult.js +2 -0
  445. package/dist/types/CodecErrorInfo.d.ts +5 -0
  446. package/dist/types/CodecErrorInfo.js +2 -0
  447. package/dist/types/CodecModule.d.ts +2 -0
  448. package/dist/types/CodecModule.js +2 -0
  449. package/dist/types/CodecModuleConstructor.d.ts +2 -0
  450. package/dist/types/CodecModuleConstructor.js +2 -0
  451. package/dist/types/CodecSchema.d.ts +6 -0
  452. package/dist/types/CodecSchema.js +2 -0
  453. package/dist/types/DemuxProducer.d.ts +23 -0
  454. package/dist/types/DemuxProducer.js +2 -0
  455. package/dist/types/Dissection.d.ts +23 -0
  456. package/dist/types/Dissection.js +2 -0
  457. package/dist/types/HeaderTreeNode.d.ts +4 -0
  458. package/dist/types/HeaderTreeNode.js +2 -0
  459. package/dist/types/LayerGraph.d.ts +32 -0
  460. package/dist/types/LayerGraph.js +2 -0
  461. package/dist/types/PostHandlerItem.d.ts +4 -0
  462. package/dist/types/PostHandlerItem.js +2 -0
  463. package/package.json +141 -0
@@ -0,0 +1,43 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * Gopher — the Internet Gopher Protocol (RFC 1436), carried over TCP well-known port 70. A transaction
6
+ * is US-ASCII text:
7
+ *
8
+ * REQUEST (client → server): "<selector>{C}" e.g. "/rfc/rfc1436.txt\r\n"
9
+ * or "<selector>{TAB}<search>{C}" (a type-7 index-search query)
10
+ * {C} is CR LF. The empty selector requests the root menu ("\r\n").
11
+ * RESPONSE (server → client): a series of directory items, each a Gopher menu line
12
+ * "<type><display>{TAB}<selector>{TAB}<host>{TAB}<port>{C}", the whole
13
+ * listing terminated by a lone "." line (".\r\n"); or, for a text item,
14
+ * the file body terminated the same way.
15
+ *
16
+ * MINIMAL slice (mirrors the Finger/Ident/SIP/HTTP verbatim-message pattern): a Gopher message is
17
+ * free-form US-ASCII framed only by CR LF and a menu grammar whose display/selector/host fields MAY carry
18
+ * almost any octet, and whitespace/line ordering is significant to peers. The ENTIRE payload is therefore
19
+ * the single source of truth — decoded verbatim to hex in the authoritative `message` field and
20
+ * re-emitted byte-for-byte on encode. On top of that the first line is parsed into DISPLAY-ONLY metadata:
21
+ * whether the transaction is a request or a response (decided by the TCP port direction — dst 70 is a
22
+ * request, src 70 a response), the request selector and optional type-7 search term, and whether the
23
+ * payload is terminated by the "." end-of-transmission line. Those metadata carry no codec of their own
24
+ * and never reconstruct the bytes — the message owns them. So any Gopher payload (a selector request, a
25
+ * menu response, a text body, or a truncated fragment) round-trips exactly.
26
+ *
27
+ * Matching rationale (NO heuristicFallback): Gopher is claimed ONLY on the tcp:70 bucket. A request line
28
+ * is arbitrary US-ASCII text with no distinctive off-port content signature, so recognizing it relies
29
+ * entirely on the well-known port; joining the global content-heuristic chain would mislabel arbitrary
30
+ * text TCP payloads on any port. Confining Gopher to tcp:70 keeps that impossible; alt-port Gopher is rare
31
+ * and falls losslessly to raw. As the terminal verbatim layer it consumes to the end of the segment (like
32
+ * Finger/Ident/HTTP) so a well-formed frame round-trips byte-for-byte.
33
+ */
34
+ export declare class Gopher extends BaseHeader {
35
+ #private;
36
+ get SCHEMA(): ProtocolJSONSchema;
37
+ readonly id: string;
38
+ readonly name: string;
39
+ readonly nickname: string;
40
+ readonly matchKeys: string[];
41
+ match(): boolean;
42
+ readonly demuxProducers: DemuxProducer[];
43
+ }
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Gopher = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ const BufferToHex_1 = require("../helper/BufferToHex");
6
+ const HexToBuffer_1 = require("../helper/HexToBuffer");
7
+ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
8
+ /** The Gopher well-known TCP port (RFC 1436). */
9
+ const GOPHER_PORT = 70;
10
+ /**
11
+ * Gopher — the Internet Gopher Protocol (RFC 1436), carried over TCP well-known port 70. A transaction
12
+ * is US-ASCII text:
13
+ *
14
+ * REQUEST (client → server): "<selector>{C}" e.g. "/rfc/rfc1436.txt\r\n"
15
+ * or "<selector>{TAB}<search>{C}" (a type-7 index-search query)
16
+ * {C} is CR LF. The empty selector requests the root menu ("\r\n").
17
+ * RESPONSE (server → client): a series of directory items, each a Gopher menu line
18
+ * "<type><display>{TAB}<selector>{TAB}<host>{TAB}<port>{C}", the whole
19
+ * listing terminated by a lone "." line (".\r\n"); or, for a text item,
20
+ * the file body terminated the same way.
21
+ *
22
+ * MINIMAL slice (mirrors the Finger/Ident/SIP/HTTP verbatim-message pattern): a Gopher message is
23
+ * free-form US-ASCII framed only by CR LF and a menu grammar whose display/selector/host fields MAY carry
24
+ * almost any octet, and whitespace/line ordering is significant to peers. The ENTIRE payload is therefore
25
+ * the single source of truth — decoded verbatim to hex in the authoritative `message` field and
26
+ * re-emitted byte-for-byte on encode. On top of that the first line is parsed into DISPLAY-ONLY metadata:
27
+ * whether the transaction is a request or a response (decided by the TCP port direction — dst 70 is a
28
+ * request, src 70 a response), the request selector and optional type-7 search term, and whether the
29
+ * payload is terminated by the "." end-of-transmission line. Those metadata carry no codec of their own
30
+ * and never reconstruct the bytes — the message owns them. So any Gopher payload (a selector request, a
31
+ * menu response, a text body, or a truncated fragment) round-trips exactly.
32
+ *
33
+ * Matching rationale (NO heuristicFallback): Gopher is claimed ONLY on the tcp:70 bucket. A request line
34
+ * is arbitrary US-ASCII text with no distinctive off-port content signature, so recognizing it relies
35
+ * entirely on the well-known port; joining the global content-heuristic chain would mislabel arbitrary
36
+ * text TCP payloads on any port. Confining Gopher to tcp:70 keeps that impossible; alt-port Gopher is rare
37
+ * and falls losslessly to raw. As the terminal verbatim layer it consumes to the end of the segment (like
38
+ * Finger/Ident/HTTP) so a well-formed frame round-trips byte-for-byte.
39
+ */
40
+ class Gopher extends BaseHeader_1.BaseHeader {
41
+ constructor() {
42
+ super(...arguments);
43
+ this.id = 'gopher';
44
+ this.name = 'Internet Gopher Protocol';
45
+ this.nickname = 'Gopher';
46
+ //Gopher is recognized ONLY on the well-known port 70 — deliberately NOT via heuristicFallback. A
47
+ //request/response line is arbitrary US-ASCII text with no distinctive off-port content signature, so
48
+ //its recognition depends entirely on the port bucket; joining the global heuristic chain would
49
+ //mislabel arbitrary text TCP payloads on any port. See the class doc for the full rationale.
50
+ this.matchKeys = ['tcpport:70'];
51
+ //A leaf header — a Gopher request/response is a single free-form text transaction; nothing demuxes
52
+ //off it.
53
+ this.demuxProducers = [];
54
+ }
55
+ static #schemaCache;
56
+ get SCHEMA() {
57
+ return (Gopher.#schemaCache ??= Gopher.#buildSchema());
58
+ }
59
+ /** Bytes available to this header: Gopher rides on TCP, which has no per-message length. */
60
+ #payloadLength() {
61
+ const available = this.packet.length - this.startPos;
62
+ return available < 0 ? 0 : available;
63
+ }
64
+ /**
65
+ * True when this transaction is a client request (TCP destination port 70), false for a server
66
+ * response (source port 70). Read from the parent TCP layer for display only; when neither port is 70
67
+ * (an alt-port capture that still reached this bucket via a custom match) it defaults to a request.
68
+ */
69
+ #isRequestDirection() {
70
+ const tcp = this.prevCodecModule;
71
+ if (!tcp)
72
+ return true;
73
+ const dstport = tcp.instance.dstport.getValue(0);
74
+ const srcport = tcp.instance.srcport.getValue(0);
75
+ if (srcport === GOPHER_PORT && dstport !== GOPHER_PORT)
76
+ return false;
77
+ return true;
78
+ }
79
+ /**
80
+ * Parse the first line into the display-only metadata fields. A request line is
81
+ * `<selector>[{TAB}<search>]{C}`; a response is a menu/text body terminated by a lone "." line.
82
+ * Populated on decode only — these fields have no encode, so they never affect the re-emitted bytes
83
+ * and never mutate `message`. Never throws: missing tokens yield empty strings / 0.
84
+ */
85
+ #parse(text) {
86
+ const isRequest = this.#isRequestDirection();
87
+ this.instance.isRequest.setValue(isRequest);
88
+ //Isolate the first line (up to the first CR LF, or a lone LF); `message` still holds all bytes.
89
+ let firstLine = text;
90
+ const lf = firstLine.indexOf('\n');
91
+ if (lf >= 0)
92
+ firstLine = firstLine.slice(0, lf);
93
+ if (firstLine.endsWith('\r'))
94
+ firstLine = firstLine.slice(0, -1);
95
+ //A Gopher payload is complete when it ends with the "." end-of-transmission line (".\r\n", or a
96
+ //lone "." with a tolerated bare LF, or the whole payload being just ".").
97
+ const hasTerminator = /(^|\r?\n)\.\r?\n$/.test(text) || text === '.\r\n' || text === '.\n' || text === '.';
98
+ this.instance.hasTerminator.setValue(hasTerminator);
99
+ if (isRequest) {
100
+ //Request: the selector is the first line, optionally followed by a TAB + search term (type 7).
101
+ const tab = firstLine.indexOf('\t');
102
+ const selector = tab >= 0 ? firstLine.slice(0, tab) : firstLine;
103
+ const search = tab >= 0 ? firstLine.slice(tab + 1) : '';
104
+ this.instance.selector.setValue(selector);
105
+ this.instance.searchTerm.setValue(search);
106
+ this.instance.itemCount.setValue(0);
107
+ const shown = selector === '' ? '(root)' : selector;
108
+ this.instance.summaryInfo.setValue(search ? `request ${shown} search="${search}"` : `request ${shown}`);
109
+ return;
110
+ }
111
+ //Response: count the menu/text lines that precede the terminating "." line. Split on LF, drop the
112
+ //optional trailing empty element after the last CR LF, and stop at the "." terminator line.
113
+ this.instance.selector.setValue('');
114
+ this.instance.searchTerm.setValue('');
115
+ const lines = text.split('\n');
116
+ let count = 0;
117
+ for (const rawLine of lines) {
118
+ const line = rawLine.endsWith('\r') ? rawLine.slice(0, -1) : rawLine;
119
+ if (line === '.')
120
+ break;
121
+ if (line === '')
122
+ continue;
123
+ count++;
124
+ }
125
+ this.instance.itemCount.setValue(count);
126
+ this.instance.summaryInfo.setValue(`response ${count} line${count === 1 ? '' : 's'}${hasTerminator ? '' : ' (partial)'}`);
127
+ }
128
+ static #buildSchema() {
129
+ return {
130
+ type: 'object',
131
+ summary: 'Gopher ${summaryInfo}',
132
+ properties: {
133
+ //Display-only metadata parsed on decode (no encode — populated by the `message` field
134
+ //below, never read back). isRequest is decided by the TCP port direction; selector and
135
+ //searchTerm apply to a request; itemCount to a response; hasTerminator flags the "." end.
136
+ isRequest: { type: 'boolean', label: 'Is Request', default: false },
137
+ selector: { type: 'string', label: 'Selector', default: '' },
138
+ searchTerm: { type: 'string', label: 'Search Term', default: '' },
139
+ itemCount: { type: 'integer', label: 'Item Count', minimum: 0, default: 0 },
140
+ hasTerminator: { type: 'boolean', label: 'Has Terminator', default: false },
141
+ //Drives the one-line summary (request selector / response line count).
142
+ summaryInfo: { type: 'string', label: 'Summary', hidden: true, default: '' },
143
+ //The whole raw payload is the single source of truth: decoded verbatim to hex and
144
+ //re-emitted untouched (byte-perfect for any Gopher payload). The first line is parsed into
145
+ //the display-only metadata above, which carry no codec of their own.
146
+ message: {
147
+ type: 'string',
148
+ label: 'Message',
149
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
150
+ default: '',
151
+ decode: function () {
152
+ const available = this.#payloadLength();
153
+ if (available <= 0) {
154
+ this.instance.message.setValue('');
155
+ this.#parse('');
156
+ return;
157
+ }
158
+ const raw = this.readBytes(0, available);
159
+ this.instance.message.setValue((0, BufferToHex_1.BufferToHex)(raw));
160
+ this.#parse(raw.toString('latin1'));
161
+ },
162
+ encode: function () {
163
+ //Re-emit the authoritative payload verbatim — never reconstruct from metadata.
164
+ this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(this.instance.message.getValue('')));
165
+ }
166
+ }
167
+ }
168
+ };
169
+ }
170
+ match() {
171
+ //Reached only on the tcp:70 bucket. Port 70 IS Gopher's, so any non-empty payload over TCP is
172
+ //claimed and kept verbatim (byte-perfect) — deliberately without a printable-text gate, so a
173
+ //binary text/menu body is never wrongly dropped to raw. An empty payload (a bare ACK) is not
174
+ //claimed.
175
+ if (!this.prevCodecModule)
176
+ return false;
177
+ if (this.prevCodecModule.id !== 'tcp')
178
+ return false;
179
+ return this.#payloadLength() >= 1;
180
+ }
181
+ }
182
+ exports.Gopher = Gopher;
@@ -0,0 +1,30 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * HART-IP (HART over IP, FieldComm Group spec HCF_SPEC-085), the process-automation transport that
6
+ * carries HART commands over UDP and TCP port 5094. Every HART-IP message begins with a fixed 8-byte
7
+ * header: Version (== 1), Message Type (0 Request, 1 Response, 2 Publish/Notify, 3 NAK), Message ID
8
+ * (0 Session Initiate, 1 Session Close, 2 Keep Alive, 3 Token-Passing PDU, 4 Direct PDU), a Status
9
+ * byte, a 2-byte Sequence Number, and a 2-byte Byte Count — the total message length including this
10
+ * 8-byte header. The HART PDU payload follows.
11
+ *
12
+ * Byte-perfect strategy (minimal slice): the 8-byte header is structured; the HART PDU (a session
13
+ * record, a command frame, or a token-passing / direct PDU whose layout depends on the Message ID and
14
+ * the HART command set) is kept verbatim as `payload` hex, bounded by the Byte Count and the transport
15
+ * payload (UDP length − 8, or the captured TCP bytes). The Byte Count is auto-computed from the payload
16
+ * on encode when not supplied, else honored verbatim (a crafted message may lie); the message is bounded
17
+ * by Byte Count so a second pipelined message or trailing bytes are left to the codec's recursion /
18
+ * RawData. Both UDP and TCP use the same 8-byte header (HART-IP has no TCP record-marking prefix). A
19
+ * well-formed message round-trips byte-for-byte.
20
+ */
21
+ export declare class HARTIP extends BaseHeader {
22
+ #private;
23
+ get SCHEMA(): ProtocolJSONSchema;
24
+ readonly id: string;
25
+ readonly name: string;
26
+ readonly nickname: string;
27
+ readonly matchKeys: string[];
28
+ match(): boolean;
29
+ readonly demuxProducers: DemuxProducer[];
30
+ }
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HARTIP = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ const BufferToHex_1 = require("../helper/BufferToHex");
6
+ const HexToBuffer_1 = require("../helper/HexToBuffer");
7
+ const BufferToNumber_1 = require("../helper/BufferToNumber");
8
+ const NumberToBuffer_1 = require("../helper/NumberToBuffer");
9
+ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
10
+ /**
11
+ * HART-IP (HART over IP, FieldComm Group spec HCF_SPEC-085), the process-automation transport that
12
+ * carries HART commands over UDP and TCP port 5094. Every HART-IP message begins with a fixed 8-byte
13
+ * header: Version (== 1), Message Type (0 Request, 1 Response, 2 Publish/Notify, 3 NAK), Message ID
14
+ * (0 Session Initiate, 1 Session Close, 2 Keep Alive, 3 Token-Passing PDU, 4 Direct PDU), a Status
15
+ * byte, a 2-byte Sequence Number, and a 2-byte Byte Count — the total message length including this
16
+ * 8-byte header. The HART PDU payload follows.
17
+ *
18
+ * Byte-perfect strategy (minimal slice): the 8-byte header is structured; the HART PDU (a session
19
+ * record, a command frame, or a token-passing / direct PDU whose layout depends on the Message ID and
20
+ * the HART command set) is kept verbatim as `payload` hex, bounded by the Byte Count and the transport
21
+ * payload (UDP length − 8, or the captured TCP bytes). The Byte Count is auto-computed from the payload
22
+ * on encode when not supplied, else honored verbatim (a crafted message may lie); the message is bounded
23
+ * by Byte Count so a second pipelined message or trailing bytes are left to the codec's recursion /
24
+ * RawData. Both UDP and TCP use the same 8-byte header (HART-IP has no TCP record-marking prefix). A
25
+ * well-formed message round-trips byte-for-byte.
26
+ */
27
+ class HARTIP extends BaseHeader_1.BaseHeader {
28
+ constructor() {
29
+ super(...arguments);
30
+ this.id = 'hartip';
31
+ this.name = 'HART-IP';
32
+ this.nickname = 'HART-IP';
33
+ //HART-IP rides UDP and TCP port 5094.
34
+ this.matchKeys = ['udpport:5094', 'tcpport:5094'];
35
+ //A leaf header — the HART PDU payload requires Message-ID- and command-set-dependent parsing.
36
+ this.demuxProducers = [];
37
+ }
38
+ static #schemaCache;
39
+ get SCHEMA() {
40
+ return (HARTIP.#schemaCache ??= HARTIP.#buildSchema());
41
+ }
42
+ /**
43
+ * Header-relative end offset of the transport payload available to this HART-IP message, so a lying
44
+ * Byte Count never reads past the real transport payload and trailing / pipelined data is left to the
45
+ * codec. Over UDP the bound is (udp.length − 8); over TCP HART-IP has no framing prefix, so the bound
46
+ * is the captured bytes. Both clamped to what was actually captured.
47
+ */
48
+ #payloadEnd() {
49
+ let end = this.packet.length - this.startPos;
50
+ const prev = this.prevCodecModule;
51
+ if (prev && prev.id === 'udp') {
52
+ const udpLength = prev.instance.length.getValue(0);
53
+ if (udpLength >= 8 && udpLength - 8 < end)
54
+ end = udpLength - 8;
55
+ }
56
+ return end < 0 ? 0 : end;
57
+ }
58
+ static #buildSchema() {
59
+ return {
60
+ type: 'object',
61
+ summary: 'HART-IP type=${messageType} id=${messageId} seq=${sequenceNumber}',
62
+ properties: {
63
+ //Protocol version — 1 for the current HART-IP specification. Kept verbatim so a crafted
64
+ //message with any version still round-trips.
65
+ version: this.fieldUInt('version', 0, 1, 'Version'),
66
+ //0 Request, 1 Response, 2 Publish/Notify, 3 NAK. Kept as a plain clamped byte (not an Ajv
67
+ //enum) so any non-conformant / crafted value decoded from the wire still re-encodes
68
+ //without throwing — decode never fails and encode is a faithful executor.
69
+ messageType: this.fieldUInt('messageType', 1, 1, 'Message Type'),
70
+ //0 Session Initiate, 1 Session Close, 2 Keep Alive, 3 Token-Passing PDU, 4 Direct PDU.
71
+ messageId: this.fieldUInt('messageId', 2, 1, 'Message ID'),
72
+ //Response/communication status (0 on a request); an opaque byte kept verbatim.
73
+ status: this.fieldUInt('status', 3, 1, 'Status'),
74
+ //Monotonic per-session sequence number matching a response to its request.
75
+ sequenceNumber: this.fieldUInt('sequenceNumber', 4, 2, 'Sequence Number'),
76
+ byteCount: {
77
+ type: 'integer',
78
+ label: 'Byte Count',
79
+ //minimum 0 (not 8): a crafted/corrupt message may carry a Byte Count below the 8-byte
80
+ //header, and such a value must round-trip (honored verbatim) rather than being rejected
81
+ //by Ajv at the encode entry — decode never fails, encode is faithful.
82
+ minimum: 0,
83
+ maximum: 65535,
84
+ decode: function () {
85
+ this.instance.byteCount.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(6, 2)));
86
+ },
87
+ encode: function () {
88
+ //Byte Count is the whole message length = 8-byte header + payload. Honored when
89
+ //supplied (a crafted message may lie); else derived from the payload.
90
+ const provided = this.instance.byteCount.getValue();
91
+ let value = (provided !== undefined && provided !== null)
92
+ ? provided
93
+ : 8 + (0, HexToBuffer_1.HexToBuffer)(this.instance.payload.getValue('')).length;
94
+ if (value > 65535) {
95
+ this.recordError(this.instance.byteCount.getPath(), 'Maximum value is 65535');
96
+ value = 65535;
97
+ }
98
+ if (value < 0) {
99
+ this.recordError(this.instance.byteCount.getPath(), 'Minimum value is 0');
100
+ value = 0;
101
+ }
102
+ this.instance.byteCount.setValue(value);
103
+ this.writeBytes(6, (0, NumberToBuffer_1.UInt16ToBuffer)(value));
104
+ }
105
+ },
106
+ //The HART PDU after the 8-byte header, kept verbatim. Bounded by the Byte Count (the
107
+ //message ends at offset Byte Count) and the captured transport payload, so trailing /
108
+ //pipelined data is left to the codec's recursion / RawData.
109
+ payload: {
110
+ type: 'string',
111
+ label: 'Payload',
112
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
113
+ decode: function () {
114
+ const transportEnd = this.#payloadEnd();
115
+ const byteCount = this.instance.byteCount.getValue(0);
116
+ let end = byteCount;
117
+ if (end > transportEnd)
118
+ end = transportEnd;
119
+ this.instance.payload.setValue(end > 8 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(8, end - 8)) : '');
120
+ },
121
+ encode: function () {
122
+ const payload = this.instance.payload.getValue('');
123
+ if (payload)
124
+ this.writeBytes(8, (0, HexToBuffer_1.HexToBuffer)(payload));
125
+ }
126
+ }
127
+ }
128
+ };
129
+ }
130
+ match() {
131
+ //HART-IP is selected via the udpport:5094 / tcpport:5094 buckets. This stays a port-bucket
132
+ //protocol (matchKeys only, NO heuristicFallback): require the full 8-byte header within the
133
+ //transport payload and Version == 1 so non-HART-IP traffic on 5094 falls through to raw. The
134
+ //payload bound is the transport payload (udp.length − 8 / captured TCP bytes), not the whole
135
+ //captured frame, so Ethernet padding is not mistaken for header bytes.
136
+ if (!this.prevCodecModule)
137
+ return false;
138
+ if (this.prevCodecModule.id !== 'udp' && this.prevCodecModule.id !== 'tcp')
139
+ return false;
140
+ if (this.#payloadEnd() < 8)
141
+ return false;
142
+ return (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(0, 1, true)) === 1;
143
+ }
144
+ }
145
+ exports.HARTIP = HARTIP;
@@ -0,0 +1,27 @@
1
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
2
+ import { BaseHeader } from '../abstracts/BaseHeader';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * HSR — High-availability Seamless Redundancy (IEC 62439-3), an L2 redundancy tag carried with EtherType
6
+ * 0x892f. This codec decodes the 6-octet HSR tag: a 4-bit Path / network id (`path`, top nibble of the
7
+ * first 2 octets) and a 12-bit LSDU Size (`lsduSize`, the low 12 bits) packed into the same 2-octet
8
+ * window, a 16-bit Sequence Number (`seqNr`, offset 2), and the 16-bit original EtherType of the carried
9
+ * frame (`etherType`, offset 4, a lowercase 4-hex string). `path` and `lsduSize` overlay disjoint bit
10
+ * ranges so their two encode closures write the shared window without clobbering each other; `lsduSize`
11
+ * is a plain read/write value and is NOT used to bound the carried frame (the inner protocol self-bounds).
12
+ *
13
+ * The trailing field is deliberately named `etherType` and stored exactly like VLAN/Ethernet, and is
14
+ * published as an `ethertype` demux key, so L2 children (GOOSE, SV, VLAN, ARP…) discriminate on it
15
+ * normally. match() mirrors VLAN: it fires whenever the carrying layer's EtherType is 0x892f — directly
16
+ * on Ethernet, inside a VLAN, or nested in another HSR tag — provided at least the 6 tag octets are
17
+ * present.
18
+ */
19
+ export declare class HSR extends BaseHeader {
20
+ SCHEMA: ProtocolJSONSchema;
21
+ readonly id: string;
22
+ readonly matchKeys: string[];
23
+ readonly demuxProducers: DemuxProducer[];
24
+ readonly name: string;
25
+ readonly nickname: string;
26
+ match(): boolean;
27
+ }
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HSR = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ const NumberToHex_1 = require("../helper/NumberToHex");
6
+ const BufferToHex_1 = require("../helper/BufferToHex");
7
+ /**
8
+ * HSR — High-availability Seamless Redundancy (IEC 62439-3), an L2 redundancy tag carried with EtherType
9
+ * 0x892f. This codec decodes the 6-octet HSR tag: a 4-bit Path / network id (`path`, top nibble of the
10
+ * first 2 octets) and a 12-bit LSDU Size (`lsduSize`, the low 12 bits) packed into the same 2-octet
11
+ * window, a 16-bit Sequence Number (`seqNr`, offset 2), and the 16-bit original EtherType of the carried
12
+ * frame (`etherType`, offset 4, a lowercase 4-hex string). `path` and `lsduSize` overlay disjoint bit
13
+ * ranges so their two encode closures write the shared window without clobbering each other; `lsduSize`
14
+ * is a plain read/write value and is NOT used to bound the carried frame (the inner protocol self-bounds).
15
+ *
16
+ * The trailing field is deliberately named `etherType` and stored exactly like VLAN/Ethernet, and is
17
+ * published as an `ethertype` demux key, so L2 children (GOOSE, SV, VLAN, ARP…) discriminate on it
18
+ * normally. match() mirrors VLAN: it fires whenever the carrying layer's EtherType is 0x892f — directly
19
+ * on Ethernet, inside a VLAN, or nested in another HSR tag — provided at least the 6 tag octets are
20
+ * present.
21
+ */
22
+ class HSR extends BaseHeader_1.BaseHeader {
23
+ constructor() {
24
+ super(...arguments);
25
+ this.SCHEMA = {
26
+ type: 'object',
27
+ summary: 'HSR seq=${seqNr}',
28
+ properties: {
29
+ path: {
30
+ type: 'integer',
31
+ minimum: 0,
32
+ maximum: 15,
33
+ default: 0,
34
+ label: 'Path',
35
+ //Path (network id) and LSDUsize share the first 2 octets: Path is the top 4 bits,
36
+ //LSDUsize the low 12 bits. writeBits masks its own field, so the two encode closures
37
+ //overlay disjoint bit ranges into the same window without clobbering each other.
38
+ decode: () => {
39
+ this.instance.path.setValue(this.readBits(0, 2, 0, 4));
40
+ },
41
+ encode: () => {
42
+ const pathValue = this.instance.path.getValue(0);
43
+ this.instance.path.setValue(pathValue);
44
+ this.writeBits(0, 2, 0, 4, pathValue);
45
+ }
46
+ },
47
+ lsduSize: {
48
+ type: 'integer',
49
+ minimum: 0,
50
+ maximum: 4095,
51
+ default: 0,
52
+ label: 'LSDU Size',
53
+ //A plain read/write field: NOT used to bound the carried frame (the inner protocol
54
+ //self-bounds via its own length semantics).
55
+ decode: () => {
56
+ this.instance.lsduSize.setValue(this.readBits(0, 2, 4, 12));
57
+ },
58
+ encode: () => {
59
+ const lsduSizeValue = this.instance.lsduSize.getValue(0);
60
+ this.instance.lsduSize.setValue(lsduSizeValue);
61
+ this.writeBits(0, 2, 4, 12, lsduSizeValue);
62
+ }
63
+ },
64
+ seqNr: BaseHeader_1.BaseHeader.fieldUInt('seqNr', 2, 2, 'Sequence Number'),
65
+ etherType: {
66
+ type: 'string',
67
+ minLength: 4,
68
+ maxLength: 4,
69
+ label: 'EtherType',
70
+ //The ORIGINAL EtherType of the carried frame. MUST be named `etherType` and stored as a
71
+ //lowercase 4-hex string exactly like VLAN/Ethernet, because L2 children (GOOSE, SV,
72
+ //VLAN, ARP) discriminate by reading prevCodecModule.instance.etherType — a different
73
+ //name would make them read undefined and fall through to RawData.
74
+ decode: () => {
75
+ this.instance.etherType.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(4, 2)));
76
+ },
77
+ encode: () => {
78
+ const etherType = this.instance.etherType.getValue((0, NumberToHex_1.UInt16ToHex)(0x0000), (nodePath) => this.recordError(nodePath, 'Not Found'));
79
+ const typeBuffer = Buffer.from(etherType, 'hex');
80
+ if (typeBuffer.length < 2)
81
+ typeBuffer.fill(0, 0, 1);
82
+ this.writeBytes(4, typeBuffer.subarray(0, 2));
83
+ }
84
+ }
85
+ }
86
+ };
87
+ this.id = 'hsr';
88
+ this.matchKeys = ['ethertype:892f'];
89
+ this.demuxProducers = [{ field: 'etherType', namespace: 'ethertype', kind: 'string' }];
90
+ this.name = 'High-availability Seamless Redundancy';
91
+ this.nickname = 'HSR';
92
+ }
93
+ match() {
94
+ //Like a VLAN tag, HSR is selected by the carrying layer's EtherType (0x892f) with no restriction
95
+ //on which layer that is — so it rides directly on Ethernet (the usual case) and equally inside a
96
+ //VLAN (VLAN-tagged HSR) or a nested HSR tag. This mirrors VLAN_802dot1Q.match exactly.
97
+ if (!this.prevCodecModule)
98
+ return false;
99
+ if (this.prevCodecModule.instance.etherType.getValue() !== (0, NumberToHex_1.UInt16ToHex)(0x892f))
100
+ return false;
101
+ //The 6-octet HSR tag must fit: Path/LSDUsize (2) + SeqNr (2) + carried EtherType (2).
102
+ return this.packet.length - this.startPos >= 6;
103
+ }
104
+ }
105
+ exports.HSR = HSR;
@@ -0,0 +1,26 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * HSRP — Hot Standby Router Protocol version 1 (RFC 2281, Cisco), carried over UDP port 1985 to the
6
+ * all-routers multicast group 224.0.0.2. The version-1 message is a fixed 20 bytes: Version (0 for v1),
7
+ * Op Code (0 Hello / 1 Coup / 2 Resign), State (0 Initial / 1 Learn / 2 Listen / 4 Speak / 8 Standby /
8
+ * 16 Active), Hellotime and Holdtime (seconds), Priority, Group, a Reserved byte, an 8-byte
9
+ * Authentication Data field (a plaintext password, default "cisco" — kept verbatim as hex so any value
10
+ * round-trips), and the 4-byte Virtual IP Address.
11
+ *
12
+ * Only version 0 (HSRPv1) is decoded field-by-field; a non-zero Version (HSRPv2 uses a different,
13
+ * TLV-based layout on this port) falls back to a verbatim `rawBody` hex so the message still round-trips
14
+ * byte-for-byte. HSRP is a leaf — nothing rides on top of it. The message is bounded by the 20-byte v1
15
+ * mandatory section; any trailing bytes in the UDP datagram are left to the codec's recursion / RawData.
16
+ */
17
+ export declare class HSRP extends BaseHeader {
18
+ #private;
19
+ get SCHEMA(): ProtocolJSONSchema;
20
+ readonly id: string;
21
+ readonly name: string;
22
+ readonly nickname: string;
23
+ readonly matchKeys: string[];
24
+ match(): boolean;
25
+ readonly demuxProducers: DemuxProducer[];
26
+ }