@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,340 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RGoose = 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
+ * IEC 61850-90-5 Session protocol — Routable GOOSE / Routable SV (R-GOOSE / R-SV).
12
+ *
13
+ * Carries a GOOSE (goosePdu) or SV (savPdu) APDU over UDP inside an OSI-style Session PDU (SPDU). One
14
+ * header handles both, branching on the Session Identifier (SI) byte: 0xA1 = non-tunnelled GOOSE,
15
+ * 0xA2 = non-tunnelled SV, 0xA0 = tunnelled. This is a leaf (Slice 1): each payload item's APDU is kept
16
+ * as bounded raw hex — structuring it via the shared BER/GOOSE/SV decoders is deferred to Slice 2, so we
17
+ * deliberately do NOT recurse into Goose.ts / IEC61850SampledValues.ts (that would swallow the trailing
18
+ * signature and any 2nd payload item). All multi-byte session fields are big-endian.
19
+ *
20
+ * ── VERIFIED BYTE LAYOUT (cross-checked against Wireshark 4.6.7 packet-goose.c `dissect_rgoose`, and
21
+ * tshark's own R-GOOSE dissection of a crafted frame; offsets are header-relative) ──────────────────
22
+ * off w field source
23
+ * 0 1 SI (Session Identifier) packet-goose.c OSI_SPDU_* (0xA0 tunneled, 0xA1 GOOSE, 0xA2 SV, 0xA3 mgmt)
24
+ * 1 1 LI (session header length) hf_goose_session_hdr_length (display only; proto_item_set_len=LI+2)
25
+ * 2 1 Common session header id hf_goose_content_id (0x80)
26
+ * 3 1 Header length hf_goose_hdr_length
27
+ * 4 4 SPDU length hf_goose_spdu_lenth (BE)
28
+ * 8 4 SPDU number hf_goose_spdu_num (BE)
29
+ * 12 2 Version hf_goose_version (BE, =1)
30
+ * ── Security information subtree ──
31
+ * 14 4 Time of current key hf_goose_current_key_t (BE)
32
+ * 18 2 Time to next key hf_goose_next_key_t (BE)
33
+ * 20 4 Key ID hf_goose_key_id (BE)
34
+ * 24 1 Initialization vector length hf_goose_init_vec_length → ivLen
35
+ * 25 iv Initialization vector hf_goose_init_vec (present only if ivLen>0)
36
+ * ── Session user information ──
37
+ * 25+iv 4 Payload length hf_goose_payload_length (BE); bounds the payload-item walk
38
+ * ── per payload item (APDU_HEADER_SIZE=6, then the APDU) ──
39
+ * +0 1 Payload type tag hf_goose_apdu_tag (0x81 GOOSE, 0x82 SV, 0x83 tunnel, 0x84 mgmt)
40
+ * +1 1 Simulation flag hf_goose_apdu_simulation
41
+ * +2 2 APPID hf_goose_apdu_appid (BE)
42
+ * +4 2 APDU length hf_goose_apdu_length (BE)
43
+ * +6 N APDU (goosePdu 0x61.. / savPdu 0x60.. BER)
44
+ * ── trailer (after payload length consumed) ──
45
+ * v Signature / HMAC optional 0xAF-tagged padding then HMAC; Wireshark lumps the
46
+ * trailing bytes as hf_goose_hmac (it does not parse a 0x85 tag)
47
+ *
48
+ * NOTE (layout uncertainty, resolved in favour of tshark): some 90-5 texts describe the security area as
49
+ * TimeOfCurrentKey(4)+TimeToNextKey(2)+SecurityAlgorithm(enc 1 + MAC 1)+KeyID(4). Wireshark 4.6.7 instead
50
+ * models those bytes as KeyID(4)+InitVectorLength(1)+InitVector — the SAME octets, different field names.
51
+ * tshark is the byte-layout gate here, so we follow Wireshark's interpretation exactly.
52
+ *
53
+ * There is NO explicit payload-item count: items are walked accumulating (6 + APDU length) until the
54
+ * Payload length is consumed (matches Wireshark's `while (apdu_offset < payload_length)` loop).
55
+ *
56
+ * TRANSPORT: real R-GOOSE reaches Wireshark's dissector via a CLTP (ISO 8602) UD TPDU heuristic over UDP,
57
+ * but the common/libiec61850 wire form puts the SPDU directly in the UDP payload (SI as the first byte);
58
+ * that is the form modelled here (matchKeys udpport:102, SI-signature match), and the form the fixture
59
+ * ships. The session byte layout itself was validated by wrapping this SPDU in a minimal CLTP UD TPDU and
60
+ * confirming tshark dissects it as R-GOOSE with the expected SPDU number / APPID / goosePdu / HMAC.
61
+ *
62
+ * Length fields (LI / Header length / SPDU length / Payload length / per-item APDU length) are honored
63
+ * when present and derived only when absent — a well-formed frame's derived values equal the decoded
64
+ * ones, so it round-trips byte-for-byte. A crafted frame that lies is re-emitted faithfully as long as
65
+ * its payload is honestly tiled by items (the signature boundary is taken from the actual item bytes on
66
+ * both decode and encode); a self-contradictory payloadLength that overshoots the item span by a partial
67
+ * item is best-effort, like a truncated frame.
68
+ */
69
+ class RGoose extends BaseHeader_1.BaseHeader {
70
+ constructor() {
71
+ super(...arguments);
72
+ this.id = 'r-session';
73
+ this.name = 'IEC 61850-90-5 Session';
74
+ this.nickname = 'R-GOOSE/R-SV';
75
+ this.matchKeys = ['udpport:102'];
76
+ //A leaf for Slice 1: each payload item's APDU is retained as bounded raw hex rather than recursing
77
+ //into the GOOSE/SV decoders (structuring the APDU is Slice 2).
78
+ this.demuxProducers = [];
79
+ }
80
+ static #schemaCache;
81
+ get SCHEMA() {
82
+ return (RGoose.#schemaCache ??= RGoose.#buildSchema());
83
+ }
84
+ /** The SPDU bytes available in this UDP datagram (so a retained trailer/padding is not over-read). */
85
+ #available() {
86
+ let available = this.packet.length - this.startPos;
87
+ if (this.prevCodecModule && this.prevCodecModule.id === 'udp') {
88
+ const udpLength = this.prevCodecModule.instance.length.getValue(0);
89
+ if (udpLength >= 8 && udpLength - 8 < available)
90
+ available = udpLength - 8;
91
+ }
92
+ return available < 0 ? 0 : available;
93
+ }
94
+ /** Initialization-vector length (drives every offset after the fixed 25-byte session header). */
95
+ #ivLen() {
96
+ const value = this.instance.security.initVecLength.getValue(0);
97
+ const n = typeof value === 'number' ? value : parseInt(String(value));
98
+ return Number.isFinite(n) && n > 0 ? n : 0;
99
+ }
100
+ /** Offset of the Payload length field: fixed 25-byte header + the variable IV. */
101
+ #payloadLengthOffset() {
102
+ return 25 + this.#ivLen();
103
+ }
104
+ static #buildSchema() {
105
+ return {
106
+ type: 'object',
107
+ summary: 'R-GOOSE/R-SV spdu=${spduNumber} si=${si}',
108
+ properties: {
109
+ si: this.fieldUInt('si', 0, 1, 'Session Identifier'),
110
+ li: {
111
+ type: 'integer', label: 'Session Header Length', minimum: 0, maximum: 255,
112
+ decode: function () { this.instance.li.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(1, 1))); },
113
+ encode: function () {
114
+ const value = this.instance.li.getValue();
115
+ //Honor when present, else derive: octets from the common header id (offset 2) to the
116
+ //end of the security info (= where the payload length begins, minus those 2 bytes).
117
+ const li = (value === undefined || value === null) ? this.#payloadLengthOffset() - 2 : value;
118
+ this.instance.li.setValue(li);
119
+ this.writeBytes(1, Buffer.from([li & 0xff]));
120
+ }
121
+ },
122
+ commonHeaderId: {
123
+ type: 'integer', label: 'Common Session Header Id', minimum: 0, maximum: 255,
124
+ decode: function () { this.instance.commonHeaderId.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(2, 1))); },
125
+ encode: function () {
126
+ const value = this.instance.commonHeaderId.getValue();
127
+ const id = (value === undefined || value === null) ? 0x80 : value;
128
+ this.instance.commonHeaderId.setValue(id);
129
+ this.writeBytes(2, Buffer.from([id & 0xff]));
130
+ }
131
+ },
132
+ headerLength: {
133
+ type: 'integer', label: 'Header Length', minimum: 0, maximum: 255,
134
+ decode: function () { this.instance.headerLength.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(3, 1))); },
135
+ encode: function () {
136
+ const value = this.instance.headerLength.getValue();
137
+ //Honor when present, else derive: octets from the SPDU length field (offset 4) to the
138
+ //end of the security info.
139
+ const hl = (value === undefined || value === null) ? this.#payloadLengthOffset() - 4 : value;
140
+ this.instance.headerLength.setValue(hl);
141
+ this.writeBytes(3, Buffer.from([hl & 0xff]));
142
+ }
143
+ },
144
+ spduLength: {
145
+ type: 'integer', label: 'SPDU Length', minimum: 0, maximum: 4294967295,
146
+ decode: function () { this.instance.spduLength.setValue((0, BufferToNumber_1.BufferToUInt32)(this.readBytes(4, 4))); },
147
+ encode: function () {
148
+ const value = this.instance.spduLength.getValue();
149
+ if (value !== undefined && value !== null) {
150
+ this.instance.spduLength.setValue(value);
151
+ this.writeBytes(4, (0, NumberToBuffer_1.UInt32ToBuffer)(value));
152
+ return;
153
+ }
154
+ //Derive: octets from the SPDU number field (offset 8) to the end of the SPDU
155
+ //(payload + signature). Computed once the whole header has been written.
156
+ this.writeBytes(4, (0, NumberToBuffer_1.UInt32ToBuffer)(0));
157
+ this.addPostSelfEncodeHandler(() => {
158
+ const derived = this.length - 8 < 0 ? 0 : this.length - 8;
159
+ this.instance.spduLength.setValue(derived);
160
+ this.writeBytes(4, (0, NumberToBuffer_1.UInt32ToBuffer)(derived));
161
+ });
162
+ }
163
+ },
164
+ spduNumber: this.fieldUInt('spduNumber', 8, 4, 'SPDU Number'),
165
+ version: {
166
+ type: 'integer', label: 'Version', minimum: 0, maximum: 65535,
167
+ decode: function () { this.instance.version.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(12, 2))); },
168
+ encode: function () {
169
+ const value = this.instance.version.getValue();
170
+ const version = (value === undefined || value === null) ? 1 : value;
171
+ this.instance.version.setValue(version);
172
+ this.writeBytes(12, (0, NumberToBuffer_1.UInt16ToBuffer)(version));
173
+ }
174
+ },
175
+ security: {
176
+ type: 'object',
177
+ label: 'Security Information',
178
+ properties: {
179
+ timeCurrentKey: {
180
+ type: 'integer', label: 'Time of Current Key', minimum: 0, maximum: 4294967295,
181
+ decode: function () { this.instance.security.timeCurrentKey.setValue((0, BufferToNumber_1.BufferToUInt32)(this.readBytes(14, 4))); },
182
+ encode: function () { this.writeBytes(14, (0, NumberToBuffer_1.UInt32ToBuffer)(this.instance.security.timeCurrentKey.getValue(0))); }
183
+ },
184
+ timeNextKey: {
185
+ type: 'integer', label: 'Time to Next Key', minimum: 0, maximum: 65535,
186
+ decode: function () { this.instance.security.timeNextKey.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(18, 2))); },
187
+ encode: function () { this.writeBytes(18, (0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.security.timeNextKey.getValue(0))); }
188
+ },
189
+ keyId: {
190
+ type: 'integer', label: 'Key ID', minimum: 0, maximum: 4294967295,
191
+ decode: function () { this.instance.security.keyId.setValue((0, BufferToNumber_1.BufferToUInt32)(this.readBytes(20, 4))); },
192
+ encode: function () { this.writeBytes(20, (0, NumberToBuffer_1.UInt32ToBuffer)(this.instance.security.keyId.getValue(0))); }
193
+ },
194
+ initVecLength: {
195
+ type: 'integer', label: 'Init Vector Length', minimum: 0, maximum: 255,
196
+ decode: function () { this.instance.security.initVecLength.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(24, 1))); },
197
+ encode: function () {
198
+ const value = this.instance.security.initVecLength.getValue();
199
+ //Honor when present, else derive from the init-vector hex length.
200
+ const iv = (0, HexToBuffer_1.HexToBuffer)(this.instance.security.initVec.getValue(''));
201
+ const len = (value === undefined || value === null) ? iv.length : value;
202
+ this.instance.security.initVecLength.setValue(len);
203
+ this.writeBytes(24, Buffer.from([len & 0xff]));
204
+ }
205
+ },
206
+ initVec: {
207
+ type: 'string', label: 'Init Vector', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
208
+ decode: function () {
209
+ const ivLen = this.#ivLen();
210
+ this.instance.security.initVec.setValue(ivLen > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(25, ivLen)) : '');
211
+ },
212
+ encode: function () {
213
+ const iv = (0, HexToBuffer_1.HexToBuffer)(this.instance.security.initVec.getValue(''));
214
+ if (iv.length)
215
+ this.writeBytes(25, iv);
216
+ }
217
+ }
218
+ }
219
+ },
220
+ payloadLength: {
221
+ type: 'integer', label: 'Payload Length', minimum: 0, maximum: 4294967295,
222
+ decode: function () {
223
+ this.instance.payloadLength.setValue((0, BufferToNumber_1.BufferToUInt32)(this.readBytes(this.#payloadLengthOffset(), 4)));
224
+ },
225
+ encode: function () {
226
+ const value = this.instance.payloadLength.getValue();
227
+ let length;
228
+ if (value !== undefined && value !== null) {
229
+ length = value;
230
+ }
231
+ else {
232
+ //Derive: sum of (6-byte APDU header + APDU bytes) over every payload item —
233
+ //exactly the span Wireshark walks against the payload length.
234
+ const items = this.instance.payloadItems.getValue([]);
235
+ length = (Array.isArray(items) ? items : []).reduce((sum, item) => sum + 6 + (0, HexToBuffer_1.HexToBuffer)(item && item.apdu ? item.apdu : '').length, 0);
236
+ }
237
+ this.instance.payloadLength.setValue(length);
238
+ this.writeBytes(this.#payloadLengthOffset(), (0, NumberToBuffer_1.UInt32ToBuffer)(length));
239
+ }
240
+ },
241
+ payloadItems: {
242
+ type: 'array',
243
+ label: 'Payload Items',
244
+ items: {
245
+ type: 'object',
246
+ properties: {
247
+ payloadType: { type: 'integer', label: 'Payload Type', minimum: 0, maximum: 255 },
248
+ simulation: { type: 'integer', label: 'Simulation', minimum: 0, maximum: 255 },
249
+ appid: { type: 'integer', label: 'APPID', minimum: 0, maximum: 65535 },
250
+ apduLength: { type: 'integer', label: 'APDU Length', minimum: 0, maximum: 65535 },
251
+ apdu: { type: 'string', label: 'APDU', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
252
+ }
253
+ },
254
+ decode: function () {
255
+ const available = this.#available();
256
+ const start = this.#payloadLengthOffset() + 4;
257
+ const payloadLength = this.instance.payloadLength.getValue(0);
258
+ //The payload length bounds the item walk; clamp to the datagram so a lying length
259
+ //cannot read past the buffer.
260
+ const end = Math.min(start + payloadLength, available);
261
+ const items = [];
262
+ let offset = start;
263
+ let guard = 0;
264
+ while (offset + 6 <= end && guard++ < 4096) {
265
+ const payloadType = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(offset, 1));
266
+ const simulation = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(offset + 1, 1));
267
+ const appid = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset + 2, 2));
268
+ const apduLength = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset + 4, 2));
269
+ const apduAvail = Math.min(apduLength, end - (offset + 6));
270
+ const apdu = apduAvail > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset + 6, apduAvail)) : '';
271
+ items.push({ payloadType: payloadType, simulation: simulation, appid: appid, apduLength: apduLength, apdu: apdu });
272
+ offset += 6 + apduLength;
273
+ }
274
+ this.instance.payloadItems.setValue(items);
275
+ },
276
+ encode: function () {
277
+ const items = this.instance.payloadItems.getValue([]);
278
+ let offset = this.#payloadLengthOffset() + 4;
279
+ (Array.isArray(items) ? items : []).forEach((item) => {
280
+ const apdu = (0, HexToBuffer_1.HexToBuffer)(item && item.apdu ? item.apdu : '');
281
+ //Honor the item's APDU length when supplied, else derive from the APDU bytes.
282
+ const apduLength = (item && item.apduLength !== undefined && item.apduLength !== null) ? item.apduLength : apdu.length;
283
+ this.writeBytes(offset, Buffer.from([(item && item.payloadType ? item.payloadType : 0) & 0xff]));
284
+ this.writeBytes(offset + 1, Buffer.from([(item && item.simulation ? item.simulation : 0) & 0xff]));
285
+ this.writeBytes(offset + 2, (0, NumberToBuffer_1.UInt16ToBuffer)(item && item.appid ? item.appid : 0));
286
+ this.writeBytes(offset + 4, (0, NumberToBuffer_1.UInt16ToBuffer)(apduLength));
287
+ if (apdu.length)
288
+ this.writeBytes(offset + 6, apdu);
289
+ //Advance by the actual bytes written so items stay contiguous.
290
+ offset += 6 + apdu.length;
291
+ });
292
+ }
293
+ },
294
+ signature: {
295
+ type: 'string',
296
+ label: 'Signature',
297
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
298
+ decode: function () {
299
+ const available = this.#available();
300
+ //Everything after the decoded payload items is the signature / HMAC trailer (possibly
301
+ //0xAF-tagged padding + HMAC), kept verbatim. The start is computed from the ACTUAL
302
+ //decoded item bytes — identical to the encode side below — rather than from the
303
+ //payloadLength field, so decode and encode are symmetric by construction: no byte is
304
+ //dropped even if a crafted payloadLength overshoots the real item span by a partial
305
+ //item (a payloadLength honestly tiled by items gives the same offset either way).
306
+ const items = this.instance.payloadItems.getValue([]);
307
+ let sigStart = this.#payloadLengthOffset() + 4;
308
+ (Array.isArray(items) ? items : []).forEach((item) => {
309
+ sigStart += 6 + (0, HexToBuffer_1.HexToBuffer)(item && item.apdu ? item.apdu : '').length;
310
+ });
311
+ this.instance.signature.setValue(sigStart < available ? (0, BufferToHex_1.BufferToHex)(this.readBytes(sigStart, available - sigStart)) : '');
312
+ },
313
+ encode: function () {
314
+ const signature = (0, HexToBuffer_1.HexToBuffer)(this.instance.signature.getValue(''));
315
+ if (!signature.length)
316
+ return;
317
+ const items = this.instance.payloadItems.getValue([]);
318
+ let sigStart = this.#payloadLengthOffset() + 4;
319
+ (Array.isArray(items) ? items : []).forEach((item) => {
320
+ sigStart += 6 + (0, HexToBuffer_1.HexToBuffer)(item && item.apdu ? item.apdu : '').length;
321
+ });
322
+ this.writeBytes(sigStart, signature);
323
+ }
324
+ }
325
+ }
326
+ };
327
+ }
328
+ match() {
329
+ //A UDP child. Require the minimum session header (Wireshark's heuristic floor is 27 bytes) and a
330
+ //Session Identifier in the R-GOOSE/R-SV/tunnel set. No heuristicFallback: recognized only on the
331
+ //well-known UDP port 102, gated by the SI signature.
332
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'udp')
333
+ return false;
334
+ if (this.#available() < 27)
335
+ return false;
336
+ const si = this.readBytes(0, 1, true)[0];
337
+ return si === 0xA0 || si === 0xA1 || si === 0xA2;
338
+ }
339
+ }
340
+ exports.RGoose = RGoose;
@@ -0,0 +1,29 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * RIP v2 — Routing Information Protocol version 2 (RFC 2453). Rides UDP, conventionally source and
6
+ * destination port 520 (responses are multicast to 224.0.0.9). All multi-byte fields are big-endian.
7
+ *
8
+ * A message is a 4-byte header — command (1 = request, 2 = response), version (= 2), and a 2-byte
9
+ * reserved field (must be zero) — followed by zero or more 20-byte route table entries. Each entry is
10
+ * addressFamily (2, AF_INET = 2), routeTag (2), ipAddress (4, IPv4), subnetMask (4, IPv4), nextHop
11
+ * (4, IPv4), and metric (4, 1..16 where 16 = infinity).
12
+ *
13
+ * The entry walk is bounded by the bytes actually present in the UDP payload, so a truncated capture can
14
+ * never over-read; any trailing bytes shorter than a full 20-byte entry fall to the raw layer. Entries
15
+ * are carried generically (including RIPv2 authentication entries, whose addressFamily is 0xFFFF and
16
+ * whose 16 bytes of auth data occupy the ipAddress/subnetMask/nextHop/metric slots) so every entry —
17
+ * route or auth — round-trips byte-for-byte; per-entry auth semantics are a later enrichment. This is a
18
+ * leaf header — nothing demuxes off RIP.
19
+ */
20
+ export declare class RIP extends BaseHeader {
21
+ #private;
22
+ get SCHEMA(): ProtocolJSONSchema;
23
+ readonly id: string;
24
+ readonly name: string;
25
+ readonly nickname: string;
26
+ readonly matchKeys: string[];
27
+ match(): boolean;
28
+ readonly demuxProducers: DemuxProducer[];
29
+ }
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RIP = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ const BufferToNumber_1 = require("../helper/BufferToNumber");
6
+ const NumberToBuffer_1 = require("../helper/NumberToBuffer");
7
+ const BufferToIP_1 = require("../helper/BufferToIP");
8
+ const IPToBuffer_1 = require("../helper/IPToBuffer");
9
+ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
10
+ //The fixed geometry of a RIP message: a 4-byte header (command, version, reserved) then route entries
11
+ //of 20 bytes each, walked to the end of the UDP payload (RFC 2453 caps a packet at 25 entries).
12
+ const HEADER_LENGTH = 4;
13
+ const ENTRY_LENGTH = 20;
14
+ /**
15
+ * RIP v2 — Routing Information Protocol version 2 (RFC 2453). Rides UDP, conventionally source and
16
+ * destination port 520 (responses are multicast to 224.0.0.9). All multi-byte fields are big-endian.
17
+ *
18
+ * A message is a 4-byte header — command (1 = request, 2 = response), version (= 2), and a 2-byte
19
+ * reserved field (must be zero) — followed by zero or more 20-byte route table entries. Each entry is
20
+ * addressFamily (2, AF_INET = 2), routeTag (2), ipAddress (4, IPv4), subnetMask (4, IPv4), nextHop
21
+ * (4, IPv4), and metric (4, 1..16 where 16 = infinity).
22
+ *
23
+ * The entry walk is bounded by the bytes actually present in the UDP payload, so a truncated capture can
24
+ * never over-read; any trailing bytes shorter than a full 20-byte entry fall to the raw layer. Entries
25
+ * are carried generically (including RIPv2 authentication entries, whose addressFamily is 0xFFFF and
26
+ * whose 16 bytes of auth data occupy the ipAddress/subnetMask/nextHop/metric slots) so every entry —
27
+ * route or auth — round-trips byte-for-byte; per-entry auth semantics are a later enrichment. This is a
28
+ * leaf header — nothing demuxes off RIP.
29
+ */
30
+ class RIP extends BaseHeader_1.BaseHeader {
31
+ constructor() {
32
+ super(...arguments);
33
+ this.id = 'rip';
34
+ this.name = 'Routing Information Protocol';
35
+ this.nickname = 'RIP';
36
+ //Port-defined (udp:520). The command/version bytes are a weak signature, so this stays a plain
37
+ //bucket entry (no heuristicFallback): RIP only when it rides udp:520, and only when the header looks
38
+ //like RIPv2 (version = 2, command request/response). RIPv1 and non-RIP payloads fall to raw.
39
+ this.matchKeys = ['udpport:520'];
40
+ //Leaf header: the route entries are terminal data, nothing demuxes off RIP.
41
+ this.demuxProducers = [];
42
+ }
43
+ static #schemaCache;
44
+ get SCHEMA() {
45
+ return (RIP.#schemaCache ??= RIP.#buildSchema());
46
+ }
47
+ /** Bytes available for this RIP message: the frame end, clamped by the UDP payload length. */
48
+ #available() {
49
+ let available = this.packet.length - this.startPos;
50
+ if (this.prevCodecModule && this.prevCodecModule.id === 'udp') {
51
+ const udpLength = this.prevCodecModule.instance.length.getValue(0);
52
+ if (udpLength >= 8 && udpLength - 8 < available)
53
+ available = udpLength - 8;
54
+ }
55
+ return available < 0 ? 0 : available;
56
+ }
57
+ static #entryItemSchema() {
58
+ return {
59
+ type: 'object',
60
+ label: 'Route Entry',
61
+ properties: {
62
+ addressFamily: { type: 'integer', label: 'Address Family', minimum: 0, maximum: 65535 },
63
+ routeTag: { type: 'integer', label: 'Route Tag', minimum: 0, maximum: 65535 },
64
+ ipAddress: { type: 'string', label: 'IP Address', minLength: 7, maxLength: 15, contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.IPv4 },
65
+ subnetMask: { type: 'string', label: 'Subnet Mask', minLength: 7, maxLength: 15, contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.IPv4 },
66
+ nextHop: { type: 'string', label: 'Next Hop', minLength: 7, maxLength: 15, contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.IPv4 },
67
+ metric: { type: 'integer', label: 'Metric', minimum: 0, maximum: 4294967295 }
68
+ }
69
+ };
70
+ }
71
+ static #buildSchema() {
72
+ return {
73
+ type: 'object',
74
+ summary: 'RIPv2 command ${command}',
75
+ properties: {
76
+ command: this.fieldUInt('command', 0, 1, 'Command'),
77
+ version: this.fieldUInt('version', 1, 1, 'Version'),
78
+ reserved: this.fieldUInt('reserved', 2, 2, 'Reserved'),
79
+ entries: {
80
+ type: 'array',
81
+ label: 'Route Entries',
82
+ items: this.#entryItemSchema(),
83
+ decode: function () {
84
+ //Walk fixed 20-byte entries to the end of the UDP payload. The count is bounded by
85
+ //the captured bytes so a truncated frame never over-reads; a trailing partial entry
86
+ //(< 20 bytes) is left for the raw layer.
87
+ const available = this.#available();
88
+ const total = available >= HEADER_LENGTH ? Math.floor((available - HEADER_LENGTH) / ENTRY_LENGTH) : 0;
89
+ const entries = [];
90
+ for (let i = 0; i < total; i++) {
91
+ const base = HEADER_LENGTH + i * ENTRY_LENGTH;
92
+ entries.push({
93
+ addressFamily: (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(base, 2)),
94
+ routeTag: (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(base + 2, 2)),
95
+ ipAddress: (0, BufferToIP_1.BufferToIPv4)(this.readBytes(base + 4, 4)),
96
+ subnetMask: (0, BufferToIP_1.BufferToIPv4)(this.readBytes(base + 8, 4)),
97
+ nextHop: (0, BufferToIP_1.BufferToIPv4)(this.readBytes(base + 12, 4)),
98
+ metric: (0, BufferToNumber_1.BufferToUInt32)(this.readBytes(base + 16, 4))
99
+ });
100
+ }
101
+ this.instance.entries.setValue(entries);
102
+ },
103
+ encode: function () {
104
+ const entries = this.instance.entries.getValue();
105
+ if (!Array.isArray(entries))
106
+ return;
107
+ entries.forEach((entry, index) => {
108
+ const base = HEADER_LENGTH + index * ENTRY_LENGTH;
109
+ this.writeBytes(base, (0, NumberToBuffer_1.UInt16ToBuffer)(entry.addressFamily ? entry.addressFamily : 0));
110
+ this.writeBytes(base + 2, (0, NumberToBuffer_1.UInt16ToBuffer)(entry.routeTag ? entry.routeTag : 0));
111
+ this.writeBytes(base + 4, (0, IPToBuffer_1.IPv4ToBuffer)(entry.ipAddress ? entry.ipAddress : '0.0.0.0'));
112
+ this.writeBytes(base + 8, (0, IPToBuffer_1.IPv4ToBuffer)(entry.subnetMask ? entry.subnetMask : '0.0.0.0'));
113
+ this.writeBytes(base + 12, (0, IPToBuffer_1.IPv4ToBuffer)(entry.nextHop ? entry.nextHop : '0.0.0.0'));
114
+ this.writeBytes(base + 16, (0, NumberToBuffer_1.UInt32ToBuffer)(entry.metric ? entry.metric : 0));
115
+ });
116
+ }
117
+ }
118
+ }
119
+ };
120
+ }
121
+ match() {
122
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'udp')
123
+ return false;
124
+ //Require the whole 4-byte header and the RIPv2 signature: version (=2) and a defined command
125
+ //(1 = request, 2 = response — the only commands RFC 2453 defines).
126
+ if (this.#available() < HEADER_LENGTH)
127
+ return false;
128
+ const command = (0, BufferToNumber_1.BufferToUInt8)(this.packet.subarray(this.startPos, this.startPos + 1));
129
+ const version = (0, BufferToNumber_1.BufferToUInt8)(this.packet.subarray(this.startPos + 1, this.startPos + 2));
130
+ return version === 2 && (command === 1 || command === 2);
131
+ }
132
+ }
133
+ exports.RIP = RIP;
@@ -0,0 +1,26 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * RIPng — RIP for IPv6 (RFC 2080), carried over UDP port 521 (the RIPng process address ff02::9). A
6
+ * RIPng message is a 4-byte fixed header — Command (1 Request, 2 Response), Version (= 1) and a 2-byte
7
+ * reserved field (kept verbatim) — followed by zero or more 20-byte Route Table Entries (RTEs). Each
8
+ * RTE is an IPv6 Prefix (16 bytes), a Route Tag (2 bytes), a Prefix Length (1 byte) and a Metric
9
+ * (1 byte). An RTE with Metric 255 and Prefix Length 0 is a Next Hop RTE (RFC 2080 §2.1.1) carrying the
10
+ * next-hop address for the RTEs that follow it; it is carried structurally like any other RTE.
11
+ *
12
+ * The message has no length field of its own — the RTE array runs to the end of the UDP payload
13
+ * (udp.length - 8), which bounds the walk so retained Ethernet padding / trailing bytes are not
14
+ * absorbed. The IPv6 Prefix is kept verbatim as a lower-case hex string so any prefix (including a
15
+ * zero prefix, or a next-hop address) round-trips byte-for-byte. RIPng is a leaf — nothing rides on it.
16
+ */
17
+ export declare class RIPng 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
+ }