@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,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LDAP = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
6
|
+
/**
|
|
7
|
+
* LDAP — Lightweight Directory Access Protocol (RFC 4511), over TCP port 389. Each LDAPMessage is a
|
|
8
|
+
* BER-encoded ASN.1 SEQUENCE: SEQUENCE { messageID INTEGER, protocolOp CHOICE [, controls] }, where
|
|
9
|
+
* protocolOp is a context/application-tagged element identifying the operation — 0x60 bindRequest,
|
|
10
|
+
* 0x61 bindResponse, 0x63 searchRequest, 0x64 searchResultEntry, 0x65 searchResultDone,
|
|
11
|
+
* 0x42 unbindRequest, and so on.
|
|
12
|
+
*
|
|
13
|
+
* Minimal slice (byte-perfect): the outer SEQUENCE and its length are decoded, the messageID INTEGER is
|
|
14
|
+
* decoded as a signed integer, and the protocolOp is split into its TAG (one byte, e.g. 0x60) plus its
|
|
15
|
+
* BODY — the protocolOp length/content and any trailing controls — kept verbatim as `protocolOpData`
|
|
16
|
+
* hex. Re-encode rebuilds the SEQUENCE with minimal-definite lengths, re-emits the messageID with
|
|
17
|
+
* minimal two's-complement BER, and appends the protocolOp tag + verbatim body. So any operation
|
|
18
|
+
* round-trips exactly without a per-op encoder. Full BER structuring of each operation (bind DN/auth,
|
|
19
|
+
* search filter/attributes, result codes …) is a later, separate slice.
|
|
20
|
+
*
|
|
21
|
+
* Non-minimal BER lengths (long-form where short-form would do) regularize to minimal form on re-encode,
|
|
22
|
+
* exactly like SNMP — standard LDAP servers emit minimal lengths, so real traffic is byte-perfect.
|
|
23
|
+
*/
|
|
24
|
+
class LDAP extends BaseHeader_1.BaseHeader {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
this.id = 'ldap';
|
|
28
|
+
this.name = 'LDAP';
|
|
29
|
+
this.nickname = 'LDAP';
|
|
30
|
+
//Directory service on TCP port 389. A BER SEQUENCE opening a message has only a weak content
|
|
31
|
+
//signature (tag 0x30 + a plausible definite length, then an INTEGER messageID), so this is
|
|
32
|
+
//port-defined: no heuristicFallback — the port + 0x30 signature is not distinctive enough to claim
|
|
33
|
+
//arbitrary TCP segments, so LDAP is only tried on its well-known port.
|
|
34
|
+
this.matchKeys = ['tcpport:389'];
|
|
35
|
+
//A leaf header — nothing demuxes above LDAP in this minimal slice.
|
|
36
|
+
this.demuxProducers = [];
|
|
37
|
+
}
|
|
38
|
+
static #schemaCache;
|
|
39
|
+
get SCHEMA() {
|
|
40
|
+
return (LDAP.#schemaCache ??= LDAP.#buildSchema());
|
|
41
|
+
}
|
|
42
|
+
// ===== Minimal BER/DER codec (definite length only) — mirrors SNMP.ts =====
|
|
43
|
+
/** Read one TLV at `pos`; defensive against truncation (always advances, clamps to buffer). */
|
|
44
|
+
static #readTLV(buf, pos) {
|
|
45
|
+
if (pos >= buf.length)
|
|
46
|
+
return { tag: 0, contentStart: pos, contentLen: 0, next: pos + 1 };
|
|
47
|
+
const tag = buf[pos];
|
|
48
|
+
let p = pos + 1;
|
|
49
|
+
let len = p < buf.length ? buf[p] : 0;
|
|
50
|
+
p += 1;
|
|
51
|
+
if (len & 0x80) {
|
|
52
|
+
const lengthBytes = len & 0x7f;
|
|
53
|
+
len = 0;
|
|
54
|
+
for (let i = 0; i < lengthBytes; i++) {
|
|
55
|
+
len = len * 256 + (p < buf.length ? buf[p] : 0);
|
|
56
|
+
p += 1;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const contentStart = p;
|
|
60
|
+
//Clamp the content to what is actually present so a lying length cannot read out of bounds.
|
|
61
|
+
const contentLen = Math.min(len, Math.max(0, buf.length - contentStart));
|
|
62
|
+
return { tag: tag, contentStart: contentStart, contentLen: contentLen, next: contentStart + contentLen };
|
|
63
|
+
}
|
|
64
|
+
/** Decode a BER INTEGER content (big-endian two's-complement, signed). */
|
|
65
|
+
static #berInt(buf) {
|
|
66
|
+
if (buf.length === 0)
|
|
67
|
+
return 0;
|
|
68
|
+
let value = 0;
|
|
69
|
+
for (const byte of buf)
|
|
70
|
+
value = value * 256 + byte;
|
|
71
|
+
if (buf[0] & 0x80)
|
|
72
|
+
value -= Math.pow(2, 8 * buf.length);
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
/** Encode a signed integer as minimal BER INTEGER content bytes. */
|
|
76
|
+
static #intToBer(value) {
|
|
77
|
+
const bytes = [];
|
|
78
|
+
let v = Math.trunc(value);
|
|
79
|
+
if (v >= 0) {
|
|
80
|
+
do {
|
|
81
|
+
bytes.unshift(v & 0xff);
|
|
82
|
+
v = Math.floor(v / 256);
|
|
83
|
+
} while (v > 0);
|
|
84
|
+
if (bytes[0] & 0x80)
|
|
85
|
+
bytes.unshift(0);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
do {
|
|
89
|
+
bytes.unshift(v & 0xff);
|
|
90
|
+
v = Math.floor(v / 256);
|
|
91
|
+
} while (v < -1);
|
|
92
|
+
if (!(bytes[0] & 0x80))
|
|
93
|
+
bytes.unshift(0xff);
|
|
94
|
+
}
|
|
95
|
+
return Buffer.from(bytes);
|
|
96
|
+
}
|
|
97
|
+
/** Encode a definite length in minimal form (short form < 128, else long form). */
|
|
98
|
+
static #encodeLength(length) {
|
|
99
|
+
if (length < 0x80)
|
|
100
|
+
return Buffer.from([length]);
|
|
101
|
+
const bytes = [];
|
|
102
|
+
let v = length;
|
|
103
|
+
while (v > 0) {
|
|
104
|
+
bytes.unshift(v & 0xff);
|
|
105
|
+
v = Math.floor(v / 256);
|
|
106
|
+
}
|
|
107
|
+
return Buffer.from([0x80 | bytes.length, ...bytes]);
|
|
108
|
+
}
|
|
109
|
+
/** Build a complete TLV: tag + minimal length + content. */
|
|
110
|
+
static #tlv(tag, content) {
|
|
111
|
+
return Buffer.concat([Buffer.from([tag]), this.#encodeLength(content.length), content]);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Peek the outer SEQUENCE header from a short prefix and return the whole-message length
|
|
115
|
+
* (header bytes + declared content). The length field is read UNCLAMPED (the peek is only long
|
|
116
|
+
* enough for the header, so #readTLV's content clamp would wrongly cap the total). Returns 0 when
|
|
117
|
+
* the prefix does not open a well-formed SEQUENCE header.
|
|
118
|
+
*/
|
|
119
|
+
static #outerMessageLength(peek) {
|
|
120
|
+
if (peek.length < 2 || peek[0] !== 0x30)
|
|
121
|
+
return 0;
|
|
122
|
+
let hp = 1;
|
|
123
|
+
let declaredLength = peek[hp];
|
|
124
|
+
hp += 1;
|
|
125
|
+
if (declaredLength & 0x80) {
|
|
126
|
+
const lengthBytes = declaredLength & 0x7f;
|
|
127
|
+
if (lengthBytes < 1 || lengthBytes > 4)
|
|
128
|
+
return 0;
|
|
129
|
+
declaredLength = 0;
|
|
130
|
+
for (let i = 0; i < lengthBytes; i++) {
|
|
131
|
+
declaredLength = declaredLength * 256 + (hp < peek.length ? peek[hp] : 0);
|
|
132
|
+
hp += 1;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return hp + declaredLength;
|
|
136
|
+
}
|
|
137
|
+
static #buildSchema() {
|
|
138
|
+
return {
|
|
139
|
+
type: 'object',
|
|
140
|
+
summary: 'LDAP op=${protocolOpTag}',
|
|
141
|
+
properties: {
|
|
142
|
+
//LDAP is one nested BER blob, so the whole message is parsed here (and emitted in the
|
|
143
|
+
//matching encode) rather than field-by-field at fixed offsets. The remaining properties
|
|
144
|
+
//below carry only schema/label/validation metadata; they have no closures of their own.
|
|
145
|
+
messageID: {
|
|
146
|
+
type: 'integer',
|
|
147
|
+
//A real LDAP messageID is 0..maxInt, but the on-wire field is a signed BER INTEGER, so a
|
|
148
|
+
//malformed frame can carry a negative value. The bounds match the signed 32-bit range the
|
|
149
|
+
//#berInt/#intToBer helpers support, so decode of a malformed negative messageID re-encodes
|
|
150
|
+
//faithfully instead of tripping the encode-entry Ajv gate (keeping decode→encode total).
|
|
151
|
+
minimum: -2147483648,
|
|
152
|
+
maximum: 2147483647,
|
|
153
|
+
decode: function () {
|
|
154
|
+
const available = this.packet.length - this.startPos;
|
|
155
|
+
if (available <= 0)
|
|
156
|
+
return;
|
|
157
|
+
//Peek the outer SEQUENCE header to learn the whole-message length, then read the
|
|
158
|
+
//whole message (non-dry-run) so headerLength/endPos cover exactly the BER message.
|
|
159
|
+
const peek = this.readBytes(0, available < 8 ? available : 8, true);
|
|
160
|
+
const declaredTotal = LDAP.#outerMessageLength(peek);
|
|
161
|
+
const total = Math.min(declaredTotal > 0 ? declaredTotal : available, available);
|
|
162
|
+
const buf = this.readBytes(0, total > 0 ? total : 0);
|
|
163
|
+
const message = LDAP.#readTLV(buf, 0);
|
|
164
|
+
let p = message.contentStart;
|
|
165
|
+
const messageIdTLV = LDAP.#readTLV(buf, p);
|
|
166
|
+
this.instance.messageID.setValue(LDAP.#berInt(buf.subarray(messageIdTLV.contentStart, messageIdTLV.next)));
|
|
167
|
+
p = messageIdTLV.next;
|
|
168
|
+
//protocolOp: its TAG is one byte (e.g. 0x60 bindRequest); its BODY — the op's own
|
|
169
|
+
//length/content plus any trailing controls, all the way to the end of the outer
|
|
170
|
+
//SEQUENCE — is kept verbatim so any operation round-trips without a per-op encoder.
|
|
171
|
+
if (p >= message.next)
|
|
172
|
+
return;
|
|
173
|
+
this.instance.protocolOpTag.setValue(buf[p]);
|
|
174
|
+
this.instance.protocolOpData.setValue(buf.subarray(p + 1, message.next).toString('hex'));
|
|
175
|
+
},
|
|
176
|
+
encode: function () {
|
|
177
|
+
const messageID = this.instance.messageID.getValue(0);
|
|
178
|
+
const protocolOpTag = this.instance.protocolOpTag.getValue(0x60);
|
|
179
|
+
const protocolOpData = this.instance.protocolOpData.getValue('');
|
|
180
|
+
const protocolOp = Buffer.concat([
|
|
181
|
+
Buffer.from([protocolOpTag & 0xff]),
|
|
182
|
+
Buffer.from(protocolOpData, 'hex')
|
|
183
|
+
]);
|
|
184
|
+
const message = LDAP.#tlv(0x30, Buffer.concat([
|
|
185
|
+
LDAP.#tlv(0x02, LDAP.#intToBer(messageID)),
|
|
186
|
+
protocolOp
|
|
187
|
+
]));
|
|
188
|
+
this.writeBytes(0, message);
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
//The protocolOp CHOICE tag: 0x60 bindRequest, 0x61 bindResponse, 0x63 searchRequest,
|
|
192
|
+
//0x64 searchResultEntry, 0x65 searchResultDone, 0x66 modifyRequest, 0x67 modifyResponse,
|
|
193
|
+
//0x68 addRequest, 0x69 addResponse, 0x4a delRequest, 0x42 unbindRequest, 0x73 extendedReq …
|
|
194
|
+
protocolOpTag: { type: 'integer', label: 'Protocol Op Tag', minimum: 0, maximum: 255 },
|
|
195
|
+
//The protocolOp body (op length/content + any controls) kept verbatim as hex — see decode.
|
|
196
|
+
protocolOpData: { type: 'string', label: 'Protocol Op Data', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
match() {
|
|
201
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'tcp')
|
|
202
|
+
return false;
|
|
203
|
+
const available = this.packet.length - this.startPos;
|
|
204
|
+
if (available < 2)
|
|
205
|
+
return false;
|
|
206
|
+
const peek = this.readBytes(0, available < 8 ? available : 8, true);
|
|
207
|
+
//Must open with a BER SEQUENCE (0x30) whose definite length is well-formed and plausible.
|
|
208
|
+
if (peek[0] !== 0x30)
|
|
209
|
+
return false;
|
|
210
|
+
const declaredTotal = LDAP.#outerMessageLength(peek);
|
|
211
|
+
if (declaredTotal <= 0)
|
|
212
|
+
return false;
|
|
213
|
+
//Locate the byte after the outer length; for a real LDAPMessage it is the messageID INTEGER
|
|
214
|
+
//tag (0x02). This strengthens the otherwise-weak port+0x30 signature and rejects non-LDAP
|
|
215
|
+
//SEQUENCE-like traffic on 389.
|
|
216
|
+
let hp = 1;
|
|
217
|
+
const lenByte = peek[1];
|
|
218
|
+
hp += 1;
|
|
219
|
+
if (lenByte & 0x80)
|
|
220
|
+
hp += (lenByte & 0x7f);
|
|
221
|
+
if (hp < peek.length && peek[hp] !== 0x02)
|
|
222
|
+
return false;
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
exports.LDAP = LDAP;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* LDP — Label Distribution Protocol (RFC 5036, MPLS label distribution), UDP + TCP port 646. UDP/646
|
|
6
|
+
* carries the Hello discovery messages (multicast to 224.0.0.2); TCP/646 carries the session (LSP
|
|
7
|
+
* establishment, label mappings). Every LDP PDU begins with a fixed 10-byte common header — a 2-byte
|
|
8
|
+
* Version (== 1), a 2-byte PDU Length, a 4-byte LSR ID (the label switch router's identifier, an IPv4
|
|
9
|
+
* address), and a 2-byte Label Space id — followed by one or more messages. The PDU Length counts every
|
|
10
|
+
* octet after the Version and PDU Length fields (i.e. LSR ID + Label Space + the messages).
|
|
11
|
+
*
|
|
12
|
+
* Each message is a 1-bit U (unknown) flag + a 15-bit Message Type (0x0100 Hello, 0x0200 Initialization,
|
|
13
|
+
* 0x0400 Label Mapping, …), a 2-byte Message Length, a 4-byte Message Id, and the message's parameter
|
|
14
|
+
* TLVs. The per-message and per-TLV layout is type-dependent, so this codec keeps the common header
|
|
15
|
+
* structured and the messages verbatim as `messages` hex (byte-perfect), bounded by the PDU Length (the
|
|
16
|
+
* PDU ends at offset 4 + PDU Length) and by the transport payload (UDP length − 8), so a second pipelined
|
|
17
|
+
* PDU or trailing bytes are left to the codec's recursion / RawData. The PDU Length is auto-computed from
|
|
18
|
+
* the LSR ID + Label Space + messages on encode when not supplied, else honored verbatim (a crafted PDU
|
|
19
|
+
* may lie). A well-formed PDU round-trips byte-for-byte; per-message / per-TLV decoding is a later
|
|
20
|
+
* enrichment.
|
|
21
|
+
*/
|
|
22
|
+
export declare class LDP extends BaseHeader {
|
|
23
|
+
#private;
|
|
24
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly name: string;
|
|
27
|
+
readonly nickname: string;
|
|
28
|
+
readonly matchKeys: string[];
|
|
29
|
+
match(): boolean;
|
|
30
|
+
readonly demuxProducers: DemuxProducer[];
|
|
31
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LDP = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
6
|
+
const HexToBuffer_1 = require("../helper/HexToBuffer");
|
|
7
|
+
const BufferToNumber_1 = require("../helper/BufferToNumber");
|
|
8
|
+
const NumberToBuffer_1 = require("../helper/NumberToBuffer");
|
|
9
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
10
|
+
/**
|
|
11
|
+
* LDP — Label Distribution Protocol (RFC 5036, MPLS label distribution), UDP + TCP port 646. UDP/646
|
|
12
|
+
* carries the Hello discovery messages (multicast to 224.0.0.2); TCP/646 carries the session (LSP
|
|
13
|
+
* establishment, label mappings). Every LDP PDU begins with a fixed 10-byte common header — a 2-byte
|
|
14
|
+
* Version (== 1), a 2-byte PDU Length, a 4-byte LSR ID (the label switch router's identifier, an IPv4
|
|
15
|
+
* address), and a 2-byte Label Space id — followed by one or more messages. The PDU Length counts every
|
|
16
|
+
* octet after the Version and PDU Length fields (i.e. LSR ID + Label Space + the messages).
|
|
17
|
+
*
|
|
18
|
+
* Each message is a 1-bit U (unknown) flag + a 15-bit Message Type (0x0100 Hello, 0x0200 Initialization,
|
|
19
|
+
* 0x0400 Label Mapping, …), a 2-byte Message Length, a 4-byte Message Id, and the message's parameter
|
|
20
|
+
* TLVs. The per-message and per-TLV layout is type-dependent, so this codec keeps the common header
|
|
21
|
+
* structured and the messages verbatim as `messages` hex (byte-perfect), bounded by the PDU Length (the
|
|
22
|
+
* PDU ends at offset 4 + PDU Length) and by the transport payload (UDP length − 8), so a second pipelined
|
|
23
|
+
* PDU or trailing bytes are left to the codec's recursion / RawData. The PDU Length is auto-computed from
|
|
24
|
+
* the LSR ID + Label Space + messages on encode when not supplied, else honored verbatim (a crafted PDU
|
|
25
|
+
* may lie). A well-formed PDU round-trips byte-for-byte; per-message / per-TLV decoding is a later
|
|
26
|
+
* enrichment.
|
|
27
|
+
*/
|
|
28
|
+
class LDP extends BaseHeader_1.BaseHeader {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
this.id = 'ldp';
|
|
32
|
+
this.name = 'Label Distribution Protocol';
|
|
33
|
+
this.nickname = 'LDP';
|
|
34
|
+
//LDP discovery (Hello) over UDP 646, session over TCP 646.
|
|
35
|
+
this.matchKeys = ['tcpport:646', 'udpport:646'];
|
|
36
|
+
//A leaf header — per-message / per-TLV parsing is kept verbatim for now.
|
|
37
|
+
this.demuxProducers = [];
|
|
38
|
+
}
|
|
39
|
+
static #schemaCache;
|
|
40
|
+
get SCHEMA() {
|
|
41
|
+
return (LDP.#schemaCache ??= LDP.#buildSchema());
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Header-relative end offset of the bytes this LDP layer may read, bounded by the transport payload so
|
|
45
|
+
* a lying PDU Length never reads past the real payload into a trailing FCS. Over UDP the bound is
|
|
46
|
+
* (udp.length − 8); over TCP (a session byte stream with no per-PDU record prefix) it is the captured
|
|
47
|
+
* remainder. The PDU Length further bounds the consumed span inside this window (see the messages
|
|
48
|
+
* field), leaving trailing / pipelined PDUs to the codec's recursion.
|
|
49
|
+
*/
|
|
50
|
+
#payloadEnd() {
|
|
51
|
+
let end = this.packet.length - this.startPos;
|
|
52
|
+
const prev = this.prevCodecModule;
|
|
53
|
+
if (prev && prev.id === 'udp') {
|
|
54
|
+
const udpLength = prev.instance.length.getValue(0);
|
|
55
|
+
if (udpLength >= 8 && udpLength - 8 < end)
|
|
56
|
+
end = udpLength - 8;
|
|
57
|
+
}
|
|
58
|
+
return end < 0 ? 0 : end;
|
|
59
|
+
}
|
|
60
|
+
static #buildSchema() {
|
|
61
|
+
return {
|
|
62
|
+
type: 'object',
|
|
63
|
+
summary: 'LDP lsr=${lsrId}:${labelSpace}',
|
|
64
|
+
properties: {
|
|
65
|
+
//Version of the LDP protocol; RFC 5036 defines version 1.
|
|
66
|
+
version: this.fieldUInt('version', 0, 2, 'Version'),
|
|
67
|
+
pduLength: {
|
|
68
|
+
type: 'integer',
|
|
69
|
+
label: 'PDU Length',
|
|
70
|
+
minimum: 0,
|
|
71
|
+
maximum: 65535,
|
|
72
|
+
decode: function () {
|
|
73
|
+
this.instance.pduLength.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
|
|
74
|
+
},
|
|
75
|
+
encode: function () {
|
|
76
|
+
//PDU Length counts every octet after the Version + PDU Length fields = LSR ID(4) +
|
|
77
|
+
//Label Space(2) + messages. Honored when supplied (a crafted PDU may lie); else
|
|
78
|
+
//derived from the messages hex (like BGP's Length).
|
|
79
|
+
const provided = this.instance.pduLength.getValue();
|
|
80
|
+
let value = (provided !== undefined && provided !== null)
|
|
81
|
+
? provided
|
|
82
|
+
: 6 + (0, HexToBuffer_1.HexToBuffer)(this.instance.messages.getValue('')).length;
|
|
83
|
+
if (value > 65535) {
|
|
84
|
+
this.recordError(this.instance.pduLength.getPath(), 'Maximum value is 65535');
|
|
85
|
+
value = 65535;
|
|
86
|
+
}
|
|
87
|
+
if (value < 0) {
|
|
88
|
+
this.recordError(this.instance.pduLength.getPath(), 'Minimum value is 0');
|
|
89
|
+
value = 0;
|
|
90
|
+
}
|
|
91
|
+
this.instance.pduLength.setValue(value);
|
|
92
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(value));
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
//The LSR (Label Switch Router) identifier — a 4-byte value carried as an IPv4 address.
|
|
96
|
+
lsrId: this.fieldIPv4('lsrId', 4, 'LSR ID'),
|
|
97
|
+
//The Label Space id: 0 means the platform-wide (per-router) label space; non-zero names a
|
|
98
|
+
//per-interface label space.
|
|
99
|
+
labelSpace: this.fieldUInt('labelSpace', 8, 2, 'Label Space'),
|
|
100
|
+
//The messages after the 10-byte common header, kept verbatim. Bounded by the PDU Length
|
|
101
|
+
//(the PDU ends at offset 4 + PDU Length) and by the transport payload, so a second pipelined
|
|
102
|
+
//PDU or trailing bytes are left to the codec's recursion / RawData.
|
|
103
|
+
messages: {
|
|
104
|
+
type: 'string',
|
|
105
|
+
label: 'Messages',
|
|
106
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
107
|
+
decode: function () {
|
|
108
|
+
const payloadEnd = this.#payloadEnd();
|
|
109
|
+
const pduLength = this.instance.pduLength.getValue(0);
|
|
110
|
+
let end = 4 + pduLength;
|
|
111
|
+
if (end > payloadEnd)
|
|
112
|
+
end = payloadEnd;
|
|
113
|
+
this.instance.messages.setValue(end > 10 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(10, end - 10)) : '');
|
|
114
|
+
},
|
|
115
|
+
encode: function () {
|
|
116
|
+
const messages = this.instance.messages.getValue('');
|
|
117
|
+
if (messages)
|
|
118
|
+
this.writeBytes(10, (0, HexToBuffer_1.HexToBuffer)(messages));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
match() {
|
|
125
|
+
//LDP rides UDP/TCP port 646 (selected via the udpport:646 / tcpport:646 buckets). This stays a
|
|
126
|
+
//port-bucket protocol: matchKeys only, NO heuristicFallback — a 2-byte Version of 1 alone is too
|
|
127
|
+
//weak to claim LDP off port 646, and non-LDP traffic on 646 must fall through to raw. Require the
|
|
128
|
+
//full 10-byte common header within the transport payload and Version == 1.
|
|
129
|
+
if (!this.prevCodecModule)
|
|
130
|
+
return false;
|
|
131
|
+
if (this.prevCodecModule.id !== 'udp' && this.prevCodecModule.id !== 'tcp')
|
|
132
|
+
return false;
|
|
133
|
+
if (this.#payloadEnd() < 10)
|
|
134
|
+
return false;
|
|
135
|
+
return (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(0, 2, true)) === 1;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.LDP = LDP;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* LISP — Locator/ID Separation Protocol control plane (RFC 6830), UDP port 4342. Every LISP control
|
|
6
|
+
* message begins with a 4-bit Type in the high nibble of the first octet (1 Map-Request, 2 Map-Reply,
|
|
7
|
+
* 3 Map-Register, 4 Map-Notify, 8 Encapsulated Control Message), followed by a type-specific body of
|
|
8
|
+
* flags, a Nonce, and AFI-tagged EID/RLOC records.
|
|
9
|
+
*
|
|
10
|
+
* The per-type body layout (Map-Request's Source-EID + ITR-RLOC list + record EID-prefixes,
|
|
11
|
+
* Map-Reply/Register's locator records, the ECM's inner LISP-encapsulated control packet) is
|
|
12
|
+
* self-delimited by AFI-tagged, count-driven sub-structures with no single length field, so this
|
|
13
|
+
* minimal codec keeps the whole message verbatim as `message` hex (byte-perfect) and only surfaces the
|
|
14
|
+
* Type nibble for display. The message is bounded by the UDP payload (it runs to the end of the
|
|
15
|
+
* datagram); `message` is authoritative on encode (re-emitting every byte, including the Type nibble),
|
|
16
|
+
* so a well-formed message round-trips byte-for-byte.
|
|
17
|
+
*
|
|
18
|
+
* The data plane (UDP 4341) whose payload is an inner IP packet is intentionally NOT handled here — it
|
|
19
|
+
* would require the IP headers to match inside a LISP tunnel; left to a later enrichment.
|
|
20
|
+
*/
|
|
21
|
+
export declare class LISP extends BaseHeader {
|
|
22
|
+
#private;
|
|
23
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly nickname: string;
|
|
27
|
+
readonly matchKeys: string[];
|
|
28
|
+
match(): boolean;
|
|
29
|
+
readonly demuxProducers: DemuxProducer[];
|
|
30
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LISP = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
6
|
+
const HexToBuffer_1 = require("../helper/HexToBuffer");
|
|
7
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
8
|
+
/**
|
|
9
|
+
* LISP — Locator/ID Separation Protocol control plane (RFC 6830), UDP port 4342. Every LISP control
|
|
10
|
+
* message begins with a 4-bit Type in the high nibble of the first octet (1 Map-Request, 2 Map-Reply,
|
|
11
|
+
* 3 Map-Register, 4 Map-Notify, 8 Encapsulated Control Message), followed by a type-specific body of
|
|
12
|
+
* flags, a Nonce, and AFI-tagged EID/RLOC records.
|
|
13
|
+
*
|
|
14
|
+
* The per-type body layout (Map-Request's Source-EID + ITR-RLOC list + record EID-prefixes,
|
|
15
|
+
* Map-Reply/Register's locator records, the ECM's inner LISP-encapsulated control packet) is
|
|
16
|
+
* self-delimited by AFI-tagged, count-driven sub-structures with no single length field, so this
|
|
17
|
+
* minimal codec keeps the whole message verbatim as `message` hex (byte-perfect) and only surfaces the
|
|
18
|
+
* Type nibble for display. The message is bounded by the UDP payload (it runs to the end of the
|
|
19
|
+
* datagram); `message` is authoritative on encode (re-emitting every byte, including the Type nibble),
|
|
20
|
+
* so a well-formed message round-trips byte-for-byte.
|
|
21
|
+
*
|
|
22
|
+
* The data plane (UDP 4341) whose payload is an inner IP packet is intentionally NOT handled here — it
|
|
23
|
+
* would require the IP headers to match inside a LISP tunnel; left to a later enrichment.
|
|
24
|
+
*/
|
|
25
|
+
class LISP extends BaseHeader_1.BaseHeader {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
this.id = 'lisp';
|
|
29
|
+
this.name = 'Locator/ID Separation Protocol';
|
|
30
|
+
this.nickname = 'LISP';
|
|
31
|
+
this.matchKeys = ['udpport:4342'];
|
|
32
|
+
//A leaf header — the per-type, AFI/count-driven body requires cross-record context to sub-decode.
|
|
33
|
+
this.demuxProducers = [];
|
|
34
|
+
}
|
|
35
|
+
static #schemaCache;
|
|
36
|
+
get SCHEMA() {
|
|
37
|
+
return (LISP.#schemaCache ??= LISP.#buildSchema());
|
|
38
|
+
}
|
|
39
|
+
static #buildSchema() {
|
|
40
|
+
return {
|
|
41
|
+
type: 'object',
|
|
42
|
+
summary: 'LISP type=${type}',
|
|
43
|
+
properties: {
|
|
44
|
+
//Type: the high 4 bits of the first octet (RFC 6830 §5.3). 1 Map-Request, 2 Map-Reply,
|
|
45
|
+
//3 Map-Register, 4 Map-Notify, 8 Encapsulated Control Message — kept as a plain 4-bit
|
|
46
|
+
//integer (no enum: an unknown/out-of-spec type is still a legal decode and must
|
|
47
|
+
//re-encode). Display only: `message` re-emits the whole octet, so this write is
|
|
48
|
+
//overwritten by `message` when present; it lets a Type-only crafted message still emit.
|
|
49
|
+
type: {
|
|
50
|
+
type: 'integer',
|
|
51
|
+
label: 'Type',
|
|
52
|
+
minimum: 0,
|
|
53
|
+
maximum: 15,
|
|
54
|
+
decode: function () {
|
|
55
|
+
this.instance.type.setValue(this.readBits(0, 1, 0, 4));
|
|
56
|
+
},
|
|
57
|
+
encode: function () {
|
|
58
|
+
const node = this.instance.type;
|
|
59
|
+
let value = node.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
60
|
+
if (value > 15) {
|
|
61
|
+
this.recordError(node.getPath(), 'Maximum value is 15');
|
|
62
|
+
value = 15;
|
|
63
|
+
}
|
|
64
|
+
if (value < 0) {
|
|
65
|
+
this.recordError(node.getPath(), 'Minimum value is 0');
|
|
66
|
+
value = 0;
|
|
67
|
+
}
|
|
68
|
+
node.setValue(value);
|
|
69
|
+
this.writeBits(0, 1, 0, 4, value);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
//The whole control message kept verbatim (Type nibble included), bounded by the UDP
|
|
73
|
+
//payload — a LISP control message has no length field and runs to the end of the
|
|
74
|
+
//datagram. Authoritative on encode (re-emits every byte); UDP delivers exactly one
|
|
75
|
+
//datagram so there is no trailing/pipelined data to leave for the codec's recursion.
|
|
76
|
+
message: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
label: 'Message',
|
|
79
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
80
|
+
decode: function () {
|
|
81
|
+
const remaining = this.packet.length - this.startPos;
|
|
82
|
+
this.instance.message.setValue(remaining > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(0, remaining)) : '');
|
|
83
|
+
},
|
|
84
|
+
encode: function () {
|
|
85
|
+
const message = this.instance.message.getValue('');
|
|
86
|
+
if (message)
|
|
87
|
+
this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(message));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
match() {
|
|
94
|
+
//LISP control rides on UDP port 4342. The message carries no strong content magic (the leading
|
|
95
|
+
//nibble is just a small type number), so the well-known port is the signature. Require a
|
|
96
|
+
//minimum payload (Type octet + a partial fixed header) so a stray/empty UDP/4342 datagram
|
|
97
|
+
//falls through to raw rather than being claimed as a 1-byte LISP message.
|
|
98
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'udp')
|
|
99
|
+
return false;
|
|
100
|
+
return this.packet.length - this.startPos >= 4;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.LISP = LISP;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* LLC — IEEE 802.2 Logical Link Control, the header of an IEEE 802.3 (length-encapsulated) Ethernet
|
|
6
|
+
* frame. In an Ethernet II frame bytes 12–13 are an EtherType (always ≥ 0x0600); in an 802.3 frame they
|
|
7
|
+
* are instead a *length* (≤ 0x05DC = 1500), and the frame payload begins with this 3-or-4-byte LLC
|
|
8
|
+
* header: a 1-byte DSAP (Destination Service Access Point), a 1-byte SSAP (Source SAP), and a Control
|
|
9
|
+
* field that is 1 byte for U-format (its two low bits are 0b11) or 2 bytes for I/S-format.
|
|
10
|
+
*
|
|
11
|
+
* LLC is a content-heuristic child of Ethernet (and 802.1Q): it claims a frame only when the parent's
|
|
12
|
+
* EtherType value is ≤ 0x05DC, which by construction can never be a real EtherType — so the Ethernet II
|
|
13
|
+
* path is completely untouched. It carries no length of its own; the child it routes to (STP by DSAP
|
|
14
|
+
* 0x42, IS-IS by 0xFE, or SNAP by 0xAA which re-exposes an EtherType) bounds itself, and any trailing
|
|
15
|
+
* 802.3 minimum-frame padding falls to the codec's RawData catch-all. The DSAP is exposed as an `llcsap`
|
|
16
|
+
* demux key. A well-formed frame round-trips byte-for-byte.
|
|
17
|
+
*/
|
|
18
|
+
export declare class LLC extends BaseHeader {
|
|
19
|
+
#private;
|
|
20
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly nickname: string;
|
|
24
|
+
readonly matchKeys: string[];
|
|
25
|
+
readonly demuxProducers: DemuxProducer[];
|
|
26
|
+
match(): boolean;
|
|
27
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LLC = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
6
|
+
const HexToBuffer_1 = require("../helper/HexToBuffer");
|
|
7
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
8
|
+
/**
|
|
9
|
+
* LLC — IEEE 802.2 Logical Link Control, the header of an IEEE 802.3 (length-encapsulated) Ethernet
|
|
10
|
+
* frame. In an Ethernet II frame bytes 12–13 are an EtherType (always ≥ 0x0600); in an 802.3 frame they
|
|
11
|
+
* are instead a *length* (≤ 0x05DC = 1500), and the frame payload begins with this 3-or-4-byte LLC
|
|
12
|
+
* header: a 1-byte DSAP (Destination Service Access Point), a 1-byte SSAP (Source SAP), and a Control
|
|
13
|
+
* field that is 1 byte for U-format (its two low bits are 0b11) or 2 bytes for I/S-format.
|
|
14
|
+
*
|
|
15
|
+
* LLC is a content-heuristic child of Ethernet (and 802.1Q): it claims a frame only when the parent's
|
|
16
|
+
* EtherType value is ≤ 0x05DC, which by construction can never be a real EtherType — so the Ethernet II
|
|
17
|
+
* path is completely untouched. It carries no length of its own; the child it routes to (STP by DSAP
|
|
18
|
+
* 0x42, IS-IS by 0xFE, or SNAP by 0xAA which re-exposes an EtherType) bounds itself, and any trailing
|
|
19
|
+
* 802.3 minimum-frame padding falls to the codec's RawData catch-all. The DSAP is exposed as an `llcsap`
|
|
20
|
+
* demux key. A well-formed frame round-trips byte-for-byte.
|
|
21
|
+
*/
|
|
22
|
+
class LLC extends BaseHeader_1.BaseHeader {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
this.id = 'llc';
|
|
26
|
+
this.name = 'Logical Link Control';
|
|
27
|
+
this.nickname = 'LLC';
|
|
28
|
+
//A content-heuristic child (no matchKeys) — claimed when the Ethernet/VLAN parent's EtherType is a
|
|
29
|
+
//length (≤ 0x05DC), which cannot be a real EtherType.
|
|
30
|
+
this.matchKeys = [];
|
|
31
|
+
this.demuxProducers = [{ field: 'dsap', namespace: 'llcsap', kind: 'uint' }];
|
|
32
|
+
}
|
|
33
|
+
static #schemaCache;
|
|
34
|
+
get SCHEMA() {
|
|
35
|
+
return (LLC.#schemaCache ??= LLC.#buildSchema());
|
|
36
|
+
}
|
|
37
|
+
static #buildSchema() {
|
|
38
|
+
return {
|
|
39
|
+
type: 'object',
|
|
40
|
+
summary: 'LLC dsap=${dsap} ssap=${ssap}',
|
|
41
|
+
properties: {
|
|
42
|
+
//Destination Service Access Point — the field the `llcsap` demux key is produced from.
|
|
43
|
+
//Kept as the raw byte (not masked for the I/G bit) so it re-emits exactly and 0x42/0xAA/0xFE
|
|
44
|
+
//route unambiguously.
|
|
45
|
+
dsap: this.fieldUInt('dsap', 0, 1, 'DSAP'),
|
|
46
|
+
ssap: this.fieldUInt('ssap', 1, 1, 'SSAP'),
|
|
47
|
+
//Control: 1 byte for Unnumbered format (low two bits 0b11), else 2 bytes (Information /
|
|
48
|
+
//Supervisory). Stored as hex preserving its on-wire length so encode reproduces it exactly;
|
|
49
|
+
//because the non-dry read grows headerLength, the child layer starts at the correct offset.
|
|
50
|
+
control: {
|
|
51
|
+
type: 'string',
|
|
52
|
+
label: 'Control',
|
|
53
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
54
|
+
decode: function () {
|
|
55
|
+
const first = this.readBytes(2, 1, true)[0];
|
|
56
|
+
const length = (first & 0x03) === 0x03 ? 1 : 2;
|
|
57
|
+
this.instance.control.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(2, length)));
|
|
58
|
+
},
|
|
59
|
+
encode: function () {
|
|
60
|
+
//Default to a U-format UI control (0x03) when crafting without a supplied value.
|
|
61
|
+
const control = this.instance.control.getValue('03');
|
|
62
|
+
this.writeBytes(2, (0, HexToBuffer_1.HexToBuffer)(control && control.length >= 2 ? control : '03'));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
match() {
|
|
69
|
+
const prev = this.prevCodecModule;
|
|
70
|
+
if (!prev || (prev.id !== 'eth' && prev.id !== 'vlan'))
|
|
71
|
+
return false;
|
|
72
|
+
//IEEE 802.3: bytes 12–13 ≤ 1500 (0x05DC) are a length → an 802.3/LLC frame. Valid EtherTypes are
|
|
73
|
+
//all ≥ 0x0600, so this gate never claims an Ethernet II frame (the 1501–1535 gap is left to raw,
|
|
74
|
+
//matching prior behavior). Require at least the 3-byte minimum LLC header.
|
|
75
|
+
const value = parseInt(prev.instance.etherType.getValue(''), 16);
|
|
76
|
+
if (!(value >= 0 && value <= 0x05dc))
|
|
77
|
+
return false;
|
|
78
|
+
return this.packet.length - this.startPos >= 3;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.LLC = LLC;
|