@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,203 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GTPU = 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
+ * GTP-U — GPRS Tunnelling Protocol, User plane (3GPP TS 29.281), UDP port 2152. The mandatory 8-byte
12
+ * header is a Flags byte (Version[3] / Protocol-Type / reserved / E / S / PN), a Message Type
13
+ * (0xFF = G-PDU carries a user IP packet), a 2-byte Length (everything after the 8-byte header), and a
14
+ * 4-byte TEID (Tunnel Endpoint Identifier). If any of E/S/PN is set, a 4-byte optional field
15
+ * (Sequence Number + N-PDU Number + Next-Extension-Header-Type) follows, then a chain of extension
16
+ * headers. For a G-PDU the payload after the header is a raw inner IP packet.
17
+ *
18
+ * The optional field + extension-header chain is kept verbatim (optionalHeader hex) so any GTP-U
19
+ * variant round-trips byte-for-byte; the inner IP packet is left to the codec's recursion (IPv4/IPv6
20
+ * accept a GTP-U tunnel parent, matching by IP version), decoding a fresh ip/… stack after the tunnel.
21
+ */
22
+ class GTPU extends BaseHeader_1.BaseHeader {
23
+ constructor() {
24
+ super(...arguments);
25
+ this.id = 'gtp';
26
+ this.name = 'GPRS Tunnelling Protocol, User plane';
27
+ this.nickname = 'GTP-U';
28
+ this.matchKeys = ['udpport:2152'];
29
+ //No child demux key; the inner IP packet is matched by IPv4/IPv6's tunnel-aware match() (which
30
+ //accepts a 'gtp' parent and matches by the IP version nibble), so recursion decodes the inner stack.
31
+ this.demuxProducers = [];
32
+ }
33
+ static #schemaCache;
34
+ get SCHEMA() {
35
+ return (GTPU.#schemaCache ??= GTPU.#buildSchema());
36
+ }
37
+ static #flagBit(name, bitOffset, label) {
38
+ return {
39
+ type: 'boolean',
40
+ label: label,
41
+ decode: function () {
42
+ this.instance.flags[name].setValue(!!this.readBits(0, 1, bitOffset, 1));
43
+ },
44
+ encode: function () {
45
+ const value = !!this.instance.flags[name].getValue();
46
+ this.instance.flags[name].setValue(value);
47
+ this.writeBits(0, 1, bitOffset, 1, value ? 1 : 0);
48
+ }
49
+ };
50
+ }
51
+ /** The payload length available for this GTP-U message, clamped by the UDP datagram. */
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
+ static #buildSchema() {
62
+ return {
63
+ type: 'object',
64
+ summary: 'GTP-U teid=${teid} type=${msgType}',
65
+ properties: {
66
+ //Flags byte (bit 0 = MSB): Version[0..2], PT[3], reserved[4], E[5], S[6], PN[7].
67
+ flags: {
68
+ type: 'object',
69
+ label: 'Flags',
70
+ properties: {
71
+ version: {
72
+ type: 'integer',
73
+ label: 'Version',
74
+ minimum: 0,
75
+ maximum: 7,
76
+ decode: function () { this.instance.flags.version.setValue(this.readBits(0, 1, 0, 3)); },
77
+ encode: function () { this.writeBits(0, 1, 0, 3, this.instance.flags.version.getValue(0)); }
78
+ },
79
+ pt: this.#flagBit('pt', 3, 'Protocol Type'),
80
+ e: this.#flagBit('e', 5, 'Extension Header Present'),
81
+ s: this.#flagBit('s', 6, 'Sequence Number Present'),
82
+ pn: this.#flagBit('pn', 7, 'N-PDU Number Present')
83
+ }
84
+ },
85
+ msgType: this.fieldUInt('msgType', 1, 1, 'Message Type'),
86
+ length: {
87
+ type: 'integer',
88
+ label: 'Length',
89
+ minimum: 0,
90
+ maximum: 65535,
91
+ decode: function () {
92
+ this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
93
+ },
94
+ encode: function () {
95
+ const length = this.instance.length.getValue();
96
+ if (length !== undefined && length !== null) {
97
+ this.instance.length.setValue(length);
98
+ this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(length));
99
+ }
100
+ else {
101
+ this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(0));
102
+ //GTP-U Length = every byte after the mandatory 8-byte header (optional field +
103
+ //extension headers + inner payload). Compute it after the whole packet encodes.
104
+ this.addPostPacketEncodeHandler(() => {
105
+ let started = false;
106
+ let total = 0;
107
+ this.codecModules.forEach((codecModule) => {
108
+ if (codecModule === this)
109
+ started = true;
110
+ if (started)
111
+ total += codecModule.length;
112
+ });
113
+ const value = total - 8 < 0 ? 0 : total - 8;
114
+ this.instance.length.setValue(value);
115
+ this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(value));
116
+ }, 1);
117
+ }
118
+ }
119
+ },
120
+ teid: this.fieldHex('teid', 4, 4, 'TEID'),
121
+ //Optional field (Sequence Number + N-PDU Number + Next Extension Header Type) and any
122
+ //extension-header chain, kept verbatim. Empty when E/S/PN are all clear.
123
+ optionalHeader: {
124
+ type: 'string',
125
+ label: 'Optional Header',
126
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
127
+ hidden: true,
128
+ decode: function () {
129
+ const e = !!this.instance.flags.e.getValue();
130
+ const s = !!this.instance.flags.s.getValue();
131
+ const pn = !!this.instance.flags.pn.getValue();
132
+ if (!e && !s && !pn) {
133
+ this.instance.optionalHeader.setValue('');
134
+ return;
135
+ }
136
+ const available = this.#available();
137
+ //4 optional bytes: Sequence Number(2) + N-PDU Number(1) + Next-Ext-Header-Type(1).
138
+ let optionalLength = 4;
139
+ if (e) {
140
+ //Walk the extension-header chain: each is length(1, in 4-octet units) + body +
141
+ //a trailing Next-Extension-Header-Type; a 0 type ends the chain.
142
+ let nextType = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(11, 1, true));
143
+ let offset = 12;
144
+ let guard = 0;
145
+ while (nextType !== 0 && offset < available && guard++ < 256) {
146
+ const units = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(offset, 1, true));
147
+ if (units === 0)
148
+ break;
149
+ const extBytes = units * 4;
150
+ if (offset + extBytes > available)
151
+ break;
152
+ nextType = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(offset + extBytes - 1, 1, true));
153
+ offset += extBytes;
154
+ }
155
+ optionalLength = offset - 8;
156
+ }
157
+ if (8 + optionalLength > available)
158
+ optionalLength = available - 8;
159
+ this.instance.optionalHeader.setValue(optionalLength > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(8, optionalLength)) : '');
160
+ },
161
+ encode: function () {
162
+ const optionalHeader = this.instance.optionalHeader.getValue('');
163
+ if (optionalHeader)
164
+ this.writeBytes(8, (0, HexToBuffer_1.HexToBuffer)(optionalHeader));
165
+ }
166
+ },
167
+ //Non-G-PDU messages (message type != 0xFF: Echo, Error Indication, End Marker, …) carry
168
+ //GTP Information Elements, NOT an inner IP packet. Consume them here so the codec's
169
+ //recursion has nothing left to (mis)interpret as inner IP by the version nibble. For a
170
+ //G-PDU (0xFF) this is empty and the header stops after the optional field, leaving the
171
+ //inner IP packet to be decoded recursively.
172
+ payload: {
173
+ type: 'string',
174
+ label: 'Payload',
175
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
176
+ hidden: true,
177
+ decode: function () {
178
+ const msgType = this.instance.msgType.getValue(0);
179
+ if (msgType === 0xff) {
180
+ this.instance.payload.setValue('');
181
+ return;
182
+ }
183
+ const available = this.#available();
184
+ const consumed = 8 + (0, HexToBuffer_1.HexToBuffer)(this.instance.optionalHeader.getValue('')).length;
185
+ this.instance.payload.setValue(consumed < available ? (0, BufferToHex_1.BufferToHex)(this.readBytes(consumed, available - consumed)) : '');
186
+ },
187
+ encode: function () {
188
+ const payload = this.instance.payload.getValue('');
189
+ if (payload) {
190
+ const consumed = 8 + (0, HexToBuffer_1.HexToBuffer)(this.instance.optionalHeader.getValue('')).length;
191
+ this.writeBytes(consumed, (0, HexToBuffer_1.HexToBuffer)(payload));
192
+ }
193
+ }
194
+ }
195
+ }
196
+ };
197
+ }
198
+ match() {
199
+ //Require the 8-byte mandatory header within the UDP payload (see RADIUS: bound by payload).
200
+ return !!this.prevCodecModule && this.prevCodecModule.id === 'udp' && this.#available() >= 8;
201
+ }
202
+ }
203
+ exports.GTPU = GTPU;
@@ -0,0 +1,30 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * GTPv2-C — GPRS Tunnelling Protocol version 2, Control plane (3GPP TS 29.274), UDP port 2123. The
6
+ * mandatory part is the first 4 octets: a Flags byte (Version[3] = 2, P = Piggybacking, T = TEID flag,
7
+ * then 3 spare bits), a Message Type (1 Echo Request, 2 Echo Response, 32 Create Session Request,
8
+ * 33 Create Session Response, …), and a 2-byte Message Length (the octet count of everything after
9
+ * these first 4 octets). When the T flag is set a 4-byte TEID follows; then a 3-byte Sequence Number
10
+ * and a 1-byte Spare are always present. The rest of the message is a flat list of Information Elements,
11
+ * each a 1-byte Type, a 2-byte Length (the value byte count), a byte carrying a 4-bit spare + 4-bit
12
+ * Instance, and Length value octets.
13
+ *
14
+ * IEs are carried generically (type + instance + verbatim hex value) so every IE — including grouped and
15
+ * vendor-specific ones whose value is opaque — round-trips byte-for-byte; per-IE semantic decoding is a
16
+ * later enrichment. The Message Length is honoured verbatim when supplied (a crafted message may lie),
17
+ * else derived from the actual TEID/Sequence/Spare/IE bytes. The IE walk is bounded by both the Message
18
+ * Length and the UDP datagram, so retained Ethernet padding / trailing bytes are not absorbed. A
19
+ * well-formed message round-trips byte-for-byte. GTPv2-C is a leaf — nothing rides on top of it.
20
+ */
21
+ export declare class GTPv2C 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
+ }
@@ -0,0 +1,281 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GTPv2C = 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
+ * GTPv2-C — GPRS Tunnelling Protocol version 2, Control plane (3GPP TS 29.274), UDP port 2123. The
12
+ * mandatory part is the first 4 octets: a Flags byte (Version[3] = 2, P = Piggybacking, T = TEID flag,
13
+ * then 3 spare bits), a Message Type (1 Echo Request, 2 Echo Response, 32 Create Session Request,
14
+ * 33 Create Session Response, …), and a 2-byte Message Length (the octet count of everything after
15
+ * these first 4 octets). When the T flag is set a 4-byte TEID follows; then a 3-byte Sequence Number
16
+ * and a 1-byte Spare are always present. The rest of the message is a flat list of Information Elements,
17
+ * each a 1-byte Type, a 2-byte Length (the value byte count), a byte carrying a 4-bit spare + 4-bit
18
+ * Instance, and Length value octets.
19
+ *
20
+ * IEs are carried generically (type + instance + verbatim hex value) so every IE — including grouped and
21
+ * vendor-specific ones whose value is opaque — round-trips byte-for-byte; per-IE semantic decoding is a
22
+ * later enrichment. The Message Length is honoured verbatim when supplied (a crafted message may lie),
23
+ * else derived from the actual TEID/Sequence/Spare/IE bytes. The IE walk is bounded by both the Message
24
+ * Length and the UDP datagram, so retained Ethernet padding / trailing bytes are not absorbed. A
25
+ * well-formed message round-trips byte-for-byte. GTPv2-C is a leaf — nothing rides on top of it.
26
+ */
27
+ class GTPv2C extends BaseHeader_1.BaseHeader {
28
+ constructor() {
29
+ super(...arguments);
30
+ this.id = 'gtpv2';
31
+ this.name = 'GPRS Tunnelling Protocol version 2, Control plane';
32
+ this.nickname = 'GTPv2-C';
33
+ this.matchKeys = ['udpport:2123'];
34
+ //A leaf header — the IE values are kept as verbatim hex, so nothing demuxes above GTPv2-C.
35
+ this.demuxProducers = [];
36
+ }
37
+ static #schemaCache;
38
+ get SCHEMA() {
39
+ return (GTPv2C.#schemaCache ??= GTPv2C.#buildSchema());
40
+ }
41
+ /** A single flag bit of the first byte (byte 0), MSB-first: bitOffset 3 = P, 4 = T. */
42
+ static #flagBit(name, bitOffset, label) {
43
+ return {
44
+ type: 'boolean',
45
+ label: label,
46
+ decode: function () {
47
+ this.instance.flags[name].setValue(!!this.readBits(0, 1, bitOffset, 1));
48
+ },
49
+ encode: function () {
50
+ const value = !!this.instance.flags[name].getValue();
51
+ this.instance.flags[name].setValue(value);
52
+ this.writeBits(0, 1, bitOffset, 1, value ? 1 : 0);
53
+ }
54
+ };
55
+ }
56
+ /** True when the T (TEID) flag is set — a 4-byte TEID then sits between the length field and the sequence number. */
57
+ #teidPresent() {
58
+ return !!this.instance.flags.teidFlag.getValue();
59
+ }
60
+ /** Header-relative offset of the 3-byte Sequence Number: after the 4 mandatory octets, +4 for the TEID when present. */
61
+ #sequenceOffset() {
62
+ return this.#teidPresent() ? 8 : 4;
63
+ }
64
+ /** The payload length available to this message, clamped by the UDP datagram (so padding/FCS is not absorbed). */
65
+ #available() {
66
+ let available = this.packet.length - this.startPos;
67
+ if (this.prevCodecModule && this.prevCodecModule.id === 'udp') {
68
+ const udpLength = this.prevCodecModule.instance.length.getValue(0);
69
+ if (udpLength >= 8 && udpLength - 8 < available)
70
+ available = udpLength - 8;
71
+ }
72
+ return available < 0 ? 0 : available;
73
+ }
74
+ /** Header-relative end offset of the IE list: 4 (mandatory) + Message Length, clamped down to the UDP payload. */
75
+ #messageEnd() {
76
+ let end = 4 + this.instance.messageLength.getValue(0);
77
+ const available = this.#available();
78
+ if (available && available < end)
79
+ end = available;
80
+ return end;
81
+ }
82
+ static #buildSchema() {
83
+ return {
84
+ type: 'object',
85
+ summary: 'GTPv2-C type=${messageType} seq=${sequenceNumber}',
86
+ properties: {
87
+ //Byte 0 (MSB-first): Version[0..2] (= 2), P[3] Piggybacking, T[4] TEID flag, spare[5..7].
88
+ flags: {
89
+ type: 'object',
90
+ label: 'Flags',
91
+ properties: {
92
+ version: {
93
+ type: 'integer',
94
+ label: 'Version',
95
+ minimum: 0,
96
+ maximum: 7,
97
+ decode: function () { this.instance.flags.version.setValue(this.readBits(0, 1, 0, 3)); },
98
+ encode: function () { this.writeBits(0, 1, 0, 3, this.instance.flags.version.getValue(2)); }
99
+ },
100
+ piggybacking: this.#flagBit('piggybacking', 3, 'Piggybacking'),
101
+ teidFlag: this.#flagBit('teidFlag', 4, 'TEID Flag'),
102
+ //3 spare bits kept verbatim so a non-canonical first byte still round-trips.
103
+ spare: {
104
+ type: 'integer',
105
+ label: 'Spare',
106
+ minimum: 0,
107
+ maximum: 7,
108
+ hidden: true,
109
+ decode: function () { this.instance.flags.spare.setValue(this.readBits(0, 1, 5, 3)); },
110
+ encode: function () { this.writeBits(0, 1, 5, 3, this.instance.flags.spare.getValue(0)); }
111
+ }
112
+ }
113
+ },
114
+ messageType: this.fieldUInt('messageType', 1, 1, 'Message Type'),
115
+ messageLength: {
116
+ type: 'integer',
117
+ label: 'Message Length',
118
+ minimum: 0,
119
+ maximum: 65535,
120
+ decode: function () {
121
+ this.instance.messageLength.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
122
+ },
123
+ encode: function () {
124
+ //Message Length counts every octet after the first 4: the TEID (if T), the 3-byte
125
+ //Sequence Number, the 1-byte Spare, and all IEs. Honoured when supplied (a crafted
126
+ //message may lie); else derived from the actual fields.
127
+ const provided = this.instance.messageLength.getValue();
128
+ let value;
129
+ if (provided !== undefined && provided !== null) {
130
+ value = provided;
131
+ }
132
+ else {
133
+ let iesBytes = 0;
134
+ const ies = this.instance.ies.getValue([]);
135
+ if (ies)
136
+ for (const ie of ies)
137
+ iesBytes += 4 + (0, HexToBuffer_1.HexToBuffer)(ie.value ? ie.value : '').length;
138
+ value = (this.#teidPresent() ? 4 : 0) + 3 + 1 + iesBytes;
139
+ }
140
+ if (value > 65535) {
141
+ this.recordError(this.instance.messageLength.getPath(), 'Maximum value is 65535');
142
+ value = 65535;
143
+ }
144
+ this.instance.messageLength.setValue(value);
145
+ this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(value));
146
+ }
147
+ },
148
+ //4-byte TEID, present only when the T flag is set. Kept verbatim as hex.
149
+ teid: {
150
+ type: 'string',
151
+ label: 'TEID',
152
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
153
+ decode: function () {
154
+ if (!this.#teidPresent())
155
+ return;
156
+ this.instance.teid.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(4, 4)));
157
+ },
158
+ encode: function () {
159
+ if (!this.#teidPresent())
160
+ return;
161
+ this.writeBytes(4, (0, HexToBuffer_1.HexToBuffer)(this.instance.teid.getValue('00000000')));
162
+ }
163
+ },
164
+ //3-byte Sequence Number, at offset 4 (no TEID) or 8 (TEID present).
165
+ sequenceNumber: {
166
+ type: 'integer',
167
+ label: 'Sequence Number',
168
+ minimum: 0,
169
+ maximum: 16777215,
170
+ decode: function () {
171
+ this.instance.sequenceNumber.setValue(this.readBits(this.#sequenceOffset(), 3, 0, 24));
172
+ },
173
+ encode: function () {
174
+ const node = this.instance.sequenceNumber;
175
+ let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
176
+ if (value > 16777215) {
177
+ this.recordError(node.getPath(), 'Maximum value is 16777215');
178
+ value = 16777215;
179
+ }
180
+ if (value < 0) {
181
+ this.recordError(node.getPath(), 'Minimum value is 0');
182
+ value = 0;
183
+ }
184
+ node.setValue(value);
185
+ this.writeBits(this.#sequenceOffset(), 3, 0, 24, value);
186
+ }
187
+ },
188
+ //1-byte Spare after the Sequence Number, kept verbatim.
189
+ spare: {
190
+ type: 'string',
191
+ label: 'Spare',
192
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
193
+ hidden: true,
194
+ decode: function () {
195
+ this.instance.spare.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(this.#sequenceOffset() + 3, 1)));
196
+ },
197
+ encode: function () {
198
+ this.writeBytes(this.#sequenceOffset() + 3, (0, HexToBuffer_1.HexToBuffer)(this.instance.spare.getValue('00')));
199
+ }
200
+ },
201
+ //Information Elements: a flat list from the end of the mandatory part to the Message Length
202
+ //end (clamped to the UDP payload). Each IE = Type(1) + Length(2) + (spare[4]+Instance[4])(1)
203
+ //+ Length value octets. The Length is derived from the value byte count on encode.
204
+ ies: {
205
+ type: 'array',
206
+ label: 'Information Elements',
207
+ items: {
208
+ type: 'object',
209
+ label: 'IE',
210
+ properties: {
211
+ type: { type: 'integer', label: 'Type', minimum: 0, maximum: 255 },
212
+ spare: { type: 'integer', label: 'Spare', minimum: 0, maximum: 15, hidden: true },
213
+ instance: { type: 'integer', label: 'Instance', minimum: 0, maximum: 15 },
214
+ value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
215
+ }
216
+ },
217
+ decode: function () {
218
+ const end = this.#messageEnd();
219
+ const ies = [];
220
+ let offset = this.#sequenceOffset() + 4;
221
+ //Each IE needs a 4-byte header; stop when it or its value would overrun the bound.
222
+ while (offset + 4 <= end) {
223
+ const type = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(offset, 1));
224
+ const length = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset + 1, 2));
225
+ const instByte = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(offset + 3, 1));
226
+ const valueStart = offset + 4;
227
+ if (valueStart + length > end)
228
+ break;
229
+ const value = length > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(valueStart, length)) : '';
230
+ ies.push({ type: type, spare: instByte >> 4, instance: instByte & 0x0f, value: value });
231
+ offset = valueStart + length;
232
+ }
233
+ this.instance.ies.setValue(ies);
234
+ },
235
+ encode: function () {
236
+ const ies = this.instance.ies.getValue([]);
237
+ if (!ies)
238
+ return;
239
+ let offset = this.#sequenceOffset() + 4;
240
+ for (let i = 0; i < ies.length; i++) {
241
+ const ie = ies[i];
242
+ let value = (0, HexToBuffer_1.HexToBuffer)(ie.value ? ie.value : '');
243
+ //The IE Length is a 16-bit field; a longer value cannot be represented, so clamp
244
+ //it and record the error rather than silently wrapping (which corrupts the chain).
245
+ if (value.length > 65535) {
246
+ this.recordError(`ies[${i}].value`, 'Maximum IE value length is 65535 bytes');
247
+ value = value.subarray(0, 65535);
248
+ }
249
+ this.writeBytes(offset, (0, NumberToBuffer_1.UInt8ToBuffer)(ie.type ? ie.type : 0));
250
+ this.writeBytes(offset + 1, (0, NumberToBuffer_1.UInt16ToBuffer)(value.length));
251
+ const spare = ie.spare ? ie.spare : 0;
252
+ const instance = ie.instance ? ie.instance : 0;
253
+ this.writeBytes(offset + 3, (0, NumberToBuffer_1.UInt8ToBuffer)(((spare & 0x0f) << 4) | (instance & 0x0f)));
254
+ offset += 4;
255
+ if (value.length) {
256
+ this.writeBytes(offset, value);
257
+ offset += value.length;
258
+ }
259
+ }
260
+ }
261
+ }
262
+ }
263
+ };
264
+ }
265
+ match() {
266
+ //GTPv2-C rides on UDP port 2123 (either endpoint — a request's destination or a response's
267
+ //source). Require the mandatory 8-byte header (flags + type + length + seq + spare, no TEID) to
268
+ //be present in the UDP payload, and Version == 2 in the first byte so GTPv1-C (version 1) on the
269
+ //same port falls through.
270
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'udp')
271
+ return false;
272
+ const dstport = this.prevCodecModule.instance.dstport.getValue(0);
273
+ const srcport = this.prevCodecModule.instance.srcport.getValue(0);
274
+ if (dstport !== 2123 && srcport !== 2123)
275
+ return false;
276
+ if (this.#available() < 8)
277
+ return false;
278
+ return this.readBits(0, 1, 0, 3) === 2;
279
+ }
280
+ }
281
+ exports.GTPv2C = GTPv2C;
@@ -0,0 +1,34 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * Git Smart Transport over the native `git://` protocol (git-daemon, TCP port 9418). The wire format is
6
+ * a stream of pkt-lines: each pkt-line is a 4-character ASCII hexadecimal length prefix (the length
7
+ * COUNTS those 4 characters) followed by that many minus four bytes of payload; the special value
8
+ * "0000" is a flush-pkt (an empty delimiter, no payload). A git-daemon session opens with a single
9
+ * request pkt-line such as `0032git-upload-pack /project.git\0host=example.com\0` — a length prefix,
10
+ * the service command and repository path, then NUL-delimited extra parameters (host, and for v2 an
11
+ * extra NUL plus capabilities).
12
+ *
13
+ * Like SIP/HTTP, the message body is a text-ish framed stream whose full internal structure (an
14
+ * arbitrary number of pkt-lines, service negotiation, ref advertisements, packfile data) is far richer
15
+ * than a form needs, and byte layout is significant. So the ENTIRE payload of the current segment is
16
+ * kept verbatim as the authoritative `message` field (hex) and re-emitted untouched; only the FIRST
17
+ * pkt-line is parsed on decode into display-only metadata (its declared length and command line).
18
+ * Encode never reconstructs the stream from the parsed fields — it writes `message` back byte-for-byte
19
+ * — so any conformant (or even malformed) git segment round-trips exactly.
20
+ *
21
+ * Note: a git session spans many TCP segments (request, ref advertisement, want/have negotiation, the
22
+ * packfile); reassembly across segments is out of scope. This single-segment codec keeps whatever bytes
23
+ * are present in the current segment verbatim, which is byte-perfect for the single-packet case.
24
+ */
25
+ export declare class GitProtocol extends BaseHeader {
26
+ #private;
27
+ get SCHEMA(): ProtocolJSONSchema;
28
+ readonly id: string;
29
+ readonly name: string;
30
+ readonly nickname: string;
31
+ readonly matchKeys: string[];
32
+ match(): boolean;
33
+ readonly demuxProducers: DemuxProducer[];
34
+ }