@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,207 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SLP = 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
+ * SLP — Service Location Protocol Version 2 (RFC 2608), UDP (and TCP) port 427. Every SLPv2 message
10
+ * begins with a common header: an 8-bit Version (2), an 8-bit Function-ID (1 SrvRqst, 2 SrvRply,
11
+ * 3 SrvReg, 4 SrvDeReg, 5 SrvAck, 6 AttrRqst, 7 AttrRply, 8 DAAdvert, 9 SrvTypeRqst, 10 SrvTypeRply,
12
+ * 11 SAAdvert), a 24-bit Length (the entire message octet count including this header), a 16-bit Flags
13
+ * field (bit 0 Overflow, bit 1 Fresh, bit 2 Request-multicast, the remaining 13 bits reserved), a 24-bit
14
+ * Next Extension Offset, a 16-bit XID, a 16-bit Language Tag Length and the Language Tag of that many
15
+ * octets — then the Function-ID-specific body.
16
+ *
17
+ * The body layout differs per Function-ID (SrvRqst's PRList/service-type/scope/predicate/SPL SPI,
18
+ * SrvRply's URL entries, SrvReg's URL + attributes, …) and several sub-structures carry authentication
19
+ * blocks and cross-message context, so this common-header codec keeps the body verbatim as `body` hex
20
+ * (byte-perfect) and does not sub-decode it. The Length is auto-computed on encode when not supplied,
21
+ * else honored verbatim (a crafted message may lie); the Language Tag Length is likewise honor-else-
22
+ * derive. The message is bounded by its Length (and the UDP datagram) so trailing / pipelined bytes are
23
+ * left to the codec's recursion / RawData. A well-formed message round-trips byte-for-byte.
24
+ */
25
+ class SLP extends BaseHeader_1.BaseHeader {
26
+ constructor() {
27
+ super(...arguments);
28
+ this.id = 'slp';
29
+ this.name = 'Service Location Protocol';
30
+ this.nickname = 'SLP';
31
+ this.matchKeys = ['udpport:427', 'tcpport:427'];
32
+ //A leaf header — the Function-ID-specific body requires per-type, cross-message parsing.
33
+ this.demuxProducers = [];
34
+ }
35
+ static #schemaCache;
36
+ get SCHEMA() {
37
+ return (SLP.#schemaCache ??= SLP.#buildSchema());
38
+ }
39
+ /** The UDP payload length bounded by the datagram, so trailing padding is not absorbed. */
40
+ #boundedAvailable() {
41
+ let available = this.packet.length - this.startPos;
42
+ if (this.prevCodecModule && this.prevCodecModule.id === 'udp') {
43
+ const udpLength = this.prevCodecModule.instance.length.getValue(0);
44
+ if (udpLength >= 8 && udpLength - 8 < available)
45
+ available = udpLength - 8;
46
+ }
47
+ return available < 0 ? 0 : available;
48
+ }
49
+ /** The decoded Language Tag octet count, clamped to what is actually present after the 14-byte header. */
50
+ #langTagBytes() {
51
+ let count = this.instance.langTagLen.getValue(0);
52
+ if (count < 0)
53
+ count = 0;
54
+ const available = this.#boundedAvailable();
55
+ if (14 + count > available)
56
+ count = available - 14;
57
+ return count < 0 ? 0 : count;
58
+ }
59
+ /** A plain big-endian unsigned 24-bit field of 3 octets at `offset`. */
60
+ static #fieldUInt24(name, offset, label) {
61
+ return {
62
+ type: 'integer',
63
+ label: label,
64
+ minimum: 0,
65
+ maximum: 16777215,
66
+ decode: function () {
67
+ const b = this.readBytes(offset, 3);
68
+ this.instance[name].setValue((b[0] << 16) | (b[1] << 8) | b[2]);
69
+ },
70
+ encode: function () {
71
+ const node = this.instance[name];
72
+ let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
73
+ if (value > 16777215) {
74
+ this.recordError(node.getPath(), 'Maximum value is 16777215');
75
+ value = 16777215;
76
+ }
77
+ if (value < 0) {
78
+ this.recordError(node.getPath(), 'Minimum value is 0');
79
+ value = 0;
80
+ }
81
+ node.setValue(value);
82
+ this.writeBytes(offset, Buffer.from([(value >> 16) & 0xff, (value >> 8) & 0xff, value & 0xff]));
83
+ }
84
+ };
85
+ }
86
+ static #buildSchema() {
87
+ return {
88
+ type: 'object',
89
+ summary: 'SLP func=${functionId} xid=${xid}',
90
+ properties: {
91
+ version: this.fieldUInt('version', 0, 1, 'Version'),
92
+ functionId: this.fieldUInt('functionId', 1, 1, 'Function-ID'),
93
+ length: {
94
+ type: 'integer',
95
+ label: 'Length',
96
+ minimum: 0,
97
+ maximum: 16777215,
98
+ decode: function () {
99
+ const b = this.readBytes(2, 3);
100
+ this.instance.length.setValue((b[0] << 16) | (b[1] << 8) | b[2]);
101
+ },
102
+ encode: function () {
103
+ //Length counts the whole message = 14-byte common header + Language Tag + body.
104
+ //Honored when supplied (a crafted message may lie); else derived from the fields.
105
+ const provided = this.instance.length.getValue();
106
+ let value = (provided !== undefined && provided !== null)
107
+ ? provided
108
+ : 14 + (0, HexToBuffer_1.HexToBuffer)(this.instance.langTag.getValue('')).length + (0, HexToBuffer_1.HexToBuffer)(this.instance.body.getValue('')).length;
109
+ if (value > 16777215) {
110
+ this.recordError(this.instance.length.getPath(), 'Maximum value is 16777215');
111
+ value = 16777215;
112
+ }
113
+ if (value < 0)
114
+ value = 0;
115
+ this.instance.length.setValue(value);
116
+ this.writeBytes(2, Buffer.from([(value >> 16) & 0xff, (value >> 8) & 0xff, value & 0xff]));
117
+ }
118
+ },
119
+ //Flags: bit 0 Overflow, bit 1 Fresh, bit 2 Request-multicast; the remaining 13 bits are
120
+ //reserved. Kept as a plain uint16 so reserved bits round-trip; the bit split is UI
121
+ //enrichment for later.
122
+ flags: this.fieldUInt('flags', 5, 2, 'Flags'),
123
+ nextExtOffset: this.#fieldUInt24('nextExtOffset', 7, 'Next Extension Offset'),
124
+ xid: this.fieldUInt('xid', 10, 2, 'XID'),
125
+ langTagLen: {
126
+ type: 'integer',
127
+ label: 'Language Tag Length',
128
+ minimum: 0,
129
+ maximum: 65535,
130
+ decode: function () {
131
+ const b = this.readBytes(12, 2);
132
+ this.instance.langTagLen.setValue((b[0] << 8) | b[1]);
133
+ },
134
+ encode: function () {
135
+ //Length of the Language Tag that follows. Honored when supplied (a crafted message
136
+ //may lie); else derived from the Language Tag bytes.
137
+ const provided = this.instance.langTagLen.getValue();
138
+ let value = (provided !== undefined && provided !== null)
139
+ ? provided
140
+ : (0, HexToBuffer_1.HexToBuffer)(this.instance.langTag.getValue('')).length;
141
+ if (value > 65535) {
142
+ this.recordError(this.instance.langTagLen.getPath(), 'Maximum value is 65535');
143
+ value = 65535;
144
+ }
145
+ if (value < 0)
146
+ value = 0;
147
+ this.instance.langTagLen.setValue(value);
148
+ this.writeBytes(12, Buffer.from([(value >> 8) & 0xff, value & 0xff]));
149
+ }
150
+ },
151
+ //The Language Tag (US-ASCII, e.g. "en"), kept verbatim as hex so any tag round-trips
152
+ //byte-for-byte. Bounded by the Language Tag Length and the bytes actually present.
153
+ langTag: {
154
+ type: 'string',
155
+ label: 'Language Tag',
156
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
157
+ decode: function () {
158
+ const count = this.#langTagBytes();
159
+ this.instance.langTag.setValue(count > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(14, count)) : '');
160
+ },
161
+ encode: function () {
162
+ const langTag = this.instance.langTag.getValue('');
163
+ if (langTag)
164
+ this.writeBytes(14, (0, HexToBuffer_1.HexToBuffer)(langTag));
165
+ }
166
+ },
167
+ //The Function-ID-specific body after the common header + Language Tag, kept verbatim.
168
+ //Bounded by the message Length (the message ends at offset Length) and the captured / UDP
169
+ //bytes, so trailing / pipelined data is left to the codec's recursion / RawData.
170
+ body: {
171
+ type: 'string',
172
+ label: 'Body',
173
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
174
+ decode: function () {
175
+ const available = this.#boundedAvailable();
176
+ const length = this.instance.length.getValue(0);
177
+ let bodyStart = 14 + this.#langTagBytes();
178
+ if (bodyStart > available)
179
+ bodyStart = available;
180
+ let end = length;
181
+ if (end > available)
182
+ end = available;
183
+ this.instance.body.setValue(end > bodyStart ? (0, BufferToHex_1.BufferToHex)(this.readBytes(bodyStart, end - bodyStart)) : '');
184
+ },
185
+ encode: function () {
186
+ const body = this.instance.body.getValue('');
187
+ if (body)
188
+ this.writeBytes(14 + (0, HexToBuffer_1.HexToBuffer)(this.instance.langTag.getValue('')).length, (0, HexToBuffer_1.HexToBuffer)(body));
189
+ }
190
+ }
191
+ }
192
+ };
193
+ }
194
+ match() {
195
+ //SLP rides on UDP/TCP port 427 (selected via the udpport:427 / tcpport:427 bucket). Require the
196
+ //full 14-byte common header and Version == 2 (the SLPv2 content signature) so non-SLP 427 traffic
197
+ //falls through to raw.
198
+ if (!this.prevCodecModule)
199
+ return false;
200
+ if (this.prevCodecModule.id !== 'udp' && this.prevCodecModule.id !== 'tcp')
201
+ return false;
202
+ if (this.packet.length - this.startPos < 14)
203
+ return false;
204
+ return this.readBytes(0, 1, true)[0] === 2;
205
+ }
206
+ }
207
+ exports.SLP = SLP;
@@ -0,0 +1,32 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * SLPv1 — Service Location Protocol Version 1 (RFC 2165), UDP (and TCP) port 427. An SLPv1 message
6
+ * begins with a 12-octet common header: an 8-bit Version (1), an 8-bit Function (1 SrvReq, 2 SrvRply,
7
+ * 3 SrvReg, 4 SrvDeReg, 5 SrvAck, 6 AttrRqst, 7 AttrRply, 8 DAAdvert, 9 SrvTypeRqst, 10 SrvTypeRply),
8
+ * a 16-bit Length (the whole message octet count including this header), an 8-bit Flags field (bit 0
9
+ * Overflow, bit 1 Monolingual, bit 2 URL Authentication, bit 3 Attribute Authentication, bit 4 Fresh;
10
+ * the remaining 3 bits reserved), an 8-bit Dialect, a 2-octet Language Code (ISO 639, e.g. "en"), a
11
+ * 16-bit Character Encoding (MIBenum) and a 16-bit XID — then the Function-specific body.
12
+ *
13
+ * The body layout differs per Function and several sub-structures carry authentication blocks and
14
+ * cross-message context, so this common-header codec keeps the body verbatim as `body` hex (byte-
15
+ * perfect) and does not sub-decode it. The Length is auto-computed on encode when not supplied, else
16
+ * honored verbatim (a crafted message may lie). The message is bounded by its Length (and the UDP
17
+ * datagram) so trailing / pipelined bytes are left to the codec's recursion / RawData. A well-formed
18
+ * message round-trips byte-for-byte.
19
+ *
20
+ * Note: SLPv1 (RFC 2165) and SLPv2 (RFC 2608, see SLP) share port 427 but have entirely different
21
+ * header layouts, so they are separate codecs selected by the Version octet (1 vs 2).
22
+ */
23
+ export declare class SLPv1 extends BaseHeader {
24
+ #private;
25
+ get SCHEMA(): ProtocolJSONSchema;
26
+ readonly id: string;
27
+ readonly name: string;
28
+ readonly nickname: string;
29
+ readonly matchKeys: string[];
30
+ match(): boolean;
31
+ readonly demuxProducers: DemuxProducer[];
32
+ }
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SLPv1 = 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
+ * SLPv1 — Service Location Protocol Version 1 (RFC 2165), UDP (and TCP) port 427. An SLPv1 message
10
+ * begins with a 12-octet common header: an 8-bit Version (1), an 8-bit Function (1 SrvReq, 2 SrvRply,
11
+ * 3 SrvReg, 4 SrvDeReg, 5 SrvAck, 6 AttrRqst, 7 AttrRply, 8 DAAdvert, 9 SrvTypeRqst, 10 SrvTypeRply),
12
+ * a 16-bit Length (the whole message octet count including this header), an 8-bit Flags field (bit 0
13
+ * Overflow, bit 1 Monolingual, bit 2 URL Authentication, bit 3 Attribute Authentication, bit 4 Fresh;
14
+ * the remaining 3 bits reserved), an 8-bit Dialect, a 2-octet Language Code (ISO 639, e.g. "en"), a
15
+ * 16-bit Character Encoding (MIBenum) and a 16-bit XID — then the Function-specific body.
16
+ *
17
+ * The body layout differs per Function and several sub-structures carry authentication blocks and
18
+ * cross-message context, so this common-header codec keeps the body verbatim as `body` hex (byte-
19
+ * perfect) and does not sub-decode it. The Length is auto-computed on encode when not supplied, else
20
+ * honored verbatim (a crafted message may lie). The message is bounded by its Length (and the UDP
21
+ * datagram) so trailing / pipelined bytes are left to the codec's recursion / RawData. A well-formed
22
+ * message round-trips byte-for-byte.
23
+ *
24
+ * Note: SLPv1 (RFC 2165) and SLPv2 (RFC 2608, see SLP) share port 427 but have entirely different
25
+ * header layouts, so they are separate codecs selected by the Version octet (1 vs 2).
26
+ */
27
+ class SLPv1 extends BaseHeader_1.BaseHeader {
28
+ constructor() {
29
+ super(...arguments);
30
+ this.id = 'slpv1';
31
+ this.name = 'Service Location Protocol Version 1';
32
+ this.nickname = 'SLPv1';
33
+ this.matchKeys = ['udpport:427', 'tcpport:427'];
34
+ //A leaf header — the Function-specific body requires per-type, cross-message parsing.
35
+ this.demuxProducers = [];
36
+ }
37
+ static #schemaCache;
38
+ get SCHEMA() {
39
+ return (SLPv1.#schemaCache ??= SLPv1.#buildSchema());
40
+ }
41
+ /** The UDP payload length bounded by the datagram, so trailing padding is not absorbed. */
42
+ #boundedAvailable() {
43
+ let available = this.packet.length - this.startPos;
44
+ if (this.prevCodecModule && this.prevCodecModule.id === 'udp') {
45
+ const udpLength = this.prevCodecModule.instance.length.getValue(0);
46
+ if (udpLength >= 8 && udpLength - 8 < available)
47
+ available = udpLength - 8;
48
+ }
49
+ return available < 0 ? 0 : available;
50
+ }
51
+ static #buildSchema() {
52
+ return {
53
+ type: 'object',
54
+ summary: 'SLPv1 func=${functionId} xid=${xid}',
55
+ properties: {
56
+ version: this.fieldUInt('version', 0, 1, 'Version'),
57
+ functionId: this.fieldUInt('functionId', 1, 1, 'Function'),
58
+ length: {
59
+ type: 'integer',
60
+ label: 'Length',
61
+ minimum: 0,
62
+ maximum: 65535,
63
+ decode: function () {
64
+ const b = this.readBytes(2, 2);
65
+ this.instance.length.setValue((b[0] << 8) | b[1]);
66
+ },
67
+ encode: function () {
68
+ //Length counts the whole message = 12-byte common header + body. Honored when
69
+ //supplied (a crafted message may lie); else derived from the body bytes.
70
+ const provided = this.instance.length.getValue();
71
+ let value = (provided !== undefined && provided !== null)
72
+ ? provided
73
+ : 12 + (0, HexToBuffer_1.HexToBuffer)(this.instance.body.getValue('')).length;
74
+ if (value > 65535) {
75
+ this.recordError(this.instance.length.getPath(), 'Maximum value is 65535');
76
+ value = 65535;
77
+ }
78
+ if (value < 0)
79
+ value = 0;
80
+ this.instance.length.setValue(value);
81
+ this.writeBytes(2, Buffer.from([(value >> 8) & 0xff, value & 0xff]));
82
+ }
83
+ },
84
+ //Flags: bit 0 Overflow, bit 1 Monolingual, bit 2 URL Auth, bit 3 Attr Auth, bit 4 Fresh;
85
+ //the remaining 3 bits reserved. Kept as a plain uint8 so reserved bits round-trip.
86
+ flags: this.fieldUInt('flags', 4, 1, 'Flags'),
87
+ dialect: this.fieldUInt('dialect', 5, 1, 'Dialect'),
88
+ //2-octet ISO 639 Language Code (e.g. "en"), kept verbatim as hex so any value round-trips.
89
+ languageCode: {
90
+ type: 'string',
91
+ label: 'Language Code',
92
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
93
+ decode: function () {
94
+ this.instance.languageCode.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(6, 2)));
95
+ },
96
+ encode: function () {
97
+ const code = this.instance.languageCode.getValue('');
98
+ this.writeBytes(6, code ? (0, HexToBuffer_1.HexToBuffer)(code) : Buffer.alloc(2, 0));
99
+ }
100
+ },
101
+ charEncoding: this.fieldUInt('charEncoding', 8, 2, 'Character Encoding'),
102
+ xid: this.fieldUInt('xid', 10, 2, 'XID'),
103
+ //The Function-specific body after the 12-byte common header, kept verbatim. Bounded by the
104
+ //message Length and the captured / UDP bytes, so trailing / pipelined data is left to the
105
+ //codec's recursion / RawData.
106
+ body: {
107
+ type: 'string',
108
+ label: 'Body',
109
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
110
+ decode: function () {
111
+ const available = this.#boundedAvailable();
112
+ let end = this.instance.length.getValue(0);
113
+ if (end > available)
114
+ end = available;
115
+ this.instance.body.setValue(end > 12 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(12, end - 12)) : '');
116
+ },
117
+ encode: function () {
118
+ const body = this.instance.body.getValue('');
119
+ if (body)
120
+ this.writeBytes(12, (0, HexToBuffer_1.HexToBuffer)(body));
121
+ }
122
+ }
123
+ }
124
+ };
125
+ }
126
+ match() {
127
+ //SLPv1 rides on UDP/TCP port 427 (shared with SLPv2). Require the full 12-byte common header and
128
+ //Version == 1 (the SLPv1 content signature) so non-SLP 427 traffic falls through to raw.
129
+ if (!this.prevCodecModule)
130
+ return false;
131
+ if (this.prevCodecModule.id !== 'udp' && this.prevCodecModule.id !== 'tcp')
132
+ return false;
133
+ if (this.packet.length - this.startPos < 12)
134
+ return false;
135
+ return this.readBytes(0, 1, true)[0] === 1;
136
+ }
137
+ }
138
+ exports.SLPv1 = SLPv1;
@@ -0,0 +1,37 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * SMB1 / CIFS (MS-CIFS / MS-SMB), TCP port 445 (Direct TCP) and TCP port 139 (over NBSS). Both transports
6
+ * frame the SMB message with a 4-byte prefix: a zero "session message" type byte followed by a 24-bit
7
+ * big-endian length giving the number of SMB message bytes that follow — the Direct TCP transport header
8
+ * (MS-SMB2 §2.1) on 445, and the equivalent NetBIOS Session Service session-message header on 139. The
9
+ * prefix is kept structurally so a message on either port round-trips byte-for-byte.
10
+ *
11
+ * After the prefix comes the 32-byte SMB1 header (MS-CIFS §2.2.3.1): Protocol (the 0xFF 'S' 'M' 'B' magic,
12
+ * ff534d42), Command (1 byte — 0x72 NEGOTIATE, 0x73 SESSION_SETUP_ANDX, 0x75 TREE_CONNECT_ANDX, …), a
13
+ * 4-byte NT Status, Flags (1 byte), Flags2 (2 bytes), PIDHigh (2 bytes), an 8-byte SecuritySignature,
14
+ * 2 reserved bytes, TID / PIDLow / UID / MID (2 bytes each). The parameter/data block follows: WordCount
15
+ * (1 byte), the Words (WordCount × 2 bytes), ByteCount (2 bytes) and the Bytes.
16
+ *
17
+ * ⚠️ Every multi-byte scalar in the SMB1 header is LITTLE-ENDIAN (SMB's on-wire byte order). There is no
18
+ * little-endian helper in this codebase, so the uint16 / uint32 fields are read and written byte-by-byte
19
+ * in their closures. The 8-byte SecuritySignature and the 2-byte Reserved field are kept verbatim as hex
20
+ * (opaque), so they round-trip byte-for-byte.
21
+ *
22
+ * The parameter/data block (WordCount + Words + ByteCount + Bytes) is command-dependent, cross-message
23
+ * state, so this single-message codec keeps it verbatim as `body` hex (byte-perfect). The 24-bit prefix
24
+ * length is honored when supplied (a crafted frame may lie) else derived as 32 + body bytes; the message
25
+ * is bounded by it, so a second pipelined message or trailing bytes are left to the codec's recursion /
26
+ * RawData. A well-formed message round-trips byte-for-byte.
27
+ */
28
+ export declare class SMB1 extends BaseHeader {
29
+ #private;
30
+ get SCHEMA(): ProtocolJSONSchema;
31
+ readonly id: string;
32
+ readonly name: string;
33
+ readonly nickname: string;
34
+ readonly matchKeys: string[];
35
+ match(): boolean;
36
+ readonly demuxProducers: DemuxProducer[];
37
+ }
@@ -0,0 +1,200 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SMB1 = 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
+ * SMB1 / CIFS (MS-CIFS / MS-SMB), TCP port 445 (Direct TCP) and TCP port 139 (over NBSS). Both transports
10
+ * frame the SMB message with a 4-byte prefix: a zero "session message" type byte followed by a 24-bit
11
+ * big-endian length giving the number of SMB message bytes that follow — the Direct TCP transport header
12
+ * (MS-SMB2 §2.1) on 445, and the equivalent NetBIOS Session Service session-message header on 139. The
13
+ * prefix is kept structurally so a message on either port round-trips byte-for-byte.
14
+ *
15
+ * After the prefix comes the 32-byte SMB1 header (MS-CIFS §2.2.3.1): Protocol (the 0xFF 'S' 'M' 'B' magic,
16
+ * ff534d42), Command (1 byte — 0x72 NEGOTIATE, 0x73 SESSION_SETUP_ANDX, 0x75 TREE_CONNECT_ANDX, …), a
17
+ * 4-byte NT Status, Flags (1 byte), Flags2 (2 bytes), PIDHigh (2 bytes), an 8-byte SecuritySignature,
18
+ * 2 reserved bytes, TID / PIDLow / UID / MID (2 bytes each). The parameter/data block follows: WordCount
19
+ * (1 byte), the Words (WordCount × 2 bytes), ByteCount (2 bytes) and the Bytes.
20
+ *
21
+ * ⚠️ Every multi-byte scalar in the SMB1 header is LITTLE-ENDIAN (SMB's on-wire byte order). There is no
22
+ * little-endian helper in this codebase, so the uint16 / uint32 fields are read and written byte-by-byte
23
+ * in their closures. The 8-byte SecuritySignature and the 2-byte Reserved field are kept verbatim as hex
24
+ * (opaque), so they round-trip byte-for-byte.
25
+ *
26
+ * The parameter/data block (WordCount + Words + ByteCount + Bytes) is command-dependent, cross-message
27
+ * state, so this single-message codec keeps it verbatim as `body` hex (byte-perfect). The 24-bit prefix
28
+ * length is honored when supplied (a crafted frame may lie) else derived as 32 + body bytes; the message
29
+ * is bounded by it, so a second pipelined message or trailing bytes are left to the codec's recursion /
30
+ * RawData. A well-formed message round-trips byte-for-byte.
31
+ */
32
+ class SMB1 extends BaseHeader_1.BaseHeader {
33
+ constructor() {
34
+ super(...arguments);
35
+ this.id = 'smb1';
36
+ this.name = 'SMB1';
37
+ this.nickname = 'SMB1';
38
+ //SMB1/CIFS rides TCP port 445 (Direct TCP) and 139 (over NBSS).
39
+ this.matchKeys = ['tcpport:445', 'tcpport:139'];
40
+ //A leaf header — the command-specific parameter/data block requires per-command, cross-message parsing.
41
+ this.demuxProducers = [];
42
+ }
43
+ static #schemaCache;
44
+ get SCHEMA() {
45
+ return (SMB1.#schemaCache ??= SMB1.#buildSchema());
46
+ }
47
+ /** A little-endian unsigned 16-bit field of 2 octets at `offset`. */
48
+ static #fieldUInt16LE(name, offset, label) {
49
+ return {
50
+ type: 'integer',
51
+ label: label,
52
+ minimum: 0,
53
+ maximum: 65535,
54
+ decode: function () {
55
+ const b = this.readBytes(offset, 2);
56
+ this.instance[name].setValue(b[0] | (b[1] << 8));
57
+ },
58
+ encode: function () {
59
+ const node = this.instance[name];
60
+ let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
61
+ if (value > 65535) {
62
+ this.recordError(node.getPath(), 'Maximum value is 65535');
63
+ value = 65535;
64
+ }
65
+ if (value < 0) {
66
+ this.recordError(node.getPath(), 'Minimum value is 0');
67
+ value = 0;
68
+ }
69
+ node.setValue(value);
70
+ this.writeBytes(offset, Buffer.from([value & 0xff, (value >> 8) & 0xff]));
71
+ }
72
+ };
73
+ }
74
+ /** A little-endian unsigned 32-bit field of 4 octets at `offset`. */
75
+ static #fieldUInt32LE(name, offset, label) {
76
+ return {
77
+ type: 'integer',
78
+ label: label,
79
+ minimum: 0,
80
+ maximum: 4294967295,
81
+ decode: function () {
82
+ const b = this.readBytes(offset, 4);
83
+ this.instance[name].setValue((b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)) >>> 0);
84
+ },
85
+ encode: function () {
86
+ const node = this.instance[name];
87
+ let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
88
+ if (value > 4294967295) {
89
+ this.recordError(node.getPath(), 'Maximum value is 4294967295');
90
+ value = 4294967295;
91
+ }
92
+ if (value < 0) {
93
+ this.recordError(node.getPath(), 'Minimum value is 0');
94
+ value = 0;
95
+ }
96
+ node.setValue(value);
97
+ this.writeBytes(offset, Buffer.from([value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >>> 24) & 0xff]));
98
+ }
99
+ };
100
+ }
101
+ static #buildSchema() {
102
+ return {
103
+ type: 'object',
104
+ summary: 'SMB1 command=${command} tid=${tid} mid=${mid}',
105
+ properties: {
106
+ //Transport prefix: byte 0 is the zero "session message" type (Direct TCP on 445, or the
107
+ //NetBIOS Session Service session-message header on 139); bytes 1-3 are the 24-bit
108
+ //big-endian message length. Kept as a plain octet so a crafted non-zero type round-trips.
109
+ transportType: this.fieldUInt('transportType', 0, 1, 'Transport Type'),
110
+ //24-bit big-endian length of the SMB message that follows (the 32-byte header + body,
111
+ //excluding this 4-byte transport prefix). Honored when supplied (a crafted frame may lie);
112
+ //else derived as 32 + body bytes.
113
+ streamProtocolLength: {
114
+ type: 'integer',
115
+ label: 'Stream Protocol Length',
116
+ minimum: 0,
117
+ maximum: 16777215,
118
+ decode: function () {
119
+ const b = this.readBytes(1, 3);
120
+ this.instance.streamProtocolLength.setValue((b[0] << 16) | (b[1] << 8) | b[2]);
121
+ },
122
+ encode: function () {
123
+ const provided = this.instance.streamProtocolLength.getValue();
124
+ let value = (provided !== undefined && provided !== null)
125
+ ? provided
126
+ : 32 + (0, HexToBuffer_1.HexToBuffer)(this.instance.body.getValue('')).length;
127
+ if (value > 16777215) {
128
+ this.recordError(this.instance.streamProtocolLength.getPath(), 'Maximum value is 16777215');
129
+ value = 16777215;
130
+ }
131
+ if (value < 0) {
132
+ this.recordError(this.instance.streamProtocolLength.getPath(), 'Minimum value is 0');
133
+ value = 0;
134
+ }
135
+ this.instance.streamProtocolLength.setValue(value);
136
+ this.writeBytes(1, Buffer.from([(value >> 16) & 0xff, (value >> 8) & 0xff, value & 0xff]));
137
+ }
138
+ },
139
+ //The 4-byte Protocol magic — 0xFF 'S' 'M' 'B' (ff534d42). Kept verbatim so a crafted magic
140
+ //round-trips; the match() gate enforces the real signature for selection (and separates
141
+ //SMB1 from SMB2's 0xFE 'S' 'M' 'B' in the same 445/139 buckets).
142
+ protocolId: this.fieldHex('protocolId', 4, 4, 'Protocol Id'),
143
+ //Command (MS-CIFS §2.2.2.1): 0x72 NEGOTIATE, 0x73 SESSION_SETUP_ANDX, 0x75 TREE_CONNECT_ANDX,
144
+ //… (kept as a plain honored uint — no enum, so an unknown/crafted opcode still round-trips).
145
+ command: this.fieldUInt('command', 8, 1, 'Command'),
146
+ //NT Status (4-byte LE) — MS-CIFS §2.2.3.1 (in the SMB_COM error class/code form when
147
+ //Flags2 SMB_FLAGS2_NT_STATUS is clear; a 4-byte field either way).
148
+ status: this.#fieldUInt32LE('status', 9, 'Status'),
149
+ flags: this.fieldUInt('flags', 13, 1, 'Flags'),
150
+ flags2: this.#fieldUInt16LE('flags2', 14, 'Flags2'),
151
+ //PIDHigh — the high 2 bytes of a 32-bit Process Id.
152
+ pidHigh: this.#fieldUInt16LE('pidHigh', 16, 'PID High'),
153
+ //8-byte SecuritySignature (zero when unsigned) — kept verbatim.
154
+ securitySignature: this.fieldHex('securitySignature', 18, 8, 'Security Signature'),
155
+ //2 reserved bytes — kept verbatim so they round-trip untouched.
156
+ reserved: this.fieldHex('reserved', 26, 2, 'Reserved'),
157
+ tid: this.#fieldUInt16LE('tid', 28, 'Tree Id'),
158
+ //PIDLow — the low 2 bytes of the Process Id.
159
+ pidLow: this.#fieldUInt16LE('pidLow', 30, 'PID Low'),
160
+ uid: this.#fieldUInt16LE('uid', 32, 'User Id'),
161
+ mid: this.#fieldUInt16LE('mid', 34, 'Multiplex Id'),
162
+ //The parameter/data block after the 32-byte header (WordCount + Words + ByteCount + Bytes),
163
+ //kept verbatim. Bounded by the transport prefix length (the message ends at 4 +
164
+ //streamProtocolLength) and the captured bytes, so trailing / pipelined data is left to the
165
+ //codec's recursion / RawData.
166
+ body: {
167
+ type: 'string',
168
+ label: 'Body',
169
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
170
+ decode: function () {
171
+ const remaining = this.packet.length - this.startPos;
172
+ const streamLength = this.instance.streamProtocolLength.getValue(0);
173
+ let end = 4 + streamLength;
174
+ if (end > remaining)
175
+ end = remaining;
176
+ this.instance.body.setValue(end > 36 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(36, end - 36)) : '');
177
+ },
178
+ encode: function () {
179
+ const body = this.instance.body.getValue('');
180
+ if (body)
181
+ this.writeBytes(36, (0, HexToBuffer_1.HexToBuffer)(body));
182
+ }
183
+ }
184
+ }
185
+ };
186
+ }
187
+ match() {
188
+ //SMB1 rides on TCP port 445 / 139 (selected via the tcpport buckets). Require the 4-byte transport
189
+ //prefix + the 0xFF 'S' 'M' 'B' (ff534d42) Protocol magic at offset 4 — a strong 4-byte content
190
+ //signature — so non-SMB1 445/139 traffic (and SMB2's 0xFE 'S' 'M' 'B') falls through to raw. The
191
+ //magic gate makes SMB1 and SMB2 mutually exclusive in the shared port buckets. Selection stays
192
+ //port-bucketed (matchKeys, no heuristicFallback) like the other length-bounded TCP payload codecs.
193
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'tcp')
194
+ return false;
195
+ if (this.packet.length - this.startPos < 8)
196
+ return false;
197
+ return (0, BufferToHex_1.BufferToHex)(this.readBytes(4, 4)) === 'ff534d42';
198
+ }
199
+ }
200
+ exports.SMB1 = SMB1;
@@ -0,0 +1,36 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * SMB2 / SMB3 (MS-SMB2), TCP port 445. Over the Direct TCP transport (MS-SMB2 §2.1) every message is
6
+ * framed by a 4-byte transport header — a zero byte followed by a 24-bit big-endian StreamProtocolLength
7
+ * giving the number of SMB2 message bytes that follow — then the 64-byte SMB2 packet header, then the
8
+ * command-specific body.
9
+ *
10
+ * The 64-byte SMB2 header (MS-SMB2 §2.2.1.2, the SYNC form) is: ProtocolId (the 0xFE 'S' 'M' 'B' magic),
11
+ * StructureSize (always 64), CreditCharge, Status/ChannelSequence+Reserved, Command (0 NEGOTIATE, 1
12
+ * SESSION_SETUP, 3 TREE_CONNECT, 5 CREATE, 8 READ, 9 WRITE, …), CreditRequest/Response, Flags, NextCommand,
13
+ * MessageId, Reserved(ProcessId), TreeId, SessionId and a 16-byte Signature.
14
+ *
15
+ * ⚠️ Every multi-byte scalar in the SMB2 header is LITTLE-ENDIAN (SMB's on-wire byte order). There is no
16
+ * little-endian helper in this codebase, so the uint16 / uint32 fields are read and written byte-by-byte
17
+ * in their closures. The 8-byte MessageId / SessionId and the Signature are kept verbatim as hex (opaque,
18
+ * and 64-bit values exceed a JS number's exact integer range), so they round-trip byte-for-byte.
19
+ *
20
+ * The command-specific body (the NEGOTIATE dialects, SESSION_SETUP security blob, CREATE contexts, READ /
21
+ * WRITE data, …) is cross-message, command-dependent state, so this single-message codec keeps it verbatim
22
+ * as `body` hex (byte-perfect). The StreamProtocolLength is honored when supplied (a crafted frame may lie)
23
+ * else derived as 64 + body bytes; the message is bounded by it, so a second compounded/pipelined message
24
+ * or trailing bytes are left to the codec's recursion / RawData. A well-formed message round-trips
25
+ * byte-for-byte.
26
+ */
27
+ export declare class SMB2 extends BaseHeader {
28
+ #private;
29
+ get SCHEMA(): ProtocolJSONSchema;
30
+ readonly id: string;
31
+ readonly name: string;
32
+ readonly nickname: string;
33
+ readonly matchKeys: string[];
34
+ match(): boolean;
35
+ readonly demuxProducers: DemuxProducer[];
36
+ }