@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,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EtherCAT = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
6
|
+
const HexToBuffer_1 = require("../helper/HexToBuffer");
|
|
7
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
8
|
+
/**
|
|
9
|
+
* EtherCAT — Ethernet for Control Automation Technology (IEC 61158 Type 12), carried directly in an
|
|
10
|
+
* Ethernet II frame with EtherType 0x88A4 (an Ethernet child — no IP/UDP). Immediately after the Ethernet
|
|
11
|
+
* header comes a 2-byte EtherCAT header, then the EtherCAT datagram chain.
|
|
12
|
+
*
|
|
13
|
+
* ⚠️ Unlike most of the codec's protocols (which are big-endian), the 2-byte EtherCAT header is a single
|
|
14
|
+
* LITTLE-ENDIAN uint16. There is no little-endian helper in this codebase, so the header word is read and
|
|
15
|
+
* written byte-by-byte in the closures (see ENIP for the precedent). Within that 16-bit LE value `h`:
|
|
16
|
+
* - Length = bits 0..10 (11 bits) = byte count of all datagrams that follow the 2-byte header.
|
|
17
|
+
* - Reserved = bit 11 (1 bit) = preserved verbatim for a byte-perfect round-trip.
|
|
18
|
+
* - Type = bits 12..15 (4 bits) = 1 for EtherCAT commands (DLPDUs); other values exist.
|
|
19
|
+
* So `length = h & 0x07FF`, `reserved = (h >> 11) & 0x1`, `type = (h >> 12) & 0x0F`; and on encode
|
|
20
|
+
* `h = (length & 0x07FF) | ((reserved & 1) << 11) | ((type & 0x0F) << 12)`, written LITTLE-ENDIAN as
|
|
21
|
+
* `[h & 0xff, (h >> 8) & 0xff]`.
|
|
22
|
+
*
|
|
23
|
+
* The datagram chain (each datagram: 10-byte header + data + 2-byte working counter) is command-dependent,
|
|
24
|
+
* addressed, chainable state, so this minimal slice keeps it verbatim as `data` hex (byte-perfect), bounded
|
|
25
|
+
* by the Length field (data ends at offset 2 + Length, clamped to the captured bytes). Anything after the
|
|
26
|
+
* Length-bounded region is left to the codec's recursion / RawData (e.g. Ethernet padding). Structuring the
|
|
27
|
+
* datagram chain (Cmd/Idx/Address/Len/IRQ/WKC per datagram) is a deferred slice. Length is honor-else-derive
|
|
28
|
+
* on encode: honored when supplied (a crafted frame may carry any Length), else derived from the data.
|
|
29
|
+
*/
|
|
30
|
+
class EtherCAT extends BaseHeader_1.BaseHeader {
|
|
31
|
+
constructor() {
|
|
32
|
+
super(...arguments);
|
|
33
|
+
this.id = 'ecat';
|
|
34
|
+
this.name = 'EtherCAT';
|
|
35
|
+
this.nickname = 'EtherCAT';
|
|
36
|
+
this.matchKeys = ['ethertype:88a4'];
|
|
37
|
+
//A leaf header — the datagram chain requires command-dependent, addressed parsing (deferred slice).
|
|
38
|
+
this.demuxProducers = [];
|
|
39
|
+
}
|
|
40
|
+
static #schemaCache;
|
|
41
|
+
get SCHEMA() {
|
|
42
|
+
return (EtherCAT.#schemaCache ??= EtherCAT.#buildSchema());
|
|
43
|
+
}
|
|
44
|
+
/** Read the 2-byte EtherCAT header as a little-endian uint16. */
|
|
45
|
+
static #readHeaderWord(header) {
|
|
46
|
+
const b = header.readBytes(0, 2);
|
|
47
|
+
return b[0] | (b[1] << 8);
|
|
48
|
+
}
|
|
49
|
+
static #buildSchema() {
|
|
50
|
+
return {
|
|
51
|
+
type: 'object',
|
|
52
|
+
summary: 'EtherCAT type=${type} len=${length}',
|
|
53
|
+
properties: {
|
|
54
|
+
//length/reserved/type all live in the same 2 header bytes (one little-endian uint16), so
|
|
55
|
+
//each decodes from that single LE word by extracting its bits. Only `length` has an encode:
|
|
56
|
+
//it re-reads all three instance values, assembles the full word, and writes the 2 bytes once
|
|
57
|
+
//(so the three fields never clobber each other). reserved/type are decode-only.
|
|
58
|
+
length: {
|
|
59
|
+
type: 'integer',
|
|
60
|
+
label: 'Length',
|
|
61
|
+
minimum: 0,
|
|
62
|
+
//The on-wire field is 11 bits (max 0x7FF); the schema bound is left wider (uint16) so an
|
|
63
|
+
//over-range value reaches the encode closure and is clamped+recorded there (an 11-bit
|
|
64
|
+
//Ajv cap would silently reject it at the entry point instead).
|
|
65
|
+
maximum: 65535,
|
|
66
|
+
decode: function () {
|
|
67
|
+
this.instance.length.setValue(EtherCAT.#readHeaderWord(this) & 0x07FF);
|
|
68
|
+
},
|
|
69
|
+
encode: function () {
|
|
70
|
+
//Length counts only the datagram bytes that follow the 2-byte header. Honored when
|
|
71
|
+
//supplied (a crafted frame may lie); else derived from the data byte count.
|
|
72
|
+
const provided = this.instance.length.getValue();
|
|
73
|
+
let length = (provided !== undefined && provided !== null)
|
|
74
|
+
? provided
|
|
75
|
+
: (0, HexToBuffer_1.HexToBuffer)(this.instance.data.getValue('')).length;
|
|
76
|
+
//Length is an 11-bit field (max 0x7FF). A larger value cannot be represented, so
|
|
77
|
+
//clamp it and record the error rather than letting it wrap into the Type/Reserved
|
|
78
|
+
//bits (which would corrupt the header word).
|
|
79
|
+
if (length > 0x7FF) {
|
|
80
|
+
this.recordError(this.instance.length.getPath(), 'Maximum value is 2047');
|
|
81
|
+
length = 0x7FF;
|
|
82
|
+
}
|
|
83
|
+
if (length < 0) {
|
|
84
|
+
this.recordError(this.instance.length.getPath(), 'Minimum value is 0');
|
|
85
|
+
length = 0;
|
|
86
|
+
}
|
|
87
|
+
this.instance.length.setValue(length);
|
|
88
|
+
const reserved = this.instance.reserved.getValue(0) & 0x1;
|
|
89
|
+
const type = this.instance.type.getValue(0) & 0x0F;
|
|
90
|
+
const h = (length & 0x07FF) | (reserved << 11) | (type << 12);
|
|
91
|
+
this.writeBytes(0, Buffer.from([h & 0xff, (h >> 8) & 0xff]));
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
reserved: {
|
|
95
|
+
type: 'integer',
|
|
96
|
+
label: 'Reserved',
|
|
97
|
+
minimum: 0,
|
|
98
|
+
maximum: 1,
|
|
99
|
+
default: 0,
|
|
100
|
+
//Decode-only: bit 11 of the LE header word. Written by `length`'s encode (see above).
|
|
101
|
+
decode: function () {
|
|
102
|
+
this.instance.reserved.setValue((EtherCAT.#readHeaderWord(this) >> 11) & 0x1);
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
type: {
|
|
106
|
+
type: 'integer',
|
|
107
|
+
label: 'Type',
|
|
108
|
+
minimum: 0,
|
|
109
|
+
maximum: 15,
|
|
110
|
+
default: 1,
|
|
111
|
+
//Decode-only: bits 12..15 of the LE header word. Written by `length`'s encode (see above).
|
|
112
|
+
decode: function () {
|
|
113
|
+
this.instance.type.setValue((EtherCAT.#readHeaderWord(this) >> 12) & 0x0F);
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
//The EtherCAT datagram chain, kept verbatim (byte-perfect). Bounded by the Length field
|
|
117
|
+
//(data ends at offset 2 + Length) and the captured bytes, so trailing padding / pipelined
|
|
118
|
+
//bytes are left to the codec's recursion / RawData. Datagram structuring is a deferred slice.
|
|
119
|
+
data: {
|
|
120
|
+
type: 'string',
|
|
121
|
+
label: 'Data',
|
|
122
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
123
|
+
decode: function () {
|
|
124
|
+
const remaining = this.packet.length - this.startPos;
|
|
125
|
+
const length = this.instance.length.getValue(0);
|
|
126
|
+
let end = 2 + length;
|
|
127
|
+
if (end > remaining)
|
|
128
|
+
end = remaining;
|
|
129
|
+
this.instance.data.setValue(end > 2 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(2, end - 2)) : '');
|
|
130
|
+
},
|
|
131
|
+
encode: function () {
|
|
132
|
+
const data = this.instance.data.getValue('');
|
|
133
|
+
if (data)
|
|
134
|
+
this.writeBytes(2, (0, HexToBuffer_1.HexToBuffer)(data));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
match() {
|
|
141
|
+
//An Ethernet child selected by EtherType 0x88A4 (stored as a lowercase 4-hex string). Require the
|
|
142
|
+
//2-byte minimum for the EtherCAT header.
|
|
143
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'eth')
|
|
144
|
+
return false;
|
|
145
|
+
if (this.prevCodecModule.instance.etherType.getValue() !== '88a4')
|
|
146
|
+
return false;
|
|
147
|
+
return this.packet.length - this.startPos >= 2;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.EtherCAT = EtherCAT;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
3
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
4
|
+
/**
|
|
5
|
+
* Ethernet II — the DIX/Ethernet II MAC frame header, the usual L2 root of a captured packet. This codec
|
|
6
|
+
* decodes the 14-octet header: a 6-octet Destination MAC (`dmac`, offset 0) and 6-octet Source MAC
|
|
7
|
+
* (`smac`, offset 6), both formatted as colon-separated lowercase hex, and a 16-bit EtherType
|
|
8
|
+
* (`etherType`, offset 12, kept as a 4-hex string e.g. "0800"). The EtherType is published as a demux
|
|
9
|
+
* key (namespace `ethertype`) so the next layer (IPv4/IPv6/ARP/VLAN/GOOSE/SV…) is selected by it.
|
|
10
|
+
*
|
|
11
|
+
* As the link-layer root it registers `linktype:1` (DLT_EN10MB) so decode(packet, 1) dispatches here, and
|
|
12
|
+
* `heuristicFallback` keeps Ethernet the default root: match() returns true when there is no parent. When
|
|
13
|
+
* there IS a parent it only claims the payload of tunnels that carry a bare inner Ethernet frame —
|
|
14
|
+
* unconditionally for TRILL / VXLAN / NVGRE / MPLS / QinQ, and for GENEVE / GRE only when their Protocol
|
|
15
|
+
* Type is 0x6558 (Transparent Ethernet Bridging); other GENEVE/GRE payloads route elsewhere rather than
|
|
16
|
+
* being mislabeled as a fabricated Ethernet layer.
|
|
17
|
+
*/
|
|
18
|
+
export declare class EthernetII extends BaseHeader {
|
|
19
|
+
#private;
|
|
20
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly nickname: string;
|
|
24
|
+
readonly demuxProducers: DemuxProducer[];
|
|
25
|
+
readonly matchKeys: string[];
|
|
26
|
+
readonly heuristicFallback: boolean;
|
|
27
|
+
match(): boolean;
|
|
28
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EthernetII = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const NumberToHex_1 = require("../helper/NumberToHex");
|
|
6
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
7
|
+
/**
|
|
8
|
+
* Ethernet II — the DIX/Ethernet II MAC frame header, the usual L2 root of a captured packet. This codec
|
|
9
|
+
* decodes the 14-octet header: a 6-octet Destination MAC (`dmac`, offset 0) and 6-octet Source MAC
|
|
10
|
+
* (`smac`, offset 6), both formatted as colon-separated lowercase hex, and a 16-bit EtherType
|
|
11
|
+
* (`etherType`, offset 12, kept as a 4-hex string e.g. "0800"). The EtherType is published as a demux
|
|
12
|
+
* key (namespace `ethertype`) so the next layer (IPv4/IPv6/ARP/VLAN/GOOSE/SV…) is selected by it.
|
|
13
|
+
*
|
|
14
|
+
* As the link-layer root it registers `linktype:1` (DLT_EN10MB) so decode(packet, 1) dispatches here, and
|
|
15
|
+
* `heuristicFallback` keeps Ethernet the default root: match() returns true when there is no parent. When
|
|
16
|
+
* there IS a parent it only claims the payload of tunnels that carry a bare inner Ethernet frame —
|
|
17
|
+
* unconditionally for TRILL / VXLAN / NVGRE / MPLS / QinQ, and for GENEVE / GRE only when their Protocol
|
|
18
|
+
* Type is 0x6558 (Transparent Ethernet Bridging); other GENEVE/GRE payloads route elsewhere rather than
|
|
19
|
+
* being mislabeled as a fabricated Ethernet layer.
|
|
20
|
+
*/
|
|
21
|
+
class EthernetII extends BaseHeader_1.BaseHeader {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(...arguments);
|
|
24
|
+
this.id = 'eth';
|
|
25
|
+
this.name = 'Ethernet II';
|
|
26
|
+
this.nickname = 'ETH';
|
|
27
|
+
this.demuxProducers = [{ field: 'etherType', namespace: 'ethertype', kind: 'string' }];
|
|
28
|
+
//DLT_EN10MB = 1. Lets decode(packet, 1) dispatch to Ethernet by link type; heuristicFallback keeps
|
|
29
|
+
//Ethernet as the default no-linktype root (its match() still succeeds when there is no parent).
|
|
30
|
+
this.matchKeys = ['linktype:1'];
|
|
31
|
+
this.heuristicFallback = true;
|
|
32
|
+
}
|
|
33
|
+
static #schemaCache;
|
|
34
|
+
//Class-cached SCHEMA (④): field closures are plain functions taking dynamic `this` via .call(this),
|
|
35
|
+
//so they capture no instance and the structure is built once and shared.
|
|
36
|
+
get SCHEMA() {
|
|
37
|
+
return (EthernetII.#schemaCache ??= EthernetII.#buildSchema());
|
|
38
|
+
}
|
|
39
|
+
static #buildSchema() {
|
|
40
|
+
return {
|
|
41
|
+
type: 'object',
|
|
42
|
+
properties: {
|
|
43
|
+
dmac: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
minLength: 17,
|
|
46
|
+
maxLength: 17,
|
|
47
|
+
label: 'Destination',
|
|
48
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.MAC,
|
|
49
|
+
decode: function () {
|
|
50
|
+
this.instance.dmac.setValue(Array.from(this.readBytes(0, 6)).map((value) => value.toString(16).padStart(2, '0')).join(':'));
|
|
51
|
+
},
|
|
52
|
+
encode: function () {
|
|
53
|
+
const dmac = this.instance.dmac
|
|
54
|
+
.getValue('00:00:00:00:00:00', (nodePath) => this.recordError(nodePath, 'Not Found'))
|
|
55
|
+
.toString()
|
|
56
|
+
.split(':')
|
|
57
|
+
.map((value) => parseInt(value, 16))
|
|
58
|
+
.map((value) => value ? value : 0);
|
|
59
|
+
this.writeBytes(0, Buffer.alloc(6, Buffer.from(dmac)));
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
smac: {
|
|
63
|
+
type: 'string',
|
|
64
|
+
minLength: 17,
|
|
65
|
+
maxLength: 17,
|
|
66
|
+
label: 'Source',
|
|
67
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.MAC,
|
|
68
|
+
decode: function () {
|
|
69
|
+
this.instance.smac.setValue(Array.from(this.readBytes(6, 6)).map((value) => value.toString(16).padStart(2, '0')).join(':'));
|
|
70
|
+
},
|
|
71
|
+
encode: function () {
|
|
72
|
+
const smac = this.instance.smac
|
|
73
|
+
.getValue('00:00:00:00:00:00', (nodePath) => this.recordError(nodePath, 'Not Found'))
|
|
74
|
+
.toString()
|
|
75
|
+
.split(':')
|
|
76
|
+
.map((value) => parseInt(value, 16))
|
|
77
|
+
.map((value) => value ? value : 0);
|
|
78
|
+
this.writeBytes(6, Buffer.alloc(6, Buffer.from(smac)));
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
etherType: {
|
|
82
|
+
type: 'string',
|
|
83
|
+
minLength: 4,
|
|
84
|
+
maxLength: 4,
|
|
85
|
+
label: 'EtherType',
|
|
86
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
87
|
+
decode: function () {
|
|
88
|
+
this.instance.etherType.setValue(this.readBytes(12, 2).toString('hex').padStart(4, '0'));
|
|
89
|
+
},
|
|
90
|
+
encode: function () {
|
|
91
|
+
const etherType = this.instance.etherType.getValue((0, NumberToHex_1.UInt16ToHex)(0x0000), (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
92
|
+
const typeBuffer = Buffer.from(etherType, 'hex');
|
|
93
|
+
if (typeBuffer.length < 2)
|
|
94
|
+
typeBuffer.fill(0, 0, 1);
|
|
95
|
+
this.writeBytes(12, typeBuffer.subarray(0, 2));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
match() {
|
|
102
|
+
if (!this.prevCodecModule)
|
|
103
|
+
return true;
|
|
104
|
+
//Tunnels that carry a bare Ethernet frame with no inner protocol-type field: claim their payload
|
|
105
|
+
//as Ethernet unconditionally.
|
|
106
|
+
const specialScenes = ['trill', 'vxlan', 'nvgre', 'mpls', 'qinq'];
|
|
107
|
+
if (specialScenes.includes(this.prevCodecModule.id))
|
|
108
|
+
return true;
|
|
109
|
+
//GENEVE and GRE carry a Protocol Type: only their Transparent Ethernet Bridging payload (0x6558)
|
|
110
|
+
//is an inner Ethernet frame. Other types route to IPv4/IPv6 (ethertype demux) or fall through to
|
|
111
|
+
//Raw — so an unknown type is not mislabeled as a fabricated Ethernet layer.
|
|
112
|
+
if (this.prevCodecModule.id === 'geneve' || this.prevCodecModule.id === 'gre')
|
|
113
|
+
return this.prevCodecModule.instance.protocolType.getValue() === (0, NumberToHex_1.UInt16ToHex)(0x6558);
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.EthernetII = EthernetII;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* FCoE — Fibre Channel over Ethernet (FC-BB-5 / T11), carried directly in an Ethernet II frame with
|
|
6
|
+
* EtherType 0x8906 (an Ethernet child — no IP/UDP). An FCoE frame encapsulates a full native Fibre
|
|
7
|
+
* Channel frame between a 14-byte FCoE header and a 4-byte FCoE trailer:
|
|
8
|
+
*
|
|
9
|
+
* +--------------------------------------------------------------+
|
|
10
|
+
* | FCoE header (14 bytes): Version (high 4 bits of byte 0) + |
|
|
11
|
+
* | Reserved (low 4 bits of byte 0 + 12 bytes) + SOF (byte 13) |
|
|
12
|
+
* +--------------------------------------------------------------+
|
|
13
|
+
* | Encapsulated FC frame: 24-byte FC header (R_CTL/D_ID/CS_CTL/ |
|
|
14
|
+
* | S_ID/TYPE/F_CTL/SEQ_ID/DF_CTL/SEQ_CNT/OX_ID/RX_ID/Parameter)|
|
|
15
|
+
* | + FC payload + 4-byte FC CRC |
|
|
16
|
+
* +--------------------------------------------------------------+
|
|
17
|
+
* | FCoE trailer (4 bytes): EOF (1 byte) + Reserved (3 bytes) |
|
|
18
|
+
* +--------------------------------------------------------------+
|
|
19
|
+
*
|
|
20
|
+
* The Version nibble and the SOF/EOF delimiter codes are surfaced structurally; the encapsulated FC
|
|
21
|
+
* frame (FC header + payload + FC CRC) needs FC-level, cross-frame class-of-service context and its own
|
|
22
|
+
* CRC handling, so this codec keeps it verbatim as `fcFrame` hex (byte-perfect) rather than sub-decoding
|
|
23
|
+
* it — the FC dissection is a later enrichment. FCoE carries no length field of its own: like other
|
|
24
|
+
* Ethernet children it runs to the end of the frame, so the encapsulated FC frame is bounded by the
|
|
25
|
+
* frame's last 4 bytes (the EOF trailer). Nothing (CRC, SOF/EOF) is recomputed on encode — a faithful
|
|
26
|
+
* executor carries the delimiters and the FC CRC as-is — so a well-formed FCoE frame round-trips
|
|
27
|
+
* byte-for-byte.
|
|
28
|
+
*/
|
|
29
|
+
export declare class FCoE extends BaseHeader {
|
|
30
|
+
#private;
|
|
31
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
32
|
+
readonly id: string;
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly nickname: string;
|
|
35
|
+
readonly matchKeys: string[];
|
|
36
|
+
match(): boolean;
|
|
37
|
+
readonly demuxProducers: DemuxProducer[];
|
|
38
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FCoE = 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
|
+
* FCoE — Fibre Channel over Ethernet (FC-BB-5 / T11), carried directly in an Ethernet II frame with
|
|
12
|
+
* EtherType 0x8906 (an Ethernet child — no IP/UDP). An FCoE frame encapsulates a full native Fibre
|
|
13
|
+
* Channel frame between a 14-byte FCoE header and a 4-byte FCoE trailer:
|
|
14
|
+
*
|
|
15
|
+
* +--------------------------------------------------------------+
|
|
16
|
+
* | FCoE header (14 bytes): Version (high 4 bits of byte 0) + |
|
|
17
|
+
* | Reserved (low 4 bits of byte 0 + 12 bytes) + SOF (byte 13) |
|
|
18
|
+
* +--------------------------------------------------------------+
|
|
19
|
+
* | Encapsulated FC frame: 24-byte FC header (R_CTL/D_ID/CS_CTL/ |
|
|
20
|
+
* | S_ID/TYPE/F_CTL/SEQ_ID/DF_CTL/SEQ_CNT/OX_ID/RX_ID/Parameter)|
|
|
21
|
+
* | + FC payload + 4-byte FC CRC |
|
|
22
|
+
* +--------------------------------------------------------------+
|
|
23
|
+
* | FCoE trailer (4 bytes): EOF (1 byte) + Reserved (3 bytes) |
|
|
24
|
+
* +--------------------------------------------------------------+
|
|
25
|
+
*
|
|
26
|
+
* The Version nibble and the SOF/EOF delimiter codes are surfaced structurally; the encapsulated FC
|
|
27
|
+
* frame (FC header + payload + FC CRC) needs FC-level, cross-frame class-of-service context and its own
|
|
28
|
+
* CRC handling, so this codec keeps it verbatim as `fcFrame` hex (byte-perfect) rather than sub-decoding
|
|
29
|
+
* it — the FC dissection is a later enrichment. FCoE carries no length field of its own: like other
|
|
30
|
+
* Ethernet children it runs to the end of the frame, so the encapsulated FC frame is bounded by the
|
|
31
|
+
* frame's last 4 bytes (the EOF trailer). Nothing (CRC, SOF/EOF) is recomputed on encode — a faithful
|
|
32
|
+
* executor carries the delimiters and the FC CRC as-is — so a well-formed FCoE frame round-trips
|
|
33
|
+
* byte-for-byte.
|
|
34
|
+
*/
|
|
35
|
+
class FCoE extends BaseHeader_1.BaseHeader {
|
|
36
|
+
constructor() {
|
|
37
|
+
super(...arguments);
|
|
38
|
+
this.id = 'fcoe';
|
|
39
|
+
this.name = 'Fibre Channel over Ethernet';
|
|
40
|
+
this.nickname = 'FCoE';
|
|
41
|
+
this.matchKeys = ['ethertype:8906'];
|
|
42
|
+
//A leaf header — the encapsulated FC frame requires FC-level, cross-frame parsing.
|
|
43
|
+
this.demuxProducers = [];
|
|
44
|
+
}
|
|
45
|
+
static #schemaCache;
|
|
46
|
+
get SCHEMA() {
|
|
47
|
+
return (FCoE.#schemaCache ??= FCoE.#buildSchema());
|
|
48
|
+
}
|
|
49
|
+
/** Header length of the fixed FCoE header (Version + Reserved + SOF). */
|
|
50
|
+
static #HEADER_LEN = 14;
|
|
51
|
+
/** Trailer length of the fixed FCoE trailer (EOF + 3 reserved bytes). */
|
|
52
|
+
static #TRAILER_LEN = 4;
|
|
53
|
+
/**
|
|
54
|
+
* Bytes available to FCoE within the Ethernet frame. FCoE has no length field — it runs to the end
|
|
55
|
+
* of the frame — so the whole captured Ethernet payload is FCoE content (header + FC frame + trailer).
|
|
56
|
+
*/
|
|
57
|
+
#available() {
|
|
58
|
+
const available = this.packet.length - this.startPos;
|
|
59
|
+
return available < 0 ? 0 : available;
|
|
60
|
+
}
|
|
61
|
+
static #buildSchema() {
|
|
62
|
+
return {
|
|
63
|
+
type: 'object',
|
|
64
|
+
summary: 'FCoE ver=${version} sof=${sof} eof=${eof}',
|
|
65
|
+
properties: {
|
|
66
|
+
//Version — the high 4 bits of byte 0 (FC-BB-5 defines version 0).
|
|
67
|
+
version: {
|
|
68
|
+
type: 'integer',
|
|
69
|
+
label: 'Version',
|
|
70
|
+
minimum: 0,
|
|
71
|
+
maximum: 15,
|
|
72
|
+
decode: function () {
|
|
73
|
+
this.instance.version.setValue(this.readBits(0, 1, 0, 4));
|
|
74
|
+
},
|
|
75
|
+
encode: function () {
|
|
76
|
+
const node = this.instance.version;
|
|
77
|
+
let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
78
|
+
if (value > 15) {
|
|
79
|
+
this.recordError(node.getPath(), 'Maximum value is 15');
|
|
80
|
+
value = 15;
|
|
81
|
+
}
|
|
82
|
+
if (value < 0) {
|
|
83
|
+
this.recordError(node.getPath(), 'Minimum value is 0');
|
|
84
|
+
value = 0;
|
|
85
|
+
}
|
|
86
|
+
node.setValue(value);
|
|
87
|
+
this.writeBits(0, 1, 0, 4, value);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
//Reserved — the low 4 bits of byte 0 (kept verbatim so any non-zero reserved nibble
|
|
91
|
+
//round-trips). Shares byte 0 with Version; writeBits masks so the two never clobber.
|
|
92
|
+
reservedFlags: {
|
|
93
|
+
type: 'integer',
|
|
94
|
+
label: 'Reserved',
|
|
95
|
+
minimum: 0,
|
|
96
|
+
maximum: 15,
|
|
97
|
+
decode: function () {
|
|
98
|
+
this.instance.reservedFlags.setValue(this.readBits(0, 1, 4, 4));
|
|
99
|
+
},
|
|
100
|
+
encode: function () {
|
|
101
|
+
const node = this.instance.reservedFlags;
|
|
102
|
+
let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
103
|
+
if (value > 15) {
|
|
104
|
+
this.recordError(node.getPath(), 'Maximum value is 15');
|
|
105
|
+
value = 15;
|
|
106
|
+
}
|
|
107
|
+
if (value < 0) {
|
|
108
|
+
this.recordError(node.getPath(), 'Minimum value is 0');
|
|
109
|
+
value = 0;
|
|
110
|
+
}
|
|
111
|
+
node.setValue(value);
|
|
112
|
+
this.writeBits(0, 1, 4, 4, value);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
//The 12 reserved bytes (bytes 1..12) of the FCoE header, kept verbatim.
|
|
116
|
+
reserved: this.fieldHex('reserved', 1, 12, 'Reserved'),
|
|
117
|
+
//Start Of Frame delimiter code (byte 13) — e.g. SOFi3 0x2e, SOFn3 0x36. Kept verbatim.
|
|
118
|
+
sof: this.fieldUInt('sof', 13, 1, 'SOF'),
|
|
119
|
+
//The encapsulated Fibre Channel frame: 24-byte FC header + FC payload + 4-byte FC CRC,
|
|
120
|
+
//kept verbatim. Bounded by the frame's last 4 bytes (the EOF trailer) so the trailer is
|
|
121
|
+
//not pulled into the FC frame; FCoE runs to the end of the Ethernet frame.
|
|
122
|
+
fcFrame: {
|
|
123
|
+
type: 'string',
|
|
124
|
+
label: 'FC Frame',
|
|
125
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
126
|
+
decode: function () {
|
|
127
|
+
const available = this.#available();
|
|
128
|
+
//A trailer (EOF + 3 reserved) is present only when there is room for both the
|
|
129
|
+
//14-byte header and the 4-byte trailer; otherwise everything after the header is
|
|
130
|
+
//the (truncated) FC frame and there is no trailer.
|
|
131
|
+
const fcEnd = available >= FCoE.#HEADER_LEN + FCoE.#TRAILER_LEN
|
|
132
|
+
? available - FCoE.#TRAILER_LEN
|
|
133
|
+
: available;
|
|
134
|
+
this.instance.fcFrame.setValue(fcEnd > FCoE.#HEADER_LEN
|
|
135
|
+
? (0, BufferToHex_1.BufferToHex)(this.readBytes(FCoE.#HEADER_LEN, fcEnd - FCoE.#HEADER_LEN))
|
|
136
|
+
: '');
|
|
137
|
+
},
|
|
138
|
+
encode: function () {
|
|
139
|
+
const fcFrame = this.instance.fcFrame.getValue('');
|
|
140
|
+
if (fcFrame)
|
|
141
|
+
this.writeBytes(FCoE.#HEADER_LEN, (0, HexToBuffer_1.HexToBuffer)(fcFrame));
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
//End Of Frame delimiter code (first trailer byte) — e.g. EOFn 0x41, EOFt 0x42. Kept
|
|
145
|
+
//verbatim. Sits at a frame-length-dependent offset (right after the FC frame), so it is
|
|
146
|
+
//located from the frame end on decode and from the FC frame length on encode.
|
|
147
|
+
eof: {
|
|
148
|
+
type: 'integer',
|
|
149
|
+
label: 'EOF',
|
|
150
|
+
minimum: 0,
|
|
151
|
+
maximum: 255,
|
|
152
|
+
decode: function () {
|
|
153
|
+
const available = this.#available();
|
|
154
|
+
if (available < FCoE.#HEADER_LEN + FCoE.#TRAILER_LEN)
|
|
155
|
+
return;
|
|
156
|
+
this.instance.eof.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(available - FCoE.#TRAILER_LEN, 1)));
|
|
157
|
+
},
|
|
158
|
+
encode: function () {
|
|
159
|
+
const raw = this.instance.eof.getValue();
|
|
160
|
+
if (raw === undefined || raw === null)
|
|
161
|
+
return;
|
|
162
|
+
const node = this.instance.eof;
|
|
163
|
+
let value = raw;
|
|
164
|
+
if (value > 255) {
|
|
165
|
+
this.recordError(node.getPath(), 'Maximum value is 255');
|
|
166
|
+
value = 255;
|
|
167
|
+
}
|
|
168
|
+
if (value < 0) {
|
|
169
|
+
this.recordError(node.getPath(), 'Minimum value is 0');
|
|
170
|
+
value = 0;
|
|
171
|
+
}
|
|
172
|
+
node.setValue(value);
|
|
173
|
+
const fcLen = (0, HexToBuffer_1.HexToBuffer)(this.instance.fcFrame.getValue('')).length;
|
|
174
|
+
this.writeBytes(FCoE.#HEADER_LEN + fcLen, (0, NumberToBuffer_1.UInt8ToBuffer)(value));
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
//The 3 reserved bytes after EOF, kept verbatim. Located from the frame end on decode and
|
|
178
|
+
//from the FC frame length on encode (right after the EOF byte).
|
|
179
|
+
eofReserved: {
|
|
180
|
+
type: 'string',
|
|
181
|
+
label: 'Reserved',
|
|
182
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
183
|
+
decode: function () {
|
|
184
|
+
const available = this.#available();
|
|
185
|
+
if (available < FCoE.#HEADER_LEN + FCoE.#TRAILER_LEN)
|
|
186
|
+
return;
|
|
187
|
+
this.instance.eofReserved.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(available - 3, 3)));
|
|
188
|
+
},
|
|
189
|
+
encode: function () {
|
|
190
|
+
const eofReserved = this.instance.eofReserved.getValue('');
|
|
191
|
+
if (!eofReserved)
|
|
192
|
+
return;
|
|
193
|
+
const fcLen = (0, HexToBuffer_1.HexToBuffer)(this.instance.fcFrame.getValue('')).length;
|
|
194
|
+
this.writeBytes(FCoE.#HEADER_LEN + fcLen + 1, (0, HexToBuffer_1.HexToBuffer)(eofReserved));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
match() {
|
|
201
|
+
//An Ethernet child selected by EtherType 0x8906 (stored as a lowercase 4-hex string). Require at
|
|
202
|
+
//least the fixed 14-byte FCoE header to be present.
|
|
203
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'eth')
|
|
204
|
+
return false;
|
|
205
|
+
if (this.prevCodecModule.instance.etherType.getValue() !== '8906')
|
|
206
|
+
return false;
|
|
207
|
+
return this.packet.length - this.startPos >= FCoE.#HEADER_LEN;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
exports.FCoE = FCoE;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* FTP — the File Transfer Protocol control channel (RFC 959), carried as US-ASCII text over TCP
|
|
6
|
+
* well-known port 21. The control channel is line-based: a client sends commands
|
|
7
|
+
* (`USER anonymous\r\n`, `PASS x\r\n`, `RETR file\r\n`, …) and a server sends replies
|
|
8
|
+
* (`220 Service ready\r\n`, `331 …\r\n`); a multi-line reply repeats the code with a '-' after the
|
|
9
|
+
* first line (`220-…\r\n…\r\n220 …\r\n`). The bulk data transfer runs on a separate dynamic-port
|
|
10
|
+
* connection which is out of scope — only the control channel on port 21 is claimed here (like TFTP,
|
|
11
|
+
* whose data channel is likewise not claimed).
|
|
12
|
+
*
|
|
13
|
+
* Like Syslog, SIP and HTTP, the message is text whose full internal structure (arbitrary arguments,
|
|
14
|
+
* significant whitespace, multi-line reply continuations) is richer than a form needs. So the ENTIRE
|
|
15
|
+
* raw message is kept verbatim as the authoritative `message` field (hex) and re-emitted untouched;
|
|
16
|
+
* only the first line is parsed on decode into display-only metadata (command/argument for a command,
|
|
17
|
+
* replyCode/replyText for a reply). Encode never reconstructs the message from the parsed fields — it
|
|
18
|
+
* writes `message` back byte-for-byte — so any conformant (or even malformed) FTP line round-trips
|
|
19
|
+
* exactly.
|
|
20
|
+
*
|
|
21
|
+
* Note: a single TCP segment may carry more than one control line (pipelined commands) or only part of
|
|
22
|
+
* a multi-line reply; reassembly across segments is out of scope. This single-segment codec keeps
|
|
23
|
+
* whatever bytes are present verbatim, which is byte-perfect for the single-packet case.
|
|
24
|
+
*/
|
|
25
|
+
export declare class FTP extends BaseHeader {
|
|
26
|
+
#private;
|
|
27
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly nickname: string;
|
|
31
|
+
readonly matchKeys: string[];
|
|
32
|
+
match(): boolean;
|
|
33
|
+
readonly demuxProducers: DemuxProducer[];
|
|
34
|
+
}
|