@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,905 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TCP = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const BufferToNumber_1 = require("../helper/BufferToNumber");
|
|
6
|
+
const NumberToBuffer_1 = require("../helper/NumberToBuffer");
|
|
7
|
+
const IPToBuffer_1 = require("../helper/IPToBuffer");
|
|
8
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
9
|
+
const NumberToHex_1 = require("../helper/NumberToHex");
|
|
10
|
+
const HexToNumber_1 = require("../helper/HexToNumber");
|
|
11
|
+
var TCPOption;
|
|
12
|
+
(function (TCPOption) {
|
|
13
|
+
TCPOption["End_of_Option_List"] = "EOL";
|
|
14
|
+
TCPOption["No_Operation"] = "NOP";
|
|
15
|
+
TCPOption["Maximum_Segment_Size"] = "MSS";
|
|
16
|
+
TCPOption["Window_Scale"] = "Window-Scale";
|
|
17
|
+
TCPOption["Selective_Acknowledgment_Permitted"] = "SACK-Permitted";
|
|
18
|
+
TCPOption["Selective_Acknowledgment"] = "SACK";
|
|
19
|
+
TCPOption["Timestamp"] = "TS";
|
|
20
|
+
TCPOption["User_Timeout"] = "UTO";
|
|
21
|
+
TCPOption["TCP_Authentication_Option"] = "TCP-AO";
|
|
22
|
+
})(TCPOption || (TCPOption = {}));
|
|
23
|
+
class TCP extends BaseHeader_1.BaseHeader {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
this.id = 'tcp';
|
|
27
|
+
this.matchKeys = ['ipproto:6'];
|
|
28
|
+
//Produces a port demux key from BOTH ports (a protocol's well-known port may be src or dst).
|
|
29
|
+
this.demuxProducers = [
|
|
30
|
+
{ field: 'dstport', namespace: 'tcpport', kind: 'uint' },
|
|
31
|
+
{ field: 'srcport', namespace: 'tcpport', kind: 'uint' }
|
|
32
|
+
];
|
|
33
|
+
this.name = 'Transmission Control Protocol';
|
|
34
|
+
this.nickname = 'TCP';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Calculate TCP Checksum
|
|
38
|
+
* @param tcpHeaderBuffer
|
|
39
|
+
* @protected
|
|
40
|
+
*/
|
|
41
|
+
calculateTCPChecksum(tcpHeaderBuffer) {
|
|
42
|
+
const tcpHeaderLength = tcpHeaderBuffer.length;
|
|
43
|
+
//The checksum needs the IP pseudo-header from the layer below. Building a malformed
|
|
44
|
+
//stack (e.g. TCP with no IP beneath) is a legitimate use case, so record an error and
|
|
45
|
+
//skip the checksum rather than dereferencing a missing previous layer and throwing.
|
|
46
|
+
if (!this.prevCodecModule) {
|
|
47
|
+
this.recordError(this.instance.checksum.getPath(), 'Cannot compute TCP checksum: no IP layer beneath TCP');
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
const ipVersion = this.prevCodecModule.instance.version.getValue();
|
|
51
|
+
let pseudoHeaderBuffer = Buffer.from([]);
|
|
52
|
+
const sourceIp = this.prevCodecModule.instance.sip.getValue();
|
|
53
|
+
const destinationIp = this.prevCodecModule.instance.dip.getValue();
|
|
54
|
+
if (ipVersion === 4) {
|
|
55
|
+
//4 Bytes
|
|
56
|
+
const sourceIPv4Buffer = Buffer.from(sourceIp.split('.').map((value) => parseInt(value)));
|
|
57
|
+
const destinationIPv4Buffer = Buffer.from(destinationIp.split('.').map((value) => parseInt(value)));
|
|
58
|
+
//IPv4 Pseudo header
|
|
59
|
+
pseudoHeaderBuffer = Buffer.concat([
|
|
60
|
+
sourceIPv4Buffer,
|
|
61
|
+
destinationIPv4Buffer,
|
|
62
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(0), //Reserved field
|
|
63
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(6), //Protocol type (TCP = 6)
|
|
64
|
+
Buffer.from([(tcpHeaderLength >> 8) & 0xFF]),
|
|
65
|
+
Buffer.from([tcpHeaderLength & 0xFF])
|
|
66
|
+
]);
|
|
67
|
+
}
|
|
68
|
+
else if (ipVersion === 6) {
|
|
69
|
+
//16 Bytes
|
|
70
|
+
const sourceIPv6Buffer = (0, IPToBuffer_1.IPv6ToBuffer)(sourceIp);
|
|
71
|
+
const destinationIPv6Buffer = (0, IPToBuffer_1.IPv6ToBuffer)(destinationIp);
|
|
72
|
+
//IPv6 Pseudo header
|
|
73
|
+
pseudoHeaderBuffer = Buffer.concat([
|
|
74
|
+
sourceIPv6Buffer,
|
|
75
|
+
destinationIPv6Buffer,
|
|
76
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(0), //Reserved field
|
|
77
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(0), //Reserved field
|
|
78
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(0), //Reserved field
|
|
79
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(6), //Protocol type (TCP = 6)
|
|
80
|
+
Buffer.from([(tcpHeaderLength >> 8) & 0xFF]),
|
|
81
|
+
Buffer.from([tcpHeaderLength & 0xFF])
|
|
82
|
+
]);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
const dataBuffer = Buffer.concat([pseudoHeaderBuffer, tcpHeaderBuffer]);
|
|
88
|
+
const data = Uint8Array.from(dataBuffer);
|
|
89
|
+
let sum = 0;
|
|
90
|
+
for (let i = 0; i < data.length; i += 2)
|
|
91
|
+
sum += (data[i] << 8) + (data[i + 1] || 0);
|
|
92
|
+
while (sum >>> 16)
|
|
93
|
+
sum = (sum & 0xFFFF) + (sum >>> 16);
|
|
94
|
+
return (~sum) & 0xFFFF;
|
|
95
|
+
}
|
|
96
|
+
static #schemaCache;
|
|
97
|
+
//Class-cached SCHEMA (④): field closures are functions taking dynamic `this` via .call(this).
|
|
98
|
+
//fieldUInt is a static factory, so `this.fieldUInt` below resolves against the class.
|
|
99
|
+
get SCHEMA() {
|
|
100
|
+
return (TCP.#schemaCache ??= TCP.#buildSchema());
|
|
101
|
+
}
|
|
102
|
+
static #buildSchema() {
|
|
103
|
+
return {
|
|
104
|
+
type: 'object',
|
|
105
|
+
summary: '${srcport} → ${dstport} Seq=${seq} Ack=${ack} Win=${window}',
|
|
106
|
+
properties: {
|
|
107
|
+
//Migrated to the declarative field building block (byte-identical; golden/round-trip unchanged).
|
|
108
|
+
srcport: this.fieldUInt('srcport', 0, 2, 'Source Port'),
|
|
109
|
+
dstport: this.fieldUInt('dstport', 2, 2, 'Destination Port'),
|
|
110
|
+
seq: {
|
|
111
|
+
type: 'integer',
|
|
112
|
+
label: 'Sequence Number',
|
|
113
|
+
minimum: 0,
|
|
114
|
+
maximum: 4294967295,
|
|
115
|
+
decode: function () {
|
|
116
|
+
this.instance.seq.setValue((0, BufferToNumber_1.BufferToUInt32)(this.readBytes(4, 4)));
|
|
117
|
+
},
|
|
118
|
+
encode: function () {
|
|
119
|
+
let seqNum = this.instance.seq.getValue(0);
|
|
120
|
+
if (seqNum > 4294967295) {
|
|
121
|
+
this.recordError(this.instance.seq.getPath(), 'Maximum value is 4294967295');
|
|
122
|
+
seqNum = 4294967295;
|
|
123
|
+
}
|
|
124
|
+
if (seqNum < 0) {
|
|
125
|
+
this.recordError(this.instance.seq.getPath(), 'Minimum value is 0');
|
|
126
|
+
seqNum = 0;
|
|
127
|
+
}
|
|
128
|
+
this.instance.seq.setValue(seqNum);
|
|
129
|
+
this.writeBytes(4, (0, NumberToBuffer_1.UInt32ToBuffer)(seqNum));
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
ack: {
|
|
133
|
+
type: 'integer',
|
|
134
|
+
label: 'Acknowledgment Number',
|
|
135
|
+
minimum: 0,
|
|
136
|
+
maximum: 4294967295,
|
|
137
|
+
decode: function () {
|
|
138
|
+
this.instance.ack.setValue((0, BufferToNumber_1.BufferToUInt32)(this.readBytes(8, 4)));
|
|
139
|
+
},
|
|
140
|
+
encode: function () {
|
|
141
|
+
let ackNum = this.instance.ack.getValue(0);
|
|
142
|
+
if (ackNum > 4294967295) {
|
|
143
|
+
this.recordError(this.instance.ack.getPath(), 'Maximum value is 4294967295');
|
|
144
|
+
ackNum = 4294967295;
|
|
145
|
+
}
|
|
146
|
+
if (ackNum < 0) {
|
|
147
|
+
this.recordError(this.instance.ack.getPath(), 'Minimum value is 0');
|
|
148
|
+
ackNum = 0;
|
|
149
|
+
}
|
|
150
|
+
this.instance.ack.setValue(ackNum);
|
|
151
|
+
this.writeBytes(8, (0, NumberToBuffer_1.UInt32ToBuffer)(ackNum));
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
hdrLen: {
|
|
155
|
+
type: 'integer',
|
|
156
|
+
label: 'Header Length',
|
|
157
|
+
minimum: 0,
|
|
158
|
+
maximum: 60,
|
|
159
|
+
decode: function () {
|
|
160
|
+
this.instance.hdrLen.setValue(this.readBits(12, 1, 0, 4) * 4);
|
|
161
|
+
},
|
|
162
|
+
encode: function () {
|
|
163
|
+
const hdrLen = this.instance.hdrLen.getValue(0);
|
|
164
|
+
if (hdrLen) {
|
|
165
|
+
this.instance.hdrLen.setValue(hdrLen);
|
|
166
|
+
this.writeBits(12, 1, 0, 4, hdrLen ? Math.floor(hdrLen / 4) : 0);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
this.addPostSelfEncodeHandler(() => {
|
|
170
|
+
this.instance.hdrLen.setValue(Math.floor(this.length / 4) * 4);
|
|
171
|
+
this.writeBits(12, 1, 0, 4, Math.floor(this.length / 4));
|
|
172
|
+
}, 1);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
flags: {
|
|
177
|
+
type: 'object',
|
|
178
|
+
label: 'Flags',
|
|
179
|
+
properties: {
|
|
180
|
+
res: {
|
|
181
|
+
type: 'integer',
|
|
182
|
+
label: 'Reserved',
|
|
183
|
+
minimum: 0,
|
|
184
|
+
maximum: 7,
|
|
185
|
+
decode: function () {
|
|
186
|
+
this.instance.flags.res.setValue(this.readBits(12, 1, 4, 3));
|
|
187
|
+
},
|
|
188
|
+
encode: function () {
|
|
189
|
+
let reserved = this.instance.flags.res.getValue(0);
|
|
190
|
+
if (reserved > 7) {
|
|
191
|
+
this.recordError(this.instance.flags.res.getPath(), 'Maximum value is 7');
|
|
192
|
+
reserved = 7;
|
|
193
|
+
}
|
|
194
|
+
if (reserved < 0) {
|
|
195
|
+
this.recordError(this.instance.flags.res.getPath(), 'Minimum value is 0');
|
|
196
|
+
reserved = 0;
|
|
197
|
+
}
|
|
198
|
+
this.instance.flags.res.setValue(reserved);
|
|
199
|
+
this.writeBits(12, 1, 4, 3, reserved);
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
ae: {
|
|
203
|
+
type: 'boolean',
|
|
204
|
+
label: 'Accurate ECN',
|
|
205
|
+
decode: function () {
|
|
206
|
+
this.instance.flags.ae.setValue(!!this.readBits(12, 1, 7, 1));
|
|
207
|
+
},
|
|
208
|
+
encode: function () {
|
|
209
|
+
const accurateECN = !!this.instance.flags.ae.getValue();
|
|
210
|
+
this.instance.flags.ae.setValue(accurateECN);
|
|
211
|
+
this.writeBits(12, 1, 7, 1, accurateECN ? 1 : 0);
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
cwr: {
|
|
215
|
+
type: 'boolean',
|
|
216
|
+
label: 'Congestion Window Reduced',
|
|
217
|
+
decode: function () {
|
|
218
|
+
this.instance.flags.cwr.setValue(!!this.readBits(13, 1, 0, 1));
|
|
219
|
+
},
|
|
220
|
+
encode: function () {
|
|
221
|
+
const congestionWindowReduced = !!this.instance.flags.cwr.getValue();
|
|
222
|
+
this.instance.flags.cwr.setValue(congestionWindowReduced);
|
|
223
|
+
this.writeBits(13, 1, 0, 1, congestionWindowReduced ? 1 : 0);
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
ece: {
|
|
227
|
+
type: 'boolean',
|
|
228
|
+
label: 'ECN-Echo',
|
|
229
|
+
decode: function () {
|
|
230
|
+
this.instance.flags.ece.setValue(!!this.readBits(13, 1, 1, 1));
|
|
231
|
+
},
|
|
232
|
+
encode: function () {
|
|
233
|
+
const ECNEcho = !!this.instance.flags.ece.getValue();
|
|
234
|
+
this.instance.flags.ece.setValue(ECNEcho);
|
|
235
|
+
this.writeBits(13, 1, 1, 1, ECNEcho ? 1 : 0);
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
urg: {
|
|
239
|
+
type: 'boolean',
|
|
240
|
+
label: 'Urgent',
|
|
241
|
+
decode: function () {
|
|
242
|
+
this.instance.flags.urg.setValue(!!this.readBits(13, 1, 2, 1));
|
|
243
|
+
},
|
|
244
|
+
encode: function () {
|
|
245
|
+
const urgent = !!this.instance.flags.urg.getValue();
|
|
246
|
+
this.instance.flags.urg.setValue(urgent);
|
|
247
|
+
this.writeBits(13, 1, 2, 1, urgent ? 1 : 0);
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
ack: {
|
|
251
|
+
type: 'boolean',
|
|
252
|
+
label: 'Acknowledgment',
|
|
253
|
+
decode: function () {
|
|
254
|
+
this.instance.flags.ack.setValue(!!this.readBits(13, 1, 3, 1));
|
|
255
|
+
},
|
|
256
|
+
encode: function () {
|
|
257
|
+
const acknowledgment = !!this.instance.flags.ack.getValue();
|
|
258
|
+
this.instance.flags.ack.setValue(acknowledgment);
|
|
259
|
+
this.writeBits(13, 1, 3, 1, acknowledgment ? 1 : 0);
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
push: {
|
|
263
|
+
type: 'boolean',
|
|
264
|
+
label: 'Push',
|
|
265
|
+
decode: function () {
|
|
266
|
+
this.instance.flags.push.setValue(!!this.readBits(13, 1, 4, 1));
|
|
267
|
+
},
|
|
268
|
+
encode: function () {
|
|
269
|
+
const push = !!this.instance.flags.push.getValue();
|
|
270
|
+
this.instance.flags.push.setValue(push);
|
|
271
|
+
this.writeBits(13, 1, 4, 1, push ? 1 : 0);
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
rst: {
|
|
275
|
+
type: 'boolean',
|
|
276
|
+
label: 'Reset',
|
|
277
|
+
decode: function () {
|
|
278
|
+
this.instance.flags.rst.setValue(!!this.readBits(13, 1, 5, 1));
|
|
279
|
+
},
|
|
280
|
+
encode: function () {
|
|
281
|
+
const reset = !!this.instance.flags.rst.getValue();
|
|
282
|
+
this.instance.flags.rst.setValue(reset);
|
|
283
|
+
this.writeBits(13, 1, 5, 1, reset ? 1 : 0);
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
syn: {
|
|
287
|
+
type: 'boolean',
|
|
288
|
+
label: 'Syn',
|
|
289
|
+
decode: function () {
|
|
290
|
+
this.instance.flags.syn.setValue(!!this.readBits(13, 1, 6, 1));
|
|
291
|
+
},
|
|
292
|
+
encode: function () {
|
|
293
|
+
const syn = !!this.instance.flags.syn.getValue();
|
|
294
|
+
this.instance.flags.syn.setValue(syn);
|
|
295
|
+
this.writeBits(13, 1, 6, 1, syn ? 1 : 0);
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
fin: {
|
|
299
|
+
type: 'boolean',
|
|
300
|
+
label: 'Fin',
|
|
301
|
+
decode: function () {
|
|
302
|
+
this.instance.flags.fin.setValue(!!this.readBits(13, 1, 7, 1));
|
|
303
|
+
},
|
|
304
|
+
encode: function () {
|
|
305
|
+
const fin = !!this.instance.flags.fin.getValue();
|
|
306
|
+
this.instance.flags.fin.setValue(fin);
|
|
307
|
+
this.writeBits(13, 1, 7, 1, fin ? 1 : 0);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
window: {
|
|
313
|
+
type: 'integer',
|
|
314
|
+
label: 'Window Size',
|
|
315
|
+
minimum: 0,
|
|
316
|
+
maximum: 65535,
|
|
317
|
+
decode: function () {
|
|
318
|
+
this.instance.window.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(14, 2)));
|
|
319
|
+
},
|
|
320
|
+
encode: function () {
|
|
321
|
+
let windowSize = this.instance.window.getValue(0);
|
|
322
|
+
if (windowSize > 65535) {
|
|
323
|
+
this.recordError(this.instance.window.getPath(), 'Maximum value is 65535');
|
|
324
|
+
windowSize = 65535;
|
|
325
|
+
}
|
|
326
|
+
if (windowSize < 0) {
|
|
327
|
+
this.recordError(this.instance.window.getPath(), 'Minimum value is 0');
|
|
328
|
+
windowSize = 0;
|
|
329
|
+
}
|
|
330
|
+
this.instance.window.setValue(windowSize);
|
|
331
|
+
this.writeBytes(14, (0, NumberToBuffer_1.UInt16ToBuffer)(windowSize));
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
checksum: {
|
|
335
|
+
type: 'integer',
|
|
336
|
+
label: 'Checksum',
|
|
337
|
+
minimum: 0,
|
|
338
|
+
maximum: 65535,
|
|
339
|
+
decode: function () {
|
|
340
|
+
this.instance.checksum.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(16, 2)));
|
|
341
|
+
},
|
|
342
|
+
encode: function () {
|
|
343
|
+
const checksum = this.instance.checksum.getValue(0);
|
|
344
|
+
if (checksum) {
|
|
345
|
+
this.instance.checksum.setValue(checksum);
|
|
346
|
+
this.writeBytes(16, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
this.instance.checksum.setValue(checksum);
|
|
350
|
+
this.writeBytes(16, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
351
|
+
this.addPostPacketEncodeHandler(() => {
|
|
352
|
+
//Calculate checksum after packet encoded
|
|
353
|
+
let startPos = 0;
|
|
354
|
+
let endPos = 0;
|
|
355
|
+
this.codecModules.forEach((codecModule) => {
|
|
356
|
+
if (codecModule === this)
|
|
357
|
+
startPos = codecModule.startPos;
|
|
358
|
+
endPos = codecModule.endPos > endPos ? codecModule.endPos : endPos;
|
|
359
|
+
});
|
|
360
|
+
const calcChecksum = this.calculateTCPChecksum(this.packet.subarray(startPos, endPos));
|
|
361
|
+
this.instance.checksum.setValue(calcChecksum);
|
|
362
|
+
this.writeBytes(16, (0, NumberToBuffer_1.UInt16ToBuffer)(calcChecksum));
|
|
363
|
+
}, 100);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
urgPtr: {
|
|
368
|
+
type: 'integer',
|
|
369
|
+
label: 'Urgent Pointer',
|
|
370
|
+
minimum: 0,
|
|
371
|
+
maximum: 65535,
|
|
372
|
+
decode: function () {
|
|
373
|
+
this.instance.urgPtr.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(18, 2)));
|
|
374
|
+
},
|
|
375
|
+
encode: function () {
|
|
376
|
+
let urgPtr = this.instance.urgPtr.getValue(0);
|
|
377
|
+
if (urgPtr > 65535) {
|
|
378
|
+
this.recordError(this.instance.urgPtr.getPath(), 'Maximum value is 65535');
|
|
379
|
+
urgPtr = 65535;
|
|
380
|
+
}
|
|
381
|
+
if (urgPtr < 0) {
|
|
382
|
+
this.recordError(this.instance.urgPtr.getPath(), 'Minimum value is 0');
|
|
383
|
+
urgPtr = 0;
|
|
384
|
+
}
|
|
385
|
+
this.instance.urgPtr.setValue(urgPtr);
|
|
386
|
+
this.writeBytes(18, (0, NumberToBuffer_1.UInt16ToBuffer)(urgPtr));
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
options: {
|
|
390
|
+
type: 'array',
|
|
391
|
+
label: 'Options',
|
|
392
|
+
items: {
|
|
393
|
+
anyOf: [
|
|
394
|
+
//Kind = 0 (End of Option List, EOL)
|
|
395
|
+
{
|
|
396
|
+
type: 'object',
|
|
397
|
+
label: 'End of Option List',
|
|
398
|
+
properties: {
|
|
399
|
+
option: {
|
|
400
|
+
type: 'string',
|
|
401
|
+
label: 'Option',
|
|
402
|
+
enum: [TCPOption.End_of_Option_List],
|
|
403
|
+
const: TCPOption.End_of_Option_List,
|
|
404
|
+
hidden: true
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
},
|
|
408
|
+
//Kind = 1 (No-Operation, NOP)
|
|
409
|
+
{
|
|
410
|
+
type: 'object',
|
|
411
|
+
label: 'No-Operation',
|
|
412
|
+
properties: {
|
|
413
|
+
option: {
|
|
414
|
+
type: 'string',
|
|
415
|
+
label: 'Option',
|
|
416
|
+
enum: [TCPOption.No_Operation],
|
|
417
|
+
const: TCPOption.No_Operation,
|
|
418
|
+
hidden: true
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
//Kind = 2 (Maximum Segment Size, MSS)
|
|
423
|
+
{
|
|
424
|
+
type: 'object',
|
|
425
|
+
label: 'Maximum Segment Size',
|
|
426
|
+
properties: {
|
|
427
|
+
option: {
|
|
428
|
+
type: 'string',
|
|
429
|
+
label: 'Option',
|
|
430
|
+
enum: [TCPOption.Maximum_Segment_Size],
|
|
431
|
+
const: TCPOption.Maximum_Segment_Size,
|
|
432
|
+
hidden: true
|
|
433
|
+
},
|
|
434
|
+
mss: {
|
|
435
|
+
type: 'integer',
|
|
436
|
+
label: 'MSS',
|
|
437
|
+
maximum: 65535,
|
|
438
|
+
minimum: 0
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
//Kind = 3 (Window Scale)
|
|
443
|
+
{
|
|
444
|
+
type: 'object',
|
|
445
|
+
label: 'Window Scale',
|
|
446
|
+
properties: {
|
|
447
|
+
option: {
|
|
448
|
+
type: 'string',
|
|
449
|
+
label: 'Option',
|
|
450
|
+
enum: [TCPOption.Window_Scale],
|
|
451
|
+
const: TCPOption.Window_Scale,
|
|
452
|
+
hidden: true
|
|
453
|
+
},
|
|
454
|
+
shift: {
|
|
455
|
+
type: 'integer',
|
|
456
|
+
label: 'Shift count',
|
|
457
|
+
minimum: 0,
|
|
458
|
+
maximum: 14
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
},
|
|
462
|
+
//Kind = 4 (Selective Acknowledgment Permitted, SACK-Permitted)
|
|
463
|
+
{
|
|
464
|
+
type: 'object',
|
|
465
|
+
label: 'Selective Acknowledgment Permitted',
|
|
466
|
+
properties: {
|
|
467
|
+
option: {
|
|
468
|
+
type: 'string',
|
|
469
|
+
label: 'Option',
|
|
470
|
+
enum: [TCPOption.Selective_Acknowledgment_Permitted],
|
|
471
|
+
const: TCPOption.Selective_Acknowledgment_Permitted,
|
|
472
|
+
hidden: true
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
},
|
|
476
|
+
//Kind = 5 (Selective Acknowledgment, SACK)
|
|
477
|
+
{
|
|
478
|
+
type: 'object',
|
|
479
|
+
label: 'Selective Acknowledgment',
|
|
480
|
+
properties: {
|
|
481
|
+
option: {
|
|
482
|
+
type: 'string',
|
|
483
|
+
label: 'Option',
|
|
484
|
+
enum: [TCPOption.Selective_Acknowledgment],
|
|
485
|
+
const: TCPOption.Selective_Acknowledgment,
|
|
486
|
+
hidden: true
|
|
487
|
+
},
|
|
488
|
+
blocks: {
|
|
489
|
+
type: 'array',
|
|
490
|
+
label: 'SACK Blocks',
|
|
491
|
+
items: {
|
|
492
|
+
type: 'string',
|
|
493
|
+
maxLength: 16,
|
|
494
|
+
minLength: 16,
|
|
495
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
},
|
|
500
|
+
//Kind = 8 (Timestamp, TS)
|
|
501
|
+
{
|
|
502
|
+
type: 'object',
|
|
503
|
+
label: 'Timestamp',
|
|
504
|
+
properties: {
|
|
505
|
+
option: {
|
|
506
|
+
type: 'string',
|
|
507
|
+
label: 'Option',
|
|
508
|
+
enum: [TCPOption.Timestamp],
|
|
509
|
+
const: TCPOption.Timestamp,
|
|
510
|
+
hidden: true
|
|
511
|
+
},
|
|
512
|
+
tsval: {
|
|
513
|
+
type: 'integer',
|
|
514
|
+
label: 'TSval',
|
|
515
|
+
minimum: 0,
|
|
516
|
+
maximum: 4294967295
|
|
517
|
+
},
|
|
518
|
+
tsecr: {
|
|
519
|
+
type: 'integer',
|
|
520
|
+
label: 'TSecr',
|
|
521
|
+
minimum: 0,
|
|
522
|
+
maximum: 4294967295
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
},
|
|
526
|
+
//Kind = 28 (User Timeout, UTO)
|
|
527
|
+
{
|
|
528
|
+
type: 'object',
|
|
529
|
+
label: 'User Timeout',
|
|
530
|
+
properties: {
|
|
531
|
+
option: {
|
|
532
|
+
type: 'string',
|
|
533
|
+
label: 'Option',
|
|
534
|
+
enum: [TCPOption.User_Timeout],
|
|
535
|
+
const: TCPOption.User_Timeout,
|
|
536
|
+
hidden: true
|
|
537
|
+
},
|
|
538
|
+
timeout: {
|
|
539
|
+
type: 'integer',
|
|
540
|
+
label: 'Timeout',
|
|
541
|
+
minimum: 0,
|
|
542
|
+
maximum: 32767
|
|
543
|
+
},
|
|
544
|
+
granularity: {
|
|
545
|
+
type: 'integer',
|
|
546
|
+
label: 'Granularity',
|
|
547
|
+
enum: [0, 1]
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
},
|
|
551
|
+
//Kind = 29 (TCP Authentication Option, TCP-AO)
|
|
552
|
+
{
|
|
553
|
+
type: 'object',
|
|
554
|
+
label: 'TCP Authentication Option',
|
|
555
|
+
properties: {
|
|
556
|
+
option: {
|
|
557
|
+
type: 'string',
|
|
558
|
+
label: 'Option',
|
|
559
|
+
enum: [TCPOption.TCP_Authentication_Option],
|
|
560
|
+
const: TCPOption.TCP_Authentication_Option,
|
|
561
|
+
hidden: true
|
|
562
|
+
},
|
|
563
|
+
data: {
|
|
564
|
+
type: 'string',
|
|
565
|
+
label: 'Data',
|
|
566
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
},
|
|
570
|
+
//Default
|
|
571
|
+
{
|
|
572
|
+
type: 'object',
|
|
573
|
+
label: 'Default',
|
|
574
|
+
properties: {
|
|
575
|
+
kind: {
|
|
576
|
+
type: 'integer',
|
|
577
|
+
label: 'Kind'
|
|
578
|
+
},
|
|
579
|
+
data: {
|
|
580
|
+
type: 'string',
|
|
581
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
582
|
+
label: 'Data'
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
]
|
|
587
|
+
},
|
|
588
|
+
decode: function () {
|
|
589
|
+
const hdrLen = this.instance.hdrLen.getValue();
|
|
590
|
+
const optionsLength = hdrLen - this.length;
|
|
591
|
+
if (!optionsLength)
|
|
592
|
+
return;
|
|
593
|
+
let optionOffset = this.length;
|
|
594
|
+
const options = [];
|
|
595
|
+
let index = 0;
|
|
596
|
+
while (optionOffset < hdrLen) {
|
|
597
|
+
const kind = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(optionOffset, 1));
|
|
598
|
+
optionOffset += 1;
|
|
599
|
+
switch (kind) {
|
|
600
|
+
//Kind = 0 (End of Option List, EOL)
|
|
601
|
+
case 0:
|
|
602
|
+
{
|
|
603
|
+
options.push({
|
|
604
|
+
option: TCPOption.End_of_Option_List
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
break;
|
|
608
|
+
//Kind = 1 (No-Operation, NOP)
|
|
609
|
+
case 1:
|
|
610
|
+
{
|
|
611
|
+
options.push({
|
|
612
|
+
option: TCPOption.No_Operation
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
break;
|
|
616
|
+
//Kind = 2 (Maximum Segment Size, MSS)
|
|
617
|
+
case 2:
|
|
618
|
+
{
|
|
619
|
+
const length = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(optionOffset, 1));
|
|
620
|
+
if (length !== 4)
|
|
621
|
+
this.recordError(this.instance.options.getPath(index), 'MSS option TLV length should be 4');
|
|
622
|
+
optionOffset += 1;
|
|
623
|
+
const value = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(optionOffset, 2));
|
|
624
|
+
optionOffset += 2;
|
|
625
|
+
options.push({
|
|
626
|
+
option: TCPOption.Maximum_Segment_Size,
|
|
627
|
+
mss: value
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
break;
|
|
631
|
+
//Kind = 3 (Window Scale)
|
|
632
|
+
case 3:
|
|
633
|
+
{
|
|
634
|
+
const length = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(optionOffset, 1));
|
|
635
|
+
if (length !== 3)
|
|
636
|
+
this.recordError(this.instance.options.getPath(index), 'Window Scale option TLV length should be 3');
|
|
637
|
+
optionOffset += 1;
|
|
638
|
+
const value = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(optionOffset, 1));
|
|
639
|
+
optionOffset += 1;
|
|
640
|
+
if (value < 0 || value > 14)
|
|
641
|
+
this.recordError(this.instance.options.getPath(index), 'Window Scale option TLV value should between 0 and 14');
|
|
642
|
+
options.push({
|
|
643
|
+
option: TCPOption.Window_Scale,
|
|
644
|
+
shift: value
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
break;
|
|
648
|
+
//Kind = 4 (Selective Acknowledgment Permitted, SACK-Permitted)
|
|
649
|
+
case 4:
|
|
650
|
+
{
|
|
651
|
+
const length = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(optionOffset, 1));
|
|
652
|
+
optionOffset += 1;
|
|
653
|
+
if (length !== 2)
|
|
654
|
+
this.recordError(this.instance.options.getPath(index), 'SACK-Permitted option TLV length should be 2');
|
|
655
|
+
options.push({
|
|
656
|
+
option: TCPOption.Selective_Acknowledgment_Permitted
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
break;
|
|
660
|
+
//Kind = 5 (Selective Acknowledgment, SACK)
|
|
661
|
+
case 5:
|
|
662
|
+
{
|
|
663
|
+
const length = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(optionOffset, 1));
|
|
664
|
+
optionOffset += 1;
|
|
665
|
+
let sackBlockTotalLength = length - 2;
|
|
666
|
+
if (sackBlockTotalLength < 0) {
|
|
667
|
+
this.recordError(this.instance.options.getPath(index), 'SACK option block count should not less than 0');
|
|
668
|
+
sackBlockTotalLength = 0;
|
|
669
|
+
}
|
|
670
|
+
let sackBlockCount = sackBlockTotalLength ? Math.floor(sackBlockTotalLength / 8) : 0;
|
|
671
|
+
const sackBlocks = [];
|
|
672
|
+
while (sackBlockCount > 0) {
|
|
673
|
+
sackBlocks.push((0, NumberToHex_1.UInt64ToHex)(BigInt(`0x${(0, BufferToNumber_1.BufferToUInt64)(this.readBytes(optionOffset, 8)).toString(16)}`)));
|
|
674
|
+
optionOffset += 8;
|
|
675
|
+
sackBlockCount -= 1;
|
|
676
|
+
}
|
|
677
|
+
options.push({
|
|
678
|
+
option: TCPOption.Selective_Acknowledgment,
|
|
679
|
+
blocks: sackBlocks
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
break;
|
|
683
|
+
//Kind = 8 (Timestamp, TS)
|
|
684
|
+
case 8:
|
|
685
|
+
{
|
|
686
|
+
const length = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(optionOffset, 1));
|
|
687
|
+
optionOffset += 1;
|
|
688
|
+
if (length !== 10)
|
|
689
|
+
this.recordError(this.instance.options.getPath(index), 'Timestamp option TLV length should be 10');
|
|
690
|
+
const tsval = (0, BufferToNumber_1.BufferToUInt32)(this.readBytes(optionOffset, 4));
|
|
691
|
+
optionOffset += 4;
|
|
692
|
+
const tsecr = (0, BufferToNumber_1.BufferToUInt32)(this.readBytes(optionOffset, 4));
|
|
693
|
+
optionOffset += 4;
|
|
694
|
+
options.push({
|
|
695
|
+
option: TCPOption.Timestamp,
|
|
696
|
+
tsval: tsval,
|
|
697
|
+
tsecr: tsecr
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
break;
|
|
701
|
+
//Kind = 28 (User Timeout, UTO)
|
|
702
|
+
case 28:
|
|
703
|
+
{
|
|
704
|
+
//RFC 5482: Kind=28, Length=4, then a single 16-bit value whose top
|
|
705
|
+
//bit is Granularity (G) and low 15 bits are the User Timeout.
|
|
706
|
+
const length = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(optionOffset, 1));
|
|
707
|
+
optionOffset += 1;
|
|
708
|
+
if (length !== 4)
|
|
709
|
+
this.recordError(this.instance.options.getPath(index), 'UTO option TLV length should be 4');
|
|
710
|
+
const value = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(optionOffset, 2));
|
|
711
|
+
optionOffset += 2;
|
|
712
|
+
options.push({
|
|
713
|
+
option: TCPOption.User_Timeout,
|
|
714
|
+
granularity: (value >> 15) & 0x01,
|
|
715
|
+
timeout: value & 0x7fff
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
break;
|
|
719
|
+
//Kind = 29 (TCP Authentication Option, TCP-AO)
|
|
720
|
+
case 29:
|
|
721
|
+
{
|
|
722
|
+
const length = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(optionOffset, 1));
|
|
723
|
+
optionOffset += 1;
|
|
724
|
+
let dataLength = length - 2;
|
|
725
|
+
if (dataLength < 0) {
|
|
726
|
+
this.recordError(this.instance.options.getPath(index), 'TCP Authentication Option TLV length should not less than 2');
|
|
727
|
+
dataLength = 0;
|
|
728
|
+
}
|
|
729
|
+
let data;
|
|
730
|
+
if (dataLength) {
|
|
731
|
+
data = this.readBytes(optionOffset, dataLength);
|
|
732
|
+
optionOffset += dataLength;
|
|
733
|
+
}
|
|
734
|
+
else {
|
|
735
|
+
data = Buffer.from([]);
|
|
736
|
+
}
|
|
737
|
+
options.push({
|
|
738
|
+
option: TCPOption.TCP_Authentication_Option,
|
|
739
|
+
data: data.toString('hex')
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
break;
|
|
743
|
+
default: {
|
|
744
|
+
const length = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(optionOffset, 1));
|
|
745
|
+
let dataLength = length - 2;
|
|
746
|
+
if (dataLength < 0) {
|
|
747
|
+
this.recordError(this.instance.options.getPath(index), 'Option TLV length should not less than 2');
|
|
748
|
+
dataLength = 0;
|
|
749
|
+
}
|
|
750
|
+
let data;
|
|
751
|
+
if (dataLength) {
|
|
752
|
+
data = this.readBytes(optionOffset, dataLength);
|
|
753
|
+
optionOffset += dataLength;
|
|
754
|
+
}
|
|
755
|
+
else {
|
|
756
|
+
data = Buffer.from([]);
|
|
757
|
+
}
|
|
758
|
+
options.push({
|
|
759
|
+
kind: kind,
|
|
760
|
+
data: data.toString('hex')
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
index += 1;
|
|
765
|
+
}
|
|
766
|
+
this.instance.options.setValue(options);
|
|
767
|
+
},
|
|
768
|
+
encode: function () {
|
|
769
|
+
const options = this.instance.options.getValue();
|
|
770
|
+
if (!options)
|
|
771
|
+
return;
|
|
772
|
+
let optionOffset = this.length;
|
|
773
|
+
options.forEach((optionItem) => {
|
|
774
|
+
const namedOptionItem = optionItem;
|
|
775
|
+
switch (namedOptionItem.option) {
|
|
776
|
+
case TCPOption.End_of_Option_List: {
|
|
777
|
+
const optionEOL = optionItem;
|
|
778
|
+
this.writeBytes(optionOffset, (0, NumberToBuffer_1.UInt8ToBuffer)(0));
|
|
779
|
+
optionOffset += 1;
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
case TCPOption.No_Operation: {
|
|
783
|
+
const optionNOP = optionItem;
|
|
784
|
+
this.writeBytes(optionOffset, (0, NumberToBuffer_1.UInt8ToBuffer)(1));
|
|
785
|
+
optionOffset += 1;
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
case TCPOption.Maximum_Segment_Size: {
|
|
789
|
+
const optionMSS = optionItem;
|
|
790
|
+
const mssBuffer = Buffer.concat([
|
|
791
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(2),
|
|
792
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(4),
|
|
793
|
+
(0, NumberToBuffer_1.UInt16ToBuffer)(optionMSS.mss)
|
|
794
|
+
]);
|
|
795
|
+
this.writeBytes(optionOffset, mssBuffer);
|
|
796
|
+
optionOffset += mssBuffer.length;
|
|
797
|
+
return;
|
|
798
|
+
}
|
|
799
|
+
case TCPOption.Window_Scale: {
|
|
800
|
+
const optionWS = optionItem;
|
|
801
|
+
const wsBuffer = Buffer.concat([
|
|
802
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(3),
|
|
803
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(3),
|
|
804
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(optionWS.shift)
|
|
805
|
+
]);
|
|
806
|
+
this.writeBytes(optionOffset, wsBuffer);
|
|
807
|
+
optionOffset += wsBuffer.length;
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
case TCPOption.Selective_Acknowledgment_Permitted: {
|
|
811
|
+
const optionSackPermitted = optionItem;
|
|
812
|
+
const sackPermittedBuffer = Buffer.concat([
|
|
813
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(4),
|
|
814
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(2)
|
|
815
|
+
]);
|
|
816
|
+
this.writeBytes(optionOffset, sackPermittedBuffer);
|
|
817
|
+
optionOffset += sackPermittedBuffer.length;
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
case TCPOption.Selective_Acknowledgment: {
|
|
821
|
+
const optionSack = optionItem;
|
|
822
|
+
const kindBuffer = (0, NumberToBuffer_1.UInt8ToBuffer)(5);
|
|
823
|
+
const length = 2;
|
|
824
|
+
let blocksBuffer = Buffer.from([]);
|
|
825
|
+
optionSack.blocks.forEach((block) => {
|
|
826
|
+
blocksBuffer = Buffer.concat([blocksBuffer, (0, NumberToBuffer_1.UInt64ToBuffer)((0, HexToNumber_1.HexToUInt64)(block))]);
|
|
827
|
+
});
|
|
828
|
+
const sackBuffer = Buffer.concat([kindBuffer, (0, NumberToBuffer_1.UInt8ToBuffer)(length + blocksBuffer.length), blocksBuffer]);
|
|
829
|
+
this.writeBytes(optionOffset, sackBuffer);
|
|
830
|
+
optionOffset += sackBuffer.length;
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
case TCPOption.Timestamp: {
|
|
834
|
+
const optionTS = optionItem;
|
|
835
|
+
const tsBuffer = Buffer.concat([
|
|
836
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(8),
|
|
837
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(10),
|
|
838
|
+
(0, NumberToBuffer_1.UInt32ToBuffer)(optionTS.tsval ? optionTS.tsval : 0),
|
|
839
|
+
(0, NumberToBuffer_1.UInt32ToBuffer)(optionTS.tsecr ? optionTS.tsecr : 0)
|
|
840
|
+
]);
|
|
841
|
+
this.writeBytes(optionOffset, tsBuffer);
|
|
842
|
+
optionOffset += tsBuffer.length;
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
case TCPOption.User_Timeout: {
|
|
846
|
+
//RFC 5482: Kind=28, Length=4, value = G(top bit) | User Timeout(15 bits).
|
|
847
|
+
const optionUTO = optionItem;
|
|
848
|
+
const granularity = optionUTO.granularity ? optionUTO.granularity : 0;
|
|
849
|
+
const timeout = optionUTO.timeout ? optionUTO.timeout : 0;
|
|
850
|
+
const value = ((granularity & 0x01) << 15) | (timeout & 0x7fff);
|
|
851
|
+
const utoBuffer = Buffer.concat([
|
|
852
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(28),
|
|
853
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(4),
|
|
854
|
+
(0, NumberToBuffer_1.UInt16ToBuffer)(value)
|
|
855
|
+
]);
|
|
856
|
+
this.writeBytes(optionOffset, utoBuffer);
|
|
857
|
+
optionOffset += utoBuffer.length;
|
|
858
|
+
return;
|
|
859
|
+
}
|
|
860
|
+
case TCPOption.TCP_Authentication_Option: {
|
|
861
|
+
const optionTcpAo = optionItem;
|
|
862
|
+
const kindBuffer = (0, NumberToBuffer_1.UInt8ToBuffer)(29);
|
|
863
|
+
const dataBuffer = Buffer.from(optionTcpAo.data, 'hex');
|
|
864
|
+
const lengthBuffer = (0, NumberToBuffer_1.UInt8ToBuffer)(dataBuffer.length + 2);
|
|
865
|
+
const tcpAoBuffer = Buffer.concat([kindBuffer, lengthBuffer, dataBuffer]);
|
|
866
|
+
this.writeBytes(optionOffset, tcpAoBuffer);
|
|
867
|
+
optionOffset += tcpAoBuffer.length;
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
default: {
|
|
871
|
+
const defaultOptionItem = optionItem;
|
|
872
|
+
const kind = defaultOptionItem.kind;
|
|
873
|
+
const hexBuffer = Buffer.from(defaultOptionItem.data.toString(), 'hex');
|
|
874
|
+
const length = hexBuffer.length + 2;
|
|
875
|
+
const defaultOptionBuffer = Buffer.concat([(0, NumberToBuffer_1.UInt8ToBuffer)(kind), (0, NumberToBuffer_1.UInt8ToBuffer)(length), hexBuffer]);
|
|
876
|
+
this.writeBytes(optionOffset, defaultOptionBuffer);
|
|
877
|
+
optionOffset += defaultOptionBuffer.length;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
});
|
|
881
|
+
if (this.length > 60)
|
|
882
|
+
return this.recordError(this.instance.options.getPath(), 'Options too large');
|
|
883
|
+
const padLength = (4 - this.length % 4) % 4;
|
|
884
|
+
if (padLength) {
|
|
885
|
+
//Add Padding
|
|
886
|
+
this.writeBytes(this.length, Buffer.alloc(padLength, 0));
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
match() {
|
|
894
|
+
if (!this.prevCodecModule)
|
|
895
|
+
return false;
|
|
896
|
+
//TCP sits above IPv4 (protocol field) or IPv6 (next-header field) — accept its demux value from
|
|
897
|
+
//either, so match() stays consistent with the shared 'ipproto:6' dispatch key.
|
|
898
|
+
if (this.prevCodecModule.instance.protocol.getValue() === 0x06)
|
|
899
|
+
return true;
|
|
900
|
+
if (this.prevCodecModule.instance.nxt.getValue() === 0x06)
|
|
901
|
+
return true;
|
|
902
|
+
return false;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
exports.TCP = TCP;
|