@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,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MDNS = void 0;
|
|
4
|
+
const DNS_1 = require("./DNS");
|
|
5
|
+
/**
|
|
6
|
+
* mDNS — Multicast DNS (RFC 6762). The on-wire message format is byte-for-byte the standard DNS message
|
|
7
|
+
* (RFC 1035): the same 12-byte header, questions, and resource records with label compression. mDNS
|
|
8
|
+
* only reinterprets bits that DNS already carries verbatim — the top bit of a question's QCLASS is the
|
|
9
|
+
* unicast-response (QU) bit, and the top bit of a record's CLASS is the cache-flush bit — so storing
|
|
10
|
+
* QCLASS/CLASS as their full 16-bit values (as the DNS codec does) preserves them automatically and the
|
|
11
|
+
* whole message round-trips byte-perfect through the inherited DNS decode/encode. The only differences
|
|
12
|
+
* here are the protocol identity, the demux port (UDP 5353), the Info summary, and a tightened match().
|
|
13
|
+
*/
|
|
14
|
+
class MDNS extends DNS_1.DNS {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.id = 'mdns';
|
|
18
|
+
this.name = 'Multicast DNS';
|
|
19
|
+
this.nickname = 'mDNS';
|
|
20
|
+
this.matchKeys = ['udpport:5353'];
|
|
21
|
+
}
|
|
22
|
+
static #schemaCache;
|
|
23
|
+
//Reuse the parent DNS schema (identical wire format + field closures) but relabel the Info summary
|
|
24
|
+
//so an mDNS packet does not render as "DNS". Shares the `properties` closures by reference; only the
|
|
25
|
+
//top-level object and its summary template differ.
|
|
26
|
+
get SCHEMA() {
|
|
27
|
+
return (MDNS.#schemaCache ??= { ...super.SCHEMA, summary: 'mDNS ${id} queries=${qdcount} answers=${ancount}' });
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* mDNS lives on UDP port 5353 and never uses the classic DNS port 53. Because UDP produces its demux
|
|
31
|
+
* keys destination-port-first, a DNS *response* (srcport 53) sent to a client that happens to use
|
|
32
|
+
* ephemeral port 5353 would otherwise hit the mDNS bucket first and be mislabeled. Reject any packet
|
|
33
|
+
* that carries port 53 (that is DNS, matched by the udpport:53 bucket), and require 5353 to be present.
|
|
34
|
+
*/
|
|
35
|
+
match() {
|
|
36
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'udp')
|
|
37
|
+
return false;
|
|
38
|
+
const srcport = this.prevCodecModule.instance.srcport.getValue(0);
|
|
39
|
+
const dstport = this.prevCodecModule.instance.dstport.getValue(0);
|
|
40
|
+
if (srcport === 53 || dstport === 53)
|
|
41
|
+
return false;
|
|
42
|
+
return srcport === 5353 || dstport === 5353;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.MDNS = MDNS;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* MGCP — the Media Gateway Control Protocol (RFC 3435), the master/slave signalling protocol by which a
|
|
6
|
+
* Call Agent controls media gateways for VoIP. It is US-ASCII text carried over UDP (gateways listen on
|
|
7
|
+
* 2427, call agents on 2727). A message is a command or response line, then parameter lines, a blank
|
|
8
|
+
* line, and an optional SDP session description.
|
|
9
|
+
*
|
|
10
|
+
* The command line is `VERB SP transactionId SP endpoint SP "MGCP 1.0" CRLF` (VERB ∈ CRCX/MDCX/DLCX/…);
|
|
11
|
+
* a response line is `responseCode SP transactionId SP commentText CRLF`.
|
|
12
|
+
*
|
|
13
|
+
* Like SIP and HTTP, the message body is text whose full internal structure (arbitrary parameter lines,
|
|
14
|
+
* an embedded SDP session, significant whitespace/line ordering) is far richer than a form needs. So the
|
|
15
|
+
* ENTIRE raw message is kept verbatim as the authoritative `message` field (hex) and re-emitted
|
|
16
|
+
* untouched; only the first line is parsed on decode into display-only metadata
|
|
17
|
+
* (verb/transactionId/endpoint/version or responseCode/comment). Encode never reconstructs the message
|
|
18
|
+
* from the parsed fields — it writes `message` back byte-for-byte — so any conformant (or even
|
|
19
|
+
* malformed) MGCP message round-trips exactly.
|
|
20
|
+
*/
|
|
21
|
+
export declare class MGCP extends BaseHeader {
|
|
22
|
+
#private;
|
|
23
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly nickname: string;
|
|
27
|
+
readonly matchKeys: string[];
|
|
28
|
+
match(): boolean;
|
|
29
|
+
readonly demuxProducers: DemuxProducer[];
|
|
30
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.MGCP = 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
|
+
/** MGCP verbs (RFC 3435 §3.2 + common extensions) used only to recognize a command start-line. */
|
|
10
|
+
const MGCP_VERBS = ['CRCX', 'MDCX', 'DLCX', 'RQNT', 'NTFY', 'AUEP', 'AUCX', 'RSIP', 'EPCF'];
|
|
11
|
+
/**
|
|
12
|
+
* MGCP — the Media Gateway Control Protocol (RFC 3435), the master/slave signalling protocol by which a
|
|
13
|
+
* Call Agent controls media gateways for VoIP. It is US-ASCII text carried over UDP (gateways listen on
|
|
14
|
+
* 2427, call agents on 2727). A message is a command or response line, then parameter lines, a blank
|
|
15
|
+
* line, and an optional SDP session description.
|
|
16
|
+
*
|
|
17
|
+
* The command line is `VERB SP transactionId SP endpoint SP "MGCP 1.0" CRLF` (VERB ∈ CRCX/MDCX/DLCX/…);
|
|
18
|
+
* a response line is `responseCode SP transactionId SP commentText CRLF`.
|
|
19
|
+
*
|
|
20
|
+
* Like SIP and HTTP, the message body is text whose full internal structure (arbitrary parameter lines,
|
|
21
|
+
* an embedded SDP session, significant whitespace/line ordering) is far richer than a form needs. So the
|
|
22
|
+
* ENTIRE raw message is kept verbatim as the authoritative `message` field (hex) and re-emitted
|
|
23
|
+
* untouched; only the first line is parsed on decode into display-only metadata
|
|
24
|
+
* (verb/transactionId/endpoint/version or responseCode/comment). Encode never reconstructs the message
|
|
25
|
+
* from the parsed fields — it writes `message` back byte-for-byte — so any conformant (or even
|
|
26
|
+
* malformed) MGCP message round-trips exactly.
|
|
27
|
+
*/
|
|
28
|
+
class MGCP extends BaseHeader_1.BaseHeader {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
this.id = 'mgcp';
|
|
32
|
+
this.name = 'Media Gateway Control Protocol';
|
|
33
|
+
this.nickname = 'MGCP';
|
|
34
|
+
this.matchKeys = ['udpport:2427', 'udpport:2727'];
|
|
35
|
+
//A leaf header — the embedded SDP body and the transaction it belongs to are a higher-layer concern.
|
|
36
|
+
this.demuxProducers = [];
|
|
37
|
+
}
|
|
38
|
+
static #schemaCache;
|
|
39
|
+
get SCHEMA() {
|
|
40
|
+
return (_a.#schemaCache ??= _a.#buildSchema());
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Bytes of this header: for UDP, bounded by the datagram length (so a retained FCS/padding is not
|
|
44
|
+
* absorbed); otherwise take the rest of the packet. Never negative.
|
|
45
|
+
*/
|
|
46
|
+
#payloadLength() {
|
|
47
|
+
let available = this.packet.length - this.startPos;
|
|
48
|
+
if (this.prevCodecModule && this.prevCodecModule.id === 'udp') {
|
|
49
|
+
const udpLength = this.prevCodecModule.instance.length.getValue(0);
|
|
50
|
+
if (udpLength >= 8 && udpLength - 8 < available)
|
|
51
|
+
available = udpLength - 8;
|
|
52
|
+
}
|
|
53
|
+
return available < 0 ? 0 : available;
|
|
54
|
+
}
|
|
55
|
+
/** The first line of the message (up to the first CRLF, or the whole payload if none). */
|
|
56
|
+
static #firstLine(text) {
|
|
57
|
+
const idx = text.indexOf('\r\n');
|
|
58
|
+
return idx >= 0 ? text.slice(0, idx) : text;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Parse the first line into the display-only metadata fields. A response line begins with a 3-digit
|
|
62
|
+
* numeric code; anything else is treated as a command line. Populated on decode only — these fields
|
|
63
|
+
* have no encode, so they never affect the re-emitted bytes. Never throws: missing tokens yield
|
|
64
|
+
* empty strings, a non-numeric code yields 0.
|
|
65
|
+
*/
|
|
66
|
+
#parseFirstLine(text) {
|
|
67
|
+
const line = _a.#firstLine(text);
|
|
68
|
+
const parts = line.split(' ');
|
|
69
|
+
if (/^\d{3}$/.test(parts[0] || '')) {
|
|
70
|
+
//Response line: responseCode SP transactionId SP commentText
|
|
71
|
+
this.instance.isResponse.setValue(true);
|
|
72
|
+
this.instance.verb.setValue('');
|
|
73
|
+
this.instance.transactionId.setValue(parts.length > 1 ? parts[1] : '');
|
|
74
|
+
this.instance.endpoint.setValue('');
|
|
75
|
+
this.instance.version.setValue('');
|
|
76
|
+
this.instance.responseCode.setValue(Number(parts[0]));
|
|
77
|
+
this.instance.comment.setValue(parts.length > 2 ? parts.slice(2).join(' ') : '');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
//Command line: VERB SP transactionId SP endpoint SP "MGCP 1.0"
|
|
81
|
+
this.instance.isResponse.setValue(false);
|
|
82
|
+
this.instance.verb.setValue(parts[0] ? parts[0] : '');
|
|
83
|
+
this.instance.transactionId.setValue(parts.length > 1 ? parts[1] : '');
|
|
84
|
+
this.instance.endpoint.setValue(parts.length > 2 ? parts[2] : '');
|
|
85
|
+
//The MGCP-Version is the trailing "MGCP 1.0" (last two tokens); keep whatever tokens follow the
|
|
86
|
+
//endpoint so a non-standard version string is still displayed.
|
|
87
|
+
this.instance.version.setValue(parts.length > 3 ? parts.slice(3).join(' ') : '');
|
|
88
|
+
this.instance.responseCode.setValue(0);
|
|
89
|
+
this.instance.comment.setValue('');
|
|
90
|
+
}
|
|
91
|
+
static #buildSchema() {
|
|
92
|
+
return {
|
|
93
|
+
type: 'object',
|
|
94
|
+
summary: 'MGCP ${verb}${responseCode}',
|
|
95
|
+
properties: {
|
|
96
|
+
//The whole raw message is the single source of truth: decoded verbatim to hex and
|
|
97
|
+
//re-emitted untouched (byte-perfect for any MGCP message). The first line is parsed into
|
|
98
|
+
//the display-only metadata below, which carry no codec of their own.
|
|
99
|
+
message: {
|
|
100
|
+
type: 'string',
|
|
101
|
+
label: 'Message',
|
|
102
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
103
|
+
decode: function () {
|
|
104
|
+
const available = this.#payloadLength();
|
|
105
|
+
if (available <= 0) {
|
|
106
|
+
this.instance.message.setValue('');
|
|
107
|
+
this.#parseFirstLine('');
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const raw = this.readBytes(0, available);
|
|
111
|
+
this.instance.message.setValue((0, BufferToHex_1.BufferToHex)(raw));
|
|
112
|
+
this.#parseFirstLine(raw.toString('latin1'));
|
|
113
|
+
},
|
|
114
|
+
encode: function () {
|
|
115
|
+
//Re-emit the authoritative message verbatim — never reconstruct from metadata.
|
|
116
|
+
this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(this.instance.message.getValue('')));
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
//Display-only metadata parsed from the first line on decode (no encode — populated by the
|
|
120
|
+
//message field above, never read back). isResponse distinguishes a response line from a
|
|
121
|
+
//command line; verb/endpoint/version are for commands, responseCode/comment for responses.
|
|
122
|
+
isResponse: { type: 'boolean', label: 'Is Response' },
|
|
123
|
+
verb: { type: 'string', label: 'Verb' },
|
|
124
|
+
transactionId: { type: 'string', label: 'Transaction ID' },
|
|
125
|
+
endpoint: { type: 'string', label: 'Endpoint' },
|
|
126
|
+
version: { type: 'string', label: 'Version' },
|
|
127
|
+
responseCode: { type: 'integer', label: 'Response Code', minimum: 0, maximum: 999 },
|
|
128
|
+
comment: { type: 'string', label: 'Comment' }
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
match() {
|
|
133
|
+
//MGCP rides on UDP ports 2427 (gateway) / 2727 (call agent) as US-ASCII text. Recognize it by the
|
|
134
|
+
//first-line signature: a known verb followed by a space, or a 3-digit response code followed by a
|
|
135
|
+
//space — so non-MGCP traffic on these ports falls through to raw rather than claiming an
|
|
136
|
+
//un-decodable text layer.
|
|
137
|
+
if (!this.prevCodecModule)
|
|
138
|
+
return false;
|
|
139
|
+
if (this.prevCodecModule.id !== 'udp')
|
|
140
|
+
return false;
|
|
141
|
+
if (this.#payloadLength() < 5)
|
|
142
|
+
return false;
|
|
143
|
+
const lead = this.readBytes(0, 16, true).toString('latin1');
|
|
144
|
+
//A 3-digit response code (e.g. "200 ") begins a response.
|
|
145
|
+
if (/^\d{3} /.test(lead))
|
|
146
|
+
return true;
|
|
147
|
+
for (const verb of MGCP_VERBS) {
|
|
148
|
+
if (lead.startsWith(verb + ' '))
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.MGCP = MGCP;
|
|
155
|
+
_a = MGCP;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* MMS — Manufacturing Message Specification (ISO 9506) for IEC 61850, the innermost application layer of
|
|
6
|
+
* the substation stack: TPKT → COTP → ISO Session → (this) ISO Presentation + MMS. In the data-transfer
|
|
7
|
+
* phase the Session user data is a Presentation "fully-encoded-data" PDU (BER `[APPLICATION 1]`, tag
|
|
8
|
+
* 0x61) that wraps a PDV-list (SEQUENCE 0x30) carrying a presentation-context-identifier and the MMS PDU
|
|
9
|
+
* itself as `[0]` single-ASN1-type (0xa0). The MMS PDU is a CHOICE — 0xa0 confirmed-request, 0xa1
|
|
10
|
+
* confirmed-response, 0xa2 confirmed-error, 0xa3 unconfirmed, 0xa8 initiate-request, 0xa9
|
|
11
|
+
* initiate-response, 0x05 NULL (keep-alive) …
|
|
12
|
+
*
|
|
13
|
+
* Following the SNMP pattern, this header owns the whole nested BER blob and re-emits it verbatim (so it
|
|
14
|
+
* round-trips byte-for-byte regardless of definite/indefinite length quirks), while exposing the parsed
|
|
15
|
+
* presentation context and the MMS PDU type as display metadata. The single-frame completeness gate is
|
|
16
|
+
* enforced upstream by COTP, so a T2-fragmented MMS body never reaches here. Deeper structuring of the
|
|
17
|
+
* MMS service body (read/write/report) and the connection-phase ACSE are later slices.
|
|
18
|
+
*/
|
|
19
|
+
export declare class MMS extends BaseHeader {
|
|
20
|
+
#private;
|
|
21
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly nickname: string;
|
|
25
|
+
readonly matchKeys: string[];
|
|
26
|
+
readonly heuristicFallback: boolean;
|
|
27
|
+
match(): boolean;
|
|
28
|
+
readonly demuxProducers: DemuxProducer[];
|
|
29
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MMS = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
6
|
+
const HexToBuffer_1 = require("../helper/HexToBuffer");
|
|
7
|
+
/**
|
|
8
|
+
* MMS — Manufacturing Message Specification (ISO 9506) for IEC 61850, the innermost application layer of
|
|
9
|
+
* the substation stack: TPKT → COTP → ISO Session → (this) ISO Presentation + MMS. In the data-transfer
|
|
10
|
+
* phase the Session user data is a Presentation "fully-encoded-data" PDU (BER `[APPLICATION 1]`, tag
|
|
11
|
+
* 0x61) that wraps a PDV-list (SEQUENCE 0x30) carrying a presentation-context-identifier and the MMS PDU
|
|
12
|
+
* itself as `[0]` single-ASN1-type (0xa0). The MMS PDU is a CHOICE — 0xa0 confirmed-request, 0xa1
|
|
13
|
+
* confirmed-response, 0xa2 confirmed-error, 0xa3 unconfirmed, 0xa8 initiate-request, 0xa9
|
|
14
|
+
* initiate-response, 0x05 NULL (keep-alive) …
|
|
15
|
+
*
|
|
16
|
+
* Following the SNMP pattern, this header owns the whole nested BER blob and re-emits it verbatim (so it
|
|
17
|
+
* round-trips byte-for-byte regardless of definite/indefinite length quirks), while exposing the parsed
|
|
18
|
+
* presentation context and the MMS PDU type as display metadata. The single-frame completeness gate is
|
|
19
|
+
* enforced upstream by COTP, so a T2-fragmented MMS body never reaches here. Deeper structuring of the
|
|
20
|
+
* MMS service body (read/write/report) and the connection-phase ACSE are later slices.
|
|
21
|
+
*/
|
|
22
|
+
class MMS extends BaseHeader_1.BaseHeader {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
this.id = 'mms';
|
|
26
|
+
this.name = 'Manufacturing Message Specification';
|
|
27
|
+
this.nickname = 'MMS';
|
|
28
|
+
//A content-heuristic child of ISO Session (unkeyed), selected by the Presentation fully-encoded-data
|
|
29
|
+
//BER tag 0x61 (the MMS data-transfer phase).
|
|
30
|
+
this.matchKeys = [];
|
|
31
|
+
this.heuristicFallback = true;
|
|
32
|
+
//A leaf for this slice — the MMS service body is kept verbatim inside `message`.
|
|
33
|
+
this.demuxProducers = [];
|
|
34
|
+
}
|
|
35
|
+
static #schemaCache;
|
|
36
|
+
get SCHEMA() {
|
|
37
|
+
return (MMS.#schemaCache ??= MMS.#buildSchema());
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A clamping, never-throwing BER TLV read at `pos`: returns the tag, the header length (tag+length
|
|
41
|
+
* octets), the content start and the content length (clamped to the buffer). Indefinite length (0x80)
|
|
42
|
+
* yields a content that runs to the buffer end (kept verbatim, not parsed). Returns null past the end.
|
|
43
|
+
*/
|
|
44
|
+
static #readTLV(buf, pos) {
|
|
45
|
+
if (pos + 2 > buf.length)
|
|
46
|
+
return null;
|
|
47
|
+
const tag = buf[pos];
|
|
48
|
+
const lengthOctet = buf[pos + 1];
|
|
49
|
+
let contentStart = pos + 2;
|
|
50
|
+
let contentLength;
|
|
51
|
+
if (lengthOctet < 0x80) {
|
|
52
|
+
contentLength = lengthOctet;
|
|
53
|
+
}
|
|
54
|
+
else if (lengthOctet === 0x80) {
|
|
55
|
+
contentLength = buf.length - contentStart;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const n = lengthOctet & 0x7f;
|
|
59
|
+
if (contentStart + n > buf.length)
|
|
60
|
+
return null;
|
|
61
|
+
contentLength = 0;
|
|
62
|
+
for (let i = 0; i < n; i++)
|
|
63
|
+
contentLength = (contentLength << 8) | buf[contentStart + i];
|
|
64
|
+
contentStart += n;
|
|
65
|
+
}
|
|
66
|
+
if (contentStart + contentLength > buf.length)
|
|
67
|
+
contentLength = buf.length - contentStart;
|
|
68
|
+
if (contentLength < 0)
|
|
69
|
+
contentLength = 0;
|
|
70
|
+
return { tag: tag, contentStart: contentStart, contentLength: contentLength };
|
|
71
|
+
}
|
|
72
|
+
//MMS ConfirmedServiceRequest/Response CHOICE context tags (ISO 9506-2) → service name, for display.
|
|
73
|
+
static #SERVICE_NAMES = {
|
|
74
|
+
0: 'status', 1: 'getNameList', 2: 'identify', 3: 'rename', 4: 'read', 5: 'write',
|
|
75
|
+
6: 'getVariableAccessAttributes', 7: 'defineNamedVariable', 8: 'defineScatteredAccess',
|
|
76
|
+
9: 'getScatteredAccessAttributes', 10: 'deleteVariableAccess', 11: 'defineNamedVariableList',
|
|
77
|
+
12: 'getNamedVariableListAttributes', 13: 'deleteNamedVariableList', 14: 'defineNamedType',
|
|
78
|
+
15: 'getNamedTypeAttributes', 16: 'deleteNamedType', 17: 'input', 18: 'output', 19: 'takeControl',
|
|
79
|
+
20: 'relinquishControl', 21: 'defineSemaphore', 22: 'deleteSemaphore', 23: 'reportSemaphoreStatus',
|
|
80
|
+
24: 'reportPoolSemaphoreStatus', 25: 'reportSemaphoreEntryStatus', 26: 'initiateDownloadSequence',
|
|
81
|
+
27: 'downloadSegment', 28: 'terminateDownloadSequence', 29: 'initiateUploadSequence', 30: 'uploadSegment'
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Parse the Presentation/MMS nesting for display, best-effort: the presentation context, the MMS PDU
|
|
85
|
+
* type (0xa0 confirmed-request / 0xa1 confirmed-response / 0xa2 confirmed-error / 0xa3 unconfirmed /
|
|
86
|
+
* 0x05 NULL …), and — for a confirmed request/response/error — the invokeID and the service (from the
|
|
87
|
+
* ConfirmedService CHOICE context tag). -1 / '' when a part is absent.
|
|
88
|
+
*/
|
|
89
|
+
static #parse(buf) {
|
|
90
|
+
const result = { presentationContext: -1, mmsPduType: -1, invokeID: -1, service: '', objectNames: [] };
|
|
91
|
+
//61 (fully-encoded-data) → 30 (PDV-list) → 02 01 ctx, a0 (presentation-data-values) → MMS PDU.
|
|
92
|
+
const app = MMS.#readTLV(buf, 0);
|
|
93
|
+
if (!app || app.tag !== 0x61)
|
|
94
|
+
return result;
|
|
95
|
+
const pdvList = MMS.#readTLV(buf, app.contentStart);
|
|
96
|
+
if (!pdvList || pdvList.tag !== 0x30)
|
|
97
|
+
return result;
|
|
98
|
+
let pos = pdvList.contentStart;
|
|
99
|
+
const end = pdvList.contentStart + pdvList.contentLength;
|
|
100
|
+
while (pos < end) {
|
|
101
|
+
const tlv = MMS.#readTLV(buf, pos);
|
|
102
|
+
if (!tlv)
|
|
103
|
+
break;
|
|
104
|
+
if (tlv.tag === 0x02 && tlv.contentLength >= 1) {
|
|
105
|
+
//presentation-context-identifier (INTEGER)
|
|
106
|
+
let value = 0;
|
|
107
|
+
for (let i = 0; i < tlv.contentLength; i++)
|
|
108
|
+
value = (value << 8) | buf[tlv.contentStart + i];
|
|
109
|
+
result.presentationContext = value;
|
|
110
|
+
}
|
|
111
|
+
else if (tlv.tag === 0xa0) {
|
|
112
|
+
//presentation-data-values [0] → the MMS PDU TLV is inside.
|
|
113
|
+
const mmsPdu = MMS.#readTLV(buf, tlv.contentStart);
|
|
114
|
+
if (mmsPdu) {
|
|
115
|
+
result.mmsPduType = mmsPdu.tag;
|
|
116
|
+
MMS.#parseConfirmed(buf, mmsPdu, result);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
pos = tlv.contentStart + tlv.contentLength;
|
|
120
|
+
}
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
/** True if every byte is printable ASCII (a heuristic Identifier guard for context-tagged names). */
|
|
124
|
+
static #isPrintable(buf) {
|
|
125
|
+
if (buf.length === 0)
|
|
126
|
+
return false;
|
|
127
|
+
for (const b of buf)
|
|
128
|
+
if (b < 0x20 || b > 0x7e)
|
|
129
|
+
return false;
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Recursively collect the object/variable names referenced in an MMS service body into `out` (depth- and
|
|
134
|
+
* count-bounded, never-throwing). A name is an ObjectName Identifier (VisibleString): the domain-specific
|
|
135
|
+
* form's domainID/itemID appear as universal VisibleString (BER 0x1a), while the vmd-specific [0],
|
|
136
|
+
* domain-scope [1] and aa-specific [2] forms are IMPLICIT context-tagged primitives (0x80/0x81/0x82). To
|
|
137
|
+
* avoid collecting non-name context values (objectClass, error codes, booleans, or Data VALUEs, whose
|
|
138
|
+
* string alternatives are tags ≥ [3]), the context-primitive forms are taken only when their content is a
|
|
139
|
+
* printable Identifier.
|
|
140
|
+
*/
|
|
141
|
+
static #collectVisibleStrings(buf, start, end, out, depth) {
|
|
142
|
+
if (depth > 32 || out.length >= 64)
|
|
143
|
+
return;
|
|
144
|
+
let pos = start;
|
|
145
|
+
while (pos < end && out.length < 64) {
|
|
146
|
+
const tlv = MMS.#readTLV(buf, pos);
|
|
147
|
+
if (!tlv)
|
|
148
|
+
break;
|
|
149
|
+
const constructed = (tlv.tag & 0x20) !== 0;
|
|
150
|
+
const content = buf.subarray(tlv.contentStart, tlv.contentStart + tlv.contentLength);
|
|
151
|
+
if (tlv.tag === 0x1a) {
|
|
152
|
+
out.push(content.toString('latin1'));
|
|
153
|
+
}
|
|
154
|
+
else if (!constructed && (tlv.tag & 0xc0) === 0x80 && (tlv.tag & 0x1f) <= 2 && MMS.#isPrintable(content)) {
|
|
155
|
+
//vmd-specific [0] / domain-scope [1] / aa-specific [2] Identifier.
|
|
156
|
+
out.push(content.toString('latin1'));
|
|
157
|
+
}
|
|
158
|
+
else if (constructed) {
|
|
159
|
+
MMS.#collectVisibleStrings(buf, tlv.contentStart, tlv.contentStart + tlv.contentLength, out, depth + 1);
|
|
160
|
+
}
|
|
161
|
+
const next = tlv.contentStart + tlv.contentLength;
|
|
162
|
+
if (next <= pos)
|
|
163
|
+
break;
|
|
164
|
+
pos = next;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/** For a confirmed-request/response/error MMS PDU, extract the invokeID, the service name, and the
|
|
168
|
+
* object/variable names referenced. */
|
|
169
|
+
static #parseConfirmed(buf, mmsPdu, result) {
|
|
170
|
+
if (mmsPdu.tag !== 0xa0 && mmsPdu.tag !== 0xa1 && mmsPdu.tag !== 0xa2)
|
|
171
|
+
return;
|
|
172
|
+
//All three begin with the invokeID INTEGER (Confirmed-{Request,Response,Error}PDU).
|
|
173
|
+
const invokeID = MMS.#readTLV(buf, mmsPdu.contentStart);
|
|
174
|
+
if (!invokeID || invokeID.tag !== 0x02)
|
|
175
|
+
return;
|
|
176
|
+
let id = 0;
|
|
177
|
+
for (let i = 0; i < invokeID.contentLength; i++)
|
|
178
|
+
id = (id << 8) | buf[invokeID.contentStart + i];
|
|
179
|
+
result.invokeID = id;
|
|
180
|
+
//The ConfirmedService CHOICE is the element after the invokeID ONLY for request/response. A
|
|
181
|
+
//Confirmed-ErrorPDU's second element is modifierPosition/serviceError, not a service, so skip it.
|
|
182
|
+
if (mmsPdu.tag !== 0xa0 && mmsPdu.tag !== 0xa1)
|
|
183
|
+
return;
|
|
184
|
+
const service = MMS.#readTLV(buf, invokeID.contentStart + invokeID.contentLength);
|
|
185
|
+
if (!service)
|
|
186
|
+
return;
|
|
187
|
+
//Single-byte context tags (0..30) identify the service; a higher (multi-byte) tag's first byte has
|
|
188
|
+
//low bits 0x1f=31, absent from the map, so it shows as "31" — lossy but never aliases a real name.
|
|
189
|
+
const tagNumber = service.tag & 0x1f;
|
|
190
|
+
result.service = MMS.#SERVICE_NAMES[tagNumber] ?? String(tagNumber);
|
|
191
|
+
//Collect the object/variable names referenced within the service body.
|
|
192
|
+
MMS.#collectVisibleStrings(buf, service.contentStart, service.contentStart + service.contentLength, result.objectNames, 0);
|
|
193
|
+
}
|
|
194
|
+
static #buildSchema() {
|
|
195
|
+
return {
|
|
196
|
+
type: 'object',
|
|
197
|
+
summary: 'MMS pdu=${mmsPduType} ctx=${presentationContext}',
|
|
198
|
+
properties: {
|
|
199
|
+
//The whole Presentation + MMS BER blob is the authoritative source: decoded verbatim to hex
|
|
200
|
+
//and re-emitted untouched, so any (even malformed) frame round-trips byte-for-byte.
|
|
201
|
+
message: {
|
|
202
|
+
type: 'string', label: 'Message', contentEncoding: 'hex',
|
|
203
|
+
decode: function () {
|
|
204
|
+
const available = this.packet.length - this.startPos;
|
|
205
|
+
const buf = this.readBytes(0, available);
|
|
206
|
+
this.instance.message.setValue((0, BufferToHex_1.BufferToHex)(buf));
|
|
207
|
+
const parsed = MMS.#parse(buf);
|
|
208
|
+
this.instance.presentationContext.setValue(parsed.presentationContext);
|
|
209
|
+
this.instance.mmsPduType.setValue(parsed.mmsPduType);
|
|
210
|
+
if (parsed.invokeID >= 0)
|
|
211
|
+
this.instance.mmsInvokeID.setValue(parsed.invokeID);
|
|
212
|
+
if (parsed.service)
|
|
213
|
+
this.instance.mmsService.setValue(parsed.service);
|
|
214
|
+
if (parsed.objectNames.length)
|
|
215
|
+
this.instance.mmsObjectNames.setValue(parsed.objectNames);
|
|
216
|
+
},
|
|
217
|
+
encode: function () {
|
|
218
|
+
this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(this.instance.message.getValue('')));
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
//Display-only metadata parsed from the BER blob on decode (no encode — populated by the
|
|
222
|
+
//message field above), so they never affect the re-emitted bytes. invokeID / service are
|
|
223
|
+
//present only for a confirmed request/response/error PDU.
|
|
224
|
+
presentationContext: { type: 'integer', label: 'Presentation Context' },
|
|
225
|
+
mmsPduType: { type: 'integer', label: 'MMS PDU Type' },
|
|
226
|
+
mmsInvokeID: { type: 'integer', label: 'Invoke ID' },
|
|
227
|
+
mmsService: { type: 'string', label: 'MMS Service' },
|
|
228
|
+
mmsObjectNames: { type: 'array', label: 'Object Names', items: { type: 'string' } }
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
match() {
|
|
233
|
+
const prev = this.prevCodecModule;
|
|
234
|
+
if (!prev || prev.id !== 'iso-session')
|
|
235
|
+
return false;
|
|
236
|
+
if (this.packet.length - this.startPos < 2)
|
|
237
|
+
return false;
|
|
238
|
+
//Presentation fully-encoded-data (BER [APPLICATION 1] = 0x61). The connection-phase CP-type (0x31)
|
|
239
|
+
//+ ACSE is a later slice.
|
|
240
|
+
return this.readBytes(0, 1, true)[0] === 0x61;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
exports.MMS = MMS;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* MPLS — Multiprotocol Label Switching (RFC 3032), carried directly in an Ethernet II frame with
|
|
6
|
+
* EtherType 0x8847 (unicast) or 0x8848 (multicast) — an Ethernet child, no IP/UDP below it. The MPLS
|
|
7
|
+
* shim is a label stack: a sequence of 4-byte entries, each packing a 20-bit Label, a 3-bit Traffic
|
|
8
|
+
* Class / Experimental field (TC/EXP), a 1-bit Bottom-of-Stack flag (S), and an 8-bit Time To Live
|
|
9
|
+
* (TTL). The stack repeats until an entry with S=1 (the bottom of stack); the encapsulated packet
|
|
10
|
+
* (typically IPv4/IPv6, dispatched by the first payload nibble) follows immediately after it.
|
|
11
|
+
*
|
|
12
|
+
* This codec is the label-stack leaf: it decodes the stack (each entry's structured label/tc/s/ttl)
|
|
13
|
+
* up to and including the S=1 entry, then keeps the encapsulated packet after it as an opaque `payload`
|
|
14
|
+
* hex field so MPLS is a self-contained byte-perfect leaf. (It deliberately consumes the payload rather
|
|
15
|
+
* than leaving it to the codec's recursion: with IPv4/IPv6.match unchanged the inner IP would not fall
|
|
16
|
+
* to RawData but be claimed by the greedy EthernetII content heuristic, which emits an un-re-encodable
|
|
17
|
+
* layer for a short trailer. Owning the bytes keeps decode→encode from ever throwing.) Each entry and
|
|
18
|
+
* the payload are re-emitted verbatim, so a well-formed shim round-trips byte-for-byte. Structured inner
|
|
19
|
+
* IPv4/IPv6 recursion is a serial follow-up (IPv4/IPv6.match must learn an 'mpls' parent branch
|
|
20
|
+
* dispatching on the first payload nibble, at which point `payload` becomes real child layers).
|
|
21
|
+
*/
|
|
22
|
+
export declare class MPLS extends BaseHeader {
|
|
23
|
+
#private;
|
|
24
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly name: string;
|
|
27
|
+
readonly nickname: string;
|
|
28
|
+
readonly matchKeys: string[];
|
|
29
|
+
match(): boolean;
|
|
30
|
+
readonly demuxProducers: DemuxProducer[];
|
|
31
|
+
}
|