@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,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BACnetIP = 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
|
+
* BACnet/IP — the BACnet Virtual Link Control (BVLC) layer that carries BACnet over UDP (ANSI/ASHRAE
|
|
12
|
+
* 135 Annex J), UDP port 47808 (0xBAC0). Every message starts with a 4-byte BVLC header: a Type octet
|
|
13
|
+
* (0x81 for BACnet/IP), a Function octet (e.g. Original-Unicast-NPDU 0x0A, Original-Broadcast-NPDU 0x0B,
|
|
14
|
+
* Forwarded-NPDU 0x04, BVLC-Result 0x00), and a 2-byte Length that counts the WHOLE BVLC message
|
|
15
|
+
* (header + everything after). The bytes after the header are the NPDU and APDU (and, for a few
|
|
16
|
+
* functions, a BVLC-specific address prefix).
|
|
17
|
+
*
|
|
18
|
+
* This codec decodes the BVLC header structurally and keeps the NPDU + APDU verbatim as `payload` hex,
|
|
19
|
+
* bounded by the BVLC Length (so a trailing/coalesced datagram is left to RawData). The NPDU's
|
|
20
|
+
* conditional routing fields are intricate enough that structuring them belongs to a later slice. The
|
|
21
|
+
* Length is honored when supplied, else derived from the payload; a well-formed message round-trips
|
|
22
|
+
* byte-for-byte.
|
|
23
|
+
*/
|
|
24
|
+
class BACnetIP extends BaseHeader_1.BaseHeader {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
this.id = 'bacnet';
|
|
28
|
+
this.name = 'BACnet/IP';
|
|
29
|
+
this.nickname = 'BACnet';
|
|
30
|
+
this.matchKeys = ['udpport:47808'];
|
|
31
|
+
//A leaf header — the NPDU/APDU are kept verbatim (structuring them is a later slice).
|
|
32
|
+
this.demuxProducers = [];
|
|
33
|
+
}
|
|
34
|
+
static #schemaCache;
|
|
35
|
+
get SCHEMA() {
|
|
36
|
+
return (BACnetIP.#schemaCache ??= BACnetIP.#buildSchema());
|
|
37
|
+
}
|
|
38
|
+
static #buildSchema() {
|
|
39
|
+
return {
|
|
40
|
+
type: 'object',
|
|
41
|
+
summary: 'BACnet/IP func=${function}',
|
|
42
|
+
properties: {
|
|
43
|
+
type: this.fieldHex('type', 0, 1, 'Type'),
|
|
44
|
+
'function': this.fieldUInt('function', 1, 1, 'Function'),
|
|
45
|
+
length: {
|
|
46
|
+
type: 'integer',
|
|
47
|
+
label: 'Length',
|
|
48
|
+
minimum: 0,
|
|
49
|
+
maximum: 65535,
|
|
50
|
+
decode: function () {
|
|
51
|
+
this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
|
|
52
|
+
},
|
|
53
|
+
encode: function () {
|
|
54
|
+
//BVLC Length counts the whole message (4-byte header + payload). Honored when
|
|
55
|
+
//supplied (a crafted message may lie); else derived from the payload.
|
|
56
|
+
const provided = this.instance.length.getValue();
|
|
57
|
+
const value = (provided !== undefined && provided !== null)
|
|
58
|
+
? provided
|
|
59
|
+
: 4 + (0, HexToBuffer_1.HexToBuffer)(this.instance.payload.getValue('')).length;
|
|
60
|
+
this.instance.length.setValue(value);
|
|
61
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(value));
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
//NPDU + APDU (and any BVLC address prefix), kept verbatim and bounded by the BVLC Length
|
|
65
|
+
//so a trailing/coalesced datagram is left to raw.
|
|
66
|
+
payload: {
|
|
67
|
+
type: 'string',
|
|
68
|
+
label: 'Payload',
|
|
69
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
70
|
+
decode: function () {
|
|
71
|
+
const remaining = this.packet.length - this.startPos;
|
|
72
|
+
const length = this.instance.length.getValue(0);
|
|
73
|
+
let end = length >= 4 ? length : remaining;
|
|
74
|
+
if (end > remaining)
|
|
75
|
+
end = remaining;
|
|
76
|
+
this.instance.payload.setValue(end > 4 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(4, end - 4)) : '');
|
|
77
|
+
},
|
|
78
|
+
encode: function () {
|
|
79
|
+
const payload = this.instance.payload.getValue('');
|
|
80
|
+
if (payload)
|
|
81
|
+
this.writeBytes(4, (0, HexToBuffer_1.HexToBuffer)(payload));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
match() {
|
|
88
|
+
//BACnet/IP rides on UDP port 47808. Require the 4-byte BVLC header and the 0x81 type signature so
|
|
89
|
+
//non-BACnet traffic on that port falls through to raw.
|
|
90
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'udp')
|
|
91
|
+
return false;
|
|
92
|
+
if (this.packet.length - this.startPos < 4)
|
|
93
|
+
return false;
|
|
94
|
+
return this.readBytes(0, 1, true)[0] === 0x81;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.BACnetIP = BACnetIP;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* BFD — Bidirectional Forwarding Detection Control (RFC 5880), UDP port 3784 (single-hop) and 4784
|
|
6
|
+
* (multi-hop). The mandatory section is 24 bytes: a first byte carrying Version[3] (= 1) and a 5-bit
|
|
7
|
+
* Diagnostic code, a second byte carrying the 2-bit Session State (0 AdminDown / 1 Down / 2 Init /
|
|
8
|
+
* 3 Up) followed by six flag bits (P Poll, F Final, C Control-Plane-Independent, A Authentication
|
|
9
|
+
* Present, D Demand, M Multipoint), a Detect Mult (detection-time multiplier), a Length (of the whole
|
|
10
|
+
* BFD Control packet in bytes), then five 4-byte fields: My Discriminator, Your Discriminator, and the
|
|
11
|
+
* Desired Min TX / Required Min RX / Required Min Echo RX intervals (all in microseconds).
|
|
12
|
+
*
|
|
13
|
+
* If the A (Authentication Present) flag is set an optional Authentication Section follows the
|
|
14
|
+
* mandatory 24 bytes (Auth Type, Auth Len, then type-specific auth data). It is kept verbatim as
|
|
15
|
+
* `authSection` hex so any auth variant round-trips byte-for-byte; when A is clear it is empty. The
|
|
16
|
+
* Length field is honoured verbatim (not recomputed) so a captured packet re-encodes byte-for-byte.
|
|
17
|
+
* BFD Control is a leaf — nothing rides on top of it.
|
|
18
|
+
*/
|
|
19
|
+
export declare class BFD extends BaseHeader {
|
|
20
|
+
#private;
|
|
21
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly nickname: string;
|
|
25
|
+
readonly matchKeys: string[];
|
|
26
|
+
match(): boolean;
|
|
27
|
+
readonly demuxProducers: DemuxProducer[];
|
|
28
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BFD = 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
|
+
* BFD — Bidirectional Forwarding Detection Control (RFC 5880), UDP port 3784 (single-hop) and 4784
|
|
10
|
+
* (multi-hop). The mandatory section is 24 bytes: a first byte carrying Version[3] (= 1) and a 5-bit
|
|
11
|
+
* Diagnostic code, a second byte carrying the 2-bit Session State (0 AdminDown / 1 Down / 2 Init /
|
|
12
|
+
* 3 Up) followed by six flag bits (P Poll, F Final, C Control-Plane-Independent, A Authentication
|
|
13
|
+
* Present, D Demand, M Multipoint), a Detect Mult (detection-time multiplier), a Length (of the whole
|
|
14
|
+
* BFD Control packet in bytes), then five 4-byte fields: My Discriminator, Your Discriminator, and the
|
|
15
|
+
* Desired Min TX / Required Min RX / Required Min Echo RX intervals (all in microseconds).
|
|
16
|
+
*
|
|
17
|
+
* If the A (Authentication Present) flag is set an optional Authentication Section follows the
|
|
18
|
+
* mandatory 24 bytes (Auth Type, Auth Len, then type-specific auth data). It is kept verbatim as
|
|
19
|
+
* `authSection` hex so any auth variant round-trips byte-for-byte; when A is clear it is empty. The
|
|
20
|
+
* Length field is honoured verbatim (not recomputed) so a captured packet re-encodes byte-for-byte.
|
|
21
|
+
* BFD Control is a leaf — nothing rides on top of it.
|
|
22
|
+
*/
|
|
23
|
+
class BFD extends BaseHeader_1.BaseHeader {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
this.id = 'bfd';
|
|
27
|
+
this.name = 'Bidirectional Forwarding Detection';
|
|
28
|
+
this.nickname = 'BFD';
|
|
29
|
+
this.matchKeys = ['udpport:3784', 'udpport:4784'];
|
|
30
|
+
//A leaf header — nothing is carried on top of a BFD Control packet.
|
|
31
|
+
this.demuxProducers = [];
|
|
32
|
+
}
|
|
33
|
+
static #schemaCache;
|
|
34
|
+
get SCHEMA() {
|
|
35
|
+
return (BFD.#schemaCache ??= BFD.#buildSchema());
|
|
36
|
+
}
|
|
37
|
+
/** The payload length bounded by the UDP datagram (so retained padding/FCS is not absorbed). */
|
|
38
|
+
#payloadLength() {
|
|
39
|
+
let available = this.packet.length - this.startPos;
|
|
40
|
+
if (this.prevCodecModule && this.prevCodecModule.id === 'udp') {
|
|
41
|
+
const udpLength = this.prevCodecModule.instance.length.getValue(0);
|
|
42
|
+
if (udpLength >= 8 && udpLength - 8 < available)
|
|
43
|
+
available = udpLength - 8;
|
|
44
|
+
}
|
|
45
|
+
return available < 0 ? 0 : available;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A single flag bit of the second byte (byte 1), MSB-first: bitOffset 2 = P, 3 = F, 4 = C,
|
|
49
|
+
* 5 = A, 6 = D, 7 = M (bitOffsets 0..1 are the 2-bit Session State). Decode reads it as a boolean
|
|
50
|
+
* into `flags[name]`; encode writes it back — byte-for-byte identical to the hand-written pattern.
|
|
51
|
+
*/
|
|
52
|
+
static #flagBit(name, bitOffset, label) {
|
|
53
|
+
return {
|
|
54
|
+
type: 'boolean',
|
|
55
|
+
label: label,
|
|
56
|
+
decode: function () {
|
|
57
|
+
this.instance.flags[name].setValue(!!this.readBits(1, 1, bitOffset, 1));
|
|
58
|
+
},
|
|
59
|
+
encode: function () {
|
|
60
|
+
const value = !!this.instance.flags[name].getValue();
|
|
61
|
+
this.instance.flags[name].setValue(value);
|
|
62
|
+
this.writeBits(1, 1, bitOffset, 1, value ? 1 : 0);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
static #buildSchema() {
|
|
67
|
+
return {
|
|
68
|
+
type: 'object',
|
|
69
|
+
summary: 'BFD state=${flags.state} mult=${detectMult}',
|
|
70
|
+
properties: {
|
|
71
|
+
//Byte 0: Version (top 3 bits, = 1 for RFC 5880) + Diagnostic (low 5 bits). MSB-first,
|
|
72
|
+
//so version is bitOffset 0..2 and diagnostic bitOffset 3..7 of a 1-octet window.
|
|
73
|
+
version: {
|
|
74
|
+
type: 'integer',
|
|
75
|
+
label: 'Version',
|
|
76
|
+
minimum: 0,
|
|
77
|
+
maximum: 7,
|
|
78
|
+
decode: function () { this.instance.version.setValue(this.readBits(0, 1, 0, 3)); },
|
|
79
|
+
encode: function () { this.writeBits(0, 1, 0, 3, this.instance.version.getValue(1)); }
|
|
80
|
+
},
|
|
81
|
+
diagnostic: {
|
|
82
|
+
type: 'integer',
|
|
83
|
+
label: 'Diagnostic',
|
|
84
|
+
minimum: 0,
|
|
85
|
+
maximum: 31,
|
|
86
|
+
decode: function () { this.instance.diagnostic.setValue(this.readBits(0, 1, 3, 5)); },
|
|
87
|
+
encode: function () { this.writeBits(0, 1, 3, 5, this.instance.diagnostic.getValue(0)); }
|
|
88
|
+
},
|
|
89
|
+
//Byte 1: 2-bit Session State + six single-bit flags (P F C A D M), MSB-first.
|
|
90
|
+
flags: {
|
|
91
|
+
type: 'object',
|
|
92
|
+
label: 'Flags',
|
|
93
|
+
properties: {
|
|
94
|
+
state: {
|
|
95
|
+
type: 'integer',
|
|
96
|
+
label: 'Session State',
|
|
97
|
+
minimum: 0,
|
|
98
|
+
maximum: 3,
|
|
99
|
+
decode: function () { this.instance.flags.state.setValue(this.readBits(1, 1, 0, 2)); },
|
|
100
|
+
encode: function () { this.writeBits(1, 1, 0, 2, this.instance.flags.state.getValue(0)); }
|
|
101
|
+
},
|
|
102
|
+
poll: this.#flagBit('poll', 2, 'Poll'),
|
|
103
|
+
final: this.#flagBit('final', 3, 'Final'),
|
|
104
|
+
controlPlaneIndependent: this.#flagBit('controlPlaneIndependent', 4, 'Control Plane Independent'),
|
|
105
|
+
authPresent: this.#flagBit('authPresent', 5, 'Authentication Present'),
|
|
106
|
+
demand: this.#flagBit('demand', 6, 'Demand'),
|
|
107
|
+
multipoint: this.#flagBit('multipoint', 7, 'Multipoint')
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
detectMult: this.fieldUInt('detectMult', 2, 1, 'Detect Mult'),
|
|
111
|
+
//Length of the entire BFD Control packet in bytes. Honoured verbatim (a real no-auth
|
|
112
|
+
//packet carries 24) — not recomputed, so a captured packet re-encodes byte-for-byte.
|
|
113
|
+
length: this.fieldUInt('length', 3, 1, 'Length'),
|
|
114
|
+
myDiscriminator: this.fieldUInt('myDiscriminator', 4, 4, 'My Discriminator'),
|
|
115
|
+
yourDiscriminator: this.fieldUInt('yourDiscriminator', 8, 4, 'Your Discriminator'),
|
|
116
|
+
desiredMinTxInterval: this.fieldUInt('desiredMinTxInterval', 12, 4, 'Desired Min TX Interval'),
|
|
117
|
+
requiredMinRxInterval: this.fieldUInt('requiredMinRxInterval', 16, 4, 'Required Min RX Interval'),
|
|
118
|
+
requiredMinEchoRxInterval: this.fieldUInt('requiredMinEchoRxInterval', 20, 4, 'Required Min Echo RX Interval'),
|
|
119
|
+
//Optional Authentication Section (present only when the A flag is set). Kept verbatim so
|
|
120
|
+
//any auth type (simple password, keyed MD5/SHA1, meticulous) round-trips byte-for-byte;
|
|
121
|
+
//bounded by the UDP datagram. Runs after `flags` so authPresent is known.
|
|
122
|
+
authSection: {
|
|
123
|
+
type: 'string',
|
|
124
|
+
label: 'Authentication Section',
|
|
125
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
126
|
+
decode: function () {
|
|
127
|
+
const authPresent = !!this.instance.flags.authPresent.getValue();
|
|
128
|
+
const available = this.#payloadLength();
|
|
129
|
+
if (!authPresent || available <= 24) {
|
|
130
|
+
this.instance.authSection.setValue('');
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
//The auth section runs to the BFD Length (which includes it) when Length is sane;
|
|
134
|
+
//anything past that inside the UDP datagram is trailing padding, left to raw (so
|
|
135
|
+
//the A-set path matches the A-clear path, which routes such bytes to a raw layer).
|
|
136
|
+
const length = this.instance.length.getValue(0);
|
|
137
|
+
const authLength = (length >= 24 && length <= available) ? length - 24 : available - 24;
|
|
138
|
+
this.instance.authSection.setValue(authLength > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(24, authLength)) : '');
|
|
139
|
+
},
|
|
140
|
+
encode: function () {
|
|
141
|
+
const authSection = this.instance.authSection.getValue('');
|
|
142
|
+
if (authSection)
|
|
143
|
+
this.writeBytes(24, (0, HexToBuffer_1.HexToBuffer)(authSection));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
match() {
|
|
150
|
+
//Require the 24-byte mandatory section within the UDP payload (a shorter datagram on the BFD
|
|
151
|
+
//ports is not a BFD Control packet and must fall through to raw rather than claim a layer).
|
|
152
|
+
return !!this.prevCodecModule && this.prevCodecModule.id === 'udp' && this.#payloadLength() >= 24;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.BFD = BFD;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* Border Gateway Protocol (BGP-4, RFC 4271), TCP port 179. Every BGP message begins with a fixed
|
|
6
|
+
* 19-byte header — a 16-byte Marker (all ones, 0xFF, in modern BGP without authentication), a 2-byte
|
|
7
|
+
* Length (the total message octet count including this header), and a 1-byte Type (1 OPEN, 2 UPDATE,
|
|
8
|
+
* 3 NOTIFICATION, 4 KEEPALIVE) — followed by the type-specific body.
|
|
9
|
+
*
|
|
10
|
+
* The body layout differs per message type (OPEN's capabilities, UPDATE's withdrawn routes / path
|
|
11
|
+
* attributes / NLRI, NOTIFICATION's error code) and several sub-structures need cross-message and
|
|
12
|
+
* capability-negotiation context, so this single-message codec keeps the body verbatim as `body` hex
|
|
13
|
+
* (byte-perfect) and does not sub-decode it. The Length is auto-computed from the body on encode when
|
|
14
|
+
* not supplied, else honored verbatim (a crafted message may lie); the message is bounded by Length so
|
|
15
|
+
* a second pipelined BGP message or trailing bytes are left to the codec's recursion / RawData. A
|
|
16
|
+
* well-formed message round-trips byte-for-byte.
|
|
17
|
+
*/
|
|
18
|
+
export declare class BGP 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
|
+
match(): boolean;
|
|
26
|
+
readonly demuxProducers: DemuxProducer[];
|
|
27
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BGP = 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
|
+
* Border Gateway Protocol (BGP-4, RFC 4271), TCP port 179. Every BGP message begins with a fixed
|
|
12
|
+
* 19-byte header — a 16-byte Marker (all ones, 0xFF, in modern BGP without authentication), a 2-byte
|
|
13
|
+
* Length (the total message octet count including this header), and a 1-byte Type (1 OPEN, 2 UPDATE,
|
|
14
|
+
* 3 NOTIFICATION, 4 KEEPALIVE) — followed by the type-specific body.
|
|
15
|
+
*
|
|
16
|
+
* The body layout differs per message type (OPEN's capabilities, UPDATE's withdrawn routes / path
|
|
17
|
+
* attributes / NLRI, NOTIFICATION's error code) and several sub-structures need cross-message and
|
|
18
|
+
* capability-negotiation context, so this single-message codec keeps the body verbatim as `body` hex
|
|
19
|
+
* (byte-perfect) and does not sub-decode it. The Length is auto-computed from the body on encode when
|
|
20
|
+
* not supplied, else honored verbatim (a crafted message may lie); the message is bounded by Length so
|
|
21
|
+
* a second pipelined BGP message or trailing bytes are left to the codec's recursion / RawData. A
|
|
22
|
+
* well-formed message round-trips byte-for-byte.
|
|
23
|
+
*/
|
|
24
|
+
class BGP extends BaseHeader_1.BaseHeader {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
this.id = 'bgp';
|
|
28
|
+
this.name = 'Border Gateway Protocol';
|
|
29
|
+
this.nickname = 'BGP';
|
|
30
|
+
this.matchKeys = ['tcpport:179'];
|
|
31
|
+
//A leaf header — the type-specific body requires per-type, capability-dependent parsing.
|
|
32
|
+
this.demuxProducers = [];
|
|
33
|
+
}
|
|
34
|
+
static #schemaCache;
|
|
35
|
+
get SCHEMA() {
|
|
36
|
+
return (BGP.#schemaCache ??= BGP.#buildSchema());
|
|
37
|
+
}
|
|
38
|
+
static #buildSchema() {
|
|
39
|
+
return {
|
|
40
|
+
type: 'object',
|
|
41
|
+
summary: 'BGP type=${type} len=${length}',
|
|
42
|
+
properties: {
|
|
43
|
+
//The 16-byte Marker. In RFC 4271 (no authentication) it is all ones (0xFF); kept
|
|
44
|
+
//verbatim so any legacy/authenticated marker still round-trips.
|
|
45
|
+
marker: this.fieldHex('marker', 0, 16, 'Marker'),
|
|
46
|
+
length: {
|
|
47
|
+
type: 'integer',
|
|
48
|
+
label: 'Length',
|
|
49
|
+
minimum: 19,
|
|
50
|
+
maximum: 65535,
|
|
51
|
+
decode: function () {
|
|
52
|
+
this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(16, 2)));
|
|
53
|
+
},
|
|
54
|
+
encode: function () {
|
|
55
|
+
//Length counts the whole message = 19-byte header + body. Honored when supplied
|
|
56
|
+
//(a crafted message may lie); else derived from the body.
|
|
57
|
+
const provided = this.instance.length.getValue();
|
|
58
|
+
let value = (provided !== undefined && provided !== null)
|
|
59
|
+
? provided
|
|
60
|
+
: 19 + (0, HexToBuffer_1.HexToBuffer)(this.instance.body.getValue('')).length;
|
|
61
|
+
if (value > 65535) {
|
|
62
|
+
this.recordError(this.instance.length.getPath(), 'Maximum value is 65535');
|
|
63
|
+
value = 65535;
|
|
64
|
+
}
|
|
65
|
+
this.instance.length.setValue(value);
|
|
66
|
+
this.writeBytes(16, (0, NumberToBuffer_1.UInt16ToBuffer)(value));
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
type: this.fieldUInt('type', 18, 1, 'Type'),
|
|
70
|
+
//The type-specific body after the 19-byte header, kept verbatim. Bounded by the message
|
|
71
|
+
//Length (the message ends at offset Length) and the captured bytes, so trailing /
|
|
72
|
+
//pipelined data is left to the codec's recursion / RawData.
|
|
73
|
+
body: {
|
|
74
|
+
type: 'string',
|
|
75
|
+
label: 'Body',
|
|
76
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
77
|
+
decode: function () {
|
|
78
|
+
const remaining = this.packet.length - this.startPos;
|
|
79
|
+
const length = this.instance.length.getValue(0);
|
|
80
|
+
let end = length;
|
|
81
|
+
if (end > remaining)
|
|
82
|
+
end = remaining;
|
|
83
|
+
this.instance.body.setValue(end > 19 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(19, end - 19)) : '');
|
|
84
|
+
},
|
|
85
|
+
encode: function () {
|
|
86
|
+
const body = this.instance.body.getValue('');
|
|
87
|
+
if (body)
|
|
88
|
+
this.writeBytes(19, (0, HexToBuffer_1.HexToBuffer)(body));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
match() {
|
|
95
|
+
//BGP rides on TCP port 179. Require the full 19-byte header and the all-ones Marker signature
|
|
96
|
+
//(16 bytes of 0xFF) so non-BGP 179 traffic falls through to raw. The marker is a strong,
|
|
97
|
+
//distinctive content signature, but selection stays port-bucketed (matchKeys) to stay
|
|
98
|
+
//conservative like the other length-bounded TCP payload codecs.
|
|
99
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'tcp')
|
|
100
|
+
return false;
|
|
101
|
+
if (this.packet.length - this.startPos < 19)
|
|
102
|
+
return false;
|
|
103
|
+
const marker = this.readBytes(0, 16, true);
|
|
104
|
+
for (let i = 0; i < 16; i++) {
|
|
105
|
+
if (marker[i] !== 0xff)
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.BGP = BGP;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* BSAP-IP — Bristol/Emerson (Bristol Babcock) BSAP over UDP, well-known UDP port 1234. BSAP (Bristol
|
|
6
|
+
* Standard Asynchronous/Synchronous Protocol) is a proprietary master/slave SCADA protocol for Network
|
|
7
|
+
* 3000 (DPC 33xx) and ControlWave devices; ControlWave Ethernet nodes encapsulate it in UDP and default
|
|
8
|
+
* to port 1234 (documented by the Emerson/Kepware/PTC-TOPServer/AUTOSOL driver manuals).
|
|
9
|
+
*
|
|
10
|
+
* ⚠️ There is NO public authoritative on-wire byte layout for the BSAP-IP encapsulation. The serial BSAP
|
|
11
|
+
* link protocol (DLE/STX framing, 16-bit CRC-CCITT) is documented in Emerson's "BSAP Communications
|
|
12
|
+
* Application Programmer's Reference", but the IP framing (message flags / local-address / NPDU sequence
|
|
13
|
+
* & function fields) is not publicly specified, and Wireshark's built-in `bsap` dissector is an unrelated
|
|
14
|
+
* name collision (BSSAP, the GSM/ANSI A-interface over SCCP — fields `bsap.dlci.sapi`, `bsap.pdu_type`
|
|
15
|
+
* routing to `ansi_a_bsmap`/`ansi_a_dtap`), NOT this Bristol SCADA protocol.
|
|
16
|
+
*
|
|
17
|
+
* Because no field offsets can be pinned down with confidence, this is a deliberately conservative
|
|
18
|
+
* minimal slice: it claims BSAP-IP by its well-known UDP port (like ENIP claims 44818 with no content
|
|
19
|
+
* magic) and carries the entire UDP payload verbatim as `payload` hex (byte-perfect). The payload is
|
|
20
|
+
* bounded by the UDP datagram (the codec has already advanced past the UDP header), so nothing beyond
|
|
21
|
+
* the datagram is absorbed. A frame round-trips byte-for-byte, and decode never throws. Sub-decoding the
|
|
22
|
+
* BSAP message (sequence / function / routing fields) is left for when an authoritative spec is available.
|
|
23
|
+
*/
|
|
24
|
+
export declare class BSAPIP extends BaseHeader {
|
|
25
|
+
#private;
|
|
26
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly nickname: string;
|
|
30
|
+
readonly matchKeys: string[];
|
|
31
|
+
match(): boolean;
|
|
32
|
+
readonly demuxProducers: DemuxProducer[];
|
|
33
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BSAPIP = 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
|
+
* BSAP-IP — Bristol/Emerson (Bristol Babcock) BSAP over UDP, well-known UDP port 1234. BSAP (Bristol
|
|
10
|
+
* Standard Asynchronous/Synchronous Protocol) is a proprietary master/slave SCADA protocol for Network
|
|
11
|
+
* 3000 (DPC 33xx) and ControlWave devices; ControlWave Ethernet nodes encapsulate it in UDP and default
|
|
12
|
+
* to port 1234 (documented by the Emerson/Kepware/PTC-TOPServer/AUTOSOL driver manuals).
|
|
13
|
+
*
|
|
14
|
+
* ⚠️ There is NO public authoritative on-wire byte layout for the BSAP-IP encapsulation. The serial BSAP
|
|
15
|
+
* link protocol (DLE/STX framing, 16-bit CRC-CCITT) is documented in Emerson's "BSAP Communications
|
|
16
|
+
* Application Programmer's Reference", but the IP framing (message flags / local-address / NPDU sequence
|
|
17
|
+
* & function fields) is not publicly specified, and Wireshark's built-in `bsap` dissector is an unrelated
|
|
18
|
+
* name collision (BSSAP, the GSM/ANSI A-interface over SCCP — fields `bsap.dlci.sapi`, `bsap.pdu_type`
|
|
19
|
+
* routing to `ansi_a_bsmap`/`ansi_a_dtap`), NOT this Bristol SCADA protocol.
|
|
20
|
+
*
|
|
21
|
+
* Because no field offsets can be pinned down with confidence, this is a deliberately conservative
|
|
22
|
+
* minimal slice: it claims BSAP-IP by its well-known UDP port (like ENIP claims 44818 with no content
|
|
23
|
+
* magic) and carries the entire UDP payload verbatim as `payload` hex (byte-perfect). The payload is
|
|
24
|
+
* bounded by the UDP datagram (the codec has already advanced past the UDP header), so nothing beyond
|
|
25
|
+
* the datagram is absorbed. A frame round-trips byte-for-byte, and decode never throws. Sub-decoding the
|
|
26
|
+
* BSAP message (sequence / function / routing fields) is left for when an authoritative spec is available.
|
|
27
|
+
*/
|
|
28
|
+
class BSAPIP extends BaseHeader_1.BaseHeader {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
this.id = 'bsap';
|
|
32
|
+
this.name = 'Bristol/Emerson BSAP over IP';
|
|
33
|
+
this.nickname = 'BSAP-IP';
|
|
34
|
+
//Well-known UDP port 1234 (ControlWave / Network 3000 default). No content magic exists for BSAP-IP,
|
|
35
|
+
//so selection is port-bucketed only (no heuristicFallback) — the same conservative stance as ENIP.
|
|
36
|
+
this.matchKeys = ['udpport:1234'];
|
|
37
|
+
//A leaf header — the BSAP message body has no public on-wire spec to demux further.
|
|
38
|
+
this.demuxProducers = [];
|
|
39
|
+
}
|
|
40
|
+
static #schemaCache;
|
|
41
|
+
get SCHEMA() {
|
|
42
|
+
return (BSAPIP.#schemaCache ??= BSAPIP.#buildSchema());
|
|
43
|
+
}
|
|
44
|
+
static #buildSchema() {
|
|
45
|
+
return {
|
|
46
|
+
type: 'object',
|
|
47
|
+
summary: 'BSAP-IP over UDP/1234',
|
|
48
|
+
properties: {
|
|
49
|
+
//The whole UDP payload, kept verbatim. No public on-wire layout exists to sub-decode it,
|
|
50
|
+
//so it is carried as opaque hex. Bounded by the captured bytes (= the UDP datagram, since
|
|
51
|
+
//the codec advanced startPos past the UDP header), so trailing frames are not absorbed.
|
|
52
|
+
payload: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
label: 'Payload',
|
|
55
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
56
|
+
decode: function () {
|
|
57
|
+
const remaining = this.packet.length - this.startPos;
|
|
58
|
+
this.instance.payload.setValue(remaining > 0 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(0, remaining)) : '');
|
|
59
|
+
},
|
|
60
|
+
encode: function () {
|
|
61
|
+
const payload = this.instance.payload.getValue('');
|
|
62
|
+
if (payload)
|
|
63
|
+
this.writeBytes(0, (0, HexToBuffer_1.HexToBuffer)(payload));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
match() {
|
|
70
|
+
//BSAP-IP rides on UDP port 1234. There is no content signature to validate, so the well-known
|
|
71
|
+
//port is the signature; require at least one payload byte so an empty datagram falls through to
|
|
72
|
+
//raw rather than being claimed as an empty BSAP-IP layer.
|
|
73
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'udp')
|
|
74
|
+
return false;
|
|
75
|
+
return this.packet.length - this.startPos >= 1;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.BSAPIP = BSAPIP;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* Babel routing protocol (RFC 8966), carried in UDP over port 6696 (to the well-known multicast group
|
|
6
|
+
* or unicast). A Babel packet starts with a fixed 4-byte header — Magic (== 42), Version (== 2) and a
|
|
7
|
+
* 2-byte Body Length (the octet count of the packet body that follows the header, not counting the
|
|
8
|
+
* optional packet trailer) — followed by the packet body: a flat sequence of TLVs, then an optional
|
|
9
|
+
* trailer (which may only carry Pad1/PadN sub-TLVs).
|
|
10
|
+
*
|
|
11
|
+
* Each TLV is Type (1 byte) + Length (1 byte, the value byte count, NOT counting the Type/Length pair)
|
|
12
|
+
* + Value, except Pad1 (Type 0) which is a single byte with no Length/Value. Common types: 0 Pad1,
|
|
13
|
+
* 1 PadN, 2 Acknowledgment Request, 4 Hello, 5 IHU, 8 Update.
|
|
14
|
+
*
|
|
15
|
+
* Byte-perfect strategy (minimal slice): structure Magic / Version / Body Length, then carry the TLVs
|
|
16
|
+
* generically (Type + verbatim hex Value, Pad1 special-cased as a bare byte) so every TLV — including
|
|
17
|
+
* types this codec does not sub-decode — round-trips byte-for-byte. The TLV walk is bounded by Body
|
|
18
|
+
* Length AND the UDP payload (udp.length − 8), so a lying Body Length cannot read past the datagram.
|
|
19
|
+
* Body Length is honored when supplied (a crafted packet may lie) else derived from the TLVs; any bytes
|
|
20
|
+
* after the body (the packet trailer, or leftover bytes from a truncated TLV) are kept verbatim in
|
|
21
|
+
* `trailer` so the datagram is reproduced exactly. A well-formed packet round-trips byte-for-byte.
|
|
22
|
+
*/
|
|
23
|
+
export declare class Babel extends BaseHeader {
|
|
24
|
+
#private;
|
|
25
|
+
get SCHEMA(): ProtocolJSONSchema;
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly nickname: string;
|
|
29
|
+
readonly matchKeys: string[];
|
|
30
|
+
match(): boolean;
|
|
31
|
+
readonly demuxProducers: DemuxProducer[];
|
|
32
|
+
}
|