@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,26 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * LLDP — Link Layer Discovery Protocol (IEEE 802.1AB), carried directly in an Ethernet II frame with
6
+ * EtherType 0x88CC (an Ethernet child — no IP/UDP). An LLDPDU is a flat sequence of TLVs; each TLV is a
7
+ * 2-byte header — Type (7 bits, the high bits 15..9) + Length (9 bits, bits 8..0, the value byte count) —
8
+ * followed by Length value bytes. The mandatory TLVs come first in order (Chassis ID = 1, Port ID = 2,
9
+ * Time To Live = 3), then zero or more optional TLVs, terminated by the End Of LLDPDU TLV (type 0,
10
+ * length 0). LLDP has no length field of its own — it runs to the end of the frame.
11
+ *
12
+ * TLVs are carried generically (type + verbatim hex value) so every TLV — including optional and
13
+ * organization-specific ones whose value is opaque — round-trips byte-for-byte; per-TLV semantic decoding
14
+ * is a later enrichment. The walk stops at the End TLV (type 0) or when the frame is exhausted; any bytes
15
+ * after the End TLV are Ethernet padding, kept verbatim in `padding` so the frame is reproduced exactly.
16
+ */
17
+ export declare class LLDP extends BaseHeader {
18
+ #private;
19
+ get SCHEMA(): ProtocolJSONSchema;
20
+ readonly id: string;
21
+ readonly name: string;
22
+ readonly nickname: string;
23
+ readonly matchKeys: string[];
24
+ match(): boolean;
25
+ readonly demuxProducers: DemuxProducer[];
26
+ }
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LLDP = 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
+ * LLDP — Link Layer Discovery Protocol (IEEE 802.1AB), carried directly in an Ethernet II frame with
10
+ * EtherType 0x88CC (an Ethernet child — no IP/UDP). An LLDPDU is a flat sequence of TLVs; each TLV is a
11
+ * 2-byte header — Type (7 bits, the high bits 15..9) + Length (9 bits, bits 8..0, the value byte count) —
12
+ * followed by Length value bytes. The mandatory TLVs come first in order (Chassis ID = 1, Port ID = 2,
13
+ * Time To Live = 3), then zero or more optional TLVs, terminated by the End Of LLDPDU TLV (type 0,
14
+ * length 0). LLDP has no length field of its own — it runs to the end of the frame.
15
+ *
16
+ * TLVs are carried generically (type + verbatim hex value) so every TLV — including optional and
17
+ * organization-specific ones whose value is opaque — round-trips byte-for-byte; per-TLV semantic decoding
18
+ * is a later enrichment. The walk stops at the End TLV (type 0) or when the frame is exhausted; any bytes
19
+ * after the End TLV are Ethernet padding, kept verbatim in `padding` so the frame is reproduced exactly.
20
+ */
21
+ class LLDP extends BaseHeader_1.BaseHeader {
22
+ constructor() {
23
+ super(...arguments);
24
+ this.id = 'lldp';
25
+ this.name = 'Link Layer Discovery Protocol';
26
+ this.nickname = 'LLDP';
27
+ this.matchKeys = ['ethertype:88cc'];
28
+ //A leaf header — nothing demuxes above LLDP.
29
+ this.demuxProducers = [];
30
+ }
31
+ static #schemaCache;
32
+ get SCHEMA() {
33
+ return (LLDP.#schemaCache ??= LLDP.#buildSchema());
34
+ }
35
+ static #buildSchema() {
36
+ return {
37
+ type: 'object',
38
+ summary: 'LLDP ${tlvs.length} TLVs',
39
+ properties: {
40
+ tlvs: {
41
+ type: 'array',
42
+ label: 'TLVs',
43
+ items: {
44
+ type: 'object',
45
+ label: 'TLV',
46
+ properties: {
47
+ type: { type: 'integer', label: 'Type', minimum: 0, maximum: 127 },
48
+ value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
49
+ }
50
+ },
51
+ decode: function () {
52
+ //LLDP runs to the end of the frame — there is no length field. Bound the walk by the
53
+ //remaining frame bytes, reading each 2-byte TLV header as type(7)+length(9), MSB-first.
54
+ const available = this.packet.length - this.startPos;
55
+ const tlvs = [];
56
+ let offset = 0;
57
+ while (offset + 2 <= available) {
58
+ const type = this.readBits(offset, 2, 0, 7);
59
+ const length = this.readBits(offset, 2, 7, 9);
60
+ //A value that overruns the frame (truncation) is not consumed — stop and leave the
61
+ //remaining bytes to `padding`, keeping the round-trip exact.
62
+ if (offset + 2 + length > available)
63
+ break;
64
+ const value = length > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset + 2, length)) : '';
65
+ tlvs.push({ type: type, value: value });
66
+ offset += 2 + length;
67
+ //End Of LLDPDU (type 0): logical end of the PDU — anything after is padding.
68
+ if (type === 0)
69
+ break;
70
+ }
71
+ this.instance.tlvs.setValue(tlvs);
72
+ //Trailing bytes after the End TLV (or after a truncated TLV) are Ethernet padding.
73
+ this.instance.padding.setValue(offset < available ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset, available - offset)) : '');
74
+ },
75
+ encode: function () {
76
+ const tlvs = this.instance.tlvs.getValue([]);
77
+ let offset = 0;
78
+ if (tlvs) {
79
+ for (let i = 0; i < tlvs.length; i++) {
80
+ const tlv = tlvs[i];
81
+ let value = (0, HexToBuffer_1.HexToBuffer)(tlv.value ? tlv.value : '');
82
+ //The TLV length is a 9-bit field (max 511 bytes). A longer value cannot be
83
+ //represented, so clamp it and record the error rather than silently wrapping
84
+ //the length modulo 512 (which would corrupt the following TLVs).
85
+ if (value.length > 511) {
86
+ this.recordError(`tlvs[${i}].value`, 'Maximum TLV value length is 511 bytes');
87
+ value = value.subarray(0, 511);
88
+ }
89
+ //Pack the 2-byte header: type in the high 7 bits, the value byte count in the
90
+ //low 9 bits. writeBits masks each field, so type and length never clobber.
91
+ this.writeBits(offset, 2, 0, 7, tlv.type ? tlv.type : 0);
92
+ this.writeBits(offset, 2, 7, 9, value.length);
93
+ offset += 2;
94
+ if (value.length) {
95
+ this.writeBytes(offset, value);
96
+ offset += value.length;
97
+ }
98
+ }
99
+ }
100
+ const padding = this.instance.padding.getValue('');
101
+ if (padding)
102
+ this.writeBytes(offset, (0, HexToBuffer_1.HexToBuffer)(padding));
103
+ }
104
+ },
105
+ //Ethernet padding after the End Of LLDPDU TLV, kept verbatim. No codec of its own — it is
106
+ //set/read by the `tlvs` field (which owns the single offset walk); this entry is metadata
107
+ //so the editor sees the padding bytes.
108
+ padding: {
109
+ type: 'string',
110
+ label: 'Padding',
111
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX
112
+ }
113
+ }
114
+ };
115
+ }
116
+ match() {
117
+ //An Ethernet child selected by EtherType 0x88CC (stored as a lowercase 4-hex string). Require the
118
+ //2-byte minimum for one TLV header.
119
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'eth')
120
+ return false;
121
+ if (this.prevCodecModule.instance.etherType.getValue() !== '88cc')
122
+ return false;
123
+ return this.packet.length - this.startPos >= 2;
124
+ }
125
+ }
126
+ exports.LLDP = LLDP;
@@ -0,0 +1,23 @@
1
+ import { DNS } from './DNS';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ /**
4
+ * LLMNR — Link-Local Multicast Name Resolution (RFC 4795). Like mDNS, the on-wire message is the
5
+ * standard DNS message format (RFC 1035): the same 12-byte header, questions, and resource records
6
+ * with label compression. LLMNR reinterprets two header bits that DNS already carries verbatim (the C
7
+ * "conflict" and T "tentative" bits inside the flags word), so the inherited DNS decode/encode
8
+ * round-trips every LLMNR message byte-perfect. Only the identity, the demux port (UDP 5355), the Info
9
+ * summary, and a tightened match() differ. Multicast group 224.0.0.252 / ff02::1:3.
10
+ */
11
+ export declare class LLMNR extends DNS {
12
+ #private;
13
+ get SCHEMA(): ProtocolJSONSchema;
14
+ readonly id: string;
15
+ readonly name: string;
16
+ readonly nickname: string;
17
+ readonly matchKeys: string[];
18
+ /**
19
+ * LLMNR uses UDP port 5355 and never the classic DNS port 53. As UDP produces its demux keys
20
+ * destination-port-first, reject any packet that carries port 53 (that is DNS) and require 5355.
21
+ */
22
+ match(): boolean;
23
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LLMNR = void 0;
4
+ const DNS_1 = require("./DNS");
5
+ /**
6
+ * LLMNR — Link-Local Multicast Name Resolution (RFC 4795). Like mDNS, the on-wire message is the
7
+ * standard DNS message format (RFC 1035): the same 12-byte header, questions, and resource records
8
+ * with label compression. LLMNR reinterprets two header bits that DNS already carries verbatim (the C
9
+ * "conflict" and T "tentative" bits inside the flags word), so the inherited DNS decode/encode
10
+ * round-trips every LLMNR message byte-perfect. Only the identity, the demux port (UDP 5355), the Info
11
+ * summary, and a tightened match() differ. Multicast group 224.0.0.252 / ff02::1:3.
12
+ */
13
+ class LLMNR extends DNS_1.DNS {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.id = 'llmnr';
17
+ this.name = 'Link-Local Multicast Name Resolution';
18
+ this.nickname = 'LLMNR';
19
+ this.matchKeys = ['udpport:5355'];
20
+ }
21
+ static #schemaCache;
22
+ //Reuse the parent DNS schema (identical wire format + closures) but relabel the Info summary.
23
+ get SCHEMA() {
24
+ return (LLMNR.#schemaCache ??= { ...super.SCHEMA, summary: 'LLMNR ${id} queries=${qdcount} answers=${ancount}' });
25
+ }
26
+ /**
27
+ * LLMNR uses UDP port 5355 and never the classic DNS port 53. As UDP produces its demux keys
28
+ * destination-port-first, reject any packet that carries port 53 (that is DNS) and require 5355.
29
+ */
30
+ match() {
31
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'udp')
32
+ return false;
33
+ const srcport = this.prevCodecModule.instance.srcport.getValue(0);
34
+ const dstport = this.prevCodecModule.instance.dstport.getValue(0);
35
+ if (srcport === 53 || dstport === 53)
36
+ return false;
37
+ return srcport === 5355 || dstport === 5355;
38
+ }
39
+ }
40
+ exports.LLMNR = LLMNR;
@@ -0,0 +1,31 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * LPD / LPR — the Line Printer Daemon protocol (RFC 1179), the classic BSD print-spooling protocol
6
+ * carried over TCP port 515. A command message is US-ASCII text: a single 1-byte command code followed
7
+ * by operands (ASCII, space-separated — typically the queue name, and for some commands a user/job
8
+ * list) terminated by a line feed (0x0A). The daemon commands are 0x01 "Print any waiting jobs",
9
+ * 0x02 "Receive a printer job", 0x03/0x04 "Send queue state" (short/long), 0x05 "Remove jobs"; inside a
10
+ * receive-job session the same 1-byte-code framing carries the sub-commands (abort / receive control
11
+ * file / receive data file), followed by the transferred file bytes.
12
+ *
13
+ * Like SIP/HTTP, an LPD stream mixes a short command line with arbitrary (and, for the data-transfer
14
+ * sub-commands, binary) file content whose framing spans TCP segments — richer than a form needs and
15
+ * whitespace-significant. So the ENTIRE payload is kept verbatim as the authoritative `message` field
16
+ * (hex) and re-emitted untouched (byte-perfect for any LPD message); only the leading command byte and
17
+ * its operand line are parsed on decode into display-only metadata (command / commandName / operands),
18
+ * which carry no codec of their own — encode never reconstructs the message from them. The payload is
19
+ * bounded by the enclosing IP datagram (not the whole frame) so a short command does not swallow
20
+ * Ethernet padding; any trailing bytes fall through to the codec's recursion / RawData.
21
+ */
22
+ export declare class LPD 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
+ }
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LPD = 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
+ /** Human-readable names for the LPD command codes (RFC 1179 §5 daemon commands + §6 receive-job subcommands). */
9
+ const LPD_COMMANDS = {
10
+ 0x01: 'Print any waiting jobs',
11
+ 0x02: 'Receive a printer job',
12
+ 0x03: 'Send queue state (short)',
13
+ 0x04: 'Send queue state (long)',
14
+ 0x05: 'Remove jobs'
15
+ };
16
+ /**
17
+ * LPD / LPR — the Line Printer Daemon protocol (RFC 1179), the classic BSD print-spooling protocol
18
+ * carried over TCP port 515. A command message is US-ASCII text: a single 1-byte command code followed
19
+ * by operands (ASCII, space-separated — typically the queue name, and for some commands a user/job
20
+ * list) terminated by a line feed (0x0A). The daemon commands are 0x01 "Print any waiting jobs",
21
+ * 0x02 "Receive a printer job", 0x03/0x04 "Send queue state" (short/long), 0x05 "Remove jobs"; inside a
22
+ * receive-job session the same 1-byte-code framing carries the sub-commands (abort / receive control
23
+ * file / receive data file), followed by the transferred file bytes.
24
+ *
25
+ * Like SIP/HTTP, an LPD stream mixes a short command line with arbitrary (and, for the data-transfer
26
+ * sub-commands, binary) file content whose framing spans TCP segments — richer than a form needs and
27
+ * whitespace-significant. So the ENTIRE payload is kept verbatim as the authoritative `message` field
28
+ * (hex) and re-emitted untouched (byte-perfect for any LPD message); only the leading command byte and
29
+ * its operand line are parsed on decode into display-only metadata (command / commandName / operands),
30
+ * which carry no codec of their own — encode never reconstructs the message from them. The payload is
31
+ * bounded by the enclosing IP datagram (not the whole frame) so a short command does not swallow
32
+ * Ethernet padding; any trailing bytes fall through to the codec's recursion / RawData.
33
+ */
34
+ class LPD extends BaseHeader_1.BaseHeader {
35
+ constructor() {
36
+ super(...arguments);
37
+ this.id = 'lpd';
38
+ this.name = 'Line Printer Daemon Protocol';
39
+ this.nickname = 'LPD';
40
+ this.matchKeys = ['tcpport:515'];
41
+ //A leaf header — the transferred control/data file bytes of a receive-job session are kept verbatim.
42
+ this.demuxProducers = [];
43
+ }
44
+ static #schemaCache;
45
+ get SCHEMA() {
46
+ return (LPD.#schemaCache ??= LPD.#buildSchema());
47
+ }
48
+ /**
49
+ * Bytes of this LPD layer: LPD rides on TCP (no per-message length), so the payload is the rest of
50
+ * the segment — but bounded by the enclosing IPv4/IPv6 datagram so a small command line does not
51
+ * absorb Ethernet padding (min-frame zero padding after a short IP packet). The TCP payload =
52
+ * IP payload − TCP header length; trailing bytes past that are left to the codec's recursion.
53
+ */
54
+ #payloadLength() {
55
+ let available = this.packet.length - this.startPos;
56
+ const tcp = this.prevCodecModule;
57
+ if (tcp) {
58
+ //Walk back to the enclosing IP layer (skip the TCP module itself at the tail).
59
+ const modules = this.prevCodecModules;
60
+ for (let i = modules.length - 2; i >= 0; i--) {
61
+ const module = modules[i];
62
+ if (module.id === 'ipv4') {
63
+ const tcpPayload = (module.instance.length.getValue(0) - module.length) - tcp.length;
64
+ if (tcpPayload >= 0 && tcpPayload < available)
65
+ available = tcpPayload;
66
+ break;
67
+ }
68
+ if (module.id === 'ipv6') {
69
+ const tcpPayload = module.instance.plen.getValue(0) - tcp.length;
70
+ if (tcpPayload >= 0 && tcpPayload < available)
71
+ available = tcpPayload;
72
+ break;
73
+ }
74
+ }
75
+ }
76
+ return available < 0 ? 0 : available;
77
+ }
78
+ /**
79
+ * Parse the display-only metadata from the payload: the leading command byte, its human-readable
80
+ * name, and the operand text (the ASCII bytes after the command byte up to the first line feed).
81
+ * Populated on decode only — these fields have no encode, so they never affect the re-emitted bytes.
82
+ * Never throws: an empty payload yields command 0 / empty operands.
83
+ */
84
+ #parseCommand(raw) {
85
+ const command = raw.length > 0 ? raw[0] : 0;
86
+ this.instance.command.setValue(command);
87
+ this.instance.commandName.setValue(LPD_COMMANDS[command] ? LPD_COMMANDS[command] : '');
88
+ let end = raw.indexOf(0x0a, 1);
89
+ if (end < 0)
90
+ end = raw.length;
91
+ this.instance.operands.setValue(raw.length > 1 ? raw.subarray(1, end).toString('latin1') : '');
92
+ }
93
+ static #buildSchema() {
94
+ return {
95
+ type: 'object',
96
+ summary: 'LPD command=${command}',
97
+ properties: {
98
+ //The whole raw payload is the single source of truth: decoded verbatim to hex and
99
+ //re-emitted untouched (byte-perfect for any LPD message). The command byte + operand line
100
+ //are parsed into the display-only metadata below, which carry no codec of their own.
101
+ message: {
102
+ type: 'string',
103
+ label: 'Message',
104
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
105
+ decode: function () {
106
+ const available = this.#payloadLength();
107
+ if (available <= 0) {
108
+ this.instance.message.setValue('');
109
+ this.#parseCommand(Buffer.alloc(0));
110
+ return;
111
+ }
112
+ const raw = this.readBytes(0, available);
113
+ this.instance.message.setValue((0, BufferToHex_1.BufferToHex)(raw));
114
+ this.#parseCommand(raw);
115
+ },
116
+ encode: function () {
117
+ //Re-emit the authoritative payload verbatim — never reconstruct from metadata.
118
+ this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(this.instance.message.getValue('')));
119
+ }
120
+ },
121
+ //Display-only metadata parsed from the payload on decode (no encode — populated by the
122
+ //message field above, never read back). command is the 1-byte code, commandName its
123
+ //RFC 1179 label, operands the ASCII operand line up to the first line feed.
124
+ command: { type: 'integer', label: 'Command', minimum: 0, maximum: 255 },
125
+ commandName: { type: 'string', label: 'Command Name' },
126
+ operands: { type: 'string', label: 'Operands' }
127
+ }
128
+ };
129
+ }
130
+ match() {
131
+ //LPD rides on TCP port 515 (selected via the tcpport:515 bucket). This stays a port-bucket
132
+ //protocol: matchKeys only, NO heuristicFallback — a leading 1-byte command code is far too weak
133
+ //a signature to claim LPD off port 515, and non-LPD traffic on 515 must fall through to raw. Guard
134
+ //on port + a valid command code (0x01..0x05) followed by an ASCII operand line ending in a line
135
+ //feed (LF), so binary/garbage on 515 is not claimed. Bounded by the transport payload (not the
136
+ //whole frame) so Ethernet padding is not mistaken for the command line.
137
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'tcp')
138
+ return false;
139
+ const available = this.#payloadLength();
140
+ if (available < 2)
141
+ return false;
142
+ const scan = available < 256 ? available : 256;
143
+ const lead = this.readBytes(0, scan, true);
144
+ const command = lead[0];
145
+ if (command < 0x01 || command > 0x05)
146
+ return false;
147
+ //The operand bytes (after the command code, up to the first LF) must be printable ASCII, and a
148
+ //terminating LF must be present within the scanned window.
149
+ for (let i = 1; i < lead.length; i++) {
150
+ const byte = lead[i];
151
+ if (byte === 0x0a)
152
+ return true;
153
+ if (byte < 0x20 || byte > 0x7e)
154
+ return false;
155
+ }
156
+ return false;
157
+ }
158
+ }
159
+ exports.LPD = LPD;
@@ -0,0 +1,34 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * MACsec — MAC Security (IEEE 802.1AE), carried directly in an Ethernet II frame with EtherType 0x88E5
6
+ * (an Ethernet child — no IP/UDP). Each frame carries a Security TAG (SecTAG) followed by the secured
7
+ * user data and a trailing Integrity Check Value (ICV).
8
+ *
9
+ * The SecTAG is 6 or 14 octets:
10
+ * - byte 0: TCI (TAG Control Information, high 6 bits) + AN (Association Number, low 2 bits). The TCI
11
+ * bits, MSB-first, are V (Version), ES (End Station), SC (SCI present), SCB (Single Copy Broadcast),
12
+ * E (Encryption), C (Changed text).
13
+ * - byte 1: SL (Short Length) — the secured-data octet count when it is < 48, else 0. Informational
14
+ * here; it does not bound the secured data (the ICV does).
15
+ * - bytes 2..5: PN (Packet Number) — big-endian 32-bit anti-replay counter.
16
+ * - bytes 6..13: SCI (Secure Channel Identifier) — 8 octets, present only when the SC bit is set.
17
+ *
18
+ * After the SecTAG comes the secured data (the original frame's user data — encrypted when the E bit is
19
+ * set, otherwise authenticated cleartext) and a fixed 16-octet ICV at the very end of the frame. Without
20
+ * the SA keys the secured region cannot be split, so — like ESP — MACsec is a leaf: the SecTAG fields are
21
+ * surfaced and the secured data + ICV are kept verbatim as hex. The secured data spans from the end of
22
+ * the SecTAG to the last 16 octets (the ICV); nothing is recomputed on encode (a faithful executor
23
+ * carries the ciphertext and ICV as-is), so a well-formed MACsec frame round-trips byte-for-byte.
24
+ */
25
+ export declare class MACsec extends BaseHeader {
26
+ #private;
27
+ get SCHEMA(): ProtocolJSONSchema;
28
+ readonly id: string;
29
+ readonly name: string;
30
+ readonly nickname: string;
31
+ readonly matchKeys: string[];
32
+ match(): boolean;
33
+ readonly demuxProducers: DemuxProducer[];
34
+ }
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MACsec = 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
+ * MACsec — MAC Security (IEEE 802.1AE), carried directly in an Ethernet II frame with EtherType 0x88E5
10
+ * (an Ethernet child — no IP/UDP). Each frame carries a Security TAG (SecTAG) followed by the secured
11
+ * user data and a trailing Integrity Check Value (ICV).
12
+ *
13
+ * The SecTAG is 6 or 14 octets:
14
+ * - byte 0: TCI (TAG Control Information, high 6 bits) + AN (Association Number, low 2 bits). The TCI
15
+ * bits, MSB-first, are V (Version), ES (End Station), SC (SCI present), SCB (Single Copy Broadcast),
16
+ * E (Encryption), C (Changed text).
17
+ * - byte 1: SL (Short Length) — the secured-data octet count when it is < 48, else 0. Informational
18
+ * here; it does not bound the secured data (the ICV does).
19
+ * - bytes 2..5: PN (Packet Number) — big-endian 32-bit anti-replay counter.
20
+ * - bytes 6..13: SCI (Secure Channel Identifier) — 8 octets, present only when the SC bit is set.
21
+ *
22
+ * After the SecTAG comes the secured data (the original frame's user data — encrypted when the E bit is
23
+ * set, otherwise authenticated cleartext) and a fixed 16-octet ICV at the very end of the frame. Without
24
+ * the SA keys the secured region cannot be split, so — like ESP — MACsec is a leaf: the SecTAG fields are
25
+ * surfaced and the secured data + ICV are kept verbatim as hex. The secured data spans from the end of
26
+ * the SecTAG to the last 16 octets (the ICV); nothing is recomputed on encode (a faithful executor
27
+ * carries the ciphertext and ICV as-is), so a well-formed MACsec frame round-trips byte-for-byte.
28
+ */
29
+ class MACsec extends BaseHeader_1.BaseHeader {
30
+ constructor() {
31
+ super(...arguments);
32
+ this.id = 'macsec';
33
+ this.name = 'MAC Security';
34
+ this.nickname = 'MACsec';
35
+ this.matchKeys = ['ethertype:88e5'];
36
+ //A leaf header — the secured data is opaque without the SA keys and cannot be dissected further.
37
+ this.demuxProducers = [];
38
+ }
39
+ static #schemaCache;
40
+ get SCHEMA() {
41
+ return (MACsec.#schemaCache ??= MACsec.#buildSchema());
42
+ }
43
+ /** SecTAG length: 6 octets, plus the 8-octet SCI when the SC bit (byte 0, bit 5 MSB-first) is set. */
44
+ #sectagLength() {
45
+ return this.instance.sc.getValue(0) ? 14 : 6;
46
+ }
47
+ /**
48
+ * A field packed into the first SecTAG octet (byte 0): `bitLength` bits at `bitOffset` (MSB-first).
49
+ * Decode reads it into `name`; encode clamps to the field's range (recording an error, never
50
+ * throwing) and overlays it via writeBits — each sub-field masks its own bits so they never clobber.
51
+ */
52
+ static #fieldBits(name, bitOffset, bitLength, label) {
53
+ const maximum = (1 << bitLength) - 1;
54
+ return {
55
+ type: 'integer',
56
+ label: label,
57
+ minimum: 0,
58
+ maximum: maximum,
59
+ decode: function () {
60
+ this.instance[name].setValue(this.readBits(0, 1, bitOffset, bitLength));
61
+ },
62
+ encode: function () {
63
+ const node = this.instance[name];
64
+ let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
65
+ if (value > maximum) {
66
+ this.recordError(node.getPath(), `Maximum value is ${maximum}`);
67
+ value = maximum;
68
+ }
69
+ if (value < 0) {
70
+ this.recordError(node.getPath(), 'Minimum value is 0');
71
+ value = 0;
72
+ }
73
+ node.setValue(value);
74
+ this.writeBits(0, 1, bitOffset, bitLength, value);
75
+ }
76
+ };
77
+ }
78
+ static #buildSchema() {
79
+ return {
80
+ type: 'object',
81
+ summary: 'MACsec an=${an} pn=${packetNumber}',
82
+ properties: {
83
+ //TCI (TAG Control Information) — the high 6 bits of SecTAG byte 0, MSB-first, then AN.
84
+ version: this.#fieldBits('version', 0, 1, 'Version (V)'),
85
+ es: this.#fieldBits('es', 1, 1, 'End Station (ES)'),
86
+ sc: this.#fieldBits('sc', 2, 1, 'SCI Present (SC)'),
87
+ scb: this.#fieldBits('scb', 3, 1, 'Single Copy Broadcast (SCB)'),
88
+ encryption: this.#fieldBits('encryption', 4, 1, 'Encryption (E)'),
89
+ changed: this.#fieldBits('changed', 5, 1, 'Changed Text (C)'),
90
+ //Association Number — the low 2 bits of SecTAG byte 0.
91
+ an: this.#fieldBits('an', 6, 2, 'Association Number (AN)'),
92
+ //Short Length — secured-data octet count when < 48, else 0. Informational; honored verbatim.
93
+ shortLength: this.fieldUInt('shortLength', 1, 1, 'Short Length (SL)'),
94
+ //Packet Number — big-endian 32-bit anti-replay counter.
95
+ packetNumber: this.fieldUInt('packetNumber', 2, 4, 'Packet Number'),
96
+ //Secure Channel Identifier — 8 octets, present only when the SC bit is set. Its presence
97
+ //shifts the secured data / ICV by 8 octets (see #sectagLength). Normalised to 8 octets on
98
+ //encode so the SecTAG length stays consistent with the SC bit.
99
+ sci: {
100
+ type: 'string',
101
+ label: 'SCI',
102
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
103
+ decode: function () {
104
+ this.instance.sci.setValue(this.instance.sc.getValue(0) ? (0, BufferToHex_1.BufferToHex)(this.readBytes(6, 8)) : '');
105
+ },
106
+ encode: function () {
107
+ if (!this.instance.sc.getValue(0)) {
108
+ this.instance.sci.setValue('');
109
+ return;
110
+ }
111
+ let buffer = (0, HexToBuffer_1.HexToBuffer)(this.instance.sci.getValue('0000000000000000'));
112
+ if (buffer.length !== 8) {
113
+ this.recordError(this.instance.sci.getPath(), 'SCI must be 8 octets when the SC bit is set');
114
+ const fixed = Buffer.alloc(8, 0);
115
+ buffer.copy(fixed, 0, 0, Math.min(8, buffer.length));
116
+ buffer = fixed;
117
+ }
118
+ this.instance.sci.setValue((0, BufferToHex_1.BufferToHex)(buffer));
119
+ this.writeBytes(6, buffer);
120
+ }
121
+ },
122
+ //The secured user data (encrypted when the E bit is set, else authenticated cleartext),
123
+ //kept verbatim. Spans from the end of the SecTAG to the last 16 octets (the ICV); bounded
124
+ //so the trailing ICV is never pulled in.
125
+ securedData: {
126
+ type: 'string',
127
+ label: 'Secured Data',
128
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
129
+ decode: function () {
130
+ const available = this.packet.length - this.startPos;
131
+ const sectag = this.#sectagLength();
132
+ let icvStart = available - 16;
133
+ if (icvStart < sectag)
134
+ icvStart = sectag;
135
+ this.instance.securedData.setValue(icvStart > sectag ? (0, BufferToHex_1.BufferToHex)(this.readBytes(sectag, icvStart - sectag)) : '');
136
+ },
137
+ encode: function () {
138
+ const data = this.instance.securedData.getValue('');
139
+ if (data)
140
+ this.writeBytes(this.#sectagLength(), (0, HexToBuffer_1.HexToBuffer)(data));
141
+ }
142
+ },
143
+ //The Integrity Check Value — the trailing 16 octets of the frame, kept verbatim (never
144
+ //recomputed; the SA key is out of band). Placed immediately after the secured data.
145
+ icv: {
146
+ type: 'string',
147
+ label: 'ICV',
148
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
149
+ decode: function () {
150
+ const available = this.packet.length - this.startPos;
151
+ const sectag = this.#sectagLength();
152
+ let icvStart = available - 16;
153
+ if (icvStart < sectag)
154
+ icvStart = sectag;
155
+ this.instance.icv.setValue(available > icvStart ? (0, BufferToHex_1.BufferToHex)(this.readBytes(icvStart, available - icvStart)) : '');
156
+ },
157
+ encode: function () {
158
+ const icv = this.instance.icv.getValue('');
159
+ if (icv) {
160
+ const dataBytes = (0, HexToBuffer_1.HexToBuffer)(this.instance.securedData.getValue('')).length;
161
+ this.writeBytes(this.#sectagLength() + dataBytes, (0, HexToBuffer_1.HexToBuffer)(icv));
162
+ }
163
+ }
164
+ }
165
+ }
166
+ };
167
+ }
168
+ match() {
169
+ //An Ethernet child selected by EtherType 0x88E5 (stored as a lowercase 4-hex string). Require the
170
+ //6-octet minimum SecTAG (TCI/AN + SL + PN, no SCI) so the fixed header fields have room.
171
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'eth')
172
+ return false;
173
+ if (this.prevCodecModule.instance.etherType.getValue() !== '88e5')
174
+ return false;
175
+ return this.packet.length - this.startPos >= 6;
176
+ }
177
+ }
178
+ exports.MACsec = MACsec;
@@ -0,0 +1,26 @@
1
+ import { DNS } from './DNS';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ /**
4
+ * mDNS — Multicast DNS (RFC 6762). The on-wire message format is byte-for-byte the standard DNS message
5
+ * (RFC 1035): the same 12-byte header, questions, and resource records with label compression. mDNS
6
+ * only reinterprets bits that DNS already carries verbatim — the top bit of a question's QCLASS is the
7
+ * unicast-response (QU) bit, and the top bit of a record's CLASS is the cache-flush bit — so storing
8
+ * QCLASS/CLASS as their full 16-bit values (as the DNS codec does) preserves them automatically and the
9
+ * whole message round-trips byte-perfect through the inherited DNS decode/encode. The only differences
10
+ * here are the protocol identity, the demux port (UDP 5353), the Info summary, and a tightened match().
11
+ */
12
+ export declare class MDNS extends DNS {
13
+ #private;
14
+ get SCHEMA(): ProtocolJSONSchema;
15
+ readonly id: string;
16
+ readonly name: string;
17
+ readonly nickname: string;
18
+ readonly matchKeys: string[];
19
+ /**
20
+ * mDNS lives on UDP port 5353 and never uses the classic DNS port 53. Because UDP produces its demux
21
+ * keys destination-port-first, a DNS *response* (srcport 53) sent to a client that happens to use
22
+ * ephemeral port 5353 would otherwise hit the mDNS bucket first and be mislabeled. Reject any packet
23
+ * that carries port 53 (that is DNS, matched by the udpport:53 bucket), and require 5353 to be present.
24
+ */
25
+ match(): boolean;
26
+ }