@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.
- package/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/README.md +352 -0
- package/README.zh-CN.md +342 -0
- package/dist/Codec.d.ts +133 -0
- package/dist/Codec.js +632 -0
- package/dist/PacketHeaders.d.ts +189 -0
- package/dist/PacketHeaders.js +384 -0
- package/dist/abstracts/BaseHeader.d.ts +325 -0
- package/dist/abstracts/BaseHeader.js +734 -0
- package/dist/errors/CodecSchemaValidateError.d.ts +4 -0
- package/dist/errors/CodecSchemaValidateError.js +11 -0
- package/dist/headers/ADSAMS.d.ts +33 -0
- package/dist/headers/ADSAMS.js +208 -0
- package/dist/headers/AH.d.ts +28 -0
- package/dist/headers/AH.js +137 -0
- package/dist/headers/AMQP.d.ts +31 -0
- package/dist/headers/AMQP.js +316 -0
- package/dist/headers/ARP.d.ts +26 -0
- package/dist/headers/ARP.js +243 -0
- package/dist/headers/BACnetIP.d.ts +27 -0
- package/dist/headers/BACnetIP.js +97 -0
- package/dist/headers/BFD.d.ts +28 -0
- package/dist/headers/BFD.js +155 -0
- package/dist/headers/BGP.d.ts +27 -0
- package/dist/headers/BGP.js +111 -0
- package/dist/headers/BSAPIP.d.ts +33 -0
- package/dist/headers/BSAPIP.js +78 -0
- package/dist/headers/Babel.d.ts +32 -0
- package/dist/headers/Babel.js +224 -0
- package/dist/headers/BitTorrent.d.ts +28 -0
- package/dist/headers/BitTorrent.js +72 -0
- package/dist/headers/C37118.d.ts +26 -0
- package/dist/headers/C37118.js +147 -0
- package/dist/headers/CAPWAP.d.ts +38 -0
- package/dist/headers/CAPWAP.js +275 -0
- package/dist/headers/CDP.d.ts +25 -0
- package/dist/headers/CDP.js +117 -0
- package/dist/headers/CMS.d.ts +33 -0
- package/dist/headers/CMS.js +238 -0
- package/dist/headers/COTP.d.ts +30 -0
- package/dist/headers/COTP.js +193 -0
- package/dist/headers/CassandraCQL.d.ts +28 -0
- package/dist/headers/CassandraCQL.js +117 -0
- package/dist/headers/CoAP.d.ts +29 -0
- package/dist/headers/CoAP.js +140 -0
- package/dist/headers/Codesys.d.ts +32 -0
- package/dist/headers/Codesys.js +119 -0
- package/dist/headers/Collectd.d.ts +29 -0
- package/dist/headers/Collectd.js +154 -0
- package/dist/headers/DCCP.d.ts +30 -0
- package/dist/headers/DCCP.js +204 -0
- package/dist/headers/DHCP.d.ts +26 -0
- package/dist/headers/DHCP.js +148 -0
- package/dist/headers/DHCPFailover.d.ts +30 -0
- package/dist/headers/DHCPFailover.js +104 -0
- package/dist/headers/DHCPv6.d.ts +25 -0
- package/dist/headers/DHCPv6.js +145 -0
- package/dist/headers/DNP3.d.ts +27 -0
- package/dist/headers/DNP3.js +150 -0
- package/dist/headers/DNS.d.ts +55 -0
- package/dist/headers/DNS.js +309 -0
- package/dist/headers/DTLS.d.ts +33 -0
- package/dist/headers/DTLS.js +142 -0
- package/dist/headers/Diameter.d.ts +34 -0
- package/dist/headers/Diameter.js +229 -0
- package/dist/headers/EAPOL.d.ts +32 -0
- package/dist/headers/EAPOL.js +135 -0
- package/dist/headers/EIGRP.d.ts +28 -0
- package/dist/headers/EIGRP.js +165 -0
- package/dist/headers/ENIP.d.ts +31 -0
- package/dist/headers/ENIP.js +164 -0
- package/dist/headers/ESP.d.ts +27 -0
- package/dist/headers/ESP.js +140 -0
- package/dist/headers/Elasticsearch.d.ts +30 -0
- package/dist/headers/Elasticsearch.js +125 -0
- package/dist/headers/EtherCAT.d.ts +35 -0
- package/dist/headers/EtherCAT.js +150 -0
- package/dist/headers/EthernetII.d.ts +28 -0
- package/dist/headers/EthernetII.js +117 -0
- package/dist/headers/FCoE.d.ts +38 -0
- package/dist/headers/FCoE.js +210 -0
- package/dist/headers/FTP.d.ts +34 -0
- package/dist/headers/FTP.js +158 -0
- package/dist/headers/Finger.d.ts +41 -0
- package/dist/headers/Finger.js +135 -0
- package/dist/headers/FoundationFieldbusHSE.d.ts +43 -0
- package/dist/headers/FoundationFieldbusHSE.js +163 -0
- package/dist/headers/GELF.d.ts +35 -0
- package/dist/headers/GELF.js +261 -0
- package/dist/headers/GENEVE.d.ts +26 -0
- package/dist/headers/GENEVE.js +209 -0
- package/dist/headers/GESRTP.d.ts +32 -0
- package/dist/headers/GESRTP.js +141 -0
- package/dist/headers/GLBP.d.ts +29 -0
- package/dist/headers/GLBP.js +159 -0
- package/dist/headers/GRE.d.ts +27 -0
- package/dist/headers/GRE.js +181 -0
- package/dist/headers/GTPU.d.ts +25 -0
- package/dist/headers/GTPU.js +203 -0
- package/dist/headers/GTPv2C.d.ts +30 -0
- package/dist/headers/GTPv2C.js +281 -0
- package/dist/headers/GitProtocol.d.ts +34 -0
- package/dist/headers/GitProtocol.js +141 -0
- package/dist/headers/Goose.d.ts +115 -0
- package/dist/headers/Goose.js +1067 -0
- package/dist/headers/Gopher.d.ts +43 -0
- package/dist/headers/Gopher.js +182 -0
- package/dist/headers/HARTIP.d.ts +30 -0
- package/dist/headers/HARTIP.js +145 -0
- package/dist/headers/HSR.d.ts +27 -0
- package/dist/headers/HSR.js +105 -0
- package/dist/headers/HSRP.d.ts +26 -0
- package/dist/headers/HSRP.js +173 -0
- package/dist/headers/HTTP.d.ts +32 -0
- package/dist/headers/HTTP.js +153 -0
- package/dist/headers/HTTP2.d.ts +34 -0
- package/dist/headers/HTTP2.js +190 -0
- package/dist/headers/IAX2.d.ts +33 -0
- package/dist/headers/IAX2.js +274 -0
- package/dist/headers/ICMP.d.ts +15 -0
- package/dist/headers/ICMP.js +148 -0
- package/dist/headers/ICMPv6.d.ts +15 -0
- package/dist/headers/ICMPv6.js +129 -0
- package/dist/headers/IEC104_I_Frame.d.ts +23 -0
- package/dist/headers/IEC104_I_Frame.js +6489 -0
- package/dist/headers/IEC104_S_Frame.d.ts +26 -0
- package/dist/headers/IEC104_S_Frame.js +135 -0
- package/dist/headers/IEC104_U_Frame.d.ts +27 -0
- package/dist/headers/IEC104_U_Frame.js +176 -0
- package/dist/headers/IEC61850SampledValues.d.ts +20 -0
- package/dist/headers/IEC61850SampledValues.js +420 -0
- package/dist/headers/IGMP.d.ts +31 -0
- package/dist/headers/IGMP.js +274 -0
- package/dist/headers/IMAP.d.ts +32 -0
- package/dist/headers/IMAP.js +185 -0
- package/dist/headers/IPFIX.d.ts +29 -0
- package/dist/headers/IPFIX.js +156 -0
- package/dist/headers/IPv4.d.ts +20 -0
- package/dist/headers/IPv4.js +370 -0
- package/dist/headers/IPv6.d.ts +29 -0
- package/dist/headers/IPv6.js +209 -0
- package/dist/headers/IPv6HopByHopOptions.d.ts +81 -0
- package/dist/headers/IPv6HopByHopOptions.js +495 -0
- package/dist/headers/IRC.d.ts +34 -0
- package/dist/headers/IRC.js +175 -0
- package/dist/headers/ISAKMP.d.ts +29 -0
- package/dist/headers/ISAKMP.js +197 -0
- package/dist/headers/ISCSI.d.ts +39 -0
- package/dist/headers/ISCSI.js +289 -0
- package/dist/headers/ISIS.d.ts +25 -0
- package/dist/headers/ISIS.js +79 -0
- package/dist/headers/ISOSession.d.ts +27 -0
- package/dist/headers/ISOSession.js +343 -0
- package/dist/headers/Ident.d.ts +42 -0
- package/dist/headers/Ident.js +184 -0
- package/dist/headers/KNXnetIP.d.ts +30 -0
- package/dist/headers/KNXnetIP.js +135 -0
- package/dist/headers/Kafka.d.ts +35 -0
- package/dist/headers/Kafka.js +128 -0
- package/dist/headers/Kerberos.d.ts +30 -0
- package/dist/headers/Kerberos.js +217 -0
- package/dist/headers/L2TP.d.ts +26 -0
- package/dist/headers/L2TP.js +297 -0
- package/dist/headers/LACP.d.ts +31 -0
- package/dist/headers/LACP.js +151 -0
- package/dist/headers/LDAP.d.ts +31 -0
- package/dist/headers/LDAP.js +226 -0
- package/dist/headers/LDP.d.ts +31 -0
- package/dist/headers/LDP.js +138 -0
- package/dist/headers/LISP.d.ts +30 -0
- package/dist/headers/LISP.js +103 -0
- package/dist/headers/LLC.d.ts +27 -0
- package/dist/headers/LLC.js +81 -0
- package/dist/headers/LLDP.d.ts +26 -0
- package/dist/headers/LLDP.js +126 -0
- package/dist/headers/LLMNR.d.ts +23 -0
- package/dist/headers/LLMNR.js +40 -0
- package/dist/headers/LPD.d.ts +31 -0
- package/dist/headers/LPD.js +159 -0
- package/dist/headers/MACsec.d.ts +34 -0
- package/dist/headers/MACsec.js +178 -0
- package/dist/headers/MDNS.d.ts +26 -0
- package/dist/headers/MDNS.js +45 -0
- package/dist/headers/MGCP.d.ts +30 -0
- package/dist/headers/MGCP.js +155 -0
- package/dist/headers/MMS.d.ts +29 -0
- package/dist/headers/MMS.js +243 -0
- package/dist/headers/MPLS.d.ts +31 -0
- package/dist/headers/MPLS.js +145 -0
- package/dist/headers/MQTT.d.ts +30 -0
- package/dist/headers/MQTT.js +173 -0
- package/dist/headers/MQTTSN.d.ts +34 -0
- package/dist/headers/MQTTSN.js +177 -0
- package/dist/headers/MarkerProtocol.d.ts +32 -0
- package/dist/headers/MarkerProtocol.js +153 -0
- package/dist/headers/Megaco.d.ts +32 -0
- package/dist/headers/Megaco.js +144 -0
- package/dist/headers/Memcached.d.ts +44 -0
- package/dist/headers/Memcached.js +285 -0
- package/dist/headers/ModbusTCP.d.ts +25 -0
- package/dist/headers/ModbusTCP.js +99 -0
- package/dist/headers/ModbusUDP.d.ts +26 -0
- package/dist/headers/ModbusUDP.js +100 -0
- package/dist/headers/MongoDB.d.ts +33 -0
- package/dist/headers/MongoDB.js +143 -0
- package/dist/headers/MySQL.d.ts +30 -0
- package/dist/headers/MySQL.js +114 -0
- package/dist/headers/NATS.d.ts +29 -0
- package/dist/headers/NATS.js +135 -0
- package/dist/headers/NBDS.d.ts +34 -0
- package/dist/headers/NBDS.js +176 -0
- package/dist/headers/NBNS.d.ts +34 -0
- package/dist/headers/NBNS.js +78 -0
- package/dist/headers/NBSS.d.ts +36 -0
- package/dist/headers/NBSS.js +137 -0
- package/dist/headers/NFS.d.ts +36 -0
- package/dist/headers/NFS.js +273 -0
- package/dist/headers/NHRP.d.ts +32 -0
- package/dist/headers/NHRP.js +154 -0
- package/dist/headers/NNTP.d.ts +35 -0
- package/dist/headers/NNTP.js +162 -0
- package/dist/headers/NTP.d.ts +18 -0
- package/dist/headers/NTP.js +73 -0
- package/dist/headers/NetFlowV5.d.ts +28 -0
- package/dist/headers/NetFlowV5.js +205 -0
- package/dist/headers/OLSR.d.ts +31 -0
- package/dist/headers/OLSR.js +213 -0
- package/dist/headers/OPCUA.d.ts +33 -0
- package/dist/headers/OPCUA.js +165 -0
- package/dist/headers/OPCUAPubSub.d.ts +33 -0
- package/dist/headers/OPCUAPubSub.js +144 -0
- package/dist/headers/OSPF.d.ts +31 -0
- package/dist/headers/OSPF.js +365 -0
- package/dist/headers/OmronFINS.d.ts +31 -0
- package/dist/headers/OmronFINS.js +90 -0
- package/dist/headers/OpenFlow.d.ts +30 -0
- package/dist/headers/OpenFlow.js +113 -0
- package/dist/headers/OpenVPN.d.ts +35 -0
- package/dist/headers/OpenVPN.js +214 -0
- package/dist/headers/PCWorx.d.ts +35 -0
- package/dist/headers/PCWorx.js +115 -0
- package/dist/headers/PIM.d.ts +27 -0
- package/dist/headers/PIM.js +129 -0
- package/dist/headers/POP3.d.ts +31 -0
- package/dist/headers/POP3.js +152 -0
- package/dist/headers/POWERLINK.d.ts +28 -0
- package/dist/headers/POWERLINK.js +116 -0
- package/dist/headers/PPPoEDiscovery.d.ts +29 -0
- package/dist/headers/PPPoEDiscovery.js +198 -0
- package/dist/headers/PPPoESession.d.ts +28 -0
- package/dist/headers/PPPoESession.js +125 -0
- package/dist/headers/PPTP.d.ts +30 -0
- package/dist/headers/PPTP.js +122 -0
- package/dist/headers/PROFINETRT.d.ts +28 -0
- package/dist/headers/PROFINETRT.js +74 -0
- package/dist/headers/PTP.d.ts +34 -0
- package/dist/headers/PTP.js +213 -0
- package/dist/headers/PostgreSQL.d.ts +40 -0
- package/dist/headers/PostgreSQL.js +236 -0
- package/dist/headers/QUIC.d.ts +34 -0
- package/dist/headers/QUIC.js +308 -0
- package/dist/headers/RADIUS.d.ts +24 -0
- package/dist/headers/RADIUS.js +138 -0
- package/dist/headers/RDP.d.ts +27 -0
- package/dist/headers/RDP.js +93 -0
- package/dist/headers/RFB.d.ts +39 -0
- package/dist/headers/RFB.js +151 -0
- package/dist/headers/RGoose.d.ts +72 -0
- package/dist/headers/RGoose.js +340 -0
- package/dist/headers/RIP.d.ts +29 -0
- package/dist/headers/RIP.js +133 -0
- package/dist/headers/RIPng.d.ts +26 -0
- package/dist/headers/RIPng.js +140 -0
- package/dist/headers/RMCP.d.ts +26 -0
- package/dist/headers/RMCP.js +155 -0
- package/dist/headers/RSVP.d.ts +31 -0
- package/dist/headers/RSVP.js +263 -0
- package/dist/headers/RTCP.d.ts +34 -0
- package/dist/headers/RTCP.js +217 -0
- package/dist/headers/RTP.d.ts +33 -0
- package/dist/headers/RTP.js +291 -0
- package/dist/headers/RTPS.d.ts +33 -0
- package/dist/headers/RTPS.js +182 -0
- package/dist/headers/RTSP.d.ts +36 -0
- package/dist/headers/RTSP.js +184 -0
- package/dist/headers/RawData.d.ts +17 -0
- package/dist/headers/RawData.js +43 -0
- package/dist/headers/Redis.d.ts +32 -0
- package/dist/headers/Redis.js +202 -0
- package/dist/headers/Rlogin.d.ts +42 -0
- package/dist/headers/Rlogin.js +139 -0
- package/dist/headers/Rsync.d.ts +28 -0
- package/dist/headers/Rsync.js +117 -0
- package/dist/headers/S7comm.d.ts +36 -0
- package/dist/headers/S7comm.js +244 -0
- package/dist/headers/SCTP.d.ts +35 -0
- package/dist/headers/SCTP.js +174 -0
- package/dist/headers/SFlow.d.ts +29 -0
- package/dist/headers/SFlow.js +242 -0
- package/dist/headers/SIP.d.ts +27 -0
- package/dist/headers/SIP.js +146 -0
- package/dist/headers/SLMP.d.ts +36 -0
- package/dist/headers/SLMP.js +154 -0
- package/dist/headers/SLP.d.ts +30 -0
- package/dist/headers/SLP.js +207 -0
- package/dist/headers/SLPv1.d.ts +32 -0
- package/dist/headers/SLPv1.js +138 -0
- package/dist/headers/SMB1.d.ts +37 -0
- package/dist/headers/SMB1.js +200 -0
- package/dist/headers/SMB2.d.ts +36 -0
- package/dist/headers/SMB2.js +203 -0
- package/dist/headers/SMPP.d.ts +33 -0
- package/dist/headers/SMPP.js +119 -0
- package/dist/headers/SMTP.d.ts +33 -0
- package/dist/headers/SMTP.js +157 -0
- package/dist/headers/SNAP.d.ts +22 -0
- package/dist/headers/SNAP.js +68 -0
- package/dist/headers/SNMP.d.ts +28 -0
- package/dist/headers/SNMP.js +302 -0
- package/dist/headers/SOCKS4.d.ts +42 -0
- package/dist/headers/SOCKS4.js +302 -0
- package/dist/headers/SOCKS5.d.ts +45 -0
- package/dist/headers/SOCKS5.js +223 -0
- package/dist/headers/SSDP.d.ts +27 -0
- package/dist/headers/SSDP.js +161 -0
- package/dist/headers/SSH.d.ts +44 -0
- package/dist/headers/SSH.js +274 -0
- package/dist/headers/STOMP.d.ts +48 -0
- package/dist/headers/STOMP.js +177 -0
- package/dist/headers/STP.d.ts +26 -0
- package/dist/headers/STP.js +150 -0
- package/dist/headers/STUN.d.ts +25 -0
- package/dist/headers/STUN.js +183 -0
- package/dist/headers/SercosIII.d.ts +43 -0
- package/dist/headers/SercosIII.js +199 -0
- package/dist/headers/Skinny.d.ts +32 -0
- package/dist/headers/Skinny.js +139 -0
- package/dist/headers/StatsD.d.ts +27 -0
- package/dist/headers/StatsD.js +134 -0
- package/dist/headers/SunRPC.d.ts +34 -0
- package/dist/headers/SunRPC.js +268 -0
- package/dist/headers/Syslog.d.ts +21 -0
- package/dist/headers/Syslog.js +91 -0
- package/dist/headers/TCP.d.ts +19 -0
- package/dist/headers/TCP.js +905 -0
- package/dist/headers/TFTP.d.ts +28 -0
- package/dist/headers/TFTP.js +224 -0
- package/dist/headers/TLS_Alert.d.ts +24 -0
- package/dist/headers/TLS_Alert.js +639 -0
- package/dist/headers/TLS_ApplicationData.d.ts +24 -0
- package/dist/headers/TLS_ApplicationData.js +170 -0
- package/dist/headers/TLS_ChangeCipherSpec.d.ts +23 -0
- package/dist/headers/TLS_ChangeCipherSpec.js +168 -0
- package/dist/headers/TLS_Handshake.d.ts +65 -0
- package/dist/headers/TLS_Handshake.js +860 -0
- package/dist/headers/TLS_Heartbeat.d.ts +27 -0
- package/dist/headers/TLS_Heartbeat.js +247 -0
- package/dist/headers/TPKT.d.ts +26 -0
- package/dist/headers/TPKT.js +99 -0
- package/dist/headers/TacacsPlus.d.ts +27 -0
- package/dist/headers/TacacsPlus.js +133 -0
- package/dist/headers/Telnet.d.ts +40 -0
- package/dist/headers/Telnet.js +193 -0
- package/dist/headers/Teredo.d.ts +40 -0
- package/dist/headers/Teredo.js +251 -0
- package/dist/headers/TimeProtocol.d.ts +25 -0
- package/dist/headers/TimeProtocol.js +53 -0
- package/dist/headers/UDP.d.ts +19 -0
- package/dist/headers/UDP.js +171 -0
- package/dist/headers/VLAN_802dot1Q.d.ts +24 -0
- package/dist/headers/VLAN_802dot1Q.js +96 -0
- package/dist/headers/VRRP.d.ts +26 -0
- package/dist/headers/VRRP.js +309 -0
- package/dist/headers/VXLAN.d.ts +24 -0
- package/dist/headers/VXLAN.js +75 -0
- package/dist/headers/WCCP.d.ts +29 -0
- package/dist/headers/WCCP.js +117 -0
- package/dist/headers/WHOIS.d.ts +37 -0
- package/dist/headers/WHOIS.js +126 -0
- package/dist/headers/WSDiscovery.d.ts +29 -0
- package/dist/headers/WSDiscovery.js +118 -0
- package/dist/headers/WakeOnLAN.d.ts +30 -0
- package/dist/headers/WakeOnLAN.js +126 -0
- package/dist/headers/WebSocket.d.ts +26 -0
- package/dist/headers/WebSocket.js +173 -0
- package/dist/headers/WireGuard.d.ts +38 -0
- package/dist/headers/WireGuard.js +216 -0
- package/dist/headers/XMPP.d.ts +37 -0
- package/dist/headers/XMPP.js +149 -0
- package/dist/headers/Zabbix.d.ts +35 -0
- package/dist/headers/Zabbix.js +153 -0
- package/dist/headers/cms/AcsiPdu.d.ts +45 -0
- package/dist/headers/cms/AcsiPdu.js +112 -0
- package/dist/headers/cms/PerDecoder.d.ts +68 -0
- package/dist/headers/cms/PerDecoder.js +211 -0
- package/dist/headers/cms/PerReader.d.ts +64 -0
- package/dist/headers/cms/PerReader.js +155 -0
- package/dist/helper/BufferToHex.d.ts +5 -0
- package/dist/helper/BufferToHex.js +10 -0
- package/dist/helper/BufferToIP.d.ts +12 -0
- package/dist/helper/BufferToIP.js +23 -0
- package/dist/helper/BufferToNumber.d.ts +18 -0
- package/dist/helper/BufferToNumber.js +47 -0
- package/dist/helper/HexToBuffer.d.ts +7 -0
- package/dist/helper/HexToBuffer.js +27 -0
- package/dist/helper/HexToNumber.d.ts +18 -0
- package/dist/helper/HexToNumber.js +48 -0
- package/dist/helper/IPToBuffer.d.ts +12 -0
- package/dist/helper/IPToBuffer.js +34 -0
- package/dist/helper/NumberToBERBuffer.d.ts +18 -0
- package/dist/helper/NumberToBERBuffer.js +31 -0
- package/dist/helper/NumberToBERHex.d.ts +18 -0
- package/dist/helper/NumberToBERHex.js +52 -0
- package/dist/helper/NumberToBuffer.d.ts +18 -0
- package/dist/helper/NumberToBuffer.js +38 -0
- package/dist/helper/NumberToHex.d.ts +18 -0
- package/dist/helper/NumberToHex.js +35 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +113 -0
- package/dist/lib/FlexibleObject.d.ts +27 -0
- package/dist/lib/FlexibleObject.js +113 -0
- package/dist/lib/GetBERIntegerLengthFromBuffer.d.ts +6 -0
- package/dist/lib/GetBERIntegerLengthFromBuffer.js +16 -0
- package/dist/lib/ProcessPacketPostHandlers.d.ts +13 -0
- package/dist/lib/ProcessPacketPostHandlers.js +53 -0
- package/dist/lib/SortPostHandlers.d.ts +7 -0
- package/dist/lib/SortPostHandlers.js +11 -0
- package/dist/lib/StringContentEncodingEnum.d.ts +10 -0
- package/dist/lib/StringContentEncodingEnum.js +14 -0
- package/dist/schema/ProtocolFieldJSONSchema.d.ts +35 -0
- package/dist/schema/ProtocolFieldJSONSchema.js +2 -0
- package/dist/schema/ProtocolFieldJSONSchemaDefinition.d.ts +2 -0
- package/dist/schema/ProtocolFieldJSONSchemaDefinition.js +2 -0
- package/dist/schema/ProtocolJSONSchema.d.ts +32 -0
- package/dist/schema/ProtocolJSONSchema.js +2 -0
- package/dist/types/CodecData.d.ts +7 -0
- package/dist/types/CodecData.js +2 -0
- package/dist/types/CodecDecodeResult.d.ts +10 -0
- package/dist/types/CodecDecodeResult.js +2 -0
- package/dist/types/CodecEncodeInput.d.ts +2 -0
- package/dist/types/CodecEncodeInput.js +2 -0
- package/dist/types/CodecEncodeResult.d.ts +5 -0
- package/dist/types/CodecEncodeResult.js +2 -0
- package/dist/types/CodecErrorInfo.d.ts +5 -0
- package/dist/types/CodecErrorInfo.js +2 -0
- package/dist/types/CodecModule.d.ts +2 -0
- package/dist/types/CodecModule.js +2 -0
- package/dist/types/CodecModuleConstructor.d.ts +2 -0
- package/dist/types/CodecModuleConstructor.js +2 -0
- package/dist/types/CodecSchema.d.ts +6 -0
- package/dist/types/CodecSchema.js +2 -0
- package/dist/types/DemuxProducer.d.ts +23 -0
- package/dist/types/DemuxProducer.js +2 -0
- package/dist/types/Dissection.d.ts +23 -0
- package/dist/types/Dissection.js +2 -0
- package/dist/types/HeaderTreeNode.d.ts +4 -0
- package/dist/types/HeaderTreeNode.js +2 -0
- package/dist/types/LayerGraph.d.ts +32 -0
- package/dist/types/LayerGraph.js +2 -0
- package/dist/types/PostHandlerItem.d.ts +4 -0
- package/dist/types/PostHandlerItem.js +2 -0
- package/package.json +141 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GELF = 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
|
+
* GELF — Graylog Extended Log Format, the log-shipping payload Graylog and its inputs exchange over
|
|
12
|
+
* UDP port 12201. A GELF UDP datagram carries a single log message in one of three on-wire forms, told
|
|
13
|
+
* apart by the first bytes of the payload:
|
|
14
|
+
*
|
|
15
|
+
* - Chunked (magic 0x1E0F): a large message split across datagrams. The 12-byte chunk header is the
|
|
16
|
+
* 2-byte magic, an 8-byte Message ID (shared by all chunks of one message), a 1-byte Sequence Number
|
|
17
|
+
* (this chunk's index) and a 1-byte Sequence Count (total chunks), followed by this chunk's slice of
|
|
18
|
+
* the (possibly compressed) message. The receiver reassembles the slices by Message ID / Sequence.
|
|
19
|
+
* - GZIP (magic 0x1F8B): the whole datagram is a single gzip-compressed GELF JSON document.
|
|
20
|
+
* - Uncompressed: anything else — the datagram is the GELF JSON document as UTF-8 text (a `{ ... }`
|
|
21
|
+
* object). (A zlib-deflated document, magic 0x78, also falls here and is kept verbatim.)
|
|
22
|
+
*
|
|
23
|
+
* This is the minimal faithful slice: the form is detected from the leading magic and the chunk header
|
|
24
|
+
* is structured (magic / messageId / sequenceNumber / sequenceCount + chunk `data` hex); the gzip body
|
|
25
|
+
* and the uncompressed/zlib body are opaque here and kept verbatim (`payload` / `message` hex) — the
|
|
26
|
+
* chunk-reassembly, gunzip and JSON decoding are a later enrichment layered on top of this byte-perfect
|
|
27
|
+
* base. Everything is bounded by the enclosing UDP payload length so a trailing FCS/padding is not
|
|
28
|
+
* absorbed. Nothing is recomputed on encode (the Sequence Count is honored, not derived), so a
|
|
29
|
+
* well-formed datagram of any form round-trips byte-for-byte. `form` is a decode-time discriminant that
|
|
30
|
+
* writes no bytes; on encode it is honored when supplied, else inferred from which fields are present.
|
|
31
|
+
*/
|
|
32
|
+
class GELF extends BaseHeader_1.BaseHeader {
|
|
33
|
+
constructor() {
|
|
34
|
+
super(...arguments);
|
|
35
|
+
this.id = 'gelf';
|
|
36
|
+
this.name = 'Graylog Extended Log Format';
|
|
37
|
+
this.nickname = 'GELF';
|
|
38
|
+
this.matchKeys = ['udpport:12201'];
|
|
39
|
+
//A leaf header — chunk reassembly, gunzip and GELF JSON decoding are deferred to a later slice.
|
|
40
|
+
this.demuxProducers = [];
|
|
41
|
+
}
|
|
42
|
+
static #schemaCache;
|
|
43
|
+
get SCHEMA() {
|
|
44
|
+
return (GELF.#schemaCache ??= GELF.#buildSchema());
|
|
45
|
+
}
|
|
46
|
+
/** End of this datagram within the captured bytes: bounded by the parent UDP payload (udp.length − 8). */
|
|
47
|
+
#payloadEnd() {
|
|
48
|
+
let end = this.packet.length - this.startPos;
|
|
49
|
+
const prev = this.prevCodecModule;
|
|
50
|
+
if (prev && prev.id === 'udp') {
|
|
51
|
+
const udpLength = prev.instance.length.getValue(0);
|
|
52
|
+
if (udpLength >= 8 && udpLength - 8 < end)
|
|
53
|
+
end = udpLength - 8;
|
|
54
|
+
}
|
|
55
|
+
return end < 0 ? 0 : end;
|
|
56
|
+
}
|
|
57
|
+
/** Detect the on-wire form from the leading magic bytes of the payload. */
|
|
58
|
+
#detectForm() {
|
|
59
|
+
const end = this.#payloadEnd();
|
|
60
|
+
if (end < 2)
|
|
61
|
+
return 'uncompressed';
|
|
62
|
+
const lead = this.readBytes(0, 2, true);
|
|
63
|
+
if (lead[0] === 0x1e && lead[1] === 0x0f)
|
|
64
|
+
return 'chunked';
|
|
65
|
+
if (lead[0] === 0x1f && lead[1] === 0x8b)
|
|
66
|
+
return 'gzip';
|
|
67
|
+
return 'uncompressed';
|
|
68
|
+
}
|
|
69
|
+
static #buildSchema() {
|
|
70
|
+
return {
|
|
71
|
+
type: 'object',
|
|
72
|
+
summary: 'GELF ${form}',
|
|
73
|
+
properties: {
|
|
74
|
+
//Discriminant chosen at decode from the leading magic (chunked / gzip / uncompressed).
|
|
75
|
+
//It writes no bytes; on encode it is honored when supplied, else inferred from which
|
|
76
|
+
//form-specific fields are present (a chunk has a Message ID; a gzip form has payload).
|
|
77
|
+
//No enum: it never gates re-encoding of a decoded value.
|
|
78
|
+
form: {
|
|
79
|
+
type: 'string',
|
|
80
|
+
label: 'Form',
|
|
81
|
+
decode: function () {
|
|
82
|
+
this.instance.form.setValue(this.#detectForm());
|
|
83
|
+
},
|
|
84
|
+
encode: function () {
|
|
85
|
+
let form = this.instance.form.getValue();
|
|
86
|
+
if (!form) {
|
|
87
|
+
if (this.instance.messageId.getValue() !== undefined)
|
|
88
|
+
form = 'chunked';
|
|
89
|
+
else if (this.instance.payload.getValue() !== undefined)
|
|
90
|
+
form = 'gzip';
|
|
91
|
+
else
|
|
92
|
+
form = 'uncompressed';
|
|
93
|
+
}
|
|
94
|
+
this.instance.form.setValue(form);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
//Chunked form (magic 0x1E0F). The 12-byte chunk header, structured. Each field acts only
|
|
98
|
+
//when the form is chunked; otherwise it stays unset so it neither decodes phantom values
|
|
99
|
+
//nor writes bytes for the gzip/uncompressed forms.
|
|
100
|
+
magic: {
|
|
101
|
+
type: 'string',
|
|
102
|
+
label: 'Magic',
|
|
103
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
104
|
+
decode: function () {
|
|
105
|
+
if (this.instance.form.getValue() !== 'chunked')
|
|
106
|
+
return;
|
|
107
|
+
this.instance.magic.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(0, 2)));
|
|
108
|
+
},
|
|
109
|
+
encode: function () {
|
|
110
|
+
if (this.instance.form.getValue() !== 'chunked')
|
|
111
|
+
return;
|
|
112
|
+
//Honor a supplied magic verbatim (a crafted chunk may lie); else the GELF 0x1E0F.
|
|
113
|
+
this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(this.instance.magic.getValue('1e0f')));
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
//8-byte Message ID shared by every chunk of one logical message.
|
|
117
|
+
messageId: {
|
|
118
|
+
type: 'string',
|
|
119
|
+
label: 'Message ID',
|
|
120
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
121
|
+
decode: function () {
|
|
122
|
+
if (this.instance.form.getValue() !== 'chunked')
|
|
123
|
+
return;
|
|
124
|
+
this.instance.messageId.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(2, 8)));
|
|
125
|
+
},
|
|
126
|
+
encode: function () {
|
|
127
|
+
if (this.instance.form.getValue() !== 'chunked')
|
|
128
|
+
return;
|
|
129
|
+
this.writeBytes(2, (0, HexToBuffer_1.HexToBuffer)(this.instance.messageId.getValue('0000000000000000')));
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
//This chunk's index (0-based) among the sequence.
|
|
133
|
+
sequenceNumber: {
|
|
134
|
+
type: 'integer',
|
|
135
|
+
label: 'Sequence Number',
|
|
136
|
+
minimum: 0,
|
|
137
|
+
maximum: 255,
|
|
138
|
+
decode: function () {
|
|
139
|
+
if (this.instance.form.getValue() !== 'chunked')
|
|
140
|
+
return;
|
|
141
|
+
this.instance.sequenceNumber.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(10, 1)));
|
|
142
|
+
},
|
|
143
|
+
encode: function () {
|
|
144
|
+
if (this.instance.form.getValue() !== 'chunked')
|
|
145
|
+
return;
|
|
146
|
+
const node = this.instance.sequenceNumber;
|
|
147
|
+
let value = node.getValue(0);
|
|
148
|
+
if (value > 255) {
|
|
149
|
+
this.recordError(node.getPath(), 'Maximum value is 255');
|
|
150
|
+
value = 255;
|
|
151
|
+
}
|
|
152
|
+
if (value < 0) {
|
|
153
|
+
this.recordError(node.getPath(), 'Minimum value is 0');
|
|
154
|
+
value = 0;
|
|
155
|
+
}
|
|
156
|
+
node.setValue(value);
|
|
157
|
+
this.writeBytes(10, (0, NumberToBuffer_1.UInt8ToBuffer)(value));
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
//Total number of chunks in the sequence. Honored verbatim (not derived) — a crafted chunk
|
|
161
|
+
//may carry any count.
|
|
162
|
+
sequenceCount: {
|
|
163
|
+
type: 'integer',
|
|
164
|
+
label: 'Sequence Count',
|
|
165
|
+
minimum: 0,
|
|
166
|
+
maximum: 255,
|
|
167
|
+
decode: function () {
|
|
168
|
+
if (this.instance.form.getValue() !== 'chunked')
|
|
169
|
+
return;
|
|
170
|
+
this.instance.sequenceCount.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(11, 1)));
|
|
171
|
+
},
|
|
172
|
+
encode: function () {
|
|
173
|
+
if (this.instance.form.getValue() !== 'chunked')
|
|
174
|
+
return;
|
|
175
|
+
const node = this.instance.sequenceCount;
|
|
176
|
+
let value = node.getValue(0);
|
|
177
|
+
if (value > 255) {
|
|
178
|
+
this.recordError(node.getPath(), 'Maximum value is 255');
|
|
179
|
+
value = 255;
|
|
180
|
+
}
|
|
181
|
+
if (value < 0) {
|
|
182
|
+
this.recordError(node.getPath(), 'Minimum value is 0');
|
|
183
|
+
value = 0;
|
|
184
|
+
}
|
|
185
|
+
node.setValue(value);
|
|
186
|
+
this.writeBytes(11, (0, NumberToBuffer_1.UInt8ToBuffer)(value));
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
//This chunk's slice of the (possibly compressed) message, after the 12-byte chunk header.
|
|
190
|
+
//Opaque here (reassembly is deferred); kept verbatim, bounded by the UDP payload.
|
|
191
|
+
data: {
|
|
192
|
+
type: 'string',
|
|
193
|
+
label: 'Chunk Data',
|
|
194
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
195
|
+
decode: function () {
|
|
196
|
+
if (this.instance.form.getValue() !== 'chunked')
|
|
197
|
+
return;
|
|
198
|
+
const end = this.#payloadEnd();
|
|
199
|
+
this.instance.data.setValue(end > 12 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(12, end - 12)) : '');
|
|
200
|
+
},
|
|
201
|
+
encode: function () {
|
|
202
|
+
if (this.instance.form.getValue() !== 'chunked')
|
|
203
|
+
return;
|
|
204
|
+
const data = this.instance.data.getValue('');
|
|
205
|
+
if (data)
|
|
206
|
+
this.writeBytes(12, (0, HexToBuffer_1.HexToBuffer)(data));
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
//GZIP form (magic 0x1F8B): the whole gzip-compressed GELF document, opaque, kept verbatim
|
|
210
|
+
//(magic included) and bounded by the UDP payload.
|
|
211
|
+
payload: {
|
|
212
|
+
type: 'string',
|
|
213
|
+
label: 'GZIP Payload',
|
|
214
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
215
|
+
decode: function () {
|
|
216
|
+
if (this.instance.form.getValue() !== 'gzip')
|
|
217
|
+
return;
|
|
218
|
+
const end = this.#payloadEnd();
|
|
219
|
+
this.instance.payload.setValue(end > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(0, end)) : '');
|
|
220
|
+
},
|
|
221
|
+
encode: function () {
|
|
222
|
+
if (this.instance.form.getValue() !== 'gzip')
|
|
223
|
+
return;
|
|
224
|
+
const payload = this.instance.payload.getValue('');
|
|
225
|
+
if (payload)
|
|
226
|
+
this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(payload));
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
//Uncompressed form: the GELF JSON document as text (or a zlib-deflated body). Kept verbatim
|
|
230
|
+
//as hex and bounded by the UDP payload, so any body round-trips byte-for-byte.
|
|
231
|
+
message: {
|
|
232
|
+
type: 'string',
|
|
233
|
+
label: 'Message',
|
|
234
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
235
|
+
decode: function () {
|
|
236
|
+
if (this.instance.form.getValue() !== 'uncompressed')
|
|
237
|
+
return;
|
|
238
|
+
const end = this.#payloadEnd();
|
|
239
|
+
this.instance.message.setValue(end > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(0, end)) : '');
|
|
240
|
+
},
|
|
241
|
+
encode: function () {
|
|
242
|
+
if (this.instance.form.getValue() !== 'uncompressed')
|
|
243
|
+
return;
|
|
244
|
+
const message = this.instance.message.getValue('');
|
|
245
|
+
if (message)
|
|
246
|
+
this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(message));
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
match() {
|
|
253
|
+
//GELF rides on UDP well-known port 12201 (the matchKeys bucket selects it). The uncompressed
|
|
254
|
+
//form is arbitrary JSON with no fixed magic, so the port is the signature; require at least one
|
|
255
|
+
//payload byte so an empty datagram falls through to raw rather than claiming an empty layer.
|
|
256
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'udp')
|
|
257
|
+
return false;
|
|
258
|
+
return this.#payloadEnd() >= 1;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
exports.GELF = GELF;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* GENEVE — Generic Network Virtualization Encapsulation (RFC 8926), a network-virtualization overlay on
|
|
6
|
+
* UDP port 6081. The 8-byte base header is: Version(2 bits) + Opt Len(6 bits, options length in 4-byte
|
|
7
|
+
* units), O(OAM) + C(Critical) + 6 reserved bits, a 16-bit Protocol Type (the EtherType of the payload:
|
|
8
|
+
* 0x6558 = Transparent Ethernet Bridging, 0x0800 = IPv4, 0x86dd = IPv6), a 24-bit VNI, and a reserved
|
|
9
|
+
* byte. It is followed by Opt Len*4 bytes of variable-length options, then the inner frame.
|
|
10
|
+
*
|
|
11
|
+
* Like VXLAN, this codec decodes only its own header + options (headerLength = 8 + Opt Len*4); the inner
|
|
12
|
+
* frame is left to the codec's recursion. Protocol Type is declared as an `ethertype` demux producer so
|
|
13
|
+
* an inner IPv4/IPv6 packet is dispatched to IPv4/IPv6 (which accept a 'geneve' tunnel parent), while a
|
|
14
|
+
* Transparent-Ethernet-Bridging (0x6558) payload falls through to EthernetII (which already accepts a
|
|
15
|
+
* 'geneve' parent). The whole nested packet round-trips byte-for-byte layer by layer.
|
|
16
|
+
*/
|
|
17
|
+
export declare class GENEVE extends BaseHeader {
|
|
18
|
+
#private;
|
|
19
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly nickname: string;
|
|
23
|
+
readonly matchKeys: string[];
|
|
24
|
+
match(): boolean;
|
|
25
|
+
readonly demuxProducers: DemuxProducer[];
|
|
26
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GENEVE = 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
|
+
* GENEVE — Generic Network Virtualization Encapsulation (RFC 8926), a network-virtualization overlay on
|
|
12
|
+
* UDP port 6081. The 8-byte base header is: Version(2 bits) + Opt Len(6 bits, options length in 4-byte
|
|
13
|
+
* units), O(OAM) + C(Critical) + 6 reserved bits, a 16-bit Protocol Type (the EtherType of the payload:
|
|
14
|
+
* 0x6558 = Transparent Ethernet Bridging, 0x0800 = IPv4, 0x86dd = IPv6), a 24-bit VNI, and a reserved
|
|
15
|
+
* byte. It is followed by Opt Len*4 bytes of variable-length options, then the inner frame.
|
|
16
|
+
*
|
|
17
|
+
* Like VXLAN, this codec decodes only its own header + options (headerLength = 8 + Opt Len*4); the inner
|
|
18
|
+
* frame is left to the codec's recursion. Protocol Type is declared as an `ethertype` demux producer so
|
|
19
|
+
* an inner IPv4/IPv6 packet is dispatched to IPv4/IPv6 (which accept a 'geneve' tunnel parent), while a
|
|
20
|
+
* Transparent-Ethernet-Bridging (0x6558) payload falls through to EthernetII (which already accepts a
|
|
21
|
+
* 'geneve' parent). The whole nested packet round-trips byte-for-byte layer by layer.
|
|
22
|
+
*/
|
|
23
|
+
class GENEVE extends BaseHeader_1.BaseHeader {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
this.id = 'geneve';
|
|
27
|
+
this.name = 'Generic Network Virtualization Encapsulation';
|
|
28
|
+
this.nickname = 'GENEVE';
|
|
29
|
+
this.matchKeys = ['udpport:6081'];
|
|
30
|
+
//Protocol Type is an EtherType; declaring it in the 'ethertype' namespace dispatches the inner IPv4/
|
|
31
|
+
//IPv6 packet to the O(1) bucket (which accepts a 'geneve' parent), while a 0x6558 Ethernet payload
|
|
32
|
+
//falls through to EthernetII's tunnel-aware match.
|
|
33
|
+
this.demuxProducers = [{ field: 'protocolType', namespace: 'ethertype', kind: 'string' }];
|
|
34
|
+
}
|
|
35
|
+
static #schemaCache;
|
|
36
|
+
get SCHEMA() {
|
|
37
|
+
return (GENEVE.#schemaCache ??= GENEVE.#buildSchema());
|
|
38
|
+
}
|
|
39
|
+
/** The payload length bounded by the UDP datagram (so a retained FCS/padding is not absorbed). */
|
|
40
|
+
#available() {
|
|
41
|
+
let available = this.packet.length - this.startPos;
|
|
42
|
+
if (this.prevCodecModule && this.prevCodecModule.id === 'udp') {
|
|
43
|
+
const udpLength = this.prevCodecModule.instance.length.getValue(0);
|
|
44
|
+
if (udpLength >= 8 && udpLength - 8 < available)
|
|
45
|
+
available = udpLength - 8;
|
|
46
|
+
}
|
|
47
|
+
return available < 0 ? 0 : available;
|
|
48
|
+
}
|
|
49
|
+
static #buildSchema() {
|
|
50
|
+
return {
|
|
51
|
+
type: 'object',
|
|
52
|
+
summary: 'GENEVE vni=${vni} proto=${protocolType}',
|
|
53
|
+
properties: {
|
|
54
|
+
version: {
|
|
55
|
+
type: 'integer', label: 'Version', minimum: 0, maximum: 3,
|
|
56
|
+
decode: function () { this.instance.version.setValue(this.readBits(0, 1, 0, 2)); },
|
|
57
|
+
encode: function () { this.writeBits(0, 1, 0, 2, this.instance.version.getValue(0)); }
|
|
58
|
+
},
|
|
59
|
+
//Opt Len (options length in 4-byte units) — metadata; the value is derived from the
|
|
60
|
+
//options list by the `body` master on encode and read from the wire on decode.
|
|
61
|
+
optLen: { type: 'integer', label: 'Option Length', minimum: 0, maximum: 63 },
|
|
62
|
+
oam: {
|
|
63
|
+
type: 'boolean', label: 'OAM',
|
|
64
|
+
decode: function () { this.instance.oam.setValue(!!this.readBits(1, 1, 0, 1)); },
|
|
65
|
+
encode: function () {
|
|
66
|
+
const oam = !!this.instance.oam.getValue();
|
|
67
|
+
this.instance.oam.setValue(oam);
|
|
68
|
+
this.writeBits(1, 1, 0, 1, oam ? 1 : 0);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
critical: {
|
|
72
|
+
type: 'boolean', label: 'Critical Options Present',
|
|
73
|
+
decode: function () { this.instance.critical.setValue(!!this.readBits(1, 1, 1, 1)); },
|
|
74
|
+
encode: function () {
|
|
75
|
+
const critical = !!this.instance.critical.getValue();
|
|
76
|
+
this.instance.critical.setValue(critical);
|
|
77
|
+
this.writeBits(1, 1, 1, 1, critical ? 1 : 0);
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
//Reserved 6 bits of byte 1, kept verbatim for a byte-perfect round-trip.
|
|
81
|
+
reserved1: {
|
|
82
|
+
type: 'integer', label: 'Reserved', minimum: 0, maximum: 63, hidden: true,
|
|
83
|
+
decode: function () { this.instance.reserved1.setValue(this.readBits(1, 1, 2, 6)); },
|
|
84
|
+
encode: function () { this.writeBits(1, 1, 2, 6, this.instance.reserved1.getValue(0)); }
|
|
85
|
+
},
|
|
86
|
+
//Protocol Type is the EtherType of the inner frame — stored as a lowercase hex string
|
|
87
|
+
//(like eth.etherType) so it can drive the `ethertype` demux dimension to the inner codec.
|
|
88
|
+
protocolType: {
|
|
89
|
+
type: 'string', label: 'Protocol Type', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
90
|
+
decode: function () { this.instance.protocolType.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(2, 2))); },
|
|
91
|
+
encode: function () {
|
|
92
|
+
const hex = this.instance.protocolType.getValue('6558');
|
|
93
|
+
this.writeBytes(2, (0, HexToBuffer_1.HexToBuffer)(hex.padStart(4, '0').slice(-4)));
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
vni: {
|
|
97
|
+
type: 'integer', label: 'VNI', minimum: 0, maximum: 16777215,
|
|
98
|
+
decode: function () { this.instance.vni.setValue(this.readBits(4, 3, 0, 24)); },
|
|
99
|
+
encode: function () {
|
|
100
|
+
let vni = this.instance.vni.getValue(0);
|
|
101
|
+
if (vni > 16777215) {
|
|
102
|
+
this.recordError(this.instance.vni.getPath(), 'Maximum value is 16777215');
|
|
103
|
+
vni = 16777215;
|
|
104
|
+
}
|
|
105
|
+
if (vni < 0) {
|
|
106
|
+
this.recordError(this.instance.vni.getPath(), 'Minimum value is 0');
|
|
107
|
+
vni = 0;
|
|
108
|
+
}
|
|
109
|
+
this.instance.vni.setValue(vni);
|
|
110
|
+
this.writeBits(4, 3, 0, 24, vni);
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
//Reserved byte 7, kept verbatim.
|
|
114
|
+
reserved2: {
|
|
115
|
+
type: 'string', label: 'Reserved', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX, hidden: true,
|
|
116
|
+
decode: function () { this.instance.reserved2.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(7, 1))); },
|
|
117
|
+
encode: function () { this.writeBytes(7, (0, HexToBuffer_1.HexToBuffer)(this.instance.reserved2.getValue('00'))); }
|
|
118
|
+
},
|
|
119
|
+
options: {
|
|
120
|
+
type: 'array', label: 'Options',
|
|
121
|
+
items: {
|
|
122
|
+
type: 'object', label: 'Option',
|
|
123
|
+
properties: {
|
|
124
|
+
optionClass: { type: 'integer', label: 'Option Class', minimum: 0, maximum: 65535 },
|
|
125
|
+
type: { type: 'integer', label: 'Type', minimum: 0, maximum: 255 },
|
|
126
|
+
critical: { type: 'boolean', label: 'Critical' },
|
|
127
|
+
reserved: { type: 'integer', label: 'Reserved', minimum: 0, maximum: 7, hidden: true },
|
|
128
|
+
data: { type: 'string', label: 'Data', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
//Any bytes in the option region the option walk could not structure (malformed) are kept
|
|
133
|
+
//verbatim so the header always round-trips and the inner frame starts at the right offset.
|
|
134
|
+
optionsTail: { type: 'string', label: 'Options Tail', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX, hidden: true },
|
|
135
|
+
//Master field: parses/emits the Opt Len field and the option region (runs after the fixed
|
|
136
|
+
//header fields — property order — so the fixed bytes are already read/written).
|
|
137
|
+
body: {
|
|
138
|
+
type: 'string', label: 'Body', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX, hidden: true,
|
|
139
|
+
decode: function () {
|
|
140
|
+
const available = this.#available();
|
|
141
|
+
const optLen = this.readBits(0, 1, 2, 6);
|
|
142
|
+
this.instance.optLen.setValue(optLen);
|
|
143
|
+
const end = Math.min(8 + optLen * 4, available);
|
|
144
|
+
let offset = 8;
|
|
145
|
+
const options = [];
|
|
146
|
+
while (offset + 4 <= end) {
|
|
147
|
+
const optionClass = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset, 2));
|
|
148
|
+
const type = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(offset + 2, 1));
|
|
149
|
+
const b3 = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(offset + 3, 1));
|
|
150
|
+
const reserved = (b3 >> 5) & 0x07;
|
|
151
|
+
const dataBytes = (b3 & 0x1f) * 4;
|
|
152
|
+
if (offset + 4 + dataBytes > end)
|
|
153
|
+
break;
|
|
154
|
+
options.push({
|
|
155
|
+
optionClass: optionClass,
|
|
156
|
+
type: type,
|
|
157
|
+
critical: !!(type & 0x80),
|
|
158
|
+
reserved: reserved,
|
|
159
|
+
data: dataBytes > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset + 4, dataBytes)) : ''
|
|
160
|
+
});
|
|
161
|
+
offset += 4 + dataBytes;
|
|
162
|
+
}
|
|
163
|
+
this.instance.options.setValue(options);
|
|
164
|
+
//Consume the rest of the (optLen-defined) option region verbatim so headerLength
|
|
165
|
+
//= 8 + optLen*4 and the inner frame is dispatched at the right offset.
|
|
166
|
+
this.instance.optionsTail.setValue(offset < end ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset, end - offset)) : '');
|
|
167
|
+
},
|
|
168
|
+
encode: function () {
|
|
169
|
+
let offset = 8;
|
|
170
|
+
const options = this.instance.options.getValue([]);
|
|
171
|
+
if (options)
|
|
172
|
+
for (let i = 0; i < options.length; i++) {
|
|
173
|
+
const option = options[i];
|
|
174
|
+
const data = (0, HexToBuffer_1.HexToBuffer)(option.data ? option.data : '');
|
|
175
|
+
//Option data is a 5-bit length in 4-byte units, so it must be a multiple of 4
|
|
176
|
+
//bytes and at most 124 — record rather than silently wrap a malformed length.
|
|
177
|
+
if (data.length % 4 !== 0 || data.length > 124)
|
|
178
|
+
this.recordError(this.instance.options.getPath() + `[${i}].data`, 'Option data must be a multiple of 4 bytes and at most 124');
|
|
179
|
+
this.writeBytes(offset, (0, NumberToBuffer_1.UInt16ToBuffer)(option.optionClass ? option.optionClass : 0));
|
|
180
|
+
offset += 2;
|
|
181
|
+
this.writeBytes(offset, Buffer.from([(option.type ? option.type : 0) & 0xff]));
|
|
182
|
+
offset += 1;
|
|
183
|
+
const reserved = (option.reserved ? option.reserved : 0) & 0x07;
|
|
184
|
+
this.writeBytes(offset, Buffer.from([(reserved << 5) | ((data.length / 4) & 0x1f)]));
|
|
185
|
+
offset += 1;
|
|
186
|
+
if (data.length) {
|
|
187
|
+
this.writeBytes(offset, data);
|
|
188
|
+
offset += data.length;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const tail = (0, HexToBuffer_1.HexToBuffer)(this.instance.optionsTail.getValue(''));
|
|
192
|
+
if (tail.length) {
|
|
193
|
+
this.writeBytes(offset, tail);
|
|
194
|
+
offset += tail.length;
|
|
195
|
+
}
|
|
196
|
+
//Opt Len = the whole option region in 4-byte units.
|
|
197
|
+
this.writeBits(0, 1, 2, 6, ((offset - 8) / 4) & 0x3f);
|
|
198
|
+
this.instance.optLen.setValue((offset - 8) / 4);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
match() {
|
|
205
|
+
//Require the 8-byte base header within the UDP payload (see RADIUS: bound by payload).
|
|
206
|
+
return !!this.prevCodecModule && this.prevCodecModule.id === 'udp' && this.#available() >= 8;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
exports.GENEVE = GENEVE;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* GE-SRTP — GE Fanuc (GE Intelligent Platforms) Service Request Transport Protocol, TCP port 18245.
|
|
6
|
+
* The proprietary Ethernet protocol spoken by GE Series 90 / PACSystems / VersaMax PLCs. GE publishes
|
|
7
|
+
* no specification; the on-wire layout used here is the community reverse-engineering (Collin Matthews'
|
|
8
|
+
* `TheMadHatt3r/ge-ethernet-SRTP`; the New Haven "Leveraging the SRTP protocol …" paper).
|
|
9
|
+
*
|
|
10
|
+
* Every message begins with a fixed 56-byte header. Only a subset of those 56 bytes has a confidently
|
|
11
|
+
* documented meaning — the message Type, sequence numbers, a controller timestamp, the message-type
|
|
12
|
+
* byte, the mailbox source/destination, packet counters, and the service-request block (Service Request
|
|
13
|
+
* Code, segment selector / memory type, memory offset, data length). Everything else in the header is
|
|
14
|
+
* "reserved/unknown" and is kept verbatim as hex so it round-trips untouched. A READ request is exactly
|
|
15
|
+
* the 56-byte header; a response carries the read data after the header, so any bytes captured past the
|
|
16
|
+
* 56-byte header are kept verbatim as `payload` hex (bounded by the captured TCP payload).
|
|
17
|
+
*
|
|
18
|
+
* ⚠️ The two-octet memory-offset and data-length fields are LITTLE-ENDIAN (segment selector / SNP
|
|
19
|
+
* addressing convention: LSB first). There is no little-endian helper in this codebase, so those uint16
|
|
20
|
+
* fields are read/written byte-by-byte in their closures. Every numeric field is a clamped uint (never a
|
|
21
|
+
* hard enum) so any value that decodes off the wire re-encodes without an Ajv rejection.
|
|
22
|
+
*/
|
|
23
|
+
export declare class GESRTP extends BaseHeader {
|
|
24
|
+
#private;
|
|
25
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly nickname: string;
|
|
29
|
+
readonly matchKeys: string[];
|
|
30
|
+
match(): boolean;
|
|
31
|
+
readonly demuxProducers: DemuxProducer[];
|
|
32
|
+
}
|