@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,365 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OSPF = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
6
|
+
const BufferToIP_1 = require("../helper/BufferToIP");
|
|
7
|
+
const IPToBuffer_1 = require("../helper/IPToBuffer");
|
|
8
|
+
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
9
|
+
/**
|
|
10
|
+
* OSPF — Open Shortest Path First (OSPFv2, RFC 2328), carried directly on IP as protocol 89. This codec
|
|
11
|
+
* decodes the 24-octet common header: an 8-bit Version (`version`, offset 0), an 8-bit Message Type
|
|
12
|
+
* (`type`, offset 1; 1 Hello, 2 Database Description, 3 LS Request, 4 LS Update, 5 LS Ack), a 16-bit
|
|
13
|
+
* Packet Length (`packetLength`, offset 2), the Source Router ID (`routerId`, IPv4, offset 4), the Area
|
|
14
|
+
* ID (`areaId`, IPv4, offset 8), a 16-bit Checksum (`checksum`, offset 12, honored verbatim and never
|
|
15
|
+
* recomputed so a captured packet round-trips), a 16-bit Auth Type (`auType`, offset 14) and the 8-octet
|
|
16
|
+
* Authentication field (`auth`, hex, offset 16).
|
|
17
|
+
*
|
|
18
|
+
* For a Hello (type 1) the body is decoded field-by-field: Network Mask (offset 24), 16-bit Hello Interval
|
|
19
|
+
* (offset 28), 8-bit Options (offset 30), 8-bit Router Priority (offset 31), 32-bit Router Dead Interval
|
|
20
|
+
* (offset 32), Designated and Backup Designated Routers (IPv4, offsets 36 and 40), then the Active
|
|
21
|
+
* Neighbors list (4-octet Router IDs from offset 44 onward). For all other types the payload is kept
|
|
22
|
+
* verbatim as `rawBody` hex from offset 24. Both are bounded by min(Packet Length, the bytes the IP layer
|
|
23
|
+
* below actually made available) and never below the 24-octet header, so a lying length field can't read
|
|
24
|
+
* past the real IP payload. match() fires on IPv4 protocol 89 or IPv6 Next Header 89 with a full common
|
|
25
|
+
* header present.
|
|
26
|
+
*/
|
|
27
|
+
class OSPF extends BaseHeader_1.BaseHeader {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
this.id = 'ospf';
|
|
31
|
+
this.matchKeys = ['ipproto:89'];
|
|
32
|
+
this.name = 'Open Shortest Path First';
|
|
33
|
+
this.nickname = 'OSPF';
|
|
34
|
+
//A leaf header (OSPF LSA bodies are decoded inline / kept as rawBody).
|
|
35
|
+
this.demuxProducers = [];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Bytes of OSPF the IP layer below says are available.
|
|
39
|
+
* IPv4 carries a total-length field, so the OSPF payload is (total length - IP header length);
|
|
40
|
+
* IPv6 carries the payload length directly (plen). Mirrors the GRE #available() pattern so the
|
|
41
|
+
* body decode can be bounded by the real on-wire length rather than trusting the OSPF length
|
|
42
|
+
* field alone (which a malformed packet may overstate). Returns 0 when neither is present.
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
#available() {
|
|
46
|
+
const prev = this.prevCodecModule;
|
|
47
|
+
if (!prev)
|
|
48
|
+
return 0;
|
|
49
|
+
const ipv4TotalLength = prev.instance.length.getValue(0);
|
|
50
|
+
if (ipv4TotalLength)
|
|
51
|
+
return ipv4TotalLength - prev.length;
|
|
52
|
+
const ipv6PayloadLength = prev.instance.plen.getValue(0);
|
|
53
|
+
if (ipv6PayloadLength)
|
|
54
|
+
return ipv6PayloadLength;
|
|
55
|
+
return 0;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Header-relative end offset of the OSPF packet body: the OSPF length field, clamped down to the
|
|
59
|
+
* bytes the IP layer actually made available (#available). Never less than the 24-byte common
|
|
60
|
+
* header. Both the Hello neighbour list and the raw-body fallback are bounded by this.
|
|
61
|
+
* @private
|
|
62
|
+
*/
|
|
63
|
+
#bodyEnd() {
|
|
64
|
+
let end = this.instance.packetLength.getValue(0);
|
|
65
|
+
const available = this.#available();
|
|
66
|
+
if (available && available < end)
|
|
67
|
+
end = available;
|
|
68
|
+
if (end < 24)
|
|
69
|
+
end = 24;
|
|
70
|
+
return end;
|
|
71
|
+
}
|
|
72
|
+
static #schemaCache;
|
|
73
|
+
//Class-cached SCHEMA (field closures are plain functions taking dynamic `this` via .call(this)).
|
|
74
|
+
get SCHEMA() {
|
|
75
|
+
return (OSPF.#schemaCache ??= OSPF.#buildSchema());
|
|
76
|
+
}
|
|
77
|
+
static #buildSchema() {
|
|
78
|
+
return {
|
|
79
|
+
type: 'object',
|
|
80
|
+
summary: 'OSPF type=${type} rid=${routerId}',
|
|
81
|
+
properties: {
|
|
82
|
+
//==== Common header (24 bytes, RFC 2328 §A.3.1) ====
|
|
83
|
+
version: this.fieldUInt('version', 0, 1, 'Version'),
|
|
84
|
+
type: this.fieldUInt('type', 1, 1, 'Message Type'),
|
|
85
|
+
packetLength: this.fieldUInt('packetLength', 2, 2, 'Packet Length'),
|
|
86
|
+
routerId: {
|
|
87
|
+
type: 'string',
|
|
88
|
+
label: 'Source Router ID',
|
|
89
|
+
minLength: 7,
|
|
90
|
+
maxLength: 15,
|
|
91
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.IPv4,
|
|
92
|
+
decode: function () {
|
|
93
|
+
this.instance.routerId.setValue((0, BufferToIP_1.BufferToIPv4)(this.readBytes(4, 4)));
|
|
94
|
+
},
|
|
95
|
+
encode: function () {
|
|
96
|
+
const routerId = this.instance.routerId.getValue('0.0.0.0', (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
97
|
+
this.instance.routerId.setValue(routerId);
|
|
98
|
+
this.writeBytes(4, (0, IPToBuffer_1.IPv4ToBuffer)(routerId));
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
areaId: {
|
|
102
|
+
type: 'string',
|
|
103
|
+
label: 'Area ID',
|
|
104
|
+
minLength: 7,
|
|
105
|
+
maxLength: 15,
|
|
106
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.IPv4,
|
|
107
|
+
decode: function () {
|
|
108
|
+
this.instance.areaId.setValue((0, BufferToIP_1.BufferToIPv4)(this.readBytes(8, 4)));
|
|
109
|
+
},
|
|
110
|
+
encode: function () {
|
|
111
|
+
const areaId = this.instance.areaId.getValue('0.0.0.0', (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
112
|
+
this.instance.areaId.setValue(areaId);
|
|
113
|
+
this.writeBytes(8, (0, IPToBuffer_1.IPv4ToBuffer)(areaId));
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
//Honored verbatim: the OSPF checksum (ones-complement over the packet excluding the
|
|
117
|
+
//authentication field) is never recomputed, so a captured packet round-trips byte-for-byte.
|
|
118
|
+
checksum: this.fieldUInt('checksum', 12, 2, 'Checksum'),
|
|
119
|
+
auType: this.fieldUInt('auType', 14, 2, 'Auth Type'),
|
|
120
|
+
auth: {
|
|
121
|
+
type: 'string',
|
|
122
|
+
label: 'Authentication',
|
|
123
|
+
minLength: 0,
|
|
124
|
+
maxLength: 16,
|
|
125
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
126
|
+
decode: function () {
|
|
127
|
+
this.instance.auth.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(16, 8)));
|
|
128
|
+
},
|
|
129
|
+
encode: function () {
|
|
130
|
+
const auth = this.instance.auth.getValue('0000000000000000');
|
|
131
|
+
this.instance.auth.setValue(auth);
|
|
132
|
+
this.writeBytes(16, Buffer.from(auth, 'hex'));
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
//==== Hello body (RFC 2328 §A.3.2), decoded only for type 1 ====
|
|
136
|
+
hello: {
|
|
137
|
+
type: 'object',
|
|
138
|
+
label: 'Hello Packet',
|
|
139
|
+
properties: {
|
|
140
|
+
networkMask: {
|
|
141
|
+
type: 'string',
|
|
142
|
+
label: 'Network Mask',
|
|
143
|
+
minLength: 7,
|
|
144
|
+
maxLength: 15,
|
|
145
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.IPv4,
|
|
146
|
+
decode: function () {
|
|
147
|
+
const type = this.instance.type.getValue(0);
|
|
148
|
+
if (type !== 1)
|
|
149
|
+
return;
|
|
150
|
+
this.instance.hello.networkMask.setValue((0, BufferToIP_1.BufferToIPv4)(this.readBytes(24, 4)));
|
|
151
|
+
},
|
|
152
|
+
encode: function () {
|
|
153
|
+
const type = this.instance.type.getValue(0);
|
|
154
|
+
if (type !== 1)
|
|
155
|
+
return;
|
|
156
|
+
const networkMask = this.instance.hello.networkMask.getValue('0.0.0.0');
|
|
157
|
+
this.instance.hello.networkMask.setValue(networkMask);
|
|
158
|
+
this.writeBytes(24, (0, IPToBuffer_1.IPv4ToBuffer)(networkMask));
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
helloInterval: {
|
|
162
|
+
type: 'integer',
|
|
163
|
+
label: 'Hello Interval',
|
|
164
|
+
minimum: 0,
|
|
165
|
+
maximum: 65535,
|
|
166
|
+
decode: function () {
|
|
167
|
+
const type = this.instance.type.getValue(0);
|
|
168
|
+
if (type !== 1)
|
|
169
|
+
return;
|
|
170
|
+
this.instance.hello.helloInterval.setValue(this.readBits(28, 2, 0, 16));
|
|
171
|
+
},
|
|
172
|
+
encode: function () {
|
|
173
|
+
const type = this.instance.type.getValue(0);
|
|
174
|
+
if (type !== 1)
|
|
175
|
+
return;
|
|
176
|
+
const helloInterval = this.instance.hello.helloInterval.getValue(0);
|
|
177
|
+
this.instance.hello.helloInterval.setValue(helloInterval);
|
|
178
|
+
this.writeBits(28, 2, 0, 16, helloInterval);
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
options: {
|
|
182
|
+
type: 'integer',
|
|
183
|
+
label: 'Options',
|
|
184
|
+
minimum: 0,
|
|
185
|
+
maximum: 255,
|
|
186
|
+
decode: function () {
|
|
187
|
+
const type = this.instance.type.getValue(0);
|
|
188
|
+
if (type !== 1)
|
|
189
|
+
return;
|
|
190
|
+
this.instance.hello.options.setValue(this.readBits(30, 1, 0, 8));
|
|
191
|
+
},
|
|
192
|
+
encode: function () {
|
|
193
|
+
const type = this.instance.type.getValue(0);
|
|
194
|
+
if (type !== 1)
|
|
195
|
+
return;
|
|
196
|
+
const options = this.instance.hello.options.getValue(0);
|
|
197
|
+
this.instance.hello.options.setValue(options);
|
|
198
|
+
this.writeBits(30, 1, 0, 8, options);
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
routerPriority: {
|
|
202
|
+
type: 'integer',
|
|
203
|
+
label: 'Router Priority',
|
|
204
|
+
minimum: 0,
|
|
205
|
+
maximum: 255,
|
|
206
|
+
decode: function () {
|
|
207
|
+
const type = this.instance.type.getValue(0);
|
|
208
|
+
if (type !== 1)
|
|
209
|
+
return;
|
|
210
|
+
this.instance.hello.routerPriority.setValue(this.readBits(31, 1, 0, 8));
|
|
211
|
+
},
|
|
212
|
+
encode: function () {
|
|
213
|
+
const type = this.instance.type.getValue(0);
|
|
214
|
+
if (type !== 1)
|
|
215
|
+
return;
|
|
216
|
+
const routerPriority = this.instance.hello.routerPriority.getValue(0);
|
|
217
|
+
this.instance.hello.routerPriority.setValue(routerPriority);
|
|
218
|
+
this.writeBits(31, 1, 0, 8, routerPriority);
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
routerDeadInterval: {
|
|
222
|
+
type: 'integer',
|
|
223
|
+
label: 'Router Dead Interval',
|
|
224
|
+
minimum: 0,
|
|
225
|
+
maximum: 4294967295,
|
|
226
|
+
decode: function () {
|
|
227
|
+
const type = this.instance.type.getValue(0);
|
|
228
|
+
if (type !== 1)
|
|
229
|
+
return;
|
|
230
|
+
this.instance.hello.routerDeadInterval.setValue(this.readBits(32, 4, 0, 32));
|
|
231
|
+
},
|
|
232
|
+
encode: function () {
|
|
233
|
+
const type = this.instance.type.getValue(0);
|
|
234
|
+
if (type !== 1)
|
|
235
|
+
return;
|
|
236
|
+
const routerDeadInterval = this.instance.hello.routerDeadInterval.getValue(0);
|
|
237
|
+
this.instance.hello.routerDeadInterval.setValue(routerDeadInterval);
|
|
238
|
+
this.writeBits(32, 4, 0, 32, routerDeadInterval);
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
designatedRouter: {
|
|
242
|
+
type: 'string',
|
|
243
|
+
label: 'Designated Router',
|
|
244
|
+
minLength: 7,
|
|
245
|
+
maxLength: 15,
|
|
246
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.IPv4,
|
|
247
|
+
decode: function () {
|
|
248
|
+
const type = this.instance.type.getValue(0);
|
|
249
|
+
if (type !== 1)
|
|
250
|
+
return;
|
|
251
|
+
this.instance.hello.designatedRouter.setValue((0, BufferToIP_1.BufferToIPv4)(this.readBytes(36, 4)));
|
|
252
|
+
},
|
|
253
|
+
encode: function () {
|
|
254
|
+
const type = this.instance.type.getValue(0);
|
|
255
|
+
if (type !== 1)
|
|
256
|
+
return;
|
|
257
|
+
const designatedRouter = this.instance.hello.designatedRouter.getValue('0.0.0.0');
|
|
258
|
+
this.instance.hello.designatedRouter.setValue(designatedRouter);
|
|
259
|
+
this.writeBytes(36, (0, IPToBuffer_1.IPv4ToBuffer)(designatedRouter));
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
backupDesignatedRouter: {
|
|
263
|
+
type: 'string',
|
|
264
|
+
label: 'Backup Designated Router',
|
|
265
|
+
minLength: 7,
|
|
266
|
+
maxLength: 15,
|
|
267
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.IPv4,
|
|
268
|
+
decode: function () {
|
|
269
|
+
const type = this.instance.type.getValue(0);
|
|
270
|
+
if (type !== 1)
|
|
271
|
+
return;
|
|
272
|
+
this.instance.hello.backupDesignatedRouter.setValue((0, BufferToIP_1.BufferToIPv4)(this.readBytes(40, 4)));
|
|
273
|
+
},
|
|
274
|
+
encode: function () {
|
|
275
|
+
const type = this.instance.type.getValue(0);
|
|
276
|
+
if (type !== 1)
|
|
277
|
+
return;
|
|
278
|
+
const backupDesignatedRouter = this.instance.hello.backupDesignatedRouter.getValue('0.0.0.0');
|
|
279
|
+
this.instance.hello.backupDesignatedRouter.setValue(backupDesignatedRouter);
|
|
280
|
+
this.writeBytes(40, (0, IPToBuffer_1.IPv4ToBuffer)(backupDesignatedRouter));
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
neighbors: {
|
|
284
|
+
type: 'array',
|
|
285
|
+
label: 'Active Neighbors',
|
|
286
|
+
items: {
|
|
287
|
+
type: 'string',
|
|
288
|
+
minLength: 7,
|
|
289
|
+
maxLength: 15,
|
|
290
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.IPv4
|
|
291
|
+
},
|
|
292
|
+
//Neighbour Router IDs run from the end of the fixed Hello fields (offset 44)
|
|
293
|
+
//to the OSPF packet length, 4 bytes each. Bounded by #bodyEnd so a corrupt
|
|
294
|
+
//length field can't read past the IP payload.
|
|
295
|
+
decode: function () {
|
|
296
|
+
const type = this.instance.type.getValue(0);
|
|
297
|
+
if (type !== 1)
|
|
298
|
+
return;
|
|
299
|
+
const end = this.#bodyEnd();
|
|
300
|
+
const neighbors = [];
|
|
301
|
+
let offset = 44;
|
|
302
|
+
while (offset + 4 <= end) {
|
|
303
|
+
neighbors.push((0, BufferToIP_1.BufferToIPv4)(this.readBytes(offset, 4)));
|
|
304
|
+
offset += 4;
|
|
305
|
+
}
|
|
306
|
+
this.instance.hello.neighbors.setValue(neighbors);
|
|
307
|
+
},
|
|
308
|
+
encode: function () {
|
|
309
|
+
const type = this.instance.type.getValue(0);
|
|
310
|
+
if (type !== 1)
|
|
311
|
+
return;
|
|
312
|
+
const neighbors = this.instance.hello.neighbors.getValue();
|
|
313
|
+
if (!neighbors)
|
|
314
|
+
return;
|
|
315
|
+
let offset = 44;
|
|
316
|
+
neighbors.forEach((neighbor) => {
|
|
317
|
+
this.writeBytes(offset, (0, IPToBuffer_1.IPv4ToBuffer)(neighbor));
|
|
318
|
+
offset += 4;
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
//==== Raw body fallback for types 2-5 (DD / LS Request / LS Update / LS Ack) ====
|
|
325
|
+
//Kept verbatim (like SNMP pduRaw), byte-perfect. Bounded by #bodyEnd.
|
|
326
|
+
rawBody: {
|
|
327
|
+
type: 'string',
|
|
328
|
+
label: 'Body',
|
|
329
|
+
minLength: 0,
|
|
330
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
331
|
+
decode: function () {
|
|
332
|
+
const type = this.instance.type.getValue(0);
|
|
333
|
+
if (type === 1)
|
|
334
|
+
return;
|
|
335
|
+
const end = this.#bodyEnd();
|
|
336
|
+
if (end <= 24)
|
|
337
|
+
return;
|
|
338
|
+
this.instance.rawBody.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(24, end - 24)));
|
|
339
|
+
},
|
|
340
|
+
encode: function () {
|
|
341
|
+
const type = this.instance.type.getValue(0);
|
|
342
|
+
if (type === 1)
|
|
343
|
+
return;
|
|
344
|
+
if (this.instance.rawBody.isUndefined())
|
|
345
|
+
return;
|
|
346
|
+
this.writeBytes(24, Buffer.from(this.instance.rawBody.getValue(''), 'hex'));
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
match() {
|
|
353
|
+
if (!this.prevCodecModule)
|
|
354
|
+
return false;
|
|
355
|
+
//OSPF sits directly on IP (protocol 89). Accept the demux value from either the IPv4
|
|
356
|
+
//protocol field or the IPv6 next-header field, and require at least a full 24-byte common
|
|
357
|
+
//header of IP payload to be present.
|
|
358
|
+
const protocol = this.prevCodecModule.instance.protocol.getValue(0);
|
|
359
|
+
const nextHeader = this.prevCodecModule.instance.nxt.getValue(0);
|
|
360
|
+
if (protocol !== 89 && nextHeader !== 89)
|
|
361
|
+
return false;
|
|
362
|
+
return this.#available() >= 24;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
exports.OSPF = OSPF;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* OMRON FINS (Factory Interface Network Service), UDP port 9600. FINS is OMRON's industrial control
|
|
6
|
+
* protocol for PLC access. This codec handles the UDP-encapsulated form (the TCP form prefixes a 16-byte
|
|
7
|
+
* 'FINS' frame header + length and is not covered here).
|
|
8
|
+
*
|
|
9
|
+
* Every UDP FINS message opens with a fixed 10-byte FINS header — ICF (Information Control Field), a
|
|
10
|
+
* reserved octet, GCT (Gateway Count), the destination address triple DNA/DA1/DA2 (network / node /
|
|
11
|
+
* unit), the source address triple SNA/SA1/SA2, and SID (Service ID) — followed by a 2-byte command
|
|
12
|
+
* code (MRC/SRC, big-endian: 0x0101 Memory Area Read, 0x0102 Memory Area Write, 0x0501 Controller Status
|
|
13
|
+
* Read, …) and the command-specific parameter/data area.
|
|
14
|
+
*
|
|
15
|
+
* The parameter/data area layout is command-dependent (and for responses carries a 2-byte end code and
|
|
16
|
+
* variable data), cross-message state that this single-message codec does not sub-decode; it is kept
|
|
17
|
+
* verbatim as `body` hex (byte-perfect), bounded by the captured UDP payload. There is no length field
|
|
18
|
+
* in the FINS header — a single UDP datagram carries exactly one FINS message — so the body runs to the
|
|
19
|
+
* end of the payload and a well-formed message round-trips byte-for-byte. The command is stored as a
|
|
20
|
+
* plain integer (no enum) so any on-wire MRC/SRC value decodes and re-encodes without rejection.
|
|
21
|
+
*/
|
|
22
|
+
export declare class OmronFINS 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,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OmronFINS = 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
|
+
* OMRON FINS (Factory Interface Network Service), UDP port 9600. FINS is OMRON's industrial control
|
|
10
|
+
* protocol for PLC access. This codec handles the UDP-encapsulated form (the TCP form prefixes a 16-byte
|
|
11
|
+
* 'FINS' frame header + length and is not covered here).
|
|
12
|
+
*
|
|
13
|
+
* Every UDP FINS message opens with a fixed 10-byte FINS header — ICF (Information Control Field), a
|
|
14
|
+
* reserved octet, GCT (Gateway Count), the destination address triple DNA/DA1/DA2 (network / node /
|
|
15
|
+
* unit), the source address triple SNA/SA1/SA2, and SID (Service ID) — followed by a 2-byte command
|
|
16
|
+
* code (MRC/SRC, big-endian: 0x0101 Memory Area Read, 0x0102 Memory Area Write, 0x0501 Controller Status
|
|
17
|
+
* Read, …) and the command-specific parameter/data area.
|
|
18
|
+
*
|
|
19
|
+
* The parameter/data area layout is command-dependent (and for responses carries a 2-byte end code and
|
|
20
|
+
* variable data), cross-message state that this single-message codec does not sub-decode; it is kept
|
|
21
|
+
* verbatim as `body` hex (byte-perfect), bounded by the captured UDP payload. There is no length field
|
|
22
|
+
* in the FINS header — a single UDP datagram carries exactly one FINS message — so the body runs to the
|
|
23
|
+
* end of the payload and a well-formed message round-trips byte-for-byte. The command is stored as a
|
|
24
|
+
* plain integer (no enum) so any on-wire MRC/SRC value decodes and re-encodes without rejection.
|
|
25
|
+
*/
|
|
26
|
+
class OmronFINS extends BaseHeader_1.BaseHeader {
|
|
27
|
+
constructor() {
|
|
28
|
+
super(...arguments);
|
|
29
|
+
this.id = 'fins';
|
|
30
|
+
this.name = 'OMRON FINS';
|
|
31
|
+
this.nickname = 'FINS';
|
|
32
|
+
this.matchKeys = ['udpport:9600'];
|
|
33
|
+
//A leaf header — the parameter/data area requires per-command, cross-message parsing.
|
|
34
|
+
this.demuxProducers = [];
|
|
35
|
+
}
|
|
36
|
+
static #schemaCache;
|
|
37
|
+
get SCHEMA() {
|
|
38
|
+
return (OmronFINS.#schemaCache ??= OmronFINS.#buildSchema());
|
|
39
|
+
}
|
|
40
|
+
static #buildSchema() {
|
|
41
|
+
return {
|
|
42
|
+
type: 'object',
|
|
43
|
+
summary: 'FINS cmd=${command} ${sna}.${sa1}.${sa2}->${dna}.${da1}.${da2}',
|
|
44
|
+
properties: {
|
|
45
|
+
//ICF — Information Control Field: bit0 response-required flag, bit6 command/response,
|
|
46
|
+
//bit7 gateway; kept as a whole octet so any legal value round-trips.
|
|
47
|
+
icf: this.fieldUInt('icf', 0, 1, 'Information Control Field'),
|
|
48
|
+
//Reserved octet — kept verbatim.
|
|
49
|
+
rsv: this.fieldUInt('rsv', 1, 1, 'Reserved'),
|
|
50
|
+
//Gateway Count — how many gateways the message may still traverse.
|
|
51
|
+
gct: this.fieldUInt('gct', 2, 1, 'Gateway Count'),
|
|
52
|
+
dna: this.fieldUInt('dna', 3, 1, 'Destination Network Address'),
|
|
53
|
+
da1: this.fieldUInt('da1', 4, 1, 'Destination Node Address'),
|
|
54
|
+
da2: this.fieldUInt('da2', 5, 1, 'Destination Unit Address'),
|
|
55
|
+
sna: this.fieldUInt('sna', 6, 1, 'Source Network Address'),
|
|
56
|
+
sa1: this.fieldUInt('sa1', 7, 1, 'Source Node Address'),
|
|
57
|
+
sa2: this.fieldUInt('sa2', 8, 1, 'Source Unit Address'),
|
|
58
|
+
sid: this.fieldUInt('sid', 9, 1, 'Service ID'),
|
|
59
|
+
//Command code MRC/SRC, big-endian (0x0101 Memory Area Read, 0x0102 Write, 0x0501
|
|
60
|
+
//Controller Status Read, …). Plain integer — any on-wire value decodes/re-encodes.
|
|
61
|
+
command: this.fieldUInt('command', 10, 2, 'Command Code'),
|
|
62
|
+
//Command-specific parameter/data area, kept verbatim. Bounded by the captured UDP
|
|
63
|
+
//payload (a single datagram = one FINS message), so the whole remainder is consumed.
|
|
64
|
+
body: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
label: 'Body',
|
|
67
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
68
|
+
decode: function () {
|
|
69
|
+
const remaining = this.packet.length - this.startPos;
|
|
70
|
+
this.instance.body.setValue(remaining > 12 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(12, remaining - 12)) : '');
|
|
71
|
+
},
|
|
72
|
+
encode: function () {
|
|
73
|
+
const body = this.instance.body.getValue('');
|
|
74
|
+
if (body)
|
|
75
|
+
this.writeBytes(12, (0, HexToBuffer_1.HexToBuffer)(body));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
match() {
|
|
82
|
+
//UDP FINS rides on port 9600. The FINS header carries no strong content magic, so the
|
|
83
|
+
//well-known port is the signature: require the full 10-byte header + 2-byte command (12 bytes)
|
|
84
|
+
//to be present so a too-short datagram falls through to raw.
|
|
85
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'udp')
|
|
86
|
+
return false;
|
|
87
|
+
return this.packet.length - this.startPos >= 12;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.OmronFINS = OmronFINS;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { DemuxProducer } from '../types/DemuxProducer';
|
|
4
|
+
/**
|
|
5
|
+
* OpenFlow (Open Networking Foundation), the SDN switch/controller protocol. Runs over TLS or plain TCP,
|
|
6
|
+
* well-known port 6653 (modern; the pre-ONF IANA-assigned 6633 is still widely seen). Every OpenFlow
|
|
7
|
+
* message begins with a fixed 8-byte header (big-endian) — Version (0x01 OF 1.0, 0x04 OF 1.3, 0x05 OF 1.4,
|
|
8
|
+
* 0x06 OF 1.5), Type (0 Hello, 1 Error, 2 Echo Request, 3 Echo Reply, 5 Features Request, 6 Features
|
|
9
|
+
* Reply, …), Length (the total message octet count INCLUDING this 8-byte header) and a Transaction ID
|
|
10
|
+
* (xid, echoed on replies) — followed by the type-and-version-specific body.
|
|
11
|
+
*
|
|
12
|
+
* The body layout differs per Type and per Version (Error's code/data, Features Reply's datapath id and
|
|
13
|
+
* port descriptions, Flow-Mod's match/instructions, …) and much of it needs cross-message negotiation
|
|
14
|
+
* context, so this single-message codec keeps the body verbatim as `body` hex (byte-perfect) and does not
|
|
15
|
+
* sub-decode it. Version and Type are plain uints (no hard enum) so an unknown/experimental value still
|
|
16
|
+
* decodes and re-encodes. The Length is auto-computed from the body on encode when not supplied, else
|
|
17
|
+
* honored verbatim (a crafted message may lie); the message is bounded by Length so a second pipelined
|
|
18
|
+
* OpenFlow message or trailing bytes are left to the codec's recursion / RawData. A well-formed message
|
|
19
|
+
* round-trips byte-for-byte.
|
|
20
|
+
*/
|
|
21
|
+
export declare class OpenFlow 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,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpenFlow = 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
|
+
* OpenFlow (Open Networking Foundation), the SDN switch/controller protocol. Runs over TLS or plain TCP,
|
|
12
|
+
* well-known port 6653 (modern; the pre-ONF IANA-assigned 6633 is still widely seen). Every OpenFlow
|
|
13
|
+
* message begins with a fixed 8-byte header (big-endian) — Version (0x01 OF 1.0, 0x04 OF 1.3, 0x05 OF 1.4,
|
|
14
|
+
* 0x06 OF 1.5), Type (0 Hello, 1 Error, 2 Echo Request, 3 Echo Reply, 5 Features Request, 6 Features
|
|
15
|
+
* Reply, …), Length (the total message octet count INCLUDING this 8-byte header) and a Transaction ID
|
|
16
|
+
* (xid, echoed on replies) — followed by the type-and-version-specific body.
|
|
17
|
+
*
|
|
18
|
+
* The body layout differs per Type and per Version (Error's code/data, Features Reply's datapath id and
|
|
19
|
+
* port descriptions, Flow-Mod's match/instructions, …) and much of it needs cross-message negotiation
|
|
20
|
+
* context, so this single-message codec keeps the body verbatim as `body` hex (byte-perfect) and does not
|
|
21
|
+
* sub-decode it. Version and Type are plain uints (no hard enum) so an unknown/experimental value still
|
|
22
|
+
* decodes and re-encodes. The Length is auto-computed from the body on encode when not supplied, else
|
|
23
|
+
* honored verbatim (a crafted message may lie); the message is bounded by Length so a second pipelined
|
|
24
|
+
* OpenFlow message or trailing bytes are left to the codec's recursion / RawData. A well-formed message
|
|
25
|
+
* round-trips byte-for-byte.
|
|
26
|
+
*/
|
|
27
|
+
class OpenFlow extends BaseHeader_1.BaseHeader {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
this.id = 'openflow';
|
|
31
|
+
this.name = 'OpenFlow';
|
|
32
|
+
this.nickname = 'OpenFlow';
|
|
33
|
+
this.matchKeys = ['tcpport:6653', 'tcpport:6633'];
|
|
34
|
+
//A leaf header — the body is type-and-version-specific and negotiation-dependent.
|
|
35
|
+
this.demuxProducers = [];
|
|
36
|
+
}
|
|
37
|
+
static #schemaCache;
|
|
38
|
+
get SCHEMA() {
|
|
39
|
+
return (OpenFlow.#schemaCache ??= OpenFlow.#buildSchema());
|
|
40
|
+
}
|
|
41
|
+
static #buildSchema() {
|
|
42
|
+
return {
|
|
43
|
+
type: 'object',
|
|
44
|
+
summary: 'OpenFlow v=${version} type=${type} len=${length}',
|
|
45
|
+
properties: {
|
|
46
|
+
//Protocol version (0x01 OF 1.0, 0x04 OF 1.3, 0x05 OF 1.4, 0x06 OF 1.5). Kept as a plain
|
|
47
|
+
//uint8 — an unknown/experimental version must still decode and round-trip, so no enum.
|
|
48
|
+
version: this.fieldUInt('version', 0, 1, 'Version'),
|
|
49
|
+
//Message type (0 Hello, 1 Error, 2 Echo Request, 3 Echo Reply, 5 Features Request,
|
|
50
|
+
//6 Features Reply, …). Plain uint8 — versions differ in the type table, so no hard enum.
|
|
51
|
+
type: this.fieldUInt('type', 1, 1, 'Type'),
|
|
52
|
+
length: {
|
|
53
|
+
type: 'integer',
|
|
54
|
+
label: 'Length',
|
|
55
|
+
//Full uint16 range: Length is honored verbatim on encode, so any on-wire value
|
|
56
|
+
//(including a crafted/short one) must re-encode without Ajv rejecting it.
|
|
57
|
+
minimum: 0,
|
|
58
|
+
maximum: 65535,
|
|
59
|
+
decode: function () {
|
|
60
|
+
this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
|
|
61
|
+
},
|
|
62
|
+
encode: function () {
|
|
63
|
+
//Length counts the whole message = 8-byte header + body. Honored when supplied
|
|
64
|
+
//(a crafted message may lie); else derived from the body.
|
|
65
|
+
const provided = this.instance.length.getValue();
|
|
66
|
+
let value = (provided !== undefined && provided !== null)
|
|
67
|
+
? provided
|
|
68
|
+
: 8 + (0, HexToBuffer_1.HexToBuffer)(this.instance.body.getValue('')).length;
|
|
69
|
+
if (value > 65535) {
|
|
70
|
+
this.recordError(this.instance.length.getPath(), 'Maximum value is 65535');
|
|
71
|
+
value = 65535;
|
|
72
|
+
}
|
|
73
|
+
this.instance.length.setValue(value);
|
|
74
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(value));
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
//Transaction ID (xid): the sender picks it and the peer echoes it on the matching reply.
|
|
78
|
+
xid: this.fieldUInt('xid', 4, 4, 'Transaction ID'),
|
|
79
|
+
//The type-and-version-specific body after the 8-byte header, kept verbatim. Bounded by the
|
|
80
|
+
//message Length (the message ends at offset Length) and the captured bytes, so trailing /
|
|
81
|
+
//pipelined data is left to the codec's recursion / RawData.
|
|
82
|
+
body: {
|
|
83
|
+
type: 'string',
|
|
84
|
+
label: 'Body',
|
|
85
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
86
|
+
decode: function () {
|
|
87
|
+
const remaining = this.packet.length - this.startPos;
|
|
88
|
+
const length = this.instance.length.getValue(0);
|
|
89
|
+
let end = length;
|
|
90
|
+
if (end > remaining)
|
|
91
|
+
end = remaining;
|
|
92
|
+
this.instance.body.setValue(end > 8 ? (0, BufferToHex_1.BufferToHex)(this.readBytes(8, end - 8)) : '');
|
|
93
|
+
},
|
|
94
|
+
encode: function () {
|
|
95
|
+
const body = this.instance.body.getValue('');
|
|
96
|
+
if (body)
|
|
97
|
+
this.writeBytes(8, (0, HexToBuffer_1.HexToBuffer)(body));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
match() {
|
|
104
|
+
//OpenFlow rides on TCP port 6653 (modern) / 6633 (legacy). The 8-byte header carries no strong
|
|
105
|
+
//content magic (Version+Type are weak, one-byte hints), so the well-known port is the signature:
|
|
106
|
+
//require the full 8-byte header to be present. Selection stays port-bucketed (matchKeys), no
|
|
107
|
+
//heuristic fallback — a bare Version byte is far too weak to claim off-port traffic.
|
|
108
|
+
if (!this.prevCodecModule || this.prevCodecModule.id !== 'tcp')
|
|
109
|
+
return false;
|
|
110
|
+
return this.packet.length - this.startPos >= 8;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.OpenFlow = OpenFlow;
|