@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,217 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RTCP = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ const BufferToHex_1 = require("../helper/BufferToHex");
6
+ const HexToBuffer_1 = require("../helper/HexToBuffer");
7
+ const BufferToNumber_1 = require("../helper/BufferToNumber");
8
+ const NumberToBuffer_1 = require("../helper/NumberToBuffer");
9
+ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
10
+ /**
11
+ * RTCP — RTP Control Protocol (RFC 3550 §6), the companion control channel to RTP. Rides UDP on
12
+ * dynamically negotiated ports (classically the RTP media port + 1, or multiplexed onto the media port
13
+ * with rtcp-mux, RFC 5761), so there is no fixed well-known port; a small set of common defaults is
14
+ * declared as matchKeys and selection stays strictly port-bucketed (see match()).
15
+ *
16
+ * Every RTCP packet begins with a 4-byte common header — Version (2 bits, always 2), Padding (1 bit),
17
+ * a 5-bit count whose meaning is packet-type-specific (Reception Report Count for SR/RR, Source Count
18
+ * for SDES/BYE), an 8-bit Packet Type (200 SR, 201 RR, 202 SDES, 203 BYE, 204 APP, 205 RTPFB, 206
19
+ * PSFB, 207 XR) and a 16-bit Length in 32-bit words minus one (RFC 3550 §6.4.1) — and, for the
20
+ * report-bearing types, an SSRC of the sender. RTCP packets are transmitted as COMPOUND packets:
21
+ * several stacked back-to-back in a single UDP datagram (RFC 3550 §6.1).
22
+ *
23
+ * This minimal codec structures the FIRST packet's common header (version/padding/count/packetType/
24
+ * length) plus its SSRC, then keeps that first packet's remaining body verbatim as `body` hex (bounded
25
+ * by the Length field — packet-type-specific decoding of SR sender info / report blocks / SDES chunks
26
+ * is a later enrichment), and keeps any further compound packets verbatim as `rest` hex (bounded by
27
+ * the UDP payload). The Length is honored when supplied (a crafted packet may lie) else derived from
28
+ * the body; every field is width-clamped so a decoded value always re-encodes. A well-formed datagram
29
+ * round-trips byte-for-byte.
30
+ */
31
+ class RTCP extends BaseHeader_1.BaseHeader {
32
+ constructor() {
33
+ super(...arguments);
34
+ this.id = 'rtcp';
35
+ this.name = 'RTP Control Protocol';
36
+ this.nickname = 'RTCP';
37
+ //RTCP uses dynamically negotiated UDP ports with no fixed well-known port. Like RTP, the common
38
+ //defaults are declared as port buckets and selection stays STRICTLY port-bucketed — heuristicFallback
39
+ //is deliberately NOT set, because Version==2 + a Packet Type in 200-207 is a weak signature that
40
+ //would falsely claim unrelated UDP traffic if run over every datagram. Recognition on other ports is
41
+ //a "decode as" concern, mirroring RTP.
42
+ this.matchKeys = ['udpport:5005', 'udpport:5007', 'udpport:5009'];
43
+ //A leaf header — packet-type-specific body and stacked compound packets are kept verbatim.
44
+ this.demuxProducers = [];
45
+ }
46
+ static #schemaCache;
47
+ get SCHEMA() {
48
+ return (RTCP.#schemaCache ??= RTCP.#buildSchema());
49
+ }
50
+ static #buildSchema() {
51
+ return {
52
+ type: 'object',
53
+ summary: 'RTCP pt=${packetType} len=${length}',
54
+ properties: {
55
+ //Byte 0 packs Version (bits 0-1), Padding (bit 2) and a 5-bit count (bits 3-7). Each is a
56
+ //separate field over the same octet window; writeBits read-modify-writes so sequential
57
+ //encode of the three composes byte 0 correctly.
58
+ version: {
59
+ type: 'integer',
60
+ label: 'Version',
61
+ minimum: 0,
62
+ maximum: 3,
63
+ decode: function () {
64
+ this.instance.version.setValue(this.readBits(0, 1, 0, 2));
65
+ },
66
+ encode: function () {
67
+ const node = this.instance.version;
68
+ let value = node.getValue(2, (nodePath) => this.recordError(nodePath, 'Not Found'));
69
+ if (value > 3)
70
+ value = 3;
71
+ if (value < 0)
72
+ value = 0;
73
+ node.setValue(value);
74
+ this.writeBits(0, 1, 0, 2, value);
75
+ }
76
+ },
77
+ //Padding flag: when set, the packet ends with padding octets whose last byte is the pad
78
+ //count (RFC 3550 §6.4.1). The padding bytes themselves live inside `body`/`rest` verbatim.
79
+ padding: {
80
+ type: 'integer',
81
+ label: 'Padding',
82
+ minimum: 0,
83
+ maximum: 1,
84
+ decode: function () {
85
+ this.instance.padding.setValue(this.readBits(0, 1, 2, 1));
86
+ },
87
+ encode: function () {
88
+ const node = this.instance.padding;
89
+ let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
90
+ if (value > 1)
91
+ value = 1;
92
+ if (value < 0)
93
+ value = 0;
94
+ node.setValue(value);
95
+ this.writeBits(0, 1, 2, 1, value);
96
+ }
97
+ },
98
+ //5-bit count: Reception Report Count (SR/RR) or Source Count (SDES/BYE), packet-type
99
+ //dependent. Kept as a plain integer; its per-type semantics are UI enrichment for later.
100
+ reportCount: {
101
+ type: 'integer',
102
+ label: 'Report/Source Count',
103
+ minimum: 0,
104
+ maximum: 31,
105
+ decode: function () {
106
+ this.instance.reportCount.setValue(this.readBits(0, 1, 3, 5));
107
+ },
108
+ encode: function () {
109
+ const node = this.instance.reportCount;
110
+ let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
111
+ if (value > 31)
112
+ value = 31;
113
+ if (value < 0)
114
+ value = 0;
115
+ node.setValue(value);
116
+ this.writeBits(0, 1, 3, 5, value);
117
+ }
118
+ },
119
+ //Packet Type (200 SR .. 207 XR). A plain uint8 — no hard enum, so an unknown/future type
120
+ //still decodes and re-encodes (never-throws).
121
+ packetType: this.fieldUInt('packetType', 1, 1, 'Packet Type'),
122
+ length: {
123
+ type: 'integer',
124
+ label: 'Length',
125
+ minimum: 0,
126
+ maximum: 65535,
127
+ decode: function () {
128
+ this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
129
+ },
130
+ encode: function () {
131
+ //Length = 32-bit words of the first packet minus one (RFC 3550 §6.4.1). The first
132
+ //packet is the 8-byte header+SSRC plus `body`. Honored when supplied (a crafted
133
+ //packet may lie); else derived from the body length.
134
+ const provided = this.instance.length.getValue();
135
+ let value = (provided !== undefined && provided !== null)
136
+ ? provided
137
+ : Math.floor((8 + (0, HexToBuffer_1.HexToBuffer)(this.instance.body.getValue('')).length) / 4) - 1;
138
+ if (value < 0)
139
+ value = 0;
140
+ if (value > 65535) {
141
+ this.recordError(this.instance.length.getPath(), 'Maximum value is 65535');
142
+ value = 65535;
143
+ }
144
+ this.instance.length.setValue(value);
145
+ this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(value));
146
+ }
147
+ },
148
+ //SSRC of the sender (SR/RR/report-bearing types). Kept verbatim as hex — an identifier the
149
+ //editor round-trips untouched, no endian ambiguity.
150
+ ssrc: this.fieldHex('ssrc', 4, 4, 'SSRC'),
151
+ //The first RTCP packet's remaining body after the 8-byte header+SSRC: SR sender info,
152
+ //report blocks, SDES chunks, etc. Bounded by the Length field (the first packet ends at
153
+ //(Length+1)*4 bytes) and the captured bytes, so trailing compound packets are NOT swallowed.
154
+ body: {
155
+ type: 'string',
156
+ label: 'Body',
157
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
158
+ decode: function () {
159
+ const available = this.packet.length - this.startPos;
160
+ let firstEnd = (this.instance.length.getValue(0) + 1) * 4;
161
+ if (firstEnd < 8)
162
+ firstEnd = 8;
163
+ if (firstEnd > available)
164
+ firstEnd = available;
165
+ this.instance.body.setValue(firstEnd > 8 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(8, firstEnd - 8)) : '');
166
+ },
167
+ encode: function () {
168
+ const body = this.instance.body.getValue('');
169
+ if (body)
170
+ this.writeBytes(8, (0, HexToBuffer_1.HexToBuffer)(body));
171
+ }
172
+ },
173
+ //Any further packets in the compound RTCP datagram (RFC 3550 §6.1), kept verbatim. Starts
174
+ //where the first packet ends ((Length+1)*4) and runs to the end of the UDP payload; a leaf
175
+ //field, sub-decoding each stacked packet is a later enrichment.
176
+ rest: {
177
+ type: 'string',
178
+ label: 'Compound Remainder',
179
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
180
+ decode: function () {
181
+ const available = this.packet.length - this.startPos;
182
+ let firstEnd = (this.instance.length.getValue(0) + 1) * 4;
183
+ if (firstEnd < 8)
184
+ firstEnd = 8;
185
+ if (firstEnd > available)
186
+ firstEnd = available;
187
+ this.instance.rest.setValue(available > firstEnd ? (0, BufferToHex_1.BufferToHex)(this.readBytes(firstEnd, available - firstEnd)) : '');
188
+ },
189
+ encode: function () {
190
+ const rest = this.instance.rest.getValue('');
191
+ if (!rest)
192
+ return;
193
+ let firstEnd = (this.instance.length.getValue(0) + 1) * 4;
194
+ if (firstEnd < 8)
195
+ firstEnd = 8;
196
+ this.writeBytes(firstEnd, (0, HexToBuffer_1.HexToBuffer)(rest));
197
+ }
198
+ }
199
+ }
200
+ };
201
+ }
202
+ match() {
203
+ //Only ever consulted for the declared UDP port buckets (no heuristic fallback). Within a bucket,
204
+ //guard on the two-bit Version (must be 2) and a Packet Type in the RTCP range 200-207 (RFC 3550,
205
+ //RFC 4585/4587) so non-RTCP traffic on these ports falls through to raw.
206
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'udp')
207
+ return false;
208
+ if (this.packet.length - this.startPos < 8)
209
+ return false;
210
+ const version = (this.readBytes(0, 1, true)[0] >> 6) & 0x03;
211
+ if (version !== 2)
212
+ return false;
213
+ const packetType = this.readBytes(1, 1, true)[0];
214
+ return packetType >= 200 && packetType <= 207;
215
+ }
216
+ }
217
+ exports.RTCP = RTCP;
@@ -0,0 +1,33 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * RTP — Real-time Transport Protocol (RFC 3550), carried over UDP on application-negotiated (SDP)
6
+ * dynamic ports. The 12-byte fixed header is: byte 0 = Version(2 bits, always 2) + Padding(P) +
7
+ * Extension(X) + CSRC Count(CC, 4 bits); byte 1 = Marker(M) + Payload Type(PT, 7 bits); then a 16-bit
8
+ * Sequence Number, a 32-bit Timestamp and a 32-bit SSRC. It is followed by CC × 4-byte CSRC identifiers,
9
+ * an optional header extension (present when X=1: a 16-bit profile id + a 16-bit length in 32-bit words +
10
+ * length×4 bytes of data), and the media payload.
11
+ *
12
+ * ⚠️ RTP has no in-band magic — its only signature is the 2-bit Version field (==2), far too weak to
13
+ * heuristically claim arbitrary UDP traffic (that would swallow every UDP flow). So this codec is
14
+ * port-bucketed ONLY (the common RTP/AVP default even ports 5004/5006/5008) with NO heuristicFallback,
15
+ * and its match() still requires Version==2 and the full 12-byte header. Real deployments negotiate the
16
+ * port via SDP, so an editor should offer an explicit decode-as for other ports rather than any guess.
17
+ *
18
+ * The CSRC list, optional extension and payload are parsed generically (identifiers/extension data kept
19
+ * verbatim as hex, payload bounded by the UDP datagram so a retained FCS/padding is not absorbed). The
20
+ * CSRC Count is honored-else-derived from the CSRC list; the extension length is honored-else-derived
21
+ * from the extension data byte length; the payload-type-specific media bytes are a leaf (not sub-decoded).
22
+ * A well-formed packet round-trips byte-for-byte.
23
+ */
24
+ export declare class RTP extends BaseHeader {
25
+ #private;
26
+ get SCHEMA(): ProtocolJSONSchema;
27
+ readonly id: string;
28
+ readonly name: string;
29
+ readonly nickname: string;
30
+ readonly matchKeys: string[];
31
+ match(): boolean;
32
+ readonly demuxProducers: DemuxProducer[];
33
+ }
@@ -0,0 +1,291 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RTP = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ const BufferToHex_1 = require("../helper/BufferToHex");
6
+ const HexToBuffer_1 = require("../helper/HexToBuffer");
7
+ const BufferToNumber_1 = require("../helper/BufferToNumber");
8
+ const NumberToBuffer_1 = require("../helper/NumberToBuffer");
9
+ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
10
+ /**
11
+ * RTP — Real-time Transport Protocol (RFC 3550), carried over UDP on application-negotiated (SDP)
12
+ * dynamic ports. The 12-byte fixed header is: byte 0 = Version(2 bits, always 2) + Padding(P) +
13
+ * Extension(X) + CSRC Count(CC, 4 bits); byte 1 = Marker(M) + Payload Type(PT, 7 bits); then a 16-bit
14
+ * Sequence Number, a 32-bit Timestamp and a 32-bit SSRC. It is followed by CC × 4-byte CSRC identifiers,
15
+ * an optional header extension (present when X=1: a 16-bit profile id + a 16-bit length in 32-bit words +
16
+ * length×4 bytes of data), and the media payload.
17
+ *
18
+ * ⚠️ RTP has no in-band magic — its only signature is the 2-bit Version field (==2), far too weak to
19
+ * heuristically claim arbitrary UDP traffic (that would swallow every UDP flow). So this codec is
20
+ * port-bucketed ONLY (the common RTP/AVP default even ports 5004/5006/5008) with NO heuristicFallback,
21
+ * and its match() still requires Version==2 and the full 12-byte header. Real deployments negotiate the
22
+ * port via SDP, so an editor should offer an explicit decode-as for other ports rather than any guess.
23
+ *
24
+ * The CSRC list, optional extension and payload are parsed generically (identifiers/extension data kept
25
+ * verbatim as hex, payload bounded by the UDP datagram so a retained FCS/padding is not absorbed). The
26
+ * CSRC Count is honored-else-derived from the CSRC list; the extension length is honored-else-derived
27
+ * from the extension data byte length; the payload-type-specific media bytes are a leaf (not sub-decoded).
28
+ * A well-formed packet round-trips byte-for-byte.
29
+ */
30
+ class RTP extends BaseHeader_1.BaseHeader {
31
+ constructor() {
32
+ super(...arguments);
33
+ this.id = 'rtp';
34
+ this.name = 'Real-time Transport Protocol';
35
+ this.nickname = 'RTP';
36
+ //RTP/AVP common default even ports only. RTP has no reliable content magic (Version==2 is a 2-bit
37
+ //signature), so it is NEVER placed in the heuristic fallback list — matching arbitrary UDP traffic
38
+ //would swallow every UDP flow. Real ports are negotiated by SDP; an editor should decode-as for them.
39
+ this.matchKeys = ['udpport:5004', 'udpport:5006', 'udpport:5008'];
40
+ //A leaf header — payload-type (codec) specific media de-structuring is deferred to a later slice.
41
+ this.demuxProducers = [];
42
+ }
43
+ static #schemaCache;
44
+ get SCHEMA() {
45
+ return (RTP.#schemaCache ??= RTP.#buildSchema());
46
+ }
47
+ /**
48
+ * The RTP length (fixed header + CSRC + extension + payload) bounded by the enclosing UDP datagram,
49
+ * so a lying CC/extension length near the end does not read into a retained FCS/padding. Bounds the
50
+ * field reads and the match gate.
51
+ */
52
+ #available() {
53
+ let available = this.packet.length - this.startPos;
54
+ if (this.prevCodecModule && this.prevCodecModule.id === 'udp') {
55
+ const udpLength = this.prevCodecModule.instance.length.getValue(0);
56
+ if (udpLength >= 8 && udpLength - 8 < available)
57
+ available = udpLength - 8;
58
+ }
59
+ return available < 0 ? 0 : available;
60
+ }
61
+ /** A fixed-width big-endian unsigned bit field within one octet at `byteOffset` (bitOffset 0 = MSB). */
62
+ static #uintBits(name, byteOffset, bitOffset, bitLength, label) {
63
+ const maximum = (2 ** bitLength) - 1;
64
+ return {
65
+ type: 'integer',
66
+ label: label,
67
+ minimum: 0,
68
+ maximum: maximum,
69
+ decode: function () {
70
+ this.instance[name].setValue(this.readBits(byteOffset, 1, bitOffset, bitLength));
71
+ },
72
+ encode: function () {
73
+ const node = this.instance[name];
74
+ let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
75
+ if (value > maximum) {
76
+ this.recordError(node.getPath(), `Maximum value is ${maximum}`);
77
+ value = maximum;
78
+ }
79
+ if (value < 0) {
80
+ this.recordError(node.getPath(), 'Minimum value is 0');
81
+ value = 0;
82
+ }
83
+ node.setValue(value);
84
+ this.writeBits(byteOffset, 1, bitOffset, bitLength, value);
85
+ }
86
+ };
87
+ }
88
+ /** A single flag bit within one octet at `byteOffset` (bitOffset 0 = MSB). */
89
+ static #flagBit(name, byteOffset, bitOffset, label) {
90
+ return {
91
+ type: 'boolean',
92
+ label: label,
93
+ decode: function () {
94
+ this.instance[name].setValue(!!this.readBits(byteOffset, 1, bitOffset, 1));
95
+ },
96
+ encode: function () {
97
+ const value = !!this.instance[name].getValue();
98
+ this.instance[name].setValue(value);
99
+ this.writeBits(byteOffset, 1, bitOffset, 1, value ? 1 : 0);
100
+ }
101
+ };
102
+ }
103
+ static #buildSchema() {
104
+ return {
105
+ type: 'object',
106
+ summary: 'RTP pt=${payloadType} seq=${sequenceNumber} ssrc=${ssrc}',
107
+ properties: {
108
+ //Byte 0 (MSB first): Version(0-1) Padding(2) Extension(3) CSRC Count(4-7).
109
+ version: this.#uintBits('version', 0, 0, 2, 'Version'),
110
+ padding: this.#flagBit('padding', 0, 2, 'Padding'),
111
+ extension: this.#flagBit('extension', 0, 3, 'Extension'),
112
+ //CSRC Count: the number of 4-byte CSRC identifiers. Honored when supplied (a crafted
113
+ //packet may lie), else derived from the CSRC list length; written into byte 0 bits 4-7.
114
+ csrcCount: {
115
+ type: 'integer',
116
+ label: 'CSRC Count',
117
+ minimum: 0,
118
+ maximum: 15,
119
+ decode: function () {
120
+ this.instance.csrcCount.setValue(this.readBits(0, 1, 4, 4));
121
+ },
122
+ encode: function () {
123
+ const provided = this.instance.csrcCount.getValue();
124
+ const csrc = this.instance.csrc.getValue();
125
+ let value = (provided !== undefined && provided !== null)
126
+ ? provided
127
+ : (Array.isArray(csrc) ? csrc.length : 0);
128
+ if (value > 15) {
129
+ this.recordError(this.instance.csrcCount.getPath(), 'Maximum value is 15');
130
+ value = 15;
131
+ }
132
+ if (value < 0)
133
+ value = 0;
134
+ this.instance.csrcCount.setValue(value);
135
+ this.writeBits(0, 1, 4, 4, value);
136
+ }
137
+ },
138
+ //Byte 1 (MSB first): Marker(0) Payload Type(1-7).
139
+ marker: this.#flagBit('marker', 1, 0, 'Marker'),
140
+ payloadType: this.#uintBits('payloadType', 1, 1, 7, 'Payload Type'),
141
+ sequenceNumber: this.fieldUInt('sequenceNumber', 2, 2, 'Sequence Number'),
142
+ timestamp: this.fieldUInt('timestamp', 4, 4, 'Timestamp'),
143
+ ssrc: this.fieldUInt('ssrc', 8, 4, 'SSRC'),
144
+ //CC × 4-byte contributing-source identifiers, kept verbatim as hex. Populated by the
145
+ //master `body` field (offsets depend on the CC count decoded above).
146
+ csrc: {
147
+ type: 'array',
148
+ label: 'CSRC List',
149
+ items: {
150
+ type: 'string',
151
+ label: 'CSRC',
152
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX
153
+ }
154
+ },
155
+ //Optional header extension (RFC 3550 §5.3.1), present only when the Extension (X) flag is
156
+ //set: a 16-bit profile id, a 16-bit length in 32-bit words, then length×4 bytes of data.
157
+ //Populated by the master `body` field.
158
+ extensionHeader: {
159
+ type: 'object',
160
+ label: 'Header Extension',
161
+ properties: {
162
+ profile: { type: 'integer', label: 'Profile', minimum: 0, maximum: 65535 },
163
+ length: { type: 'integer', label: 'Length (32-bit words)', minimum: 0, maximum: 65535 },
164
+ data: { type: 'string', label: 'Data', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
165
+ }
166
+ },
167
+ //The media payload, kept verbatim as hex, bounded by the UDP datagram. Payload-type
168
+ //(codec) specific de-structuring is a leaf — not sub-decoded here.
169
+ payload: {
170
+ type: 'string',
171
+ label: 'Payload',
172
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX
173
+ },
174
+ //Master field: the CSRC list, optional extension and payload have flag/count-dependent
175
+ //offsets, so they are parsed/emitted together here (runs after the fixed fields — property
176
+ //order). Hidden: it carries no value of its own, only drives the variable-length tail.
177
+ body: {
178
+ type: 'string',
179
+ label: 'Body',
180
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
181
+ hidden: true,
182
+ decode: function () {
183
+ const available = this.#available();
184
+ //CSRC count clamped to the spec's 0-15 AND to the bytes actually present, so a
185
+ //lying count cannot spawn phantom identifiers past the datagram end.
186
+ let count = this.instance.csrcCount.getValue(0);
187
+ if (count < 0)
188
+ count = 0;
189
+ if (count > 15)
190
+ count = 15;
191
+ if (12 + count * 4 > available)
192
+ count = Math.floor((available - 12) / 4);
193
+ if (count < 0)
194
+ count = 0;
195
+ let offset = 12;
196
+ const csrc = [];
197
+ for (let i = 0; i < count; i++) {
198
+ csrc.push((0, BufferToHex_1.BufferToHex)(this.readBytes(offset, 4)));
199
+ offset += 4;
200
+ }
201
+ this.instance.csrc.setValue(csrc);
202
+ const hasExtension = !!this.instance.extension.getValue();
203
+ if (hasExtension && offset + 4 <= available) {
204
+ const profile = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset, 2));
205
+ const words = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset + 2, 2));
206
+ offset += 4;
207
+ let dataBytes = words * 4;
208
+ if (offset + dataBytes > available)
209
+ dataBytes = available - offset;
210
+ if (dataBytes < 0)
211
+ dataBytes = 0;
212
+ const data = dataBytes > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset, dataBytes)) : '';
213
+ offset += dataBytes;
214
+ this.instance.extensionHeader.profile.setValue(profile);
215
+ this.instance.extensionHeader.length.setValue(words);
216
+ this.instance.extensionHeader.data.setValue(data);
217
+ }
218
+ const payloadBytes = available - offset > 0 ? available - offset : 0;
219
+ this.instance.payload.setValue(payloadBytes > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset, payloadBytes)) : '');
220
+ },
221
+ encode: function () {
222
+ let offset = 12;
223
+ const csrc = this.instance.csrc.getValue();
224
+ if (Array.isArray(csrc)) {
225
+ csrc.forEach((entry) => {
226
+ //Normalize each identifier to exactly 4 bytes so the tail stays aligned
227
+ //(a decoded entry is 8 hex chars → copied whole; a crafted one is padded/
228
+ //truncated).
229
+ const source = (0, HexToBuffer_1.HexToBuffer)(typeof entry === 'string' && entry ? entry : '00000000');
230
+ const four = Buffer.alloc(4);
231
+ source.copy(four, 0, 0, 4);
232
+ this.writeBytes(offset, four);
233
+ offset += 4;
234
+ });
235
+ }
236
+ //Emit the extension only when the X flag is set AND an extension header was
237
+ //actually captured on decode. A malformed packet with X=1 but too few trailing
238
+ //bytes decodes without an extensionHeader (the decode gates on availability); if
239
+ //encode emitted one solely from the X bit it would synthesize 4 zero bytes the
240
+ //wire never had, breaking byte-perfect. Honoring the captured extension keeps them
241
+ //symmetric.
242
+ const extHeader = this.instance.extensionHeader.getValue();
243
+ const hasExtension = !!this.instance.extension.getValue() && extHeader !== undefined && extHeader !== null;
244
+ if (hasExtension) {
245
+ let profile = this.instance.extensionHeader.profile.getValue(0);
246
+ if (profile > 65535)
247
+ profile = 65535;
248
+ if (profile < 0)
249
+ profile = 0;
250
+ const data = this.instance.extensionHeader.data.getValue('');
251
+ const dataBuffer = (0, HexToBuffer_1.HexToBuffer)(data);
252
+ //Length honored when supplied (a crafted packet may lie), else derived from
253
+ //the data byte length (in 32-bit words).
254
+ const providedLength = this.instance.extensionHeader.length.getValue();
255
+ let words = (providedLength !== undefined && providedLength !== null)
256
+ ? providedLength
257
+ : Math.ceil(dataBuffer.length / 4);
258
+ if (words > 65535)
259
+ words = 65535;
260
+ if (words < 0)
261
+ words = 0;
262
+ this.instance.extensionHeader.profile.setValue(profile);
263
+ this.instance.extensionHeader.length.setValue(words);
264
+ this.writeBytes(offset, (0, NumberToBuffer_1.UInt16ToBuffer)(profile));
265
+ this.writeBytes(offset + 2, (0, NumberToBuffer_1.UInt16ToBuffer)(words));
266
+ offset += 4;
267
+ if (dataBuffer.length) {
268
+ this.writeBytes(offset, dataBuffer);
269
+ offset += dataBuffer.length;
270
+ }
271
+ }
272
+ const payload = this.instance.payload.getValue('');
273
+ if (payload)
274
+ this.writeBytes(offset, (0, HexToBuffer_1.HexToBuffer)(payload));
275
+ }
276
+ }
277
+ }
278
+ };
279
+ }
280
+ match() {
281
+ //RTP rides on UDP (one of the default RTP/AVP ports). Require the full 12-byte fixed header within
282
+ //the datagram and the Version==2 signature (bits 7:6 of byte 0) so a non-RTP datagram on the port
283
+ //falls through to raw rather than claiming an un-decodable layer.
284
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'udp')
285
+ return false;
286
+ if (this.#available() < 12)
287
+ return false;
288
+ return this.readBits(0, 1, 0, 2) === 2;
289
+ }
290
+ }
291
+ exports.RTP = RTP;
@@ -0,0 +1,33 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * RTPS — the OMG DDSI-RTPS wire protocol (Real-Time Publish-Subscribe) that carries DDS traffic for
6
+ * industrial IoT / robotics. It rides UDP on dynamically negotiated ports (the well-known 7400-range
7
+ * discovery ports are only defaults), so selection is by content signature, not port: every RTPS
8
+ * message opens with a 20-byte header — the 4-byte magic 'RTPS' (0x52545053), a 2-byte protocol
9
+ * version, a 2-byte vendorId, and a 12-byte guidPrefix — followed by a sequence of submessages.
10
+ *
11
+ * Each submessage is a 4-byte submessage header — submessageId(1), flags(1), submessageLength(2) —
12
+ * then `submessageLength` body octets. The single most important quirk: the low bit of the flags octet
13
+ * is the EndiannessFlag, and it governs the byte order of THAT submessage's submessageLength field
14
+ * (little-endian when set, big-endian when clear). A submessageLength of 0 is legal for the final
15
+ * submessage and means "the rest of the message"; it is honored verbatim so the frame round-trips.
16
+ *
17
+ * The submessage bodies (DATA's serialized payload, ACKNACK bitmaps, INFO_TS timestamps, …) are cross-
18
+ * message, QoS- and type-dependent state, so they are kept verbatim as hex (byte-perfect) rather than
19
+ * sub-decoded. The whole message is bounded by the UDP payload (the parent UDP Length when present),
20
+ * and every submessageLength is honored on encode (a crafted message may lie), else derived from the
21
+ * body. A well-formed message round-trips byte-for-byte.
22
+ */
23
+ export declare class RTPS 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
+ readonly heuristicFallback: boolean;
31
+ match(): boolean;
32
+ readonly demuxProducers: DemuxProducer[];
33
+ }