@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,229 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Diameter = 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
+ * Diameter (RFC 6733), the RADIUS successor — TCP/SCTP port 3868. A 20-byte fixed header, all
12
+ * big-endian: Version (1, always 1) + Message Length (3, the whole message including the header and the
13
+ * padded AVPs) + Command Flags (1: R/P/E/T in the high nibble) + Command Code (3) + Application-Id (4) +
14
+ * Hop-by-Hop Id (4) + End-to-End Id (4). It is followed by AVPs until the Message Length is consumed.
15
+ *
16
+ * Each AVP is AVP Code(4) + Flags(1: V/M/P) + Length(3, counts the AVP header + data but NOT the trailing
17
+ * padding) + [Vendor-Id(4) only when the V flag 0x80 is set] + data + padding (zero bytes to the next
18
+ * 4-byte boundary). Because the AVP Length excludes the padding, the alignment pad is the tricky part of a
19
+ * byte-perfect round-trip: it is captured verbatim (per AVP, as hex) and re-emitted, so even a malformed
20
+ * non-zero pad reproduces exactly. AVPs are carried generically (code + flags + verbatim hex value) so
21
+ * every AVP — including Grouped AVPs whose value nests sub-AVPs — round-trips; per-AVP semantic decoding
22
+ * is a later enrichment. The walk is bounded by the Message Length (and the captured bytes), so any
23
+ * trailing/pipelined bytes spill to the raw layer.
24
+ *
25
+ * MATCH is a two-signal gate — the well-known port bucket (tcpport:3868) plus a content signature
26
+ * (Version == 1 and a plausible Message Length >= 20) — so there is deliberately NO heuristicFallback:
27
+ * unlike a content-signed protocol (TLS/IEC104), Diameter's first byte (a constant 1) and 3-byte length
28
+ * are far too weak a signature to claim arbitrary off-port TCP traffic, so recognition stays anchored to
29
+ * the port bucket. Non-Diameter traffic on 3868 (or a Version != 1) falls through to raw.
30
+ */
31
+ class Diameter extends BaseHeader_1.BaseHeader {
32
+ constructor() {
33
+ super(...arguments);
34
+ this.id = 'diameter';
35
+ this.name = 'Diameter';
36
+ this.nickname = 'Diameter';
37
+ this.matchKeys = ['tcpport:3868'];
38
+ //A leaf header — AVP values are kept as hex, not demuxed further.
39
+ this.demuxProducers = [];
40
+ }
41
+ static #schemaCache;
42
+ get SCHEMA() {
43
+ return (Diameter.#schemaCache ??= Diameter.#buildSchema());
44
+ }
45
+ /** A 3-octet big-endian unsigned integer at `buffer[0..2]`. */
46
+ static #readUInt24(buffer) {
47
+ return ((buffer[0] << 16) | (buffer[1] << 8) | buffer[2]) >>> 0;
48
+ }
49
+ /** A 3-octet big-endian buffer for `value` (only the low 24 bits are kept). */
50
+ static #uint24ToBuffer(value) {
51
+ const v = value >>> 0;
52
+ return Buffer.from([(v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF]);
53
+ }
54
+ /** Bytes available for this Diameter message: the frame end, clamped by the Message Length. During
55
+ * MATCH the Message Length is unset (0), so this reduces to the captured-frame bound. */
56
+ #available() {
57
+ let available = this.packet.length - this.startPos;
58
+ const messageLength = this.instance.messageLength.getValue(0);
59
+ if (messageLength >= 20 && messageLength < available)
60
+ available = messageLength;
61
+ return available < 0 ? 0 : available;
62
+ }
63
+ static #buildSchema() {
64
+ return {
65
+ type: 'object',
66
+ summary: 'Diameter cmd=${commandCode}',
67
+ properties: {
68
+ version: this.fieldUInt('version', 0, 1, 'Version'),
69
+ messageLength: {
70
+ type: 'integer',
71
+ label: 'Message Length',
72
+ minimum: 0,
73
+ maximum: 16777215,
74
+ decode: function () {
75
+ this.instance.messageLength.setValue(Diameter.#readUInt24(this.readBytes(1, 3)));
76
+ },
77
+ encode: function () {
78
+ //Honor an explicitly-set Message Length (so a decoded malformed length still
79
+ //round-trips byte-for-byte); auto-compute only when the field is absent (crafting).
80
+ //The Message Length counts the whole message — the 20-byte header plus every padded
81
+ //AVP — which is exactly this header's final length after the AVPs have encoded.
82
+ const messageLength = this.instance.messageLength.getValue();
83
+ if (messageLength !== undefined && messageLength !== null) {
84
+ this.instance.messageLength.setValue(messageLength);
85
+ this.writeBytes(1, Diameter.#uint24ToBuffer(messageLength));
86
+ }
87
+ else {
88
+ this.writeBytes(1, Diameter.#uint24ToBuffer(0));
89
+ this.addPostSelfEncodeHandler(() => {
90
+ this.instance.messageLength.setValue(this.length);
91
+ this.writeBytes(1, Diameter.#uint24ToBuffer(this.length));
92
+ }, 1);
93
+ }
94
+ }
95
+ },
96
+ commandFlags: this.fieldUInt('commandFlags', 4, 1, 'Command Flags'),
97
+ commandCode: {
98
+ type: 'integer',
99
+ label: 'Command Code',
100
+ minimum: 0,
101
+ maximum: 16777215,
102
+ decode: function () {
103
+ this.instance.commandCode.setValue(Diameter.#readUInt24(this.readBytes(5, 3)));
104
+ },
105
+ encode: function () {
106
+ const node = this.instance.commandCode;
107
+ let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
108
+ if (value > 16777215) {
109
+ this.recordError(node.getPath(), 'Maximum value is 16777215');
110
+ value = 16777215;
111
+ }
112
+ if (value < 0) {
113
+ this.recordError(node.getPath(), 'Minimum value is 0');
114
+ value = 0;
115
+ }
116
+ node.setValue(value);
117
+ this.writeBytes(5, Diameter.#uint24ToBuffer(value));
118
+ }
119
+ },
120
+ applicationId: this.fieldUInt('applicationId', 8, 4, 'Application-Id'),
121
+ hopByHopId: this.fieldUInt('hopByHopId', 12, 4, 'Hop-by-Hop Identifier'),
122
+ endToEndId: this.fieldUInt('endToEndId', 16, 4, 'End-to-End Identifier'),
123
+ avps: {
124
+ type: 'array',
125
+ label: 'AVPs',
126
+ items: {
127
+ type: 'object',
128
+ label: 'AVP',
129
+ properties: {
130
+ code: { type: 'integer', label: 'AVP Code', minimum: 0, maximum: 4294967295 },
131
+ flags: { type: 'integer', label: 'AVP Flags', minimum: 0, maximum: 255 },
132
+ length: { type: 'integer', label: 'AVP Length', minimum: 0, maximum: 16777215 },
133
+ vendorId: { type: 'integer', label: 'Vendor-Id', minimum: 0, maximum: 4294967295 },
134
+ data: { type: 'string', label: 'Data', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX },
135
+ padding: { type: 'string', label: 'Padding', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
136
+ }
137
+ },
138
+ decode: function () {
139
+ const available = this.#available();
140
+ const avps = [];
141
+ let offset = 20;
142
+ //Each AVP is code(4) flags(1) length(3) [vendorId(4) if V] data padding. A Length
143
+ //below its own header size is invalid (and would not advance), and a Length that
144
+ //overruns the available bytes is truncated — in both cases stop and leave the
145
+ //remaining bytes to the raw layer, keeping the round-trip exact.
146
+ while (offset + 8 <= available) {
147
+ const code = (0, BufferToNumber_1.BufferToUInt32)(this.readBytes(offset, 4, true));
148
+ const flags = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(offset + 4, 1, true));
149
+ const avpLength = Diameter.#readUInt24(this.readBytes(offset + 5, 3, true));
150
+ const hasVendor = (flags & 0x80) !== 0;
151
+ const headerSize = hasVendor ? 12 : 8;
152
+ if (avpLength < headerSize || offset + avpLength > available)
153
+ break;
154
+ //Padding to the next 4-byte boundary is NOT counted in avpLength; the Message
155
+ //Length includes it, so it is within `available` for a well-formed message
156
+ //(clamped defensively for a truncated one).
157
+ const padLength = (4 - (avpLength % 4)) % 4;
158
+ const padAvailable = Math.min(padLength, available - (offset + avpLength));
159
+ const dataLength = avpLength - headerSize;
160
+ const dataOffset = offset + headerSize;
161
+ const avp = {
162
+ code: code,
163
+ flags: flags,
164
+ length: avpLength,
165
+ data: dataLength > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(dataOffset, dataLength)) : '',
166
+ padding: padAvailable > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset + avpLength, padAvailable)) : ''
167
+ };
168
+ if (hasVendor)
169
+ avp.vendorId = (0, BufferToNumber_1.BufferToUInt32)(this.readBytes(offset + 8, 4, true));
170
+ avps.push(avp);
171
+ offset += avpLength + padAvailable;
172
+ }
173
+ this.instance.avps.setValue(avps);
174
+ },
175
+ encode: function () {
176
+ const avps = this.instance.avps.getValue([]);
177
+ if (!avps)
178
+ return;
179
+ let offset = 20;
180
+ for (const avp of avps) {
181
+ const flags = avp.flags ? avp.flags : 0;
182
+ const hasVendor = (flags & 0x80) !== 0;
183
+ const headerSize = hasVendor ? 12 : 8;
184
+ const data = (0, HexToBuffer_1.HexToBuffer)(avp.data ? avp.data : '');
185
+ //Honor an explicit AVP Length (a crafted AVP may lie / a decoded one carries its
186
+ //on-wire value); else derive it from the header size + data. For a decoded AVP
187
+ //these agree exactly, so the walk advances identically to decode.
188
+ const avpLength = (avp.length !== undefined && avp.length !== null)
189
+ ? avp.length
190
+ : headerSize + data.length;
191
+ this.writeBytes(offset, (0, NumberToBuffer_1.UInt32ToBuffer)(avp.code ? avp.code : 0));
192
+ this.writeBytes(offset + 4, (0, NumberToBuffer_1.UInt8ToBuffer)(flags));
193
+ this.writeBytes(offset + 5, Diameter.#uint24ToBuffer(avpLength));
194
+ let dataOffset = offset + 8;
195
+ if (hasVendor) {
196
+ this.writeBytes(offset + 8, (0, NumberToBuffer_1.UInt32ToBuffer)(avp.vendorId ? avp.vendorId : 0));
197
+ dataOffset = offset + 12;
198
+ }
199
+ if (data.length)
200
+ this.writeBytes(dataOffset, data);
201
+ //Padding is kept verbatim so a non-zero/truncated pad round-trips; when absent
202
+ //(crafting) it is derived as zero bytes to the next 4-byte boundary.
203
+ const padding = (avp.padding !== undefined && avp.padding !== null)
204
+ ? (0, HexToBuffer_1.HexToBuffer)(avp.padding)
205
+ : Buffer.alloc((4 - (avpLength % 4)) % 4, 0);
206
+ if (padding.length)
207
+ this.writeBytes(offset + avpLength, padding);
208
+ offset += avpLength + padding.length;
209
+ }
210
+ }
211
+ }
212
+ }
213
+ };
214
+ }
215
+ match() {
216
+ //Diameter rides on TCP port 3868 (the port bucket routes candidates here). Confirm with the
217
+ //content signature: the full 20-byte fixed header present, Version == 1, and a plausible Message
218
+ //Length (>= 20). During MATCH the Message Length field is unset, so #available() is the captured
219
+ //bound only. NO heuristicFallback: this signature is too weak to claim off-port traffic.
220
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'tcp')
221
+ return false;
222
+ if (this.#available() < 20)
223
+ return false;
224
+ if ((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(0, 1, true)) !== 1)
225
+ return false;
226
+ return Diameter.#readUInt24(this.readBytes(1, 3, true)) >= 20;
227
+ }
228
+ }
229
+ exports.Diameter = Diameter;
@@ -0,0 +1,32 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * EAPOL — EAP over LAN (IEEE 802.1X port-based network access control), carried directly in an Ethernet
6
+ * II frame with EtherType 0x888E (an Ethernet child — no IP/UDP). Every EAPOL frame begins with a fixed
7
+ * 4-byte header — Protocol Version (1), Packet Type (1), and Body Length (2, big-endian, the count of
8
+ * body bytes that follow the header) — then `Body Length` bytes of type-specific body.
9
+ *
10
+ * The Packet Type selects the body: 0 = EAP-Packet (an encapsulated EAP message), 1 = EAPOL-Start,
11
+ * 2 = EAPOL-Logoff, 3 = EAPOL-Key (e.g. the WPA/RSN 4-way-handshake key descriptor), 4 = EAPOL-Encapsulated-
12
+ * ASF-Alert. Start/Logoff carry an empty body (Body Length 0). The body is kept verbatim as `body` hex so
13
+ * every frame — including the EAP message and the 802.11 key descriptor, both of which are separate
14
+ * cross-frame/stateful parsers — round-trips byte-for-byte; per-type semantic decoding is a later
15
+ * enrichment.
16
+ *
17
+ * The body is bounded by Body Length (body ends at offset 4 + bodyLength) and the captured bytes, so any
18
+ * trailing bytes — Ethernet padding to the 60-byte minimum, or a pipelined frame — are left to the
19
+ * codec's recursion / RawData rather than swallowed. Body Length is honored verbatim on encode when
20
+ * supplied (a crafted frame may lie), else derived from the body byte count. A well-formed frame
21
+ * round-trips byte-for-byte.
22
+ */
23
+ export declare class EAPOL extends BaseHeader {
24
+ #private;
25
+ get SCHEMA(): ProtocolJSONSchema;
26
+ readonly id: string;
27
+ readonly name: string;
28
+ readonly nickname: string;
29
+ readonly matchKeys: string[];
30
+ match(): boolean;
31
+ readonly demuxProducers: DemuxProducer[];
32
+ }
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EAPOL = 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
+ * EAPOL — EAP over LAN (IEEE 802.1X port-based network access control), carried directly in an Ethernet
10
+ * II frame with EtherType 0x888E (an Ethernet child — no IP/UDP). Every EAPOL frame begins with a fixed
11
+ * 4-byte header — Protocol Version (1), Packet Type (1), and Body Length (2, big-endian, the count of
12
+ * body bytes that follow the header) — then `Body Length` bytes of type-specific body.
13
+ *
14
+ * The Packet Type selects the body: 0 = EAP-Packet (an encapsulated EAP message), 1 = EAPOL-Start,
15
+ * 2 = EAPOL-Logoff, 3 = EAPOL-Key (e.g. the WPA/RSN 4-way-handshake key descriptor), 4 = EAPOL-Encapsulated-
16
+ * ASF-Alert. Start/Logoff carry an empty body (Body Length 0). The body is kept verbatim as `body` hex so
17
+ * every frame — including the EAP message and the 802.11 key descriptor, both of which are separate
18
+ * cross-frame/stateful parsers — round-trips byte-for-byte; per-type semantic decoding is a later
19
+ * enrichment.
20
+ *
21
+ * The body is bounded by Body Length (body ends at offset 4 + bodyLength) and the captured bytes, so any
22
+ * trailing bytes — Ethernet padding to the 60-byte minimum, or a pipelined frame — are left to the
23
+ * codec's recursion / RawData rather than swallowed. Body Length is honored verbatim on encode when
24
+ * supplied (a crafted frame may lie), else derived from the body byte count. A well-formed frame
25
+ * round-trips byte-for-byte.
26
+ */
27
+ class EAPOL extends BaseHeader_1.BaseHeader {
28
+ constructor() {
29
+ super(...arguments);
30
+ this.id = 'eapol';
31
+ this.name = 'EAP over LAN';
32
+ this.nickname = 'EAPOL';
33
+ this.matchKeys = ['ethertype:888e'];
34
+ //A leaf header — the EAP message / EAPOL-Key descriptor requires separate, stateful parsing.
35
+ this.demuxProducers = [];
36
+ }
37
+ static #schemaCache;
38
+ get SCHEMA() {
39
+ return (EAPOL.#schemaCache ??= EAPOL.#buildSchema());
40
+ }
41
+ static #buildSchema() {
42
+ return {
43
+ type: 'object',
44
+ summary: 'EAPOL type=${packetType} len=${bodyLength}',
45
+ properties: {
46
+ //Protocol Version — 1 (802.1X-2001), 2 (802.1X-2004), 3 (802.1X-2010).
47
+ version: this.fieldUInt('version', 0, 1, 'Version'),
48
+ //Packet Type selects the body kind. Constrained to the defined types for the editor; an
49
+ //unknown type still decodes best-effort (decode never validates) but is out of enum on encode.
50
+ packetType: {
51
+ type: 'integer',
52
+ label: 'Packet Type',
53
+ minimum: 0,
54
+ maximum: 255,
55
+ enum: [0, 1, 2, 3, 4],
56
+ decode: function () {
57
+ this.instance.packetType.setValue(this.readBytes(1, 1)[0]);
58
+ },
59
+ encode: function () {
60
+ let value = this.instance.packetType.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
61
+ if (value > 255) {
62
+ this.recordError(this.instance.packetType.getPath(), 'Maximum value is 255');
63
+ value = 255;
64
+ }
65
+ if (value < 0) {
66
+ this.recordError(this.instance.packetType.getPath(), 'Minimum value is 0');
67
+ value = 0;
68
+ }
69
+ this.instance.packetType.setValue(value);
70
+ this.writeBytes(1, Buffer.from([value & 0xff]));
71
+ }
72
+ },
73
+ bodyLength: {
74
+ type: 'integer',
75
+ label: 'Body Length',
76
+ minimum: 0,
77
+ maximum: 65535,
78
+ decode: function () {
79
+ const b = this.readBytes(2, 2);
80
+ this.instance.bodyLength.setValue((b[0] << 8) | b[1]);
81
+ },
82
+ encode: function () {
83
+ //Body Length counts only the body that follows the 4-byte header. Honored when
84
+ //supplied (a crafted frame may lie); else derived from the body byte count.
85
+ const provided = this.instance.bodyLength.getValue();
86
+ let value = (provided !== undefined && provided !== null)
87
+ ? provided
88
+ : (0, HexToBuffer_1.HexToBuffer)(this.instance.body.getValue('')).length;
89
+ if (value > 65535) {
90
+ this.recordError(this.instance.bodyLength.getPath(), 'Maximum value is 65535');
91
+ value = 65535;
92
+ }
93
+ if (value < 0) {
94
+ this.recordError(this.instance.bodyLength.getPath(), 'Minimum value is 0');
95
+ value = 0;
96
+ }
97
+ this.instance.bodyLength.setValue(value);
98
+ this.writeBytes(2, Buffer.from([(value >> 8) & 0xff, value & 0xff]));
99
+ }
100
+ },
101
+ //The type-specific body (EAP message / EAPOL-Key descriptor / …), kept verbatim. Bounded
102
+ //by Body Length (body ends at offset 4 + bodyLength) and the captured bytes, so trailing
103
+ //padding / a pipelined frame is left to the codec's recursion / RawData.
104
+ body: {
105
+ type: 'string',
106
+ label: 'Body',
107
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
108
+ decode: function () {
109
+ const remaining = this.packet.length - this.startPos;
110
+ const bodyLength = this.instance.bodyLength.getValue(0);
111
+ let end = 4 + bodyLength;
112
+ if (end > remaining)
113
+ end = remaining;
114
+ this.instance.body.setValue(end > 4 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(4, end - 4)) : '');
115
+ },
116
+ encode: function () {
117
+ const body = this.instance.body.getValue('');
118
+ if (body)
119
+ this.writeBytes(4, (0, HexToBuffer_1.HexToBuffer)(body));
120
+ }
121
+ }
122
+ }
123
+ };
124
+ }
125
+ match() {
126
+ //An Ethernet child selected by EtherType 0x888E (stored as a lowercase 4-hex string). Require the
127
+ //full 4-byte fixed header to be present.
128
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'eth')
129
+ return false;
130
+ if (this.prevCodecModule.instance.etherType.getValue() !== '888e')
131
+ return false;
132
+ return this.packet.length - this.startPos >= 4;
133
+ }
134
+ }
135
+ exports.EAPOL = EAPOL;
@@ -0,0 +1,28 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * EIGRP — Enhanced Interior Gateway Routing Protocol (Cisco), carried directly over IP as protocol 88.
6
+ * Every EIGRP packet begins with a fixed 20-byte header — Version (1), Opcode (1: 1 Update, 3 Query,
7
+ * 4 Reply, 5 Hello, 10 SIA-Query, 11 SIA-Reply), Checksum (2, the IP-style ones-complement checksum
8
+ * over the whole EIGRP packet), Flags (4), Sequence (4), Acknowledge (4), Virtual Router ID (2) and
9
+ * Autonomous System number (2) — followed by a chain of TLVs. Each TLV is a 2-byte Type, a 2-byte
10
+ * Length (the total TLV octet count including the 4-byte TLV header) and Length-4 value bytes.
11
+ *
12
+ * The TLV chain has no terminator/count, so the walk is bounded by the enclosing IP payload (like GRE /
13
+ * OSPF #available) — a lying Length near the end never reads into a trailing FCS/padding. TLV values are
14
+ * kept verbatim as hex (per-TLV route/parameter bodies are opaque here), so every TLV round-trips
15
+ * byte-for-byte; the Length is honored when supplied (a crafted TLV may lie) else derived from the value
16
+ * byte count. The Checksum is honored verbatim, never recomputed (encode is a faithful executor). A
17
+ * well-formed packet round-trips byte-for-byte. Leaf header — TLV sub-structures are not sub-decoded.
18
+ */
19
+ export declare class EIGRP extends BaseHeader {
20
+ #private;
21
+ get SCHEMA(): ProtocolJSONSchema;
22
+ readonly id: string;
23
+ readonly name: string;
24
+ readonly nickname: string;
25
+ readonly matchKeys: string[];
26
+ match(): boolean;
27
+ readonly demuxProducers: DemuxProducer[];
28
+ }
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EIGRP = 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
+ * EIGRP — Enhanced Interior Gateway Routing Protocol (Cisco), carried directly over IP as protocol 88.
12
+ * Every EIGRP packet begins with a fixed 20-byte header — Version (1), Opcode (1: 1 Update, 3 Query,
13
+ * 4 Reply, 5 Hello, 10 SIA-Query, 11 SIA-Reply), Checksum (2, the IP-style ones-complement checksum
14
+ * over the whole EIGRP packet), Flags (4), Sequence (4), Acknowledge (4), Virtual Router ID (2) and
15
+ * Autonomous System number (2) — followed by a chain of TLVs. Each TLV is a 2-byte Type, a 2-byte
16
+ * Length (the total TLV octet count including the 4-byte TLV header) and Length-4 value bytes.
17
+ *
18
+ * The TLV chain has no terminator/count, so the walk is bounded by the enclosing IP payload (like GRE /
19
+ * OSPF #available) — a lying Length near the end never reads into a trailing FCS/padding. TLV values are
20
+ * kept verbatim as hex (per-TLV route/parameter bodies are opaque here), so every TLV round-trips
21
+ * byte-for-byte; the Length is honored when supplied (a crafted TLV may lie) else derived from the value
22
+ * byte count. The Checksum is honored verbatim, never recomputed (encode is a faithful executor). A
23
+ * well-formed packet round-trips byte-for-byte. Leaf header — TLV sub-structures are not sub-decoded.
24
+ */
25
+ class EIGRP extends BaseHeader_1.BaseHeader {
26
+ constructor() {
27
+ super(...arguments);
28
+ this.id = 'eigrp';
29
+ this.name = 'Enhanced Interior Gateway Routing Protocol';
30
+ this.nickname = 'EIGRP';
31
+ this.matchKeys = ['ipproto:88'];
32
+ //A leaf header — EIGRP TLV bodies are kept as verbatim hex, nothing demuxes above it.
33
+ this.demuxProducers = [];
34
+ }
35
+ /**
36
+ * Bytes of EIGRP the IP layer below says are available. IPv4 carries a total-length field, so the
37
+ * EIGRP payload is (total length - IP header length); IPv6 carries the payload length directly
38
+ * (plen). Mirrors the GRE / OSPF #available() pattern so the TLV walk is bounded by the real on-wire
39
+ * length rather than the captured frame (which may include Ethernet padding after the IP payload).
40
+ * @private
41
+ */
42
+ #available() {
43
+ let available = this.packet.length - this.startPos;
44
+ const prev = this.prevCodecModule;
45
+ if (prev && prev.id === 'ipv4') {
46
+ const ipPayload = prev.instance.length.getValue(0) - prev.length;
47
+ if (ipPayload >= 0 && ipPayload < available)
48
+ available = ipPayload;
49
+ }
50
+ else if (prev && prev.id === 'ipv6') {
51
+ const ipPayload = prev.instance.plen.getValue(0);
52
+ if (ipPayload >= 0 && ipPayload < available)
53
+ available = ipPayload;
54
+ }
55
+ return available < 0 ? 0 : available;
56
+ }
57
+ static #schemaCache;
58
+ get SCHEMA() {
59
+ return (EIGRP.#schemaCache ??= EIGRP.#buildSchema());
60
+ }
61
+ static #buildSchema() {
62
+ return {
63
+ type: 'object',
64
+ summary: 'EIGRP opcode=${opcode} as=${autonomousSystem}',
65
+ properties: {
66
+ //==== Fixed 20-byte header ====
67
+ version: this.fieldUInt('version', 0, 1, 'Version'),
68
+ opcode: this.fieldUInt('opcode', 1, 1, 'Opcode'),
69
+ //Honored verbatim: the EIGRP checksum (ones-complement over the whole packet with the
70
+ //checksum field zeroed) is never recomputed, so a captured packet round-trips byte-for-byte.
71
+ checksum: this.fieldUInt('checksum', 2, 2, 'Checksum'),
72
+ flags: this.fieldUInt('flags', 4, 4, 'Flags'),
73
+ sequence: this.fieldUInt('sequence', 8, 4, 'Sequence'),
74
+ ack: this.fieldUInt('ack', 12, 4, 'Acknowledge'),
75
+ virtualRouterId: this.fieldUInt('virtualRouterId', 16, 2, 'Virtual Router ID'),
76
+ autonomousSystem: this.fieldUInt('autonomousSystem', 18, 2, 'Autonomous System'),
77
+ //==== TLV chain (type + length-incl-header + verbatim value) ====
78
+ tlvs: {
79
+ type: 'array',
80
+ label: 'TLVs',
81
+ items: {
82
+ type: 'object',
83
+ label: 'TLV',
84
+ properties: {
85
+ type: { type: 'integer', label: 'Type', minimum: 0, maximum: 65535 },
86
+ length: { type: 'integer', label: 'Length', minimum: 0, maximum: 65535 },
87
+ value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
88
+ }
89
+ },
90
+ decode: function () {
91
+ //The TLV chain has no terminator/count — bound the walk by the IP payload so a
92
+ //corrupt Length can't read past the datagram into an FCS/padding. Each TLV is a
93
+ //2-byte Type + 2-byte Length (whole-TLV octet count incl. the 4-byte header).
94
+ const available = this.#available();
95
+ const tlvs = [];
96
+ let offset = 20;
97
+ while (offset + 4 <= available) {
98
+ const type = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset, 2));
99
+ const length = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset + 2, 2));
100
+ //Value byte count = Length - 4; clamp to the bytes actually available (a lying
101
+ //Length is stored verbatim but never over-reads). The step is always >= 4, so
102
+ //the walk cannot stall even on a zero/undersized Length.
103
+ let valueLen = length - 4;
104
+ if (valueLen < 0)
105
+ valueLen = 0;
106
+ if (offset + 4 + valueLen > available)
107
+ valueLen = available - offset - 4;
108
+ const value = valueLen > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset + 4, valueLen)) : '';
109
+ tlvs.push({ type: type, length: length, value: value });
110
+ offset += 4 + valueLen;
111
+ }
112
+ this.instance.tlvs.setValue(tlvs);
113
+ },
114
+ encode: function () {
115
+ const tlvs = this.instance.tlvs.getValue([]);
116
+ let offset = 20;
117
+ if (tlvs) {
118
+ for (let i = 0; i < tlvs.length; i++) {
119
+ const tlv = tlvs[i];
120
+ const value = (0, HexToBuffer_1.HexToBuffer)(tlv.value ? tlv.value : '');
121
+ let type = tlv.type ? tlv.type : 0;
122
+ if (type > 65535) {
123
+ this.recordError(`tlvs[${i}].type`, 'Maximum value is 65535');
124
+ type = 65535;
125
+ }
126
+ if (type < 0)
127
+ type = 0;
128
+ //Length is honored when supplied (a crafted TLV may lie about its size),
129
+ //else derived from the 4-byte header + the actual value byte count.
130
+ let length = (tlv.length !== undefined && tlv.length !== null)
131
+ ? tlv.length
132
+ : 4 + value.length;
133
+ if (length > 65535) {
134
+ this.recordError(`tlvs[${i}].length`, 'Maximum value is 65535');
135
+ length = 65535;
136
+ }
137
+ if (length < 0)
138
+ length = 0;
139
+ this.writeBytes(offset, (0, NumberToBuffer_1.UInt16ToBuffer)(type));
140
+ this.writeBytes(offset + 2, (0, NumberToBuffer_1.UInt16ToBuffer)(length));
141
+ offset += 4;
142
+ if (value.length) {
143
+ this.writeBytes(offset, value);
144
+ offset += value.length;
145
+ }
146
+ }
147
+ }
148
+ }
149
+ }
150
+ }
151
+ };
152
+ }
153
+ match() {
154
+ //EIGRP sits directly on IP (protocol 88). Accept the demux value from either the IPv4 protocol
155
+ //field or the IPv6 next-header field, and require at least the fixed 20-byte header of IP payload.
156
+ if (!this.prevCodecModule)
157
+ return false;
158
+ const protocol = this.prevCodecModule.instance.protocol.getValue(0);
159
+ const nextHeader = this.prevCodecModule.instance.nxt.getValue(0);
160
+ if (protocol !== 88 && nextHeader !== 88)
161
+ return false;
162
+ return this.#available() >= 20;
163
+ }
164
+ }
165
+ exports.EIGRP = EIGRP;
@@ -0,0 +1,31 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * EtherNet/IP encapsulation (ODVA / IEC 61158, IEC 61784), TCP & UDP port 44818. Every EtherNet/IP
6
+ * message begins with a fixed 24-byte encapsulation header — Command, Length (the count of bytes that
7
+ * follow the header), Session Handle, Status, an 8-byte Sender Context echoed back by the target, and an
8
+ * Options field — followed by `Length` bytes of command-specific data (the CIP Common Packet Format /
9
+ * encapsulated CIP request or reply).
10
+ *
11
+ * ⚠️ Unlike most of the codec's protocols, every multi-byte field in this header is LITTLE-ENDIAN (ODVA
12
+ * inherits the CIP on-wire byte order). There is no little-endian helper in this codebase, so the uint16
13
+ * / uint32 fields are read and written byte-by-byte in their closures.
14
+ *
15
+ * The command-specific data is the CIP/CPF payload; decoding it (item counts, address/data items, the
16
+ * embedded CIP service request) is cross-message and command-dependent state, so this single-message
17
+ * codec keeps it verbatim as `data` hex (byte-perfect). The Length is auto-computed from the data on
18
+ * encode when not supplied, else honored verbatim (a crafted message may carry any Length); the data is
19
+ * bounded by the Length field so a pipelined/trailing message is left to the codec's recursion / RawData.
20
+ * A well-formed message round-trips byte-for-byte.
21
+ */
22
+ export declare class ENIP 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
+ match(): boolean;
30
+ readonly demuxProducers: DemuxProducer[];
31
+ }