@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,274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IAX2 = 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
|
+
* IAX2 — Inter-Asterisk eXchange version 2 (RFC 5456), the Asterisk VoIP signalling + media trunking
|
|
12
|
+
* protocol, UDP port 4569. Every IAX2 datagram carries exactly one frame whose first bit (the F bit,
|
|
13
|
+
* the MSB of octet 0) selects the frame format:
|
|
14
|
+
*
|
|
15
|
+
* - Full frame (F = 1) — a 12-byte header: F(1) + Source Call Number(15) | R(1, retransmit) +
|
|
16
|
+
* Destination Call Number(15) | Timestamp(32) | OSeqno(8) | ISeqno(8) | Frame Type(8) | C(1) +
|
|
17
|
+
* Subclass(7), followed by the frame data (the Information Elements of a NEW/AUTHREQ/… command, or a
|
|
18
|
+
* media payload). Full frames are reliably delivered and carry the call-control state.
|
|
19
|
+
* - Mini frame (F = 0) — a 4-byte header: F(1) + Source Call Number(15) | Timestamp(16), followed by
|
|
20
|
+
* the media payload. Mini frames carry audio with a truncated 16-bit timestamp to save bandwidth.
|
|
21
|
+
*
|
|
22
|
+
* Byte-perfect strategy (minimal slice): the format is chosen by peeking the MSB of octet 0; the fixed
|
|
23
|
+
* header is bit-unpacked field by field and the frame data is kept verbatim as `data` hex. IAX2 has no
|
|
24
|
+
* in-frame length field — one frame occupies the whole UDP payload — so `data` runs to the transport
|
|
25
|
+
* payload end (udp.length − 8, clamped to the captured bytes so Ethernet padding is not consumed). Every
|
|
26
|
+
* wire field is a plain clamped integer (no Ajv enum), so a crafted / non-conformant value decoded off
|
|
27
|
+
* the wire re-encodes without being rejected — decode never fails and encode is a faithful executor. A
|
|
28
|
+
* well-formed frame round-trips byte-for-byte.
|
|
29
|
+
*/
|
|
30
|
+
class IAX2 extends BaseHeader_1.BaseHeader {
|
|
31
|
+
constructor() {
|
|
32
|
+
super(...arguments);
|
|
33
|
+
this.id = 'iax2';
|
|
34
|
+
this.name = 'Inter-Asterisk eXchange v2';
|
|
35
|
+
this.nickname = 'IAX2';
|
|
36
|
+
//IAX2 rides UDP port 4569. No content magic (the F bit alone is not distinctive), so this stays a
|
|
37
|
+
//pure port-bucket protocol: matchKeys only, no heuristicFallback.
|
|
38
|
+
this.matchKeys = ['udpport:4569'];
|
|
39
|
+
//A leaf header — the frame data (IAX2 Information Elements or the media payload) requires
|
|
40
|
+
//Frame-Type- and Subclass-dependent parsing layered on top of this faithful base.
|
|
41
|
+
this.demuxProducers = [];
|
|
42
|
+
}
|
|
43
|
+
static #schemaCache;
|
|
44
|
+
get SCHEMA() {
|
|
45
|
+
return (IAX2.#schemaCache ??= IAX2.#buildSchema());
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Header-relative end offset of the transport payload available to this frame, so a decode never
|
|
49
|
+
* reads past the real UDP payload and trailing Ethernet padding is left to the codec. Over UDP the
|
|
50
|
+
* bound is (udp.length − 8); clamped to what was actually captured.
|
|
51
|
+
*/
|
|
52
|
+
#payloadEnd() {
|
|
53
|
+
let end = this.packet.length - this.startPos;
|
|
54
|
+
const prev = this.prevCodecModule;
|
|
55
|
+
if (prev && prev.id === 'udp') {
|
|
56
|
+
const udpLength = prev.instance.length.getValue(0);
|
|
57
|
+
if (udpLength >= 8 && udpLength - 8 < end)
|
|
58
|
+
end = udpLength - 8;
|
|
59
|
+
}
|
|
60
|
+
return end < 0 ? 0 : end;
|
|
61
|
+
}
|
|
62
|
+
/** True when the frame currently being decoded/encoded is a Full frame (F bit set). */
|
|
63
|
+
#isFull() {
|
|
64
|
+
return this.instance.fullFrame.getValue() === true;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* An unsigned integer bit-field present ONLY in Full frames (R bit, Destination Call Number, the C
|
|
68
|
+
* bit, the Subclass). Decode/encode no-op on a Mini frame so those keys never appear, keeping the
|
|
69
|
+
* Mini decode result minimal and its re-encode byte-exact.
|
|
70
|
+
*/
|
|
71
|
+
static #fullBits(name, offset, length, bitOffset, bitLength, label) {
|
|
72
|
+
const maximum = 2 ** bitLength - 1;
|
|
73
|
+
return {
|
|
74
|
+
type: 'integer',
|
|
75
|
+
label: label,
|
|
76
|
+
minimum: 0,
|
|
77
|
+
maximum: maximum,
|
|
78
|
+
decode: function () {
|
|
79
|
+
if (!this.#isFull())
|
|
80
|
+
return;
|
|
81
|
+
this.instance[name].setValue(this.readBits(offset, length, bitOffset, bitLength));
|
|
82
|
+
},
|
|
83
|
+
encode: function () {
|
|
84
|
+
if (!this.#isFull())
|
|
85
|
+
return;
|
|
86
|
+
const node = this.instance[name];
|
|
87
|
+
let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
88
|
+
if (value > maximum) {
|
|
89
|
+
this.recordError(node.getPath(), `Maximum value is ${maximum}`);
|
|
90
|
+
value = maximum;
|
|
91
|
+
}
|
|
92
|
+
if (value < 0) {
|
|
93
|
+
this.recordError(node.getPath(), 'Minimum value is 0');
|
|
94
|
+
value = 0;
|
|
95
|
+
}
|
|
96
|
+
node.setValue(value);
|
|
97
|
+
this.writeBits(offset, length, bitOffset, bitLength, value);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* An unsigned big-endian integer byte-field present ONLY in Full frames (OSeqno, ISeqno, Frame
|
|
103
|
+
* Type). Decode/encode no-op on a Mini frame.
|
|
104
|
+
*/
|
|
105
|
+
static #fullUInt(name, offset, byteLength, label) {
|
|
106
|
+
const maximum = byteLength === 1 ? 255 : 65535;
|
|
107
|
+
const read = byteLength === 1 ? BufferToNumber_1.BufferToUInt8 : BufferToNumber_1.BufferToUInt16;
|
|
108
|
+
const write = byteLength === 1 ? NumberToBuffer_1.UInt8ToBuffer : NumberToBuffer_1.UInt16ToBuffer;
|
|
109
|
+
return {
|
|
110
|
+
type: 'integer',
|
|
111
|
+
label: label,
|
|
112
|
+
minimum: 0,
|
|
113
|
+
maximum: maximum,
|
|
114
|
+
decode: function () {
|
|
115
|
+
if (!this.#isFull())
|
|
116
|
+
return;
|
|
117
|
+
this.instance[name].setValue(read(this.readBytes(offset, byteLength)));
|
|
118
|
+
},
|
|
119
|
+
encode: function () {
|
|
120
|
+
if (!this.#isFull())
|
|
121
|
+
return;
|
|
122
|
+
const node = this.instance[name];
|
|
123
|
+
let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
124
|
+
if (value > maximum) {
|
|
125
|
+
this.recordError(node.getPath(), `Maximum value is ${maximum}`);
|
|
126
|
+
value = maximum;
|
|
127
|
+
}
|
|
128
|
+
if (value < 0) {
|
|
129
|
+
this.recordError(node.getPath(), 'Minimum value is 0');
|
|
130
|
+
value = 0;
|
|
131
|
+
}
|
|
132
|
+
node.setValue(value);
|
|
133
|
+
this.writeBytes(offset, write(value));
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
static #buildSchema() {
|
|
138
|
+
return {
|
|
139
|
+
type: 'object',
|
|
140
|
+
summary: 'IAX2 src=${sourceCall} ts=${timestamp}',
|
|
141
|
+
properties: {
|
|
142
|
+
//F bit (MSB of octet 0): true => Full frame (12-byte header), false => Mini frame (4-byte
|
|
143
|
+
//header). Decoded first so every following field can branch on the frame format.
|
|
144
|
+
fullFrame: {
|
|
145
|
+
type: 'boolean',
|
|
146
|
+
label: 'Full Frame',
|
|
147
|
+
decode: function () {
|
|
148
|
+
this.instance.fullFrame.setValue(this.readBits(0, 1, 0, 1) === 1);
|
|
149
|
+
},
|
|
150
|
+
encode: function () {
|
|
151
|
+
const value = this.instance.fullFrame.getValue() === true;
|
|
152
|
+
this.instance.fullFrame.setValue(value);
|
|
153
|
+
this.writeBits(0, 1, 0, 1, value ? 1 : 0);
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
//Source Call Number: the low 15 bits of the first 2 octets. Present in BOTH formats.
|
|
157
|
+
sourceCall: {
|
|
158
|
+
type: 'integer',
|
|
159
|
+
label: 'Source Call Number',
|
|
160
|
+
minimum: 0,
|
|
161
|
+
maximum: 32767,
|
|
162
|
+
decode: function () {
|
|
163
|
+
this.instance.sourceCall.setValue(this.readBits(0, 2, 1, 15));
|
|
164
|
+
},
|
|
165
|
+
encode: function () {
|
|
166
|
+
const node = this.instance.sourceCall;
|
|
167
|
+
let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
168
|
+
if (value > 32767) {
|
|
169
|
+
this.recordError(node.getPath(), 'Maximum value is 32767');
|
|
170
|
+
value = 32767;
|
|
171
|
+
}
|
|
172
|
+
if (value < 0) {
|
|
173
|
+
this.recordError(node.getPath(), 'Minimum value is 0');
|
|
174
|
+
value = 0;
|
|
175
|
+
}
|
|
176
|
+
node.setValue(value);
|
|
177
|
+
this.writeBits(0, 2, 1, 15, value);
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
//Retransmit (R) bit — MSB of octet 2. Full frames only.
|
|
181
|
+
retransmit: this.#fullBits('retransmit', 2, 1, 0, 1, 'Retransmit'),
|
|
182
|
+
//Destination Call Number: the low 15 bits of octets 2..3. Full frames only.
|
|
183
|
+
destCall: this.#fullBits('destCall', 2, 2, 1, 15, 'Destination Call Number'),
|
|
184
|
+
//Timestamp: 32-bit (Full, octets 4..7) or 16-bit truncated (Mini, octets 2..3). A single
|
|
185
|
+
//field whose width/offset follow the frame format; the Ajv maximum stays at the 32-bit
|
|
186
|
+
//ceiling so a decoded Full timestamp is never rejected on re-encode.
|
|
187
|
+
timestamp: {
|
|
188
|
+
type: 'integer',
|
|
189
|
+
label: 'Timestamp',
|
|
190
|
+
minimum: 0,
|
|
191
|
+
maximum: 4294967295,
|
|
192
|
+
decode: function () {
|
|
193
|
+
if (this.#isFull()) {
|
|
194
|
+
this.instance.timestamp.setValue((0, BufferToNumber_1.BufferToUInt32)(this.readBytes(4, 4)));
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
this.instance.timestamp.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
encode: function () {
|
|
201
|
+
const full = this.#isFull();
|
|
202
|
+
const maximum = full ? 4294967295 : 65535;
|
|
203
|
+
const node = this.instance.timestamp;
|
|
204
|
+
let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
205
|
+
if (value > maximum) {
|
|
206
|
+
this.recordError(node.getPath(), `Maximum value is ${maximum}`);
|
|
207
|
+
value = maximum;
|
|
208
|
+
}
|
|
209
|
+
if (value < 0) {
|
|
210
|
+
this.recordError(node.getPath(), 'Minimum value is 0');
|
|
211
|
+
value = 0;
|
|
212
|
+
}
|
|
213
|
+
node.setValue(value);
|
|
214
|
+
if (full)
|
|
215
|
+
this.writeBytes(4, (0, NumberToBuffer_1.UInt32ToBuffer)(value));
|
|
216
|
+
else
|
|
217
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(value));
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
//Outbound stream sequence number (octet 8). Full frames only.
|
|
221
|
+
oSeqno: this.#fullUInt('oSeqno', 8, 1, 'Outbound Sequence Number'),
|
|
222
|
+
//Inbound stream sequence number (octet 9). Full frames only.
|
|
223
|
+
iSeqno: this.#fullUInt('iSeqno', 9, 1, 'Inbound Sequence Number'),
|
|
224
|
+
//Frame Type (octet 10): 1 DTMF, 2 Voice, 4 Control, 6 IAX, 7 Text, … Full frames only.
|
|
225
|
+
//Kept as a plain clamped byte (no Ajv enum) so any crafted value round-trips.
|
|
226
|
+
frameType: this.#fullUInt('frameType', 10, 1, 'Frame Type'),
|
|
227
|
+
//C bit — MSB of octet 11. When set, the Subclass is interpreted as 2^Subclass. Preserved
|
|
228
|
+
//verbatim so the frame round-trips regardless of interpretation. Full frames only.
|
|
229
|
+
subclassC: this.#fullBits('subclassC', 11, 1, 0, 1, 'Subclass Is Power Of Two (C)'),
|
|
230
|
+
//Subclass: low 7 bits of octet 11 — the command within the Frame Type (e.g. NEW=1 within
|
|
231
|
+
//Frame Type 6 IAX). Full frames only.
|
|
232
|
+
subclass: this.#fullBits('subclass', 11, 1, 1, 7, 'Subclass'),
|
|
233
|
+
//The frame data after the fixed header (Full: from octet 12; Mini: from octet 4), kept
|
|
234
|
+
//verbatim. IAX2 has no in-frame length field, so it runs to the transport payload end
|
|
235
|
+
//(udp.length − 8, clamped to the captured bytes), leaving trailing padding to the codec.
|
|
236
|
+
data: {
|
|
237
|
+
type: 'string',
|
|
238
|
+
label: 'Data',
|
|
239
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
240
|
+
decode: function () {
|
|
241
|
+
const headerLength = this.#isFull() ? 12 : 4;
|
|
242
|
+
const end = this.#payloadEnd();
|
|
243
|
+
this.instance.data.setValue(end > headerLength ? (0, BufferToHex_1.BufferToHex)(this.readBytes(headerLength, end - headerLength)) : '');
|
|
244
|
+
},
|
|
245
|
+
encode: function () {
|
|
246
|
+
const headerLength = this.#isFull() ? 12 : 4;
|
|
247
|
+
const data = this.instance.data.getValue('');
|
|
248
|
+
if (data)
|
|
249
|
+
this.writeBytes(headerLength, (0, HexToBuffer_1.HexToBuffer)(data));
|
|
250
|
+
else
|
|
251
|
+
this.readBytes(headerLength, 0);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
match() {
|
|
258
|
+
//Selected via the udpport:4569 bucket. Require the transport payload to hold the full fixed
|
|
259
|
+
//header for the frame format the F bit announces — 4 bytes for a Mini frame, 12 for a Full
|
|
260
|
+
//frame — so a short datagram on 4569 falls through to raw and the always-re-emitted Full header
|
|
261
|
+
//never breaks the byte round-trip. The payload bound is the UDP payload (udp.length − 8), not
|
|
262
|
+
//the captured frame, so Ethernet padding is not mistaken for header bytes.
|
|
263
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'udp')
|
|
264
|
+
return false;
|
|
265
|
+
const end = this.#payloadEnd();
|
|
266
|
+
if (end < 4)
|
|
267
|
+
return false;
|
|
268
|
+
const full = ((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(0, 1, true)) & 0x80) !== 0;
|
|
269
|
+
if (full && end < 12)
|
|
270
|
+
return false;
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
exports.IAX2 = IAX2;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
2
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
3
|
+
export declare class ICMP extends BaseHeader {
|
|
4
|
+
/**
|
|
5
|
+
* Calculate ICMPv4 checksum
|
|
6
|
+
* @protected
|
|
7
|
+
*/
|
|
8
|
+
protected calculateIcmpChecksum(): number;
|
|
9
|
+
SCHEMA: ProtocolJSONSchema;
|
|
10
|
+
id: string;
|
|
11
|
+
readonly matchKeys: string[];
|
|
12
|
+
name: string;
|
|
13
|
+
nickname: string;
|
|
14
|
+
match(): boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ICMP = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const BufferToNumber_1 = require("../helper/BufferToNumber");
|
|
6
|
+
const NumberToBuffer_1 = require("../helper/NumberToBuffer");
|
|
7
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
8
|
+
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
9
|
+
class ICMP extends BaseHeader_1.BaseHeader {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.SCHEMA = {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
type: {
|
|
16
|
+
type: 'integer',
|
|
17
|
+
label: 'Type',
|
|
18
|
+
minimum: 0,
|
|
19
|
+
maximum: 255,
|
|
20
|
+
decode: () => {
|
|
21
|
+
this.instance.type.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(0, 1)));
|
|
22
|
+
},
|
|
23
|
+
encode: () => {
|
|
24
|
+
const type = this.instance.type.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
25
|
+
this.instance.type.setValue(type);
|
|
26
|
+
this.writeBytes(0, (0, NumberToBuffer_1.UInt8ToBuffer)(type));
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
code: {
|
|
30
|
+
type: 'integer',
|
|
31
|
+
label: 'Code',
|
|
32
|
+
minimum: 0,
|
|
33
|
+
maximum: 255,
|
|
34
|
+
decode: () => {
|
|
35
|
+
this.instance.code.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(1, 1)));
|
|
36
|
+
},
|
|
37
|
+
encode: () => {
|
|
38
|
+
const code = this.instance.code.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
39
|
+
this.instance.code.setValue(code);
|
|
40
|
+
this.writeBytes(1, (0, NumberToBuffer_1.UInt8ToBuffer)(code));
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
checksum: {
|
|
44
|
+
type: 'integer',
|
|
45
|
+
label: 'Checksum',
|
|
46
|
+
minimum: 0,
|
|
47
|
+
maximum: 65535,
|
|
48
|
+
decode: () => {
|
|
49
|
+
this.instance.checksum.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
|
|
50
|
+
},
|
|
51
|
+
encode: () => {
|
|
52
|
+
let checksum = this.instance.checksum.getValue(0);
|
|
53
|
+
this.instance.checksum.setValue(checksum);
|
|
54
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
55
|
+
if (!checksum) {
|
|
56
|
+
checksum = this.calculateIcmpChecksum();
|
|
57
|
+
this.instance.checksum.setValue(checksum);
|
|
58
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
ident: {
|
|
63
|
+
type: 'number',
|
|
64
|
+
label: 'Identifier (BE)',
|
|
65
|
+
minimum: 0,
|
|
66
|
+
maximum: 65535,
|
|
67
|
+
decode: () => {
|
|
68
|
+
this.instance.ident.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(4, 2)));
|
|
69
|
+
},
|
|
70
|
+
encode: () => {
|
|
71
|
+
const ident = this.instance.ident.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
72
|
+
this.instance.ident.setValue(ident);
|
|
73
|
+
this.writeBytes(4, (0, NumberToBuffer_1.UInt16ToBuffer)(ident));
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
seq: {
|
|
77
|
+
type: 'number',
|
|
78
|
+
label: 'Sequence Number (BE)',
|
|
79
|
+
minimum: 0,
|
|
80
|
+
maximum: 65535,
|
|
81
|
+
decode: () => {
|
|
82
|
+
this.instance.seq.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(6, 2)));
|
|
83
|
+
},
|
|
84
|
+
encode: () => {
|
|
85
|
+
const seq = this.instance.seq.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
86
|
+
this.instance.seq.setValue(seq);
|
|
87
|
+
this.writeBytes(6, (0, NumberToBuffer_1.UInt16ToBuffer)(seq));
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
message: {
|
|
91
|
+
type: 'string',
|
|
92
|
+
label: 'Message Body',
|
|
93
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
94
|
+
decode: () => {
|
|
95
|
+
const messageDataLength = this.packet.length - this.startPos - 8;
|
|
96
|
+
this.instance.message.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(8, messageDataLength)));
|
|
97
|
+
},
|
|
98
|
+
encode: () => {
|
|
99
|
+
const messageHex = this.instance.message.getValue('');
|
|
100
|
+
this.instance.message.setValue(messageHex);
|
|
101
|
+
this.writeBytes(8, Buffer.from(messageHex, 'hex'));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
this.id = 'icmp';
|
|
107
|
+
this.matchKeys = ['ipproto:1'];
|
|
108
|
+
this.name = 'Internet Control Message Protocol';
|
|
109
|
+
this.nickname = 'ICMP';
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Calculate ICMPv4 checksum
|
|
113
|
+
* @protected
|
|
114
|
+
*/
|
|
115
|
+
calculateIcmpChecksum() {
|
|
116
|
+
const icmpHeader = Buffer.concat([
|
|
117
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(this.instance.type.getValue(0)),
|
|
118
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(this.instance.code.getValue(0)),
|
|
119
|
+
(0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.checksum.getValue(0)),
|
|
120
|
+
(0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.ident.getValue(0)),
|
|
121
|
+
(0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.seq.getValue(0)),
|
|
122
|
+
Buffer.from(this.instance.message.getValue(''), 'hex')
|
|
123
|
+
]);
|
|
124
|
+
const paddedBuffer = icmpHeader.length % 2 === 1 ?
|
|
125
|
+
Buffer.concat([
|
|
126
|
+
icmpHeader,
|
|
127
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(0)
|
|
128
|
+
]) : icmpHeader;
|
|
129
|
+
// 4. 计算 checksum
|
|
130
|
+
let checksum = 0;
|
|
131
|
+
for (let i = 0; i < paddedBuffer.length; i += 2) {
|
|
132
|
+
const word = (paddedBuffer[i] << 8) | (paddedBuffer[i + 1] || 0);
|
|
133
|
+
checksum += word;
|
|
134
|
+
// 处理溢出
|
|
135
|
+
if (checksum > 0xFFFF) {
|
|
136
|
+
checksum = (checksum & 0xFFFF) + 1;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// 取反得到最终 checksum
|
|
140
|
+
return (~checksum) & 0xFFFF;
|
|
141
|
+
}
|
|
142
|
+
match() {
|
|
143
|
+
if (!this.prevCodecModule)
|
|
144
|
+
return false;
|
|
145
|
+
return this.prevCodecModule.instance.protocol.getValue() === 0x01;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.ICMP = ICMP;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
2
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
3
|
+
export declare class ICMPv6 extends BaseHeader {
|
|
4
|
+
/**
|
|
5
|
+
* Calculate ICMPv6 checksum
|
|
6
|
+
* @protected
|
|
7
|
+
*/
|
|
8
|
+
protected calculateIcmpv6Checksum(): number;
|
|
9
|
+
SCHEMA: ProtocolJSONSchema;
|
|
10
|
+
id: string;
|
|
11
|
+
readonly matchKeys: string[];
|
|
12
|
+
name: string;
|
|
13
|
+
nickname: string;
|
|
14
|
+
match(): boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ICMPv6 = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
6
|
+
const BufferToNumber_1 = require("../helper/BufferToNumber");
|
|
7
|
+
const NumberToBuffer_1 = require("../helper/NumberToBuffer");
|
|
8
|
+
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
9
|
+
const IPToBuffer_1 = require("../helper/IPToBuffer");
|
|
10
|
+
class ICMPv6 extends BaseHeader_1.BaseHeader {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.SCHEMA = {
|
|
14
|
+
type: 'object',
|
|
15
|
+
properties: {
|
|
16
|
+
type: {
|
|
17
|
+
type: 'integer',
|
|
18
|
+
label: 'Type',
|
|
19
|
+
minimum: 0,
|
|
20
|
+
maximum: 255,
|
|
21
|
+
decode: () => {
|
|
22
|
+
this.instance.type.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(0, 1)));
|
|
23
|
+
},
|
|
24
|
+
encode: () => {
|
|
25
|
+
const type = this.instance.type.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
26
|
+
this.instance.type.setValue(type);
|
|
27
|
+
this.writeBytes(0, (0, NumberToBuffer_1.UInt8ToBuffer)(type));
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
code: {
|
|
31
|
+
type: 'integer',
|
|
32
|
+
label: 'Code',
|
|
33
|
+
minimum: 0,
|
|
34
|
+
maximum: 255,
|
|
35
|
+
decode: () => {
|
|
36
|
+
this.instance.code.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(1, 1)));
|
|
37
|
+
},
|
|
38
|
+
encode: () => {
|
|
39
|
+
const code = this.instance.code.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
40
|
+
this.instance.code.setValue(code);
|
|
41
|
+
this.writeBytes(1, (0, NumberToBuffer_1.UInt8ToBuffer)(code));
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
checksum: {
|
|
45
|
+
type: 'integer',
|
|
46
|
+
label: 'Checksum',
|
|
47
|
+
minimum: 0,
|
|
48
|
+
maximum: 65535,
|
|
49
|
+
decode: () => {
|
|
50
|
+
this.instance.checksum.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
|
|
51
|
+
},
|
|
52
|
+
encode: () => {
|
|
53
|
+
let checksum = this.instance.checksum.getValue(0);
|
|
54
|
+
this.instance.checksum.setValue(checksum);
|
|
55
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
56
|
+
if (!checksum) {
|
|
57
|
+
checksum = this.calculateIcmpv6Checksum();
|
|
58
|
+
this.instance.checksum.setValue(checksum);
|
|
59
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
message: {
|
|
64
|
+
type: 'string',
|
|
65
|
+
label: 'Message Body',
|
|
66
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
67
|
+
decode: () => {
|
|
68
|
+
const messageDataLength = this.packet.length - this.startPos - 4;
|
|
69
|
+
this.instance.message.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(4, messageDataLength)));
|
|
70
|
+
},
|
|
71
|
+
encode: () => {
|
|
72
|
+
const messageHex = this.instance.message.getValue('');
|
|
73
|
+
this.instance.message.setValue(messageHex);
|
|
74
|
+
this.writeBytes(4, Buffer.from(messageHex, 'hex'));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
this.id = 'icmpv6';
|
|
80
|
+
this.matchKeys = ['ipproto:58'];
|
|
81
|
+
this.name = 'Internet Control Message Protocol v6';
|
|
82
|
+
this.nickname = 'ICMPv6';
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Calculate ICMPv6 checksum
|
|
86
|
+
* @protected
|
|
87
|
+
*/
|
|
88
|
+
calculateIcmpv6Checksum() {
|
|
89
|
+
const ipv6Header = this.prevCodecModules.find((prevCodecModule) => prevCodecModule.id === 'ipv6');
|
|
90
|
+
if (!ipv6Header)
|
|
91
|
+
return 0;
|
|
92
|
+
const messageBody = Buffer.from(this.instance.message.getValue(''), 'hex');
|
|
93
|
+
const sip = ipv6Header.instance.sip.getValue('0000:0000:0000:0000:0000:0000:0000:0000');
|
|
94
|
+
const dip = ipv6Header.instance.dip.getValue('0000:0000:0000:0000:0000:0000:0000:0000');
|
|
95
|
+
const pseudoHeader = Buffer.concat([
|
|
96
|
+
(0, IPToBuffer_1.IPv6ToBuffer)(sip),
|
|
97
|
+
(0, IPToBuffer_1.IPv6ToBuffer)(dip),
|
|
98
|
+
(0, NumberToBuffer_1.UInt32ToBuffer)(messageBody.length + 4),
|
|
99
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(0x00),
|
|
100
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(0x00),
|
|
101
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(0x00),
|
|
102
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(0x3a)
|
|
103
|
+
]);
|
|
104
|
+
const icmpHeader = Buffer.concat([
|
|
105
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(this.instance.type.getValue(0)),
|
|
106
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(this.instance.code.getValue(0)),
|
|
107
|
+
(0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.checksum.getValue(0))
|
|
108
|
+
]);
|
|
109
|
+
const buffer = Buffer.concat([
|
|
110
|
+
pseudoHeader,
|
|
111
|
+
icmpHeader,
|
|
112
|
+
messageBody
|
|
113
|
+
]);
|
|
114
|
+
const paddedBuffer = buffer.length % 2 === 1 ? Buffer.concat([buffer, (0, NumberToBuffer_1.UInt8ToBuffer)(0)]) : buffer;
|
|
115
|
+
let checksum = 0;
|
|
116
|
+
for (let i = 0; i < paddedBuffer.length; i += 2) {
|
|
117
|
+
checksum += (paddedBuffer[i] << 8) | (paddedBuffer[i + 1] || 0);
|
|
118
|
+
if (checksum > 0xFFFF)
|
|
119
|
+
checksum = (checksum & 0xFFFF) + 1;
|
|
120
|
+
}
|
|
121
|
+
return (~checksum) & 0xFFFF;
|
|
122
|
+
}
|
|
123
|
+
match() {
|
|
124
|
+
if (!this.prevCodecModule)
|
|
125
|
+
return false;
|
|
126
|
+
return this.prevCodecModule.instance.nxt.getValue() === 0x3a;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.ICMPv6 = ICMPv6;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
2
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
3
|
+
export declare class IEC104_I_Frame extends BaseHeader {
|
|
4
|
+
/**
|
|
5
|
+
* True when decode preserved an unparsed ASDU (unknown/unsupported type id) and no
|
|
6
|
+
* structured IOA content is present. Encode then re-emits the raw ASDU bytes verbatim;
|
|
7
|
+
* supplying structured IOA turns this false and encode rebuilds from fields.
|
|
8
|
+
*/
|
|
9
|
+
protected asduRawFallbackActive(): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Write an information object's 3-octet address. SQ=0 frames carry a per-object address; SQ=1
|
|
12
|
+
* frames carry a single base address (before the first element) with the rest implied by
|
|
13
|
+
* incrementing, so only object 1 writes it.
|
|
14
|
+
*/
|
|
15
|
+
protected writeIOAAddress(offset: number, buffer: Buffer, i: number): void;
|
|
16
|
+
SCHEMA: ProtocolJSONSchema;
|
|
17
|
+
id: string;
|
|
18
|
+
readonly matchKeys: string[];
|
|
19
|
+
readonly heuristicFallback: boolean;
|
|
20
|
+
name: string;
|
|
21
|
+
nickname: string;
|
|
22
|
+
match(): boolean;
|
|
23
|
+
}
|