@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,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XMPP = 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
|
+
* XMPP — the Extensible Messaging and Presence Protocol (RFC 6120), the XML-streaming protocol behind
|
|
10
|
+
* Jabber and many IM/presence systems. It rides over TCP: client-to-server on port 5222, server-to-server
|
|
11
|
+
* on port 5269. Unlike a request/response protocol, an XMPP session is a pair of open-ended XML streams —
|
|
12
|
+
* each peer opens a `<stream:stream>` root element and then emits a sequence of "stanzas" (`<message>`,
|
|
13
|
+
* `<presence>`, `<iq>`) as child elements until the stream is closed with `</stream:stream>`. A single
|
|
14
|
+
* captured packet therefore carries an arbitrary FRAGMENT of that XML text: the stream preamble
|
|
15
|
+
* (`<?xml version='1.0'?><stream:stream …>`), one or more whole stanzas, or even a partial element split
|
|
16
|
+
* across TCP segments.
|
|
17
|
+
*
|
|
18
|
+
* Like SIP and HTTP, the payload is text whose full internal structure (namespaces, arbitrary nested
|
|
19
|
+
* elements, significant whitespace, entity encoding) is far richer than a form needs, and byte ordering /
|
|
20
|
+
* whitespace is significant to the XML stream parser on the other end. So the ENTIRE raw payload is kept
|
|
21
|
+
* verbatim as the authoritative `message` field (hex) and re-emitted untouched; only lightweight
|
|
22
|
+
* display-only metadata (the first element's tag name, whether it is a stream header, whether an XML
|
|
23
|
+
* declaration is present) is parsed on decode. Encode never reconstructs the XML from the metadata — it
|
|
24
|
+
* writes `message` back byte-for-byte — so any conformant (or even malformed) XMPP fragment round-trips
|
|
25
|
+
* exactly.
|
|
26
|
+
*
|
|
27
|
+
* Note: XMPP stanzas can span multiple TCP segments and TLS/SASL negotiation (STARTTLS) switches the
|
|
28
|
+
* stream to ciphertext mid-session; reassembly and post-STARTTLS decryption are out of scope. This
|
|
29
|
+
* single-segment codec keeps whatever XML bytes are present in the current segment verbatim, which is
|
|
30
|
+
* byte-perfect for the single-packet case.
|
|
31
|
+
*/
|
|
32
|
+
class XMPP extends BaseHeader_1.BaseHeader {
|
|
33
|
+
constructor() {
|
|
34
|
+
super(...arguments);
|
|
35
|
+
this.id = 'xmpp';
|
|
36
|
+
this.name = 'Extensible Messaging and Presence Protocol';
|
|
37
|
+
this.nickname = 'XMPP';
|
|
38
|
+
//Client-to-server (5222) and server-to-server (5269) TCP ports. Port-bucket dispatch only, NO
|
|
39
|
+
//heuristicFallback: an XML fragment beginning with '<' is far too weak a signature to claim arbitrary
|
|
40
|
+
//TCP traffic off these ports, so XMPP is recognized solely on 5222/5269 (matching the SIP precedent
|
|
41
|
+
//for a generic text protocol).
|
|
42
|
+
this.matchKeys = ['tcpport:5222', 'tcpport:5269'];
|
|
43
|
+
//A leaf header — the XML stanza tree and the stream session it belongs to are a higher-layer concern.
|
|
44
|
+
this.demuxProducers = [];
|
|
45
|
+
}
|
|
46
|
+
static #schemaCache;
|
|
47
|
+
get SCHEMA() {
|
|
48
|
+
return (XMPP.#schemaCache ??= XMPP.#buildSchema());
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Bytes of this header: XMPP rides on TCP, which has no per-message length. Bound the payload by the
|
|
52
|
+
* enclosing IP datagram (IP total length) so a short XML fragment does not absorb Ethernet minimum-frame
|
|
53
|
+
* padding; fall back to the rest of the captured segment when no IP layer is present. Segment reassembly
|
|
54
|
+
* is out of scope (see class doc).
|
|
55
|
+
*/
|
|
56
|
+
#payloadLength() {
|
|
57
|
+
let available = this.packet.length - this.startPos;
|
|
58
|
+
//Walk back to the enclosing IP layer (prevCodecModule is the TCP header) to cap at the IP payload.
|
|
59
|
+
for (let i = this.prevCodecModules.length - 1; i >= 0; i--) {
|
|
60
|
+
const module = this.prevCodecModules[i];
|
|
61
|
+
if (module.id === 'ipv4') {
|
|
62
|
+
const ipEnd = module.startPos + module.instance.length.getValue(0);
|
|
63
|
+
const bounded = ipEnd - this.startPos;
|
|
64
|
+
if (bounded >= 0 && bounded < available)
|
|
65
|
+
available = bounded;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
if (module.id === 'ipv6') {
|
|
69
|
+
const ipEnd = module.startPos + module.length + module.instance.plen.getValue(0);
|
|
70
|
+
const bounded = ipEnd - this.startPos;
|
|
71
|
+
if (bounded >= 0 && bounded < available)
|
|
72
|
+
available = bounded;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return available < 0 ? 0 : available;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Parse the fragment head into the display-only metadata fields. Populated on decode only — these
|
|
80
|
+
* fields have no encode, so they never affect the re-emitted bytes and never mutate `message`. Never
|
|
81
|
+
* throws: a fragment with no recognizable start tag yields an empty rootElement.
|
|
82
|
+
*/
|
|
83
|
+
#parseMetadata(text) {
|
|
84
|
+
//Skip an optional leading XML declaration (`<?xml … ?>`), then find the first element start tag.
|
|
85
|
+
const declaration = text.match(/^\s*<\?xml\b[^>]*\?>/);
|
|
86
|
+
const rest = declaration ? text.slice(declaration[0].length) : text;
|
|
87
|
+
//First start-tag name: `<` then the tag name up to whitespace, `>` or `/` (closing tags start
|
|
88
|
+
//with `/`, excluded from the first char class, so `</stream:stream>` is not matched as a name).
|
|
89
|
+
const element = rest.match(/<([^\s>/!?][^\s>/]*)/);
|
|
90
|
+
const name = element ? element[1] : '';
|
|
91
|
+
this.instance.rootElement.setValue(name);
|
|
92
|
+
this.instance.isStreamHeader.setValue(name === 'stream:stream');
|
|
93
|
+
this.instance.hasXmlDeclaration.setValue(!!declaration);
|
|
94
|
+
}
|
|
95
|
+
static #buildSchema() {
|
|
96
|
+
return {
|
|
97
|
+
type: 'object',
|
|
98
|
+
summary: 'XMPP ${rootElement}',
|
|
99
|
+
properties: {
|
|
100
|
+
//The whole raw payload is the single source of truth: decoded verbatim to hex and
|
|
101
|
+
//re-emitted untouched (byte-perfect for any XMPP fragment). The fragment head is parsed
|
|
102
|
+
//into the display-only metadata below, which carry no codec of their own.
|
|
103
|
+
message: {
|
|
104
|
+
type: 'string',
|
|
105
|
+
label: 'Message',
|
|
106
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
107
|
+
decode: function () {
|
|
108
|
+
const available = this.#payloadLength();
|
|
109
|
+
if (available <= 0) {
|
|
110
|
+
this.instance.message.setValue('');
|
|
111
|
+
this.#parseMetadata('');
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const raw = this.readBytes(0, available);
|
|
115
|
+
this.instance.message.setValue((0, BufferToHex_1.BufferToHex)(raw));
|
|
116
|
+
this.#parseMetadata(raw.toString('latin1'));
|
|
117
|
+
},
|
|
118
|
+
encode: function () {
|
|
119
|
+
//Re-emit the authoritative payload verbatim — never reconstruct from metadata.
|
|
120
|
+
this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(this.instance.message.getValue('')));
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
//Display-only metadata parsed from the fragment head on decode (no encode — populated by the
|
|
124
|
+
//message field above, never read back). rootElement is the first element's tag name (e.g.
|
|
125
|
+
//'stream:stream', 'message', 'iq', 'presence'); isStreamHeader flags the stream preamble;
|
|
126
|
+
//hasXmlDeclaration flags a leading `<?xml … ?>`.
|
|
127
|
+
rootElement: { type: 'string', label: 'Root Element' },
|
|
128
|
+
isStreamHeader: { type: 'boolean', label: 'Is Stream Header' },
|
|
129
|
+
hasXmlDeclaration: { type: 'boolean', label: 'Has XML Declaration' }
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
match() {
|
|
134
|
+
//XMPP rides on TCP ports 5222/5269 as an XML text stream. Beyond the port bucket, require the
|
|
135
|
+
//first non-whitespace byte of the fragment to be '<' (an XML declaration or element start) so
|
|
136
|
+
//non-XML traffic on these ports — e.g. a TLS record after STARTTLS (leading 0x16) — falls through
|
|
137
|
+
//to raw rather than claiming an un-decodable text layer. Guard on the transport-payload length
|
|
138
|
+
//(not the whole frame remainder) so Ethernet padding is not mistaken for a fragment.
|
|
139
|
+
if (!this.prevCodecModule)
|
|
140
|
+
return false;
|
|
141
|
+
if (this.prevCodecModule.id !== 'tcp')
|
|
142
|
+
return false;
|
|
143
|
+
if (this.#payloadLength() <= 0)
|
|
144
|
+
return false;
|
|
145
|
+
const lead = this.readBytes(0, 16, true).toString('latin1');
|
|
146
|
+
return lead.replace(/^\s+/, '').startsWith('<');
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.XMPP = XMPP;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* Zabbix protocol (the Zabbix server / agent / sender header), TCP port 10051 (and 10050 for the
|
|
6
|
+
* passive agent). Every message begins with a fixed 13-byte header — a 4-byte Magic ("ZBXD",
|
|
7
|
+
* 0x5A425844), a 1-byte Flags octet (0x01 uncompressed, 0x02 compressed, 0x04 large-packet), a 4-byte
|
|
8
|
+
* Data Length and a 4-byte Reserved field — followed by `Data Length` bytes of body (a JSON request /
|
|
9
|
+
* response, or, when the compressed flag is set, zlib-deflated JSON with the uncompressed size carried
|
|
10
|
+
* in Reserved).
|
|
11
|
+
*
|
|
12
|
+
* ⚠️ Both length fields are LITTLE-ENDIAN (Zabbix serializes them low byte first). There is no
|
|
13
|
+
* little-endian helper in this codebase, so the uint32 fields are read and written byte-by-byte in
|
|
14
|
+
* their closures. For the classic (non large-packet) header Data Length / Reserved are 32-bit; the
|
|
15
|
+
* large-packet variant widens them to 64 bits, which is out of scope for this 13-byte header — the
|
|
16
|
+
* low 32 bits are decoded and a body beyond 4 GiB is not a concern for a single captured segment.
|
|
17
|
+
*
|
|
18
|
+
* The body is the JSON payload (or compressed blob); it is application-level, cross-message state, so
|
|
19
|
+
* this single-message codec keeps it verbatim as `body` hex (byte-perfect) and does not parse the JSON.
|
|
20
|
+
* Data Length is auto-computed from the body on encode when not supplied, else honored verbatim (a
|
|
21
|
+
* crafted message may lie); the body is bounded by Data Length and the captured bytes so a pipelined /
|
|
22
|
+
* trailing message is left to the codec's recursion / RawData. Reserved is honored verbatim. A
|
|
23
|
+
* well-formed message round-trips byte-for-byte.
|
|
24
|
+
*/
|
|
25
|
+
export declare class Zabbix extends BaseHeader {
|
|
26
|
+
#private;
|
|
27
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly nickname: string;
|
|
31
|
+
readonly matchKeys: string[];
|
|
32
|
+
readonly heuristicFallback: boolean;
|
|
33
|
+
match(): boolean;
|
|
34
|
+
readonly demuxProducers: DemuxProducer[];
|
|
35
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Zabbix = 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
|
+
* Zabbix protocol (the Zabbix server / agent / sender header), TCP port 10051 (and 10050 for the
|
|
10
|
+
* passive agent). Every message begins with a fixed 13-byte header — a 4-byte Magic ("ZBXD",
|
|
11
|
+
* 0x5A425844), a 1-byte Flags octet (0x01 uncompressed, 0x02 compressed, 0x04 large-packet), a 4-byte
|
|
12
|
+
* Data Length and a 4-byte Reserved field — followed by `Data Length` bytes of body (a JSON request /
|
|
13
|
+
* response, or, when the compressed flag is set, zlib-deflated JSON with the uncompressed size carried
|
|
14
|
+
* in Reserved).
|
|
15
|
+
*
|
|
16
|
+
* ⚠️ Both length fields are LITTLE-ENDIAN (Zabbix serializes them low byte first). There is no
|
|
17
|
+
* little-endian helper in this codebase, so the uint32 fields are read and written byte-by-byte in
|
|
18
|
+
* their closures. For the classic (non large-packet) header Data Length / Reserved are 32-bit; the
|
|
19
|
+
* large-packet variant widens them to 64 bits, which is out of scope for this 13-byte header — the
|
|
20
|
+
* low 32 bits are decoded and a body beyond 4 GiB is not a concern for a single captured segment.
|
|
21
|
+
*
|
|
22
|
+
* The body is the JSON payload (or compressed blob); it is application-level, cross-message state, so
|
|
23
|
+
* this single-message codec keeps it verbatim as `body` hex (byte-perfect) and does not parse the JSON.
|
|
24
|
+
* Data Length is auto-computed from the body on encode when not supplied, else honored verbatim (a
|
|
25
|
+
* crafted message may lie); the body is bounded by Data Length and the captured bytes so a pipelined /
|
|
26
|
+
* trailing message is left to the codec's recursion / RawData. Reserved is honored verbatim. A
|
|
27
|
+
* well-formed message round-trips byte-for-byte.
|
|
28
|
+
*/
|
|
29
|
+
class Zabbix extends BaseHeader_1.BaseHeader {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
this.id = 'zabbix';
|
|
33
|
+
this.name = 'Zabbix Protocol';
|
|
34
|
+
this.nickname = 'Zabbix';
|
|
35
|
+
//Well-known Zabbix server port 10051. heuristicFallback because "ZBXD" is a reliable 4-byte content
|
|
36
|
+
//signature — the Zabbix server/proxy/agent/sender speak the same framing on other ports (10050 for
|
|
37
|
+
//the passive agent, arbitrary sender ports), so it must also be recognized off 10051 via match().
|
|
38
|
+
this.matchKeys = ['tcpport:10051'];
|
|
39
|
+
this.heuristicFallback = true;
|
|
40
|
+
//A leaf header — the JSON/compressed body is application-level, cross-message state.
|
|
41
|
+
this.demuxProducers = [];
|
|
42
|
+
}
|
|
43
|
+
static #schemaCache;
|
|
44
|
+
get SCHEMA() {
|
|
45
|
+
return (Zabbix.#schemaCache ??= Zabbix.#buildSchema());
|
|
46
|
+
}
|
|
47
|
+
/** A little-endian unsigned 32-bit field of 4 octets at `offset`. */
|
|
48
|
+
static #fieldUInt32LE(name, offset, label) {
|
|
49
|
+
return {
|
|
50
|
+
type: 'integer',
|
|
51
|
+
label: label,
|
|
52
|
+
minimum: 0,
|
|
53
|
+
maximum: 4294967295,
|
|
54
|
+
decode: function () {
|
|
55
|
+
const b = this.readBytes(offset, 4);
|
|
56
|
+
this.instance[name].setValue((b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)) >>> 0);
|
|
57
|
+
},
|
|
58
|
+
encode: function () {
|
|
59
|
+
const node = this.instance[name];
|
|
60
|
+
let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
61
|
+
if (value > 4294967295) {
|
|
62
|
+
this.recordError(node.getPath(), 'Maximum value is 4294967295');
|
|
63
|
+
value = 4294967295;
|
|
64
|
+
}
|
|
65
|
+
if (value < 0) {
|
|
66
|
+
this.recordError(node.getPath(), 'Minimum value is 0');
|
|
67
|
+
value = 0;
|
|
68
|
+
}
|
|
69
|
+
node.setValue(value);
|
|
70
|
+
this.writeBytes(offset, Buffer.from([value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >>> 24) & 0xff]));
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
static #buildSchema() {
|
|
75
|
+
return {
|
|
76
|
+
type: 'object',
|
|
77
|
+
summary: 'Zabbix flags=${flags} len=${dataLength}',
|
|
78
|
+
properties: {
|
|
79
|
+
//The 4-byte protocol Magic — always "ZBXD" (0x5A425844) on the wire; kept verbatim so any
|
|
80
|
+
//non-standard magic still round-trips.
|
|
81
|
+
magic: this.fieldHex('magic', 0, 4, 'Magic'),
|
|
82
|
+
//Flags bitfield: 0x01 ZBX_TCP_PROTOCOL (uncompressed), 0x02 ZBX_TCP_COMPRESS, 0x04
|
|
83
|
+
//ZBX_TCP_LARGE. Kept as a plain uint8 (byte-perfect and editable); the bit split is UI
|
|
84
|
+
//enrichment for later.
|
|
85
|
+
flags: this.fieldUInt('flags', 4, 1, 'Flags'),
|
|
86
|
+
dataLength: {
|
|
87
|
+
type: 'integer',
|
|
88
|
+
label: 'Data Length',
|
|
89
|
+
minimum: 0,
|
|
90
|
+
maximum: 4294967295,
|
|
91
|
+
decode: function () {
|
|
92
|
+
const b = this.readBytes(5, 4);
|
|
93
|
+
this.instance.dataLength.setValue((b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)) >>> 0);
|
|
94
|
+
},
|
|
95
|
+
encode: function () {
|
|
96
|
+
//Data Length counts only the body that follows the 13-byte header (LITTLE-ENDIAN).
|
|
97
|
+
//Honored when supplied (a crafted message may lie); else derived from the body.
|
|
98
|
+
const provided = this.instance.dataLength.getValue();
|
|
99
|
+
let value = (provided !== undefined && provided !== null)
|
|
100
|
+
? provided
|
|
101
|
+
: (0, HexToBuffer_1.HexToBuffer)(this.instance.body.getValue('')).length;
|
|
102
|
+
if (value > 4294967295) {
|
|
103
|
+
this.recordError(this.instance.dataLength.getPath(), 'Maximum value is 4294967295');
|
|
104
|
+
value = 4294967295;
|
|
105
|
+
}
|
|
106
|
+
if (value < 0) {
|
|
107
|
+
this.recordError(this.instance.dataLength.getPath(), 'Minimum value is 0');
|
|
108
|
+
value = 0;
|
|
109
|
+
}
|
|
110
|
+
this.instance.dataLength.setValue(value);
|
|
111
|
+
this.writeBytes(5, Buffer.from([value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >>> 24) & 0xff]));
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
//Reserved (LITTLE-ENDIAN): zero for an uncompressed message, the uncompressed body size
|
|
115
|
+
//when the compressed flag (0x02) is set. Honored verbatim — a byte-perfect passthrough.
|
|
116
|
+
reserved: this.#fieldUInt32LE('reserved', 9, 'Reserved'),
|
|
117
|
+
//The body (JSON request/response, or a zlib-deflated blob when compressed), kept verbatim.
|
|
118
|
+
//Bounded by Data Length (body ends at offset 13 + Data Length) and the captured bytes, so
|
|
119
|
+
//trailing/pipelined data is left to the codec's recursion / RawData.
|
|
120
|
+
body: {
|
|
121
|
+
type: 'string',
|
|
122
|
+
label: 'Body',
|
|
123
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
124
|
+
decode: function () {
|
|
125
|
+
const remaining = this.packet.length - this.startPos;
|
|
126
|
+
const length = this.instance.dataLength.getValue(0);
|
|
127
|
+
let end = 13 + length;
|
|
128
|
+
if (end > remaining)
|
|
129
|
+
end = remaining;
|
|
130
|
+
this.instance.body.setValue(end > 13 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(13, end - 13)) : '');
|
|
131
|
+
},
|
|
132
|
+
encode: function () {
|
|
133
|
+
const body = this.instance.body.getValue('');
|
|
134
|
+
if (body)
|
|
135
|
+
this.writeBytes(13, (0, HexToBuffer_1.HexToBuffer)(body));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
match() {
|
|
142
|
+
//Zabbix rides on TCP. Require the full 13-byte header and the "ZBXD" Magic (0x5A425844) so
|
|
143
|
+
//non-Zabbix traffic falls through to raw. The magic is a strong 32-bit content signature — safe
|
|
144
|
+
//to match on any port; the full-header guard keeps a crafted short frame from being claimed and
|
|
145
|
+
//breaking the byte-perfect body bound.
|
|
146
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'tcp')
|
|
147
|
+
return false;
|
|
148
|
+
if (this.packet.length - this.startPos < 13)
|
|
149
|
+
return false;
|
|
150
|
+
return (0, BufferToHex_1.BufferToHex)(this.readBytes(0, 4, true)) === '5a425844';
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.Zabbix = Zabbix;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AsnType } from './PerDecoder';
|
|
2
|
+
/**
|
|
3
|
+
* GetAllDataDefinition-RequestPDU (SC 155, §8.3.5.3). A 3-field SEQUENCE (not extensible): a `reference`
|
|
4
|
+
* CHOICE between a bare logical-device name and a logical-node reference, an OPTIONAL functional
|
|
5
|
+
* constraint, and an OPTIONAL "reference after" cursor for paging. Verified byte-for-byte against a real
|
|
6
|
+
* frame whose service data `22 00` + "SW111103SWI/LLN0" decodes as preamble(00) + choice-index(1,
|
|
7
|
+
* lnReference) + length(16) + the octet-aligned reference.
|
|
8
|
+
*/
|
|
9
|
+
export declare const GET_ALL_DATA_DEFINITION_REQUEST: AsnType;
|
|
10
|
+
/**
|
|
11
|
+
* AssociateNegotiate-RequestPDU / -ResponsePDU (SC 154, §8.15.1.3). The session-opening capability
|
|
12
|
+
* exchange: negotiated APDU size, declared max ASDU size, and protocol version (0x201 = 2.1); the
|
|
13
|
+
* response adds the model version string. All fields mandatory, not extensible. Verified against a real
|
|
14
|
+
* frame whose 9-byte service data `fd e8 03 02 00 00 02 02 01` decodes to
|
|
15
|
+
* {apduSize: 65000, asduSize: 131072, protocolVersion: 513}.
|
|
16
|
+
*/
|
|
17
|
+
export declare const ASSOCIATE_NEGOTIATE_REQUEST: AsnType;
|
|
18
|
+
export declare const ASSOCIATE_NEGOTIATE_RESPONSE: AsnType;
|
|
19
|
+
/**
|
|
20
|
+
* GetAllDataValues-RequestPDU (SC 83, §8.3.4.3) is structurally identical to GetAllDataDefinition's request
|
|
21
|
+
* (a reference CHOICE plus optional functional-constraint and paging cursor) per the standard, so it reuses
|
|
22
|
+
* the same PER descriptor. Its response, by contrast, carries `Data` values encoded as GB/T 33602 TLV, not
|
|
23
|
+
* PER, and is decoded separately (not via this PER descriptor table).
|
|
24
|
+
*/
|
|
25
|
+
export declare const GET_ALL_DATA_VALUES_REQUEST: AsnType;
|
|
26
|
+
/**
|
|
27
|
+
* Associate-RequestPDU (SC 1, §8.2.1.4). Both fields OPTIONAL: an optional server access-point reference
|
|
28
|
+
* and an optional authentication parameter (signature certificate + signed UTC time + signed value). A real
|
|
29
|
+
* frame carries both absent (service data `00` = the 2-bit preamble, both cleared). VisibleString129 =
|
|
30
|
+
* VisibleString(SIZE(0..129)); UtcTime = OCTET STRING(SIZE(8)).
|
|
31
|
+
*/
|
|
32
|
+
export declare const ASSOCIATE_REQUEST: AsnType;
|
|
33
|
+
export interface ServicePdu {
|
|
34
|
+
request?: AsnType;
|
|
35
|
+
response?: AsnType;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Service Code → PDU descriptors. Only services whose ASN.1 has been transcribed and verified against a
|
|
39
|
+
* real frame appear here; an absent service (or an untranscribed direction) leaves the service data as
|
|
40
|
+
* verbatim hex. GetAllDataDefinition's response references a not-yet-transcribed `DataDefinition` type, so
|
|
41
|
+
* only the request is structured for now.
|
|
42
|
+
*/
|
|
43
|
+
export declare const SERVICE_PDU: Record<number, ServicePdu>;
|
|
44
|
+
/** Service Code → name (DL/T 2811-2024 §6.1.2 Table 1), for the display label. */
|
|
45
|
+
export declare const SERVICE_NAMES: Record<number, string>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SERVICE_NAMES = exports.SERVICE_PDU = exports.ASSOCIATE_REQUEST = exports.GET_ALL_DATA_VALUES_REQUEST = exports.ASSOCIATE_NEGOTIATE_RESPONSE = exports.ASSOCIATE_NEGOTIATE_REQUEST = exports.GET_ALL_DATA_DEFINITION_REQUEST = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* AcsiPdu — ASN.1 type descriptors for CMS (DL/T 2811-2024) ACSI service PDUs, transcribed from the
|
|
6
|
+
* standard for the {@link PerDecoder} (ALIGNED BASIC-PER, §6.10). These live on the imperative side of the
|
|
7
|
+
* codec's schema split; each service is one entry in {@link SERVICE_PDU}, keyed by its Service Code, so
|
|
8
|
+
* adding a service is a local addition and never a core change. PER ignores the IMPLICIT `[n]` tags in the
|
|
9
|
+
* printed notation (tags are a BER concern only), so they are omitted here — only the structure, order,
|
|
10
|
+
* optionality and SIZE/value constraints matter.
|
|
11
|
+
*/
|
|
12
|
+
//Common ACSI reference types (DL/T 2811-2024 §7.3): plain VisibleStrings with a SIZE constraint.
|
|
13
|
+
const OBJECT_NAME = { k: 'vstr', min: 0, max: 64 }; //ObjectName ::= VisibleString(SIZE(0..64)) §7.3.1
|
|
14
|
+
const OBJECT_REFERENCE = { k: 'vstr', min: 0, max: 129 }; //ObjectReference ::= VisibleString(SIZE(0..129)) §7.3.2
|
|
15
|
+
//FunctionalConstraint ::= VisibleString(SIZE(2)) §7.4.1.2 — a fixed 2-char code (ST, MX, CF, …), not an enum.
|
|
16
|
+
const FUNCTIONAL_CONSTRAINT = { k: 'vstr', min: 2, max: 2 };
|
|
17
|
+
/**
|
|
18
|
+
* GetAllDataDefinition-RequestPDU (SC 155, §8.3.5.3). A 3-field SEQUENCE (not extensible): a `reference`
|
|
19
|
+
* CHOICE between a bare logical-device name and a logical-node reference, an OPTIONAL functional
|
|
20
|
+
* constraint, and an OPTIONAL "reference after" cursor for paging. Verified byte-for-byte against a real
|
|
21
|
+
* frame whose service data `22 00` + "SW111103SWI/LLN0" decodes as preamble(00) + choice-index(1,
|
|
22
|
+
* lnReference) + length(16) + the octet-aligned reference.
|
|
23
|
+
*/
|
|
24
|
+
exports.GET_ALL_DATA_DEFINITION_REQUEST = {
|
|
25
|
+
k: 'seq',
|
|
26
|
+
fields: [
|
|
27
|
+
{ name: 'reference', type: { k: 'choice', alts: [
|
|
28
|
+
{ name: 'ldName', type: OBJECT_NAME },
|
|
29
|
+
{ name: 'lnReference', type: OBJECT_REFERENCE }
|
|
30
|
+
] } },
|
|
31
|
+
{ name: 'fc', type: FUNCTIONAL_CONSTRAINT, optional: true },
|
|
32
|
+
{ name: 'referenceAfter', type: OBJECT_REFERENCE, optional: true }
|
|
33
|
+
]
|
|
34
|
+
};
|
|
35
|
+
//Common ACSI integer/string base types (DL/T 2811-2024 §7.1). INT16U is fully constrained (fixed width
|
|
36
|
+
//in PER); INT32U is semi-constrained INTEGER(0..MAX) (length-prefixed octets); a bare VisibleString has no
|
|
37
|
+
//SIZE bound (length determinant + content).
|
|
38
|
+
const INT16U = { k: 'int', lb: 0, ub: 65535 };
|
|
39
|
+
const INT32U = { k: 'int', lb: 0 };
|
|
40
|
+
const VISIBLE_STRING = { k: 'vstr' };
|
|
41
|
+
/**
|
|
42
|
+
* AssociateNegotiate-RequestPDU / -ResponsePDU (SC 154, §8.15.1.3). The session-opening capability
|
|
43
|
+
* exchange: negotiated APDU size, declared max ASDU size, and protocol version (0x201 = 2.1); the
|
|
44
|
+
* response adds the model version string. All fields mandatory, not extensible. Verified against a real
|
|
45
|
+
* frame whose 9-byte service data `fd e8 03 02 00 00 02 02 01` decodes to
|
|
46
|
+
* {apduSize: 65000, asduSize: 131072, protocolVersion: 513}.
|
|
47
|
+
*/
|
|
48
|
+
exports.ASSOCIATE_NEGOTIATE_REQUEST = {
|
|
49
|
+
k: 'seq',
|
|
50
|
+
fields: [
|
|
51
|
+
{ name: 'apduSize', type: INT16U },
|
|
52
|
+
{ name: 'asduSize', type: INT32U },
|
|
53
|
+
{ name: 'protocolVersion', type: INT32U }
|
|
54
|
+
]
|
|
55
|
+
};
|
|
56
|
+
exports.ASSOCIATE_NEGOTIATE_RESPONSE = {
|
|
57
|
+
k: 'seq',
|
|
58
|
+
fields: [
|
|
59
|
+
{ name: 'apduSize', type: INT16U },
|
|
60
|
+
{ name: 'asduSize', type: INT32U },
|
|
61
|
+
{ name: 'protocolVersion', type: INT32U },
|
|
62
|
+
{ name: 'modelVersion', type: VISIBLE_STRING }
|
|
63
|
+
]
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* GetAllDataValues-RequestPDU (SC 83, §8.3.4.3) is structurally identical to GetAllDataDefinition's request
|
|
67
|
+
* (a reference CHOICE plus optional functional-constraint and paging cursor) per the standard, so it reuses
|
|
68
|
+
* the same PER descriptor. Its response, by contrast, carries `Data` values encoded as GB/T 33602 TLV, not
|
|
69
|
+
* PER, and is decoded separately (not via this PER descriptor table).
|
|
70
|
+
*/
|
|
71
|
+
exports.GET_ALL_DATA_VALUES_REQUEST = exports.GET_ALL_DATA_DEFINITION_REQUEST;
|
|
72
|
+
/**
|
|
73
|
+
* Associate-RequestPDU (SC 1, §8.2.1.4). Both fields OPTIONAL: an optional server access-point reference
|
|
74
|
+
* and an optional authentication parameter (signature certificate + signed UTC time + signed value). A real
|
|
75
|
+
* frame carries both absent (service data `00` = the 2-bit preamble, both cleared). VisibleString129 =
|
|
76
|
+
* VisibleString(SIZE(0..129)); UtcTime = OCTET STRING(SIZE(8)).
|
|
77
|
+
*/
|
|
78
|
+
exports.ASSOCIATE_REQUEST = {
|
|
79
|
+
k: 'seq',
|
|
80
|
+
fields: [
|
|
81
|
+
{ name: 'serverAccessPointReference', type: { k: 'vstr', min: 0, max: 129 }, optional: true },
|
|
82
|
+
{ name: 'authenticationParameter', type: { k: 'seq', fields: [
|
|
83
|
+
{ name: 'signatureCertificate', type: { k: 'octstr' } },
|
|
84
|
+
{ name: 'signedTime', type: { k: 'octstr', size: 8 } },
|
|
85
|
+
{ name: 'signedValue', type: { k: 'octstr' } }
|
|
86
|
+
] }, optional: true }
|
|
87
|
+
]
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Service Code → PDU descriptors. Only services whose ASN.1 has been transcribed and verified against a
|
|
91
|
+
* real frame appear here; an absent service (or an untranscribed direction) leaves the service data as
|
|
92
|
+
* verbatim hex. GetAllDataDefinition's response references a not-yet-transcribed `DataDefinition` type, so
|
|
93
|
+
* only the request is structured for now.
|
|
94
|
+
*/
|
|
95
|
+
exports.SERVICE_PDU = {
|
|
96
|
+
1: { request: exports.ASSOCIATE_REQUEST },
|
|
97
|
+
83: { request: exports.GET_ALL_DATA_VALUES_REQUEST },
|
|
98
|
+
154: { request: exports.ASSOCIATE_NEGOTIATE_REQUEST, response: exports.ASSOCIATE_NEGOTIATE_RESPONSE },
|
|
99
|
+
155: { request: exports.GET_ALL_DATA_DEFINITION_REQUEST }
|
|
100
|
+
};
|
|
101
|
+
/** Service Code → name (DL/T 2811-2024 §6.1.2 Table 1), for the display label. */
|
|
102
|
+
exports.SERVICE_NAMES = {
|
|
103
|
+
1: 'Associate',
|
|
104
|
+
2: 'Abort',
|
|
105
|
+
3: 'Release',
|
|
106
|
+
48: 'GetDataValues',
|
|
107
|
+
83: 'GetAllDataValues',
|
|
108
|
+
153: 'Test',
|
|
109
|
+
154: 'AssociateNegotiate',
|
|
110
|
+
155: 'GetAllDataDefinition',
|
|
111
|
+
156: 'GetAllCBValues'
|
|
112
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AsnType — a compact discriminated-union descriptor for the ASN.1 constructs CMS (DL/T 2811-2024) ACSI
|
|
3
|
+
* uses. This lives on the imperative side of the codec's schema split (it is procedural, not serializable
|
|
4
|
+
* JSON Schema) and is interpreted by {@link PerDecoder} against ALIGNED BASIC-PER bytes. Descriptors are
|
|
5
|
+
* transcribed per service from the spec's §7/§8 and kept in a name→type table so recursive types
|
|
6
|
+
* (`Data`, object references) resolve through `{k: 'ref'}`.
|
|
7
|
+
*/
|
|
8
|
+
export type AsnType = {
|
|
9
|
+
k: 'bool';
|
|
10
|
+
} | {
|
|
11
|
+
k: 'int';
|
|
12
|
+
lb?: number;
|
|
13
|
+
ub?: number;
|
|
14
|
+
} | {
|
|
15
|
+
k: 'enum';
|
|
16
|
+
values: string[];
|
|
17
|
+
ext?: boolean;
|
|
18
|
+
} | {
|
|
19
|
+
k: 'bitstr';
|
|
20
|
+
size?: number;
|
|
21
|
+
} | {
|
|
22
|
+
k: 'octstr';
|
|
23
|
+
size?: number;
|
|
24
|
+
} | {
|
|
25
|
+
k: 'vstr';
|
|
26
|
+
min?: number;
|
|
27
|
+
max?: number;
|
|
28
|
+
} | {
|
|
29
|
+
k: 'seq';
|
|
30
|
+
ext?: boolean;
|
|
31
|
+
fields: AsnField[];
|
|
32
|
+
} | {
|
|
33
|
+
k: 'seqof';
|
|
34
|
+
element: AsnType;
|
|
35
|
+
} | {
|
|
36
|
+
k: 'choice';
|
|
37
|
+
ext?: boolean;
|
|
38
|
+
alts: {
|
|
39
|
+
name: string;
|
|
40
|
+
type: AsnType;
|
|
41
|
+
}[];
|
|
42
|
+
} | {
|
|
43
|
+
k: 'ref';
|
|
44
|
+
name: string;
|
|
45
|
+
};
|
|
46
|
+
export interface AsnField {
|
|
47
|
+
name: string;
|
|
48
|
+
type: AsnType;
|
|
49
|
+
optional?: boolean;
|
|
50
|
+
default?: unknown;
|
|
51
|
+
}
|
|
52
|
+
export type AsnTypeTable = Record<string, AsnType>;
|
|
53
|
+
/**
|
|
54
|
+
* PerDecoder — a never-throwing ALIGNED BASIC-PER interpreter. It walks an {@link AsnType} descriptor,
|
|
55
|
+
* pulling from a {@link PerReader}, and returns a plain JS value tree for DISPLAY only (CMS keeps the raw
|
|
56
|
+
* service-data bytes as the authoritative encode form, so this decoder never affects output bytes). When it
|
|
57
|
+
* meets something it cannot safely decode — a fragmented length, an unknown `ref`, or an extensible type
|
|
58
|
+
* whose additions are present — it sets {@link bailed} so the caller can fall back to showing raw hex.
|
|
59
|
+
*/
|
|
60
|
+
export declare class PerDecoder {
|
|
61
|
+
#private;
|
|
62
|
+
constructor(buf: Buffer, table?: AsnTypeTable);
|
|
63
|
+
/** True once the decoder hit a construct it could not safely decode; the result is then incomplete. */
|
|
64
|
+
get bailed(): boolean;
|
|
65
|
+
/** Bytes consumed so far (rounded down) — lets the caller show any trailing bytes as raw. */
|
|
66
|
+
get bytePos(): number;
|
|
67
|
+
decode(type: AsnType): unknown;
|
|
68
|
+
}
|