@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,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UDP = 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
|
+
class UDP extends BaseHeader_1.BaseHeader {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.id = 'udp';
|
|
12
|
+
this.matchKeys = ['ipproto:17'];
|
|
13
|
+
//Produces a port demux key from BOTH ports (a protocol's well-known port may be src or dst).
|
|
14
|
+
this.demuxProducers = [
|
|
15
|
+
{ field: 'dstport', namespace: 'udpport', kind: 'uint' },
|
|
16
|
+
{ field: 'srcport', namespace: 'udpport', kind: 'uint' }
|
|
17
|
+
];
|
|
18
|
+
this.name = 'User Datagram Protocol';
|
|
19
|
+
this.nickname = 'UDP';
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Calculate UDP Checksum
|
|
23
|
+
* @protected
|
|
24
|
+
* @param udpHeaderBuffer
|
|
25
|
+
*/
|
|
26
|
+
calculateUDPChecksum(udpHeaderBuffer) {
|
|
27
|
+
const udpHeaderLength = udpHeaderBuffer.length;
|
|
28
|
+
const ipVersion = this.prevCodecModule.instance.version.getValue();
|
|
29
|
+
let pseudoHeaderBuffer = Buffer.from([]);
|
|
30
|
+
const sourceIp = this.prevCodecModule.instance.sip.getValue();
|
|
31
|
+
const destinationIp = this.prevCodecModule.instance.dip.getValue();
|
|
32
|
+
if (ipVersion === 4) {
|
|
33
|
+
//4 Bytes
|
|
34
|
+
const sourceIPv4Buffer = Buffer.from(sourceIp.split('.').map((value) => parseInt(value)));
|
|
35
|
+
const destinationIPv4Buffer = Buffer.from(destinationIp.split('.').map((value) => parseInt(value)));
|
|
36
|
+
//IPv4 Pseudo header
|
|
37
|
+
pseudoHeaderBuffer = Buffer.concat([
|
|
38
|
+
sourceIPv4Buffer,
|
|
39
|
+
destinationIPv4Buffer,
|
|
40
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(0), //Reserved field
|
|
41
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(17), //Protocol type (UDP = 17)
|
|
42
|
+
Buffer.from([(udpHeaderLength >> 8) & 0xFF]),
|
|
43
|
+
Buffer.from([udpHeaderLength & 0xFF])
|
|
44
|
+
]);
|
|
45
|
+
}
|
|
46
|
+
else if (ipVersion === 6) {
|
|
47
|
+
//16 Bytes
|
|
48
|
+
const sourceIPv6Buffer = (0, IPToBuffer_1.IPv6ToBuffer)(sourceIp);
|
|
49
|
+
const destinationIPv6Buffer = (0, IPToBuffer_1.IPv6ToBuffer)(destinationIp);
|
|
50
|
+
//IPv6 Pseudo header
|
|
51
|
+
pseudoHeaderBuffer = Buffer.concat([
|
|
52
|
+
sourceIPv6Buffer,
|
|
53
|
+
destinationIPv6Buffer,
|
|
54
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(0), //Reserved field
|
|
55
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(0), //Reserved field
|
|
56
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(0), //Reserved field
|
|
57
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(17), //Protocol type (UDP = 17)
|
|
58
|
+
Buffer.from([(udpHeaderLength >> 8) & 0xFF]),
|
|
59
|
+
Buffer.from([udpHeaderLength & 0xFF])
|
|
60
|
+
]);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
let dataBuffer = Buffer.concat([pseudoHeaderBuffer, udpHeaderBuffer]);
|
|
66
|
+
if (dataBuffer.length % 2)
|
|
67
|
+
dataBuffer = Buffer.concat([dataBuffer, Buffer.from('00', 'hex')]);
|
|
68
|
+
const data = Uint8Array.from(dataBuffer);
|
|
69
|
+
let sum = 0;
|
|
70
|
+
for (let i = 0; i < data.length; i += 2)
|
|
71
|
+
sum += (data[i] << 8) + (data[i + 1] || 0);
|
|
72
|
+
while (sum > 0xFFFF)
|
|
73
|
+
sum = (sum & 0xFFFF) + (sum >>> 16);
|
|
74
|
+
const _cs = (~sum) & 0xFFFF;
|
|
75
|
+
return _cs === 0 ? 0xFFFF : _cs;
|
|
76
|
+
}
|
|
77
|
+
static #schemaCache;
|
|
78
|
+
//Class-cached SCHEMA (④): field closures are functions taking dynamic `this` via .call(this).
|
|
79
|
+
//fieldUInt is a static factory, so `this.fieldUInt` below resolves against the class.
|
|
80
|
+
get SCHEMA() {
|
|
81
|
+
return (UDP.#schemaCache ??= UDP.#buildSchema());
|
|
82
|
+
}
|
|
83
|
+
static #buildSchema() {
|
|
84
|
+
return {
|
|
85
|
+
type: 'object',
|
|
86
|
+
properties: {
|
|
87
|
+
//Migrated to the declarative field building block: one call replaces the hand-mirrored
|
|
88
|
+
//decode/encode twin, byte-for-byte identical (proven by the unchanged golden + round-trip).
|
|
89
|
+
srcport: this.fieldUInt('srcport', 0, 2, 'Source Port'),
|
|
90
|
+
dstport: this.fieldUInt('dstport', 2, 2, 'Destination Port'),
|
|
91
|
+
length: {
|
|
92
|
+
type: 'integer',
|
|
93
|
+
label: 'Length',
|
|
94
|
+
minimum: 0,
|
|
95
|
+
maximum: 65535,
|
|
96
|
+
decode: function () {
|
|
97
|
+
this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(4, 2)));
|
|
98
|
+
},
|
|
99
|
+
encode: function () {
|
|
100
|
+
const length = this.instance.length.getValue(0);
|
|
101
|
+
if (length) {
|
|
102
|
+
this.instance.length.setValue(length);
|
|
103
|
+
this.writeBytes(4, (0, NumberToBuffer_1.UInt16ToBuffer)(length));
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
this.instance.length.setValue(length);
|
|
107
|
+
this.writeBytes(4, (0, NumberToBuffer_1.UInt16ToBuffer)(length));
|
|
108
|
+
this.addPostPacketEncodeHandler(() => {
|
|
109
|
+
let startCount = false;
|
|
110
|
+
let udpLength = 0;
|
|
111
|
+
this.codecModules.forEach((codecModule) => {
|
|
112
|
+
if (codecModule === this)
|
|
113
|
+
startCount = true;
|
|
114
|
+
if (startCount)
|
|
115
|
+
udpLength += codecModule.length;
|
|
116
|
+
});
|
|
117
|
+
this.instance.length.setValue(udpLength);
|
|
118
|
+
this.writeBytes(4, (0, NumberToBuffer_1.UInt16ToBuffer)(udpLength));
|
|
119
|
+
}, 1);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
checksum: {
|
|
124
|
+
type: 'integer',
|
|
125
|
+
label: 'Checksum',
|
|
126
|
+
minimum: 0,
|
|
127
|
+
maximum: 65535,
|
|
128
|
+
decode: function () {
|
|
129
|
+
this.instance.checksum.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(6, 2)));
|
|
130
|
+
},
|
|
131
|
+
encode: function () {
|
|
132
|
+
const checksum = this.instance.checksum.getValue(0);
|
|
133
|
+
if (checksum) {
|
|
134
|
+
this.instance.checksum.setValue(checksum);
|
|
135
|
+
this.writeBytes(6, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
this.writeBytes(6, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
139
|
+
this.instance.checksum.setValue(checksum);
|
|
140
|
+
this.addPostPacketEncodeHandler(() => {
|
|
141
|
+
let startCount = false;
|
|
142
|
+
let udpHeaderWithDataLength = 0;
|
|
143
|
+
this.codecModules.forEach((codecModule) => {
|
|
144
|
+
if (codecModule === this)
|
|
145
|
+
startCount = true;
|
|
146
|
+
if (startCount)
|
|
147
|
+
udpHeaderWithDataLength += codecModule.length;
|
|
148
|
+
});
|
|
149
|
+
const calcChecksum = this.calculateUDPChecksum(this.packet.subarray(this.startPos, this.startPos + udpHeaderWithDataLength));
|
|
150
|
+
this.instance.checksum.setValue(calcChecksum);
|
|
151
|
+
this.writeBytes(6, (0, NumberToBuffer_1.UInt16ToBuffer)(calcChecksum));
|
|
152
|
+
}, 2);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
match() {
|
|
160
|
+
if (!this.prevCodecModule)
|
|
161
|
+
return false;
|
|
162
|
+
//UDP sits above IPv4 (protocol field) or IPv6 (next-header field) — accept its demux value from
|
|
163
|
+
//either, so match() stays consistent with the shared 'ipproto:17' dispatch key.
|
|
164
|
+
if (this.prevCodecModule.instance.protocol.getValue() === 0x11)
|
|
165
|
+
return true;
|
|
166
|
+
if (this.prevCodecModule.instance.nxt.getValue() === 0x11)
|
|
167
|
+
return true;
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
exports.UDP = UDP;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
2
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* VLAN 802.1Q — the IEEE 802.1Q VLAN tag, selected when the carrying layer's EtherType is the TPID 0x8100.
|
|
6
|
+
* This codec decodes the 4-octet tag that follows the TPID: the 2-octet Tag Control Information split into
|
|
7
|
+
* a 3-bit Priority / PCP (`priority`, top bits of offset 0), a 1-bit Drop Eligible Indicator (`dei`,
|
|
8
|
+
* boolean) and a 12-bit VLAN ID (`id`, the low 12 bits), followed by the 16-bit EtherType of the
|
|
9
|
+
* encapsulated frame (`etherType`, offset 2, a lowercase 4-hex string).
|
|
10
|
+
*
|
|
11
|
+
* The trailing `etherType` is published as an `ethertype` demux key so the tagged inner protocol
|
|
12
|
+
* (IPv4/IPv6/ARP, another VLAN for QinQ, GOOSE, SV…) is selected exactly as it would be off bare Ethernet.
|
|
13
|
+
* match() fires whenever the parent's EtherType is 0x8100, regardless of which layer carries it, so it
|
|
14
|
+
* handles both single- and stacked-tag frames.
|
|
15
|
+
*/
|
|
16
|
+
export declare class VLAN_802dot1Q extends BaseHeader {
|
|
17
|
+
SCHEMA: ProtocolJSONSchema;
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly matchKeys: string[];
|
|
20
|
+
readonly demuxProducers: DemuxProducer[];
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly nickname: string;
|
|
23
|
+
match(): boolean;
|
|
24
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VLAN_802dot1Q = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const NumberToHex_1 = require("../helper/NumberToHex");
|
|
6
|
+
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
7
|
+
/**
|
|
8
|
+
* VLAN 802.1Q — the IEEE 802.1Q VLAN tag, selected when the carrying layer's EtherType is the TPID 0x8100.
|
|
9
|
+
* This codec decodes the 4-octet tag that follows the TPID: the 2-octet Tag Control Information split into
|
|
10
|
+
* a 3-bit Priority / PCP (`priority`, top bits of offset 0), a 1-bit Drop Eligible Indicator (`dei`,
|
|
11
|
+
* boolean) and a 12-bit VLAN ID (`id`, the low 12 bits), followed by the 16-bit EtherType of the
|
|
12
|
+
* encapsulated frame (`etherType`, offset 2, a lowercase 4-hex string).
|
|
13
|
+
*
|
|
14
|
+
* The trailing `etherType` is published as an `ethertype` demux key so the tagged inner protocol
|
|
15
|
+
* (IPv4/IPv6/ARP, another VLAN for QinQ, GOOSE, SV…) is selected exactly as it would be off bare Ethernet.
|
|
16
|
+
* match() fires whenever the parent's EtherType is 0x8100, regardless of which layer carries it, so it
|
|
17
|
+
* handles both single- and stacked-tag frames.
|
|
18
|
+
*/
|
|
19
|
+
class VLAN_802dot1Q extends BaseHeader_1.BaseHeader {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.SCHEMA = {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
priority: {
|
|
26
|
+
type: 'integer',
|
|
27
|
+
minimum: 0,
|
|
28
|
+
maximum: 7,
|
|
29
|
+
default: 0,
|
|
30
|
+
label: 'Priority',
|
|
31
|
+
decode: () => {
|
|
32
|
+
this.instance.priority.setValue(this.readBits(0, 2, 0, 3));
|
|
33
|
+
},
|
|
34
|
+
encode: () => {
|
|
35
|
+
const priorityValue = this.instance.priority.getValue(0);
|
|
36
|
+
this.instance.priority.setValue(priorityValue);
|
|
37
|
+
this.writeBits(0, 2, 0, 3, priorityValue);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
dei: {
|
|
41
|
+
type: 'boolean',
|
|
42
|
+
label: 'DEI',
|
|
43
|
+
decode: () => {
|
|
44
|
+
this.instance.dei.setValue(!!this.readBits(0, 2, 3, 1));
|
|
45
|
+
},
|
|
46
|
+
encode: () => {
|
|
47
|
+
const dei = !!this.instance.dei.getValue();
|
|
48
|
+
this.instance.dei.setValue(dei);
|
|
49
|
+
this.writeBits(0, 2, 3, 1, dei ? 1 : 0);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
id: {
|
|
53
|
+
type: 'integer',
|
|
54
|
+
minimum: 0,
|
|
55
|
+
maximum: 4095,
|
|
56
|
+
label: 'ID',
|
|
57
|
+
decode: () => {
|
|
58
|
+
this.instance.id.setValue(this.readBits(0, 2, 4, 12));
|
|
59
|
+
},
|
|
60
|
+
encode: () => {
|
|
61
|
+
const vlanId = this.instance.id.getValue(0);
|
|
62
|
+
this.instance.id.setValue(vlanId);
|
|
63
|
+
this.writeBits(0, 2, 4, 12, vlanId);
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
etherType: {
|
|
67
|
+
type: 'string',
|
|
68
|
+
minLength: 4,
|
|
69
|
+
maxLength: 4,
|
|
70
|
+
label: 'EtherType',
|
|
71
|
+
decode: () => {
|
|
72
|
+
this.instance.etherType.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(2, 2)));
|
|
73
|
+
},
|
|
74
|
+
encode: () => {
|
|
75
|
+
const etherType = this.instance.etherType.getValue((0, NumberToHex_1.UInt16ToHex)(0x0000), (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
76
|
+
const typeBuffer = Buffer.from(etherType, 'hex');
|
|
77
|
+
if (typeBuffer.length < 2)
|
|
78
|
+
typeBuffer.fill(0, 0, 1);
|
|
79
|
+
this.writeBytes(2, typeBuffer.subarray(0, 2));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
this.id = 'vlan';
|
|
85
|
+
this.matchKeys = ['ethertype:8100'];
|
|
86
|
+
this.demuxProducers = [{ field: 'etherType', namespace: 'ethertype', kind: 'string' }];
|
|
87
|
+
this.name = '802.1Q Virtual LAN';
|
|
88
|
+
this.nickname = 'VLAN';
|
|
89
|
+
}
|
|
90
|
+
match() {
|
|
91
|
+
if (!this.prevCodecModule)
|
|
92
|
+
return false;
|
|
93
|
+
return this.prevCodecModule.instance.etherType.getValue() === (0, NumberToHex_1.UInt16ToHex)(0x8100);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.VLAN_802dot1Q = VLAN_802dot1Q;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
2
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* VRRP — Virtual Router Redundancy Protocol (v2 RFC 3768, v3 RFC 5798), carried directly over IP as
|
|
6
|
+
* protocol 112. A fixed 8-byte header — Version (high nibble of byte 0) + Type (low nibble), Virtual
|
|
7
|
+
* Router ID, Priority, Count of addresses, then two version-specific bytes, then a Checksum — followed
|
|
8
|
+
* by the advertised virtual IP addresses (4-byte IPv4 each). In v2 bytes 4/5 are Auth Type / whole-second
|
|
9
|
+
* Advertisement Interval and (with Auth Type 1) 8 trailing bytes of authentication data follow the
|
|
10
|
+
* address list; in v3 bytes 4/5 are a reserved nibble + 12-bit Max Advertisement Interval (centiseconds).
|
|
11
|
+
*
|
|
12
|
+
* The version is the high nibble of byte 0 and selects how bytes 4-5 and the trailer are interpreted;
|
|
13
|
+
* version-specific fields no-op when the decoded version does not match, so on encode each octet is
|
|
14
|
+
* written by exactly one field — a well-formed advertisement round-trips byte-for-byte. The checksum is
|
|
15
|
+
* honored verbatim (not recomputed — it differs by version and, in v3, covers an IP pseudo-header).
|
|
16
|
+
*/
|
|
17
|
+
export declare class VRRP extends BaseHeader {
|
|
18
|
+
#private;
|
|
19
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly matchKeys: string[];
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly nickname: string;
|
|
24
|
+
match(): boolean;
|
|
25
|
+
readonly demuxProducers: DemuxProducer[];
|
|
26
|
+
}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VRRP = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const BufferToNumber_1 = require("../helper/BufferToNumber");
|
|
6
|
+
const NumberToBuffer_1 = require("../helper/NumberToBuffer");
|
|
7
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
8
|
+
const BufferToIP_1 = require("../helper/BufferToIP");
|
|
9
|
+
const IPToBuffer_1 = require("../helper/IPToBuffer");
|
|
10
|
+
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
11
|
+
const HexToBuffer_1 = require("../helper/HexToBuffer");
|
|
12
|
+
/**
|
|
13
|
+
* VRRP — Virtual Router Redundancy Protocol (v2 RFC 3768, v3 RFC 5798), carried directly over IP as
|
|
14
|
+
* protocol 112. A fixed 8-byte header — Version (high nibble of byte 0) + Type (low nibble), Virtual
|
|
15
|
+
* Router ID, Priority, Count of addresses, then two version-specific bytes, then a Checksum — followed
|
|
16
|
+
* by the advertised virtual IP addresses (4-byte IPv4 each). In v2 bytes 4/5 are Auth Type / whole-second
|
|
17
|
+
* Advertisement Interval and (with Auth Type 1) 8 trailing bytes of authentication data follow the
|
|
18
|
+
* address list; in v3 bytes 4/5 are a reserved nibble + 12-bit Max Advertisement Interval (centiseconds).
|
|
19
|
+
*
|
|
20
|
+
* The version is the high nibble of byte 0 and selects how bytes 4-5 and the trailer are interpreted;
|
|
21
|
+
* version-specific fields no-op when the decoded version does not match, so on encode each octet is
|
|
22
|
+
* written by exactly one field — a well-formed advertisement round-trips byte-for-byte. The checksum is
|
|
23
|
+
* honored verbatim (not recomputed — it differs by version and, in v3, covers an IP pseudo-header).
|
|
24
|
+
*/
|
|
25
|
+
class VRRP extends BaseHeader_1.BaseHeader {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
this.id = 'vrrp';
|
|
29
|
+
this.matchKeys = ['ipproto:112'];
|
|
30
|
+
this.name = 'Virtual Router Redundancy Protocol';
|
|
31
|
+
this.nickname = 'VRRP';
|
|
32
|
+
//A leaf header — nothing rides on top of a VRRP advertisement.
|
|
33
|
+
this.demuxProducers = [];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Bytes available to this header within the enclosing IP layer's payload. Mirrors the IP-carried
|
|
37
|
+
* pattern: for IPv4 the payload is (Total Length - IP header length); for IPv6 it is the Payload
|
|
38
|
+
* Length field. Falls back to the raw remaining buffer when there is no IP layer beneath (e.g. a
|
|
39
|
+
* malformed stack or a standalone decode), so match() and the address loop stay bounded.
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
#available() {
|
|
43
|
+
if (!this.prevCodecModule)
|
|
44
|
+
return this.packet.length - this.startPos;
|
|
45
|
+
const version = this.prevCodecModule.instance.version.getValue(0);
|
|
46
|
+
if (version === 4) {
|
|
47
|
+
const ipTotalLength = this.prevCodecModule.instance.length.getValue(0);
|
|
48
|
+
const available = ipTotalLength - this.prevCodecModule.length;
|
|
49
|
+
return available > 0 ? available : this.packet.length - this.startPos;
|
|
50
|
+
}
|
|
51
|
+
if (version === 6) {
|
|
52
|
+
const payloadLength = this.prevCodecModule.instance.plen.getValue(0);
|
|
53
|
+
return payloadLength > 0 ? payloadLength : this.packet.length - this.startPos;
|
|
54
|
+
}
|
|
55
|
+
return this.packet.length - this.startPos;
|
|
56
|
+
}
|
|
57
|
+
static #schemaCache;
|
|
58
|
+
//Class-cached SCHEMA: field closures are plain functions taking dynamic `this` via .call(this), so
|
|
59
|
+
//the structure is shareable and never rebuilt per packet. VRRP carries both v2 (RFC 3768) and v3
|
|
60
|
+
//(RFC 5798) advertisements; the version is the high nibble of byte 0 and selects how bytes 4-5 and
|
|
61
|
+
//the optional trailer are interpreted. Version-specific fields no-op when the decoded version does
|
|
62
|
+
//not match, so each octet is written by exactly one field on encode (byte-perfect round-trip).
|
|
63
|
+
get SCHEMA() {
|
|
64
|
+
return (VRRP.#schemaCache ??= VRRP.#buildSchema());
|
|
65
|
+
}
|
|
66
|
+
static #buildSchema() {
|
|
67
|
+
return {
|
|
68
|
+
type: 'object',
|
|
69
|
+
summary: 'VRRP v${version} vrid=${vrid} prio=${priority}',
|
|
70
|
+
properties: {
|
|
71
|
+
version: {
|
|
72
|
+
type: 'integer',
|
|
73
|
+
label: 'Version',
|
|
74
|
+
minimum: 0,
|
|
75
|
+
maximum: 15,
|
|
76
|
+
decode: function () {
|
|
77
|
+
this.instance.version.setValue(this.readBits(0, 1, 0, 4));
|
|
78
|
+
const version = this.instance.version.getValue(0);
|
|
79
|
+
if (version !== 2 && version !== 3)
|
|
80
|
+
this.recordError(this.instance.version.getPath(), 'VRRP version should be 2 or 3');
|
|
81
|
+
},
|
|
82
|
+
encode: function () {
|
|
83
|
+
let version = this.instance.version.getValue(2, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
84
|
+
version = version > 15 ? 15 : version;
|
|
85
|
+
version = version < 0 ? 0 : version;
|
|
86
|
+
this.instance.version.setValue(version);
|
|
87
|
+
this.writeBits(0, 1, 0, 4, version);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
type: {
|
|
91
|
+
type: 'integer',
|
|
92
|
+
label: 'Type',
|
|
93
|
+
minimum: 0,
|
|
94
|
+
maximum: 15,
|
|
95
|
+
decode: function () {
|
|
96
|
+
this.instance.type.setValue(this.readBits(0, 1, 4, 4));
|
|
97
|
+
},
|
|
98
|
+
encode: function () {
|
|
99
|
+
const type = this.instance.type.getValue(1, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
100
|
+
this.instance.type.setValue(type);
|
|
101
|
+
this.writeBits(0, 1, 4, 4, type);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
vrid: this.fieldUInt('vrid', 1, 1, 'Virtual Router ID'),
|
|
105
|
+
priority: this.fieldUInt('priority', 2, 1, 'Priority'),
|
|
106
|
+
count: this.fieldUInt('count', 3, 1, 'Count IP Addrs'),
|
|
107
|
+
authType: {
|
|
108
|
+
type: 'integer',
|
|
109
|
+
label: 'Auth Type',
|
|
110
|
+
minimum: 0,
|
|
111
|
+
maximum: 255,
|
|
112
|
+
//v2 only: byte 4 is the Authentication Type (RFC 3768 §5.3.6). In v3 byte 4 holds the
|
|
113
|
+
//reserved nibble + top of Max Adver Int, handled by rsvd/maxAdverInt below.
|
|
114
|
+
decode: function () {
|
|
115
|
+
const version = this.instance.version.getValue(0);
|
|
116
|
+
if (version !== 2)
|
|
117
|
+
return;
|
|
118
|
+
this.instance.authType.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(4, 1)));
|
|
119
|
+
},
|
|
120
|
+
encode: function () {
|
|
121
|
+
const version = this.instance.version.getValue(2);
|
|
122
|
+
if (version !== 2)
|
|
123
|
+
return;
|
|
124
|
+
const authType = this.instance.authType.getValue(0);
|
|
125
|
+
this.instance.authType.setValue(authType);
|
|
126
|
+
this.writeBytes(4, Buffer.from([authType & 0xFF]));
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
adverInt: {
|
|
130
|
+
type: 'integer',
|
|
131
|
+
label: 'Adver Int (seconds)',
|
|
132
|
+
minimum: 0,
|
|
133
|
+
maximum: 255,
|
|
134
|
+
//v2 only: byte 5, advertisement interval in whole seconds (RFC 3768 §5.3.7).
|
|
135
|
+
decode: function () {
|
|
136
|
+
const version = this.instance.version.getValue(0);
|
|
137
|
+
if (version !== 2)
|
|
138
|
+
return;
|
|
139
|
+
this.instance.adverInt.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(5, 1)));
|
|
140
|
+
},
|
|
141
|
+
encode: function () {
|
|
142
|
+
const version = this.instance.version.getValue(2);
|
|
143
|
+
if (version !== 2)
|
|
144
|
+
return;
|
|
145
|
+
const adverInt = this.instance.adverInt.getValue(1);
|
|
146
|
+
this.instance.adverInt.setValue(adverInt);
|
|
147
|
+
this.writeBytes(5, Buffer.from([adverInt & 0xFF]));
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
rsvd: {
|
|
151
|
+
type: 'integer',
|
|
152
|
+
label: 'Reserved',
|
|
153
|
+
minimum: 0,
|
|
154
|
+
maximum: 15,
|
|
155
|
+
//v3 only: high 4 bits of byte 4 are reserved (RFC 5798 §5.2.4). Preserved verbatim.
|
|
156
|
+
decode: function () {
|
|
157
|
+
const version = this.instance.version.getValue(0);
|
|
158
|
+
if (version !== 3)
|
|
159
|
+
return;
|
|
160
|
+
this.instance.rsvd.setValue(this.readBits(4, 1, 0, 4));
|
|
161
|
+
},
|
|
162
|
+
encode: function () {
|
|
163
|
+
const version = this.instance.version.getValue(2);
|
|
164
|
+
if (version !== 3)
|
|
165
|
+
return;
|
|
166
|
+
const rsvd = this.instance.rsvd.getValue(0);
|
|
167
|
+
this.instance.rsvd.setValue(rsvd);
|
|
168
|
+
this.writeBits(4, 1, 0, 4, rsvd);
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
maxAdverInt: {
|
|
172
|
+
type: 'integer',
|
|
173
|
+
label: 'Max Adver Int (centiseconds)',
|
|
174
|
+
minimum: 0,
|
|
175
|
+
maximum: 4095,
|
|
176
|
+
//v3 only: low 4 bits of byte 4 + all of byte 5 = 12-bit Max Advertisement Interval in
|
|
177
|
+
//centiseconds (RFC 5798 §5.2.5).
|
|
178
|
+
decode: function () {
|
|
179
|
+
const version = this.instance.version.getValue(0);
|
|
180
|
+
if (version !== 3)
|
|
181
|
+
return;
|
|
182
|
+
this.instance.maxAdverInt.setValue(this.readBits(4, 2, 4, 12));
|
|
183
|
+
},
|
|
184
|
+
encode: function () {
|
|
185
|
+
const version = this.instance.version.getValue(2);
|
|
186
|
+
if (version !== 3)
|
|
187
|
+
return;
|
|
188
|
+
const maxAdverInt = this.instance.maxAdverInt.getValue(0);
|
|
189
|
+
this.instance.maxAdverInt.setValue(maxAdverInt);
|
|
190
|
+
this.writeBits(4, 2, 4, 12, maxAdverInt);
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
reserved45: {
|
|
194
|
+
type: 'string',
|
|
195
|
+
label: 'Reserved',
|
|
196
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
197
|
+
hidden: true,
|
|
198
|
+
//Bytes 4-5 for any version other than 2 or 3 (a malformed or future advertisement):
|
|
199
|
+
//no v2/v3 field owns them, so capture them verbatim here to keep the round-trip
|
|
200
|
+
//lossless (decode never fails, and each octet is still written by exactly one field).
|
|
201
|
+
decode: function () {
|
|
202
|
+
const version = this.instance.version.getValue(0);
|
|
203
|
+
if (version === 2 || version === 3)
|
|
204
|
+
return;
|
|
205
|
+
this.instance.reserved45.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(4, 2)));
|
|
206
|
+
},
|
|
207
|
+
encode: function () {
|
|
208
|
+
const version = this.instance.version.getValue(2);
|
|
209
|
+
if (version === 2 || version === 3)
|
|
210
|
+
return;
|
|
211
|
+
if (this.instance.reserved45.isUndefined())
|
|
212
|
+
return;
|
|
213
|
+
this.writeBytes(4, (0, HexToBuffer_1.HexToBuffer)(this.instance.reserved45.getValue('0000')));
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
checksum: {
|
|
217
|
+
type: 'integer',
|
|
218
|
+
label: 'Checksum',
|
|
219
|
+
minimum: 0,
|
|
220
|
+
maximum: 65535,
|
|
221
|
+
//Honoured verbatim (faithful executor): decode reads it, encode writes the same value
|
|
222
|
+
//back untouched. VRRP checksums differ by version (v2 over the message only, v3 over
|
|
223
|
+
//an IP pseudo-header too), so recomputation is left to the caller.
|
|
224
|
+
decode: function () {
|
|
225
|
+
this.instance.checksum.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(6, 2)));
|
|
226
|
+
},
|
|
227
|
+
encode: function () {
|
|
228
|
+
let checksum = this.instance.checksum.getValue(0);
|
|
229
|
+
checksum = checksum > 65535 ? 65535 : checksum;
|
|
230
|
+
checksum = checksum < 0 ? 0 : checksum;
|
|
231
|
+
this.instance.checksum.setValue(checksum);
|
|
232
|
+
this.writeBytes(6, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
addresses: {
|
|
236
|
+
type: 'array',
|
|
237
|
+
label: 'IP Addresses',
|
|
238
|
+
items: {
|
|
239
|
+
type: 'string',
|
|
240
|
+
label: 'IP Address',
|
|
241
|
+
minLength: 7,
|
|
242
|
+
maxLength: 15,
|
|
243
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.IPv4
|
|
244
|
+
},
|
|
245
|
+
//Count IPvX addresses follow the fixed 8-byte header. For IPv4-carried VRRP each
|
|
246
|
+
//address is 4 bytes; IPv6-carried v3 (16-byte addresses) is not modelled here.
|
|
247
|
+
decode: function () {
|
|
248
|
+
const count = this.instance.count.getValue(0);
|
|
249
|
+
const addresses = [];
|
|
250
|
+
const available = this.#available();
|
|
251
|
+
for (let i = 0; i < count; i++) {
|
|
252
|
+
if (8 + i * 4 + 4 > available)
|
|
253
|
+
break;
|
|
254
|
+
addresses.push((0, BufferToIP_1.BufferToIPv4)(this.readBytes(8 + i * 4, 4)));
|
|
255
|
+
}
|
|
256
|
+
this.instance.addresses.setValue(addresses);
|
|
257
|
+
},
|
|
258
|
+
encode: function () {
|
|
259
|
+
const addresses = this.instance.addresses.getValue();
|
|
260
|
+
if (!addresses)
|
|
261
|
+
return;
|
|
262
|
+
addresses.forEach((address, i) => {
|
|
263
|
+
this.writeBytes(8 + i * 4, (0, IPToBuffer_1.IPv4ToBuffer)(address));
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
authData: {
|
|
268
|
+
type: 'string',
|
|
269
|
+
label: 'Authentication Data',
|
|
270
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
271
|
+
//v2 with Auth Type 1 (Simple Text Password, RFC 2338/3768): 8 trailing bytes of
|
|
272
|
+
//authentication data after the address list. Kept as hex, re-emitted verbatim.
|
|
273
|
+
decode: function () {
|
|
274
|
+
const version = this.instance.version.getValue(0);
|
|
275
|
+
const authType = this.instance.authType.getValue(0);
|
|
276
|
+
if (version !== 2 || authType !== 1)
|
|
277
|
+
return;
|
|
278
|
+
const count = this.instance.count.getValue(0);
|
|
279
|
+
//Bounded by the IP payload (mirrors the address loop) so a truncated auth packet
|
|
280
|
+
//does not pull trailing L2 padding into the authentication field.
|
|
281
|
+
if (8 + count * 4 + 8 > this.#available())
|
|
282
|
+
return;
|
|
283
|
+
this.instance.authData.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(8 + count * 4, 8)));
|
|
284
|
+
},
|
|
285
|
+
encode: function () {
|
|
286
|
+
const version = this.instance.version.getValue(2);
|
|
287
|
+
const authType = this.instance.authType.getValue(0);
|
|
288
|
+
if (version !== 2 || authType !== 1)
|
|
289
|
+
return;
|
|
290
|
+
if (this.instance.authData.isUndefined())
|
|
291
|
+
return;
|
|
292
|
+
const count = this.instance.count.getValue(0);
|
|
293
|
+
this.writeBytes(8 + count * 4, (0, HexToBuffer_1.HexToBuffer)(this.instance.authData.getValue('')));
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
match() {
|
|
300
|
+
if (!this.prevCodecModule)
|
|
301
|
+
return false;
|
|
302
|
+
const protocol = this.prevCodecModule.instance.protocol.getValue(0);
|
|
303
|
+
const nxt = this.prevCodecModule.instance.nxt.getValue(0);
|
|
304
|
+
if (protocol !== 112 && nxt !== 112)
|
|
305
|
+
return false;
|
|
306
|
+
return this.#available() >= 8;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
exports.VRRP = VRRP;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* VXLAN — Virtual eXtensible LAN (RFC 7348), a Layer-2-over-UDP overlay on UDP port 4789. An 8-byte
|
|
6
|
+
* header — Flags(1, the 'I' bit marks the VNI valid), 3 reserved bytes, the 24-bit VNI (VXLAN Network
|
|
7
|
+
* Identifier), and 1 reserved byte — is followed by a COMPLETE inner Ethernet frame.
|
|
8
|
+
*
|
|
9
|
+
* This codec decodes only its own 8-byte header (headerLength = 8); the inner Ethernet frame is left to
|
|
10
|
+
* the codec's normal recursion, which decodes it as a fresh eth/ip/… stack. That works because
|
|
11
|
+
* EthernetII.match() already accepts a tunnel (vxlan/gre/geneve/…) as its parent — the demux
|
|
12
|
+
* generalization anticipates tunnels — so an inner Ethernet frame after VXLAN is dispatched to
|
|
13
|
+
* EthernetII automatically. The whole nested packet round-trips byte-for-byte layer by layer.
|
|
14
|
+
*/
|
|
15
|
+
export declare class VXLAN extends BaseHeader {
|
|
16
|
+
#private;
|
|
17
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly nickname: string;
|
|
21
|
+
readonly matchKeys: string[];
|
|
22
|
+
match(): boolean;
|
|
23
|
+
readonly demuxProducers: DemuxProducer[];
|
|
24
|
+
}
|