@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,152 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.POP3 = void 0;
5
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
6
+ const BufferToHex_1 = require("../helper/BufferToHex");
7
+ const HexToBuffer_1 = require("../helper/HexToBuffer");
8
+ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
9
+ /** POP3 command verbs (RFC 1939 + STLS/CAPA extensions) used only to recognize a command line. */
10
+ const POP3_COMMANDS = ['USER', 'PASS', 'APOP', 'STAT', 'LIST', 'RETR', 'DELE', 'NOOP', 'RSET', 'QUIT', 'TOP', 'UIDL', 'CAPA', 'STLS'];
11
+ /**
12
+ * POP3 — the Post Office Protocol version 3 (RFC 1939), carried as US-ASCII text over TCP well-known
13
+ * port 110 (or 995 for the TLS-wrapped POP3S bucket). The control channel is line-based: a client sends
14
+ * commands (`USER alice\r\n`, `PASS x\r\n`, `RETR 1\r\n`, `QUIT\r\n`, …) and a server sends replies whose
15
+ * syntax DIFFERS from FTP/SMTP — instead of a 3-digit code, a POP3 reply is a status indicator:
16
+ * `+OK ...\r\n` (success) or `-ERR ...\r\n` (failure).
17
+ *
18
+ * Like FTP, Syslog, SIP and HTTP, the message is text whose full internal structure (arbitrary arguments,
19
+ * significant whitespace, multi-line RETR/LIST responses) is richer than a form needs. So the ENTIRE raw
20
+ * message is kept verbatim as the authoritative `message` field (hex) and re-emitted untouched; only the
21
+ * first line is parsed on decode into display-only metadata (command/argument for a command,
22
+ * status/replyText for a reply). Encode never reconstructs the message from the parsed fields — it writes
23
+ * `message` back byte-for-byte — so any conformant (or even malformed) POP3 line round-trips exactly.
24
+ *
25
+ * Note: a single TCP segment may carry more than one line or only part of a multi-line response;
26
+ * reassembly across segments is out of scope. This single-segment codec keeps whatever bytes are present
27
+ * verbatim, which is byte-perfect for the single-packet case.
28
+ */
29
+ class POP3 extends BaseHeader_1.BaseHeader {
30
+ constructor() {
31
+ super(...arguments);
32
+ this.id = 'pop3';
33
+ this.name = 'Post Office Protocol v3';
34
+ this.nickname = 'POP3';
35
+ //POP3 is recognized ONLY on its well-known port buckets (110, and 995 for TLS-wrapped POP3S) —
36
+ //deliberately NOT via heuristicFallback. Unlike HTTP/RTSP (whose method sets are distinctive), POP3's
37
+ //line signature is a `+OK`/`-ERR` status or a generic verb (USER/PASS/STAT/LIST/RETR/QUIT/…) that is
38
+ //SHARED with other US-ASCII line protocols this codec also models — FTP (USER/PASS/STAT/LIST/RETR/
39
+ //QUIT). Joining the global heuristic chain would let POP3 mislabel an FTP `USER`/`STAT`/`RETR` line
40
+ //on tcp:21 as POP3 (and vice-versa). Confining POP3 to its tcp:110/tcp:995 buckets keeps that
41
+ //collision impossible (FTP lives on 21, which never reaches these buckets); alt-port POP3 is rare and
42
+ //falls losslessly to raw. (POP3S on 995 is normally TLS-wrapped, so the bucket rarely carries plain
43
+ //POP3 text, but is listed for completeness/STLS-downgrade traffic.)
44
+ this.matchKeys = ['tcpport:110', 'tcpport:995'];
45
+ //A leaf header — the POP3 session it belongs to is a higher-layer concern.
46
+ this.demuxProducers = [];
47
+ }
48
+ static #schemaCache;
49
+ get SCHEMA() {
50
+ return (_a.#schemaCache ??= _a.#buildSchema());
51
+ }
52
+ /**
53
+ * Bytes of this header: POP3 rides on TCP, which has no per-message length, so take the rest of the
54
+ * segment. Reassembly across segments is out of scope (see class doc).
55
+ */
56
+ #payloadLength() {
57
+ const available = this.packet.length - this.startPos;
58
+ return available < 0 ? 0 : available;
59
+ }
60
+ /** The first line of the message (up to the first CRLF, or the whole payload if none). */
61
+ static #firstLine(text) {
62
+ const idx = text.indexOf('\r\n');
63
+ return idx >= 0 ? text.slice(0, idx) : text;
64
+ }
65
+ /**
66
+ * Parse the first line into the display-only metadata fields. A line beginning with `+OK` or `-ERR`
67
+ * is a server reply (the status indicator and the trailing text); anything else is a client command
68
+ * (the uppercased verb and its argument). Populated on decode only — these fields have no encode, so
69
+ * they never affect the re-emitted bytes and never mutate `message`. Never throws: missing/garbage
70
+ * tokens yield empty strings.
71
+ */
72
+ #parseFirstLine(text) {
73
+ const line = _a.#firstLine(text);
74
+ const reply = line.match(/^(\+OK|-ERR)(?: (.*))?$/);
75
+ if (reply) {
76
+ //Reply: a status indicator (+OK success / -ERR failure), then optional trailing text.
77
+ this.instance.isReply.setValue(true);
78
+ this.instance.status.setValue(reply[1]);
79
+ this.instance.replyText.setValue(reply[2] ?? '');
80
+ this.instance.command.setValue('');
81
+ this.instance.argument.setValue('');
82
+ return;
83
+ }
84
+ //Command: VERB SP argument (the argument may itself contain spaces, e.g. `APOP name digest`).
85
+ const idx = line.indexOf(' ');
86
+ const verb = idx >= 0 ? line.slice(0, idx) : line;
87
+ this.instance.isReply.setValue(false);
88
+ this.instance.status.setValue('');
89
+ this.instance.replyText.setValue('');
90
+ this.instance.command.setValue(verb.toUpperCase());
91
+ this.instance.argument.setValue(idx >= 0 ? line.slice(idx + 1) : '');
92
+ }
93
+ static #buildSchema() {
94
+ return {
95
+ type: 'object',
96
+ summary: 'POP3 ${command}${status}',
97
+ properties: {
98
+ //The whole raw message is the single source of truth: decoded verbatim to hex and
99
+ //re-emitted untouched (byte-perfect for any POP3 control text). The first line is parsed
100
+ //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.#parseFirstLine('');
110
+ return;
111
+ }
112
+ const raw = this.readBytes(0, available);
113
+ this.instance.message.setValue((0, BufferToHex_1.BufferToHex)(raw));
114
+ this.#parseFirstLine(raw.toString('latin1'));
115
+ },
116
+ encode: function () {
117
+ //Re-emit the authoritative message 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 first line on decode (no encode — populated by the
122
+ //message field above, never read back). isReply distinguishes a server reply from a
123
+ //client command; status/replyText describe a reply, command/argument a command.
124
+ isReply: { type: 'boolean', label: 'Is Reply' },
125
+ status: { type: 'string', label: 'Status' },
126
+ replyText: { type: 'string', label: 'Reply Text' },
127
+ command: { type: 'string', label: 'Command' },
128
+ argument: { type: 'string', label: 'Argument' }
129
+ }
130
+ };
131
+ }
132
+ match() {
133
+ //POP3 rides on TCP as US-ASCII text. Recognize it by the line signature: a `+OK`/`-ERR` status
134
+ //indicator, or a known command verb as the leading token (up to the first space or CR) — so
135
+ //non-POP3 traffic on port 110/995 falls through to raw rather than claiming an un-decodable text
136
+ //layer.
137
+ if (!this.prevCodecModule)
138
+ return false;
139
+ if (this.prevCodecModule.id !== 'tcp')
140
+ return false;
141
+ if (this.#payloadLength() < 3)
142
+ return false;
143
+ const lead = this.readBytes(0, 16, true).toString('latin1');
144
+ if (/^(\+OK|-ERR)/.test(lead))
145
+ return true;
146
+ const line = _a.#firstLine(lead);
147
+ const token = (line.split(/[ \r]/)[0] || '').toUpperCase();
148
+ return POP3_COMMANDS.includes(token);
149
+ }
150
+ }
151
+ exports.POP3 = POP3;
152
+ _a = POP3;
@@ -0,0 +1,28 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * Ethernet POWERLINK (EPL, EPSG DS 301 / IEC 61784-2 CPF 13), a real-time industrial Ethernet protocol
6
+ * carried directly in an Ethernet II frame with EtherType 0x88AB (an Ethernet child — no IP/UDP). Every
7
+ * EPL basic frame begins with a fixed 3-byte common header: a 1-byte MessageType octet (bit 7 Reserved,
8
+ * bits 6..0 the 7-bit message type), a 1-byte Destination node id, and a 1-byte Source node id. The
9
+ * message types are SoC = 1 (Start of Cycle), PReq = 3 (Poll Request), PRes = 4 (Poll Response),
10
+ * SoA = 5 (Start of Asynchronous), ASnd = 6 (Asynchronous Send). The type-specific body follows.
11
+ *
12
+ * EPL has no length field of its own — a basic frame runs to the end of the Ethernet frame (short frames
13
+ * are Ethernet-padded to the 60-byte minimum). The per-type body layouts (SoC NetTime/RelativeTime, PReq/
14
+ * PRes flags+PDO payload, SoA service request, ASnd service data) differ and several carry variable
15
+ * mapped-PDO data, so this minimal slice decodes only the 3-byte common header structurally and keeps the
16
+ * remainder — body plus any trailing Ethernet padding — verbatim as `payload` hex (byte-perfect, a
17
+ * self-contained leaf, so nothing depends on RawData). A well-formed frame round-trips byte-for-byte.
18
+ */
19
+ export declare class POWERLINK 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,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.POWERLINK = 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
+ * Ethernet POWERLINK (EPL, EPSG DS 301 / IEC 61784-2 CPF 13), a real-time industrial Ethernet protocol
10
+ * carried directly in an Ethernet II frame with EtherType 0x88AB (an Ethernet child — no IP/UDP). Every
11
+ * EPL basic frame begins with a fixed 3-byte common header: a 1-byte MessageType octet (bit 7 Reserved,
12
+ * bits 6..0 the 7-bit message type), a 1-byte Destination node id, and a 1-byte Source node id. The
13
+ * message types are SoC = 1 (Start of Cycle), PReq = 3 (Poll Request), PRes = 4 (Poll Response),
14
+ * SoA = 5 (Start of Asynchronous), ASnd = 6 (Asynchronous Send). The type-specific body follows.
15
+ *
16
+ * EPL has no length field of its own — a basic frame runs to the end of the Ethernet frame (short frames
17
+ * are Ethernet-padded to the 60-byte minimum). The per-type body layouts (SoC NetTime/RelativeTime, PReq/
18
+ * PRes flags+PDO payload, SoA service request, ASnd service data) differ and several carry variable
19
+ * mapped-PDO data, so this minimal slice decodes only the 3-byte common header structurally and keeps the
20
+ * remainder — body plus any trailing Ethernet padding — verbatim as `payload` hex (byte-perfect, a
21
+ * self-contained leaf, so nothing depends on RawData). A well-formed frame round-trips byte-for-byte.
22
+ */
23
+ class POWERLINK extends BaseHeader_1.BaseHeader {
24
+ constructor() {
25
+ super(...arguments);
26
+ this.id = 'powerlink';
27
+ this.name = 'Ethernet POWERLINK';
28
+ this.nickname = 'POWERLINK';
29
+ this.matchKeys = ['ethertype:88ab'];
30
+ //A leaf header — the per-type body is kept verbatim as `payload`; nothing demuxes above POWERLINK.
31
+ this.demuxProducers = [];
32
+ }
33
+ static #schemaCache;
34
+ get SCHEMA() {
35
+ return (POWERLINK.#schemaCache ??= POWERLINK.#buildSchema());
36
+ }
37
+ static #buildSchema() {
38
+ return {
39
+ type: 'object',
40
+ summary: 'POWERLINK mtype=${messageType} ${source}->${destination}',
41
+ properties: {
42
+ //MessageType octet (byte 0): the high bit (0x80) is Reserved, kept verbatim so a frame that
43
+ //sets it still round-trips; the low 7 bits (0x7F, epl.mtyp) carry the message type.
44
+ reserved: {
45
+ type: 'integer',
46
+ label: 'Reserved',
47
+ minimum: 0,
48
+ maximum: 1,
49
+ hidden: true,
50
+ decode: function () {
51
+ this.instance.reserved.setValue(this.readBits(0, 1, 0, 1));
52
+ },
53
+ encode: function () {
54
+ this.writeBits(0, 1, 0, 1, this.instance.reserved.getValue(0));
55
+ }
56
+ },
57
+ messageType: {
58
+ type: 'integer',
59
+ label: 'Message Type',
60
+ minimum: 0,
61
+ maximum: 127,
62
+ decode: function () {
63
+ this.instance.messageType.setValue(this.readBits(0, 1, 1, 7));
64
+ },
65
+ encode: function () {
66
+ const node = this.instance.messageType;
67
+ let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
68
+ //A 7-bit field cannot represent a value above 127 — clamp (recording the error)
69
+ //rather than let it wrap into the Reserved bit and corrupt byte 0.
70
+ if (value > 127) {
71
+ this.recordError(node.getPath(), 'Maximum value is 127');
72
+ value = 127;
73
+ }
74
+ if (value < 0) {
75
+ this.recordError(node.getPath(), 'Minimum value is 0');
76
+ value = 0;
77
+ }
78
+ node.setValue(value);
79
+ this.writeBits(0, 1, 1, 7, value);
80
+ }
81
+ },
82
+ destination: this.fieldUInt('destination', 1, 1, 'Destination Node'),
83
+ source: this.fieldUInt('source', 2, 1, 'Source Node'),
84
+ //The type-specific body plus any trailing Ethernet padding, kept verbatim. EPL has no
85
+ //length field, so — like LLDP — the frame runs to its end; the whole remainder after the
86
+ //3-byte common header is this layer's own bytes (a self-contained leaf), bounded by the
87
+ //captured frame so a truncated frame still round-trips exactly.
88
+ payload: {
89
+ type: 'string',
90
+ label: 'Payload',
91
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
92
+ decode: function () {
93
+ const available = this.packet.length - this.startPos;
94
+ this.instance.payload.setValue(available > 3 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(3, available - 3)) : '');
95
+ },
96
+ encode: function () {
97
+ const payload = this.instance.payload.getValue('');
98
+ if (payload)
99
+ this.writeBytes(3, (0, HexToBuffer_1.HexToBuffer)(payload));
100
+ }
101
+ }
102
+ }
103
+ };
104
+ }
105
+ match() {
106
+ //An Ethernet child selected by EtherType 0x88AB (stored as a lowercase 4-hex string). Not gated on
107
+ //prevCodecModule.id so an EPL frame nested under a VLAN/HSR tag is still recognized. Require the
108
+ //3-byte common header (MessageType + Destination + Source).
109
+ if (!this.prevCodecModule)
110
+ return false;
111
+ if (this.prevCodecModule.instance.etherType.getValue() !== '88ab')
112
+ return false;
113
+ return this.packet.length - this.startPos >= 3;
114
+ }
115
+ }
116
+ exports.POWERLINK = POWERLINK;
@@ -0,0 +1,29 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * PPPoE Discovery Stage (RFC 2516), carried directly in an Ethernet II frame with EtherType 0x8863 (an
6
+ * Ethernet child — no IP/UDP). The 6-byte header is a Version (high 4 bits, 1) + Type (low 4 bits, 1)
7
+ * octet, a 1-byte Code (0x09 PADI, 0x07 PADO, 0x19 PADR, 0x65 PADS, 0xa7 PADT), a 2-byte Session ID,
8
+ * and a 2-byte Length that counts only the tag payload that follows. The payload is a flat sequence of
9
+ * TLV tags — Type (2 bytes: 0x0101 Service-Name, 0x0102 AC-Name, 0x0103 Host-Uniq, 0x0104 AC-Cookie,
10
+ * 0x0000 End-Of-List) + Length (2 bytes, the value byte count) + Length value bytes — bounded by the
11
+ * header Length field.
12
+ *
13
+ * Tags are carried generically (type + honored per-tag length + verbatim hex value) so every tag —
14
+ * including opaque/vendor tags — round-trips byte-for-byte; per-tag semantic decoding is a later
15
+ * enrichment. The header Length is honored when supplied (a crafted frame may lie) and otherwise
16
+ * derived from the on-wire tag bytes. The tag walk is bounded by that Length; any trailing bytes (an
17
+ * Ethernet minimum-frame pad) are kept verbatim in `padding` so the frame reproduces exactly. A leaf
18
+ * header — the Discovery stage carries no encapsulated payload.
19
+ */
20
+ export declare class PPPoEDiscovery extends BaseHeader {
21
+ #private;
22
+ get SCHEMA(): ProtocolJSONSchema;
23
+ readonly id: string;
24
+ readonly name: string;
25
+ readonly nickname: string;
26
+ readonly matchKeys: string[];
27
+ match(): boolean;
28
+ readonly demuxProducers: DemuxProducer[];
29
+ }
@@ -0,0 +1,198 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PPPoEDiscovery = 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
+ * PPPoE Discovery Stage (RFC 2516), carried directly in an Ethernet II frame with EtherType 0x8863 (an
12
+ * Ethernet child — no IP/UDP). The 6-byte header is a Version (high 4 bits, 1) + Type (low 4 bits, 1)
13
+ * octet, a 1-byte Code (0x09 PADI, 0x07 PADO, 0x19 PADR, 0x65 PADS, 0xa7 PADT), a 2-byte Session ID,
14
+ * and a 2-byte Length that counts only the tag payload that follows. The payload is a flat sequence of
15
+ * TLV tags — Type (2 bytes: 0x0101 Service-Name, 0x0102 AC-Name, 0x0103 Host-Uniq, 0x0104 AC-Cookie,
16
+ * 0x0000 End-Of-List) + Length (2 bytes, the value byte count) + Length value bytes — bounded by the
17
+ * header Length field.
18
+ *
19
+ * Tags are carried generically (type + honored per-tag length + verbatim hex value) so every tag —
20
+ * including opaque/vendor tags — round-trips byte-for-byte; per-tag semantic decoding is a later
21
+ * enrichment. The header Length is honored when supplied (a crafted frame may lie) and otherwise
22
+ * derived from the on-wire tag bytes. The tag walk is bounded by that Length; any trailing bytes (an
23
+ * Ethernet minimum-frame pad) are kept verbatim in `padding` so the frame reproduces exactly. A leaf
24
+ * header — the Discovery stage carries no encapsulated payload.
25
+ */
26
+ class PPPoEDiscovery extends BaseHeader_1.BaseHeader {
27
+ constructor() {
28
+ super(...arguments);
29
+ this.id = 'pppoe-disc';
30
+ this.name = 'PPP-over-Ethernet Discovery';
31
+ this.nickname = 'PPPoED';
32
+ this.matchKeys = ['ethertype:8863'];
33
+ //A leaf header — the Discovery stage carries no encapsulated payload (session data uses EtherType
34
+ //0x8864, a separate header).
35
+ this.demuxProducers = [];
36
+ }
37
+ static #schemaCache;
38
+ get SCHEMA() {
39
+ return (PPPoEDiscovery.#schemaCache ??= PPPoEDiscovery.#buildSchema());
40
+ }
41
+ static #buildSchema() {
42
+ return {
43
+ type: 'object',
44
+ summary: 'PPPoE Discovery code=${code} session=${sessionId}',
45
+ properties: {
46
+ //Byte 0 high nibble: PPPoE Version (1). Written MSB-first; shares byte 0 with Type
47
+ //(writeBits masks each field so they never clobber).
48
+ version: {
49
+ type: 'integer', label: 'Version', minimum: 0, maximum: 15,
50
+ decode: function () {
51
+ this.instance.version.setValue(this.readBits(0, 1, 0, 4));
52
+ },
53
+ encode: function () {
54
+ const value = this.instance.version.getValue(1);
55
+ this.instance.version.setValue(value);
56
+ this.writeBits(0, 1, 0, 4, value);
57
+ }
58
+ },
59
+ //Byte 0 low nibble: PPPoE Type (1).
60
+ type: {
61
+ type: 'integer', label: 'Type', minimum: 0, maximum: 15,
62
+ decode: function () {
63
+ this.instance.type.setValue(this.readBits(0, 1, 4, 4));
64
+ },
65
+ encode: function () {
66
+ const value = this.instance.type.getValue(1);
67
+ this.instance.type.setValue(value);
68
+ this.writeBits(0, 1, 4, 4, value);
69
+ }
70
+ },
71
+ //Code (byte 1): 0x09 PADI, 0x07 PADO, 0x19 PADR, 0x65 PADS, 0xa7 PADT.
72
+ code: this.fieldUInt('code', 1, 1, 'Code'),
73
+ //Session ID (bytes 2-3): 0x0000 during discovery until the AC assigns it in PADS.
74
+ sessionId: this.fieldUInt('sessionId', 2, 2, 'Session ID'),
75
+ length: {
76
+ type: 'integer',
77
+ label: 'Payload Length',
78
+ minimum: 0,
79
+ maximum: 65535,
80
+ decode: function () {
81
+ this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(4, 2)));
82
+ },
83
+ encode: function () {
84
+ //Length counts only the tag payload (not the 6-byte header). Honored when supplied
85
+ //(a crafted frame may lie); else derived from the actual on-wire tag bytes, which is
86
+ //what the tags field emits — sum of (4-byte tag header + value byte count) per tag.
87
+ const provided = this.instance.length.getValue();
88
+ let value;
89
+ if (provided !== undefined && provided !== null) {
90
+ value = provided;
91
+ }
92
+ else {
93
+ const tags = this.instance.tags.getValue([]);
94
+ let total = 0;
95
+ for (const tag of (tags ? tags : [])) {
96
+ total += 4 + (0, HexToBuffer_1.HexToBuffer)(tag.value ? tag.value : '').length;
97
+ }
98
+ value = total;
99
+ }
100
+ if (value > 65535) {
101
+ this.recordError(this.instance.length.getPath(), 'Maximum value is 65535');
102
+ value = 65535;
103
+ }
104
+ this.instance.length.setValue(value);
105
+ this.writeBytes(4, (0, NumberToBuffer_1.UInt16ToBuffer)(value));
106
+ }
107
+ },
108
+ tags: {
109
+ type: 'array',
110
+ label: 'Tags',
111
+ items: {
112
+ type: 'object',
113
+ label: 'Tag',
114
+ properties: {
115
+ type: { type: 'integer', label: 'Type', minimum: 0, maximum: 65535 },
116
+ length: { type: 'integer', label: 'Length', minimum: 0, maximum: 65535, hidden: true },
117
+ value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
118
+ }
119
+ },
120
+ decode: function () {
121
+ //Bound the tag walk by the header Length (from offset 6), clamped down to the bytes
122
+ //actually present in the frame so a lying Length can't read past the buffer.
123
+ const available = this.packet.length - this.startPos;
124
+ let end = 6 + this.instance.length.getValue(0);
125
+ if (end > available)
126
+ end = available;
127
+ if (end < 6)
128
+ end = 6;
129
+ const tags = [];
130
+ let offset = 6;
131
+ while (offset + 4 <= end) {
132
+ const type = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset, 2));
133
+ const length = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset + 2, 2));
134
+ //A value that overruns the bounded region (truncation) is not consumed — stop and
135
+ //leave the remaining bytes to `padding`, keeping the round-trip exact.
136
+ if (offset + 4 + length > end)
137
+ break;
138
+ const value = length > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset + 4, length)) : '';
139
+ tags.push({ type: type, length: length, value: value });
140
+ offset += 4 + length;
141
+ }
142
+ this.instance.tags.setValue(tags);
143
+ //Trailing bytes after the last consumed tag (Ethernet minimum-frame padding, or a
144
+ //truncated tag) are kept verbatim so the frame is reproduced exactly.
145
+ this.instance.padding.setValue(offset < available ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset, available - offset)) : '');
146
+ },
147
+ encode: function () {
148
+ const tags = this.instance.tags.getValue([]);
149
+ let offset = 6;
150
+ if (tags) {
151
+ for (let i = 0; i < tags.length; i++) {
152
+ const tag = tags[i];
153
+ const value = (0, HexToBuffer_1.HexToBuffer)(tag.value ? tag.value : '');
154
+ //Per-tag Length is honored when supplied (a crafted tag may lie about its
155
+ //declared length); else derived from the actual value byte count. The value
156
+ //bytes are always written verbatim regardless of the declared Length.
157
+ let length = (tag.length !== undefined && tag.length !== null) ? tag.length : value.length;
158
+ if (length > 65535) {
159
+ this.recordError(`tags[${i}].length`, 'Maximum value is 65535');
160
+ length = 65535;
161
+ }
162
+ this.writeBytes(offset, (0, NumberToBuffer_1.UInt16ToBuffer)(tag.type ? tag.type : 0));
163
+ this.writeBytes(offset + 2, (0, NumberToBuffer_1.UInt16ToBuffer)(length));
164
+ offset += 4;
165
+ if (value.length) {
166
+ this.writeBytes(offset, value);
167
+ offset += value.length;
168
+ }
169
+ }
170
+ }
171
+ const padding = this.instance.padding.getValue('');
172
+ if (padding)
173
+ this.writeBytes(offset, (0, HexToBuffer_1.HexToBuffer)(padding));
174
+ }
175
+ },
176
+ //Ethernet minimum-frame padding after the tags, kept verbatim. No codec of its own — it is
177
+ //set/read by the `tags` field (which owns the single offset walk); this entry is metadata so
178
+ //the editor sees the padding bytes.
179
+ padding: {
180
+ type: 'string',
181
+ label: 'Padding',
182
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX
183
+ }
184
+ }
185
+ };
186
+ }
187
+ match() {
188
+ //An Ethernet child selected by EtherType 0x8863 (stored as a lower-case 4-hex string, as
189
+ //eth.etherType / a VLAN's inner etherType). Not restricted to a direct 'eth' parent so a
190
+ //VLAN-tagged discovery frame still matches. Require the 6-byte fixed header.
191
+ if (!this.prevCodecModule)
192
+ return false;
193
+ if (this.prevCodecModule.instance.etherType.getValue() !== '8863')
194
+ return false;
195
+ return this.packet.length - this.startPos >= 6;
196
+ }
197
+ }
198
+ exports.PPPoEDiscovery = PPPoEDiscovery;
@@ -0,0 +1,28 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * PPPoE Session Stage (RFC 2516), carried directly in an Ethernet II frame with EtherType 0x8864 (an
6
+ * Ethernet child — no IP/UDP). The 6-byte PPPoE header is a byte holding Version (high 4 bits, 1) and
7
+ * Type (low 4 bits, 1), a 1-byte Code (0x00 in the Session Stage), a 2-byte Session ID (non-zero), and
8
+ * a 2-byte Length (the octet count of the PPPoE payload — i.e. the PPP portion, which starts with the
9
+ * 2-byte PPP Protocol field). The payload follows: a 2-byte PPP Protocol (e.g. 0x0021 IPv4, 0x0057
10
+ * IPv6, 0xc021 LCP, 0x8021 IPCP) and its data.
11
+ *
12
+ * This minimal slice decodes the 6-byte header plus the 2-byte PPP Protocol and keeps the PPP data
13
+ * verbatim as `payload` hex (byte-perfect), bounded by the Length field so trailing Ethernet padding is
14
+ * left to the codec's recursion / RawData. The Length is honored verbatim when supplied (a crafted
15
+ * frame may lie) else derived from the actual payload (2-byte Protocol + data). A well-formed frame
16
+ * round-trips byte-for-byte. Inner IPv4/IPv6/LCP recursion is deferred to a serial follow-up (it needs
17
+ * a pppProtocol-driven demux into IPv4/IPv6.match); for now the PPP payload is a bounded-hex leaf.
18
+ */
19
+ export declare class PPPoESession 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
+ }