@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,138 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RADIUS = 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
+ * RADIUS — Remote Authentication Dial-In User Service (RFC 2865 auth / RFC 2866 accounting), UDP ports
12
+ * 1812 (auth) and 1813 (accounting). A 20-byte fixed header — Code, Identifier, Length (the whole
13
+ * packet), and a 16-byte Authenticator — followed by attributes (AVPs) in Type-Length-Value form:
14
+ * type(1) + length(1, counts the type+length+value) + value(length-2).
15
+ *
16
+ * Attributes are carried generically (type + verbatim hex value) so every attribute — including
17
+ * Vendor-Specific (26) whose value nests sub-AVPs — round-trips byte-for-byte; per-attribute semantic
18
+ * decoding is a later enrichment. The AVP walk is bounded by the RADIUS Length (and the UDP payload),
19
+ * so any trailing padding/FCS spills to the raw layer.
20
+ */
21
+ class RADIUS extends BaseHeader_1.BaseHeader {
22
+ constructor() {
23
+ super(...arguments);
24
+ this.id = 'radius';
25
+ this.name = 'Remote Authentication Dial-In User Service';
26
+ this.nickname = 'RADIUS';
27
+ this.matchKeys = ['udpport:1812', 'udpport:1813'];
28
+ //A leaf header — nothing demuxes above RADIUS.
29
+ this.demuxProducers = [];
30
+ }
31
+ static #schemaCache;
32
+ get SCHEMA() {
33
+ return (RADIUS.#schemaCache ??= RADIUS.#buildSchema());
34
+ }
35
+ /** Bytes available for this RADIUS message: the frame end, clamped by the UDP payload and the RADIUS Length. */
36
+ #available() {
37
+ let available = this.packet.length - this.startPos;
38
+ if (this.prevCodecModule && this.prevCodecModule.id === 'udp') {
39
+ const udpLength = this.prevCodecModule.instance.length.getValue(0);
40
+ if (udpLength >= 8 && udpLength - 8 < available)
41
+ available = udpLength - 8;
42
+ }
43
+ const radiusLength = this.instance.length.getValue(0);
44
+ if (radiusLength >= 20 && radiusLength < available)
45
+ available = radiusLength;
46
+ return available < 0 ? 0 : available;
47
+ }
48
+ static #buildSchema() {
49
+ return {
50
+ type: 'object',
51
+ summary: 'RADIUS code=${code} id=${identifier}',
52
+ properties: {
53
+ code: this.fieldUInt('code', 0, 1, 'Code'),
54
+ identifier: this.fieldUInt('identifier', 1, 1, 'Identifier'),
55
+ length: {
56
+ type: 'integer',
57
+ label: 'Length',
58
+ minimum: 0,
59
+ maximum: 65535,
60
+ decode: function () {
61
+ this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
62
+ },
63
+ encode: function () {
64
+ //Honor an explicitly-set Length (even 0 — so a decoded malformed Length=0 still
65
+ //round-trips byte-for-byte); auto-compute only when the field is absent (crafting).
66
+ const length = this.instance.length.getValue();
67
+ if (length !== undefined && length !== null) {
68
+ this.instance.length.setValue(length);
69
+ this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(length));
70
+ }
71
+ else {
72
+ this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(0));
73
+ //After the attributes have encoded, the header length is the whole message.
74
+ this.addPostSelfEncodeHandler(() => {
75
+ this.instance.length.setValue(this.length);
76
+ this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(this.length));
77
+ }, 1);
78
+ }
79
+ }
80
+ },
81
+ authenticator: this.fieldHex('authenticator', 4, 16, 'Authenticator'),
82
+ attributes: {
83
+ type: 'array',
84
+ label: 'Attributes',
85
+ items: {
86
+ type: 'object',
87
+ label: 'Attribute',
88
+ properties: {
89
+ type: { type: 'integer', label: 'Type', minimum: 0, maximum: 255 },
90
+ value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
91
+ }
92
+ },
93
+ decode: function () {
94
+ const available = this.#available();
95
+ const attributes = [];
96
+ let offset = 20;
97
+ //Each AVP is type(1) length(1) value(length-2). A length < 2 is invalid (and would
98
+ //not advance), and a length that overruns the payload is truncated — in both cases
99
+ //stop and leave the remaining bytes to the raw layer, keeping the round-trip exact.
100
+ while (offset + 2 <= available) {
101
+ const type = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(offset, 1, true));
102
+ const length = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(offset + 1, 1, true));
103
+ if (length < 2 || offset + length > available)
104
+ break;
105
+ const attributeBuffer = this.readBytes(offset, length);
106
+ attributes.push({ type: type, value: length > 2 ? (0, BufferToHex_1.BufferToHex)(attributeBuffer.subarray(2)) : '' });
107
+ offset += length;
108
+ }
109
+ this.instance.attributes.setValue(attributes);
110
+ },
111
+ encode: function () {
112
+ const attributes = this.instance.attributes.getValue([]);
113
+ if (!attributes)
114
+ return;
115
+ let offset = 20;
116
+ for (const attribute of attributes) {
117
+ const value = (0, HexToBuffer_1.HexToBuffer)(attribute.value ? attribute.value : '');
118
+ this.writeBytes(offset, (0, NumberToBuffer_1.UInt8ToBuffer)(attribute.type ? attribute.type : 0));
119
+ this.writeBytes(offset + 1, (0, NumberToBuffer_1.UInt8ToBuffer)(value.length + 2));
120
+ offset += 2;
121
+ if (value.length) {
122
+ this.writeBytes(offset, value);
123
+ offset += value.length;
124
+ }
125
+ }
126
+ }
127
+ }
128
+ }
129
+ };
130
+ }
131
+ match() {
132
+ //Require the full 20-byte fixed header within the UDP PAYLOAD (not just the captured frame — a
133
+ //padded sub-20-byte datagram on a RADIUS port would otherwise over-read the trailer into the
134
+ //header). During MATCH the Length field is unset, so #available() reduces to the UDP-payload bound.
135
+ return !!this.prevCodecModule && this.prevCodecModule.id === 'udp' && this.#available() >= 20;
136
+ }
137
+ }
138
+ exports.RADIUS = RADIUS;
@@ -0,0 +1,27 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * RDP — Remote Desktop Protocol (MS-RDPBCGR), specifically the X.224 Negotiation that opens every RDP
6
+ * connection, carried in the user data of a COTP Connection Request / Connection Confirm (over
7
+ * TPKT/tcp:3389). The 8-byte structure is: a 1-byte Type (0x01 Negotiation Request, 0x02 Negotiation
8
+ * Response, 0x03 Negotiation Failure), a 1-byte Flags, a 2-byte little-endian Length (always 8), and a
9
+ * 4-byte little-endian bitmask — the requested/selected security protocols (0x00 standard RDP, 0x01 TLS,
10
+ * 0x02 CredSSP/HYBRID, 0x08 RDSTLS, …).
11
+ *
12
+ * This is the single-packet-identifiable part of RDP; the subsequent MCS/T.125 data phase (over COTP DT)
13
+ * is a multi-layer sub-stack left for later. A cookie/routing-token prefix (ASCII "Cookie: …\r\n") that
14
+ * may precede the Negotiation in some Connection Requests is not handled here (such a CR falls to raw).
15
+ * The Negotiation round-trips byte-for-byte.
16
+ */
17
+ export declare class RDP 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
+ readonly heuristicFallback: boolean;
25
+ match(): boolean;
26
+ readonly demuxProducers: DemuxProducer[];
27
+ }
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RDP = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ /**
6
+ * RDP — Remote Desktop Protocol (MS-RDPBCGR), specifically the X.224 Negotiation that opens every RDP
7
+ * connection, carried in the user data of a COTP Connection Request / Connection Confirm (over
8
+ * TPKT/tcp:3389). The 8-byte structure is: a 1-byte Type (0x01 Negotiation Request, 0x02 Negotiation
9
+ * Response, 0x03 Negotiation Failure), a 1-byte Flags, a 2-byte little-endian Length (always 8), and a
10
+ * 4-byte little-endian bitmask — the requested/selected security protocols (0x00 standard RDP, 0x01 TLS,
11
+ * 0x02 CredSSP/HYBRID, 0x08 RDSTLS, …).
12
+ *
13
+ * This is the single-packet-identifiable part of RDP; the subsequent MCS/T.125 data phase (over COTP DT)
14
+ * is a multi-layer sub-stack left for later. A cookie/routing-token prefix (ASCII "Cookie: …\r\n") that
15
+ * may precede the Negotiation in some Connection Requests is not handled here (such a CR falls to raw).
16
+ * The Negotiation round-trips byte-for-byte.
17
+ */
18
+ class RDP extends BaseHeader_1.BaseHeader {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.id = 'rdp';
22
+ this.name = 'Remote Desktop Protocol';
23
+ this.nickname = 'RDP';
24
+ //A content-heuristic child of COTP (unkeyed), selected by the X.224 Negotiation signature.
25
+ this.matchKeys = [];
26
+ this.heuristicFallback = true;
27
+ //A leaf for this slice — the MCS/T.125 data phase is a separate sub-stack.
28
+ this.demuxProducers = [];
29
+ }
30
+ static #schemaCache;
31
+ get SCHEMA() {
32
+ return (RDP.#schemaCache ??= RDP.#buildSchema());
33
+ }
34
+ static #buildSchema() {
35
+ return {
36
+ type: 'object',
37
+ summary: 'RDP-Neg type=${negotiationType} protocols=${requestedProtocols}',
38
+ properties: {
39
+ //0x01 Negotiation Request, 0x02 Response, 0x03 Failure.
40
+ negotiationType: this.fieldUInt('negotiationType', 0, 1, 'Negotiation Type'),
41
+ flags: this.fieldUInt('flags', 1, 1, 'Flags'),
42
+ //2-byte LITTLE-ENDIAN length — always 8 for the Negotiation. Honored verbatim.
43
+ length: {
44
+ type: 'integer', label: 'Length', minimum: 0, maximum: 65535,
45
+ decode: function () {
46
+ const bytes = this.readBytes(2, 2);
47
+ this.instance.length.setValue((bytes[0] | (bytes[1] << 8)) & 0xffff);
48
+ },
49
+ encode: function () {
50
+ let value = this.instance.length.getValue(8);
51
+ if (value > 65535)
52
+ value = 65535;
53
+ if (value < 0)
54
+ value = 0;
55
+ this.writeBytes(2, Buffer.from([value & 0xff, (value >> 8) & 0xff]));
56
+ }
57
+ },
58
+ //4-byte LITTLE-ENDIAN protocol bitmask (RDP/TLS/CredSSP/RDSTLS). >>> 0 keeps it unsigned.
59
+ requestedProtocols: {
60
+ type: 'integer', label: 'Requested Protocols', minimum: 0, maximum: 4294967295,
61
+ decode: function () {
62
+ const b = this.readBytes(4, 4);
63
+ this.instance.requestedProtocols.setValue((b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)) >>> 0);
64
+ },
65
+ encode: function () {
66
+ let value = this.instance.requestedProtocols.getValue(0);
67
+ if (value > 4294967295)
68
+ value = 4294967295;
69
+ if (value < 0)
70
+ value = 0;
71
+ this.writeBytes(4, Buffer.from([value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >>> 24) & 0xff]));
72
+ }
73
+ }
74
+ }
75
+ };
76
+ }
77
+ match() {
78
+ //Rides in COTP CR/CC user data. The Negotiation is a strong signature: an 8-byte structure whose
79
+ //Type is 0x01/0x02/0x03 and whose little-endian Length field is exactly 8 (byte 2 = 0x08, byte
80
+ //3 = 0x00) — distinctive enough to separate it from ISO-Session/other COTP payloads without a
81
+ //port gate.
82
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'cotp')
83
+ return false;
84
+ if (this.packet.length - this.startPos < 8)
85
+ return false;
86
+ const header = this.readBytes(0, 4, true);
87
+ const type = header[0];
88
+ if (type !== 0x01 && type !== 0x02 && type !== 0x03)
89
+ return false;
90
+ return header[2] === 0x08 && header[3] === 0x00;
91
+ }
92
+ }
93
+ exports.RDP = RDP;
@@ -0,0 +1,39 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * RFB / VNC — the Remote Framebuffer Protocol (RFC 6143), the wire protocol behind VNC, carried over TCP
6
+ * well-known port 5900. A connection OPENS with a 12-byte ProtocolVersion handshake: the US-ASCII line
7
+ * `"RFB 003.008\n"` (or 003.003 / 003.007) — exactly `RFB ` then a 3-digit major, a dot, a 3-digit minor,
8
+ * and a trailing `\n`. After that come binary security/init messages and then the (complex, stateful)
9
+ * framebuffer-update protocol.
10
+ *
11
+ * MINIMAL slice: this codec structures ONLY the clean, self-identifying text part — the 12-byte
12
+ * ProtocolVersion handshake — into display-only metadata {isVersionHandshake, versionString, major,
13
+ * minor}. Everything else (the post-handshake binary messages) is kept verbatim; structuring those is a
14
+ * later slice. Like the text protocols (HTTP/SIP/FTP), the ENTIRE raw payload is the single source of
15
+ * truth: it is decoded verbatim to hex in the `message` field and re-emitted byte-for-byte on encode —
16
+ * the parsed metadata carry no codec of their own and never reconstruct the bytes. So any RFB payload
17
+ * (version handshake, binary message, or truncated fragment) round-trips exactly.
18
+ *
19
+ * Matching is deliberately PORT-CONFINED to tcp:5900 with NO heuristicFallback. The 12-byte "RFB xxx.yyy\n"
20
+ * greeting is a strong, distinctive signature, but the post-handshake RFB messages are opaque binary with
21
+ * no reliable content signature — they cannot be recognized off-port without over-claiming arbitrary TCP
22
+ * traffic. So the tcp:5900 bucket is the whole scope: on that bucket a leading "RFB " (with >=12 bytes) is
23
+ * a version handshake and any other payload is kept as verbatim RFB `data`. Off port 5900, even an
24
+ * "RFB "-looking payload falls losslessly to raw (see the port-confinement test). This mirrors FTP's
25
+ * bucket-only confinement, for the same "the tail is ambiguous, so trust the port" reason.
26
+ *
27
+ * Note: reassembly across TCP segments is out of scope. This single-segment codec keeps whatever bytes
28
+ * are present verbatim, which is byte-perfect for the single-packet case.
29
+ */
30
+ export declare class RFB extends BaseHeader {
31
+ #private;
32
+ get SCHEMA(): ProtocolJSONSchema;
33
+ readonly id: string;
34
+ readonly name: string;
35
+ readonly nickname: string;
36
+ readonly matchKeys: string[];
37
+ match(): boolean;
38
+ readonly demuxProducers: DemuxProducer[];
39
+ }
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RFB = 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 4-byte signature that opens every RFB stream ("RFB " — the ProtocolVersion handshake prefix). */
9
+ const RFB_SIGNATURE = 'RFB ';
10
+ /** The ProtocolVersion handshake is a fixed 12-byte line: `RFB ` + 3-digit major `.` 3-digit minor + `\n`. */
11
+ const RFB_VERSION_LENGTH = 12;
12
+ /**
13
+ * RFB / VNC — the Remote Framebuffer Protocol (RFC 6143), the wire protocol behind VNC, carried over TCP
14
+ * well-known port 5900. A connection OPENS with a 12-byte ProtocolVersion handshake: the US-ASCII line
15
+ * `"RFB 003.008\n"` (or 003.003 / 003.007) — exactly `RFB ` then a 3-digit major, a dot, a 3-digit minor,
16
+ * and a trailing `\n`. After that come binary security/init messages and then the (complex, stateful)
17
+ * framebuffer-update protocol.
18
+ *
19
+ * MINIMAL slice: this codec structures ONLY the clean, self-identifying text part — the 12-byte
20
+ * ProtocolVersion handshake — into display-only metadata {isVersionHandshake, versionString, major,
21
+ * minor}. Everything else (the post-handshake binary messages) is kept verbatim; structuring those is a
22
+ * later slice. Like the text protocols (HTTP/SIP/FTP), the ENTIRE raw payload is the single source of
23
+ * truth: it is decoded verbatim to hex in the `message` field and re-emitted byte-for-byte on encode —
24
+ * the parsed metadata carry no codec of their own and never reconstruct the bytes. So any RFB payload
25
+ * (version handshake, binary message, or truncated fragment) round-trips exactly.
26
+ *
27
+ * Matching is deliberately PORT-CONFINED to tcp:5900 with NO heuristicFallback. The 12-byte "RFB xxx.yyy\n"
28
+ * greeting is a strong, distinctive signature, but the post-handshake RFB messages are opaque binary with
29
+ * no reliable content signature — they cannot be recognized off-port without over-claiming arbitrary TCP
30
+ * traffic. So the tcp:5900 bucket is the whole scope: on that bucket a leading "RFB " (with >=12 bytes) is
31
+ * a version handshake and any other payload is kept as verbatim RFB `data`. Off port 5900, even an
32
+ * "RFB "-looking payload falls losslessly to raw (see the port-confinement test). This mirrors FTP's
33
+ * bucket-only confinement, for the same "the tail is ambiguous, so trust the port" reason.
34
+ *
35
+ * Note: reassembly across TCP segments is out of scope. This single-segment codec keeps whatever bytes
36
+ * are present verbatim, which is byte-perfect for the single-packet case.
37
+ */
38
+ class RFB extends BaseHeader_1.BaseHeader {
39
+ constructor() {
40
+ super(...arguments);
41
+ this.id = 'rfb';
42
+ this.name = 'RFB (VNC)';
43
+ this.nickname = 'VNC';
44
+ //RFB/VNC is recognized ONLY on the well-known port 5900 — deliberately NOT via heuristicFallback.
45
+ //The 12-byte "RFB xxx.yyy\n" greeting is distinctive, but the post-handshake RFB messages are opaque
46
+ //binary with no content signature, so they can only be claimed by trusting the port. Confining to the
47
+ //tcp:5900 bucket keeps that safe: off-port traffic (even an "RFB "-looking payload) never reaches this
48
+ //bucket and falls losslessly to raw.
49
+ this.matchKeys = ['tcpport:5900'];
50
+ //A leaf header — the post-handshake RFB message stream is a higher-layer concern (a later slice).
51
+ this.demuxProducers = [];
52
+ }
53
+ static #schemaCache;
54
+ get SCHEMA() {
55
+ return (RFB.#schemaCache ??= RFB.#buildSchema());
56
+ }
57
+ /**
58
+ * Bytes of this header: RFB rides on TCP, which has no per-message length, so take the rest of the
59
+ * segment. Reassembly across segments is out of scope (see class doc).
60
+ */
61
+ #payloadLength() {
62
+ const available = this.packet.length - this.startPos;
63
+ return available < 0 ? 0 : available;
64
+ }
65
+ /**
66
+ * Parse the display-only metadata from the raw payload. When the payload opens with the "RFB "
67
+ * signature and is at least a full 12-byte ProtocolVersion line, it is a version handshake: the
68
+ * version string ("RFB 003.008") and its numeric major/minor are extracted (best-effort — a
69
+ * malformed greeting yields 0). Otherwise it is a post-handshake binary message kept as verbatim
70
+ * `data`; versionString is set to the literal 'data' so the summary reads "VNC data". Populated on
71
+ * decode only — these fields have no encode, so they never affect the re-emitted bytes.
72
+ */
73
+ #parseVersion(raw) {
74
+ //A ProtocolVersion handshake is exactly the 12-byte "RFB xxx.yyy\n" form (RFC 6143 §7.1.1, LF only).
75
+ //Require the full pattern to match — a 12-byte payload that merely starts with "RFB " but is not a
76
+ //well-formed version line (garbage digits, or a CRLF terminator) is NOT flagged as a handshake, so
77
+ //the display metadata never claims a version it could not parse.
78
+ const line = raw.length >= RFB_VERSION_LENGTH ? raw.subarray(0, RFB_VERSION_LENGTH).toString('latin1') : '';
79
+ const match = line.match(/^RFB (\d{3})\.(\d{3})\n$/);
80
+ if (match) {
81
+ this.instance.isVersionHandshake.setValue(true);
82
+ //The version string is the greeting without its trailing newline, e.g. "RFB 003.008".
83
+ this.instance.versionString.setValue(line.replace(/[\r\n]+$/, ''));
84
+ this.instance.major.setValue(Number(match[1]));
85
+ this.instance.minor.setValue(Number(match[2]));
86
+ return;
87
+ }
88
+ this.instance.isVersionHandshake.setValue(false);
89
+ //Non-handshake payload: the summary tail is the literal 'data' (produces "VNC data").
90
+ this.instance.versionString.setValue('data');
91
+ this.instance.major.setValue(0);
92
+ this.instance.minor.setValue(0);
93
+ }
94
+ static #buildSchema() {
95
+ return {
96
+ type: 'object',
97
+ summary: 'VNC ${versionString}',
98
+ properties: {
99
+ //The whole raw payload is the single source of truth: decoded verbatim to hex and
100
+ //re-emitted untouched (byte-perfect for any RFB payload). When it is a ProtocolVersion
101
+ //handshake the leading line is parsed into the display-only metadata below, which carry
102
+ //no codec of their own.
103
+ message: {
104
+ type: 'string',
105
+ label: 'Message',
106
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
107
+ decode: function () {
108
+ const available = this.#payloadLength();
109
+ if (available <= 0) {
110
+ this.instance.message.setValue('');
111
+ this.#parseVersion(Buffer.alloc(0));
112
+ return;
113
+ }
114
+ const raw = this.readBytes(0, available);
115
+ this.instance.message.setValue((0, BufferToHex_1.BufferToHex)(raw));
116
+ this.#parseVersion(raw);
117
+ },
118
+ encode: function () {
119
+ //Re-emit the authoritative payload verbatim — never reconstruct from metadata.
120
+ this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(this.instance.message.getValue('')));
121
+ }
122
+ },
123
+ //Display-only metadata parsed from the ProtocolVersion handshake on decode (no encode —
124
+ //populated by the message field above, never read back). isVersionHandshake distinguishes
125
+ //the opening 12-byte version line from any other (binary) RFB payload; versionString/major/
126
+ //minor describe the version when it is a handshake.
127
+ isVersionHandshake: { type: 'boolean', label: 'Is Version Handshake' },
128
+ versionString: { type: 'string', label: 'Version String' },
129
+ major: { type: 'integer', label: 'Major Version', minimum: 0, maximum: 999 },
130
+ minor: { type: 'integer', label: 'Minor Version', minimum: 0, maximum: 999 }
131
+ }
132
+ };
133
+ }
134
+ match() {
135
+ //Reached only on the tcp:5900 bucket. A leading "RFB " with a full 12-byte line is a version
136
+ //handshake; any other payload on this port-confined bucket is kept as verbatim RFB data. Either
137
+ //way a non-empty payload over TCP is claimed (byte-perfect), and an empty payload is not.
138
+ if (!this.prevCodecModule)
139
+ return false;
140
+ if (this.prevCodecModule.id !== 'tcp')
141
+ return false;
142
+ const available = this.#payloadLength();
143
+ if (available < 1)
144
+ return false;
145
+ const lead = this.readBytes(0, 4, true).toString('latin1');
146
+ if (lead === RFB_SIGNATURE && available >= RFB_VERSION_LENGTH)
147
+ return true;
148
+ return available >= 1;
149
+ }
150
+ }
151
+ exports.RFB = RFB;
@@ -0,0 +1,72 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * IEC 61850-90-5 Session protocol — Routable GOOSE / Routable SV (R-GOOSE / R-SV).
6
+ *
7
+ * Carries a GOOSE (goosePdu) or SV (savPdu) APDU over UDP inside an OSI-style Session PDU (SPDU). One
8
+ * header handles both, branching on the Session Identifier (SI) byte: 0xA1 = non-tunnelled GOOSE,
9
+ * 0xA2 = non-tunnelled SV, 0xA0 = tunnelled. This is a leaf (Slice 1): each payload item's APDU is kept
10
+ * as bounded raw hex — structuring it via the shared BER/GOOSE/SV decoders is deferred to Slice 2, so we
11
+ * deliberately do NOT recurse into Goose.ts / IEC61850SampledValues.ts (that would swallow the trailing
12
+ * signature and any 2nd payload item). All multi-byte session fields are big-endian.
13
+ *
14
+ * ── VERIFIED BYTE LAYOUT (cross-checked against Wireshark 4.6.7 packet-goose.c `dissect_rgoose`, and
15
+ * tshark's own R-GOOSE dissection of a crafted frame; offsets are header-relative) ──────────────────
16
+ * off w field source
17
+ * 0 1 SI (Session Identifier) packet-goose.c OSI_SPDU_* (0xA0 tunneled, 0xA1 GOOSE, 0xA2 SV, 0xA3 mgmt)
18
+ * 1 1 LI (session header length) hf_goose_session_hdr_length (display only; proto_item_set_len=LI+2)
19
+ * 2 1 Common session header id hf_goose_content_id (0x80)
20
+ * 3 1 Header length hf_goose_hdr_length
21
+ * 4 4 SPDU length hf_goose_spdu_lenth (BE)
22
+ * 8 4 SPDU number hf_goose_spdu_num (BE)
23
+ * 12 2 Version hf_goose_version (BE, =1)
24
+ * ── Security information subtree ──
25
+ * 14 4 Time of current key hf_goose_current_key_t (BE)
26
+ * 18 2 Time to next key hf_goose_next_key_t (BE)
27
+ * 20 4 Key ID hf_goose_key_id (BE)
28
+ * 24 1 Initialization vector length hf_goose_init_vec_length → ivLen
29
+ * 25 iv Initialization vector hf_goose_init_vec (present only if ivLen>0)
30
+ * ── Session user information ──
31
+ * 25+iv 4 Payload length hf_goose_payload_length (BE); bounds the payload-item walk
32
+ * ── per payload item (APDU_HEADER_SIZE=6, then the APDU) ──
33
+ * +0 1 Payload type tag hf_goose_apdu_tag (0x81 GOOSE, 0x82 SV, 0x83 tunnel, 0x84 mgmt)
34
+ * +1 1 Simulation flag hf_goose_apdu_simulation
35
+ * +2 2 APPID hf_goose_apdu_appid (BE)
36
+ * +4 2 APDU length hf_goose_apdu_length (BE)
37
+ * +6 N APDU (goosePdu 0x61.. / savPdu 0x60.. BER)
38
+ * ── trailer (after payload length consumed) ──
39
+ * v Signature / HMAC optional 0xAF-tagged padding then HMAC; Wireshark lumps the
40
+ * trailing bytes as hf_goose_hmac (it does not parse a 0x85 tag)
41
+ *
42
+ * NOTE (layout uncertainty, resolved in favour of tshark): some 90-5 texts describe the security area as
43
+ * TimeOfCurrentKey(4)+TimeToNextKey(2)+SecurityAlgorithm(enc 1 + MAC 1)+KeyID(4). Wireshark 4.6.7 instead
44
+ * models those bytes as KeyID(4)+InitVectorLength(1)+InitVector — the SAME octets, different field names.
45
+ * tshark is the byte-layout gate here, so we follow Wireshark's interpretation exactly.
46
+ *
47
+ * There is NO explicit payload-item count: items are walked accumulating (6 + APDU length) until the
48
+ * Payload length is consumed (matches Wireshark's `while (apdu_offset < payload_length)` loop).
49
+ *
50
+ * TRANSPORT: real R-GOOSE reaches Wireshark's dissector via a CLTP (ISO 8602) UD TPDU heuristic over UDP,
51
+ * but the common/libiec61850 wire form puts the SPDU directly in the UDP payload (SI as the first byte);
52
+ * that is the form modelled here (matchKeys udpport:102, SI-signature match), and the form the fixture
53
+ * ships. The session byte layout itself was validated by wrapping this SPDU in a minimal CLTP UD TPDU and
54
+ * confirming tshark dissects it as R-GOOSE with the expected SPDU number / APPID / goosePdu / HMAC.
55
+ *
56
+ * Length fields (LI / Header length / SPDU length / Payload length / per-item APDU length) are honored
57
+ * when present and derived only when absent — a well-formed frame's derived values equal the decoded
58
+ * ones, so it round-trips byte-for-byte. A crafted frame that lies is re-emitted faithfully as long as
59
+ * its payload is honestly tiled by items (the signature boundary is taken from the actual item bytes on
60
+ * both decode and encode); a self-contradictory payloadLength that overshoots the item span by a partial
61
+ * item is best-effort, like a truncated frame.
62
+ */
63
+ export declare class RGoose extends BaseHeader {
64
+ #private;
65
+ get SCHEMA(): ProtocolJSONSchema;
66
+ readonly id: string;
67
+ readonly name: string;
68
+ readonly nickname: string;
69
+ readonly matchKeys: string[];
70
+ match(): boolean;
71
+ readonly demuxProducers: DemuxProducer[];
72
+ }