@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,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SMB2 = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
6
|
+
const HexToBuffer_1 = require("../helper/HexToBuffer");
|
|
7
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
8
|
+
/**
|
|
9
|
+
* SMB2 / SMB3 (MS-SMB2), TCP port 445. Over the Direct TCP transport (MS-SMB2 §2.1) every message is
|
|
10
|
+
* framed by a 4-byte transport header — a zero byte followed by a 24-bit big-endian StreamProtocolLength
|
|
11
|
+
* giving the number of SMB2 message bytes that follow — then the 64-byte SMB2 packet header, then the
|
|
12
|
+
* command-specific body.
|
|
13
|
+
*
|
|
14
|
+
* The 64-byte SMB2 header (MS-SMB2 §2.2.1.2, the SYNC form) is: ProtocolId (the 0xFE 'S' 'M' 'B' magic),
|
|
15
|
+
* StructureSize (always 64), CreditCharge, Status/ChannelSequence+Reserved, Command (0 NEGOTIATE, 1
|
|
16
|
+
* SESSION_SETUP, 3 TREE_CONNECT, 5 CREATE, 8 READ, 9 WRITE, …), CreditRequest/Response, Flags, NextCommand,
|
|
17
|
+
* MessageId, Reserved(ProcessId), TreeId, SessionId and a 16-byte Signature.
|
|
18
|
+
*
|
|
19
|
+
* ⚠️ Every multi-byte scalar in the SMB2 header is LITTLE-ENDIAN (SMB's on-wire byte order). There is no
|
|
20
|
+
* little-endian helper in this codebase, so the uint16 / uint32 fields are read and written byte-by-byte
|
|
21
|
+
* in their closures. The 8-byte MessageId / SessionId and the Signature are kept verbatim as hex (opaque,
|
|
22
|
+
* and 64-bit values exceed a JS number's exact integer range), so they round-trip byte-for-byte.
|
|
23
|
+
*
|
|
24
|
+
* The command-specific body (the NEGOTIATE dialects, SESSION_SETUP security blob, CREATE contexts, READ /
|
|
25
|
+
* WRITE data, …) is cross-message, command-dependent state, so this single-message codec keeps it verbatim
|
|
26
|
+
* as `body` hex (byte-perfect). The StreamProtocolLength is honored when supplied (a crafted frame may lie)
|
|
27
|
+
* else derived as 64 + body bytes; the message is bounded by it, so a second compounded/pipelined message
|
|
28
|
+
* or trailing bytes are left to the codec's recursion / RawData. A well-formed message round-trips
|
|
29
|
+
* byte-for-byte.
|
|
30
|
+
*/
|
|
31
|
+
class SMB2 extends BaseHeader_1.BaseHeader {
|
|
32
|
+
constructor() {
|
|
33
|
+
super(...arguments);
|
|
34
|
+
this.id = 'smb2';
|
|
35
|
+
this.name = 'SMB2';
|
|
36
|
+
this.nickname = 'SMB2';
|
|
37
|
+
this.matchKeys = ['tcpport:445'];
|
|
38
|
+
//A leaf header — the command-specific body requires per-command, cross-message parsing.
|
|
39
|
+
this.demuxProducers = [];
|
|
40
|
+
}
|
|
41
|
+
static #schemaCache;
|
|
42
|
+
get SCHEMA() {
|
|
43
|
+
return (SMB2.#schemaCache ??= SMB2.#buildSchema());
|
|
44
|
+
}
|
|
45
|
+
/** A little-endian unsigned 16-bit field of 2 octets at `offset`. */
|
|
46
|
+
static #fieldUInt16LE(name, offset, label) {
|
|
47
|
+
return {
|
|
48
|
+
type: 'integer',
|
|
49
|
+
label: label,
|
|
50
|
+
minimum: 0,
|
|
51
|
+
maximum: 65535,
|
|
52
|
+
decode: function () {
|
|
53
|
+
const b = this.readBytes(offset, 2);
|
|
54
|
+
this.instance[name].setValue(b[0] | (b[1] << 8));
|
|
55
|
+
},
|
|
56
|
+
encode: function () {
|
|
57
|
+
const node = this.instance[name];
|
|
58
|
+
let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
59
|
+
if (value > 65535) {
|
|
60
|
+
this.recordError(node.getPath(), 'Maximum value is 65535');
|
|
61
|
+
value = 65535;
|
|
62
|
+
}
|
|
63
|
+
if (value < 0) {
|
|
64
|
+
this.recordError(node.getPath(), 'Minimum value is 0');
|
|
65
|
+
value = 0;
|
|
66
|
+
}
|
|
67
|
+
node.setValue(value);
|
|
68
|
+
this.writeBytes(offset, Buffer.from([value & 0xff, (value >> 8) & 0xff]));
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** A little-endian unsigned 32-bit field of 4 octets at `offset`. */
|
|
73
|
+
static #fieldUInt32LE(name, offset, label) {
|
|
74
|
+
return {
|
|
75
|
+
type: 'integer',
|
|
76
|
+
label: label,
|
|
77
|
+
minimum: 0,
|
|
78
|
+
maximum: 4294967295,
|
|
79
|
+
decode: function () {
|
|
80
|
+
const b = this.readBytes(offset, 4);
|
|
81
|
+
this.instance[name].setValue((b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)) >>> 0);
|
|
82
|
+
},
|
|
83
|
+
encode: function () {
|
|
84
|
+
const node = this.instance[name];
|
|
85
|
+
let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
86
|
+
if (value > 4294967295) {
|
|
87
|
+
this.recordError(node.getPath(), 'Maximum value is 4294967295');
|
|
88
|
+
value = 4294967295;
|
|
89
|
+
}
|
|
90
|
+
if (value < 0) {
|
|
91
|
+
this.recordError(node.getPath(), 'Minimum value is 0');
|
|
92
|
+
value = 0;
|
|
93
|
+
}
|
|
94
|
+
node.setValue(value);
|
|
95
|
+
this.writeBytes(offset, Buffer.from([value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >>> 24) & 0xff]));
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
static #buildSchema() {
|
|
100
|
+
return {
|
|
101
|
+
type: 'object',
|
|
102
|
+
summary: 'SMB2 command=${command} messageId=${messageId}',
|
|
103
|
+
properties: {
|
|
104
|
+
//Direct TCP transport header (MS-SMB2 §2.1): byte 0 is zero (the "session message" type),
|
|
105
|
+
//bytes 1-3 are the 24-bit big-endian StreamProtocolLength. Kept as a plain octet so a
|
|
106
|
+
//crafted non-zero type still round-trips.
|
|
107
|
+
transportType: this.fieldUInt('transportType', 0, 1, 'Transport Type'),
|
|
108
|
+
//24-bit big-endian length of the SMB2 message that follows (the 64-byte header + body,
|
|
109
|
+
//excluding this 4-byte transport prefix). Honored when supplied (a crafted frame may lie);
|
|
110
|
+
//else derived as 64 + body bytes.
|
|
111
|
+
streamProtocolLength: {
|
|
112
|
+
type: 'integer',
|
|
113
|
+
label: 'Stream Protocol Length',
|
|
114
|
+
minimum: 0,
|
|
115
|
+
maximum: 16777215,
|
|
116
|
+
decode: function () {
|
|
117
|
+
const b = this.readBytes(1, 3);
|
|
118
|
+
this.instance.streamProtocolLength.setValue((b[0] << 16) | (b[1] << 8) | b[2]);
|
|
119
|
+
},
|
|
120
|
+
encode: function () {
|
|
121
|
+
const provided = this.instance.streamProtocolLength.getValue();
|
|
122
|
+
let value = (provided !== undefined && provided !== null)
|
|
123
|
+
? provided
|
|
124
|
+
: 64 + (0, HexToBuffer_1.HexToBuffer)(this.instance.body.getValue('')).length;
|
|
125
|
+
if (value > 16777215) {
|
|
126
|
+
this.recordError(this.instance.streamProtocolLength.getPath(), 'Maximum value is 16777215');
|
|
127
|
+
value = 16777215;
|
|
128
|
+
}
|
|
129
|
+
if (value < 0) {
|
|
130
|
+
this.recordError(this.instance.streamProtocolLength.getPath(), 'Minimum value is 0');
|
|
131
|
+
value = 0;
|
|
132
|
+
}
|
|
133
|
+
this.instance.streamProtocolLength.setValue(value);
|
|
134
|
+
this.writeBytes(1, Buffer.from([(value >> 16) & 0xff, (value >> 8) & 0xff, value & 0xff]));
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
//The 4-byte ProtocolId magic — 0xFE 'S' 'M' 'B' (fe534d42). Kept verbatim so a crafted
|
|
138
|
+
//magic round-trips; the match() gate enforces the real signature for selection.
|
|
139
|
+
protocolId: this.fieldHex('protocolId', 4, 4, 'Protocol Id'),
|
|
140
|
+
//StructureSize is always 64 on the wire (MS-SMB2 §2.2.1.1); kept as an honored LE uint so a
|
|
141
|
+
//crafted value round-trips (no hard constraint that would reject a lying value on re-encode).
|
|
142
|
+
structureSize: this.#fieldUInt16LE('structureSize', 8, 'Structure Size'),
|
|
143
|
+
creditCharge: this.#fieldUInt16LE('creditCharge', 10, 'Credit Charge'),
|
|
144
|
+
//Status (response) / ChannelSequence+Reserved (request) — a 4-byte LE field either way.
|
|
145
|
+
status: this.#fieldUInt32LE('status', 12, 'Status/ChannelSequence'),
|
|
146
|
+
//Command: 0 NEGOTIATE, 1 SESSION_SETUP, 2 LOGOFF, 3 TREE_CONNECT, 4 TREE_DISCONNECT, 5
|
|
147
|
+
//CREATE, 6 CLOSE, 8 READ, 9 WRITE, … (kept as a plain honored uint — no enum, so an
|
|
148
|
+
//unknown/crafted opcode still decodes and re-encodes).
|
|
149
|
+
command: this.#fieldUInt16LE('command', 16, 'Command'),
|
|
150
|
+
creditReqResp: this.#fieldUInt16LE('creditReqResp', 18, 'Credit Request/Response'),
|
|
151
|
+
flags: this.#fieldUInt32LE('flags', 20, 'Flags'),
|
|
152
|
+
//Offset of the next command in a compound request/response (0 = not compounded). This codec
|
|
153
|
+
//decodes the first message only; a non-zero NextCommand's trailing bytes fall through to raw.
|
|
154
|
+
nextCommand: this.#fieldUInt32LE('nextCommand', 24, 'Next Command'),
|
|
155
|
+
//8-byte MessageId — kept verbatim as hex (opaque LE, and a 64-bit value exceeds a JS
|
|
156
|
+
//number's exact integer range).
|
|
157
|
+
messageId: this.fieldHex('messageId', 28, 8, 'Message Id'),
|
|
158
|
+
//Reserved (ProcessId in the SYNC header; the low half of AsyncId in the ASYNC header),
|
|
159
|
+
//kept verbatim so either header form round-trips byte-for-byte.
|
|
160
|
+
reserved: this.fieldHex('reserved', 36, 4, 'Reserved'),
|
|
161
|
+
treeId: this.#fieldUInt32LE('treeId', 40, 'Tree Id'),
|
|
162
|
+
//8-byte SessionId — kept verbatim as hex (opaque LE, 64-bit).
|
|
163
|
+
sessionId: this.fieldHex('sessionId', 44, 8, 'Session Id'),
|
|
164
|
+
//16-byte message Signature (zero when unsigned) — kept verbatim.
|
|
165
|
+
signature: this.fieldHex('signature', 52, 16, 'Signature'),
|
|
166
|
+
//The command-specific body after the 64-byte header, kept verbatim. Bounded by the
|
|
167
|
+
//StreamProtocolLength (the message ends at 4 + StreamProtocolLength) and the captured bytes,
|
|
168
|
+
//so trailing / compounded / pipelined data is left to the codec's recursion / RawData.
|
|
169
|
+
body: {
|
|
170
|
+
type: 'string',
|
|
171
|
+
label: 'Body',
|
|
172
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
173
|
+
decode: function () {
|
|
174
|
+
const remaining = this.packet.length - this.startPos;
|
|
175
|
+
const streamLength = this.instance.streamProtocolLength.getValue(0);
|
|
176
|
+
let end = 4 + streamLength;
|
|
177
|
+
if (end > remaining)
|
|
178
|
+
end = remaining;
|
|
179
|
+
this.instance.body.setValue(end > 68 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(68, end - 68)) : '');
|
|
180
|
+
},
|
|
181
|
+
encode: function () {
|
|
182
|
+
const body = this.instance.body.getValue('');
|
|
183
|
+
if (body)
|
|
184
|
+
this.writeBytes(68, (0, HexToBuffer_1.HexToBuffer)(body));
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
match() {
|
|
191
|
+
//SMB2 rides on TCP port 445 (selected via the tcpport:445 bucket). Require the 4-byte transport
|
|
192
|
+
//prefix + the 0xFE 'S' 'M' 'B' (fe534d42) ProtocolId magic at offset 4 — a strong 4-byte content
|
|
193
|
+
//signature — so non-SMB2 445 traffic (and legacy SMB1's 0xFF 'S' 'M' 'B') falls through to raw.
|
|
194
|
+
//Selection stays port-bucketed (matchKeys, no heuristicFallback) like the other length-bounded
|
|
195
|
+
//TCP payload codecs.
|
|
196
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'tcp')
|
|
197
|
+
return false;
|
|
198
|
+
if (this.packet.length - this.startPos < 8)
|
|
199
|
+
return false;
|
|
200
|
+
return (0, BufferToHex_1.BufferToHex)(this.readBytes(4, 4)) === 'fe534d42';
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
exports.SMB2 = SMB2;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* Short Message Peer-to-Peer (SMPP 3.4), TCP port 2775 — the SMS-gateway ESME↔SMSC protocol. Every SMPP
|
|
6
|
+
* PDU begins with a fixed 16-byte header (all big-endian): command_length (the total octet count of the
|
|
7
|
+
* whole PDU, this header included), command_id (the operation, e.g. 0x00000001 bind_receiver,
|
|
8
|
+
* 0x00000002 bind_transmitter, 0x00000004 submit_sm, 0x00000009 bind_transceiver, 0x80000009
|
|
9
|
+
* bind_transceiver_resp — the 0x8000_0000 bit marks a response), command_status (0 = ESME_ROK on
|
|
10
|
+
* requests, the error code on responses) and sequence_number (correlates a request with its response) —
|
|
11
|
+
* followed by the command-specific body.
|
|
12
|
+
*
|
|
13
|
+
* The body layout is per-command (bind_*'s C-Octet-String system_id/password/system_type +
|
|
14
|
+
* interface_version + address fields, submit_sm's addresses and short_message, plus optional TLVs) and
|
|
15
|
+
* needs command-dependent parsing, so this single-PDU codec keeps the body verbatim as `body` hex
|
|
16
|
+
* (byte-perfect) and does not sub-decode it. command_length is auto-computed from the body on encode when
|
|
17
|
+
* not supplied, else honored verbatim (a crafted PDU may lie); the PDU is bounded by command_length so a
|
|
18
|
+
* second pipelined PDU or trailing bytes are left to the codec's recursion / RawData. A well-formed PDU
|
|
19
|
+
* round-trips byte-for-byte.
|
|
20
|
+
*
|
|
21
|
+
* command_id / command_status are decoded with unclamped uint32 fields (no hard enum) so any on-wire
|
|
22
|
+
* operation or error value survives decode→encode without being rejected.
|
|
23
|
+
*/
|
|
24
|
+
export declare class SMPP extends BaseHeader {
|
|
25
|
+
#private;
|
|
26
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly nickname: string;
|
|
30
|
+
readonly matchKeys: string[];
|
|
31
|
+
match(): boolean;
|
|
32
|
+
readonly demuxProducers: DemuxProducer[];
|
|
33
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SMPP = 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
|
+
* Short Message Peer-to-Peer (SMPP 3.4), TCP port 2775 — the SMS-gateway ESME↔SMSC protocol. Every SMPP
|
|
12
|
+
* PDU begins with a fixed 16-byte header (all big-endian): command_length (the total octet count of the
|
|
13
|
+
* whole PDU, this header included), command_id (the operation, e.g. 0x00000001 bind_receiver,
|
|
14
|
+
* 0x00000002 bind_transmitter, 0x00000004 submit_sm, 0x00000009 bind_transceiver, 0x80000009
|
|
15
|
+
* bind_transceiver_resp — the 0x8000_0000 bit marks a response), command_status (0 = ESME_ROK on
|
|
16
|
+
* requests, the error code on responses) and sequence_number (correlates a request with its response) —
|
|
17
|
+
* followed by the command-specific body.
|
|
18
|
+
*
|
|
19
|
+
* The body layout is per-command (bind_*'s C-Octet-String system_id/password/system_type +
|
|
20
|
+
* interface_version + address fields, submit_sm's addresses and short_message, plus optional TLVs) and
|
|
21
|
+
* needs command-dependent parsing, so this single-PDU codec keeps the body verbatim as `body` hex
|
|
22
|
+
* (byte-perfect) and does not sub-decode it. command_length is auto-computed from the body on encode when
|
|
23
|
+
* not supplied, else honored verbatim (a crafted PDU may lie); the PDU is bounded by command_length so a
|
|
24
|
+
* second pipelined PDU or trailing bytes are left to the codec's recursion / RawData. A well-formed PDU
|
|
25
|
+
* round-trips byte-for-byte.
|
|
26
|
+
*
|
|
27
|
+
* command_id / command_status are decoded with unclamped uint32 fields (no hard enum) so any on-wire
|
|
28
|
+
* operation or error value survives decode→encode without being rejected.
|
|
29
|
+
*/
|
|
30
|
+
class SMPP extends BaseHeader_1.BaseHeader {
|
|
31
|
+
constructor() {
|
|
32
|
+
super(...arguments);
|
|
33
|
+
this.id = 'smpp';
|
|
34
|
+
this.name = 'Short Message Peer-to-Peer';
|
|
35
|
+
this.nickname = 'SMPP';
|
|
36
|
+
this.matchKeys = ['tcpport:2775'];
|
|
37
|
+
//A leaf header — the command-specific body requires per-command, TLV-aware parsing.
|
|
38
|
+
this.demuxProducers = [];
|
|
39
|
+
}
|
|
40
|
+
static #schemaCache;
|
|
41
|
+
get SCHEMA() {
|
|
42
|
+
return (SMPP.#schemaCache ??= SMPP.#buildSchema());
|
|
43
|
+
}
|
|
44
|
+
static #buildSchema() {
|
|
45
|
+
return {
|
|
46
|
+
type: 'object',
|
|
47
|
+
summary: 'SMPP cmd=${commandId} seq=${sequenceNumber}',
|
|
48
|
+
properties: {
|
|
49
|
+
commandLength: {
|
|
50
|
+
type: 'integer',
|
|
51
|
+
label: 'Command Length',
|
|
52
|
+
//minimum 0 (not 16): a crafted/corrupt PDU may carry a command_length below the 16-byte
|
|
53
|
+
//header, and that value must round-trip (honored verbatim) rather than being rejected by
|
|
54
|
+
//Ajv at the encode entry — decode never fails, encode is a faithful executor.
|
|
55
|
+
minimum: 0,
|
|
56
|
+
maximum: 4294967295,
|
|
57
|
+
decode: function () {
|
|
58
|
+
this.instance.commandLength.setValue((0, BufferToNumber_1.BufferToUInt32)(this.readBytes(0, 4)));
|
|
59
|
+
},
|
|
60
|
+
encode: function () {
|
|
61
|
+
//command_length counts the whole PDU = 16-byte header + body. Honored when
|
|
62
|
+
//supplied (a crafted PDU may lie); else derived from the body.
|
|
63
|
+
const provided = this.instance.commandLength.getValue();
|
|
64
|
+
let value = (provided !== undefined && provided !== null)
|
|
65
|
+
? provided
|
|
66
|
+
: 16 + (0, HexToBuffer_1.HexToBuffer)(this.instance.body.getValue('')).length;
|
|
67
|
+
if (value > 4294967295) {
|
|
68
|
+
this.recordError(this.instance.commandLength.getPath(), 'Maximum value is 4294967295');
|
|
69
|
+
value = 4294967295;
|
|
70
|
+
}
|
|
71
|
+
if (value < 0) {
|
|
72
|
+
this.recordError(this.instance.commandLength.getPath(), 'Minimum value is 0');
|
|
73
|
+
value = 0;
|
|
74
|
+
}
|
|
75
|
+
this.instance.commandLength.setValue(value);
|
|
76
|
+
this.writeBytes(0, (0, NumberToBuffer_1.UInt32ToBuffer)(value));
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
//The operation code; the 0x80000000 bit marks a response. Kept as an unclamped uint32
|
|
80
|
+
//(no hard enum) so any on-wire command_id round-trips.
|
|
81
|
+
commandId: this.fieldUInt('commandId', 4, 4, 'Command ID'),
|
|
82
|
+
//0 = ESME_ROK on requests; the operation's error code on responses. Unclamped uint32.
|
|
83
|
+
commandStatus: this.fieldUInt('commandStatus', 8, 4, 'Command Status'),
|
|
84
|
+
//Correlates a request PDU with its response PDU.
|
|
85
|
+
sequenceNumber: this.fieldUInt('sequenceNumber', 12, 4, 'Sequence Number'),
|
|
86
|
+
//The command-specific body after the 16-byte header, kept verbatim. Bounded by
|
|
87
|
+
//command_length (the PDU ends at offset command_length) and the captured bytes, so
|
|
88
|
+
//trailing / pipelined data is left to the codec's recursion / RawData.
|
|
89
|
+
body: {
|
|
90
|
+
type: 'string',
|
|
91
|
+
label: 'Body',
|
|
92
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
93
|
+
decode: function () {
|
|
94
|
+
const remaining = this.packet.length - this.startPos;
|
|
95
|
+
const length = this.instance.commandLength.getValue(0);
|
|
96
|
+
let end = length;
|
|
97
|
+
if (end > remaining)
|
|
98
|
+
end = remaining;
|
|
99
|
+
this.instance.body.setValue(end > 16 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(16, end - 16)) : '');
|
|
100
|
+
},
|
|
101
|
+
encode: function () {
|
|
102
|
+
const body = this.instance.body.getValue('');
|
|
103
|
+
if (body)
|
|
104
|
+
this.writeBytes(16, (0, HexToBuffer_1.HexToBuffer)(body));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
match() {
|
|
111
|
+
//SMPP rides on TCP port 2775. The 16-byte header carries no strong content magic, so the
|
|
112
|
+
//well-known port is the signature: require the full header to be present. Selection stays
|
|
113
|
+
//port-bucketed (matchKeys) like the other length-bounded TCP payload codecs.
|
|
114
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'tcp')
|
|
115
|
+
return false;
|
|
116
|
+
return this.packet.length - this.startPos >= 16;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.SMPP = SMPP;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* SMTP — the Simple Mail Transfer Protocol (RFC 5321), carried as US-ASCII text over TCP well-known
|
|
6
|
+
* port 25 (and 587 for message submission). The control channel is line-based: a client sends commands
|
|
7
|
+
* (`EHLO host\r\n`, `MAIL FROM:<a@b>\r\n`, `RCPT TO:<c@d>\r\n`, `DATA\r\n`, `QUIT\r\n`) and a server
|
|
8
|
+
* sends replies (`220 mail.example.com ESMTP\r\n`, `250 OK\r\n`); a multi-line reply repeats the code
|
|
9
|
+
* with a '-' after the first line (`250-STARTTLS\r\n250 OK\r\n`). The DATA message body follows the same
|
|
10
|
+
* line channel but its arbitrary content is out of scope — only the control channel is claimed here.
|
|
11
|
+
*
|
|
12
|
+
* Like FTP, Syslog, SIP and HTTP, the message is text whose full internal structure (arbitrary
|
|
13
|
+
* arguments, significant whitespace, multi-line reply continuations) is richer than a form needs. So the
|
|
14
|
+
* ENTIRE raw message is kept verbatim as the authoritative `message` field (hex) and re-emitted
|
|
15
|
+
* untouched; only the first line is parsed on decode into display-only metadata (command/argument for a
|
|
16
|
+
* command, replyCode/replyText for a reply). Encode never reconstructs the message from the parsed
|
|
17
|
+
* fields — it writes `message` back byte-for-byte — so any conformant (or even malformed) SMTP line
|
|
18
|
+
* round-trips exactly.
|
|
19
|
+
*
|
|
20
|
+
* Note: a single TCP segment may carry more than one control line (pipelined commands) or only part of
|
|
21
|
+
* a multi-line reply; reassembly across segments is out of scope. This single-segment codec keeps
|
|
22
|
+
* whatever bytes are present verbatim, which is byte-perfect for the single-packet case.
|
|
23
|
+
*/
|
|
24
|
+
export declare class SMTP extends BaseHeader {
|
|
25
|
+
#private;
|
|
26
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly nickname: string;
|
|
30
|
+
readonly matchKeys: string[];
|
|
31
|
+
match(): boolean;
|
|
32
|
+
readonly demuxProducers: DemuxProducer[];
|
|
33
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.SMTP = 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
|
+
/** SMTP command verbs (RFC 5321 + common extensions) used only to recognize a command line. */
|
|
10
|
+
const SMTP_COMMANDS = ['EHLO', 'HELO', 'MAIL', 'RCPT', 'DATA', 'RSET', 'VRFY', 'EXPN', 'HELP', 'NOOP', 'QUIT', 'AUTH', 'STARTTLS', 'BDAT'];
|
|
11
|
+
/**
|
|
12
|
+
* SMTP — the Simple Mail Transfer Protocol (RFC 5321), carried as US-ASCII text over TCP well-known
|
|
13
|
+
* port 25 (and 587 for message submission). The control channel is line-based: a client sends commands
|
|
14
|
+
* (`EHLO host\r\n`, `MAIL FROM:<a@b>\r\n`, `RCPT TO:<c@d>\r\n`, `DATA\r\n`, `QUIT\r\n`) and a server
|
|
15
|
+
* sends replies (`220 mail.example.com ESMTP\r\n`, `250 OK\r\n`); a multi-line reply repeats the code
|
|
16
|
+
* with a '-' after the first line (`250-STARTTLS\r\n250 OK\r\n`). The DATA message body follows the same
|
|
17
|
+
* line channel but its arbitrary content is out of scope — only the control channel is claimed here.
|
|
18
|
+
*
|
|
19
|
+
* Like FTP, Syslog, SIP and HTTP, the message is text whose full internal structure (arbitrary
|
|
20
|
+
* arguments, significant whitespace, multi-line reply continuations) is richer than a form needs. So the
|
|
21
|
+
* ENTIRE raw message is kept verbatim as the authoritative `message` field (hex) and re-emitted
|
|
22
|
+
* untouched; only the first line is parsed on decode into display-only metadata (command/argument for a
|
|
23
|
+
* command, replyCode/replyText for a reply). Encode never reconstructs the message from the parsed
|
|
24
|
+
* fields — it writes `message` back byte-for-byte — so any conformant (or even malformed) SMTP line
|
|
25
|
+
* round-trips exactly.
|
|
26
|
+
*
|
|
27
|
+
* Note: a single TCP segment may carry more than one control line (pipelined commands) or only part of
|
|
28
|
+
* a multi-line reply; reassembly across segments is out of scope. This single-segment codec keeps
|
|
29
|
+
* whatever bytes are present verbatim, which is byte-perfect for the single-packet case.
|
|
30
|
+
*/
|
|
31
|
+
class SMTP extends BaseHeader_1.BaseHeader {
|
|
32
|
+
constructor() {
|
|
33
|
+
super(...arguments);
|
|
34
|
+
this.id = 'smtp';
|
|
35
|
+
this.name = 'Simple Mail Transfer Protocol';
|
|
36
|
+
this.nickname = 'SMTP';
|
|
37
|
+
//SMTP is recognized ONLY on its well-known port buckets 25 (relay) and 587 (submission) —
|
|
38
|
+
//deliberately NOT via heuristicFallback. Unlike HTTP/RTSP (whose method sets are distinctive),
|
|
39
|
+
//SMTP's line signature is a 3-digit reply code or a generic verb (HELO/QUIT/NOOP/HELP/AUTH/DATA/…)
|
|
40
|
+
//that is SHARED with other US-ASCII line protocols this codec does not model — FTP (QUIT/NOOP/AUTH/
|
|
41
|
+
//HELP), POP3 (QUIT/NOOP), IRC (QUIT), and any NNN-code greeting (FTP/NNTP). Joining the global
|
|
42
|
+
//heuristic chain would mislabel all of those as SMTP on their own ports. Confining SMTP to the
|
|
43
|
+
//tcp:25/tcp:587 buckets keeps that collision impossible (FTP/POP3/IRC live on 21/110/6667, which
|
|
44
|
+
//never reach these buckets); alt-port SMTP is rare and falls losslessly to raw.
|
|
45
|
+
this.matchKeys = ['tcpport:25', 'tcpport:587'];
|
|
46
|
+
//A leaf header — the DATA message body and the mail session it belongs to are a higher-layer concern.
|
|
47
|
+
this.demuxProducers = [];
|
|
48
|
+
}
|
|
49
|
+
static #schemaCache;
|
|
50
|
+
get SCHEMA() {
|
|
51
|
+
return (_a.#schemaCache ??= _a.#buildSchema());
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Bytes of this header: SMTP rides on TCP, which has no per-message length, so take the rest of the
|
|
55
|
+
* segment. Reassembly across segments is out of scope (see class doc).
|
|
56
|
+
*/
|
|
57
|
+
#payloadLength() {
|
|
58
|
+
const available = this.packet.length - this.startPos;
|
|
59
|
+
return available < 0 ? 0 : available;
|
|
60
|
+
}
|
|
61
|
+
/** The first line of the message (up to the first CRLF, or the whole payload if none). */
|
|
62
|
+
static #firstLine(text) {
|
|
63
|
+
const idx = text.indexOf('\r\n');
|
|
64
|
+
return idx >= 0 ? text.slice(0, idx) : text;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Parse the first line into the display-only metadata fields. A line matching `^\d{3}[ -]` is a
|
|
68
|
+
* server reply (the code, whether it is multi-line, and the trailing text); anything else is a
|
|
69
|
+
* client command (the uppercased verb and its argument). Populated on decode only — these fields
|
|
70
|
+
* have no encode, so they never affect the re-emitted bytes and never mutate `message`. Never
|
|
71
|
+
* throws: missing/garbage tokens yield empty strings or 0.
|
|
72
|
+
*/
|
|
73
|
+
#parseFirstLine(text) {
|
|
74
|
+
const line = _a.#firstLine(text);
|
|
75
|
+
const reply = line.match(/^(\d{3})([ -])(.*)$/);
|
|
76
|
+
if (reply) {
|
|
77
|
+
//Reply: 3-digit code, then ' ' (final) or '-' (a multi-line continuation follows).
|
|
78
|
+
this.instance.isReply.setValue(true);
|
|
79
|
+
this.instance.replyCode.setValue(Number(reply[1]));
|
|
80
|
+
this.instance.isMultiline.setValue(reply[2] === '-');
|
|
81
|
+
this.instance.replyText.setValue(reply[3]);
|
|
82
|
+
this.instance.command.setValue('');
|
|
83
|
+
this.instance.argument.setValue('');
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
//Command: VERB SP argument (the argument may itself contain spaces, e.g. an address path).
|
|
87
|
+
const idx = line.indexOf(' ');
|
|
88
|
+
const verb = idx >= 0 ? line.slice(0, idx) : line;
|
|
89
|
+
this.instance.isReply.setValue(false);
|
|
90
|
+
this.instance.replyCode.setValue(0);
|
|
91
|
+
this.instance.isMultiline.setValue(false);
|
|
92
|
+
this.instance.replyText.setValue('');
|
|
93
|
+
this.instance.command.setValue(verb.toUpperCase());
|
|
94
|
+
this.instance.argument.setValue(idx >= 0 ? line.slice(idx + 1) : '');
|
|
95
|
+
}
|
|
96
|
+
static #buildSchema() {
|
|
97
|
+
return {
|
|
98
|
+
type: 'object',
|
|
99
|
+
summary: 'SMTP ${command}${replyCode}',
|
|
100
|
+
properties: {
|
|
101
|
+
//The whole raw message is the single source of truth: decoded verbatim to hex and
|
|
102
|
+
//re-emitted untouched (byte-perfect for any SMTP control text). The first line is parsed
|
|
103
|
+
//into the display-only metadata below, which carry no codec of their own.
|
|
104
|
+
message: {
|
|
105
|
+
type: 'string',
|
|
106
|
+
label: 'Message',
|
|
107
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
108
|
+
decode: function () {
|
|
109
|
+
const available = this.#payloadLength();
|
|
110
|
+
if (available <= 0) {
|
|
111
|
+
this.instance.message.setValue('');
|
|
112
|
+
this.#parseFirstLine('');
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const raw = this.readBytes(0, available);
|
|
116
|
+
this.instance.message.setValue((0, BufferToHex_1.BufferToHex)(raw));
|
|
117
|
+
this.#parseFirstLine(raw.toString('latin1'));
|
|
118
|
+
},
|
|
119
|
+
encode: function () {
|
|
120
|
+
//Re-emit the authoritative message verbatim — never reconstruct from metadata.
|
|
121
|
+
this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(this.instance.message.getValue('')));
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
//Display-only metadata parsed from the first line on decode (no encode — populated by the
|
|
125
|
+
//message field above, never read back). isReply distinguishes a server reply from a
|
|
126
|
+
//client command; replyCode/isMultiline/replyText describe a reply, command/argument a
|
|
127
|
+
//command.
|
|
128
|
+
isReply: { type: 'boolean', label: 'Is Reply' },
|
|
129
|
+
replyCode: { type: 'integer', label: 'Reply Code', minimum: 0, maximum: 999 },
|
|
130
|
+
isMultiline: { type: 'boolean', label: 'Is Multiline' },
|
|
131
|
+
replyText: { type: 'string', label: 'Reply Text' },
|
|
132
|
+
command: { type: 'string', label: 'Command' },
|
|
133
|
+
argument: { type: 'string', label: 'Argument' }
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
match() {
|
|
138
|
+
//SMTP rides on TCP as US-ASCII text. Recognize it by the line signature: a 3-digit reply code
|
|
139
|
+
//followed by space or '-', or a known command verb as the leading token (up to the first space
|
|
140
|
+
//or CR) — so non-SMTP traffic on port 25/587 falls through to raw rather than claiming an
|
|
141
|
+
//un-decodable text layer.
|
|
142
|
+
if (!this.prevCodecModule)
|
|
143
|
+
return false;
|
|
144
|
+
if (this.prevCodecModule.id !== 'tcp')
|
|
145
|
+
return false;
|
|
146
|
+
if (this.#payloadLength() < 3)
|
|
147
|
+
return false;
|
|
148
|
+
const lead = this.readBytes(0, 16, true).toString('latin1');
|
|
149
|
+
if (/^\d{3}[ -]/.test(lead))
|
|
150
|
+
return true;
|
|
151
|
+
const line = _a.#firstLine(lead);
|
|
152
|
+
const token = (line.split(/[ \r]/)[0] || '').toUpperCase();
|
|
153
|
+
return SMTP_COMMANDS.includes(token);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.SMTP = SMTP;
|
|
157
|
+
_a = SMTP;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* SNAP — Sub-Network Access Protocol (IEEE 802.2), the 5-byte header that follows an LLC header whose
|
|
6
|
+
* DSAP/SSAP are 0xAA. It carries a 3-byte OUI (Organizationally Unique Identifier) and a 2-byte Protocol
|
|
7
|
+
* Identifier. When the OUI is 0x000000 the PID is an EtherType, so SNAP re-exposes it (in a field named
|
|
8
|
+
* `etherType`, identically to Ethernet/VLAN) and routes IPv4/ARP/IPv6/… through the existing `ethertype`
|
|
9
|
+
* demux for free. A non-zero OUI (e.g. Cisco 0x00000C for CDP/VTP) is a vendor protocol whose PID is not
|
|
10
|
+
* an EtherType; for those SNAP also emits an `snapoui` key of OUI+PID concatenated. A well-formed SNAP
|
|
11
|
+
* header round-trips byte-for-byte.
|
|
12
|
+
*/
|
|
13
|
+
export declare class SNAP extends BaseHeader {
|
|
14
|
+
#private;
|
|
15
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly nickname: string;
|
|
19
|
+
readonly matchKeys: string[];
|
|
20
|
+
match(): boolean;
|
|
21
|
+
readonly demuxProducers: DemuxProducer[];
|
|
22
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SNAP = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
/**
|
|
6
|
+
* SNAP — Sub-Network Access Protocol (IEEE 802.2), the 5-byte header that follows an LLC header whose
|
|
7
|
+
* DSAP/SSAP are 0xAA. It carries a 3-byte OUI (Organizationally Unique Identifier) and a 2-byte Protocol
|
|
8
|
+
* Identifier. When the OUI is 0x000000 the PID is an EtherType, so SNAP re-exposes it (in a field named
|
|
9
|
+
* `etherType`, identically to Ethernet/VLAN) and routes IPv4/ARP/IPv6/… through the existing `ethertype`
|
|
10
|
+
* demux for free. A non-zero OUI (e.g. Cisco 0x00000C for CDP/VTP) is a vendor protocol whose PID is not
|
|
11
|
+
* an EtherType; for those SNAP also emits an `snapoui` key of OUI+PID concatenated. A well-formed SNAP
|
|
12
|
+
* header round-trips byte-for-byte.
|
|
13
|
+
*/
|
|
14
|
+
class SNAP extends BaseHeader_1.BaseHeader {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.id = 'snap';
|
|
18
|
+
this.name = 'Sub-Network Access Protocol';
|
|
19
|
+
this.nickname = 'SNAP';
|
|
20
|
+
this.matchKeys = ['llcsap:170'];
|
|
21
|
+
//Two producers: the EtherType (for OUI 0x000000 → the shared ethertype machinery) and the OUI+PID
|
|
22
|
+
//(for vendor protocols → the snapoui namespace). Both are emitted; the miss simply never matches.
|
|
23
|
+
this.demuxProducers = [
|
|
24
|
+
{ field: 'etherType', namespace: 'ethertype', kind: 'string' },
|
|
25
|
+
{ field: 'ouiProtocol', namespace: 'snapoui', kind: 'string' }
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
static #schemaCache;
|
|
29
|
+
get SCHEMA() {
|
|
30
|
+
return (SNAP.#schemaCache ??= SNAP.#buildSchema());
|
|
31
|
+
}
|
|
32
|
+
static #buildSchema() {
|
|
33
|
+
return {
|
|
34
|
+
type: 'object',
|
|
35
|
+
summary: 'SNAP oui=${oui} type=${etherType}',
|
|
36
|
+
properties: {
|
|
37
|
+
oui: this.fieldHex('oui', 0, 3, 'OUI'),
|
|
38
|
+
//Named `etherType` (not `pid`) so the existing ethertype demux + IPv4/ARP/IPv6 match() —
|
|
39
|
+
//which read the parent's `etherType` field literally — route through SNAP unchanged, exactly
|
|
40
|
+
//as they do through Ethernet II and 802.1Q.
|
|
41
|
+
etherType: this.fieldHex('etherType', 3, 2, 'Protocol Type'),
|
|
42
|
+
//Display/demux-only: OUI+PID concatenated, the `snapoui` key for vendor protocols (CDP/VTP
|
|
43
|
+
//under Cisco 0x00000C). No encode closure — the bytes are written by oui + etherType, this
|
|
44
|
+
//is derived — so it never affects the re-emitted frame.
|
|
45
|
+
ouiProtocol: {
|
|
46
|
+
type: 'string',
|
|
47
|
+
label: 'OUI Protocol',
|
|
48
|
+
decode: function () {
|
|
49
|
+
const oui = this.instance.oui.getValue('');
|
|
50
|
+
const etherType = this.instance.etherType.getValue('');
|
|
51
|
+
this.instance.ouiProtocol.setValue((oui + etherType).toLowerCase());
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
match() {
|
|
58
|
+
//An LLC child selected by DSAP 0xAA (170). Confirm the parent is LLC with DSAP 0xAA and the full
|
|
59
|
+
//5-byte SNAP header is present.
|
|
60
|
+
const prev = this.prevCodecModule;
|
|
61
|
+
if (!prev || prev.id !== 'llc')
|
|
62
|
+
return false;
|
|
63
|
+
if (prev.instance.dsap.getValue(0) !== 0xaa)
|
|
64
|
+
return false;
|
|
65
|
+
return this.packet.length - this.startPos >= 5;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.SNAP = SNAP;
|