@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,141 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GESRTP = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ const BufferToHex_1 = require("../helper/BufferToHex");
6
+ const HexToBuffer_1 = require("../helper/HexToBuffer");
7
+ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
8
+ /**
9
+ * GE-SRTP — GE Fanuc (GE Intelligent Platforms) Service Request Transport Protocol, TCP port 18245.
10
+ * The proprietary Ethernet protocol spoken by GE Series 90 / PACSystems / VersaMax PLCs. GE publishes
11
+ * no specification; the on-wire layout used here is the community reverse-engineering (Collin Matthews'
12
+ * `TheMadHatt3r/ge-ethernet-SRTP`; the New Haven "Leveraging the SRTP protocol …" paper).
13
+ *
14
+ * Every message begins with a fixed 56-byte header. Only a subset of those 56 bytes has a confidently
15
+ * documented meaning — the message Type, sequence numbers, a controller timestamp, the message-type
16
+ * byte, the mailbox source/destination, packet counters, and the service-request block (Service Request
17
+ * Code, segment selector / memory type, memory offset, data length). Everything else in the header is
18
+ * "reserved/unknown" and is kept verbatim as hex so it round-trips untouched. A READ request is exactly
19
+ * the 56-byte header; a response carries the read data after the header, so any bytes captured past the
20
+ * 56-byte header are kept verbatim as `payload` hex (bounded by the captured TCP payload).
21
+ *
22
+ * ⚠️ The two-octet memory-offset and data-length fields are LITTLE-ENDIAN (segment selector / SNP
23
+ * addressing convention: LSB first). There is no little-endian helper in this codebase, so those uint16
24
+ * fields are read/written byte-by-byte in their closures. Every numeric field is a clamped uint (never a
25
+ * hard enum) so any value that decodes off the wire re-encodes without an Ajv rejection.
26
+ */
27
+ class GESRTP extends BaseHeader_1.BaseHeader {
28
+ constructor() {
29
+ super(...arguments);
30
+ this.id = 'gesrtp';
31
+ this.name = 'GE-SRTP';
32
+ this.nickname = 'GESRTP';
33
+ this.matchKeys = ['tcpport:18245'];
34
+ //A leaf header — the response data body is service-request-code dependent and not sub-decoded.
35
+ this.demuxProducers = [];
36
+ }
37
+ static #schemaCache;
38
+ get SCHEMA() {
39
+ return (GESRTP.#schemaCache ??= GESRTP.#buildSchema());
40
+ }
41
+ /** A little-endian unsigned 16-bit field of 2 octets at `offset` (LSB first, then MSB). */
42
+ static #fieldUInt16LE(name, offset, label) {
43
+ return {
44
+ type: 'integer',
45
+ label: label,
46
+ minimum: 0,
47
+ maximum: 65535,
48
+ decode: function () {
49
+ const b = this.readBytes(offset, 2);
50
+ this.instance[name].setValue(b[0] | (b[1] << 8));
51
+ },
52
+ encode: function () {
53
+ const node = this.instance[name];
54
+ let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
55
+ if (value > 65535) {
56
+ this.recordError(node.getPath(), 'Maximum value is 65535');
57
+ value = 65535;
58
+ }
59
+ if (value < 0) {
60
+ this.recordError(node.getPath(), 'Minimum value is 0');
61
+ value = 0;
62
+ }
63
+ node.setValue(value);
64
+ this.writeBytes(offset, Buffer.from([value & 0xff, (value >> 8) & 0xff]));
65
+ }
66
+ };
67
+ }
68
+ static #buildSchema() {
69
+ return {
70
+ type: 'object',
71
+ summary: 'GE-SRTP type=${type} svc=${serviceRequestCode}',
72
+ properties: {
73
+ //Byte 0: message Type (0x02 transmit/request, 0x03 return; 0x01 seen on responses).
74
+ type: this.fieldUInt('type', 0, 1, 'Type'),
75
+ //Byte 1: reserved/unknown, kept verbatim.
76
+ reserved1: this.fieldHex('reserved1', 1, 1, 'Reserved (1)'),
77
+ //Byte 2: sequence number.
78
+ sequenceNumber: this.fieldUInt('sequenceNumber', 2, 1, 'Sequence Number'),
79
+ //Byte 3: reserved/unknown.
80
+ reserved3: this.fieldHex('reserved3', 3, 1, 'Reserved (3)'),
81
+ //Byte 4: text length (documented single byte; the wider framing is unknown).
82
+ textLength: this.fieldUInt('textLength', 4, 1, 'Text Length'),
83
+ //Bytes 5..25: reserved/unknown span, kept verbatim (21 octets).
84
+ reserved5: this.fieldHex('reserved5', 5, 21, 'Reserved (5..25)'),
85
+ //Bytes 26..28: controller timestamp echoed in the header.
86
+ timeSeconds: this.fieldUInt('timeSeconds', 26, 1, 'Time Seconds'),
87
+ timeMinutes: this.fieldUInt('timeMinutes', 27, 1, 'Time Minutes'),
88
+ timeHours: this.fieldUInt('timeHours', 28, 1, 'Time Hours'),
89
+ //Byte 29: reserved/unknown.
90
+ reserved29: this.fieldHex('reserved29', 29, 1, 'Reserved (29)'),
91
+ //Byte 30: sequence number (repeated).
92
+ sequenceNumber2: this.fieldUInt('sequenceNumber2', 30, 1, 'Sequence Number (repeated)'),
93
+ //Byte 31: message-type byte (0xC0 observed on requests).
94
+ messageType: this.fieldUInt('messageType', 31, 1, 'Message Type'),
95
+ //Bytes 32..35: mailbox source, kept verbatim.
96
+ mailboxSource: this.fieldHex('mailboxSource', 32, 4, 'Mailbox Source'),
97
+ //Bytes 36..39: mailbox destination, kept verbatim.
98
+ mailboxDestination: this.fieldHex('mailboxDestination', 36, 4, 'Mailbox Destination'),
99
+ //Byte 40: packet number.
100
+ packetNumber: this.fieldUInt('packetNumber', 40, 1, 'Packet Number'),
101
+ //Byte 41: total packet count.
102
+ totalPacketNumber: this.fieldUInt('totalPacketNumber', 41, 1, 'Total Packet Number'),
103
+ //Byte 42: Service Request Code (0x04 read sys memory, 0x07 write sys memory, 0x00 status …).
104
+ serviceRequestCode: this.fieldUInt('serviceRequestCode', 42, 1, 'Service Request Code'),
105
+ //Byte 43: segment selector / memory type (0x08 %R, 0x0A %AI, 0x10 %I …), request-dependent.
106
+ segmentSelector: this.fieldUInt('segmentSelector', 43, 1, 'Segment Selector'),
107
+ //Bytes 44..45: memory offset (LITTLE-ENDIAN; zero-based, i.e. address − 1).
108
+ memoryOffset: this.#fieldUInt16LE('memoryOffset', 44, 'Memory Offset'),
109
+ //Bytes 46..47: data length (LITTLE-ENDIAN; count of the addressed units).
110
+ dataLength: this.#fieldUInt16LE('dataLength', 46, 'Data Length'),
111
+ //Bytes 48..55: remaining request-dependent / reserved header octets, kept verbatim.
112
+ reserved48: this.fieldHex('reserved48', 48, 8, 'Reserved (48..55)'),
113
+ //Anything captured after the fixed 56-byte header (e.g. a read response's data), kept
114
+ //verbatim and bounded by the captured TCP payload so it never reads past the buffer.
115
+ payload: {
116
+ type: 'string',
117
+ label: 'Payload',
118
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
119
+ decode: function () {
120
+ const remaining = this.packet.length - this.startPos;
121
+ this.instance.payload.setValue(remaining > 56 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(56, remaining - 56)) : '');
122
+ },
123
+ encode: function () {
124
+ const payload = this.instance.payload.getValue('');
125
+ if (payload)
126
+ this.writeBytes(56, (0, HexToBuffer_1.HexToBuffer)(payload));
127
+ }
128
+ }
129
+ }
130
+ };
131
+ }
132
+ match() {
133
+ //GE-SRTP rides on TCP port 18245. The header carries no strong content magic (byte 0 is only
134
+ //0x00..0x03), so the well-known port is the signature: require the full fixed 56-byte header to
135
+ //be present before claiming the payload.
136
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'tcp')
137
+ return false;
138
+ return this.packet.length - this.startPos >= 56;
139
+ }
140
+ }
141
+ exports.GESRTP = GESRTP;
@@ -0,0 +1,29 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * GLBP — Gateway Load Balancing Protocol (Cisco), carried over UDP port 3222 to the multicast group
6
+ * 224.0.0.102. Each message begins with a fixed 12-byte header — Version, Unknown1, Group (the GLBP
7
+ * group number), a 2-byte Unknown2 and a 6-byte Owner ID (a MAC address) — followed by a flat sequence
8
+ * of TLVs. Each TLV is a 1-byte Type + 1-byte Length (the length of the WHOLE TLV including this 2-byte
9
+ * header) + Length−2 value bytes (Hello = 1, Request/Response = 2, Auth = 3).
10
+ *
11
+ * GLBP is undocumented; the field names follow Wireshark's dissector, which treats byte 0 (labelled
12
+ * "Version?") as a discriminator that must equal 1 and Unknown1 (bytes must be ≤ 4) — real captures
13
+ * carry Version 1. It is kept as a plain uint8 here (no enum) so encode stays a faithful executor able
14
+ * to craft any value. The TLV value is kept verbatim as hex so every TLV — Hello, Request/Response,
15
+ * Auth, or unknown — round-trips byte-for-byte; per-TLV semantic decoding is a later enrichment. The
16
+ * TLV walk is bounded by the UDP datagram (so retained ethernet padding/FCS is not absorbed); any bytes
17
+ * after the last complete TLV are kept verbatim in `trailing` so the frame is reproduced exactly. GLBP
18
+ * is a leaf — nothing rides on top of it.
19
+ */
20
+ export declare class GLBP extends BaseHeader {
21
+ #private;
22
+ get SCHEMA(): ProtocolJSONSchema;
23
+ readonly id: string;
24
+ readonly name: string;
25
+ readonly nickname: string;
26
+ readonly matchKeys: string[];
27
+ match(): boolean;
28
+ readonly demuxProducers: DemuxProducer[];
29
+ }
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GLBP = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ const BufferToHex_1 = require("../helper/BufferToHex");
6
+ const HexToBuffer_1 = require("../helper/HexToBuffer");
7
+ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
8
+ /**
9
+ * GLBP — Gateway Load Balancing Protocol (Cisco), carried over UDP port 3222 to the multicast group
10
+ * 224.0.0.102. Each message begins with a fixed 12-byte header — Version, Unknown1, Group (the GLBP
11
+ * group number), a 2-byte Unknown2 and a 6-byte Owner ID (a MAC address) — followed by a flat sequence
12
+ * of TLVs. Each TLV is a 1-byte Type + 1-byte Length (the length of the WHOLE TLV including this 2-byte
13
+ * header) + Length−2 value bytes (Hello = 1, Request/Response = 2, Auth = 3).
14
+ *
15
+ * GLBP is undocumented; the field names follow Wireshark's dissector, which treats byte 0 (labelled
16
+ * "Version?") as a discriminator that must equal 1 and Unknown1 (bytes must be ≤ 4) — real captures
17
+ * carry Version 1. It is kept as a plain uint8 here (no enum) so encode stays a faithful executor able
18
+ * to craft any value. The TLV value is kept verbatim as hex so every TLV — Hello, Request/Response,
19
+ * Auth, or unknown — round-trips byte-for-byte; per-TLV semantic decoding is a later enrichment. The
20
+ * TLV walk is bounded by the UDP datagram (so retained ethernet padding/FCS is not absorbed); any bytes
21
+ * after the last complete TLV are kept verbatim in `trailing` so the frame is reproduced exactly. GLBP
22
+ * is a leaf — nothing rides on top of it.
23
+ */
24
+ class GLBP extends BaseHeader_1.BaseHeader {
25
+ constructor() {
26
+ super(...arguments);
27
+ this.id = 'glbp';
28
+ this.name = 'Gateway Load Balancing Protocol';
29
+ this.nickname = 'GLBP';
30
+ this.matchKeys = ['udpport:3222'];
31
+ //A leaf header — nothing is carried on top of a GLBP message.
32
+ this.demuxProducers = [];
33
+ }
34
+ static #schemaCache;
35
+ get SCHEMA() {
36
+ return (GLBP.#schemaCache ??= GLBP.#buildSchema());
37
+ }
38
+ /** The payload length bounded by the UDP datagram (so retained ethernet padding/FCS is not absorbed). */
39
+ #payloadLength() {
40
+ let available = this.packet.length - this.startPos;
41
+ if (this.prevCodecModule && this.prevCodecModule.id === 'udp') {
42
+ const udpLength = this.prevCodecModule.instance.length.getValue(0);
43
+ if (udpLength >= 8 && udpLength - 8 < available)
44
+ available = udpLength - 8;
45
+ }
46
+ return available < 0 ? 0 : available;
47
+ }
48
+ static #buildSchema() {
49
+ return {
50
+ type: 'object',
51
+ summary: 'GLBP group=${group} v=${version}',
52
+ properties: {
53
+ //Byte 0 — Wireshark labels this "Version?" and its heuristic requires it to equal 1 (real
54
+ //captures carry 1). Kept as a plain uint8 (no enum) so encode can craft any value.
55
+ version: this.fieldUInt('version', 0, 1, 'Version'),
56
+ //Byte 1 — Wireshark's "Unknown1" (its heuristic bounds it to ≤ 4). Kept verbatim.
57
+ unknown1: this.fieldUInt('unknown1', 1, 1, 'Unknown1'),
58
+ //Group number (big-endian).
59
+ group: this.fieldUInt('group', 2, 2, 'Group'),
60
+ //A 2-byte opaque field, kept verbatim so a non-canonical frame stays byte-perfect.
61
+ unknown2: this.fieldHex('unknown2', 4, 2, 'Unknown2'),
62
+ //Owner ID — a 6-byte MAC address, kept verbatim as hex (byte-perfect; MAC formatting is
63
+ //UI enrichment for later).
64
+ ownerId: this.fieldHex('ownerId', 6, 6, 'Owner ID'),
65
+ tlvs: {
66
+ type: 'array',
67
+ label: 'TLVs',
68
+ items: {
69
+ type: 'object',
70
+ label: 'TLV',
71
+ properties: {
72
+ type: { type: 'integer', label: 'Type', minimum: 0, maximum: 255 },
73
+ length: { type: 'integer', label: 'Length', minimum: 0, maximum: 255 },
74
+ value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
75
+ }
76
+ },
77
+ decode: function () {
78
+ //TLVs run from the end of the 12-byte header to the end of the UDP payload — GLBP
79
+ //has no length field of its own. The on-wire Length is the WHOLE TLV size (incl.
80
+ //the 2-byte header), so the value is Length−2 bytes.
81
+ const available = this.#payloadLength();
82
+ const tlvs = [];
83
+ let offset = 12;
84
+ while (offset + 2 <= available) {
85
+ const type = this.readBytes(offset, 1)[0];
86
+ const length = this.readBytes(offset + 1, 1)[0];
87
+ //A Length < 2 cannot even cover its own 2-byte header — stop rather than loop
88
+ //forever, leaving the remaining bytes to `trailing` so the round-trip is exact.
89
+ if (length < 2)
90
+ break;
91
+ //A TLV that overruns the payload (truncation) is not consumed — stop and leave
92
+ //the remaining bytes to `trailing`, keeping the round-trip exact.
93
+ if (offset + length > available)
94
+ break;
95
+ const valueLength = length - 2;
96
+ const value = valueLength > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset + 2, valueLength)) : '';
97
+ tlvs.push({ type: type, length: length, value: value });
98
+ offset += length;
99
+ }
100
+ this.instance.tlvs.setValue(tlvs);
101
+ //Bytes after the last complete TLV (truncation / trailing) are kept verbatim.
102
+ this.instance.trailing.setValue(offset < available ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset, available - offset)) : '');
103
+ },
104
+ encode: function () {
105
+ const tlvs = this.instance.tlvs.getValue([]);
106
+ let offset = 12;
107
+ if (tlvs) {
108
+ for (let i = 0; i < tlvs.length; i++) {
109
+ const tlv = tlvs[i];
110
+ const value = (0, HexToBuffer_1.HexToBuffer)(tlv.value ? tlv.value : '');
111
+ //Length is honored when supplied (a crafted TLV may carry any Length),
112
+ //else derived as the whole TLV size = 2-byte header + value bytes. It is a
113
+ //1-byte field, so clamp to [0, 255] (recording an error, never throwing).
114
+ const providedLength = tlv.length;
115
+ let length = (providedLength !== undefined && providedLength !== null)
116
+ ? providedLength
117
+ : value.length + 2;
118
+ if (length > 255) {
119
+ this.recordError(`tlvs[${i}].length`, 'Maximum value is 255');
120
+ length = 255;
121
+ }
122
+ if (length < 0) {
123
+ this.recordError(`tlvs[${i}].length`, 'Minimum value is 0');
124
+ length = 0;
125
+ }
126
+ this.writeBytes(offset, Buffer.from([tlv.type ? tlv.type & 0xff : 0, length]));
127
+ offset += 2;
128
+ if (value.length) {
129
+ this.writeBytes(offset, value);
130
+ offset += value.length;
131
+ }
132
+ }
133
+ }
134
+ const trailing = this.instance.trailing.getValue('');
135
+ if (trailing)
136
+ this.writeBytes(offset, (0, HexToBuffer_1.HexToBuffer)(trailing));
137
+ }
138
+ },
139
+ //Bytes after the last complete TLV, kept verbatim. No codec of its own — it is set/read by
140
+ //the `tlvs` field (which owns the single offset walk); this entry is metadata so the editor
141
+ //sees the trailing bytes.
142
+ trailing: {
143
+ type: 'string',
144
+ label: 'Trailing',
145
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX
146
+ }
147
+ }
148
+ };
149
+ }
150
+ match() {
151
+ //GLBP rides on UDP port 3222. Require the full 12-byte fixed header within the UDP payload
152
+ //(bounded by the datagram length, not the frame, so ethernet padding is not miscounted); a
153
+ //shorter datagram is not a GLBP message and falls through to raw.
154
+ if (!this.prevCodecModule || this.prevCodecModule.id !== 'udp')
155
+ return false;
156
+ return this.#payloadLength() >= 12;
157
+ }
158
+ }
159
+ exports.GLBP = GLBP;
@@ -0,0 +1,27 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * GRE — Generic Routing Encapsulation (RFC 2784 + key/sequence extensions RFC 2890), carried directly
6
+ * over IP as protocol 47. The 4-byte base header is a flags/version field — C (Checksum Present), the
7
+ * legacy R (Routing) bit, K (Key Present), S (Sequence Number Present), the legacy s/Recur bits, a
8
+ * reserved field, and a 3-bit Version (0 for GRE) — followed by a 16-bit Protocol Type (the EtherType
9
+ * of the payload). Optional trailing fields follow in order: a Checksum + Reserved1 (4 bytes, if C), a
10
+ * Key (4 bytes, if K), and a Sequence Number (4 bytes, if S). The inner frame follows.
11
+ *
12
+ * Like GENEVE, the inner frame is dispatched by Protocol Type: an ethertype demux producer routes an
13
+ * inner IPv4/IPv6 packet (0x0800/0x86dd) to IPv4/IPv6 (which accept a 'gre' parent), while a Transparent
14
+ * Ethernet Bridging payload (0x6558) falls through to EthernetII (guarded to that type). The GRE
15
+ * checksum is honored verbatim, not recomputed (encode is a faithful executor); a well-formed GRE
16
+ * message round-trips byte-for-byte. The legacy Routing (R=1, RFC 1701) fields are not parsed.
17
+ */
18
+ export declare class GRE extends BaseHeader {
19
+ #private;
20
+ get SCHEMA(): ProtocolJSONSchema;
21
+ readonly id: string;
22
+ readonly name: string;
23
+ readonly nickname: string;
24
+ readonly matchKeys: string[];
25
+ match(): boolean;
26
+ readonly demuxProducers: DemuxProducer[];
27
+ }
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GRE = 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
+ * GRE — Generic Routing Encapsulation (RFC 2784 + key/sequence extensions RFC 2890), carried directly
12
+ * over IP as protocol 47. The 4-byte base header is a flags/version field — C (Checksum Present), the
13
+ * legacy R (Routing) bit, K (Key Present), S (Sequence Number Present), the legacy s/Recur bits, a
14
+ * reserved field, and a 3-bit Version (0 for GRE) — followed by a 16-bit Protocol Type (the EtherType
15
+ * of the payload). Optional trailing fields follow in order: a Checksum + Reserved1 (4 bytes, if C), a
16
+ * Key (4 bytes, if K), and a Sequence Number (4 bytes, if S). The inner frame follows.
17
+ *
18
+ * Like GENEVE, the inner frame is dispatched by Protocol Type: an ethertype demux producer routes an
19
+ * inner IPv4/IPv6 packet (0x0800/0x86dd) to IPv4/IPv6 (which accept a 'gre' parent), while a Transparent
20
+ * Ethernet Bridging payload (0x6558) falls through to EthernetII (guarded to that type). The GRE
21
+ * checksum is honored verbatim, not recomputed (encode is a faithful executor); a well-formed GRE
22
+ * message round-trips byte-for-byte. The legacy Routing (R=1, RFC 1701) fields are not parsed.
23
+ */
24
+ class GRE extends BaseHeader_1.BaseHeader {
25
+ constructor() {
26
+ super(...arguments);
27
+ this.id = 'gre';
28
+ this.name = 'Generic Routing Encapsulation';
29
+ this.nickname = 'GRE';
30
+ this.matchKeys = ['ipproto:47'];
31
+ //Protocol Type is an EtherType; declaring it in the 'ethertype' namespace dispatches an inner IPv4/
32
+ //IPv6 packet to the O(1) bucket (which accepts a 'gre' parent), while a 0x6558 Ethernet payload
33
+ //falls through to EthernetII's tunnel-aware match.
34
+ this.demuxProducers = [{ field: 'protocolType', namespace: 'ethertype', kind: 'string' }];
35
+ }
36
+ static #schemaCache;
37
+ get SCHEMA() {
38
+ return (GRE.#schemaCache ??= GRE.#buildSchema());
39
+ }
40
+ /**
41
+ * The length available to GRE's own header (base + optional fields), bounded by the enclosing IP
42
+ * datagram — so a lying flag near the end of the IP payload does not read into a trailing FCS. This
43
+ * bounds GRE's field reads and the match gate; the inner frame is left to the codec's recursion
44
+ * (which, like the other tunnels, reads to the end of the captured packet).
45
+ */
46
+ #available() {
47
+ let available = this.packet.length - this.startPos;
48
+ const prev = this.prevCodecModule;
49
+ if (prev && prev.id === 'ipv4') {
50
+ const ipPayload = prev.instance.length.getValue(0) - prev.length;
51
+ if (ipPayload >= 0 && ipPayload < available)
52
+ available = ipPayload;
53
+ }
54
+ else if (prev && prev.id === 'ipv6') {
55
+ const ipPayload = prev.instance.plen.getValue(0);
56
+ if (ipPayload >= 0 && ipPayload < available)
57
+ available = ipPayload;
58
+ }
59
+ return available < 0 ? 0 : available;
60
+ }
61
+ /** A single flag bit within the 2-byte flags/version field (bit 0 = MSB of byte 0). */
62
+ static #flagBit(name, bitOffset, label) {
63
+ return {
64
+ type: 'boolean',
65
+ label: label,
66
+ decode: function () {
67
+ this.instance.flags[name].setValue(!!this.readBits(0, 1, bitOffset, 1));
68
+ },
69
+ encode: function () {
70
+ const value = !!this.instance.flags[name].getValue();
71
+ this.instance.flags[name].setValue(value);
72
+ this.writeBits(0, 1, bitOffset, 1, value ? 1 : 0);
73
+ }
74
+ };
75
+ }
76
+ static #buildSchema() {
77
+ return {
78
+ type: 'object',
79
+ summary: 'GRE proto=${protocolType}',
80
+ properties: {
81
+ //Flags/version (byte 0-1, MSB first): C(0) R(1) K(2) S(3) s(4) Recur(5-7) | reserved0(8-12)
82
+ //Version(13-15). The legacy R/s/Recur/reserved bits are kept verbatim for byte-perfect.
83
+ flags: {
84
+ type: 'object',
85
+ label: 'Flags',
86
+ properties: {
87
+ checksum: this.#flagBit('checksum', 0, 'Checksum Present'),
88
+ routing: this.#flagBit('routing', 1, 'Routing Present'),
89
+ key: this.#flagBit('key', 2, 'Key Present'),
90
+ sequence: this.#flagBit('sequence', 3, 'Sequence Number Present'),
91
+ strictRoute: this.#flagBit('strictRoute', 4, 'Strict Source Route'),
92
+ recur: {
93
+ type: 'integer', label: 'Recursion Control', minimum: 0, maximum: 7, hidden: true,
94
+ decode: function () { this.instance.flags.recur.setValue(this.readBits(0, 1, 5, 3)); },
95
+ encode: function () { this.writeBits(0, 1, 5, 3, this.instance.flags.recur.getValue(0)); }
96
+ },
97
+ reserved0: {
98
+ type: 'integer', label: 'Reserved', minimum: 0, maximum: 31, hidden: true,
99
+ decode: function () { this.instance.flags.reserved0.setValue(this.readBits(1, 1, 0, 5)); },
100
+ encode: function () { this.writeBits(1, 1, 0, 5, this.instance.flags.reserved0.getValue(0)); }
101
+ },
102
+ version: {
103
+ type: 'integer', label: 'Version', minimum: 0, maximum: 7,
104
+ decode: function () { this.instance.flags.version.setValue(this.readBits(1, 1, 5, 3)); },
105
+ encode: function () { this.writeBits(1, 1, 5, 3, this.instance.flags.version.getValue(0)); }
106
+ }
107
+ }
108
+ },
109
+ //Protocol Type is the EtherType of the inner frame — stored as a lowercase hex string
110
+ //(like eth.etherType) so it can drive the `ethertype` demux dimension to the inner codec.
111
+ protocolType: {
112
+ type: 'string', label: 'Protocol Type', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
113
+ decode: function () { this.instance.protocolType.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(2, 2))); },
114
+ encode: function () {
115
+ const hex = this.instance.protocolType.getValue('0800');
116
+ this.writeBytes(2, (0, HexToBuffer_1.HexToBuffer)(hex.padStart(4, '0').slice(-4)));
117
+ }
118
+ },
119
+ checksum: { type: 'integer', label: 'Checksum', minimum: 0, maximum: 65535 },
120
+ reserved1: { type: 'string', label: 'Reserved', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX, hidden: true },
121
+ keyValue: { type: 'string', label: 'Key', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX },
122
+ sequenceNumber: { type: 'integer', label: 'Sequence Number', minimum: 0, maximum: 4294967295 },
123
+ //Master field: the optional trailing fields are flag-conditional, so they are parsed/
124
+ //emitted here (runs after the fixed flags/protocolType fields — property order).
125
+ body: {
126
+ type: 'string', label: 'Body', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX, hidden: true,
127
+ decode: function () {
128
+ const available = this.#available();
129
+ const hasChecksum = !!this.instance.flags.checksum.getValue();
130
+ const hasKey = !!this.instance.flags.key.getValue();
131
+ const hasSeq = !!this.instance.flags.sequence.getValue();
132
+ let offset = 4;
133
+ if (hasChecksum && offset + 4 <= available) {
134
+ this.instance.checksum.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset, 2)));
135
+ this.instance.reserved1.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(offset + 2, 2)));
136
+ offset += 4;
137
+ }
138
+ if (hasKey && offset + 4 <= available) {
139
+ this.instance.keyValue.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(offset, 4)));
140
+ offset += 4;
141
+ }
142
+ if (hasSeq && offset + 4 <= available) {
143
+ this.instance.sequenceNumber.setValue((0, BufferToNumber_1.BufferToUInt32)(this.readBytes(offset, 4)));
144
+ offset += 4;
145
+ }
146
+ },
147
+ encode: function () {
148
+ const hasChecksum = !!this.instance.flags.checksum.getValue();
149
+ const hasKey = !!this.instance.flags.key.getValue();
150
+ const hasSeq = !!this.instance.flags.sequence.getValue();
151
+ let offset = 4;
152
+ if (hasChecksum) {
153
+ //Honored verbatim, not recomputed — a crafted GRE may carry any checksum.
154
+ this.writeBytes(offset, (0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.checksum.getValue(0)));
155
+ this.writeBytes(offset + 2, (0, HexToBuffer_1.HexToBuffer)(this.instance.reserved1.getValue('0000')));
156
+ offset += 4;
157
+ }
158
+ if (hasKey) {
159
+ this.writeBytes(offset, (0, HexToBuffer_1.HexToBuffer)(this.instance.keyValue.getValue('00000000')));
160
+ offset += 4;
161
+ }
162
+ if (hasSeq) {
163
+ this.writeBytes(offset, (0, NumberToBuffer_1.UInt32ToBuffer)(this.instance.sequenceNumber.getValue(0)));
164
+ offset += 4;
165
+ }
166
+ }
167
+ }
168
+ }
169
+ };
170
+ }
171
+ match() {
172
+ //GRE sits directly above IPv4 (protocol field) or IPv6 (next-header field) with protocol 47, and
173
+ //needs at least its 4-byte base header within the IP payload.
174
+ if (!this.prevCodecModule)
175
+ return false;
176
+ if (this.prevCodecModule.instance.protocol.getValue() !== 0x2f && this.prevCodecModule.instance.nxt.getValue() !== 0x2f)
177
+ return false;
178
+ return this.#available() >= 4;
179
+ }
180
+ }
181
+ exports.GRE = GRE;
@@ -0,0 +1,25 @@
1
+ import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * GTP-U — GPRS Tunnelling Protocol, User plane (3GPP TS 29.281), UDP port 2152. The mandatory 8-byte
6
+ * header is a Flags byte (Version[3] / Protocol-Type / reserved / E / S / PN), a Message Type
7
+ * (0xFF = G-PDU carries a user IP packet), a 2-byte Length (everything after the 8-byte header), and a
8
+ * 4-byte TEID (Tunnel Endpoint Identifier). If any of E/S/PN is set, a 4-byte optional field
9
+ * (Sequence Number + N-PDU Number + Next-Extension-Header-Type) follows, then a chain of extension
10
+ * headers. For a G-PDU the payload after the header is a raw inner IP packet.
11
+ *
12
+ * The optional field + extension-header chain is kept verbatim (optionalHeader hex) so any GTP-U
13
+ * variant round-trips byte-for-byte; the inner IP packet is left to the codec's recursion (IPv4/IPv6
14
+ * accept a GTP-U tunnel parent, matching by IP version), decoding a fresh ip/… stack after the tunnel.
15
+ */
16
+ export declare class GTPU extends BaseHeader {
17
+ #private;
18
+ get SCHEMA(): ProtocolJSONSchema;
19
+ readonly id: string;
20
+ readonly name: string;
21
+ readonly nickname: string;
22
+ readonly matchKeys: string[];
23
+ match(): boolean;
24
+ readonly demuxProducers: DemuxProducer[];
25
+ }