@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,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.IRC = void 0;
|
|
5
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
6
|
+
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
7
|
+
const HexToBuffer_1 = require("../helper/HexToBuffer");
|
|
8
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
9
|
+
/** IRC command words (RFC 1459 / RFC 2812 + CAP/SASL) used only to recognize a message line. */
|
|
10
|
+
const IRC_COMMANDS = ['PASS', 'NICK', 'USER', 'OPER', 'MODE', 'SERVICE', 'QUIT', 'SQUIT', 'JOIN', 'PART', 'TOPIC', 'NAMES', 'LIST', 'INVITE', 'KICK', 'PRIVMSG', 'NOTICE', 'MOTD', 'LUSERS', 'VERSION', 'STATS', 'LINKS', 'TIME', 'CONNECT', 'TRACE', 'ADMIN', 'INFO', 'SERVLIST', 'SQUERY', 'WHO', 'WHOIS', 'WHOWAS', 'KILL', 'PING', 'PONG', 'ERROR', 'AWAY', 'REHASH', 'DIE', 'RESTART', 'SUMMON', 'USERS', 'WALLOPS', 'USERHOST', 'ISON', 'CAP', 'AUTHENTICATE'];
|
|
11
|
+
/**
|
|
12
|
+
* IRC — the Internet Relay Chat protocol (RFC 1459 / RFC 2812), carried as US-ASCII text over TCP
|
|
13
|
+
* well-known port 6667 (or 6697 for the TLS-wrapped IRC-over-TLS bucket). The channel is line-based: each
|
|
14
|
+
* message is an optional `:prefix` (source), then a COMMAND (a verb word like PRIVMSG/JOIN/NICK, or a
|
|
15
|
+
* 3-digit numeric reply code such as 001/433), then space-separated params with an optional ` :trailing`
|
|
16
|
+
* argument, terminated by CRLF. A client sends `NICK alice\r\n`, `JOIN #chan\r\n`, `PRIVMSG #chan :hi\r\n`;
|
|
17
|
+
* a server prefixes its messages with the source (`:server 001 alice :Welcome\r\n`,
|
|
18
|
+
* `:nick!user@host PRIVMSG #chan :hi\r\n`).
|
|
19
|
+
*
|
|
20
|
+
* Like FTP, SMTP, POP3, Syslog, SIP and HTTP, the message is text whose full internal structure
|
|
21
|
+
* (arbitrary params, significant whitespace, an optional trailing argument, multiple lines per segment)
|
|
22
|
+
* is richer than a form needs. So the ENTIRE raw message is kept verbatim as the authoritative `message`
|
|
23
|
+
* field (hex) and re-emitted untouched; only the FIRST line is parsed on decode into display-only
|
|
24
|
+
* metadata (prefix/command/params/isNumeric). Encode never reconstructs the message from the parsed
|
|
25
|
+
* fields — it writes `message` back byte-for-byte — so any conformant (or even malformed) IRC line
|
|
26
|
+
* round-trips exactly.
|
|
27
|
+
*
|
|
28
|
+
* Note: a single TCP segment may carry more than one line (IRC peers pipeline freely) or only part of a
|
|
29
|
+
* line; reassembly across segments is out of scope. This single-segment codec keeps whatever bytes are
|
|
30
|
+
* present verbatim, which is byte-perfect for the single-packet case.
|
|
31
|
+
*/
|
|
32
|
+
class IRC extends BaseHeader_1.BaseHeader {
|
|
33
|
+
constructor() {
|
|
34
|
+
super(...arguments);
|
|
35
|
+
this.id = 'irc';
|
|
36
|
+
this.name = 'Internet Relay Chat';
|
|
37
|
+
this.nickname = 'IRC';
|
|
38
|
+
//IRC is recognized ONLY on its well-known port buckets 6667 (plaintext) and 6697 (IRC-over-TLS) —
|
|
39
|
+
//deliberately NOT via heuristicFallback. Unlike HTTP/RTSP (whose method sets are distinctive), IRC's
|
|
40
|
+
//line signature is a generic verb (USER/QUIT/LIST/…) or a 3-digit numeric that is SHARED with other
|
|
41
|
+
//US-ASCII line protocols this codec also models — FTP (USER/QUIT/LIST + NNN codes), POP3/SMTP
|
|
42
|
+
//(USER/QUIT). The FTP code review found exactly this collision: an IRC `USER`/`QUIT` line is
|
|
43
|
+
//indistinguishable from an FTP one. Joining the global heuristic chain would let IRC mislabel an FTP
|
|
44
|
+
//`USER`/`LIST` line (or an FTP NNN greeting) on tcp:21 as IRC (and vice-versa). Confining IRC to the
|
|
45
|
+
//tcp:6667/tcp:6697 buckets keeps that collision impossible (FTP/POP3/SMTP live on 21/110/25, which
|
|
46
|
+
//never reach these buckets); alt-port IRC is rare and falls losslessly to raw. (IRC-over-TLS on 6697
|
|
47
|
+
//is normally TLS-wrapped, so the bucket rarely carries plain IRC text, but is listed for completeness.)
|
|
48
|
+
this.matchKeys = ['tcpport:6667', 'tcpport:6697'];
|
|
49
|
+
//A leaf header — the IRC session/dialog it belongs to is a higher-layer concern.
|
|
50
|
+
this.demuxProducers = [];
|
|
51
|
+
}
|
|
52
|
+
static #schemaCache;
|
|
53
|
+
get SCHEMA() {
|
|
54
|
+
return (_a.#schemaCache ??= _a.#buildSchema());
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Bytes of this header: IRC rides on TCP, which has no per-message length, so take the rest of the
|
|
58
|
+
* segment. Reassembly across segments is out of scope (see class doc).
|
|
59
|
+
*/
|
|
60
|
+
#payloadLength() {
|
|
61
|
+
const available = this.packet.length - this.startPos;
|
|
62
|
+
return available < 0 ? 0 : available;
|
|
63
|
+
}
|
|
64
|
+
/** The first line of the message (up to the first CRLF, or the whole payload if none). */
|
|
65
|
+
static #firstLine(text) {
|
|
66
|
+
const idx = text.indexOf('\r\n');
|
|
67
|
+
return idx >= 0 ? text.slice(0, idx) : text;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Parse the first line into the display-only metadata fields. An IRC message is
|
|
71
|
+
* `[':' prefix SP] COMMAND [params] [SP ':' trailing]`: if the line begins with `:` the token up to
|
|
72
|
+
* the first space is the source prefix (e.g. 'server' or 'nick!user@host'), otherwise there is no
|
|
73
|
+
* prefix. The COMMAND is the next token — kept as-is when it is a 3-digit numeric reply code,
|
|
74
|
+
* uppercased when it is a verb word; params is the remainder of the line (including any `:trailing`).
|
|
75
|
+
* Populated on decode only — these fields have no encode, so they never affect the re-emitted bytes
|
|
76
|
+
* and never mutate `message`. This is a pragmatic display split; never throws: missing/garbage tokens
|
|
77
|
+
* yield empty strings.
|
|
78
|
+
*/
|
|
79
|
+
#parseFirstLine(text) {
|
|
80
|
+
const line = _a.#firstLine(text);
|
|
81
|
+
let rest = line;
|
|
82
|
+
let prefix = '';
|
|
83
|
+
if (rest.startsWith(':')) {
|
|
84
|
+
//A prefixed (server-originated) message: ':' source SP <rest>.
|
|
85
|
+
const sp = rest.indexOf(' ');
|
|
86
|
+
if (sp >= 0) {
|
|
87
|
+
prefix = rest.slice(1, sp);
|
|
88
|
+
rest = rest.slice(sp + 1).replace(/^ +/, '');
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
prefix = rest.slice(1);
|
|
92
|
+
rest = '';
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//COMMAND is the leading token of what remains; params is everything after it.
|
|
96
|
+
const idx = rest.indexOf(' ');
|
|
97
|
+
const rawCommand = idx >= 0 ? rest.slice(0, idx) : rest;
|
|
98
|
+
const params = idx >= 0 ? rest.slice(idx + 1) : '';
|
|
99
|
+
const isNumeric = /^\d{3}$/.test(rawCommand);
|
|
100
|
+
this.instance.prefix.setValue(prefix);
|
|
101
|
+
this.instance.command.setValue(isNumeric ? rawCommand : rawCommand.toUpperCase());
|
|
102
|
+
this.instance.params.setValue(params);
|
|
103
|
+
this.instance.isNumeric.setValue(isNumeric);
|
|
104
|
+
}
|
|
105
|
+
static #buildSchema() {
|
|
106
|
+
return {
|
|
107
|
+
type: 'object',
|
|
108
|
+
summary: 'IRC ${command}',
|
|
109
|
+
properties: {
|
|
110
|
+
//The whole raw message is the single source of truth: decoded verbatim to hex and
|
|
111
|
+
//re-emitted untouched (byte-perfect for any IRC message text). The first line is parsed
|
|
112
|
+
//into the display-only metadata below, which carry no codec of their own.
|
|
113
|
+
message: {
|
|
114
|
+
type: 'string',
|
|
115
|
+
label: 'Message',
|
|
116
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
117
|
+
decode: function () {
|
|
118
|
+
const available = this.#payloadLength();
|
|
119
|
+
if (available <= 0) {
|
|
120
|
+
this.instance.message.setValue('');
|
|
121
|
+
this.#parseFirstLine('');
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const raw = this.readBytes(0, available);
|
|
125
|
+
this.instance.message.setValue((0, BufferToHex_1.BufferToHex)(raw));
|
|
126
|
+
this.#parseFirstLine(raw.toString('latin1'));
|
|
127
|
+
},
|
|
128
|
+
encode: function () {
|
|
129
|
+
//Re-emit the authoritative message verbatim — never reconstruct from metadata.
|
|
130
|
+
this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(this.instance.message.getValue('')));
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
//Display-only metadata parsed from the first line on decode (no encode — populated by the
|
|
134
|
+
//message field above, never read back). prefix is the optional message source; command is
|
|
135
|
+
//the verb word or numeric reply code; params is the remainder (including any :trailing);
|
|
136
|
+
//isNumeric marks a 3-digit numeric reply.
|
|
137
|
+
prefix: { type: 'string', label: 'Prefix' },
|
|
138
|
+
command: { type: 'string', label: 'Command' },
|
|
139
|
+
params: { type: 'string', label: 'Params' },
|
|
140
|
+
isNumeric: { type: 'boolean', label: 'Is Numeric' }
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
match() {
|
|
145
|
+
//IRC rides on TCP as US-ASCII text. Recognize it by the line signature: either a prefixed
|
|
146
|
+
//server message (`:` source SP COMMAND …) whose command token is a known verb/numeric, or a
|
|
147
|
+
//leading token that is itself a known verb/numeric — so non-IRC traffic on port 6667/6697 falls
|
|
148
|
+
//through to raw rather than claiming an un-decodable text layer.
|
|
149
|
+
if (!this.prevCodecModule)
|
|
150
|
+
return false;
|
|
151
|
+
if (this.prevCodecModule.id !== 'tcp')
|
|
152
|
+
return false;
|
|
153
|
+
if (this.#payloadLength() < 4)
|
|
154
|
+
return false;
|
|
155
|
+
const lead = this.readBytes(0, 128, true).toString('latin1');
|
|
156
|
+
const line = _a.#firstLine(lead);
|
|
157
|
+
if (line.startsWith(':')) {
|
|
158
|
+
//A prefixed message: require ':' + a non-space source, then a space, then a command token.
|
|
159
|
+
//This keeps the `:` branch from over-claiming (a bare `:` or `: …` is not IRC).
|
|
160
|
+
const sp = line.indexOf(' ');
|
|
161
|
+
if (sp <= 1)
|
|
162
|
+
return false;
|
|
163
|
+
const rest = line.slice(sp + 1).replace(/^ +/, '');
|
|
164
|
+
const token = (rest.split(/[ \r]/)[0] || '').toUpperCase();
|
|
165
|
+
if (!token)
|
|
166
|
+
return false;
|
|
167
|
+
return /^\d{3}$/.test(token) || IRC_COMMANDS.includes(token);
|
|
168
|
+
}
|
|
169
|
+
//An unprefixed (typically client) message: the leading token must be a known verb or numeric.
|
|
170
|
+
const token = (line.split(/[ \r]/)[0] || '').toUpperCase();
|
|
171
|
+
return /^\d{3}$/.test(token) || IRC_COMMANDS.includes(token);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.IRC = IRC;
|
|
175
|
+
_a = IRC;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* ISAKMP / IKE — Internet Security Association and Key Management Protocol carrying IKEv1 (RFC 2408 /
|
|
6
|
+
* RFC 2409) and IKEv2 (RFC 7296), UDP port 500 (NAT-T also uses 4500 with a 4-byte non-ESP marker
|
|
7
|
+
* prefix — out of scope for this slice, which matches port 500 only). A 28-byte fixed header (all
|
|
8
|
+
* big-endian): the 8-byte Initiator and 8-byte Responder SPIs (cookies), a Next Payload selector, a
|
|
9
|
+
* split Version byte (high nibble = major, low nibble = minor; IKEv1 is 0x10, IKEv2 is 0x20), the
|
|
10
|
+
* Exchange Type, a flags byte, the 4-byte Message ID, and the 4-byte total message Length (header +
|
|
11
|
+
* all payloads). The header is followed by a chain of generic payloads walked via each payload's own
|
|
12
|
+
* Next Payload / Payload Length until Next Payload == 0 (or the message Length / UDP payload is
|
|
13
|
+
* consumed).
|
|
14
|
+
*
|
|
15
|
+
* Payloads are carried generically (Next Payload + critical/reserved + length + verbatim body hex) so
|
|
16
|
+
* every payload — SA proposals, KE, Nonce, encrypted payloads — round-trips byte-for-byte; per-payload
|
|
17
|
+
* semantic decoding is a later enrichment. The chain walk is bounded by the message Length (honored
|
|
18
|
+
* else derived on encode) clamped by the UDP payload, so any trailing bytes spill to the raw layer.
|
|
19
|
+
*/
|
|
20
|
+
export declare class ISAKMP extends BaseHeader {
|
|
21
|
+
#private;
|
|
22
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
23
|
+
readonly id: string;
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly nickname: string;
|
|
26
|
+
readonly matchKeys: string[];
|
|
27
|
+
match(): boolean;
|
|
28
|
+
readonly demuxProducers: DemuxProducer[];
|
|
29
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ISAKMP = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
6
|
+
const HexToBuffer_1 = require("../helper/HexToBuffer");
|
|
7
|
+
const BufferToNumber_1 = require("../helper/BufferToNumber");
|
|
8
|
+
const NumberToBuffer_1 = require("../helper/NumberToBuffer");
|
|
9
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
10
|
+
/**
|
|
11
|
+
* ISAKMP / IKE — Internet Security Association and Key Management Protocol carrying IKEv1 (RFC 2408 /
|
|
12
|
+
* RFC 2409) and IKEv2 (RFC 7296), UDP port 500 (NAT-T also uses 4500 with a 4-byte non-ESP marker
|
|
13
|
+
* prefix — out of scope for this slice, which matches port 500 only). A 28-byte fixed header (all
|
|
14
|
+
* big-endian): the 8-byte Initiator and 8-byte Responder SPIs (cookies), a Next Payload selector, a
|
|
15
|
+
* split Version byte (high nibble = major, low nibble = minor; IKEv1 is 0x10, IKEv2 is 0x20), the
|
|
16
|
+
* Exchange Type, a flags byte, the 4-byte Message ID, and the 4-byte total message Length (header +
|
|
17
|
+
* all payloads). The header is followed by a chain of generic payloads walked via each payload's own
|
|
18
|
+
* Next Payload / Payload Length until Next Payload == 0 (or the message Length / UDP payload is
|
|
19
|
+
* consumed).
|
|
20
|
+
*
|
|
21
|
+
* Payloads are carried generically (Next Payload + critical/reserved + length + verbatim body hex) so
|
|
22
|
+
* every payload — SA proposals, KE, Nonce, encrypted payloads — round-trips byte-for-byte; per-payload
|
|
23
|
+
* semantic decoding is a later enrichment. The chain walk is bounded by the message Length (honored
|
|
24
|
+
* else derived on encode) clamped by the UDP payload, so any trailing bytes spill to the raw layer.
|
|
25
|
+
*/
|
|
26
|
+
class ISAKMP extends BaseHeader_1.BaseHeader {
|
|
27
|
+
constructor() {
|
|
28
|
+
super(...arguments);
|
|
29
|
+
this.id = 'isakmp';
|
|
30
|
+
this.name = 'ISAKMP/IKE';
|
|
31
|
+
this.nickname = 'ISAKMP';
|
|
32
|
+
this.matchKeys = ['udpport:500'];
|
|
33
|
+
//A leaf header — payload bodies are carried verbatim; nothing demuxes above ISAKMP in this slice.
|
|
34
|
+
this.demuxProducers = [];
|
|
35
|
+
}
|
|
36
|
+
static #schemaCache;
|
|
37
|
+
get SCHEMA() {
|
|
38
|
+
return (ISAKMP.#schemaCache ??= ISAKMP.#buildSchema());
|
|
39
|
+
}
|
|
40
|
+
/** Bytes available for this ISAKMP message: the frame end, clamped by the UDP payload and the message Length. */
|
|
41
|
+
#available() {
|
|
42
|
+
let available = this.packet.length - this.startPos;
|
|
43
|
+
if (this.prevCodecModule && this.prevCodecModule.id === 'udp') {
|
|
44
|
+
const udpLength = this.prevCodecModule.instance.length.getValue(0);
|
|
45
|
+
if (udpLength >= 8 && udpLength - 8 < available)
|
|
46
|
+
available = udpLength - 8;
|
|
47
|
+
}
|
|
48
|
+
//During match() the Length field is not yet decoded (getValue → 0), so this reduces to the
|
|
49
|
+
//UDP-payload bound; during decode it is set and tightens the payload-chain walk.
|
|
50
|
+
const length = this.instance.length.getValue(0);
|
|
51
|
+
if (length >= 28 && length < available)
|
|
52
|
+
available = length;
|
|
53
|
+
return available < 0 ? 0 : available;
|
|
54
|
+
}
|
|
55
|
+
static #buildSchema() {
|
|
56
|
+
return {
|
|
57
|
+
type: 'object',
|
|
58
|
+
summary: 'ISAKMP exch=${exchangeType}',
|
|
59
|
+
properties: {
|
|
60
|
+
initiatorSPI: this.fieldHex('initiatorSPI', 0, 8, 'Initiator SPI'),
|
|
61
|
+
responderSPI: this.fieldHex('responderSPI', 8, 8, 'Responder SPI'),
|
|
62
|
+
nextPayload: this.fieldUInt('nextPayload', 16, 1, 'Next Payload'),
|
|
63
|
+
//Version byte (offset 17): high nibble = major, low nibble = minor. IKEv1 = 1.0 (0x10),
|
|
64
|
+
//IKEv2 = 2.0 (0x20). Split into nibbles (lossless: the whole byte is major+minor).
|
|
65
|
+
version: {
|
|
66
|
+
type: 'object',
|
|
67
|
+
label: 'Version',
|
|
68
|
+
properties: {
|
|
69
|
+
major: {
|
|
70
|
+
type: 'integer', label: 'Major', minimum: 0, maximum: 15,
|
|
71
|
+
decode: function () { this.instance.version.major.setValue(this.readBits(17, 1, 0, 4)); },
|
|
72
|
+
encode: function () { this.writeBits(17, 1, 0, 4, this.instance.version.major.getValue(2)); }
|
|
73
|
+
},
|
|
74
|
+
minor: {
|
|
75
|
+
type: 'integer', label: 'Minor', minimum: 0, maximum: 15,
|
|
76
|
+
decode: function () { this.instance.version.minor.setValue(this.readBits(17, 1, 4, 4)); },
|
|
77
|
+
encode: function () { this.writeBits(17, 1, 4, 4, this.instance.version.minor.getValue(0)); }
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
exchangeType: this.fieldUInt('exchangeType', 18, 1, 'Exchange Type'),
|
|
82
|
+
//Flags byte (offset 19) kept whole: IKEv2 uses bit X(0x08 Initiator)/V(0x10 Version)/
|
|
83
|
+
//R(0x20 Response); IKEv1 uses E/C/A. Carried verbatim so any flag combination round-trips.
|
|
84
|
+
flags: this.fieldUInt('flags', 19, 1, 'Flags'),
|
|
85
|
+
messageId: this.fieldUInt('messageId', 20, 4, 'Message ID'),
|
|
86
|
+
length: {
|
|
87
|
+
type: 'integer',
|
|
88
|
+
label: 'Length',
|
|
89
|
+
minimum: 0,
|
|
90
|
+
maximum: 4294967295,
|
|
91
|
+
decode: function () {
|
|
92
|
+
this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt32)(this.readBytes(24, 4)));
|
|
93
|
+
},
|
|
94
|
+
encode: function () {
|
|
95
|
+
//Honor an explicitly-set Length (even a decoded malformed one, so it round-trips
|
|
96
|
+
//byte-for-byte); auto-compute the whole-message length only when absent (crafting).
|
|
97
|
+
const length = this.instance.length.getValue();
|
|
98
|
+
if (length !== undefined && length !== null) {
|
|
99
|
+
this.instance.length.setValue(length);
|
|
100
|
+
this.writeBytes(24, (0, NumberToBuffer_1.UInt32ToBuffer)(length));
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
this.writeBytes(24, (0, NumberToBuffer_1.UInt32ToBuffer)(0));
|
|
104
|
+
//After the payload chain has encoded, the header length is the whole message.
|
|
105
|
+
this.addPostSelfEncodeHandler(() => {
|
|
106
|
+
this.instance.length.setValue(this.length);
|
|
107
|
+
this.writeBytes(24, (0, NumberToBuffer_1.UInt32ToBuffer)(this.length));
|
|
108
|
+
}, 1);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
payloads: {
|
|
113
|
+
type: 'array',
|
|
114
|
+
label: 'Payloads',
|
|
115
|
+
items: {
|
|
116
|
+
type: 'object',
|
|
117
|
+
label: 'Payload',
|
|
118
|
+
properties: {
|
|
119
|
+
nextPayload: { type: 'integer', label: 'Next Payload', minimum: 0, maximum: 255 },
|
|
120
|
+
critical: { type: 'boolean', label: 'Critical' },
|
|
121
|
+
reserved: { type: 'integer', label: 'Reserved', minimum: 0, maximum: 127, hidden: true },
|
|
122
|
+
payloadLength: { type: 'integer', label: 'Payload Length', minimum: 0, maximum: 65535 },
|
|
123
|
+
body: { type: 'string', label: 'Body', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
decode: function () {
|
|
127
|
+
const end = this.#available();
|
|
128
|
+
const payloads = [];
|
|
129
|
+
let offset = 28;
|
|
130
|
+
//The header's Next Payload selects the first payload's type; each generic payload
|
|
131
|
+
//header's own Next Payload selects the following one — the chain ends at 0. Probe
|
|
132
|
+
//the 4-byte generic header (dry) first; a Payload Length < 4 (would not advance) or
|
|
133
|
+
//one that overruns the message stops the walk and leaves the rest to the raw layer.
|
|
134
|
+
let next = this.instance.nextPayload.getValue(0);
|
|
135
|
+
while (next !== 0 && offset + 4 <= end) {
|
|
136
|
+
const payloadNext = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(offset, 1, true));
|
|
137
|
+
const criticalReserved = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(offset + 1, 1, true));
|
|
138
|
+
const payloadLength = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset + 2, 2, true));
|
|
139
|
+
if (payloadLength < 4 || offset + payloadLength > end)
|
|
140
|
+
break;
|
|
141
|
+
const payloadBuffer = this.readBytes(offset, payloadLength);
|
|
142
|
+
payloads.push({
|
|
143
|
+
nextPayload: payloadNext,
|
|
144
|
+
critical: !!(criticalReserved & 0x80),
|
|
145
|
+
reserved: criticalReserved & 0x7f,
|
|
146
|
+
payloadLength: payloadLength,
|
|
147
|
+
body: payloadLength > 4 ? (0, BufferToHex_1.BufferToHex)(payloadBuffer.subarray(4)) : ''
|
|
148
|
+
});
|
|
149
|
+
offset += payloadLength;
|
|
150
|
+
next = payloadNext;
|
|
151
|
+
}
|
|
152
|
+
this.instance.payloads.setValue(payloads);
|
|
153
|
+
},
|
|
154
|
+
encode: function () {
|
|
155
|
+
const payloads = this.instance.payloads.getValue([]);
|
|
156
|
+
if (!payloads)
|
|
157
|
+
return;
|
|
158
|
+
let offset = 28;
|
|
159
|
+
for (const payload of payloads) {
|
|
160
|
+
const body = (0, HexToBuffer_1.HexToBuffer)(payload.body ? payload.body : '');
|
|
161
|
+
//Honor an explicit Payload Length (byte-perfect for decoded frames), else derive
|
|
162
|
+
//it from the body (4-byte generic header + body).
|
|
163
|
+
const payloadLength = (payload.payloadLength !== undefined && payload.payloadLength !== null)
|
|
164
|
+
? payload.payloadLength
|
|
165
|
+
: body.length + 4;
|
|
166
|
+
const criticalReserved = (payload.critical ? 0x80 : 0) | ((payload.reserved ? payload.reserved : 0) & 0x7f);
|
|
167
|
+
this.writeBytes(offset, (0, NumberToBuffer_1.UInt8ToBuffer)(payload.nextPayload ? payload.nextPayload : 0));
|
|
168
|
+
this.writeBytes(offset + 1, (0, NumberToBuffer_1.UInt8ToBuffer)(criticalReserved));
|
|
169
|
+
this.writeBytes(offset + 2, (0, NumberToBuffer_1.UInt16ToBuffer)(payloadLength));
|
|
170
|
+
offset += 4;
|
|
171
|
+
if (body.length) {
|
|
172
|
+
this.writeBytes(offset, body);
|
|
173
|
+
offset += body.length;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
match() {
|
|
182
|
+
//Require the full 28-byte fixed header within the UDP payload, a plausible message Length (>= the
|
|
183
|
+
//header itself), and a major-version nibble of 1 (IKEv1) or 2 (IKEv2) — anything else on port 500
|
|
184
|
+
//(e.g. an IKE NAT keepalive 0xff, or unrelated traffic) falls through to raw. No heuristic
|
|
185
|
+
//fallback: the port bucket plus this signature is the sole selector.
|
|
186
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'udp')
|
|
187
|
+
return false;
|
|
188
|
+
if (this.#available() < 28)
|
|
189
|
+
return false;
|
|
190
|
+
const length = (0, BufferToNumber_1.BufferToUInt32)(this.readBytes(24, 4, true));
|
|
191
|
+
if (length < 28)
|
|
192
|
+
return false;
|
|
193
|
+
const major = this.readBytes(17, 1, true)[0] >> 4;
|
|
194
|
+
return major === 1 || major === 2;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
exports.ISAKMP = ISAKMP;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* iSCSI — Internet Small Computer Systems Interface (RFC 7143), TCP port 3260. Every iSCSI PDU begins
|
|
6
|
+
* with a fixed 48-byte Basic Header Segment (BHS):
|
|
7
|
+
* byte 0 : reserved bit (0x80) | Immediate bit I (0x40) | 6-bit Opcode (0x3f)
|
|
8
|
+
* byte 1 : Final/Transit bit F (0x80) | 7 opcode-specific flag bits
|
|
9
|
+
* bytes 2-3 : opcode-specific
|
|
10
|
+
* byte 4 : TotalAHSLength (count of 4-byte AHS words)
|
|
11
|
+
* bytes 5-7 : DataSegmentLength (24-bit)
|
|
12
|
+
* bytes 8-15 : LUN or opcode-specific
|
|
13
|
+
* bytes 16-19 : Initiator Task Tag
|
|
14
|
+
* bytes 20-47 : opcode-specific
|
|
15
|
+
* Opcodes include 0x00 NOP-Out, 0x01 SCSI Command, 0x03 Login Request, 0x21 SCSI Response, 0x23 Login
|
|
16
|
+
* Response. The BHS is followed by any AHS (TotalAHSLength*4 bytes), an optional header digest, the data
|
|
17
|
+
* segment (DataSegmentLength bytes padded to a 4-byte boundary), and an optional data digest.
|
|
18
|
+
*
|
|
19
|
+
* Byte-perfect strategy (minimal slice): the semantically useful values are structured — opcode /
|
|
20
|
+
* immediate / final / totalAHSLength / dataSegmentLength / initiatorTaskTag — and every other BHS byte is
|
|
21
|
+
* kept verbatim as bounded opcode-specific hex, together covering all 48 bytes exactly once (no field
|
|
22
|
+
* overlaps another, so reserved bits and opcode-specific fields round-trip untouched). DataSegmentLength
|
|
23
|
+
* is honored when supplied (a crafted PDU may lie), else derived from the actual data segment. The AHS and
|
|
24
|
+
* the (4-byte-padded) data segment follow, each bounded by the on-wire TCP payload (derived from the IP
|
|
25
|
+
* length) so a lying length never reads past the datagram; the data segment's alignment padding is
|
|
26
|
+
* consumed on decode and re-emitted as zeros on encode. This layer consumes exactly one PDU (BHS + AHS +
|
|
27
|
+
* data + pad); trailing bytes — a header/data digest (negotiated, so not modelled) or a pipelined PDU —
|
|
28
|
+
* are left to the codec's recursion / RawData. A well-formed PDU round-trips byte-for-byte.
|
|
29
|
+
*/
|
|
30
|
+
export declare class ISCSI extends BaseHeader {
|
|
31
|
+
#private;
|
|
32
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
33
|
+
readonly id: string;
|
|
34
|
+
readonly name: string;
|
|
35
|
+
readonly nickname: string;
|
|
36
|
+
readonly matchKeys: string[];
|
|
37
|
+
match(): boolean;
|
|
38
|
+
readonly demuxProducers: DemuxProducer[];
|
|
39
|
+
}
|