@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,173 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HSRP = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ const NumberToBuffer_1 = require("../helper/NumberToBuffer");
6
+ const BufferToHex_1 = require("../helper/BufferToHex");
7
+ const HexToBuffer_1 = require("../helper/HexToBuffer");
8
+ const BufferToIP_1 = require("../helper/BufferToIP");
9
+ const IPToBuffer_1 = require("../helper/IPToBuffer");
10
+ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
11
+ /**
12
+ * HSRP — Hot Standby Router Protocol version 1 (RFC 2281, Cisco), carried over UDP port 1985 to the
13
+ * all-routers multicast group 224.0.0.2. The version-1 message is a fixed 20 bytes: Version (0 for v1),
14
+ * Op Code (0 Hello / 1 Coup / 2 Resign), State (0 Initial / 1 Learn / 2 Listen / 4 Speak / 8 Standby /
15
+ * 16 Active), Hellotime and Holdtime (seconds), Priority, Group, a Reserved byte, an 8-byte
16
+ * Authentication Data field (a plaintext password, default "cisco" — kept verbatim as hex so any value
17
+ * round-trips), and the 4-byte Virtual IP Address.
18
+ *
19
+ * Only version 0 (HSRPv1) is decoded field-by-field; a non-zero Version (HSRPv2 uses a different,
20
+ * TLV-based layout on this port) falls back to a verbatim `rawBody` hex so the message still round-trips
21
+ * byte-for-byte. HSRP is a leaf — nothing rides on top of it. The message is bounded by the 20-byte v1
22
+ * mandatory section; any trailing bytes in the UDP datagram are left to the codec's recursion / RawData.
23
+ */
24
+ class HSRP extends BaseHeader_1.BaseHeader {
25
+ constructor() {
26
+ super(...arguments);
27
+ this.id = 'hsrp';
28
+ this.name = 'Hot Standby Router Protocol';
29
+ this.nickname = 'HSRP';
30
+ this.matchKeys = ['udpport:1985'];
31
+ //A leaf header — nothing is carried on top of an HSRP message.
32
+ this.demuxProducers = [];
33
+ }
34
+ static #schemaCache;
35
+ get SCHEMA() {
36
+ return (HSRP.#schemaCache ??= HSRP.#buildSchema());
37
+ }
38
+ /** The payload length bounded by the UDP datagram (so retained ethernet padding/FCS is not absorbed). */
39
+ #payloadLength() {
40
+ let available = this.packet.length - this.startPos;
41
+ if (this.prevCodecModule && this.prevCodecModule.id === 'udp') {
42
+ const udpLength = this.prevCodecModule.instance.length.getValue(0);
43
+ if (udpLength >= 8 && udpLength - 8 < available)
44
+ available = udpLength - 8;
45
+ }
46
+ return available < 0 ? 0 : available;
47
+ }
48
+ /**
49
+ * A single-octet unsigned field of the v1 mandatory section at `offset`, decoded/encoded only when
50
+ * Version is 0 (HSRPv1). No `enum` constraint: encode is a faithful executor that must be able to
51
+ * craft any Op Code / State value (including illegal ones), so the field stays a plain [0, 255]
52
+ * integer. Encode clamps to that range (recording an error, never throwing) — byte-for-byte
53
+ * identical to a hand-written uint8 for in-range values.
54
+ */
55
+ static #v1Uint8(name, offset, label) {
56
+ return {
57
+ type: 'integer',
58
+ label: label,
59
+ minimum: 0,
60
+ maximum: 255,
61
+ decode: function () {
62
+ if (this.instance.version.getValue(0) !== 0)
63
+ return;
64
+ this.instance[name].setValue(this.readBytes(offset, 1)[0]);
65
+ },
66
+ encode: function () {
67
+ if (this.instance.version.getValue(0) !== 0)
68
+ return;
69
+ const node = this.instance[name];
70
+ let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
71
+ if (value > 255) {
72
+ this.recordError(node.getPath(), 'Maximum value is 255');
73
+ value = 255;
74
+ }
75
+ if (value < 0) {
76
+ this.recordError(node.getPath(), 'Minimum value is 0');
77
+ value = 0;
78
+ }
79
+ node.setValue(value);
80
+ this.writeBytes(offset, (0, NumberToBuffer_1.UInt8ToBuffer)(value));
81
+ }
82
+ };
83
+ }
84
+ static #buildSchema() {
85
+ return {
86
+ type: 'object',
87
+ summary: 'HSRP op=${opCode} state=${state} group=${group}',
88
+ properties: {
89
+ //Version — 0 for HSRPv1. Always decoded; it selects the v1 field layout vs the rawBody
90
+ //fallback (a non-zero version is HSRPv2, which uses a different TLV layout on this port).
91
+ version: this.fieldUInt('version', 0, 1, 'Version'),
92
+ //Op Code: 0 Hello, 1 Coup, 2 Resign.
93
+ opCode: this.#v1Uint8('opCode', 1, 'Op Code'),
94
+ //State: 0 Initial, 1 Learn, 2 Listen, 4 Speak, 8 Standby, 16 Active.
95
+ state: this.#v1Uint8('state', 2, 'State'),
96
+ helloTime: this.#v1Uint8('helloTime', 3, 'Hellotime'),
97
+ holdTime: this.#v1Uint8('holdTime', 4, 'Holdtime'),
98
+ priority: this.#v1Uint8('priority', 5, 'Priority'),
99
+ group: this.#v1Uint8('group', 6, 'Group'),
100
+ //Reserved byte — kept verbatim and re-emitted so a non-canonical frame stays byte-perfect.
101
+ reserved: this.#v1Uint8('reserved', 7, 'Reserved'),
102
+ //Authentication Data (8 bytes) — a plaintext password (default "cisco", NUL-padded). Kept
103
+ //verbatim as hex so any value (or binary garbage) round-trips byte-for-byte.
104
+ authData: {
105
+ type: 'string',
106
+ label: 'Authentication Data',
107
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
108
+ decode: function () {
109
+ if (this.instance.version.getValue(0) !== 0)
110
+ return;
111
+ this.instance.authData.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(8, 8)));
112
+ },
113
+ encode: function () {
114
+ if (this.instance.version.getValue(0) !== 0)
115
+ return;
116
+ this.writeBytes(8, (0, HexToBuffer_1.HexToBuffer)(this.instance.authData.getValue('0000000000000000')));
117
+ }
118
+ },
119
+ //Virtual IP Address — the group's shared gateway address.
120
+ virtualIP: {
121
+ type: 'string',
122
+ label: 'Virtual IP Address',
123
+ minLength: 7,
124
+ maxLength: 15,
125
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.IPv4,
126
+ decode: function () {
127
+ if (this.instance.version.getValue(0) !== 0)
128
+ return;
129
+ this.instance.virtualIP.setValue((0, BufferToIP_1.BufferToIPv4)(this.readBytes(16, 4)));
130
+ },
131
+ encode: function () {
132
+ if (this.instance.version.getValue(0) !== 0)
133
+ return;
134
+ const value = this.instance.virtualIP.getValue('0.0.0.0', (nodePath) => this.recordError(nodePath, 'Not Found'));
135
+ this.instance.virtualIP.setValue(value);
136
+ this.writeBytes(16, (0, IPToBuffer_1.IPv4ToBuffer)(value));
137
+ }
138
+ },
139
+ //Raw-body fallback for a non-zero Version (HSRPv2, different layout). Kept verbatim from
140
+ //just after the Version byte to the end of the UDP payload, byte-perfect.
141
+ rawBody: {
142
+ type: 'string',
143
+ label: 'Body',
144
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
145
+ decode: function () {
146
+ if (this.instance.version.getValue(0) === 0)
147
+ return;
148
+ const end = this.#payloadLength();
149
+ if (end <= 1)
150
+ return;
151
+ this.instance.rawBody.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(1, end - 1)));
152
+ },
153
+ encode: function () {
154
+ if (this.instance.version.getValue(0) === 0)
155
+ return;
156
+ if (this.instance.rawBody.isUndefined())
157
+ return;
158
+ this.writeBytes(1, (0, HexToBuffer_1.HexToBuffer)(this.instance.rawBody.getValue('')));
159
+ }
160
+ }
161
+ }
162
+ };
163
+ }
164
+ match() {
165
+ //HSRP rides on UDP port 1985. Require the full 20-byte v1 mandatory section within the UDP
166
+ //payload (bounded by the datagram length, not the frame, so ethernet padding is not miscounted);
167
+ //a shorter datagram is not an HSRP message and falls through to raw.
168
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'udp')
169
+ return false;
170
+ return this.#payloadLength() >= 20;
171
+ }
172
+ }
173
+ exports.HSRP = HSRP;
@@ -0,0 +1,32 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * HTTP/1.x — the Hypertext Transfer Protocol (RFC 7230), carried as US-ASCII text over TCP (well-known
6
+ * port 80, commonly 8080/8000). A message is a start-line, then header lines, a CRLF, and an optional
7
+ * body. The start-line is either a Request-Line (`METHOD SP Request-URI SP HTTP-Version CRLF`) or a
8
+ * Status-Line (`HTTP-Version SP Status-Code SP Reason-Phrase CRLF`).
9
+ *
10
+ * Like Syslog and SIP, the message body is text whose full internal structure (arbitrary header fields,
11
+ * a body of any content-type, significant whitespace/header ordering/casing) is far richer than a form
12
+ * needs. So the ENTIRE raw message is kept verbatim as the authoritative `message` field (hex) and
13
+ * re-emitted untouched; only the start-line is parsed on decode into display-only metadata
14
+ * (method/uri/version or status-code/reason). Encode never reconstructs the message from the parsed
15
+ * fields — it writes `message` back byte-for-byte — so any conformant (or even malformed) HTTP message
16
+ * round-trips exactly.
17
+ *
18
+ * Note: HTTP bodies can be chunked (`Transfer-Encoding: chunked`) or span multiple TCP segments;
19
+ * reassembly across segments is out of scope. This single-segment codec keeps whatever bytes are
20
+ * present in the current segment verbatim, which is byte-perfect for the single-packet case.
21
+ */
22
+ export declare class HTTP extends BaseHeader {
23
+ #private;
24
+ get SCHEMA(): ProtocolJSONSchema;
25
+ readonly id: string;
26
+ readonly name: string;
27
+ readonly nickname: string;
28
+ readonly matchKeys: string[];
29
+ readonly heuristicFallback: boolean;
30
+ match(): boolean;
31
+ readonly demuxProducers: DemuxProducer[];
32
+ }
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.HTTP = void 0;
5
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
6
+ const BufferToHex_1 = require("../helper/BufferToHex");
7
+ const HexToBuffer_1 = require("../helper/HexToBuffer");
8
+ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
9
+ /** HTTP request methods (RFC 7231 + PATCH) used only to recognize a request start-line. */
10
+ const HTTP_METHODS = ['GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'OPTIONS', 'PATCH', 'TRACE', 'CONNECT'];
11
+ /**
12
+ * HTTP/1.x — the Hypertext Transfer Protocol (RFC 7230), carried as US-ASCII text over TCP (well-known
13
+ * port 80, commonly 8080/8000). A message is a start-line, then header lines, a CRLF, and an optional
14
+ * body. The start-line is either a Request-Line (`METHOD SP Request-URI SP HTTP-Version CRLF`) or a
15
+ * Status-Line (`HTTP-Version SP Status-Code SP Reason-Phrase CRLF`).
16
+ *
17
+ * Like Syslog and SIP, the message body is text whose full internal structure (arbitrary header fields,
18
+ * a body of any content-type, significant whitespace/header ordering/casing) is far richer than a form
19
+ * needs. So the ENTIRE raw message is kept verbatim as the authoritative `message` field (hex) and
20
+ * re-emitted untouched; only the start-line is parsed on decode into display-only metadata
21
+ * (method/uri/version or status-code/reason). Encode never reconstructs the message from the parsed
22
+ * fields — it writes `message` back byte-for-byte — so any conformant (or even malformed) HTTP message
23
+ * round-trips exactly.
24
+ *
25
+ * Note: HTTP bodies can be chunked (`Transfer-Encoding: chunked`) or span multiple TCP segments;
26
+ * reassembly across segments is out of scope. This single-segment codec keeps whatever bytes are
27
+ * present in the current segment verbatim, which is byte-perfect for the single-packet case.
28
+ */
29
+ class HTTP extends BaseHeader_1.BaseHeader {
30
+ constructor() {
31
+ super(...arguments);
32
+ this.id = 'http';
33
+ this.name = 'Hypertext Transfer Protocol';
34
+ this.nickname = 'HTTP';
35
+ //The well-known ports give O(1) bucket dispatch, but HTTP runs on arbitrary ports (3000, 8888, proxy
36
+ //ports, …). heuristicFallback lets a non-listed port still be recognized by the start-line signature
37
+ //in match() below — the ports are a fast path, not a whitelist. (STUN uses the same pattern for its
38
+ //Magic Cookie.) The signature is specific enough (a known method + space, or "HTTP/1.") that this
39
+ //does not claim arbitrary TCP traffic.
40
+ this.matchKeys = ['tcpport:80', 'tcpport:8080', 'tcpport:8000'];
41
+ this.heuristicFallback = true;
42
+ //A leaf header — the HTTP body and the exchange it belongs to are a higher-layer concern.
43
+ this.demuxProducers = [];
44
+ }
45
+ static #schemaCache;
46
+ get SCHEMA() {
47
+ return (_a.#schemaCache ??= _a.#buildSchema());
48
+ }
49
+ /**
50
+ * Bytes of this header: HTTP rides on TCP, which has no per-message length, so take the rest of the
51
+ * segment. Body reassembly across segments is out of scope (see class doc).
52
+ */
53
+ #payloadLength() {
54
+ const available = this.packet.length - this.startPos;
55
+ return available < 0 ? 0 : available;
56
+ }
57
+ /** The first line of the message (up to the first CRLF, or the whole payload if none). */
58
+ static #firstLine(text) {
59
+ const idx = text.indexOf('\r\n');
60
+ return idx >= 0 ? text.slice(0, idx) : text;
61
+ }
62
+ /**
63
+ * Parse the start-line into the display-only metadata fields. A Status-Line begins with the
64
+ * HTTP-Version ("HTTP/1.1"); anything else is treated as a Request-Line. Populated on decode only —
65
+ * these fields have no encode, so they never affect the re-emitted bytes and never mutate `message`.
66
+ * Never throws: a non-numeric status yields 0, missing tokens yield empty strings.
67
+ */
68
+ #parseStartLine(text) {
69
+ const line = _a.#firstLine(text);
70
+ if (line.startsWith('HTTP/')) {
71
+ //Status-Line: HTTP-Version SP Status-Code SP Reason-Phrase
72
+ const match = line.match(/^(\S+)\s+(\d{3})\s*(.*)$/);
73
+ this.instance.isRequest.setValue(false);
74
+ this.instance.method.setValue('');
75
+ this.instance.requestUri.setValue('');
76
+ this.instance.version.setValue(match ? match[1] : (line.split(' ')[0] || ''));
77
+ this.instance.statusCode.setValue(match ? Number(match[2]) : 0);
78
+ this.instance.reasonPhrase.setValue(match ? match[3] : '');
79
+ return;
80
+ }
81
+ //Request-Line: METHOD SP Request-URI SP HTTP-Version
82
+ const parts = line.split(' ');
83
+ this.instance.isRequest.setValue(true);
84
+ this.instance.method.setValue(parts[0] ? parts[0] : '');
85
+ this.instance.requestUri.setValue(parts.length > 1 ? parts[1] : '');
86
+ //The HTTP-Version is the last whitespace-delimited token; the Request-URI itself has no spaces.
87
+ this.instance.version.setValue(parts.length > 2 ? parts[parts.length - 1] : '');
88
+ this.instance.statusCode.setValue(0);
89
+ this.instance.reasonPhrase.setValue('');
90
+ }
91
+ static #buildSchema() {
92
+ return {
93
+ type: 'object',
94
+ summary: 'HTTP ${method}${statusCode}',
95
+ properties: {
96
+ //The whole raw message is the single source of truth: decoded verbatim to hex and
97
+ //re-emitted untouched (byte-perfect for any HTTP message). The start-line is parsed into
98
+ //the display-only metadata below, which carry no codec of their own.
99
+ message: {
100
+ type: 'string',
101
+ label: 'Message',
102
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
103
+ decode: function () {
104
+ const available = this.#payloadLength();
105
+ if (available <= 0) {
106
+ this.instance.message.setValue('');
107
+ this.#parseStartLine('');
108
+ return;
109
+ }
110
+ const raw = this.readBytes(0, available);
111
+ this.instance.message.setValue((0, BufferToHex_1.BufferToHex)(raw));
112
+ this.#parseStartLine(raw.toString('latin1'));
113
+ },
114
+ encode: function () {
115
+ //Re-emit the authoritative message verbatim — never reconstruct from metadata.
116
+ this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(this.instance.message.getValue('')));
117
+ }
118
+ },
119
+ //Display-only metadata parsed from the start-line on decode (no encode — populated by the
120
+ //message field above, never read back). isRequest distinguishes a Request-Line from a
121
+ //Status-Line; method/requestUri are for requests, statusCode/reasonPhrase for responses.
122
+ isRequest: { type: 'boolean', label: 'Is Request' },
123
+ method: { type: 'string', label: 'Method' },
124
+ requestUri: { type: 'string', label: 'Request URI' },
125
+ version: { type: 'string', label: 'Version' },
126
+ statusCode: { type: 'integer', label: 'Status Code', minimum: 0, maximum: 999 },
127
+ reasonPhrase: { type: 'string', label: 'Reason Phrase' }
128
+ }
129
+ };
130
+ }
131
+ match() {
132
+ //HTTP rides on TCP as US-ASCII text. Recognize it by the start-line signature: a known request
133
+ //method followed by a space (the trailing space rejects e.g. "GETX"), or the "HTTP/1." response
134
+ //version — so non-HTTP traffic on these ports falls through to raw rather than claiming an
135
+ //un-decodable text layer.
136
+ if (!this.prevCodecModule)
137
+ return false;
138
+ if (this.prevCodecModule.id !== 'tcp')
139
+ return false;
140
+ if (this.#payloadLength() < 4)
141
+ return false;
142
+ const lead = this.readBytes(0, 16, true).toString('latin1');
143
+ if (lead.startsWith('HTTP/1.'))
144
+ return true;
145
+ for (const method of HTTP_METHODS) {
146
+ if (lead.startsWith(method + ' '))
147
+ return true;
148
+ }
149
+ return false;
150
+ }
151
+ }
152
+ exports.HTTP = HTTP;
153
+ _a = HTTP;
@@ -0,0 +1,34 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * HTTP/2 over cleartext TCP — "h2c" (RFC 7540), well-known ports 80 / 8080. (HTTP/2 over TLS is
6
+ * negotiated by the ALPN identifier "h2" and lives INSIDE the TLS record layer, so it is not decoded
7
+ * here.) A client opens an h2c connection with the 24-byte connection preface
8
+ * `PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n` (RFC 7540 §3.5) — an extremely distinctive signature — immediately
9
+ * followed by frames. Every frame is a 9-byte header: Length (24-bit, the payload octet count), Type
10
+ * (1 = HEADERS, 4 = SETTINGS, 6 = PING, 8 = WINDOW_UPDATE, 0 = DATA, …), Flags (1 byte), a 1-bit
11
+ * Reserved and a 31-bit Stream Identifier (RFC 7540 §4.1), then Length bytes of payload.
12
+ *
13
+ * This is a MINIMAL first-slice codec: it matches only the connection-preface packet (the preface is
14
+ * the sole reliable content signature — a bare 9-byte frame header is not distinctive enough to claim
15
+ * arbitrary TCP traffic) and structures the preface plus exactly the FIRST frame that follows it. The
16
+ * frame's payload is kept verbatim as `payload` hex (its internal structure — HPACK header blocks,
17
+ * per-type SETTINGS/PING/WINDOW_UPDATE fields — is per-type, and HPACK is cross-frame connection state,
18
+ * out of scope for a single-packet slice). The frame is bounded by its Length, so any further pipelined
19
+ * frames in the same segment are left to the codec's recursion / RawData (they carry no preface, so
20
+ * this header does not re-match them). Length is honored when supplied else derived from the payload;
21
+ * Reserved and Stream Identifier are preserved verbatim. A well-formed preface packet round-trips
22
+ * byte-for-byte.
23
+ */
24
+ export declare class HTTP2 extends BaseHeader {
25
+ #private;
26
+ get SCHEMA(): ProtocolJSONSchema;
27
+ readonly id: string;
28
+ readonly name: string;
29
+ readonly nickname: string;
30
+ readonly matchKeys: string[];
31
+ readonly heuristicFallback: boolean;
32
+ match(): boolean;
33
+ readonly demuxProducers: DemuxProducer[];
34
+ }
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HTTP2 = 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
+ /**
9
+ * HTTP/2 over cleartext TCP — "h2c" (RFC 7540), well-known ports 80 / 8080. (HTTP/2 over TLS is
10
+ * negotiated by the ALPN identifier "h2" and lives INSIDE the TLS record layer, so it is not decoded
11
+ * here.) A client opens an h2c connection with the 24-byte connection preface
12
+ * `PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n` (RFC 7540 §3.5) — an extremely distinctive signature — immediately
13
+ * followed by frames. Every frame is a 9-byte header: Length (24-bit, the payload octet count), Type
14
+ * (1 = HEADERS, 4 = SETTINGS, 6 = PING, 8 = WINDOW_UPDATE, 0 = DATA, …), Flags (1 byte), a 1-bit
15
+ * Reserved and a 31-bit Stream Identifier (RFC 7540 §4.1), then Length bytes of payload.
16
+ *
17
+ * This is a MINIMAL first-slice codec: it matches only the connection-preface packet (the preface is
18
+ * the sole reliable content signature — a bare 9-byte frame header is not distinctive enough to claim
19
+ * arbitrary TCP traffic) and structures the preface plus exactly the FIRST frame that follows it. The
20
+ * frame's payload is kept verbatim as `payload` hex (its internal structure — HPACK header blocks,
21
+ * per-type SETTINGS/PING/WINDOW_UPDATE fields — is per-type, and HPACK is cross-frame connection state,
22
+ * out of scope for a single-packet slice). The frame is bounded by its Length, so any further pipelined
23
+ * frames in the same segment are left to the codec's recursion / RawData (they carry no preface, so
24
+ * this header does not re-match them). Length is honored when supplied else derived from the payload;
25
+ * Reserved and Stream Identifier are preserved verbatim. A well-formed preface packet round-trips
26
+ * byte-for-byte.
27
+ */
28
+ class HTTP2 extends BaseHeader_1.BaseHeader {
29
+ constructor() {
30
+ super(...arguments);
31
+ this.id = 'http2';
32
+ this.name = 'Hypertext Transfer Protocol 2';
33
+ this.nickname = 'HTTP2';
34
+ //Well-known h2c ports for O(1) bucket dispatch, plus heuristicFallback so a preface on any other
35
+ //port is still recognized via match(). The 24-byte connection preface is a strong, unique content
36
+ //signature (STUN/HTTP use the same dual pattern), so this cannot claim arbitrary TCP traffic.
37
+ this.matchKeys = ['tcpport:80', 'tcpport:8080'];
38
+ this.heuristicFallback = true;
39
+ //A leaf header — the frame payload (HPACK header blocks, per-type fields) needs cross-frame
40
+ //connection state and per-type parsing, out of scope for this single-packet slice.
41
+ this.demuxProducers = [];
42
+ }
43
+ /** The 24-byte HTTP/2 connection preface (RFC 7540 §3.5): "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n". */
44
+ static #PREFACE_HEX = '505249202a20485454502f322e300d0a0d0a534d0d0a0d0a';
45
+ /** Preface (24) + fixed 9-byte frame header — the bytes this header always structures and re-emits. */
46
+ static #MIN_LENGTH = 33;
47
+ static #schemaCache;
48
+ get SCHEMA() {
49
+ return (HTTP2.#schemaCache ??= HTTP2.#buildSchema());
50
+ }
51
+ /** Bytes available to this header within the current TCP segment. */
52
+ #available() {
53
+ const available = this.packet.length - this.startPos;
54
+ return available < 0 ? 0 : available;
55
+ }
56
+ static #buildSchema() {
57
+ return {
58
+ type: 'object',
59
+ summary: 'HTTP2 type=${type} stream=${streamId} len=${length}',
60
+ properties: {
61
+ //The 24-byte connection preface, kept verbatim. match() requires it, so it is always
62
+ //present on decode; the default lets a crafted frame re-emit the standard preface.
63
+ preface: {
64
+ type: 'string',
65
+ label: 'Connection Preface',
66
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
67
+ decode: function () {
68
+ this.instance.preface.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(0, 24)));
69
+ },
70
+ encode: function () {
71
+ this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(this.instance.preface.getValue(HTTP2.#PREFACE_HEX)));
72
+ }
73
+ },
74
+ //Frame payload Length: a 24-bit big-endian octet count (RFC 7540 §4.1). There is no
75
+ //uint24 helper, so it is read/written byte-by-byte. Honored when supplied (a crafted
76
+ //frame may lie); else derived from the payload byte length.
77
+ length: {
78
+ type: 'integer',
79
+ label: 'Length',
80
+ minimum: 0,
81
+ maximum: 16777215,
82
+ decode: function () {
83
+ const b = this.readBytes(24, 3);
84
+ this.instance.length.setValue((b[0] << 16) | (b[1] << 8) | b[2]);
85
+ },
86
+ encode: function () {
87
+ const provided = this.instance.length.getValue();
88
+ let value = (provided !== undefined && provided !== null)
89
+ ? provided
90
+ : (0, HexToBuffer_1.HexToBuffer)(this.instance.payload.getValue('')).length;
91
+ if (value > 16777215) {
92
+ this.recordError(this.instance.length.getPath(), 'Maximum value is 16777215');
93
+ value = 16777215;
94
+ }
95
+ if (value < 0) {
96
+ this.recordError(this.instance.length.getPath(), 'Minimum value is 0');
97
+ value = 0;
98
+ }
99
+ this.instance.length.setValue(value);
100
+ this.writeBytes(24, Buffer.from([(value >> 16) & 0xff, (value >> 8) & 0xff, value & 0xff]));
101
+ }
102
+ },
103
+ //Frame Type (RFC 7540 §6): 0 DATA, 1 HEADERS, 4 SETTINGS, 6 PING, 8 WINDOW_UPDATE, … Kept
104
+ //as a plain uint8 (no hard enum) so any unknown/experimental type still round-trips.
105
+ type: this.fieldUInt('type', 27, 1, 'Type'),
106
+ //Frame Flags (RFC 7540 §4.1): a type-specific bit set (END_STREAM, END_HEADERS, ACK, …).
107
+ flags: this.fieldUInt('flags', 28, 1, 'Flags'),
108
+ //Reserved 1-bit field (RFC 7540 §4.1): the high bit of the 4-byte Stream-Identifier word.
109
+ //"MUST remain unset when sending"; preserved verbatim so a set bit still round-trips.
110
+ reserved: {
111
+ type: 'integer',
112
+ label: 'Reserved',
113
+ minimum: 0,
114
+ maximum: 1,
115
+ decode: function () {
116
+ this.instance.reserved.setValue(this.readBits(29, 4, 0, 1));
117
+ },
118
+ encode: function () {
119
+ const node = this.instance.reserved;
120
+ let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
121
+ if (value > 1)
122
+ value = 1;
123
+ if (value < 0)
124
+ value = 0;
125
+ node.setValue(value);
126
+ this.writeBits(29, 4, 0, 1, value);
127
+ }
128
+ },
129
+ //Stream Identifier (RFC 7540 §4.1): the low 31 bits of the same word. 0 = connection
130
+ //control (SETTINGS/PING/WINDOW_UPDATE); odd = client-initiated, even = server-initiated.
131
+ streamId: {
132
+ type: 'integer',
133
+ label: 'Stream Identifier',
134
+ minimum: 0,
135
+ maximum: 2147483647,
136
+ decode: function () {
137
+ this.instance.streamId.setValue(this.readBits(29, 4, 1, 31));
138
+ },
139
+ encode: function () {
140
+ const node = this.instance.streamId;
141
+ let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
142
+ if (value > 2147483647) {
143
+ this.recordError(node.getPath(), 'Maximum value is 2147483647');
144
+ value = 2147483647;
145
+ }
146
+ if (value < 0) {
147
+ this.recordError(node.getPath(), 'Minimum value is 0');
148
+ value = 0;
149
+ }
150
+ node.setValue(value);
151
+ this.writeBits(29, 4, 1, 31, value);
152
+ }
153
+ },
154
+ //The first frame's payload after the 9-byte frame header (offset 33 = preface 24 + header
155
+ //9), kept verbatim. Bounded by the frame Length AND the captured bytes, so any pipelined
156
+ //trailing frame is left to the codec's recursion / RawData.
157
+ payload: {
158
+ type: 'string',
159
+ label: 'Payload',
160
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
161
+ decode: function () {
162
+ const available = this.#available();
163
+ const length = this.instance.length.getValue(0);
164
+ let end = 33 + length;
165
+ if (end > available)
166
+ end = available;
167
+ this.instance.payload.setValue(end > 33 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(33, end - 33)) : '');
168
+ },
169
+ encode: function () {
170
+ const payload = this.instance.payload.getValue('');
171
+ if (payload)
172
+ this.writeBytes(33, (0, HexToBuffer_1.HexToBuffer)(payload));
173
+ }
174
+ }
175
+ }
176
+ };
177
+ }
178
+ match() {
179
+ //h2c rides on TCP. Recognize ONLY the connection-preface packet: the exact 24-byte preface plus
180
+ //enough bytes for the fixed 9-byte frame header this codec always structures and re-emits (so a
181
+ //preface-only segment is not claimed and left byte-imperfect). A bare mid-stream frame carries
182
+ //no preface and is intentionally not matched (it falls through to raw).
183
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'tcp')
184
+ return false;
185
+ if (this.#available() < HTTP2.#MIN_LENGTH)
186
+ return false;
187
+ return (0, BufferToHex_1.BufferToHex)(this.readBytes(0, 24, true)) === HTTP2.#PREFACE_HEX;
188
+ }
189
+ }
190
+ exports.HTTP2 = HTTP2;
@@ -0,0 +1,33 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * IAX2 — Inter-Asterisk eXchange version 2 (RFC 5456), the Asterisk VoIP signalling + media trunking
6
+ * protocol, UDP port 4569. Every IAX2 datagram carries exactly one frame whose first bit (the F bit,
7
+ * the MSB of octet 0) selects the frame format:
8
+ *
9
+ * - Full frame (F = 1) — a 12-byte header: F(1) + Source Call Number(15) | R(1, retransmit) +
10
+ * Destination Call Number(15) | Timestamp(32) | OSeqno(8) | ISeqno(8) | Frame Type(8) | C(1) +
11
+ * Subclass(7), followed by the frame data (the Information Elements of a NEW/AUTHREQ/… command, or a
12
+ * media payload). Full frames are reliably delivered and carry the call-control state.
13
+ * - Mini frame (F = 0) — a 4-byte header: F(1) + Source Call Number(15) | Timestamp(16), followed by
14
+ * the media payload. Mini frames carry audio with a truncated 16-bit timestamp to save bandwidth.
15
+ *
16
+ * Byte-perfect strategy (minimal slice): the format is chosen by peeking the MSB of octet 0; the fixed
17
+ * header is bit-unpacked field by field and the frame data is kept verbatim as `data` hex. IAX2 has no
18
+ * in-frame length field — one frame occupies the whole UDP payload — so `data` runs to the transport
19
+ * payload end (udp.length − 8, clamped to the captured bytes so Ethernet padding is not consumed). Every
20
+ * wire field is a plain clamped integer (no Ajv enum), so a crafted / non-conformant value decoded off
21
+ * the wire re-encodes without being rejected — decode never fails and encode is a faithful executor. A
22
+ * well-formed frame round-trips byte-for-byte.
23
+ */
24
+ export declare class IAX2 extends BaseHeader {
25
+ #private;
26
+ get SCHEMA(): ProtocolJSONSchema;
27
+ readonly id: string;
28
+ readonly name: string;
29
+ readonly nickname: string;
30
+ readonly matchKeys: string[];
31
+ match(): boolean;
32
+ readonly demuxProducers: DemuxProducer[];
33
+ }