@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,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IPFIX = 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
|
+
* IPFIX — IP Flow Information Export (RFC 7011, also known as NetFlow v10), UDP port 4739. Every IPFIX
|
|
12
|
+
* Message begins with a fixed 16-byte Message Header (all big-endian) — Version (always 10), Length (the
|
|
13
|
+
* total message octet count including this header), Export Time, Sequence Number and Observation Domain
|
|
14
|
+
* ID — followed by one or more Sets. Each Set is a 4-byte header — Set ID (2 = Template Set, 3 = Options
|
|
15
|
+
* Template Set, >= 256 = a Data Set keyed by the Template ID) plus Set Length (the octet count of the
|
|
16
|
+
* whole Set including its 4-byte header) — followed by the Set records.
|
|
17
|
+
*
|
|
18
|
+
* The record layout of a Set is template-driven: a Data Set can only be parsed against the Template Set
|
|
19
|
+
* that defined its Template ID, which is cross-message, session-scoped state. So this single-message
|
|
20
|
+
* codec keeps each Set structured only down to {Set ID, Set Length, verbatim hex body} — byte-perfect —
|
|
21
|
+
* and does not sub-decode the records. The message Length is auto-computed on encode when not supplied,
|
|
22
|
+
* else honored verbatim (a crafted message may lie); each Set Length is honored verbatim, and the Sets
|
|
23
|
+
* walk is bounded by BOTH the message Length and the captured UDP payload, so trailing bytes are left to
|
|
24
|
+
* the codec's recursion / RawData. A well-formed message round-trips byte-for-byte.
|
|
25
|
+
*/
|
|
26
|
+
class IPFIX extends BaseHeader_1.BaseHeader {
|
|
27
|
+
constructor() {
|
|
28
|
+
super(...arguments);
|
|
29
|
+
this.id = 'ipfix';
|
|
30
|
+
this.name = 'IP Flow Information Export';
|
|
31
|
+
this.nickname = 'IPFIX';
|
|
32
|
+
this.matchKeys = ['udpport:4739'];
|
|
33
|
+
//A leaf header — Set records are template-driven and require cross-message, session-scoped state.
|
|
34
|
+
this.demuxProducers = [];
|
|
35
|
+
}
|
|
36
|
+
static #schemaCache;
|
|
37
|
+
get SCHEMA() {
|
|
38
|
+
return (IPFIX.#schemaCache ??= IPFIX.#buildSchema());
|
|
39
|
+
}
|
|
40
|
+
static #buildSchema() {
|
|
41
|
+
return {
|
|
42
|
+
type: 'object',
|
|
43
|
+
summary: 'IPFIX v${version} len=${length} domain=${observationDomainId}',
|
|
44
|
+
properties: {
|
|
45
|
+
//Version Number (RFC 7011 §3.1): always 10 for IPFIX. Kept as a plain uint16 (clamped in
|
|
46
|
+
//the closure, no hard enum) so a crafted non-10 value still round-trips byte-for-byte.
|
|
47
|
+
version: this.fieldUInt('version', 0, 2, 'Version'),
|
|
48
|
+
length: {
|
|
49
|
+
type: 'integer',
|
|
50
|
+
label: 'Length',
|
|
51
|
+
minimum: 0,
|
|
52
|
+
maximum: 65535,
|
|
53
|
+
decode: function () {
|
|
54
|
+
this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
|
|
55
|
+
},
|
|
56
|
+
encode: function () {
|
|
57
|
+
//Length counts the whole message = 16-byte header + all Sets. A supplied value is
|
|
58
|
+
//honored (a crafted message may lie); otherwise a placeholder is written now and
|
|
59
|
+
//the real total is filled in after every Set has encoded (post-self-encode).
|
|
60
|
+
const messageLength = this.instance.length.getValue(0);
|
|
61
|
+
if (messageLength) {
|
|
62
|
+
this.instance.length.setValue(messageLength);
|
|
63
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(messageLength));
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(0));
|
|
67
|
+
this.instance.length.setValue(0);
|
|
68
|
+
this.addPostSelfEncodeHandler(() => {
|
|
69
|
+
const total = this.length < 16 ? 16 : this.length;
|
|
70
|
+
const clamped = total > 65535 ? 65535 : total;
|
|
71
|
+
this.instance.length.setValue(clamped);
|
|
72
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(clamped));
|
|
73
|
+
}, 1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
exportTime: this.fieldUInt('exportTime', 4, 4, 'Export Time'),
|
|
78
|
+
sequenceNumber: this.fieldUInt('sequenceNumber', 8, 4, 'Sequence Number'),
|
|
79
|
+
observationDomainId: this.fieldUInt('observationDomainId', 12, 4, 'Observation Domain ID'),
|
|
80
|
+
sets: {
|
|
81
|
+
type: 'array',
|
|
82
|
+
label: 'Sets',
|
|
83
|
+
items: {
|
|
84
|
+
type: 'object',
|
|
85
|
+
label: 'Set',
|
|
86
|
+
properties: {
|
|
87
|
+
setId: { type: 'integer', label: 'Set ID', minimum: 0, maximum: 65535 },
|
|
88
|
+
setLength: { type: 'integer', label: 'Set Length', minimum: 0, maximum: 65535 },
|
|
89
|
+
body: { type: 'string', label: 'Body', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
decode: function () {
|
|
93
|
+
//Bound by BOTH the declared message Length AND the bytes actually present, so a
|
|
94
|
+
//lying Length cannot spawn phantom Sets past the end of the buffer. readBytes clamps
|
|
95
|
+
//at the buffer end; each Set consumes at least its 4-byte header so the loop always
|
|
96
|
+
//advances and cannot run forever.
|
|
97
|
+
const messageLength = this.instance.length.getValue(0);
|
|
98
|
+
const available = this.packet.length - this.startPos;
|
|
99
|
+
const end = Math.min(messageLength, available);
|
|
100
|
+
const sets = [];
|
|
101
|
+
let offset = 16;
|
|
102
|
+
while (offset + 4 <= end) {
|
|
103
|
+
const setId = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset, 2));
|
|
104
|
+
const setLength = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(offset + 2, 2));
|
|
105
|
+
offset += 4;
|
|
106
|
+
//Body = Set Length minus the 4-byte Set header, clamped to the remaining bytes
|
|
107
|
+
//so a lying/short Set Length never reads out of bounds.
|
|
108
|
+
let bodyLength = setLength - 4;
|
|
109
|
+
if (bodyLength < 0)
|
|
110
|
+
bodyLength = 0;
|
|
111
|
+
if (offset + bodyLength > end)
|
|
112
|
+
bodyLength = end - offset;
|
|
113
|
+
const body = bodyLength > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(offset, bodyLength)) : '';
|
|
114
|
+
offset += bodyLength;
|
|
115
|
+
sets.push({ setId: setId, setLength: setLength, body: body });
|
|
116
|
+
}
|
|
117
|
+
this.instance.sets.setValue(sets);
|
|
118
|
+
},
|
|
119
|
+
encode: function () {
|
|
120
|
+
const sets = this.instance.sets.getValue();
|
|
121
|
+
if (!sets)
|
|
122
|
+
return;
|
|
123
|
+
let offset = 16;
|
|
124
|
+
sets.forEach((set) => {
|
|
125
|
+
const setId = set.setId ? set.setId : 0;
|
|
126
|
+
const body = (0, HexToBuffer_1.HexToBuffer)(set.body ? set.body : '');
|
|
127
|
+
//Set Length counts the 4-byte Set header + body. Honored when supplied (a
|
|
128
|
+
//crafted Set may lie); else derived from the body.
|
|
129
|
+
const setLength = (set.setLength !== undefined && set.setLength !== null)
|
|
130
|
+
? set.setLength
|
|
131
|
+
: 4 + body.length;
|
|
132
|
+
this.writeBytes(offset, (0, NumberToBuffer_1.UInt16ToBuffer)(setId > 65535 ? 65535 : setId));
|
|
133
|
+
this.writeBytes(offset + 2, (0, NumberToBuffer_1.UInt16ToBuffer)(setLength > 65535 ? 65535 : setLength));
|
|
134
|
+
offset += 4;
|
|
135
|
+
if (body.length) {
|
|
136
|
+
this.writeBytes(offset, body);
|
|
137
|
+
offset += body.length;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
match() {
|
|
146
|
+
//IPFIX rides on UDP port 4739. The header carries no strong content magic beyond the Version
|
|
147
|
+
//field, so selection stays port-bucketed (matchKeys) and additionally requires the full 16-byte
|
|
148
|
+
//Message Header and Version == 10 so non-IPFIX 4739 traffic falls through to raw.
|
|
149
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'udp')
|
|
150
|
+
return false;
|
|
151
|
+
if (this.packet.length - this.startPos < 16)
|
|
152
|
+
return false;
|
|
153
|
+
return (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(0, 2, true)) === 10;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.IPFIX = IPFIX;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
2
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
export declare class IPv4 extends BaseHeader {
|
|
5
|
+
#private;
|
|
6
|
+
/**
|
|
7
|
+
* Calculate IPv4 header checksum
|
|
8
|
+
* @param headerBuffer
|
|
9
|
+
* @protected
|
|
10
|
+
*/
|
|
11
|
+
protected calculateIPv4Checksum(headerBuffer: Buffer): number;
|
|
12
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly matchKeys: string[];
|
|
15
|
+
readonly heuristicFallback: boolean;
|
|
16
|
+
readonly demuxProducers: DemuxProducer[];
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly nickname: string;
|
|
19
|
+
match(): boolean;
|
|
20
|
+
}
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IPv4 = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const NumberToHex_1 = require("../helper/NumberToHex");
|
|
6
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
7
|
+
const BufferToNumber_1 = require("../helper/BufferToNumber");
|
|
8
|
+
const NumberToBuffer_1 = require("../helper/NumberToBuffer");
|
|
9
|
+
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
10
|
+
const IPToBuffer_1 = require("../helper/IPToBuffer");
|
|
11
|
+
const BufferToIP_1 = require("../helper/BufferToIP");
|
|
12
|
+
const HexToBuffer_1 = require("../helper/HexToBuffer");
|
|
13
|
+
class IPv4 extends BaseHeader_1.BaseHeader {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.id = 'ipv4';
|
|
17
|
+
this.matchKeys = ['ethertype:0800'];
|
|
18
|
+
//Also in the heuristic chain so IPv4 can be recognized as the inner payload of a bare-IP tunnel
|
|
19
|
+
//(GTP-U G-PDU), which carries no inner-protocol field. The etherType path below still handles the
|
|
20
|
+
//normal ethertype:0800 bucket, so ethernet-parented IPv4 is byte-identical to before.
|
|
21
|
+
this.heuristicFallback = true;
|
|
22
|
+
this.demuxProducers = [{ field: 'protocol', namespace: 'ipproto', kind: 'uint' }];
|
|
23
|
+
this.name = 'Internet Protocol Version 4';
|
|
24
|
+
this.nickname = 'IPv4';
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Calculate IPv4 header checksum
|
|
28
|
+
* @param headerBuffer
|
|
29
|
+
* @protected
|
|
30
|
+
*/
|
|
31
|
+
calculateIPv4Checksum(headerBuffer) {
|
|
32
|
+
const header = Uint8Array.from(headerBuffer);
|
|
33
|
+
let sum = 0;
|
|
34
|
+
for (let i = 0; i < header.length; i += 2) {
|
|
35
|
+
const word = (header[i] << 8) + (header[i + 1] || 0);
|
|
36
|
+
sum += word;
|
|
37
|
+
}
|
|
38
|
+
while (sum >>> 16) {
|
|
39
|
+
sum = (sum & 0xFFFF) + (sum >>> 16);
|
|
40
|
+
}
|
|
41
|
+
return (~sum) & 0xFFFF;
|
|
42
|
+
}
|
|
43
|
+
static #schemaCache;
|
|
44
|
+
//SCHEMA is built once per class and cached (④ prototype). Its field closures are plain functions
|
|
45
|
+
//that take `this` dynamically — BaseHeader invokes each via .call(this) — so they capture no
|
|
46
|
+
//instance and the whole structure is shareable, avoiding a full per-packet rebuild. Inner callbacks
|
|
47
|
+
//(post-handlers, getValue callbacks) are arrows created when the function runs, capturing that
|
|
48
|
+
//call's `this`, so caching does not cross-wire instances. Unmigrated headers still initialise
|
|
49
|
+
//SCHEMA as an instance field.
|
|
50
|
+
get SCHEMA() {
|
|
51
|
+
return (IPv4.#schemaCache ??= IPv4.#buildSchema());
|
|
52
|
+
}
|
|
53
|
+
static #buildSchema() {
|
|
54
|
+
return {
|
|
55
|
+
type: 'object',
|
|
56
|
+
summary: '${sip} → ${dip}',
|
|
57
|
+
properties: {
|
|
58
|
+
version: {
|
|
59
|
+
type: 'integer',
|
|
60
|
+
label: 'Version',
|
|
61
|
+
minimum: 0,
|
|
62
|
+
maximum: 15,
|
|
63
|
+
decode: function () {
|
|
64
|
+
this.instance.version.setValue(this.readBits(0, 1, 0, 4));
|
|
65
|
+
if (this.instance.version.getValue() !== 4)
|
|
66
|
+
this.recordError(this.instance.version.getPath(), 'IPv4 version should be 4');
|
|
67
|
+
},
|
|
68
|
+
encode: function () {
|
|
69
|
+
let version = this.instance.version.getValue(4);
|
|
70
|
+
version = version > 15 ? 15 : version;
|
|
71
|
+
version = version < 0 ? 0 : version;
|
|
72
|
+
if (version !== 4)
|
|
73
|
+
this.recordError(this.instance.version.getPath(), 'IPv4 version should be 4');
|
|
74
|
+
this.instance.version.setValue(version);
|
|
75
|
+
this.writeBits(0, 1, 0, 4, version);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
hdrLen: {
|
|
79
|
+
type: 'integer',
|
|
80
|
+
label: 'Header Length',
|
|
81
|
+
minimum: 20,
|
|
82
|
+
maximum: 60,
|
|
83
|
+
decode: function () {
|
|
84
|
+
this.instance.hdrLen.setValue(this.readBits(0, 1, 4, 4) * 4);
|
|
85
|
+
},
|
|
86
|
+
encode: function () {
|
|
87
|
+
let headerLength = this.instance.hdrLen.getValue(0);
|
|
88
|
+
if (headerLength)
|
|
89
|
+
headerLength = headerLength ? Math.floor(headerLength / 4) : 0;
|
|
90
|
+
this.writeBits(0, 1, 4, 4, headerLength);
|
|
91
|
+
if (!headerLength)
|
|
92
|
+
this.addPostSelfEncodeHandler(() => {
|
|
93
|
+
this.instance.hdrLen.setValue(this.length);
|
|
94
|
+
this.writeBits(0, 1, 4, 4, Math.floor(this.length / 4));
|
|
95
|
+
}, 10);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
dsfield: {
|
|
99
|
+
type: 'object',
|
|
100
|
+
label: 'Differentiated Services Field',
|
|
101
|
+
properties: {
|
|
102
|
+
dscp: {
|
|
103
|
+
type: 'integer',
|
|
104
|
+
minimum: 0,
|
|
105
|
+
maximum: 63,
|
|
106
|
+
label: 'Differentiated Services Codepoint',
|
|
107
|
+
decode: function () {
|
|
108
|
+
this.instance.dsfield.dscp.setValue(this.readBits(1, 1, 0, 6));
|
|
109
|
+
},
|
|
110
|
+
encode: function () {
|
|
111
|
+
const dscp = this.instance.dsfield.dscp.getValue(0);
|
|
112
|
+
this.instance.dsfield.dscp.setValue(dscp);
|
|
113
|
+
this.writeBits(1, 1, 0, 6, dscp);
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
ecn: {
|
|
117
|
+
type: 'integer',
|
|
118
|
+
label: 'Explicit Congestion Notification',
|
|
119
|
+
decode: function () {
|
|
120
|
+
this.instance.dsfield.ecn.setValue(this.readBits(1, 1, 6, 2));
|
|
121
|
+
},
|
|
122
|
+
encode: function () {
|
|
123
|
+
const ecn = this.instance.dsfield.ecn.getValue(0);
|
|
124
|
+
this.instance.dsfield.ecn.setValue(ecn);
|
|
125
|
+
this.writeBits(1, 1, 6, 2, ecn);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
length: {
|
|
131
|
+
type: 'integer',
|
|
132
|
+
label: 'Total Length',
|
|
133
|
+
minimum: 0,
|
|
134
|
+
maximum: 65535,
|
|
135
|
+
decode: function () {
|
|
136
|
+
this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
|
|
137
|
+
},
|
|
138
|
+
encode: function () {
|
|
139
|
+
//This field's real value needs down stream codec invoke recode to fill
|
|
140
|
+
const length = this.instance.length.getValue(0);
|
|
141
|
+
if (length) {
|
|
142
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(length));
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(length));
|
|
146
|
+
this.addPostPacketEncodeHandler(() => {
|
|
147
|
+
let startCount = false;
|
|
148
|
+
let totalLength = 0;
|
|
149
|
+
this.codecModules.forEach((codecModule) => {
|
|
150
|
+
if (codecModule === this)
|
|
151
|
+
startCount = true;
|
|
152
|
+
if (startCount)
|
|
153
|
+
totalLength += codecModule.length;
|
|
154
|
+
});
|
|
155
|
+
this.instance.length.setValue(totalLength);
|
|
156
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(totalLength));
|
|
157
|
+
}, 1);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
id: {
|
|
162
|
+
type: 'integer',
|
|
163
|
+
label: 'Identification',
|
|
164
|
+
minimum: 0,
|
|
165
|
+
maximum: 65535,
|
|
166
|
+
decode: function () {
|
|
167
|
+
this.instance.id.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(4, 2)));
|
|
168
|
+
},
|
|
169
|
+
encode: function () {
|
|
170
|
+
const id = this.instance.id.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
171
|
+
this.instance.id.setValue(id);
|
|
172
|
+
this.writeBytes(4, (0, NumberToBuffer_1.UInt16ToBuffer)(id));
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
flags: {
|
|
176
|
+
type: 'object',
|
|
177
|
+
label: 'Flags',
|
|
178
|
+
properties: {
|
|
179
|
+
rb: {
|
|
180
|
+
type: 'integer',
|
|
181
|
+
enum: [0, 1],
|
|
182
|
+
label: 'Reserved bit',
|
|
183
|
+
decode: function () {
|
|
184
|
+
this.instance.flags.rb.setValue(this.readBits(6, 1, 0, 1));
|
|
185
|
+
},
|
|
186
|
+
encode: function () {
|
|
187
|
+
const rb = this.instance.flags.rb.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
188
|
+
this.instance.flags.rb.setValue(rb);
|
|
189
|
+
this.writeBits(6, 1, 0, 1, rb);
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
df: {
|
|
193
|
+
type: 'integer',
|
|
194
|
+
enum: [0, 1],
|
|
195
|
+
label: 'Don\'t fragment',
|
|
196
|
+
decode: function () {
|
|
197
|
+
this.instance.flags.df.setValue(this.readBits(6, 1, 1, 1));
|
|
198
|
+
},
|
|
199
|
+
encode: function () {
|
|
200
|
+
const df = this.instance.flags.df.getValue(1, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
201
|
+
this.instance.flags.df.setValue(df);
|
|
202
|
+
this.writeBits(6, 1, 1, 1, df);
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
mf: {
|
|
206
|
+
type: 'integer',
|
|
207
|
+
enum: [0, 1],
|
|
208
|
+
label: 'More fragments',
|
|
209
|
+
decode: function () {
|
|
210
|
+
this.instance.flags.mf.setValue(this.readBits(6, 1, 2, 1));
|
|
211
|
+
},
|
|
212
|
+
encode: function () {
|
|
213
|
+
const mf = this.instance.flags.mf.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
214
|
+
this.instance.flags.mf.setValue(mf);
|
|
215
|
+
this.writeBits(6, 1, 2, 1, mf);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
fragOffset: {
|
|
221
|
+
type: 'integer',
|
|
222
|
+
minimum: 0,
|
|
223
|
+
maximum: 8191,
|
|
224
|
+
label: 'Fragment Offset',
|
|
225
|
+
decode: function () {
|
|
226
|
+
this.instance.fragOffset.setValue(this.readBits(6, 2, 3, 13));
|
|
227
|
+
},
|
|
228
|
+
encode: function () {
|
|
229
|
+
const fragOffset = this.instance.fragOffset.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
230
|
+
this.instance.fragOffset.setValue(fragOffset);
|
|
231
|
+
this.writeBits(6, 2, 3, 13, fragOffset);
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
ttl: {
|
|
235
|
+
type: 'integer',
|
|
236
|
+
minimum: 0,
|
|
237
|
+
maximum: 255,
|
|
238
|
+
label: 'Time to Live',
|
|
239
|
+
decode: function () {
|
|
240
|
+
this.instance.ttl.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(8, 1)));
|
|
241
|
+
},
|
|
242
|
+
encode: function () {
|
|
243
|
+
const ttl = this.instance.ttl.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
244
|
+
this.instance.ttl.setValue(ttl);
|
|
245
|
+
this.writeBytes(8, (0, NumberToBuffer_1.UInt8ToBuffer)(ttl));
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
protocol: {
|
|
249
|
+
type: 'integer',
|
|
250
|
+
label: 'Protocol',
|
|
251
|
+
minimum: 0,
|
|
252
|
+
maximum: 255,
|
|
253
|
+
decode: function () {
|
|
254
|
+
this.instance.protocol.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(9, 1)));
|
|
255
|
+
},
|
|
256
|
+
encode: function () {
|
|
257
|
+
const protocol = this.instance.protocol.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
258
|
+
this.instance.protocol.setValue(protocol);
|
|
259
|
+
this.writeBytes(9, (0, NumberToBuffer_1.UInt8ToBuffer)(protocol));
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
checksum: {
|
|
263
|
+
type: 'integer',
|
|
264
|
+
label: 'Header Checksum',
|
|
265
|
+
minimum: 0,
|
|
266
|
+
maximum: 65535,
|
|
267
|
+
decode: function () {
|
|
268
|
+
this.instance.checksum.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(10, 2)));
|
|
269
|
+
},
|
|
270
|
+
encode: function () {
|
|
271
|
+
let checksum = this.instance.checksum.getValue(0);
|
|
272
|
+
checksum = checksum > 65535 ? 65535 : checksum;
|
|
273
|
+
checksum = checksum < 0 ? 0 : checksum;
|
|
274
|
+
if (checksum) {
|
|
275
|
+
this.instance.checksum.setValue(checksum);
|
|
276
|
+
this.writeBytes(10, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
this.instance.checksum.setValue(checksum);
|
|
280
|
+
this.writeBytes(10, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
281
|
+
this.addPostPacketEncodeHandler(() => {
|
|
282
|
+
const calcChecksum = this.calculateIPv4Checksum(this.packet.subarray(this.startPos, this.endPos));
|
|
283
|
+
this.instance.checksum.setValue(calcChecksum);
|
|
284
|
+
this.writeBytes(10, (0, NumberToBuffer_1.UInt16ToBuffer)(calcChecksum));
|
|
285
|
+
}, 2);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
sip: {
|
|
290
|
+
type: 'string',
|
|
291
|
+
label: 'Source Address',
|
|
292
|
+
minLength: 7,
|
|
293
|
+
maxLength: 15,
|
|
294
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.IPv4,
|
|
295
|
+
decode: function () {
|
|
296
|
+
const sipBuffer = this.readBytes(12, 4);
|
|
297
|
+
this.instance.sip.setValue((0, BufferToIP_1.BufferToIPv4)(sipBuffer));
|
|
298
|
+
},
|
|
299
|
+
encode: function () {
|
|
300
|
+
const sipStr = this.instance.sip.getValue('0.0.0.0', (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
301
|
+
this.instance.sip.setValue(sipStr);
|
|
302
|
+
this.writeBytes(12, (0, IPToBuffer_1.IPv4ToBuffer)(sipStr));
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
dip: {
|
|
306
|
+
type: 'string',
|
|
307
|
+
minLength: 7,
|
|
308
|
+
maxLength: 15,
|
|
309
|
+
label: 'Destination Address',
|
|
310
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.IPv4,
|
|
311
|
+
decode: function () {
|
|
312
|
+
const dipBuffer = this.readBytes(16, 4);
|
|
313
|
+
this.instance.dip.setValue((0, BufferToIP_1.BufferToIPv4)(dipBuffer));
|
|
314
|
+
},
|
|
315
|
+
encode: function () {
|
|
316
|
+
const dipStr = this.instance.dip.getValue('0.0.0.0', (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
317
|
+
this.instance.dip.setValue(dipStr);
|
|
318
|
+
this.writeBytes(16, (0, IPToBuffer_1.IPv4ToBuffer)(dipStr));
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
options: {
|
|
322
|
+
type: 'string',
|
|
323
|
+
label: 'Options',
|
|
324
|
+
minLength: 0,
|
|
325
|
+
maxLength: 40 * 2,
|
|
326
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
327
|
+
decode: function () {
|
|
328
|
+
if (this.length < (this.instance.hdrLen.getValue())) {
|
|
329
|
+
this.instance.options.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(this.length, (this.instance.hdrLen.getValue()) - this.length)));
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
encode: function () {
|
|
333
|
+
if (!this.instance.options.isUndefined()) {
|
|
334
|
+
let optionsBuffer = (0, HexToBuffer_1.HexToBuffer)(this.instance.options.getValue(''));
|
|
335
|
+
if (optionsBuffer.length > 40)
|
|
336
|
+
optionsBuffer = optionsBuffer.subarray(0, 40);
|
|
337
|
+
const estimateHdrLen = this.length + optionsBuffer.length;
|
|
338
|
+
if (estimateHdrLen % 4) {
|
|
339
|
+
/**
|
|
340
|
+
* IPv4 Header should have a length that a multiple of 32 bits
|
|
341
|
+
* @see https://learningnetwork.cisco.com/s/question/0D53i00000Kt6hHCAR/padding-field-on-ipv4-header
|
|
342
|
+
*/
|
|
343
|
+
optionsBuffer = Buffer.concat([optionsBuffer, Buffer.alloc((4 - estimateHdrLen % 4) % 4, 0)]);
|
|
344
|
+
}
|
|
345
|
+
this.writeBytes(this.length, optionsBuffer);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
match() {
|
|
353
|
+
if (!this.prevCodecModule)
|
|
354
|
+
return false;
|
|
355
|
+
//Normal path (unchanged): a parent that demuxed to IPv4 via its etherType field.
|
|
356
|
+
if (this.prevCodecModule.instance.etherType.getValue() === (0, NumberToHex_1.UInt16ToHex)(0x0800))
|
|
357
|
+
return true;
|
|
358
|
+
//Bare-IP tunnel path: GTP-U (and future discriminator-less IP tunnels) carry no inner-protocol
|
|
359
|
+
//field, so match by the IPv4 version nibble. The tunnel-parent id gate MUST come first — a 4-bit
|
|
360
|
+
//nibble alone is too weak a signature (many TCP/TLS payloads begin 0x4x).
|
|
361
|
+
if (['gtp'].includes(this.prevCodecModule.id) && (this.readBytes(0, 1, true)[0] >> 4) === 4)
|
|
362
|
+
return true;
|
|
363
|
+
//Typed-tunnel path: GENEVE/GRE carry a Protocol Type (an EtherType), so trust that self-describing
|
|
364
|
+
//field rather than the weak version nibble — the ethertype demux already routed us here.
|
|
365
|
+
if ((this.prevCodecModule.id === 'geneve' || this.prevCodecModule.id === 'gre') && this.prevCodecModule.instance.protocolType.getValue() === (0, NumberToHex_1.UInt16ToHex)(0x0800))
|
|
366
|
+
return true;
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
exports.IPv4 = IPv4;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
2
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* IPv6 — Internet Protocol version 6 (RFC 8200), carried on Ethernet with EtherType 0x86dd. This codec
|
|
6
|
+
* decodes the 40-octet fixed header: a 4-bit Version (`version`, offset 0), an 8-bit Traffic Class split
|
|
7
|
+
* into a 6-bit DSCP (`tclass.dscp`) and 2-bit ECN (`tclass.ecn`), a 20-bit Flow Label (`flow`), a 16-bit
|
|
8
|
+
* Payload Length (`plen`, offset 4), an 8-bit Next Header (`nxt`, offset 6), an 8-bit Hop Limit (`hllm`,
|
|
9
|
+
* offset 7), and the 16-octet Source (`sip`, offset 8) and Destination (`dip`, offset 24) addresses. It
|
|
10
|
+
* stops at the fixed header: `nxt` is published as an `ipproto` demux key, so extension headers and the
|
|
11
|
+
* upper-layer protocol (TCP/UDP/ICMPv6/OSPF…) are decoded by the next module.
|
|
12
|
+
*
|
|
13
|
+
* Payload Length is honor-else-derive: a supplied value is written as-is, but when it is 0 on encode a
|
|
14
|
+
* post-packet-encode handler sums the byte length of this header and everything after it, subtracts the
|
|
15
|
+
* 40-octet header, and writes the result (falling back to 0 when it exceeds 65535, as a Hop-by-Hop Jumbo
|
|
16
|
+
* Payload would). match() accepts the normal `ethertype:86dd` path, and — being in the heuristic chain —
|
|
17
|
+
* also an IPv6 payload inside a bare-IP GTP-U tunnel (parent id `gtp` with a version nibble of 6) or a
|
|
18
|
+
* GENEVE/GRE tunnel whose Protocol Type is 0x86dd.
|
|
19
|
+
*/
|
|
20
|
+
export declare class IPv6 extends BaseHeader {
|
|
21
|
+
SCHEMA: ProtocolJSONSchema;
|
|
22
|
+
id: string;
|
|
23
|
+
readonly matchKeys: string[];
|
|
24
|
+
readonly heuristicFallback: boolean;
|
|
25
|
+
readonly demuxProducers: DemuxProducer[];
|
|
26
|
+
name: string;
|
|
27
|
+
nickname: string;
|
|
28
|
+
match(): boolean;
|
|
29
|
+
}
|