@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,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MarkerProtocol = 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
|
+
* Marker Protocol — the Link Aggregation Marker Protocol (IEEE 802.3ad / 802.1AX), the second of the
|
|
12
|
+
* Slow Protocols carried directly in an Ethernet II frame with EtherType 0x8809 (an Ethernet child — no
|
|
13
|
+
* IP/UDP). It shares the frame type with LACP and is disambiguated by byte 0, the Slow-Protocols
|
|
14
|
+
* Subtype: 1 = LACP (claimed by the LACP header), 2 = Marker (claimed here). Byte 1 is the Version.
|
|
15
|
+
* What follows is a flat sequence of TLVs — each a 1-byte Type + 1-byte Length (the Length counts the 2
|
|
16
|
+
* header octets, so the value is Length-2 bytes) + value bytes: the Marker Information TLV (type 0x01,
|
|
17
|
+
* len 0x10) or Marker Response TLV (type 0x02, len 0x10) — carrying Requester_Port (2), Requester_System
|
|
18
|
+
* (6), Requester_Transaction_ID (4) and Pad (2) — then the Terminator (type 0x00, len 0x00). After the
|
|
19
|
+
* Terminator the PDU is padded with reserved octets to fill the fixed PDU length. Marker has no length
|
|
20
|
+
* field of its own — it runs to the end of the frame.
|
|
21
|
+
*
|
|
22
|
+
* TLVs are carried generically (type + on-wire length + verbatim hex value) so every TLV round-trips
|
|
23
|
+
* byte-for-byte; per-TLV semantic decoding (requester port/system/transaction id) is a later enrichment.
|
|
24
|
+
* The Length is honored verbatim on encode when supplied (a crafted PDU may lie), else derived from the
|
|
25
|
+
* value (2 + value bytes; 0 for the Terminator). The walk stops at the Terminator (type 0) or when the
|
|
26
|
+
* frame is exhausted; any bytes after the Terminator are the reserved padding, kept verbatim in
|
|
27
|
+
* `reserved` so the frame is reproduced exactly.
|
|
28
|
+
*/
|
|
29
|
+
class MarkerProtocol extends BaseHeader_1.BaseHeader {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
this.id = 'marker';
|
|
33
|
+
this.name = 'Link Aggregation Marker Protocol';
|
|
34
|
+
this.nickname = 'Marker';
|
|
35
|
+
this.matchKeys = ['ethertype:8809'];
|
|
36
|
+
//A leaf header — nothing demuxes above the Marker Protocol.
|
|
37
|
+
this.demuxProducers = [];
|
|
38
|
+
}
|
|
39
|
+
static #schemaCache;
|
|
40
|
+
get SCHEMA() {
|
|
41
|
+
return (MarkerProtocol.#schemaCache ??= MarkerProtocol.#buildSchema());
|
|
42
|
+
}
|
|
43
|
+
static #buildSchema() {
|
|
44
|
+
return {
|
|
45
|
+
type: 'object',
|
|
46
|
+
summary: 'Marker v${version} ${tlvs.length} TLVs',
|
|
47
|
+
properties: {
|
|
48
|
+
subtype: this.fieldUInt('subtype', 0, 1, 'Subtype'),
|
|
49
|
+
version: this.fieldUInt('version', 1, 1, 'Version'),
|
|
50
|
+
tlvs: {
|
|
51
|
+
type: 'array',
|
|
52
|
+
label: 'TLVs',
|
|
53
|
+
items: {
|
|
54
|
+
type: 'object',
|
|
55
|
+
label: 'TLV',
|
|
56
|
+
properties: {
|
|
57
|
+
type: { type: 'integer', label: 'Type', minimum: 0, maximum: 255 },
|
|
58
|
+
length: { type: 'integer', label: 'Length', minimum: 0, maximum: 255 },
|
|
59
|
+
value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
decode: function () {
|
|
63
|
+
//The Marker PDU runs to the end of the frame — there is no length field. Bound the
|
|
64
|
+
//walk by the remaining frame bytes. Each TLV is Type(1) + Length(1) + (Length-2)
|
|
65
|
+
//value bytes; the on-wire Length counts the 2 header octets (the Terminator is the
|
|
66
|
+
//exception: Length 0).
|
|
67
|
+
const available = this.packet.length - this.startPos;
|
|
68
|
+
const tlvs = [];
|
|
69
|
+
let offset = 2;
|
|
70
|
+
while (offset + 2 <= available) {
|
|
71
|
+
const type = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(offset, 1));
|
|
72
|
+
const length = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(offset + 1, 1));
|
|
73
|
+
//Terminator (type 0): logical end of the PDU — anything after is reserved padding.
|
|
74
|
+
if (type === 0) {
|
|
75
|
+
tlvs.push({ type: type, length: length, value: '' });
|
|
76
|
+
offset += 2;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
//Value byte count = Length - 2 (Length includes the 2 header octets). A malformed
|
|
80
|
+
//Length < 2 yields no value; a value that overruns the frame (truncation) is not
|
|
81
|
+
//consumed — stop and leave the remaining bytes to `reserved`, keeping round-trip exact.
|
|
82
|
+
const valueLength = length > 2 ? length - 2 : 0;
|
|
83
|
+
if (offset + 2 + valueLength > available)
|
|
84
|
+
break;
|
|
85
|
+
const value = valueLength > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset + 2, valueLength)) : '';
|
|
86
|
+
tlvs.push({ type: type, length: length, value: value });
|
|
87
|
+
offset += 2 + valueLength;
|
|
88
|
+
}
|
|
89
|
+
this.instance.tlvs.setValue(tlvs);
|
|
90
|
+
//Trailing bytes after the Terminator (or after a truncated TLV) are the reserved padding.
|
|
91
|
+
this.instance.reserved.setValue(offset < available ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset, available - offset)) : '');
|
|
92
|
+
},
|
|
93
|
+
encode: function () {
|
|
94
|
+
const tlvs = this.instance.tlvs.getValue([]);
|
|
95
|
+
let offset = 2;
|
|
96
|
+
if (tlvs) {
|
|
97
|
+
for (let i = 0; i < tlvs.length; i++) {
|
|
98
|
+
const tlv = tlvs[i];
|
|
99
|
+
const type = tlv.type ? tlv.type : 0;
|
|
100
|
+
const value = (0, HexToBuffer_1.HexToBuffer)(tlv.value ? tlv.value : '');
|
|
101
|
+
//Length is honored verbatim when supplied (a crafted PDU may lie), else derived:
|
|
102
|
+
//value bytes + the 2 header octets (0 for the Terminator, which carries no value).
|
|
103
|
+
let length = (tlv.length !== undefined && tlv.length !== null)
|
|
104
|
+
? tlv.length
|
|
105
|
+
: (type === 0 ? 0 : value.length + 2);
|
|
106
|
+
if (length > 255) {
|
|
107
|
+
this.recordError(`tlvs[${i}].length`, 'Maximum value is 255');
|
|
108
|
+
length = 255;
|
|
109
|
+
}
|
|
110
|
+
if (length < 0) {
|
|
111
|
+
this.recordError(`tlvs[${i}].length`, 'Minimum value is 0');
|
|
112
|
+
length = 0;
|
|
113
|
+
}
|
|
114
|
+
this.writeBytes(offset, (0, NumberToBuffer_1.UInt8ToBuffer)(type & 0xff));
|
|
115
|
+
this.writeBytes(offset + 1, (0, NumberToBuffer_1.UInt8ToBuffer)(length));
|
|
116
|
+
offset += 2;
|
|
117
|
+
if (value.length) {
|
|
118
|
+
this.writeBytes(offset, value);
|
|
119
|
+
offset += value.length;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const reserved = this.instance.reserved.getValue('');
|
|
124
|
+
if (reserved)
|
|
125
|
+
this.writeBytes(offset, (0, HexToBuffer_1.HexToBuffer)(reserved));
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
//Reserved padding after the Terminator TLV, kept verbatim. No codec of its own — it is
|
|
129
|
+
//set/read by the `tlvs` field (which owns the single offset walk); this entry is metadata
|
|
130
|
+
//so the editor sees the padding bytes.
|
|
131
|
+
reserved: {
|
|
132
|
+
type: 'string',
|
|
133
|
+
label: 'Reserved',
|
|
134
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
135
|
+
hidden: true
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
match() {
|
|
141
|
+
//An Ethernet child selected by EtherType 0x8809 (Slow Protocols, stored as a lowercase 4-hex
|
|
142
|
+
//string). Only Subtype 2 (Marker) is claimed — Subtype 1 (LACP) and others fall through. Require
|
|
143
|
+
//at least the 2-byte Subtype + Version so the subtype probe is in-bounds.
|
|
144
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'eth')
|
|
145
|
+
return false;
|
|
146
|
+
if (this.prevCodecModule.instance.etherType.getValue() !== '8809')
|
|
147
|
+
return false;
|
|
148
|
+
if (this.packet.length - this.startPos < 2)
|
|
149
|
+
return false;
|
|
150
|
+
return (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(0, 1, true)) === 2;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.MarkerProtocol = MarkerProtocol;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* Megaco / H.248 (RFC 3525) — the Media Gateway Control protocol by which a Media Gateway Controller
|
|
6
|
+
* commands Media Gateways for VoIP, the ITU-T/IETF successor to MGCP. This codec handles the text
|
|
7
|
+
* (ABNF) encoding carried over UDP (well-known ports 2944 text / 2945 secure-text); the alternative
|
|
8
|
+
* binary ASN.1/BER encoding is a separate wire format and out of scope here.
|
|
9
|
+
*
|
|
10
|
+
* A text message begins with a header line `MEGACO/version SP mId` (the start token "MEGACO" or its
|
|
11
|
+
* short form "!", a slash, the protocol version, then the message identifier — an [ip]:port, domain
|
|
12
|
+
* name, device name or MTP address), followed by one or more Transaction blocks (`Transaction = id {
|
|
13
|
+
* Context = ... { commands } }`).
|
|
14
|
+
*
|
|
15
|
+
* Like SIP, MGCP and HTTP, the message body is text whose full internal structure (nested
|
|
16
|
+
* transaction/context/command/descriptor blocks, significant whitespace and token ordering) is far
|
|
17
|
+
* richer than a form needs. So the ENTIRE raw message is kept verbatim as the authoritative `message`
|
|
18
|
+
* field (hex) and re-emitted untouched; only the header line is parsed on decode into display-only
|
|
19
|
+
* metadata (start token / version / message identifier). Encode never reconstructs the message from
|
|
20
|
+
* the parsed fields — it writes `message` back byte-for-byte — so any conformant (or even malformed)
|
|
21
|
+
* Megaco message round-trips exactly.
|
|
22
|
+
*/
|
|
23
|
+
export declare class Megaco extends BaseHeader {
|
|
24
|
+
#private;
|
|
25
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly nickname: string;
|
|
29
|
+
readonly matchKeys: string[];
|
|
30
|
+
match(): boolean;
|
|
31
|
+
readonly demuxProducers: DemuxProducer[];
|
|
32
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Megaco = 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
|
+
/**
|
|
10
|
+
* Megaco / H.248 (RFC 3525) — the Media Gateway Control protocol by which a Media Gateway Controller
|
|
11
|
+
* commands Media Gateways for VoIP, the ITU-T/IETF successor to MGCP. This codec handles the text
|
|
12
|
+
* (ABNF) encoding carried over UDP (well-known ports 2944 text / 2945 secure-text); the alternative
|
|
13
|
+
* binary ASN.1/BER encoding is a separate wire format and out of scope here.
|
|
14
|
+
*
|
|
15
|
+
* A text message begins with a header line `MEGACO/version SP mId` (the start token "MEGACO" or its
|
|
16
|
+
* short form "!", a slash, the protocol version, then the message identifier — an [ip]:port, domain
|
|
17
|
+
* name, device name or MTP address), followed by one or more Transaction blocks (`Transaction = id {
|
|
18
|
+
* Context = ... { commands } }`).
|
|
19
|
+
*
|
|
20
|
+
* Like SIP, MGCP and HTTP, the message body is text whose full internal structure (nested
|
|
21
|
+
* transaction/context/command/descriptor blocks, significant whitespace and token ordering) is far
|
|
22
|
+
* 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 header line is parsed on decode into display-only
|
|
24
|
+
* metadata (start token / version / message identifier). Encode never reconstructs the message from
|
|
25
|
+
* the parsed fields — it writes `message` back byte-for-byte — so any conformant (or even malformed)
|
|
26
|
+
* Megaco message round-trips exactly.
|
|
27
|
+
*/
|
|
28
|
+
class Megaco extends BaseHeader_1.BaseHeader {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
this.id = 'megaco';
|
|
32
|
+
this.name = 'Media Gateway Control Protocol (H.248/Megaco)';
|
|
33
|
+
this.nickname = 'Megaco';
|
|
34
|
+
this.matchKeys = ['udpport:2944', 'udpport:2945'];
|
|
35
|
+
//A leaf header — the nested transaction/context/command/descriptor structure and the transaction it
|
|
36
|
+
//belongs to are a higher-layer concern; the verbatim message preserves it byte-for-byte.
|
|
37
|
+
this.demuxProducers = [];
|
|
38
|
+
}
|
|
39
|
+
static #schemaCache;
|
|
40
|
+
get SCHEMA() {
|
|
41
|
+
return (_a.#schemaCache ??= _a.#buildSchema());
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Bytes of this header: for UDP, bounded by the datagram length (so a retained FCS/padding is not
|
|
45
|
+
* absorbed); otherwise take the rest of the packet. Never negative.
|
|
46
|
+
*/
|
|
47
|
+
#payloadLength() {
|
|
48
|
+
let available = this.packet.length - this.startPos;
|
|
49
|
+
if (this.prevCodecModule && this.prevCodecModule.id === 'udp') {
|
|
50
|
+
const udpLength = this.prevCodecModule.instance.length.getValue(0);
|
|
51
|
+
if (udpLength >= 8 && udpLength - 8 < available)
|
|
52
|
+
available = udpLength - 8;
|
|
53
|
+
}
|
|
54
|
+
return available < 0 ? 0 : available;
|
|
55
|
+
}
|
|
56
|
+
/** The first line of the message (up to the first CR or LF, or the whole payload if neither). */
|
|
57
|
+
static #firstLine(text) {
|
|
58
|
+
let end = text.length;
|
|
59
|
+
for (let i = 0; i < text.length; i++) {
|
|
60
|
+
const code = text.charCodeAt(i);
|
|
61
|
+
if (code === 0x0d || code === 0x0a) {
|
|
62
|
+
end = i;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return text.slice(0, end);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Parse the header line into the display-only metadata fields. The line is
|
|
70
|
+
* `startToken/version SP mId` (e.g. "MEGACO/1 [123.123.123.4]:55555"). Populated on decode only —
|
|
71
|
+
* these fields have no encode, so they never affect the re-emitted bytes. Never throws: a missing
|
|
72
|
+
* token yields an empty string, a non-numeric version yields 0.
|
|
73
|
+
*/
|
|
74
|
+
#parseHeaderLine(text) {
|
|
75
|
+
const line = _a.#firstLine(text).trim();
|
|
76
|
+
//Split the leading "startToken/version" token from the message identifier on the first space.
|
|
77
|
+
const spaceIdx = line.indexOf(' ');
|
|
78
|
+
const head = spaceIdx >= 0 ? line.slice(0, spaceIdx) : line;
|
|
79
|
+
const mId = spaceIdx >= 0 ? line.slice(spaceIdx + 1).trim() : '';
|
|
80
|
+
const slashIdx = head.indexOf('/');
|
|
81
|
+
const token = slashIdx >= 0 ? head.slice(0, slashIdx) : head;
|
|
82
|
+
const versionText = slashIdx >= 0 ? head.slice(slashIdx + 1) : '';
|
|
83
|
+
this.instance.startToken.setValue(token);
|
|
84
|
+
//Kept as the raw digit string (display-only), not a bounded integer: RFC 3525 versions are an
|
|
85
|
+
//unbounded 1*DIGIT, so a large value like "9999999999" must round-trip (the message hex is the
|
|
86
|
+
//authoritative source; encode never reads this field) without Ajv rejecting it on re-encode.
|
|
87
|
+
this.instance.version.setValue(versionText);
|
|
88
|
+
this.instance.messageId.setValue(mId);
|
|
89
|
+
}
|
|
90
|
+
static #buildSchema() {
|
|
91
|
+
return {
|
|
92
|
+
type: 'object',
|
|
93
|
+
summary: 'Megaco/${version} ${messageId}',
|
|
94
|
+
properties: {
|
|
95
|
+
//The whole raw message is the single source of truth: decoded verbatim to hex and
|
|
96
|
+
//re-emitted untouched (byte-perfect for any Megaco message). The header line is parsed
|
|
97
|
+
//into the display-only metadata below, which carry no codec of their own.
|
|
98
|
+
message: {
|
|
99
|
+
type: 'string',
|
|
100
|
+
label: 'Message',
|
|
101
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
102
|
+
decode: function () {
|
|
103
|
+
const available = this.#payloadLength();
|
|
104
|
+
if (available <= 0) {
|
|
105
|
+
this.instance.message.setValue('');
|
|
106
|
+
this.#parseHeaderLine('');
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const raw = this.readBytes(0, available);
|
|
110
|
+
this.instance.message.setValue((0, BufferToHex_1.BufferToHex)(raw));
|
|
111
|
+
this.#parseHeaderLine(raw.toString('latin1'));
|
|
112
|
+
},
|
|
113
|
+
encode: function () {
|
|
114
|
+
//Re-emit the authoritative message verbatim — never reconstruct from metadata.
|
|
115
|
+
this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(this.instance.message.getValue('')));
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
//Display-only metadata parsed from the header line on decode (no encode — populated by the
|
|
119
|
+
//message field above, never read back). startToken is "MEGACO" (or "!" short form),
|
|
120
|
+
//version is the protocol version, messageId is the message identifier (mId).
|
|
121
|
+
startToken: { type: 'string', label: 'Start Token' },
|
|
122
|
+
version: { type: 'string', label: 'Version' },
|
|
123
|
+
messageId: { type: 'string', label: 'Message Identifier' }
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
match() {
|
|
128
|
+
//Megaco text encoding rides on UDP ports 2944 (text) / 2945 (secure text) as text. Recognize it
|
|
129
|
+
//by the header-line signature: the start token "MEGACO/" or its short form "!/" (case-insensitive
|
|
130
|
+
//start token) — so non-Megaco traffic on these ports falls through to raw rather than claiming an
|
|
131
|
+
//un-decodable text layer. Leading whitespace (LWSP) before the token is tolerated.
|
|
132
|
+
if (!this.prevCodecModule)
|
|
133
|
+
return false;
|
|
134
|
+
if (this.prevCodecModule.id !== 'udp')
|
|
135
|
+
return false;
|
|
136
|
+
if (this.#payloadLength() < 3)
|
|
137
|
+
return false;
|
|
138
|
+
const lead = this.readBytes(0, 16, true).toString('latin1').replace(/^[\s]+/, '');
|
|
139
|
+
const upper = lead.toUpperCase();
|
|
140
|
+
return upper.startsWith('MEGACO/') || lead.startsWith('!/');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.Megaco = Megaco;
|
|
144
|
+
_a = Megaco;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* Memcached — the cache daemon's wire protocol, carried over TCP well-known port 11211. Memcached speaks
|
|
6
|
+
* TWO protocols on the same port, and this codec handles BOTH by branching on the first payload byte
|
|
7
|
+
* (the exact model of the SSH codec, which branches identification-vs-binary on a signature):
|
|
8
|
+
*
|
|
9
|
+
* 1. TEXT protocol (the classic, default). Line-based US-ASCII commands and replies terminated by CR LF:
|
|
10
|
+
* `get <key>\r\n`, `set <key> <flags> <exptime> <bytes>\r\n<data>\r\n`, and replies such as
|
|
11
|
+
* `VALUE <key> <flags> <bytes>\r\n<data>\r\nEND\r\n`, `STORED\r\n`, `END\r\n`, … Like the other
|
|
12
|
+
* US-ASCII line protocols in this codec (POP3/FTP/SIP/HTTP), the exact bytes a peer sees are richer
|
|
13
|
+
* than any structure a form needs (arbitrary keys, inline data blocks, pipelined commands), so the
|
|
14
|
+
* ENTIRE payload is kept verbatim as the authoritative `message` field (hex) and re-emitted untouched;
|
|
15
|
+
* only the leading token is parsed on decode into the display-only `command` field (get/set/VALUE/
|
|
16
|
+
* STORED/…). Encode never reconstructs the payload from `command` — it writes `message` back
|
|
17
|
+
* byte-for-byte, so any conformant (or malformed) text exchange round-trips exactly.
|
|
18
|
+
*
|
|
19
|
+
* 2. BINARY protocol (RFC-less, memcached's binary framing). A fixed 24-byte header —
|
|
20
|
+
* magic(1: 0x80 request / 0x81 response) · opcode(1) · keyLength(2, BE) · extrasLength(1) ·
|
|
21
|
+
* dataType(1) · vbucket-id/status(2, BE) · totalBodyLength(4, BE) · opaque(4) · cas(8) — followed by
|
|
22
|
+
* `totalBodyLength` bytes of body (extras + key + value). This codec structures the 24-byte header as
|
|
23
|
+
* editable fields and keeps the body verbatim as `body` hex, bounded by totalBodyLength (a trailing /
|
|
24
|
+
* pipelined next message is left to the codec's recursion / RawData). The `cas` field is 8 bytes, so
|
|
25
|
+
* it is kept as a HEX string (never a JS Number — 8 bytes exceeds 2^53 and would lose precision). A
|
|
26
|
+
* well-formed binary message round-trips byte-for-byte.
|
|
27
|
+
*
|
|
28
|
+
* Matching rationale (NO heuristicFallback): Memcached is claimed ONLY on the tcp:11211 bucket. The binary
|
|
29
|
+
* header's magic (0x80/0x81) is a weak one-byte signature and the text protocol shares generic verbs
|
|
30
|
+
* (get/set/…) with countless other line protocols, so neither shape carries a signature strong enough to
|
|
31
|
+
* survive the global content-heuristic chain without mislabeling unrelated TCP traffic. Confining
|
|
32
|
+
* Memcached to its well-known port keeps recognition unambiguous; alt-port memcached is rare and falls
|
|
33
|
+
* losslessly to raw.
|
|
34
|
+
*/
|
|
35
|
+
export declare class Memcached extends BaseHeader {
|
|
36
|
+
#private;
|
|
37
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
38
|
+
readonly id: string;
|
|
39
|
+
readonly name: string;
|
|
40
|
+
readonly nickname: string;
|
|
41
|
+
readonly matchKeys: string[];
|
|
42
|
+
match(): boolean;
|
|
43
|
+
readonly demuxProducers: DemuxProducer[];
|
|
44
|
+
}
|