@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,297 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.L2TP = 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
+ * L2TP — Layer Two Tunneling Protocol, version 2 (RFC 2661), UDP port 1701. The header begins with a
12
+ * 2-byte flags/version field: T (0=data / 1=control), L (Length present), S (Ns/Nr present), O (Offset
13
+ * present), P (Priority), and a 4-bit Version (=2). Depending on the flags the header then carries an
14
+ * optional Length, the Tunnel ID and Session ID, optional Ns/Nr sequence numbers, and an optional
15
+ * Offset (size + pad). A control message (T=1) carries a list of AVPs (each: M/H flags + 10-bit length,
16
+ * Vendor ID, Attribute Type, value); a data message (T=0) carries the tunneled payload, kept as raw hex
17
+ * (it is a leaf here — the tunneled PPP frame is a stateful conversation for a higher layer).
18
+ *
19
+ * A well-formed message round-trips byte-for-byte. The reserved flag bits and AVP reserved bits are
20
+ * normalized to 0 on re-encode (they MUST be 0 per RFC 2661), and an AVP's length is derived from its
21
+ * value; both hold for standard-conformant traffic.
22
+ */
23
+ class L2TP extends BaseHeader_1.BaseHeader {
24
+ constructor() {
25
+ super(...arguments);
26
+ this.id = 'l2tp';
27
+ this.name = 'Layer Two Tunneling Protocol';
28
+ this.nickname = 'L2TP';
29
+ this.matchKeys = ['udpport:1701'];
30
+ //A leaf header — the tunneled PPP payload / control-plane state belongs to a higher layer.
31
+ this.demuxProducers = [];
32
+ }
33
+ static #schemaCache;
34
+ get SCHEMA() {
35
+ return (L2TP.#schemaCache ??= L2TP.#buildSchema());
36
+ }
37
+ /** The payload length bounded by the UDP datagram (so a retained FCS/padding is not absorbed). */
38
+ #payloadLength() {
39
+ let available = this.packet.length - this.startPos;
40
+ if (this.prevCodecModule && this.prevCodecModule.id === 'udp') {
41
+ const udpLength = this.prevCodecModule.instance.length.getValue(0);
42
+ if (udpLength >= 8 && udpLength - 8 < available)
43
+ available = udpLength - 8;
44
+ }
45
+ return available < 0 ? 0 : available;
46
+ }
47
+ /** A single flag bit within the 2-byte flags field (bit 0 = MSB of byte 0). */
48
+ static #flagBit(name, bitOffset, label) {
49
+ return {
50
+ type: 'boolean',
51
+ label: label,
52
+ decode: function () {
53
+ this.instance.flags[name].setValue(!!this.readBits(0, 1, bitOffset, 1));
54
+ },
55
+ encode: function () {
56
+ const value = !!this.instance.flags[name].getValue();
57
+ this.instance.flags[name].setValue(value);
58
+ this.writeBits(0, 1, bitOffset, 1, value ? 1 : 0);
59
+ }
60
+ };
61
+ }
62
+ static #buildSchema() {
63
+ return {
64
+ type: 'object',
65
+ summary: 'L2TP ${flags.type} tid=${tunnelId} sid=${sessionId}',
66
+ properties: {
67
+ //Flags/version field (byte 0-1, MSB first): T(0) L(1) rsvd(2-3) S(4) rsvd(5) O(6) P(7),
68
+ //then rsvd(8-11) and Version(12-15). Reserved bits are normalized to 0 on encode.
69
+ flags: {
70
+ type: 'object',
71
+ label: 'Flags',
72
+ properties: {
73
+ type: this.#flagBit('type', 0, 'Type (1=control)'),
74
+ length: this.#flagBit('length', 1, 'Length Present'),
75
+ sequence: this.#flagBit('sequence', 4, 'Sequence Present'),
76
+ offset: this.#flagBit('offset', 6, 'Offset Present'),
77
+ priority: this.#flagBit('priority', 7, 'Priority'),
78
+ version: {
79
+ type: 'integer',
80
+ label: 'Version',
81
+ minimum: 0,
82
+ maximum: 15,
83
+ decode: function () { this.instance.flags.version.setValue(this.readBits(1, 1, 4, 4)); },
84
+ encode: function () { this.writeBits(1, 1, 4, 4, this.instance.flags.version.getValue(2)); }
85
+ },
86
+ //Reserved bits (byte0 bits 2-3, byte0 bit 5, byte1 bits 8-11). RFC 2661 requires
87
+ //them 0, but they are captured verbatim so any frame round-trips byte-for-byte.
88
+ reserved1: {
89
+ type: 'integer', label: 'Reserved', minimum: 0, maximum: 3, hidden: true,
90
+ decode: function () { this.instance.flags.reserved1.setValue(this.readBits(0, 1, 2, 2)); },
91
+ encode: function () { this.writeBits(0, 1, 2, 2, this.instance.flags.reserved1.getValue(0)); }
92
+ },
93
+ reserved2: {
94
+ type: 'integer', label: 'Reserved', minimum: 0, maximum: 1, hidden: true,
95
+ decode: function () { this.instance.flags.reserved2.setValue(this.readBits(0, 1, 5, 1)); },
96
+ encode: function () { this.writeBits(0, 1, 5, 1, this.instance.flags.reserved2.getValue(0)); }
97
+ },
98
+ reserved3: {
99
+ type: 'integer', label: 'Reserved', minimum: 0, maximum: 15, hidden: true,
100
+ decode: function () { this.instance.flags.reserved3.setValue(this.readBits(1, 1, 0, 4)); },
101
+ encode: function () { this.writeBits(1, 1, 0, 4, this.instance.flags.reserved3.getValue(0)); }
102
+ }
103
+ }
104
+ },
105
+ length: { type: 'integer', label: 'Length', minimum: 0, maximum: 65535 },
106
+ tunnelId: { type: 'integer', label: 'Tunnel ID', minimum: 0, maximum: 65535 },
107
+ sessionId: { type: 'integer', label: 'Session ID', minimum: 0, maximum: 65535 },
108
+ ns: { type: 'integer', label: 'Ns', minimum: 0, maximum: 65535 },
109
+ nr: { type: 'integer', label: 'Nr', minimum: 0, maximum: 65535 },
110
+ offsetSize: { type: 'integer', label: 'Offset Size', minimum: 0, maximum: 65535 },
111
+ offsetPad: { type: 'string', label: 'Offset Pad', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX, hidden: true },
112
+ avps: {
113
+ type: 'array',
114
+ label: 'AVPs',
115
+ items: {
116
+ type: 'object',
117
+ label: 'AVP',
118
+ properties: {
119
+ mandatory: { type: 'boolean', label: 'Mandatory' },
120
+ hidden: { type: 'boolean', label: 'Hidden' },
121
+ reserved: { type: 'integer', label: 'Reserved', minimum: 0, maximum: 15, hidden: true },
122
+ vendorId: { type: 'integer', label: 'Vendor ID', minimum: 0, maximum: 65535 },
123
+ attrType: { type: 'integer', label: 'Attribute Type', minimum: 0, maximum: 65535 },
124
+ value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
125
+ }
126
+ }
127
+ },
128
+ payload: { type: 'string', label: 'Payload', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX, hidden: true },
129
+ //Master field: the header layout is flag-conditional, so the whole message after the flags
130
+ //is parsed/emitted here into the sibling fields above. Runs after `flags` (property order).
131
+ body: {
132
+ type: 'string',
133
+ label: 'Body',
134
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
135
+ hidden: true,
136
+ decode: function () {
137
+ const available = this.#payloadLength();
138
+ const hasLength = !!this.instance.flags.length.getValue();
139
+ const hasSeq = !!this.instance.flags.sequence.getValue();
140
+ const hasOffset = !!this.instance.flags.offset.getValue();
141
+ const isControl = !!this.instance.flags.type.getValue();
142
+ let offset = 2;
143
+ let msgEnd = available;
144
+ if (hasLength && offset + 2 <= available) {
145
+ const length = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset, 2));
146
+ this.instance.length.setValue(length);
147
+ offset += 2;
148
+ //L2TP Length counts the whole message from the flags byte; bound the AVP walk.
149
+ if (length >= 6 && length <= available)
150
+ msgEnd = length;
151
+ }
152
+ if (offset + 2 <= available) {
153
+ this.instance.tunnelId.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset, 2)));
154
+ offset += 2;
155
+ }
156
+ if (offset + 2 <= available) {
157
+ this.instance.sessionId.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset, 2)));
158
+ offset += 2;
159
+ }
160
+ if (hasSeq) {
161
+ if (offset + 2 <= available) {
162
+ this.instance.ns.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset, 2)));
163
+ offset += 2;
164
+ }
165
+ if (offset + 2 <= available) {
166
+ this.instance.nr.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset, 2)));
167
+ offset += 2;
168
+ }
169
+ }
170
+ if (hasOffset && offset + 2 <= available) {
171
+ const offsetSize = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset, 2));
172
+ this.instance.offsetSize.setValue(offsetSize);
173
+ offset += 2;
174
+ const padLen = offset + offsetSize <= available ? offsetSize : available - offset;
175
+ this.instance.offsetPad.setValue(padLen > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset, padLen)) : '');
176
+ offset += padLen > 0 ? padLen : 0;
177
+ }
178
+ if (isControl) {
179
+ //Control message: a list of AVPs up to the message end.
180
+ const avps = [];
181
+ while (offset + 6 <= msgEnd) {
182
+ const avpFlags = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset, 2));
183
+ const avpLen = avpFlags & 0x03ff;
184
+ if (avpLen < 6 || offset + avpLen > msgEnd)
185
+ break;
186
+ avps.push({
187
+ mandatory: !!(avpFlags & 0x8000),
188
+ hidden: !!(avpFlags & 0x4000),
189
+ reserved: (avpFlags >> 10) & 0x0f,
190
+ vendorId: (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset + 2, 2)),
191
+ attrType: (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset + 4, 2)),
192
+ value: avpLen > 6 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset + 6, avpLen - 6)) : ''
193
+ });
194
+ offset += avpLen;
195
+ }
196
+ this.instance.avps.setValue(avps);
197
+ //Any bytes the AVP walk could not consume (malformed) are kept verbatim.
198
+ this.instance.payload.setValue(offset < available ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset, available - offset)) : '');
199
+ }
200
+ else {
201
+ //Data message: the tunneled payload, kept as raw hex.
202
+ this.instance.payload.setValue(offset < available ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset, available - offset)) : '');
203
+ }
204
+ },
205
+ encode: function () {
206
+ const hasLength = !!this.instance.flags.length.getValue();
207
+ const hasSeq = !!this.instance.flags.sequence.getValue();
208
+ const hasOffset = !!this.instance.flags.offset.getValue();
209
+ const isControl = !!this.instance.flags.type.getValue();
210
+ let offset = 2;
211
+ let lengthOffset = -1;
212
+ if (hasLength) {
213
+ lengthOffset = offset;
214
+ this.writeBytes(offset, (0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.length.getValue(0)));
215
+ offset += 2;
216
+ }
217
+ this.writeBytes(offset, (0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.tunnelId.getValue(0)));
218
+ offset += 2;
219
+ this.writeBytes(offset, (0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.sessionId.getValue(0)));
220
+ offset += 2;
221
+ if (hasSeq) {
222
+ this.writeBytes(offset, (0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.ns.getValue(0)));
223
+ offset += 2;
224
+ this.writeBytes(offset, (0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.nr.getValue(0)));
225
+ offset += 2;
226
+ }
227
+ if (hasOffset) {
228
+ const offsetPad = (0, HexToBuffer_1.HexToBuffer)(this.instance.offsetPad.getValue(''));
229
+ this.writeBytes(offset, (0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.offsetSize.getValue(offsetPad.length)));
230
+ offset += 2;
231
+ if (offsetPad.length) {
232
+ this.writeBytes(offset, offsetPad);
233
+ offset += offsetPad.length;
234
+ }
235
+ }
236
+ if (isControl) {
237
+ const avps = this.instance.avps.getValue([]);
238
+ if (avps)
239
+ for (let i = 0; i < avps.length; i++) {
240
+ const avp = avps[i];
241
+ const value = (0, HexToBuffer_1.HexToBuffer)(avp.value ? avp.value : '');
242
+ const avpLen = 6 + value.length;
243
+ //The AVP length is a 10-bit field, so a value > 1017 bytes cannot be
244
+ //represented — record it rather than silently truncating the length.
245
+ if (avpLen > 0x03ff)
246
+ this.recordError(this.instance.avps.getPath() + `[${i}].value`, 'AVP too long for the 10-bit length field');
247
+ const reserved = (avp.reserved ? avp.reserved : 0) & 0x0f;
248
+ const avpFlags = (avp.mandatory ? 0x8000 : 0) | (avp.hidden ? 0x4000 : 0) | (reserved << 10) | (avpLen & 0x03ff);
249
+ this.writeBytes(offset, (0, NumberToBuffer_1.UInt16ToBuffer)(avpFlags));
250
+ offset += 2;
251
+ this.writeBytes(offset, (0, NumberToBuffer_1.UInt16ToBuffer)(avp.vendorId ? avp.vendorId : 0));
252
+ offset += 2;
253
+ this.writeBytes(offset, (0, NumberToBuffer_1.UInt16ToBuffer)(avp.attrType ? avp.attrType : 0));
254
+ offset += 2;
255
+ if (value.length) {
256
+ this.writeBytes(offset, value);
257
+ offset += value.length;
258
+ }
259
+ }
260
+ }
261
+ const payload = (0, HexToBuffer_1.HexToBuffer)(this.instance.payload.getValue(''));
262
+ if (payload.length) {
263
+ this.writeBytes(offset, payload);
264
+ offset += payload.length;
265
+ }
266
+ //Fill in the L2TP Length (whole message from the flags byte) if it was not set.
267
+ if (hasLength && lengthOffset >= 0 && (this.instance.length.getValue() === undefined || this.instance.length.getValue() === null)) {
268
+ const lengthPos = lengthOffset;
269
+ this.addPostPacketEncodeHandler(() => {
270
+ let started = false;
271
+ let total = 0;
272
+ this.codecModules.forEach((codecModule) => {
273
+ if (codecModule === this)
274
+ started = true;
275
+ if (started)
276
+ total += codecModule.length;
277
+ });
278
+ this.instance.length.setValue(total);
279
+ this.writeBytes(lengthPos, (0, NumberToBuffer_1.UInt16ToBuffer)(total));
280
+ }, 1);
281
+ }
282
+ }
283
+ }
284
+ }
285
+ };
286
+ }
287
+ match() {
288
+ //Require the minimum data-message header (flags + tunnel + session = 6 bytes) within the UDP
289
+ //payload, and version 2 (RFC 2661) — L2TPv3 has a different structure and falls through to raw.
290
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'udp')
291
+ return false;
292
+ if (this.#payloadLength() < 6)
293
+ return false;
294
+ return (this.readBytes(1, 1, true)[0] & 0x0f) === 2;
295
+ }
296
+ }
297
+ exports.L2TP = L2TP;
@@ -0,0 +1,31 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * LACP — Link Aggregation Control Protocol (IEEE 802.3ad / 802.1AX), one of the Slow Protocols carried
6
+ * directly in an Ethernet II frame with EtherType 0x8809 (an Ethernet child — no IP/UDP). Byte 0 is the
7
+ * Slow-Protocols Subtype (1 = LACP; 2 = Marker, which this header does not claim) and byte 1 is the
8
+ * Version. What follows is a flat sequence of TLVs — each a 1-byte Type + 1-byte Length (the Length
9
+ * counts the 2 header octets, so the value is Length-2 bytes) + value bytes: Actor Information (type
10
+ * 0x01, len 0x14), Partner Information (0x02, 0x14), Collector Information (0x03, 0x10), then the
11
+ * Terminator (type 0x00, len 0x00). After the Terminator the LACPDU is padded with reserved octets to
12
+ * fill the fixed 110-byte PDU (the frame's minimum data field). LACP has no length field of its own — it
13
+ * runs to the end of the frame.
14
+ *
15
+ * TLVs are carried generically (type + on-wire length + verbatim hex value) so every TLV round-trips
16
+ * byte-for-byte; per-TLV semantic decoding (Actor/Partner system, state bits, …) is a later enrichment.
17
+ * The Length is honored verbatim on encode when supplied (a crafted PDU may lie), else derived from the
18
+ * value (2 + value bytes; 0 for the Terminator). The walk stops at the Terminator (type 0) or when the
19
+ * frame is exhausted; any bytes after the Terminator are the reserved padding, kept verbatim in
20
+ * `reserved` so the frame is reproduced exactly.
21
+ */
22
+ export declare class LACP 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,151 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LACP = 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
+ * LACP — Link Aggregation Control Protocol (IEEE 802.3ad / 802.1AX), one of the Slow Protocols carried
12
+ * directly in an Ethernet II frame with EtherType 0x8809 (an Ethernet child — no IP/UDP). Byte 0 is the
13
+ * Slow-Protocols Subtype (1 = LACP; 2 = Marker, which this header does not claim) and byte 1 is the
14
+ * Version. What follows is a flat sequence of TLVs — each a 1-byte Type + 1-byte Length (the Length
15
+ * counts the 2 header octets, so the value is Length-2 bytes) + value bytes: Actor Information (type
16
+ * 0x01, len 0x14), Partner Information (0x02, 0x14), Collector Information (0x03, 0x10), then the
17
+ * Terminator (type 0x00, len 0x00). After the Terminator the LACPDU is padded with reserved octets to
18
+ * fill the fixed 110-byte PDU (the frame's minimum data field). LACP has no length field of its own — it
19
+ * runs to the end of the frame.
20
+ *
21
+ * TLVs are carried generically (type + on-wire length + verbatim hex value) so every TLV round-trips
22
+ * byte-for-byte; per-TLV semantic decoding (Actor/Partner system, state bits, …) is a later enrichment.
23
+ * The Length is honored verbatim on encode when supplied (a crafted PDU may lie), else derived from the
24
+ * value (2 + value bytes; 0 for the Terminator). The walk stops at the Terminator (type 0) or when the
25
+ * frame is exhausted; any bytes after the Terminator are the reserved padding, kept verbatim in
26
+ * `reserved` so the frame is reproduced exactly.
27
+ */
28
+ class LACP extends BaseHeader_1.BaseHeader {
29
+ constructor() {
30
+ super(...arguments);
31
+ this.id = 'lacp';
32
+ this.name = 'Link Aggregation Control Protocol';
33
+ this.nickname = 'LACP';
34
+ this.matchKeys = ['ethertype:8809'];
35
+ //A leaf header — nothing demuxes above LACP.
36
+ this.demuxProducers = [];
37
+ }
38
+ static #schemaCache;
39
+ get SCHEMA() {
40
+ return (LACP.#schemaCache ??= LACP.#buildSchema());
41
+ }
42
+ static #buildSchema() {
43
+ return {
44
+ type: 'object',
45
+ summary: 'LACP v${version} ${tlvs.length} TLVs',
46
+ properties: {
47
+ subtype: this.fieldUInt('subtype', 0, 1, 'Subtype'),
48
+ version: this.fieldUInt('version', 1, 1, 'Version'),
49
+ tlvs: {
50
+ type: 'array',
51
+ label: 'TLVs',
52
+ items: {
53
+ type: 'object',
54
+ label: 'TLV',
55
+ properties: {
56
+ type: { type: 'integer', label: 'Type', minimum: 0, maximum: 255 },
57
+ length: { type: 'integer', label: 'Length', minimum: 0, maximum: 255 },
58
+ value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
59
+ }
60
+ },
61
+ decode: function () {
62
+ //LACP runs to the end of the frame — there is no length field. Bound the walk by the
63
+ //remaining frame bytes. Each TLV is Type(1) + Length(1) + (Length-2) value bytes; the
64
+ //on-wire Length counts the 2 header octets (the Terminator is the exception: Length 0).
65
+ const available = this.packet.length - this.startPos;
66
+ const tlvs = [];
67
+ let offset = 2;
68
+ while (offset + 2 <= available) {
69
+ const type = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(offset, 1));
70
+ const length = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(offset + 1, 1));
71
+ //Terminator (type 0): logical end of the PDU — anything after is reserved padding.
72
+ if (type === 0) {
73
+ tlvs.push({ type: type, length: length, value: '' });
74
+ offset += 2;
75
+ break;
76
+ }
77
+ //Value byte count = Length - 2 (Length includes the 2 header octets). A malformed
78
+ //Length < 2 yields no value; a value that overruns the frame (truncation) is not
79
+ //consumed — stop and leave the remaining bytes to `reserved`, keeping round-trip exact.
80
+ const valueLength = length > 2 ? length - 2 : 0;
81
+ if (offset + 2 + valueLength > available)
82
+ break;
83
+ const value = valueLength > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset + 2, valueLength)) : '';
84
+ tlvs.push({ type: type, length: length, value: value });
85
+ offset += 2 + valueLength;
86
+ }
87
+ this.instance.tlvs.setValue(tlvs);
88
+ //Trailing bytes after the Terminator (or after a truncated TLV) are the reserved padding.
89
+ this.instance.reserved.setValue(offset < available ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset, available - offset)) : '');
90
+ },
91
+ encode: function () {
92
+ const tlvs = this.instance.tlvs.getValue([]);
93
+ let offset = 2;
94
+ if (tlvs) {
95
+ for (let i = 0; i < tlvs.length; i++) {
96
+ const tlv = tlvs[i];
97
+ const type = tlv.type ? tlv.type : 0;
98
+ const value = (0, HexToBuffer_1.HexToBuffer)(tlv.value ? tlv.value : '');
99
+ //Length is honored verbatim when supplied (a crafted PDU may lie), else derived:
100
+ //value bytes + the 2 header octets (0 for the Terminator, which carries no value).
101
+ let length = (tlv.length !== undefined && tlv.length !== null)
102
+ ? tlv.length
103
+ : (type === 0 ? 0 : value.length + 2);
104
+ if (length > 255) {
105
+ this.recordError(`tlvs[${i}].length`, 'Maximum value is 255');
106
+ length = 255;
107
+ }
108
+ if (length < 0) {
109
+ this.recordError(`tlvs[${i}].length`, 'Minimum value is 0');
110
+ length = 0;
111
+ }
112
+ this.writeBytes(offset, (0, NumberToBuffer_1.UInt8ToBuffer)(type & 0xff));
113
+ this.writeBytes(offset + 1, (0, NumberToBuffer_1.UInt8ToBuffer)(length));
114
+ offset += 2;
115
+ if (value.length) {
116
+ this.writeBytes(offset, value);
117
+ offset += value.length;
118
+ }
119
+ }
120
+ }
121
+ const reserved = this.instance.reserved.getValue('');
122
+ if (reserved)
123
+ this.writeBytes(offset, (0, HexToBuffer_1.HexToBuffer)(reserved));
124
+ }
125
+ },
126
+ //Reserved padding after the Terminator TLV, kept verbatim. No codec of its own — it is
127
+ //set/read by the `tlvs` field (which owns the single offset walk); this entry is metadata
128
+ //so the editor sees the padding bytes.
129
+ reserved: {
130
+ type: 'string',
131
+ label: 'Reserved',
132
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
133
+ hidden: true
134
+ }
135
+ }
136
+ };
137
+ }
138
+ match() {
139
+ //An Ethernet child selected by EtherType 0x8809 (Slow Protocols, stored as a lowercase 4-hex
140
+ //string). Only Subtype 1 (LACP) is claimed — Subtype 2 (Marker) and others fall through. Require
141
+ //at least the 2-byte Subtype + Version so the subtype probe is in-bounds.
142
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'eth')
143
+ return false;
144
+ if (this.prevCodecModule.instance.etherType.getValue() !== '8809')
145
+ return false;
146
+ if (this.packet.length - this.startPos < 2)
147
+ return false;
148
+ return (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(0, 1, true)) === 1;
149
+ }
150
+ }
151
+ exports.LACP = LACP;
@@ -0,0 +1,31 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * LDAP — Lightweight Directory Access Protocol (RFC 4511), over TCP port 389. Each LDAPMessage is a
6
+ * BER-encoded ASN.1 SEQUENCE: SEQUENCE { messageID INTEGER, protocolOp CHOICE [, controls] }, where
7
+ * protocolOp is a context/application-tagged element identifying the operation — 0x60 bindRequest,
8
+ * 0x61 bindResponse, 0x63 searchRequest, 0x64 searchResultEntry, 0x65 searchResultDone,
9
+ * 0x42 unbindRequest, and so on.
10
+ *
11
+ * Minimal slice (byte-perfect): the outer SEQUENCE and its length are decoded, the messageID INTEGER is
12
+ * decoded as a signed integer, and the protocolOp is split into its TAG (one byte, e.g. 0x60) plus its
13
+ * BODY — the protocolOp length/content and any trailing controls — kept verbatim as `protocolOpData`
14
+ * hex. Re-encode rebuilds the SEQUENCE with minimal-definite lengths, re-emits the messageID with
15
+ * minimal two's-complement BER, and appends the protocolOp tag + verbatim body. So any operation
16
+ * round-trips exactly without a per-op encoder. Full BER structuring of each operation (bind DN/auth,
17
+ * search filter/attributes, result codes …) is a later, separate slice.
18
+ *
19
+ * Non-minimal BER lengths (long-form where short-form would do) regularize to minimal form on re-encode,
20
+ * exactly like SNMP — standard LDAP servers emit minimal lengths, so real traffic is byte-perfect.
21
+ */
22
+ export declare class LDAP 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
+ }