@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,343 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ISOSession = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ const BufferToHex_1 = require("../helper/BufferToHex");
6
+ const HexToBuffer_1 = require("../helper/HexToBuffer");
7
+ /**
8
+ * ISO Session — the OSI Session layer (ISO 8327 / X.225) that sits above COTP in the MMS stack
9
+ * (TPKT → COTP → Session → Presentation → MMS). Each SPDU is a 1-byte SI (SPDU Identifier) + 1-byte LI
10
+ * (Length Indicator) + LI bytes of parameters. The MMS data phase is the fixed pair GIVE-TOKENS +
11
+ * DATA-TRANSFER (`01 00 01 00`); the connection phase is a CONNECT (SI 13) or ACCEPT (SI 14) SPDU with
12
+ * variable parameters.
13
+ *
14
+ * Session is decoded as a small chain of SPDUs (each SI/LI/params kept verbatim), then the user data —
15
+ * the Presentation/MMS PDU that follows — is handed to the codec's dispatch (like COTP hands its payload
16
+ * to Session). The single-frame completeness gate is already enforced upstream by COTP (it only exposes
17
+ * a child for a DT+EOT PDU fully contained in the packet), so a T2-fragmented MMS body never reaches
18
+ * here. The SPDU chain round-trips byte-for-byte; the presentation/MMS remainder is a child layer.
19
+ */
20
+ class ISOSession extends BaseHeader_1.BaseHeader {
21
+ constructor() {
22
+ super(...arguments);
23
+ this.id = 'iso-session';
24
+ this.name = 'ISO Session';
25
+ this.nickname = 'ISO-SES';
26
+ //A content-heuristic child of COTP (unkeyed), selected by a session SI at the start of the COTP payload.
27
+ this.matchKeys = [];
28
+ this.heuristicFallback = true;
29
+ //The Presentation/MMS PDU follows as a child — nothing demuxes off Session by a field value.
30
+ this.demuxProducers = [];
31
+ }
32
+ static #schemaCache;
33
+ //Session SPDU Identifiers we walk over: DT/GT (1), REFUSE (5), NOT-FINISHED (8), FINISH/DISCONNECT
34
+ //(9), CONNECT (13), ACCEPT (14), ABORT (25), ABORT-ACCEPT (26). The Presentation PDU that follows
35
+ //begins with a BER tag (0x61 / 0x31), which is not in this set, so the walk stops at the boundary.
36
+ static #VALID_SI = new Set([1, 5, 8, 9, 13, 14, 25, 26]);
37
+ //ACSE (ISO 8650) APDU tags, for naming the connection-phase PDU carried inside a CONNECT/ACCEPT SPDU.
38
+ static #ACSE_NAMES = {
39
+ 0x60: 'AARQ', 0x61: 'AARE', 0x62: 'RLRQ', 0x63: 'RLRE', 0x64: 'ABRT'
40
+ };
41
+ get SCHEMA() {
42
+ return (ISOSession.#schemaCache ??= ISOSession.#buildSchema());
43
+ }
44
+ /** A clamping, never-throwing BER TLV read at `pos`: {tag, contentStart, contentLength} or null past end. */
45
+ static #readTLV(buf, pos) {
46
+ if (pos + 2 > buf.length)
47
+ return null;
48
+ const tag = buf[pos];
49
+ const lengthOctet = buf[pos + 1];
50
+ let contentStart = pos + 2;
51
+ let contentLength;
52
+ if (lengthOctet < 0x80) {
53
+ contentLength = lengthOctet;
54
+ }
55
+ else if (lengthOctet === 0x80) {
56
+ contentLength = buf.length - contentStart; //indefinite: run to end (kept verbatim)
57
+ }
58
+ else {
59
+ const n = lengthOctet & 0x7f;
60
+ if (contentStart + n > buf.length)
61
+ return null;
62
+ contentLength = 0;
63
+ for (let i = 0; i < n; i++)
64
+ contentLength = (contentLength << 8) | buf[contentStart + i];
65
+ contentStart += n;
66
+ }
67
+ if (contentStart + contentLength > buf.length)
68
+ contentLength = buf.length - contentStart;
69
+ if (contentLength < 0)
70
+ contentLength = 0;
71
+ return { tag: tag, contentStart: contentStart, contentLength: contentLength };
72
+ }
73
+ /** Find the first direct child TLV with the given tag within [start, end). */
74
+ static #findChild(buf, start, end, wantTag) {
75
+ let pos = start;
76
+ while (pos < end) {
77
+ const tlv = ISOSession.#readTLV(buf, pos);
78
+ if (!tlv)
79
+ break;
80
+ if (tlv.tag === wantTag)
81
+ return tlv;
82
+ const next = tlv.contentStart + tlv.contentLength;
83
+ if (next <= pos)
84
+ break;
85
+ pos = next;
86
+ }
87
+ return null;
88
+ }
89
+ /** Locate the SS-user-data (PGI 0xc1 / extended 0xc2) inside a CONNECT/ACCEPT SPDU's ISO 8327 params. */
90
+ static #sessionUserData(params) {
91
+ let pos = 0;
92
+ while (pos + 2 <= params.length) {
93
+ const pi = params[pos];
94
+ let li = params[pos + 1];
95
+ let contentStart = pos + 2;
96
+ if (li === 0xff) {
97
+ if (contentStart + 2 > params.length)
98
+ break;
99
+ li = (params[contentStart] << 8) | params[contentStart + 1];
100
+ contentStart += 2;
101
+ }
102
+ if (pi === 0xc1 || pi === 0xc2) {
103
+ const end = Math.min(contentStart + li, params.length);
104
+ return params.subarray(contentStart, end);
105
+ }
106
+ const next = contentStart + li;
107
+ if (next <= pos)
108
+ break;
109
+ pos = next;
110
+ }
111
+ return null;
112
+ }
113
+ /**
114
+ * Detect the ACSE APDU inside a CONNECT/ACCEPT SPDU's user data (best-effort, never-throwing):
115
+ * the ISO 8823 Presentation CP-type/CPA-type (0x31) → normal-mode-parameters [2] (0xa2) →
116
+ * fully-encoded-data (0x61) → PDV-list (0x30) → presentation-data-values [0] (0xa0) → the ACSE APDU.
117
+ * Returns the ACSE TLV (tag 0x60 AARQ … 0x64 ABRT) or null.
118
+ */
119
+ static #detectAcse(userData) {
120
+ const cp = ISOSession.#readTLV(userData, 0);
121
+ if (!cp || cp.tag !== 0x31)
122
+ return null;
123
+ const nmp = ISOSession.#findChild(userData, cp.contentStart, cp.contentStart + cp.contentLength, 0xa2);
124
+ if (!nmp)
125
+ return null;
126
+ const fed = ISOSession.#findChild(userData, nmp.contentStart, nmp.contentStart + nmp.contentLength, 0x61);
127
+ if (!fed)
128
+ return null;
129
+ const pdv = ISOSession.#readTLV(userData, fed.contentStart);
130
+ if (!pdv || pdv.tag !== 0x30)
131
+ return null;
132
+ const values = ISOSession.#findChild(userData, pdv.contentStart, pdv.contentStart + pdv.contentLength, 0xa0);
133
+ if (!values || values.contentStart >= userData.length)
134
+ return null;
135
+ //Only report a genuine ACSE APDU (AARQ 0x60 … ABRT 0x64); anything else leaves acseType unset.
136
+ const tag = userData[values.contentStart];
137
+ if (!(tag >= 0x60 && tag <= 0x64))
138
+ return null;
139
+ return ISOSession.#readTLV(userData, values.contentStart);
140
+ }
141
+ /**
142
+ * The OID inside a context-tagged ACSE field (e.g. application-context-name [1] = 0xa1, called-AP-title
143
+ * [2] = 0xa2, responding-AP-title [4] = 0xa4, calling-AP-title [6] = 0xa6, each wrapping an OBJECT
144
+ * IDENTIFIER form) as a dotted string, or ''.
145
+ */
146
+ static #acseOid(buf, acse, wantTag) {
147
+ const field = ISOSession.#findChild(buf, acse.contentStart, acse.contentStart + acse.contentLength, wantTag);
148
+ if (!field)
149
+ return '';
150
+ const oid = ISOSession.#readTLV(buf, field.contentStart);
151
+ if (!oid || oid.tag !== 0x06)
152
+ return '';
153
+ return ISOSession.#decodeOid(buf, oid.contentStart, oid.contentLength);
154
+ }
155
+ /** Read a small INTEGER (≤ 6 octets) from the first direct child with `wantTag` within [start, end), or -1. */
156
+ static #acseInt(buf, start, end, wantTag) {
157
+ const tlv = ISOSession.#findChild(buf, start, end, wantTag);
158
+ if (!tlv)
159
+ return -1;
160
+ let value = 0;
161
+ const limit = Math.min(tlv.contentLength, 6);
162
+ for (let i = 0; i < limit; i++)
163
+ value = (value * 256) + buf[tlv.contentStart + i];
164
+ return value;
165
+ }
166
+ /**
167
+ * Extract the MMS initiate parameters carried in the ACSE user-information (best-effort, never-throwing):
168
+ * ACSE user-information [30] (0xbe) → EXTERNAL (0x28) → encoding [0] (0xa0) → MMS initiate PDU (0xa8
169
+ * request / 0xa9 response) → proposedMaxServOutstandingCalling [1], -Called [2], nesting-level [3], and
170
+ * the (proposed/negotiated) version number inside init-detail [4] → [0]. -1 for any absent part.
171
+ */
172
+ static #mmsInitiate(buf, acse) {
173
+ const out = { maxCalling: -1, maxCalled: -1, nesting: -1, version: -1 };
174
+ const ui = ISOSession.#findChild(buf, acse.contentStart, acse.contentStart + acse.contentLength, 0xbe);
175
+ if (!ui)
176
+ return out;
177
+ const ext = ISOSession.#findChild(buf, ui.contentStart, ui.contentStart + ui.contentLength, 0x28);
178
+ if (!ext)
179
+ return out;
180
+ const enc = ISOSession.#findChild(buf, ext.contentStart, ext.contentStart + ext.contentLength, 0xa0);
181
+ if (!enc)
182
+ return out;
183
+ const init = ISOSession.#readTLV(buf, enc.contentStart);
184
+ if (!init || (init.tag !== 0xa8 && init.tag !== 0xa9))
185
+ return out;
186
+ const end = init.contentStart + init.contentLength;
187
+ out.maxCalling = ISOSession.#acseInt(buf, init.contentStart, end, 0x81);
188
+ out.maxCalled = ISOSession.#acseInt(buf, init.contentStart, end, 0x82);
189
+ out.nesting = ISOSession.#acseInt(buf, init.contentStart, end, 0x83);
190
+ const detail = ISOSession.#findChild(buf, init.contentStart, end, 0xa4);
191
+ if (detail)
192
+ out.version = ISOSession.#acseInt(buf, detail.contentStart, detail.contentStart + detail.contentLength, 0x80);
193
+ return out;
194
+ }
195
+ /** Decode a BER OBJECT IDENTIFIER body to a dotted string (never-throwing, clamped). */
196
+ static #decodeOid(buf, start, length) {
197
+ if (length <= 0 || start + length > buf.length)
198
+ return '';
199
+ //Accumulate base-128 subidentifiers (high-bit continuation). Multiplication (not <<7) so arcs above
200
+ //2^28 don't overflow the 32-bit shift.
201
+ const subs = [];
202
+ let value = 0;
203
+ for (let i = start; i < start + length; i++) {
204
+ value = value * 128 + (buf[i] & 0x7f);
205
+ if ((buf[i] & 0x80) === 0) {
206
+ subs.push(value);
207
+ value = 0;
208
+ }
209
+ }
210
+ if (subs.length === 0)
211
+ return '';
212
+ //The first subidentifier encodes the first two arcs: X*40 + Y, X in {0,1,2} (Y unbounded when X=2).
213
+ const first = subs[0];
214
+ const x = first < 40 ? 0 : first < 80 ? 1 : 2;
215
+ const parts = [x, first - x * 40, ...subs.slice(1)];
216
+ return parts.join('.');
217
+ }
218
+ static #buildSchema() {
219
+ return {
220
+ type: 'object',
221
+ summary: 'ISO-Session ${spdus.length} spdu',
222
+ properties: {
223
+ spdus: {
224
+ type: 'array',
225
+ label: 'SPDUs',
226
+ items: {
227
+ type: 'object',
228
+ properties: {
229
+ si: { type: 'integer', label: 'SPDU Identifier', minimum: 0, maximum: 255 },
230
+ li: { type: 'integer', label: 'Length Indicator', minimum: 0, maximum: 255 },
231
+ params: { type: 'string', label: 'Parameters', contentEncoding: 'hex' }
232
+ }
233
+ },
234
+ decode: function () {
235
+ const available = this.packet.length - this.startPos;
236
+ const spdus = [];
237
+ let offset = 0;
238
+ //Walk SPDUs while the SI is a session identifier; stop at the Presentation PDU (a
239
+ //BER tag, not a session SI). The SI/LI are peeked dryRun so a malformed length
240
+ //leaves the bytes to the child rather than being mis-consumed.
241
+ while (offset + 2 <= available) {
242
+ const si = this.readBytes(offset, 1, true)[0];
243
+ if (!ISOSession.#VALID_SI.has(si))
244
+ break;
245
+ const li = this.readBytes(offset + 1, 1, true)[0];
246
+ if (offset + 2 + li > available)
247
+ break;
248
+ const params = li > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset + 2, li, true)) : '';
249
+ spdus.push({ si: si, li: li, params: params });
250
+ offset += 2 + li;
251
+ }
252
+ //Mark the consumed SPDU region so headerLength stops here and the codec dispatches
253
+ //the Presentation/MMS remainder as a child (empty-param SPDUs do no non-dry read).
254
+ if (offset > 0)
255
+ this.readBytes(0, offset);
256
+ this.instance.spdus.setValue(spdus);
257
+ //Connection phase: a CONNECT (13) / ACCEPT (14) SPDU embeds the ACSE APDU in its
258
+ //user data (the presentation is not a following child here). Surface its type for
259
+ //display; the params stay verbatim so the byte round-trip is unaffected.
260
+ for (const spdu of spdus) {
261
+ if (spdu.si !== 13 && spdu.si !== 14)
262
+ continue;
263
+ const userData = ISOSession.#sessionUserData((0, HexToBuffer_1.HexToBuffer)(spdu.params));
264
+ if (!userData)
265
+ continue;
266
+ const acse = ISOSession.#detectAcse(userData);
267
+ if (acse) {
268
+ this.instance.acseType.setValue(ISOSession.#ACSE_NAMES[acse.tag] ?? `0x${acse.tag.toString(16)}`);
269
+ const appContext = ISOSession.#acseOid(userData, acse, 0xa1);
270
+ if (appContext)
271
+ this.instance.acseAppContext.setValue(appContext);
272
+ if (acse.tag === 0x60) {
273
+ //AARQ: called-AP-title [2], calling-AP-title [6].
274
+ const called = ISOSession.#acseOid(userData, acse, 0xa2);
275
+ if (called)
276
+ this.instance.acseCalledApTitle.setValue(called);
277
+ const calling = ISOSession.#acseOid(userData, acse, 0xa6);
278
+ if (calling)
279
+ this.instance.acseCallingApTitle.setValue(calling);
280
+ }
281
+ else if (acse.tag === 0x61) {
282
+ //AARE: responding-AP-title [4].
283
+ const responding = ISOSession.#acseOid(userData, acse, 0xa4);
284
+ if (responding)
285
+ this.instance.acseRespondingApTitle.setValue(responding);
286
+ }
287
+ //MMS initiate parameters carried in the ACSE user-information.
288
+ const init = ISOSession.#mmsInitiate(userData, acse);
289
+ if (init.maxCalling >= 0)
290
+ this.instance.mmsInitMaxServOutstandingCalling.setValue(init.maxCalling);
291
+ if (init.maxCalled >= 0)
292
+ this.instance.mmsInitMaxServOutstandingCalled.setValue(init.maxCalled);
293
+ if (init.nesting >= 0)
294
+ this.instance.mmsInitNestingLevel.setValue(init.nesting);
295
+ if (init.version >= 0)
296
+ this.instance.mmsInitVersion.setValue(init.version);
297
+ }
298
+ break;
299
+ }
300
+ },
301
+ encode: function () {
302
+ const spdus = this.instance.spdus.getValue();
303
+ if (!Array.isArray(spdus))
304
+ return;
305
+ let offset = 0;
306
+ for (const spdu of spdus) {
307
+ const si = Number(spdu && spdu.si) & 0xff;
308
+ const params = (0, HexToBuffer_1.HexToBuffer)(spdu && spdu.params ? String(spdu.params) : '');
309
+ //LI honored when supplied (a crafted SPDU may lie), else derived from params.
310
+ const provided = Number(spdu && spdu.li);
311
+ const li = (spdu && spdu.li !== undefined && spdu.li !== null && Number.isFinite(provided)) ? provided & 0xff : params.length & 0xff;
312
+ this.writeBytes(offset, Buffer.from([si, li]));
313
+ if (params.length)
314
+ this.writeBytes(offset + 2, params);
315
+ offset += 2 + params.length;
316
+ }
317
+ }
318
+ },
319
+ //Display-only: the ACSE APDU type (AARQ/AARE/…) and application-context-name OID parsed from
320
+ //a CONNECT/ACCEPT SPDU's user data on decode. No encode closure — the SPDU params above stay
321
+ //the encode authority.
322
+ acseType: { type: 'string', label: 'ACSE APDU' },
323
+ acseAppContext: { type: 'string', label: 'ACSE Application Context' },
324
+ acseCalledApTitle: { type: 'string', label: 'ACSE Called AP-Title' },
325
+ acseCallingApTitle: { type: 'string', label: 'ACSE Calling AP-Title' },
326
+ acseRespondingApTitle: { type: 'string', label: 'ACSE Responding AP-Title' },
327
+ mmsInitMaxServOutstandingCalling: { type: 'integer', label: 'MMS Init Max Serv Outstanding Calling' },
328
+ mmsInitMaxServOutstandingCalled: { type: 'integer', label: 'MMS Init Max Serv Outstanding Called' },
329
+ mmsInitNestingLevel: { type: 'integer', label: 'MMS Init Data Structure Nesting Level' },
330
+ mmsInitVersion: { type: 'integer', label: 'MMS Init Version' }
331
+ }
332
+ };
333
+ }
334
+ match() {
335
+ const prev = this.prevCodecModule;
336
+ if (!prev || prev.id !== 'cotp')
337
+ return false;
338
+ if (this.packet.length - this.startPos < 2)
339
+ return false;
340
+ return ISOSession.#VALID_SI.has(this.readBytes(0, 1, true)[0]);
341
+ }
342
+ }
343
+ exports.ISOSession = ISOSession;
@@ -0,0 +1,42 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * Ident — the Identification Protocol (RFC 1413), carried over TCP well-known port 113. A single
6
+ * US-ASCII line, terminated by CR LF, is exchanged in each direction:
7
+ *
8
+ * QUERY (client → server): "<server-port> , <client-port>{C}"
9
+ * e.g. "6193, 23\r\n" — asks the ident server who owns the connection
10
+ * whose remote/local TCP ports are server-port and client-port.
11
+ * REPLY (server → client): "<server-port> , <client-port> : USERID : <opsys> : <username>{C}"
12
+ * or "<server-port> , <client-port> : ERROR : <error-type>{C}"
13
+ * e.g. "6193, 23 : USERID : UNIX : stjohns\r\n"
14
+ * or "6193, 23 : ERROR : NO-USER\r\n"
15
+ *
16
+ * MINIMAL slice (mirrors the Finger/SIP/HTTP verbatim-message pattern): the line is free-form US-ASCII
17
+ * with only CR LF for framing and a username field that MAY carry almost any octet, so the exact bytes a
18
+ * peer sees are richer than a form needs. The ENTIRE payload is therefore the single source of truth —
19
+ * decoded verbatim to hex in the authoritative `message` field and re-emitted byte-for-byte on encode.
20
+ * On top of that the first line is parsed into DISPLAY-ONLY metadata: the two port numbers, whether the
21
+ * line is a query or a reply, the reply type (USERID / ERROR) and its USERID opsys+username or ERROR
22
+ * error-type. Those carry no codec of their own and never reconstruct the bytes — the message owns them.
23
+ * So any Ident payload (a query, a USERID reply, an ERROR reply, or a truncated fragment) round-trips
24
+ * exactly.
25
+ *
26
+ * Matching rationale (NO heuristicFallback): Ident is claimed ONLY on the tcp:113 bucket. A query/reply
27
+ * line is arbitrary US-ASCII text with no distinctive off-port content signature, so recognizing it
28
+ * relies entirely on the well-known port; joining the global content-heuristic chain would mislabel
29
+ * arbitrary text TCP payloads on any port. Confining Ident to tcp:113 keeps that impossible; alt-port
30
+ * Ident is rare and falls losslessly to raw. As the terminal verbatim layer it consumes to the end of the
31
+ * segment (like Finger/HTTP) so a well-formed frame round-trips byte-for-byte.
32
+ */
33
+ export declare class Ident extends BaseHeader {
34
+ #private;
35
+ get SCHEMA(): ProtocolJSONSchema;
36
+ readonly id: string;
37
+ readonly name: string;
38
+ readonly nickname: string;
39
+ readonly matchKeys: string[];
40
+ match(): boolean;
41
+ readonly demuxProducers: DemuxProducer[];
42
+ }
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Ident = void 0;
5
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
6
+ const BufferToHex_1 = require("../helper/BufferToHex");
7
+ const HexToBuffer_1 = require("../helper/HexToBuffer");
8
+ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
9
+ /**
10
+ * Ident — the Identification Protocol (RFC 1413), carried over TCP well-known port 113. A single
11
+ * US-ASCII line, terminated by CR LF, is exchanged in each direction:
12
+ *
13
+ * QUERY (client → server): "<server-port> , <client-port>{C}"
14
+ * e.g. "6193, 23\r\n" — asks the ident server who owns the connection
15
+ * whose remote/local TCP ports are server-port and client-port.
16
+ * REPLY (server → client): "<server-port> , <client-port> : USERID : <opsys> : <username>{C}"
17
+ * or "<server-port> , <client-port> : ERROR : <error-type>{C}"
18
+ * e.g. "6193, 23 : USERID : UNIX : stjohns\r\n"
19
+ * or "6193, 23 : ERROR : NO-USER\r\n"
20
+ *
21
+ * MINIMAL slice (mirrors the Finger/SIP/HTTP verbatim-message pattern): the line is free-form US-ASCII
22
+ * with only CR LF for framing and a username field that MAY carry almost any octet, so the exact bytes a
23
+ * peer sees are richer than a form needs. The ENTIRE payload is therefore the single source of truth —
24
+ * decoded verbatim to hex in the authoritative `message` field and re-emitted byte-for-byte on encode.
25
+ * On top of that the first line is parsed into DISPLAY-ONLY metadata: the two port numbers, whether the
26
+ * line is a query or a reply, the reply type (USERID / ERROR) and its USERID opsys+username or ERROR
27
+ * error-type. Those carry no codec of their own and never reconstruct the bytes — the message owns them.
28
+ * So any Ident payload (a query, a USERID reply, an ERROR reply, or a truncated fragment) round-trips
29
+ * exactly.
30
+ *
31
+ * Matching rationale (NO heuristicFallback): Ident is claimed ONLY on the tcp:113 bucket. A query/reply
32
+ * line is arbitrary US-ASCII text with no distinctive off-port content signature, so recognizing it
33
+ * relies entirely on the well-known port; joining the global content-heuristic chain would mislabel
34
+ * arbitrary text TCP payloads on any port. Confining Ident to tcp:113 keeps that impossible; alt-port
35
+ * Ident is rare and falls losslessly to raw. As the terminal verbatim layer it consumes to the end of the
36
+ * segment (like Finger/HTTP) so a well-formed frame round-trips byte-for-byte.
37
+ */
38
+ class Ident extends BaseHeader_1.BaseHeader {
39
+ constructor() {
40
+ super(...arguments);
41
+ this.id = 'ident';
42
+ this.name = 'Identification Protocol';
43
+ this.nickname = 'Ident';
44
+ //Ident is recognized ONLY on the well-known port 113 — deliberately NOT via heuristicFallback. A
45
+ //query/reply line is arbitrary US-ASCII text with no distinctive off-port content signature, so its
46
+ //recognition depends entirely on the port bucket; joining the global heuristic chain would mislabel
47
+ //arbitrary text TCP payloads on any port. See the class doc for the full rationale.
48
+ this.matchKeys = ['tcpport:113'];
49
+ //A leaf header — an Ident query/reply is a single free-form line; nothing demuxes off it.
50
+ this.demuxProducers = [];
51
+ }
52
+ static #schemaCache;
53
+ get SCHEMA() {
54
+ return (_a.#schemaCache ??= _a.#buildSchema());
55
+ }
56
+ /** Bytes available to this header: Ident rides on TCP, which has no per-message length. */
57
+ #payloadLength() {
58
+ const available = this.packet.length - this.startPos;
59
+ return available < 0 ? 0 : available;
60
+ }
61
+ /** Parse a decimal TCP port for display, clamped to [0, 65535] (never throws; non-numeric → 0). */
62
+ static #clampPort(text) {
63
+ const value = parseInt((text ? text : '').trim(), 10);
64
+ if (!Number.isFinite(value))
65
+ return 0;
66
+ return value < 0 ? 0 : value > 65535 ? 65535 : value;
67
+ }
68
+ /**
69
+ * Parse the first line into the display-only metadata fields. The line is
70
+ * `<server-port> , <client-port>[ : <resp-type> : ...]{C}` where {C} is CR LF (a lone LF is
71
+ * tolerated). Populated on decode only — these fields have no encode, so they never affect the
72
+ * re-emitted bytes and never mutate `message`. Never throws: missing tokens yield 0 / empty strings.
73
+ */
74
+ #parse(text) {
75
+ //Keep only up to the first line ending for the display parse; `message` still holds all bytes.
76
+ let line = text;
77
+ const lf = line.indexOf('\n');
78
+ if (lf >= 0)
79
+ line = line.slice(0, lf);
80
+ if (line.endsWith('\r'))
81
+ line = line.slice(0, -1);
82
+ //Fields are colon-separated; the first field is "<server-port> , <client-port>".
83
+ const parts = line.split(':');
84
+ const ports = (parts[0] ? parts[0] : '').split(',');
85
+ const serverPort = _a.#clampPort(ports[0]);
86
+ const clientPort = _a.#clampPort(ports[1]);
87
+ this.instance.serverPort.setValue(serverPort);
88
+ this.instance.clientPort.setValue(clientPort);
89
+ if (parts.length <= 1) {
90
+ //A query carries only the two ports (no ":" reply structure).
91
+ this.instance.isQuery.setValue(true);
92
+ this.instance.responseType.setValue('');
93
+ this.instance.opsys.setValue('');
94
+ this.instance.userId.setValue('');
95
+ this.instance.errorType.setValue('');
96
+ this.instance.summaryInfo.setValue(`query ${serverPort},${clientPort}`);
97
+ return;
98
+ }
99
+ this.instance.isQuery.setValue(false);
100
+ const responseType = (parts[1] ? parts[1] : '').trim();
101
+ this.instance.responseType.setValue(responseType);
102
+ if (responseType === 'USERID') {
103
+ //USERID : <opsys>[, <charset>] : <username> — the username is the remainder (it MAY itself
104
+ //contain ':'), so rejoin the trailing fields rather than taking a single token.
105
+ const opsys = (parts[2] ? parts[2] : '').trim();
106
+ const userId = parts.length > 3 ? parts.slice(3).join(':').trim() : '';
107
+ this.instance.opsys.setValue(opsys);
108
+ this.instance.userId.setValue(userId);
109
+ this.instance.errorType.setValue('');
110
+ this.instance.summaryInfo.setValue(`USERID ${userId}`);
111
+ return;
112
+ }
113
+ if (responseType === 'ERROR') {
114
+ const errorType = parts.length > 2 ? parts.slice(2).join(':').trim() : '';
115
+ this.instance.opsys.setValue('');
116
+ this.instance.userId.setValue('');
117
+ this.instance.errorType.setValue(errorType);
118
+ this.instance.summaryInfo.setValue(`ERROR ${errorType}`);
119
+ return;
120
+ }
121
+ //An unknown reply type is still a reply — keep its ports and label, drop the type-specific fields.
122
+ this.instance.opsys.setValue('');
123
+ this.instance.userId.setValue('');
124
+ this.instance.errorType.setValue('');
125
+ this.instance.summaryInfo.setValue(responseType ? responseType : `${serverPort},${clientPort}`);
126
+ }
127
+ static #buildSchema() {
128
+ return {
129
+ type: 'object',
130
+ summary: 'Ident ${summaryInfo}',
131
+ properties: {
132
+ //Display-only metadata parsed from the first line on decode (no encode — populated by the
133
+ //`message` field below, never read back). isQuery distinguishes the client query from the
134
+ //server reply; responseType/opsys/userId apply to a USERID reply, errorType to an ERROR
135
+ //reply. The two ports are present in both directions.
136
+ serverPort: { type: 'integer', label: 'Server Port', minimum: 0, maximum: 65535, default: 0 },
137
+ clientPort: { type: 'integer', label: 'Client Port', minimum: 0, maximum: 65535, default: 0 },
138
+ isQuery: { type: 'boolean', label: 'Is Query', default: false },
139
+ responseType: { type: 'string', label: 'Response Type', default: '' },
140
+ opsys: { type: 'string', label: 'Operating System', default: '' },
141
+ userId: { type: 'string', label: 'User ID', default: '' },
142
+ errorType: { type: 'string', label: 'Error Type', default: '' },
143
+ //Drives the one-line summary (query ports / USERID username / ERROR error-type).
144
+ summaryInfo: { type: 'string', label: 'Summary', hidden: true, default: '' },
145
+ //The whole raw payload is the single source of truth: decoded verbatim to hex and
146
+ //re-emitted untouched (byte-perfect for any Ident payload). The first line is parsed into
147
+ //the display-only metadata above, which carry no codec of their own.
148
+ message: {
149
+ type: 'string',
150
+ label: 'Message',
151
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
152
+ default: '',
153
+ decode: function () {
154
+ const available = this.#payloadLength();
155
+ if (available <= 0) {
156
+ this.instance.message.setValue('');
157
+ this.#parse('');
158
+ return;
159
+ }
160
+ const raw = this.readBytes(0, available);
161
+ this.instance.message.setValue((0, BufferToHex_1.BufferToHex)(raw));
162
+ this.#parse(raw.toString('latin1'));
163
+ },
164
+ encode: function () {
165
+ //Re-emit the authoritative payload verbatim — never reconstruct from metadata.
166
+ this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(this.instance.message.getValue('')));
167
+ }
168
+ }
169
+ }
170
+ };
171
+ }
172
+ match() {
173
+ //Reached only on the tcp:113 bucket. Port 113 IS Ident's, so any non-empty payload over TCP is
174
+ //claimed and kept verbatim (byte-perfect) — deliberately without a printable-text gate, so a
175
+ //server reply body is never wrongly dropped to raw. An empty payload (a bare ACK) is not claimed.
176
+ if (!this.prevCodecModule)
177
+ return false;
178
+ if (this.prevCodecModule.id !== 'tcp')
179
+ return false;
180
+ return this.#payloadLength() >= 1;
181
+ }
182
+ }
183
+ exports.Ident = Ident;
184
+ _a = Ident;
@@ -0,0 +1,30 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * KNXnet/IP (KNX over IP, ISO/IEC 14543-3, KNX Association 03/03/02), UDP port 3671 — the IP transport
6
+ * of the KNX building-automation bus (tunnelling KNX telegrams over IP and routing them between KNXnet/IP
7
+ * routers). Every KNXnet/IP frame begins with a fixed 6-byte header — Header Length (always 0x06 for the
8
+ * current spec), Protocol Version (0x10 = 1.0), a 2-byte Service Type Identifier and a 2-byte Total Length
9
+ * (the whole frame octet count INCLUDING this 6-byte header) — followed by the service-specific body.
10
+ *
11
+ * Common Service Type Identifiers: 0x0201 SEARCH_REQUEST, 0x0202 SEARCH_RESPONSE, 0x0205 CONNECT_REQUEST,
12
+ * 0x0420 TUNNELLING_REQUEST, 0x0530 ROUTING_INDICATION.
13
+ *
14
+ * The body layout differs per service type (HPAI discovery endpoints, connection headers, cEMI frames)
15
+ * and several sub-structures need connection/service context, so this single-frame codec keeps the body
16
+ * verbatim as `body` hex (byte-perfect) and does not sub-decode it. The Total Length is auto-computed from
17
+ * the body on encode when not supplied, else honored verbatim (a crafted frame may lie); the frame is
18
+ * bounded by Total Length (and the enclosing UDP payload) so trailing bytes are left to the codec's
19
+ * recursion / RawData. A well-formed frame round-trips byte-for-byte.
20
+ */
21
+ export declare class KNXnetIP extends BaseHeader {
22
+ #private;
23
+ get SCHEMA(): ProtocolJSONSchema;
24
+ readonly id: string;
25
+ readonly name: string;
26
+ readonly nickname: string;
27
+ readonly matchKeys: string[];
28
+ match(): boolean;
29
+ readonly demuxProducers: DemuxProducer[];
30
+ }