@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,316 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AMQP = 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
|
+
/** The 8-byte literal a client sends first to negotiate the protocol: "AMQP" + 4 version octets. */
|
|
11
|
+
const PROTOCOL_HEADER_MAGIC = Buffer.from('AMQP', 'latin1'); // 41 4d 51 50
|
|
12
|
+
/** AMQP frame end marker — every frame terminates with this octet (AMQP 0-9-1 §2.3.5). */
|
|
13
|
+
const FRAME_END = 0xce;
|
|
14
|
+
/** Valid frame type octets: 1=METHOD, 2=HEADER, 3=BODY, 8=HEARTBEAT (AMQP 0-9-1 §2.3.5). */
|
|
15
|
+
const FRAME_TYPES = [1, 2, 3, 8];
|
|
16
|
+
/**
|
|
17
|
+
* AMQP 0-9-1 — the Advanced Message Queuing Protocol as spoken by RabbitMQ and friends, carried over TCP
|
|
18
|
+
* port 5672. A connection opens with an 8-byte protocol header — the literal "AMQP" followed by four
|
|
19
|
+
* version octets (0 0 9 1 for 0-9-1) — sent once at connection start to negotiate the version. Everything
|
|
20
|
+
* after that is a stream of frames: a 1-byte type (1=METHOD, 2=HEADER, 3=BODY, 8=HEARTBEAT), a 2-byte
|
|
21
|
+
* channel, a 4-byte payload length, `length` payload octets, and a single 0xCE frame-end octet.
|
|
22
|
+
*
|
|
23
|
+
* This codec handles BOTH forms in one header (they are distinguished on the wire by the leading "AMQP"
|
|
24
|
+
* literal). The protocol-header handshake decodes to {isProtocolHeader:true, protocol:'AMQP', + the four
|
|
25
|
+
* version octets}; a frame decodes to type/channel/length/payload/frameEnd. The frame payload carries a
|
|
26
|
+
* class/method id and its arguments (METHOD), a content-header (HEADER), or opaque bytes (BODY) — decoding
|
|
27
|
+
* those is cross-frame, class-dependent state, so this minimal slice keeps the payload verbatim as hex
|
|
28
|
+
* (byte-perfect). The payload is bounded by the length field (the frame ends at offset 7+length, with the
|
|
29
|
+
* frame-end octet there), so a pipelined second frame or trailing bytes are left to the codec's recursion
|
|
30
|
+
* / RawData. Length is honored when supplied on encode (a crafted frame may lie), else derived from the
|
|
31
|
+
* payload bytes. A well-formed handshake or frame round-trips byte-for-byte.
|
|
32
|
+
*/
|
|
33
|
+
class AMQP extends BaseHeader_1.BaseHeader {
|
|
34
|
+
constructor() {
|
|
35
|
+
super(...arguments);
|
|
36
|
+
this.id = 'amqp';
|
|
37
|
+
this.name = 'AMQP 0-9-1';
|
|
38
|
+
this.nickname = 'AMQP';
|
|
39
|
+
this.matchKeys = ['tcpport:5672'];
|
|
40
|
+
//Deliberately NOT a heuristicFallback: an AMQP frame header (type/channel/length) carries no strong
|
|
41
|
+
//content magic — a bare 1/2/3/8 type octet over a plausible channel/length would collide with all
|
|
42
|
+
//manner of binary TCP payloads — so recognition is confined to the well-known port bucket (5672).
|
|
43
|
+
//The "AMQP" literal is a strong signature, but it only appears on the one-shot connection handshake,
|
|
44
|
+
//not on ongoing frames, so it cannot carry the protocol off-port on its own.
|
|
45
|
+
this.heuristicFallback = false;
|
|
46
|
+
//A leaf header — the frame payload (class/method arguments, content headers, body) is cross-frame,
|
|
47
|
+
//class-dependent state kept as hex, not demuxed further.
|
|
48
|
+
this.demuxProducers = [];
|
|
49
|
+
}
|
|
50
|
+
static #schemaCache;
|
|
51
|
+
get SCHEMA() {
|
|
52
|
+
return (AMQP.#schemaCache ??= AMQP.#buildSchema());
|
|
53
|
+
}
|
|
54
|
+
/** True when this instance is (being) decoded/encoded as the 8-byte protocol-header handshake. */
|
|
55
|
+
#isHandshake() {
|
|
56
|
+
return Boolean(this.instance.isProtocolHeader.getValue(false));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A version octet of the protocol-header handshake (one of the four bytes after the "AMQP" literal,
|
|
60
|
+
* at `offset`). Only present in the handshake form: decode reads it when this is a handshake; encode
|
|
61
|
+
* writes it only when this is a handshake, so a frame never emits these bytes.
|
|
62
|
+
*/
|
|
63
|
+
static #versionField(name, offset, label, defaultValue) {
|
|
64
|
+
return {
|
|
65
|
+
type: 'integer',
|
|
66
|
+
label: label,
|
|
67
|
+
minimum: 0,
|
|
68
|
+
maximum: 255,
|
|
69
|
+
default: defaultValue,
|
|
70
|
+
decode: function () {
|
|
71
|
+
if (!this.#isHandshake())
|
|
72
|
+
return;
|
|
73
|
+
this.instance[name].setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(offset, 1)));
|
|
74
|
+
},
|
|
75
|
+
encode: function () {
|
|
76
|
+
if (!this.#isHandshake())
|
|
77
|
+
return;
|
|
78
|
+
const node = this.instance[name];
|
|
79
|
+
let value = node.getValue(defaultValue, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
80
|
+
if (value > 255) {
|
|
81
|
+
this.recordError(node.getPath(), 'Maximum value is 255');
|
|
82
|
+
value = 255;
|
|
83
|
+
}
|
|
84
|
+
if (value < 0) {
|
|
85
|
+
this.recordError(node.getPath(), 'Minimum value is 0');
|
|
86
|
+
value = 0;
|
|
87
|
+
}
|
|
88
|
+
node.setValue(value);
|
|
89
|
+
this.writeBytes(offset, (0, NumberToBuffer_1.UInt8ToBuffer)(value));
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
static #buildSchema() {
|
|
94
|
+
return {
|
|
95
|
+
type: 'object',
|
|
96
|
+
//Two forms share one summary slot; `info` is a decode-only display field set to
|
|
97
|
+
//'protocol-header' for the handshake or 'type=<n>' for a frame (see the isProtocolHeader
|
|
98
|
+
//field below), so the rendered Info column reads "AMQP protocol-header" or "AMQP type=1".
|
|
99
|
+
summary: 'AMQP ${info}',
|
|
100
|
+
properties: {
|
|
101
|
+
//Discriminator + display. Decode inspects the first four octets: the "AMQP" literal marks
|
|
102
|
+
//the handshake, anything else is a frame. This field also fills the decode-only `info`
|
|
103
|
+
//display string (it needs the raw type octet, which it reads directly). On encode it is
|
|
104
|
+
//an input value (default false) that every other field branches on; it writes no bytes.
|
|
105
|
+
isProtocolHeader: {
|
|
106
|
+
type: 'boolean',
|
|
107
|
+
label: 'Is Protocol Header',
|
|
108
|
+
default: false,
|
|
109
|
+
decode: function () {
|
|
110
|
+
const lead = this.readBytes(0, 4, true);
|
|
111
|
+
const handshake = lead.length >= 4 && lead.equals(PROTOCOL_HEADER_MAGIC);
|
|
112
|
+
this.instance.isProtocolHeader.setValue(handshake);
|
|
113
|
+
this.instance.info.setValue(handshake ? 'protocol-header' : `type=${(0, BufferToNumber_1.BufferToUInt8)(this.readBytes(0, 1, true))}`);
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
//Decode-only display string for the Info summary (populated above); carries no encode, so
|
|
117
|
+
//it never affects the emitted bytes.
|
|
118
|
+
info: { type: 'string', label: 'Info' },
|
|
119
|
+
// ===== Protocol-header handshake form ("AMQP" + four version octets) =====
|
|
120
|
+
protocol: {
|
|
121
|
+
type: 'string',
|
|
122
|
+
label: 'Protocol',
|
|
123
|
+
default: 'AMQP',
|
|
124
|
+
decode: function () {
|
|
125
|
+
if (!this.#isHandshake())
|
|
126
|
+
return;
|
|
127
|
+
this.instance.protocol.setValue(this.readBytes(0, 4).toString('latin1'));
|
|
128
|
+
},
|
|
129
|
+
encode: function () {
|
|
130
|
+
if (!this.#isHandshake())
|
|
131
|
+
return;
|
|
132
|
+
//Re-emit the 4-char literal verbatim (default "AMQP"); truncate/pad to 4 octets so
|
|
133
|
+
//a crafted value can never shift the version octets that follow.
|
|
134
|
+
const text = this.instance.protocol.getValue('AMQP');
|
|
135
|
+
const bytes = Buffer.alloc(4, 0);
|
|
136
|
+
Buffer.from(text, 'latin1').copy(bytes, 0, 0, 4);
|
|
137
|
+
this.writeBytes(0, bytes);
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
//The four version octets after the literal: protocol-id, major, minor, revision (0 0 9 1).
|
|
141
|
+
protocolId: this.#versionField('protocolId', 4, 'Protocol Id', 0),
|
|
142
|
+
versionMajor: this.#versionField('versionMajor', 5, 'Version Major', 0),
|
|
143
|
+
versionMinor: this.#versionField('versionMinor', 6, 'Version Minor', 9),
|
|
144
|
+
versionRevision: this.#versionField('versionRevision', 7, 'Version Revision', 1),
|
|
145
|
+
// ===== Frame form (type + channel + length + payload + frameEnd) =====
|
|
146
|
+
type: {
|
|
147
|
+
type: 'integer',
|
|
148
|
+
label: 'Type',
|
|
149
|
+
minimum: 0,
|
|
150
|
+
maximum: 255,
|
|
151
|
+
default: 1,
|
|
152
|
+
decode: function () {
|
|
153
|
+
if (this.#isHandshake())
|
|
154
|
+
return;
|
|
155
|
+
this.instance.type.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(0, 1)));
|
|
156
|
+
},
|
|
157
|
+
encode: function () {
|
|
158
|
+
if (this.#isHandshake())
|
|
159
|
+
return;
|
|
160
|
+
const node = this.instance.type;
|
|
161
|
+
let value = node.getValue(1, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
162
|
+
if (value > 255) {
|
|
163
|
+
this.recordError(node.getPath(), 'Maximum value is 255');
|
|
164
|
+
value = 255;
|
|
165
|
+
}
|
|
166
|
+
if (value < 0) {
|
|
167
|
+
this.recordError(node.getPath(), 'Minimum value is 0');
|
|
168
|
+
value = 0;
|
|
169
|
+
}
|
|
170
|
+
node.setValue(value);
|
|
171
|
+
this.writeBytes(0, (0, NumberToBuffer_1.UInt8ToBuffer)(value));
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
channel: {
|
|
175
|
+
type: 'integer',
|
|
176
|
+
label: 'Channel',
|
|
177
|
+
minimum: 0,
|
|
178
|
+
maximum: 65535,
|
|
179
|
+
default: 0,
|
|
180
|
+
decode: function () {
|
|
181
|
+
if (this.#isHandshake())
|
|
182
|
+
return;
|
|
183
|
+
this.instance.channel.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(1, 2)));
|
|
184
|
+
},
|
|
185
|
+
encode: function () {
|
|
186
|
+
if (this.#isHandshake())
|
|
187
|
+
return;
|
|
188
|
+
const node = this.instance.channel;
|
|
189
|
+
let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
190
|
+
if (value > 65535) {
|
|
191
|
+
this.recordError(node.getPath(), 'Maximum value is 65535');
|
|
192
|
+
value = 65535;
|
|
193
|
+
}
|
|
194
|
+
if (value < 0) {
|
|
195
|
+
this.recordError(node.getPath(), 'Minimum value is 0');
|
|
196
|
+
value = 0;
|
|
197
|
+
}
|
|
198
|
+
node.setValue(value);
|
|
199
|
+
this.writeBytes(1, (0, NumberToBuffer_1.UInt16ToBuffer)(value));
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
//NOTE: Length is honored verbatim on encode (a crafted frame may lie), and the frameEnd is
|
|
203
|
+
//written at offset 7+Length, which auto-expands the buffer. A deliberately crafted Length near
|
|
204
|
+
//0xFFFFFFFF therefore drives a multi-GB allocation on re-encode — an instance of the codebase's
|
|
205
|
+
//general "writeBytes auto-expand vs read-clamp asymmetry on attacker-controlled length fields"
|
|
206
|
+
//(a scheduled hardening item at the BaseHeader level, wider here because the field is uint32 vs
|
|
207
|
+
//ENIP's uint16). It does not break the never-throws contract (the RangeError is caught and
|
|
208
|
+
//recorded), and a well-formed frame (Length == payload bytes) never triggers it.
|
|
209
|
+
length: {
|
|
210
|
+
type: 'integer',
|
|
211
|
+
label: 'Length',
|
|
212
|
+
minimum: 0,
|
|
213
|
+
maximum: 4294967295,
|
|
214
|
+
decode: function () {
|
|
215
|
+
if (this.#isHandshake())
|
|
216
|
+
return;
|
|
217
|
+
this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt32)(this.readBytes(3, 4)));
|
|
218
|
+
},
|
|
219
|
+
encode: function () {
|
|
220
|
+
if (this.#isHandshake())
|
|
221
|
+
return;
|
|
222
|
+
//Length counts the payload octets between the header and the frame-end marker.
|
|
223
|
+
//Honored when supplied (a crafted frame may lie); else derived from the payload.
|
|
224
|
+
const provided = this.instance.length.getValue();
|
|
225
|
+
let value = (provided !== undefined && provided !== null)
|
|
226
|
+
? provided
|
|
227
|
+
: (0, HexToBuffer_1.HexToBuffer)(this.instance.payload.getValue('')).length;
|
|
228
|
+
if (value > 4294967295) {
|
|
229
|
+
this.recordError(this.instance.length.getPath(), 'Maximum value is 4294967295');
|
|
230
|
+
value = 4294967295;
|
|
231
|
+
}
|
|
232
|
+
if (value < 0) {
|
|
233
|
+
this.recordError(this.instance.length.getPath(), 'Minimum value is 0');
|
|
234
|
+
value = 0;
|
|
235
|
+
}
|
|
236
|
+
this.instance.length.setValue(value);
|
|
237
|
+
this.writeBytes(3, (0, NumberToBuffer_1.UInt32ToBuffer)(value));
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
//The frame payload, kept verbatim. Bounded by the length field (payload ends at offset
|
|
241
|
+
//7+length) and the captured bytes, so a pipelined/trailing frame is left to the codec's
|
|
242
|
+
//recursion / RawData.
|
|
243
|
+
payload: {
|
|
244
|
+
type: 'string',
|
|
245
|
+
label: 'Payload',
|
|
246
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
247
|
+
decode: function () {
|
|
248
|
+
if (this.#isHandshake())
|
|
249
|
+
return;
|
|
250
|
+
const remaining = this.packet.length - this.startPos;
|
|
251
|
+
const length = this.instance.length.getValue(0);
|
|
252
|
+
let end = 7 + length;
|
|
253
|
+
if (end > remaining)
|
|
254
|
+
end = remaining;
|
|
255
|
+
this.instance.payload.setValue(end > 7 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(7, end - 7)) : '');
|
|
256
|
+
},
|
|
257
|
+
encode: function () {
|
|
258
|
+
if (this.#isHandshake())
|
|
259
|
+
return;
|
|
260
|
+
const payload = this.instance.payload.getValue('');
|
|
261
|
+
if (payload)
|
|
262
|
+
this.writeBytes(7, (0, HexToBuffer_1.HexToBuffer)(payload));
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
frameEnd: {
|
|
266
|
+
type: 'integer',
|
|
267
|
+
label: 'Frame End',
|
|
268
|
+
minimum: 0,
|
|
269
|
+
maximum: 255,
|
|
270
|
+
default: FRAME_END,
|
|
271
|
+
decode: function () {
|
|
272
|
+
if (this.#isHandshake())
|
|
273
|
+
return;
|
|
274
|
+
const length = this.instance.length.getValue(0);
|
|
275
|
+
this.instance.frameEnd.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(7 + length, 1)));
|
|
276
|
+
},
|
|
277
|
+
encode: function () {
|
|
278
|
+
if (this.#isHandshake())
|
|
279
|
+
return;
|
|
280
|
+
//Sits right after the payload; its offset depends on the length written above
|
|
281
|
+
//(the length field encodes before this one), so re-derive the same length.
|
|
282
|
+
const provided = this.instance.length.getValue();
|
|
283
|
+
const length = (provided !== undefined && provided !== null)
|
|
284
|
+
? provided
|
|
285
|
+
: (0, HexToBuffer_1.HexToBuffer)(this.instance.payload.getValue('')).length;
|
|
286
|
+
const node = this.instance.frameEnd;
|
|
287
|
+
let value = node.getValue(FRAME_END, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
288
|
+
if (value > 255) {
|
|
289
|
+
this.recordError(node.getPath(), 'Maximum value is 255');
|
|
290
|
+
value = 255;
|
|
291
|
+
}
|
|
292
|
+
if (value < 0) {
|
|
293
|
+
this.recordError(node.getPath(), 'Minimum value is 0');
|
|
294
|
+
value = 0;
|
|
295
|
+
}
|
|
296
|
+
node.setValue(value);
|
|
297
|
+
this.writeBytes(7 + length, (0, NumberToBuffer_1.UInt8ToBuffer)(value));
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
match() {
|
|
304
|
+
//AMQP rides on TCP port 5672. Accept either the connection-start protocol-header literal ("AMQP")
|
|
305
|
+
//or a frame whose leading octet is a known frame type with the fixed 7-byte header present.
|
|
306
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'tcp')
|
|
307
|
+
return false;
|
|
308
|
+
const remaining = this.packet.length - this.startPos;
|
|
309
|
+
if (remaining < 1)
|
|
310
|
+
return false;
|
|
311
|
+
if (remaining >= 4 && this.readBytes(0, 4, true).equals(PROTOCOL_HEADER_MAGIC))
|
|
312
|
+
return true;
|
|
313
|
+
return remaining >= 8 && FRAME_TYPES.includes((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(0, 1, true)));
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
exports.AMQP = AMQP;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
2
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
3
|
+
/**
|
|
4
|
+
* ARP — Address Resolution Protocol (RFC 826), carried directly on Ethernet with EtherType 0x0806.
|
|
5
|
+
* This codec decodes the classic 28-octet IPv4-over-Ethernet ARP packet, whose wire layout is: a 16-bit
|
|
6
|
+
* Hardware Type (`hardware.type`, offset 0), a 16-bit Protocol Type (`protocol.type`, offset 2, kept as a
|
|
7
|
+
* 4-hex string e.g. "0800"), an 8-bit Hardware Address Length (`hardware.size`, offset 4), an 8-bit
|
|
8
|
+
* Protocol Address Length (`protocol.size`, offset 5), a 16-bit Opcode (offset 6; 1 request, 2 reply,
|
|
9
|
+
* 3 RARP request, 4 RARP reply — other values are flagged as an error but kept), then the four address
|
|
10
|
+
* fields: Sender MAC (`sender.mac`, 6 octets, offset 8) and Sender IPv4 (`sender.ipv4`, 4 octets, offset
|
|
11
|
+
* 14), Target MAC (`target.mac`, 6 octets, offset 18) and Target IPv4 (`target.ipv4`, 4 octets, offset
|
|
12
|
+
* 24). The schema groups the two `hardware`/`protocol` sub-objects and two `sender`/`target` sub-objects
|
|
13
|
+
* for the UI, but each field reads its own fixed offset, so the on-wire interleaving is preserved.
|
|
14
|
+
*
|
|
15
|
+
* The 6-octet MAC and 4-octet IPv4 widths are fixed here (Ethernet + IPv4 ARP), independent of the
|
|
16
|
+
* declared hardware/protocol sizes. Values are range-clamped rather than rejected. match() keys purely
|
|
17
|
+
* on the parent's EtherType being 0x0806.
|
|
18
|
+
*/
|
|
19
|
+
export declare class ARP extends BaseHeader {
|
|
20
|
+
SCHEMA: ProtocolJSONSchema;
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly matchKeys: string[];
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly nickname: string;
|
|
25
|
+
match(): boolean;
|
|
26
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ARP = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const NumberToHex_1 = require("../helper/NumberToHex");
|
|
6
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
7
|
+
const HexToNumber_1 = require("../helper/HexToNumber");
|
|
8
|
+
const BufferToNumber_1 = require("../helper/BufferToNumber");
|
|
9
|
+
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
10
|
+
const NumberToBuffer_1 = require("../helper/NumberToBuffer");
|
|
11
|
+
const BufferToIP_1 = require("../helper/BufferToIP");
|
|
12
|
+
const IPToBuffer_1 = require("../helper/IPToBuffer");
|
|
13
|
+
/**
|
|
14
|
+
* ARP — Address Resolution Protocol (RFC 826), carried directly on Ethernet with EtherType 0x0806.
|
|
15
|
+
* This codec decodes the classic 28-octet IPv4-over-Ethernet ARP packet, whose wire layout is: a 16-bit
|
|
16
|
+
* Hardware Type (`hardware.type`, offset 0), a 16-bit Protocol Type (`protocol.type`, offset 2, kept as a
|
|
17
|
+
* 4-hex string e.g. "0800"), an 8-bit Hardware Address Length (`hardware.size`, offset 4), an 8-bit
|
|
18
|
+
* Protocol Address Length (`protocol.size`, offset 5), a 16-bit Opcode (offset 6; 1 request, 2 reply,
|
|
19
|
+
* 3 RARP request, 4 RARP reply — other values are flagged as an error but kept), then the four address
|
|
20
|
+
* fields: Sender MAC (`sender.mac`, 6 octets, offset 8) and Sender IPv4 (`sender.ipv4`, 4 octets, offset
|
|
21
|
+
* 14), Target MAC (`target.mac`, 6 octets, offset 18) and Target IPv4 (`target.ipv4`, 4 octets, offset
|
|
22
|
+
* 24). The schema groups the two `hardware`/`protocol` sub-objects and two `sender`/`target` sub-objects
|
|
23
|
+
* for the UI, but each field reads its own fixed offset, so the on-wire interleaving is preserved.
|
|
24
|
+
*
|
|
25
|
+
* The 6-octet MAC and 4-octet IPv4 widths are fixed here (Ethernet + IPv4 ARP), independent of the
|
|
26
|
+
* declared hardware/protocol sizes. Values are range-clamped rather than rejected. match() keys purely
|
|
27
|
+
* on the parent's EtherType being 0x0806.
|
|
28
|
+
*/
|
|
29
|
+
class ARP extends BaseHeader_1.BaseHeader {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
this.SCHEMA = {
|
|
33
|
+
type: 'object',
|
|
34
|
+
properties: {
|
|
35
|
+
hardware: {
|
|
36
|
+
type: 'object',
|
|
37
|
+
label: 'Hardware',
|
|
38
|
+
properties: {
|
|
39
|
+
type: {
|
|
40
|
+
type: 'number',
|
|
41
|
+
label: 'Type',
|
|
42
|
+
minimum: 0,
|
|
43
|
+
maximum: 65535,
|
|
44
|
+
decode: () => {
|
|
45
|
+
//Hardware type is an unsigned 16-bit field (RFC 826); a signed read would
|
|
46
|
+
//turn values >= 0x8000 negative and mismatch the unsigned encode path.
|
|
47
|
+
this.instance.hardware.type.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(0, 2)));
|
|
48
|
+
},
|
|
49
|
+
encode: () => {
|
|
50
|
+
let hwType = this.instance.hardware.type.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
51
|
+
if (hwType > 65535) {
|
|
52
|
+
this.recordError(this.instance.hardware.type.getPath(), 'Maximum value is 65535');
|
|
53
|
+
hwType = 65535;
|
|
54
|
+
}
|
|
55
|
+
if (hwType < 0) {
|
|
56
|
+
this.recordError(this.instance.hardware.type.getPath(), 'Minimum value is 0');
|
|
57
|
+
hwType = 0;
|
|
58
|
+
}
|
|
59
|
+
this.instance.hardware.type.setValue(hwType);
|
|
60
|
+
this.writeBytes(0, (0, NumberToBuffer_1.UInt16ToBuffer)(hwType));
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
size: {
|
|
64
|
+
type: 'number',
|
|
65
|
+
label: 'Size',
|
|
66
|
+
minimum: 0,
|
|
67
|
+
maximum: 255,
|
|
68
|
+
decode: () => {
|
|
69
|
+
this.instance.hardware.size.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(4, 1)));
|
|
70
|
+
},
|
|
71
|
+
encode: () => {
|
|
72
|
+
let hwSize = this.instance.hardware.size.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
73
|
+
if (hwSize > 255) {
|
|
74
|
+
this.recordError(this.instance.hardware.size.getPath(), 'Maximum value is 255');
|
|
75
|
+
hwSize = 255;
|
|
76
|
+
}
|
|
77
|
+
if (hwSize < 0) {
|
|
78
|
+
this.recordError(this.instance.hardware.size.getPath(), 'Minimum value is 0');
|
|
79
|
+
hwSize = 0;
|
|
80
|
+
}
|
|
81
|
+
this.instance.hardware.size.setValue(hwSize);
|
|
82
|
+
this.writeBytes(4, (0, NumberToBuffer_1.UInt8ToBuffer)(hwSize));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
protocol: {
|
|
88
|
+
type: 'object',
|
|
89
|
+
label: 'Protocol',
|
|
90
|
+
properties: {
|
|
91
|
+
type: {
|
|
92
|
+
type: 'string',
|
|
93
|
+
label: 'Type',
|
|
94
|
+
minLength: 4,
|
|
95
|
+
maxLength: 4,
|
|
96
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
97
|
+
decode: () => {
|
|
98
|
+
this.instance.protocol.type.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(2, 2)));
|
|
99
|
+
},
|
|
100
|
+
encode: () => {
|
|
101
|
+
const protoTypeHex = this.instance.protocol.type.getValue('0000', (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
102
|
+
let protoType = (0, HexToNumber_1.HexToUInt16)(protoTypeHex);
|
|
103
|
+
if (isNaN(protoType)) {
|
|
104
|
+
this.recordError(this.instance.protocol.type.getPath(), 'Invalid hex value');
|
|
105
|
+
protoType = 0;
|
|
106
|
+
}
|
|
107
|
+
this.instance.protocol.type.setValue(protoType);
|
|
108
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(protoType));
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
size: {
|
|
112
|
+
type: 'number',
|
|
113
|
+
label: 'Size',
|
|
114
|
+
minimum: 0,
|
|
115
|
+
maximum: 255,
|
|
116
|
+
decode: () => {
|
|
117
|
+
this.instance.protocol.size.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(5, 1)));
|
|
118
|
+
},
|
|
119
|
+
encode: () => {
|
|
120
|
+
let protoSize = this.instance.protocol.size.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
121
|
+
if (protoSize > 255) {
|
|
122
|
+
this.recordError(this.instance.protocol.size.getPath(), 'Maximum value is 255');
|
|
123
|
+
protoSize = 255;
|
|
124
|
+
}
|
|
125
|
+
if (protoSize < 0) {
|
|
126
|
+
this.recordError(this.instance.protocol.size.getPath(), 'Minimum value is 0');
|
|
127
|
+
protoSize = 0;
|
|
128
|
+
}
|
|
129
|
+
this.instance.protocol.size.setValue(protoSize);
|
|
130
|
+
this.writeBytes(5, (0, NumberToBuffer_1.UInt8ToBuffer)(protoSize));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
opcode: {
|
|
136
|
+
type: 'number',
|
|
137
|
+
label: 'Opcode',
|
|
138
|
+
enum: [1, 2, 3, 4],
|
|
139
|
+
decode: () => {
|
|
140
|
+
this.instance.opcode.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(6, 2)));
|
|
141
|
+
if (![1, 2, 3, 4].includes(this.instance.opcode.getValue()))
|
|
142
|
+
this.recordError(this.instance.opcode.getPath(), 'Opcode should be 1, 2, 3 or 4');
|
|
143
|
+
},
|
|
144
|
+
encode: () => {
|
|
145
|
+
const opcode = this.instance.opcode.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
146
|
+
if (![1, 2, 3, 4].includes(opcode))
|
|
147
|
+
this.recordError(this.instance.opcode.getPath(), 'Opcode should be 1, 2, 3 or 4');
|
|
148
|
+
this.instance.opcode.setValue(opcode);
|
|
149
|
+
this.writeBytes(6, (0, NumberToBuffer_1.UInt16ToBuffer)(opcode));
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
sender: {
|
|
153
|
+
type: 'object',
|
|
154
|
+
label: 'Sender',
|
|
155
|
+
properties: {
|
|
156
|
+
mac: {
|
|
157
|
+
type: 'string',
|
|
158
|
+
label: 'MAC address',
|
|
159
|
+
minLength: 17,
|
|
160
|
+
maxLength: 17,
|
|
161
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.UTF8,
|
|
162
|
+
decode: () => {
|
|
163
|
+
const macAddrBuffer = Buffer.alloc(6, this.readBytes(8, 6));
|
|
164
|
+
this.instance.sender.mac.setValue(Array.from(macAddrBuffer).map((value) => (0, NumberToHex_1.UInt8ToHex)(value)).join(':'));
|
|
165
|
+
},
|
|
166
|
+
encode: () => {
|
|
167
|
+
const macStr = this.instance.sender.mac.getValue();
|
|
168
|
+
const rawMacBuffer = Buffer.from(macStr.split(':').map((value) => parseInt(value, 16)).map((value) => value ? value : 0));
|
|
169
|
+
if (rawMacBuffer.length !== 6)
|
|
170
|
+
this.recordError(this.instance.sender.mac.getPath(), 'Invalid MAC address length');
|
|
171
|
+
this.writeBytes(8, Buffer.alloc(6, rawMacBuffer));
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
ipv4: {
|
|
175
|
+
type: 'string',
|
|
176
|
+
label: 'IP address',
|
|
177
|
+
minLength: 7,
|
|
178
|
+
maxLength: 15,
|
|
179
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.UTF8,
|
|
180
|
+
decode: () => {
|
|
181
|
+
const ipv4Buffer = Buffer.alloc(4, this.readBytes(14, 4));
|
|
182
|
+
this.instance.sender.ipv4.setValue((0, BufferToIP_1.BufferToIPv4)(ipv4Buffer));
|
|
183
|
+
},
|
|
184
|
+
encode: () => {
|
|
185
|
+
const ipv4Str = this.instance.sender.ipv4.getValue();
|
|
186
|
+
this.writeBytes(14, (0, IPToBuffer_1.IPv4ToBuffer)(ipv4Str));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
target: {
|
|
192
|
+
type: 'object',
|
|
193
|
+
label: 'Target',
|
|
194
|
+
properties: {
|
|
195
|
+
mac: {
|
|
196
|
+
type: 'string',
|
|
197
|
+
label: 'MAC address',
|
|
198
|
+
minLength: 17,
|
|
199
|
+
maxLength: 17,
|
|
200
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.UTF8,
|
|
201
|
+
decode: () => {
|
|
202
|
+
const macAddrBuffer = Buffer.alloc(6, this.readBytes(18, 6));
|
|
203
|
+
this.instance.target.mac.setValue(Array.from(macAddrBuffer).map((value) => (0, NumberToHex_1.UInt8ToHex)(value)).join(':'));
|
|
204
|
+
},
|
|
205
|
+
encode: () => {
|
|
206
|
+
const macStr = this.instance.target.mac.getValue();
|
|
207
|
+
const rawMacBuffer = Buffer.from(macStr.split(':').map((value) => parseInt(value, 16)).map((value) => value ? value : 0));
|
|
208
|
+
if (rawMacBuffer.length !== 6)
|
|
209
|
+
this.recordError(this.instance.target.mac.getPath(), 'Invalid MAC address length');
|
|
210
|
+
this.writeBytes(18, Buffer.alloc(6, rawMacBuffer));
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
ipv4: {
|
|
214
|
+
type: 'string',
|
|
215
|
+
label: 'IP address',
|
|
216
|
+
minLength: 7,
|
|
217
|
+
maxLength: 15,
|
|
218
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.UTF8,
|
|
219
|
+
decode: () => {
|
|
220
|
+
const ipv4Buffer = Buffer.alloc(4, this.readBytes(24, 4));
|
|
221
|
+
this.instance.target.ipv4.setValue((0, BufferToIP_1.BufferToIPv4)(ipv4Buffer));
|
|
222
|
+
},
|
|
223
|
+
encode: () => {
|
|
224
|
+
const ipv4Str = this.instance.target.ipv4.getValue();
|
|
225
|
+
this.writeBytes(24, (0, IPToBuffer_1.IPv4ToBuffer)(ipv4Str));
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
this.id = 'arp';
|
|
233
|
+
this.matchKeys = ['ethertype:0806'];
|
|
234
|
+
this.name = 'Address Resolution Protocol';
|
|
235
|
+
this.nickname = 'ARP';
|
|
236
|
+
}
|
|
237
|
+
match() {
|
|
238
|
+
if (!this.prevCodecModule)
|
|
239
|
+
return false;
|
|
240
|
+
return this.prevCodecModule.instance.etherType.getValue() === (0, NumberToHex_1.UInt16ToHex)(0x0806);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
exports.ARP = ARP;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* BACnet/IP — the BACnet Virtual Link Control (BVLC) layer that carries BACnet over UDP (ANSI/ASHRAE
|
|
6
|
+
* 135 Annex J), UDP port 47808 (0xBAC0). Every message starts with a 4-byte BVLC header: a Type octet
|
|
7
|
+
* (0x81 for BACnet/IP), a Function octet (e.g. Original-Unicast-NPDU 0x0A, Original-Broadcast-NPDU 0x0B,
|
|
8
|
+
* Forwarded-NPDU 0x04, BVLC-Result 0x00), and a 2-byte Length that counts the WHOLE BVLC message
|
|
9
|
+
* (header + everything after). The bytes after the header are the NPDU and APDU (and, for a few
|
|
10
|
+
* functions, a BVLC-specific address prefix).
|
|
11
|
+
*
|
|
12
|
+
* This codec decodes the BVLC header structurally and keeps the NPDU + APDU verbatim as `payload` hex,
|
|
13
|
+
* bounded by the BVLC Length (so a trailing/coalesced datagram is left to RawData). The NPDU's
|
|
14
|
+
* conditional routing fields are intricate enough that structuring them belongs to a later slice. The
|
|
15
|
+
* Length is honored when supplied, else derived from the payload; a well-formed message round-trips
|
|
16
|
+
* byte-for-byte.
|
|
17
|
+
*/
|
|
18
|
+
export declare class BACnetIP extends BaseHeader {
|
|
19
|
+
#private;
|
|
20
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly nickname: string;
|
|
24
|
+
readonly matchKeys: string[];
|
|
25
|
+
match(): boolean;
|
|
26
|
+
readonly demuxProducers: DemuxProducer[];
|
|
27
|
+
}
|