@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,1067 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Goose = void 0;
|
|
7
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
8
|
+
const node_tlv_1 = __importDefault(require("node-tlv"));
|
|
9
|
+
const HexToNumber_1 = require("../helper/HexToNumber");
|
|
10
|
+
const NumberToBERHex_1 = require("../helper/NumberToBERHex");
|
|
11
|
+
const NumberToHex_1 = require("../helper/NumberToHex");
|
|
12
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
13
|
+
const NumberToBERBuffer_1 = require("../helper/NumberToBERBuffer");
|
|
14
|
+
const BufferToNumber_1 = require("../helper/BufferToNumber");
|
|
15
|
+
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
16
|
+
const NumberToBuffer_1 = require("../helper/NumberToBuffer");
|
|
17
|
+
const GetBERIntegerLengthFromBuffer_1 = require("../lib/GetBERIntegerLengthFromBuffer");
|
|
18
|
+
var ItemDataType;
|
|
19
|
+
(function (ItemDataType) {
|
|
20
|
+
ItemDataType["Boolean"] = "Boolean";
|
|
21
|
+
ItemDataType["INT8"] = "INT8";
|
|
22
|
+
ItemDataType["INT16"] = "INT16";
|
|
23
|
+
ItemDataType["INT32"] = "INT32";
|
|
24
|
+
ItemDataType["INT64"] = "INT64";
|
|
25
|
+
ItemDataType["INT8U"] = "INT8U";
|
|
26
|
+
ItemDataType["INT16U"] = "INT16U";
|
|
27
|
+
ItemDataType["INT32U"] = "INT32U";
|
|
28
|
+
ItemDataType["FLOAT32"] = "FLOAT32";
|
|
29
|
+
ItemDataType["CODEDENUM"] = "CODED-ENUM";
|
|
30
|
+
ItemDataType["OCTETSTRING"] = "OCTET-STRING";
|
|
31
|
+
ItemDataType["VISIBLESTRING"] = "VISIBLE-STRING";
|
|
32
|
+
ItemDataType["TimeStamp"] = "TimeStamp";
|
|
33
|
+
ItemDataType["Quality"] = "Quality";
|
|
34
|
+
ItemDataType["Structure"] = "Structure";
|
|
35
|
+
})(ItemDataType || (ItemDataType = {}));
|
|
36
|
+
class Goose extends BaseHeader_1.BaseHeader {
|
|
37
|
+
constructor() {
|
|
38
|
+
super(...arguments);
|
|
39
|
+
this.TLVChild = [];
|
|
40
|
+
this.SCHEMA = {
|
|
41
|
+
type: 'object',
|
|
42
|
+
properties: {
|
|
43
|
+
appid: {
|
|
44
|
+
type: 'integer',
|
|
45
|
+
minimum: 0,
|
|
46
|
+
maximum: 65535,
|
|
47
|
+
label: 'APPID',
|
|
48
|
+
decode: () => {
|
|
49
|
+
this.instance.appid.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(0, 2)));
|
|
50
|
+
},
|
|
51
|
+
encode: () => {
|
|
52
|
+
const APPID = this.instance.appid.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
53
|
+
this.instance.appid.setValue(APPID);
|
|
54
|
+
this.writeBytes(0, (0, NumberToBuffer_1.UInt16ToBuffer)(APPID));
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
length: {
|
|
58
|
+
type: 'integer',
|
|
59
|
+
minimum: 0,
|
|
60
|
+
maximum: 65535,
|
|
61
|
+
label: 'Length',
|
|
62
|
+
decode: () => {
|
|
63
|
+
this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
|
|
64
|
+
},
|
|
65
|
+
encode: () => {
|
|
66
|
+
const length = this.instance.length.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
67
|
+
if (length > 0) {
|
|
68
|
+
this.instance.length.setValue(length);
|
|
69
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(length));
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
this.addPostSelfEncodeHandler(() => {
|
|
73
|
+
const finalLength = parseInt(this.instance.length.getValue().toString());
|
|
74
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(finalLength));
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
reserved1: {
|
|
80
|
+
type: 'object',
|
|
81
|
+
label: 'Reserved1',
|
|
82
|
+
properties: {
|
|
83
|
+
simulated: {
|
|
84
|
+
type: 'boolean',
|
|
85
|
+
label: 'Simulated',
|
|
86
|
+
decode: () => {
|
|
87
|
+
this.instance.reserved1.simulated.setValue(!!this.readBits(4, 2, 0, 1));
|
|
88
|
+
},
|
|
89
|
+
encode: () => {
|
|
90
|
+
const simulated = this.instance.reserved1.simulated.getValue(false);
|
|
91
|
+
this.writeBits(4, 2, 0, 1, simulated ? 1 : 0);
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
reserved: {
|
|
95
|
+
type: 'number',
|
|
96
|
+
minimum: 0,
|
|
97
|
+
maximum: 32767,
|
|
98
|
+
label: 'Reserved',
|
|
99
|
+
decode: () => {
|
|
100
|
+
this.instance.reserved1.reserved.setValue(this.readBits(4, 2, 1, 15));
|
|
101
|
+
},
|
|
102
|
+
encode: () => {
|
|
103
|
+
const reserved = this.instance.reserved1.reserved.getValue(0);
|
|
104
|
+
this.writeBits(4, 2, 1, 15, reserved);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
reserved2: {
|
|
110
|
+
type: 'object',
|
|
111
|
+
label: 'Reserved2',
|
|
112
|
+
properties: {
|
|
113
|
+
reserved: {
|
|
114
|
+
type: 'number',
|
|
115
|
+
minimum: 0,
|
|
116
|
+
maximum: 65535,
|
|
117
|
+
label: 'Reserved',
|
|
118
|
+
decode: () => {
|
|
119
|
+
this.instance.reserved2.reserved.setValue(this.readBits(6, 2, 0, 16));
|
|
120
|
+
},
|
|
121
|
+
encode: () => {
|
|
122
|
+
const reserved = this.instance.reserved2.reserved.getValue(0);
|
|
123
|
+
this.writeBits(6, 2, 0, 16, reserved);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
goosePdu: {
|
|
129
|
+
type: 'object',
|
|
130
|
+
label: 'GOOSE PDU',
|
|
131
|
+
decode: () => {
|
|
132
|
+
let readTLVBufferLength = this.packet.length - this.startPos - 8;
|
|
133
|
+
while (!this.TLVInstance) {
|
|
134
|
+
try {
|
|
135
|
+
const buffer = this.readBytes(8, readTLVBufferLength, true);
|
|
136
|
+
this.TLVInstance = node_tlv_1.default.parse(buffer);
|
|
137
|
+
const tagWithLength = buffer.toString('hex').replace(this.TLVInstance.bValue.toString('hex'), '#').split('#');
|
|
138
|
+
const tagWithLengthBytes = Math.max(...tagWithLength.map((value) => Math.ceil(value.length / 2)));
|
|
139
|
+
const TLVBufferLength = this.TLVInstance.bValue.length + tagWithLengthBytes;
|
|
140
|
+
this.TLVInstance = node_tlv_1.default.parse(this.readBytes(8, TLVBufferLength, false));
|
|
141
|
+
}
|
|
142
|
+
catch (e) {
|
|
143
|
+
readTLVBufferLength -= 1;
|
|
144
|
+
if (!readTLVBufferLength)
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
this.TLVChild = this.TLVInstance ? this.TLVInstance.getChild() : [];
|
|
149
|
+
//Capture the exact goosePdu region so it can be surfaced/reproduced if the PDU
|
|
150
|
+
//turns out to be unparseable. Use the parsed outer TLV's byte span when we have
|
|
151
|
+
//it, else the remaining buffer.
|
|
152
|
+
const goosePduByteLength = this.TLVInstance
|
|
153
|
+
? this.TLVInstance.bTag.length + this.TLVInstance.bLength.length + this.TLVInstance.bValue.length
|
|
154
|
+
: this.packet.length - this.startPos - 8;
|
|
155
|
+
const goosePduRawHex = (0, BufferToHex_1.BufferToHex)(this.readBytes(8, goosePduByteLength, true));
|
|
156
|
+
//Runs after every child field decode: if none produced structured content, the
|
|
157
|
+
//PDU is effectively unparsed - expose the raw bytes as a visible field so the
|
|
158
|
+
//analyst sees the malformed region instead of a deceptively-empty PDU.
|
|
159
|
+
this.addPostSelfDecodeHandler(() => {
|
|
160
|
+
if (this.goosePduHasStructuredContent())
|
|
161
|
+
return;
|
|
162
|
+
this.instance.goosePdu.raw.setValue(goosePduRawHex);
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
encode: () => {
|
|
166
|
+
if (this.goosePduRawFallbackActive()) {
|
|
167
|
+
//Re-emit the unparsed goosePdu bytes exactly as captured. length is kept as
|
|
168
|
+
//decoded (it may itself be inconsistent in a malformed frame).
|
|
169
|
+
const rawBuffer = Buffer.from(this.instance.goosePdu.raw.getValue().toString(), 'hex');
|
|
170
|
+
this.writeBytes(8, rawBuffer);
|
|
171
|
+
if (this.instance.length.getValue() > 0)
|
|
172
|
+
return;
|
|
173
|
+
this.instance.length.setValue(8 + rawBuffer.length);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
let buffers = Buffer.from([]);
|
|
177
|
+
this.TLVChild.forEach((item) => buffers = Buffer.concat([buffers, item.bTag, item.bLength, item.bValue]));
|
|
178
|
+
const goosePduTLV = new node_tlv_1.default(0x61, buffers);
|
|
179
|
+
const goosePduBuffer = Buffer.concat([goosePduTLV.bTag, goosePduTLV.bLength, goosePduTLV.bValue]);
|
|
180
|
+
this.writeBytes(8, goosePduBuffer);
|
|
181
|
+
/**
|
|
182
|
+
* Update the length only if it is not set
|
|
183
|
+
* Update length(APPID's length + Length's length + Reserved1's length + Reserved2's length + goosePdu's length)
|
|
184
|
+
*/
|
|
185
|
+
if (this.instance.length.getValue() > 0)
|
|
186
|
+
return;
|
|
187
|
+
this.instance.length.setValue(2 + 2 + 2 + 2 + goosePduBuffer.length);
|
|
188
|
+
},
|
|
189
|
+
properties: {
|
|
190
|
+
gocbRef: {
|
|
191
|
+
type: 'string',
|
|
192
|
+
maxLength: 129,
|
|
193
|
+
label: 'GoCBReference',
|
|
194
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.ASCII,
|
|
195
|
+
decode: () => {
|
|
196
|
+
const gocbRefTLV = this.TLVChild.find((tlv) => tlv.getTag('number') === 0x80);
|
|
197
|
+
if (!gocbRefTLV)
|
|
198
|
+
return this.recordError(this.instance.goosePdu.gocbRef.getPath(), 'Not Found');
|
|
199
|
+
this.instance.goosePdu.gocbRef.setValue(gocbRefTLV.getValue('buffer').toString('ascii'));
|
|
200
|
+
},
|
|
201
|
+
encode: () => {
|
|
202
|
+
const gocbRefValue = this.instance.goosePdu.gocbRef.getValue('', (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
203
|
+
if (!gocbRefValue)
|
|
204
|
+
return;
|
|
205
|
+
let gocbRefBuffer = Buffer.from(gocbRefValue, 'ascii');
|
|
206
|
+
if (gocbRefBuffer.length > 129) {
|
|
207
|
+
this.recordError(this.instance.goosePdu.gocbRef.getPath(), 'This VisibleString shall have a maximum size of 129 octets');
|
|
208
|
+
gocbRefBuffer = gocbRefBuffer.subarray(0, 129);
|
|
209
|
+
}
|
|
210
|
+
this.TLVChild.push(new node_tlv_1.default(0x80, gocbRefBuffer));
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
timeAllowedtoLive: {
|
|
214
|
+
type: 'number',
|
|
215
|
+
minimum: 0,
|
|
216
|
+
maximum: 4294967295,
|
|
217
|
+
label: 'TimeAllowedtoLive',
|
|
218
|
+
decode: () => {
|
|
219
|
+
const timeAllowedtoLiveString = this.TLVChild.find((tlv) => tlv.getTag('number') === 0x81)?.getValue('hex');
|
|
220
|
+
if (!timeAllowedtoLiveString)
|
|
221
|
+
return this.recordError(this.instance.goosePdu.timeAllowedtoLive.getPath(), 'Not Found');
|
|
222
|
+
this.instance.goosePdu.timeAllowedtoLive.setValue((0, HexToNumber_1.HexToUInt32)(timeAllowedtoLiveString));
|
|
223
|
+
},
|
|
224
|
+
encode: () => {
|
|
225
|
+
let timeAllowedtoLiveValue = this.instance.goosePdu.timeAllowedtoLive.getValue(-1, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
226
|
+
if (timeAllowedtoLiveValue === -1)
|
|
227
|
+
return;
|
|
228
|
+
if (timeAllowedtoLiveValue < 1 || timeAllowedtoLiveValue > 4294967295) {
|
|
229
|
+
this.recordError(this.instance.goosePdu.timeAllowedtoLive.getPath(), 'This INTEGER value shall have a range of 1 to 4294967295');
|
|
230
|
+
timeAllowedtoLiveValue = 4294967295;
|
|
231
|
+
}
|
|
232
|
+
const timeAllowedtoLiveTLV = new node_tlv_1.default(0x81, (0, NumberToBERBuffer_1.UInt32ToBERBuffer)(timeAllowedtoLiveValue));
|
|
233
|
+
this.TLVChild.push(timeAllowedtoLiveTLV);
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
datSet: {
|
|
237
|
+
type: 'string',
|
|
238
|
+
maxLength: 129,
|
|
239
|
+
label: 'DatSet',
|
|
240
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.ASCII,
|
|
241
|
+
decode: () => {
|
|
242
|
+
const datSetTLV = this.TLVChild.find((tlv) => tlv.getTag('number') === 0x82);
|
|
243
|
+
if (!datSetTLV)
|
|
244
|
+
return this.recordError(this.instance.goosePdu.datSet.getPath(), 'Not Found');
|
|
245
|
+
this.instance.goosePdu.datSet.setValue(datSetTLV.getValue('buffer').toString('ascii'));
|
|
246
|
+
},
|
|
247
|
+
encode: () => {
|
|
248
|
+
const datSetValue = this.instance.goosePdu.datSet.getValue('', (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
249
|
+
if (!datSetValue)
|
|
250
|
+
return;
|
|
251
|
+
let datSetBuffer = Buffer.from(datSetValue, 'ascii');
|
|
252
|
+
if (datSetBuffer.length > 129) {
|
|
253
|
+
this.recordError(this.instance.goosePdu.datSet.getPath(), 'This VisibleString shall have a maximum size of 129 octets');
|
|
254
|
+
datSetBuffer = datSetBuffer.subarray(0, 129);
|
|
255
|
+
}
|
|
256
|
+
this.TLVChild.push(new node_tlv_1.default(0x82, datSetBuffer));
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
goID: {
|
|
260
|
+
type: 'string',
|
|
261
|
+
maxLength: 65,
|
|
262
|
+
label: 'GoID',
|
|
263
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.ASCII,
|
|
264
|
+
decode: () => {
|
|
265
|
+
const goIDTLV = this.TLVChild.find((tlv) => tlv.getTag('number') === 0x83);
|
|
266
|
+
if (!goIDTLV)
|
|
267
|
+
return this.recordError(this.instance.goosePdu.goID.getPath(), 'Not Found');
|
|
268
|
+
this.instance.goosePdu.goID.setValue(goIDTLV.getValue('buffer').toString('ascii'));
|
|
269
|
+
},
|
|
270
|
+
encode: () => {
|
|
271
|
+
const goIDValue = this.instance.goosePdu.goID.getValue('', (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
272
|
+
if (!goIDValue)
|
|
273
|
+
return;
|
|
274
|
+
let goIDBuffer = Buffer.from(goIDValue, 'ascii');
|
|
275
|
+
if (goIDBuffer.length > 65) {
|
|
276
|
+
this.recordError(this.instance.goosePdu.goID.getPath(), 'This VisibleString shall have a maximum size of 65 octets');
|
|
277
|
+
goIDBuffer = goIDBuffer.subarray(0, 65);
|
|
278
|
+
}
|
|
279
|
+
this.TLVChild.push(new node_tlv_1.default(0x83, goIDBuffer));
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
t: {
|
|
283
|
+
type: 'string',
|
|
284
|
+
label: 'TimeStamp',
|
|
285
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.BIGINT,
|
|
286
|
+
decode: () => {
|
|
287
|
+
const tStr = this.TLVChild.find((tlv) => tlv.getTag('number') === 0x84)?.getValue('hex');
|
|
288
|
+
if (!tStr)
|
|
289
|
+
return this.recordError(this.instance.goosePdu.t.getPath(), 'Not Found');
|
|
290
|
+
this.instance.goosePdu.t.setValue(BigInt(`0x${tStr}`).toString());
|
|
291
|
+
},
|
|
292
|
+
encode: () => {
|
|
293
|
+
const tStr = this.instance.goosePdu.t.getValue('', (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
294
|
+
if (!tStr)
|
|
295
|
+
return;
|
|
296
|
+
const tBigIntValue = BigInt(tStr);
|
|
297
|
+
const tTLV = new node_tlv_1.default(0x84, Buffer.from(tBigIntValue.toString(16).padStart(8 * 2, '0'), 'hex'));
|
|
298
|
+
this.TLVChild.push(tTLV);
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
stNum: {
|
|
302
|
+
type: 'integer',
|
|
303
|
+
minimum: 0,
|
|
304
|
+
maximum: 4294967295,
|
|
305
|
+
label: 'StNum',
|
|
306
|
+
decode: () => {
|
|
307
|
+
const stNumStr = this.TLVChild.find((tlv) => tlv.getTag('number') === 0x85)?.getValue('hex');
|
|
308
|
+
if (!stNumStr)
|
|
309
|
+
return this.recordError(this.instance.goosePdu.stNum.getPath(), 'Not Found');
|
|
310
|
+
this.instance.goosePdu.stNum.setValue((0, HexToNumber_1.HexToUInt32)(stNumStr));
|
|
311
|
+
if (this.instance.goosePdu.stNum.getValue() < 1 || this.instance.goosePdu.stNum.getValue() > 4294967295)
|
|
312
|
+
this.recordError(this.instance.goosePdu.stNum.getPath(), 'This INTEGER value shall have a range of 1 to 4294967295');
|
|
313
|
+
},
|
|
314
|
+
encode: () => {
|
|
315
|
+
let stNumValue = this.instance.goosePdu.stNum.getValue(-1, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
316
|
+
if (stNumValue < 0)
|
|
317
|
+
return;
|
|
318
|
+
if (stNumValue > 4294967295) {
|
|
319
|
+
stNumValue = 4294967295;
|
|
320
|
+
this.recordError(this.instance.goosePdu.stNum.getPath(), 'This INTEGER value shall have a range of 1 to 4294967295');
|
|
321
|
+
}
|
|
322
|
+
if (stNumValue === undefined)
|
|
323
|
+
return this.recordError(this.instance.goosePdu.stNum.getPath(), 'Not Found');
|
|
324
|
+
const stNumTLV = new node_tlv_1.default(0x85, (0, NumberToBERBuffer_1.UInt32ToBERBuffer)(stNumValue));
|
|
325
|
+
this.TLVChild.push(stNumTLV);
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
sqNum: {
|
|
329
|
+
type: 'integer',
|
|
330
|
+
minimum: 0,
|
|
331
|
+
maximum: 4294967295,
|
|
332
|
+
label: 'SqNum',
|
|
333
|
+
decode: () => {
|
|
334
|
+
const sqNumStr = this.TLVChild.find((tlv) => tlv.getTag('number') === 0x86)?.getValue('hex');
|
|
335
|
+
if (!sqNumStr)
|
|
336
|
+
return this.recordError(this.instance.goosePdu.sqNum.getPath(), 'Not Found');
|
|
337
|
+
this.instance.goosePdu.sqNum.setValue((0, HexToNumber_1.HexToUInt32)(sqNumStr));
|
|
338
|
+
},
|
|
339
|
+
encode: () => {
|
|
340
|
+
let sqNumValue = this.instance.goosePdu.sqNum.getValue(-1, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
341
|
+
if (sqNumValue < 0)
|
|
342
|
+
return;
|
|
343
|
+
if (sqNumValue > 4294967295) {
|
|
344
|
+
sqNumValue = 4294967295;
|
|
345
|
+
this.recordError(this.instance.goosePdu.sqNum.getPath(), 'This INTEGER value shall have a range of 1 to 4294967295');
|
|
346
|
+
}
|
|
347
|
+
if (sqNumValue === undefined)
|
|
348
|
+
return this.recordError(this.instance.goosePdu.sqNum.getPath(), 'Not Found');
|
|
349
|
+
const sqNumTLV = new node_tlv_1.default(0x86, (0, NumberToBERBuffer_1.UInt32ToBERBuffer)(sqNumValue));
|
|
350
|
+
this.TLVChild.push(sqNumTLV);
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
simulation: {
|
|
354
|
+
type: 'boolean',
|
|
355
|
+
label: 'Simulation',
|
|
356
|
+
decode: () => {
|
|
357
|
+
const simulationStr = this.TLVChild.find((tlv) => tlv.getTag('number') === 0x87)?.getValue('hex');
|
|
358
|
+
if (!simulationStr)
|
|
359
|
+
return this.recordError(this.instance.goosePdu.simulation.getPath(), 'Not Found');
|
|
360
|
+
const simulationNum = parseInt(simulationStr, 16);
|
|
361
|
+
if (simulationNum > 1)
|
|
362
|
+
this.recordError(this.instance.goosePdu.simulation.getPath(), 'This Boolean shall have a range of TRUE, FALSE');
|
|
363
|
+
this.instance.goosePdu.simulation.setValue(!!simulationNum);
|
|
364
|
+
},
|
|
365
|
+
encode: () => {
|
|
366
|
+
const simulationValue = this.instance.goosePdu.simulation.getValue(undefined, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
367
|
+
if (simulationValue === undefined)
|
|
368
|
+
return;
|
|
369
|
+
const simulationNum = simulationValue ? 1 : 0;
|
|
370
|
+
const simulationTLV = new node_tlv_1.default(0x87, Buffer.from(simulationNum.toString(16).padStart(2, '0'), 'hex'));
|
|
371
|
+
this.TLVChild.push(simulationTLV);
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
confRev: {
|
|
375
|
+
type: 'integer',
|
|
376
|
+
label: 'ConfRev',
|
|
377
|
+
decode: () => {
|
|
378
|
+
const confRevStr = this.TLVChild.find((tlv) => tlv.getTag('number') === 0x88)?.getValue('hex');
|
|
379
|
+
if (!confRevStr)
|
|
380
|
+
return this.recordError(this.instance.goosePdu.confRev.getPath(), 'Not Found');
|
|
381
|
+
this.instance.goosePdu.confRev.setValue((0, HexToNumber_1.HexToUInt32)(confRevStr));
|
|
382
|
+
},
|
|
383
|
+
encode: () => {
|
|
384
|
+
let confRevValue = this.instance.goosePdu.confRev.getValue(-1, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
385
|
+
if (confRevValue > 4294967295) {
|
|
386
|
+
confRevValue = 4294967295;
|
|
387
|
+
this.recordError(this.instance.goosePdu.confRev.getPath(), 'This INTEGER value shall have a range of 0 to 4294967295');
|
|
388
|
+
}
|
|
389
|
+
if (confRevValue === -1)
|
|
390
|
+
return;
|
|
391
|
+
const confRevTLV = new node_tlv_1.default(0x88, (0, NumberToBERBuffer_1.UInt32ToBERBuffer)(confRevValue));
|
|
392
|
+
this.TLVChild.push(confRevTLV);
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
ndsCom: {
|
|
396
|
+
type: 'boolean',
|
|
397
|
+
label: 'NdsCom',
|
|
398
|
+
decode: () => {
|
|
399
|
+
const ndsComStr = this.TLVChild.find((tlv) => tlv.getTag('number') === 0x89)?.getValue('hex');
|
|
400
|
+
if (!ndsComStr)
|
|
401
|
+
return this.recordError(this.instance.goosePdu.ndsCom.getPath(), 'Not Found');
|
|
402
|
+
const ndsComNum = parseInt(ndsComStr, 16);
|
|
403
|
+
if (ndsComNum > 1)
|
|
404
|
+
this.recordError(this.instance.goosePdu.ndsCom.getPath(), 'This Boolean shall have a range of TRUE, FALSE');
|
|
405
|
+
this.instance.goosePdu.ndsCom.setValue(!!ndsComNum);
|
|
406
|
+
},
|
|
407
|
+
encode: () => {
|
|
408
|
+
const ndsComValue = this.instance.goosePdu.ndsCom.getValue(undefined, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
409
|
+
if (ndsComValue === undefined)
|
|
410
|
+
return;
|
|
411
|
+
const ndsComNum = ndsComValue ? 1 : 0;
|
|
412
|
+
const ndsComTLV = new node_tlv_1.default(0x89, Buffer.from(ndsComNum.toString(16).padStart(2, '0'), 'hex'));
|
|
413
|
+
this.TLVChild.push(ndsComTLV);
|
|
414
|
+
}
|
|
415
|
+
},
|
|
416
|
+
numDatSetEntries: {
|
|
417
|
+
type: 'integer',
|
|
418
|
+
label: 'NumDatSetEntries',
|
|
419
|
+
decode: () => {
|
|
420
|
+
const numDatSetEntriesStr = this.TLVChild.find((tlv) => tlv.getTag('number') === 0x8A)?.getValue('hex');
|
|
421
|
+
if (!numDatSetEntriesStr)
|
|
422
|
+
return this.recordError(this.instance.goosePdu.numDatSetEntries.getPath(), 'Not Found');
|
|
423
|
+
this.instance.goosePdu.numDatSetEntries.setValue(parseInt(numDatSetEntriesStr, 16));
|
|
424
|
+
},
|
|
425
|
+
encode: () => {
|
|
426
|
+
const numDatSetEntriesValue = this.instance.goosePdu.numDatSetEntries.getValue(undefined, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
427
|
+
if (numDatSetEntriesValue === undefined)
|
|
428
|
+
return;
|
|
429
|
+
const numDatSetEntriesTLV = new node_tlv_1.default(0x8A, (0, NumberToBERBuffer_1.UInt32ToBERBuffer)(numDatSetEntriesValue));
|
|
430
|
+
this.TLVChild.push(numDatSetEntriesTLV);
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
allData: {
|
|
434
|
+
type: 'array',
|
|
435
|
+
label: 'AllData',
|
|
436
|
+
items: {
|
|
437
|
+
anyOf: [
|
|
438
|
+
{
|
|
439
|
+
type: 'object',
|
|
440
|
+
label: ItemDataType.Boolean,
|
|
441
|
+
properties: {
|
|
442
|
+
dataType: {
|
|
443
|
+
type: 'string',
|
|
444
|
+
label: 'DataType',
|
|
445
|
+
enum: [ItemDataType.Boolean],
|
|
446
|
+
const: ItemDataType.Boolean,
|
|
447
|
+
hidden: true
|
|
448
|
+
},
|
|
449
|
+
value: {
|
|
450
|
+
type: 'boolean',
|
|
451
|
+
label: 'Value'
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
type: 'object',
|
|
457
|
+
label: ItemDataType.INT8,
|
|
458
|
+
properties: {
|
|
459
|
+
dataType: {
|
|
460
|
+
type: 'string',
|
|
461
|
+
label: 'DataType',
|
|
462
|
+
enum: [ItemDataType.INT8],
|
|
463
|
+
const: ItemDataType.INT8,
|
|
464
|
+
hidden: true
|
|
465
|
+
},
|
|
466
|
+
value: {
|
|
467
|
+
type: 'integer',
|
|
468
|
+
label: 'Value'
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
type: 'object',
|
|
474
|
+
label: ItemDataType.INT16,
|
|
475
|
+
properties: {
|
|
476
|
+
dataType: {
|
|
477
|
+
type: 'string',
|
|
478
|
+
label: 'DataType',
|
|
479
|
+
enum: [ItemDataType.INT16],
|
|
480
|
+
const: ItemDataType.INT16,
|
|
481
|
+
hidden: true
|
|
482
|
+
},
|
|
483
|
+
value: {
|
|
484
|
+
type: 'integer',
|
|
485
|
+
label: 'Value'
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
type: 'object',
|
|
491
|
+
label: ItemDataType.INT32,
|
|
492
|
+
properties: {
|
|
493
|
+
dataType: {
|
|
494
|
+
type: 'string',
|
|
495
|
+
label: 'DataType',
|
|
496
|
+
enum: [ItemDataType.INT32],
|
|
497
|
+
const: ItemDataType.INT32,
|
|
498
|
+
hidden: true
|
|
499
|
+
},
|
|
500
|
+
value: {
|
|
501
|
+
type: 'integer',
|
|
502
|
+
label: 'Value'
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
type: 'object',
|
|
508
|
+
label: ItemDataType.INT64,
|
|
509
|
+
properties: {
|
|
510
|
+
dataType: {
|
|
511
|
+
type: 'string',
|
|
512
|
+
label: 'DataType',
|
|
513
|
+
enum: [ItemDataType.INT64],
|
|
514
|
+
const: ItemDataType.INT64,
|
|
515
|
+
hidden: true
|
|
516
|
+
},
|
|
517
|
+
value: {
|
|
518
|
+
type: 'string',
|
|
519
|
+
label: 'Value',
|
|
520
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.BIGINT
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
type: 'object',
|
|
526
|
+
label: ItemDataType.INT8U,
|
|
527
|
+
properties: {
|
|
528
|
+
dataType: {
|
|
529
|
+
type: 'string',
|
|
530
|
+
label: 'DataType',
|
|
531
|
+
enum: [ItemDataType.INT8U],
|
|
532
|
+
const: ItemDataType.INT8U,
|
|
533
|
+
hidden: true
|
|
534
|
+
},
|
|
535
|
+
value: {
|
|
536
|
+
type: 'integer',
|
|
537
|
+
label: 'Value'
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
type: 'object',
|
|
543
|
+
label: ItemDataType.INT16U,
|
|
544
|
+
properties: {
|
|
545
|
+
dataType: {
|
|
546
|
+
type: 'string',
|
|
547
|
+
label: 'DataType',
|
|
548
|
+
enum: [ItemDataType.INT16U],
|
|
549
|
+
const: ItemDataType.INT16U,
|
|
550
|
+
hidden: true
|
|
551
|
+
},
|
|
552
|
+
value: {
|
|
553
|
+
type: 'integer',
|
|
554
|
+
label: 'Value'
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
type: 'object',
|
|
560
|
+
label: ItemDataType.INT32U,
|
|
561
|
+
properties: {
|
|
562
|
+
dataType: {
|
|
563
|
+
type: 'string',
|
|
564
|
+
label: 'DataType',
|
|
565
|
+
enum: [ItemDataType.INT32U],
|
|
566
|
+
const: ItemDataType.INT32U,
|
|
567
|
+
hidden: true
|
|
568
|
+
},
|
|
569
|
+
value: {
|
|
570
|
+
type: 'integer',
|
|
571
|
+
label: 'Value'
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
type: 'object',
|
|
577
|
+
label: ItemDataType.FLOAT32,
|
|
578
|
+
properties: {
|
|
579
|
+
dataType: {
|
|
580
|
+
type: 'string',
|
|
581
|
+
label: 'DataType',
|
|
582
|
+
enum: [ItemDataType.FLOAT32],
|
|
583
|
+
const: ItemDataType.FLOAT32,
|
|
584
|
+
hidden: true
|
|
585
|
+
},
|
|
586
|
+
value: {
|
|
587
|
+
type: 'number',
|
|
588
|
+
label: 'Value'
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
type: 'object',
|
|
594
|
+
label: ItemDataType.CODEDENUM,
|
|
595
|
+
properties: {
|
|
596
|
+
dataType: {
|
|
597
|
+
type: 'string',
|
|
598
|
+
label: 'DataType',
|
|
599
|
+
enum: [ItemDataType.CODEDENUM],
|
|
600
|
+
const: ItemDataType.CODEDENUM,
|
|
601
|
+
hidden: true
|
|
602
|
+
},
|
|
603
|
+
value: {
|
|
604
|
+
type: 'integer',
|
|
605
|
+
label: 'Value'
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
type: 'object',
|
|
611
|
+
label: ItemDataType.OCTETSTRING,
|
|
612
|
+
properties: {
|
|
613
|
+
dataType: {
|
|
614
|
+
type: 'string',
|
|
615
|
+
label: 'DataType',
|
|
616
|
+
enum: [ItemDataType.OCTETSTRING],
|
|
617
|
+
const: ItemDataType.OCTETSTRING,
|
|
618
|
+
hidden: true
|
|
619
|
+
},
|
|
620
|
+
value: {
|
|
621
|
+
type: 'string',
|
|
622
|
+
label: 'Value',
|
|
623
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
type: 'object',
|
|
629
|
+
label: ItemDataType.VISIBLESTRING,
|
|
630
|
+
properties: {
|
|
631
|
+
dataType: {
|
|
632
|
+
type: 'string',
|
|
633
|
+
label: 'DataType',
|
|
634
|
+
enum: [ItemDataType.VISIBLESTRING],
|
|
635
|
+
const: ItemDataType.VISIBLESTRING,
|
|
636
|
+
hidden: true
|
|
637
|
+
},
|
|
638
|
+
value: {
|
|
639
|
+
type: 'string',
|
|
640
|
+
label: 'Value',
|
|
641
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.ASCII
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
type: 'object',
|
|
647
|
+
label: ItemDataType.TimeStamp,
|
|
648
|
+
properties: {
|
|
649
|
+
dataType: {
|
|
650
|
+
type: 'string',
|
|
651
|
+
label: 'DataType',
|
|
652
|
+
enum: [ItemDataType.TimeStamp],
|
|
653
|
+
const: ItemDataType.TimeStamp,
|
|
654
|
+
hidden: true
|
|
655
|
+
},
|
|
656
|
+
value: {
|
|
657
|
+
type: 'string',
|
|
658
|
+
label: 'Value'
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
type: 'object',
|
|
664
|
+
label: ItemDataType.Quality,
|
|
665
|
+
properties: {
|
|
666
|
+
dataType: {
|
|
667
|
+
type: 'string',
|
|
668
|
+
label: 'DataType',
|
|
669
|
+
enum: [ItemDataType.Quality],
|
|
670
|
+
const: ItemDataType.Quality,
|
|
671
|
+
hidden: true
|
|
672
|
+
},
|
|
673
|
+
value: {
|
|
674
|
+
type: 'string',
|
|
675
|
+
label: 'Value',
|
|
676
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.BINARY
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
},
|
|
680
|
+
{
|
|
681
|
+
type: 'object',
|
|
682
|
+
label: ItemDataType.Structure,
|
|
683
|
+
properties: {
|
|
684
|
+
dataType: {
|
|
685
|
+
type: 'string',
|
|
686
|
+
label: 'DataType',
|
|
687
|
+
enum: [ItemDataType.Structure],
|
|
688
|
+
const: ItemDataType.Structure,
|
|
689
|
+
hidden: true
|
|
690
|
+
},
|
|
691
|
+
value: {
|
|
692
|
+
$ref: '#/properties/goosePdu/properties/allData',
|
|
693
|
+
label: 'Value'
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
]
|
|
698
|
+
},
|
|
699
|
+
/**
|
|
700
|
+
* +-----------------------------------+-------------------+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
701
|
+
* | Data types according to IEC 61850-7-2 | ASN.1 Tag for Data | ASN.1 Length | Comments |
|
|
702
|
+
* +-----------------------------------+-------------------+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
703
|
+
* | Boolean | 0x83 | 1 | 8 Bit set to 0 FALSE; anything else = TRUE |
|
|
704
|
+
* | INT8 | 0x85 | 2 | 8 Bit Big Endian; signed |
|
|
705
|
+
* | INT16 | 0x85 | 3 | 16 Bit Big Endian; signed |
|
|
706
|
+
* | INT32 | 0x85 | 5 | 32 Bit Big Endian; signed |
|
|
707
|
+
* | INT64 | 0x85 | 9 | 64Bit Big Endian; signed |
|
|
708
|
+
* | INT8U | 0x86 | 2 | 8 Bit Big Endian; unsigned |
|
|
709
|
+
* | INT16U | 0x86 | 3 | 16 Bit Big Endian; unsigned |
|
|
710
|
+
* | INT24U | - | - | Not used |
|
|
711
|
+
* | INT32U | 0x86 | 5 | 32 Bit Big Endian; unsigned |
|
|
712
|
+
* | FLOAT32 | 0x87 | 4 | 32 Bit IEEE Floating Point (IEEE 754) |
|
|
713
|
+
* | CODED-ENUM | 0x84 | 2 | Bit-string; depending on CODED ENUM definition – most of the time, can be encoded with 2 bytes (1st Byte = number of unused bit, 2nd Byte = Value) |
|
|
714
|
+
* | OCTET-STRING | 0x89 | 20 | 20 Bytes ASCII Text, Null terminated |
|
|
715
|
+
* | VISIBLE-STRING | 0x8a | 35 | 35 Bytes ASCII Text, Null terminated |
|
|
716
|
+
* | TimeStamp | 0x91 | 8 | 64 Bit TimeStamp as defined in 8.1.3.7 IEC 6 |
|
|
717
|
+
* | Quality | 0x84 | 3 | Bit-string |
|
|
718
|
+
* +-----------------------------------+-------------------+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
719
|
+
*/
|
|
720
|
+
decode: () => {
|
|
721
|
+
const allDataTLV = this.TLVChild.find((tlv) => tlv.getTag('number') === 0xAB);
|
|
722
|
+
const dataTLVs = allDataTLV ? allDataTLV.getChild() : [];
|
|
723
|
+
const allData = this.decodeDataTLVItem(dataTLVs);
|
|
724
|
+
if (allData.length)
|
|
725
|
+
this.instance.goosePdu.allData.setValue(allData);
|
|
726
|
+
},
|
|
727
|
+
encode: () => {
|
|
728
|
+
const allData = this.instance.goosePdu.allData.getValue([], (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
729
|
+
const dataItemTLVs = this.encodeDataTLVItem(allData);
|
|
730
|
+
if (dataItemTLVs.length) {
|
|
731
|
+
const allDataTLV = new node_tlv_1.default(0xAB, Buffer.concat(dataItemTLVs.map((dataItemTLV) => Buffer.concat([dataItemTLV.bTag, dataItemTLV.bLength, dataItemTLV.bValue]))));
|
|
732
|
+
this.TLVChild.push(allDataTLV);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
},
|
|
736
|
+
raw: {
|
|
737
|
+
type: 'string',
|
|
738
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
739
|
+
label: 'Unparsed Raw'
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
this.id = 'goose';
|
|
746
|
+
this.matchKeys = ['ethertype:88b8'];
|
|
747
|
+
this.name = 'IEC61850 GOOSE';
|
|
748
|
+
this.nickname = 'GOOSE';
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* True when at least one structured goosePdu field decoded/was supplied. Used to
|
|
752
|
+
* decide whether the raw-passthrough fallback applies.
|
|
753
|
+
*/
|
|
754
|
+
goosePduHasStructuredContent() {
|
|
755
|
+
const fields = ['gocbRef', 'timeAllowedtoLive', 'datSet', 'goID', 't', 'stNum', 'sqNum', 'simulation', 'confRev', 'ndsCom', 'numDatSetEntries', 'allData'];
|
|
756
|
+
return fields.some((field) => !this.instance.goosePdu[field].isUndefined());
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* True when decode preserved an unparsed goosePdu region and no structured field is
|
|
760
|
+
* present: encode then re-emits the raw bytes verbatim. Setting any structured field
|
|
761
|
+
* turns this false and encode rebuilds the PDU from fields instead.
|
|
762
|
+
*/
|
|
763
|
+
goosePduRawFallbackActive() {
|
|
764
|
+
if (this.instance.goosePdu.raw.isUndefined())
|
|
765
|
+
return false;
|
|
766
|
+
if (!this.instance.goosePdu.raw.getValue(''))
|
|
767
|
+
return false;
|
|
768
|
+
return !this.goosePduHasStructuredContent();
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Decode data TLV items
|
|
772
|
+
* @param dataTLVs
|
|
773
|
+
* @protected
|
|
774
|
+
*/
|
|
775
|
+
decodeDataTLVItem(dataTLVs) {
|
|
776
|
+
const dataItems = [];
|
|
777
|
+
dataTLVs.forEach((dataTLV) => {
|
|
778
|
+
const length = dataTLV.getLength('number');
|
|
779
|
+
const value = dataTLV.getValue('buffer');
|
|
780
|
+
switch (dataTLV.getTag('number')) {
|
|
781
|
+
case 0x83:
|
|
782
|
+
{
|
|
783
|
+
dataItems.push({
|
|
784
|
+
dataType: ItemDataType.Boolean,
|
|
785
|
+
value: !!parseInt(value.toString('hex'), 16)
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
break;
|
|
789
|
+
case 0x84:
|
|
790
|
+
{
|
|
791
|
+
switch (length) {
|
|
792
|
+
case 2:
|
|
793
|
+
{
|
|
794
|
+
dataItems.push({
|
|
795
|
+
dataType: ItemDataType.CODEDENUM,
|
|
796
|
+
value: parseInt(value.toString('hex'), 16)
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
break;
|
|
800
|
+
case 3:
|
|
801
|
+
{
|
|
802
|
+
dataItems.push({
|
|
803
|
+
dataType: ItemDataType.Quality,
|
|
804
|
+
value: parseInt(value.toString('hex'), 16).toString(2).padStart(24, '0')
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
break;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
break;
|
|
811
|
+
case 0x85:
|
|
812
|
+
{
|
|
813
|
+
const integerRealLength = (0, GetBERIntegerLengthFromBuffer_1.GetBERIntegerLengthFromBuffer)(value);
|
|
814
|
+
if (integerRealLength === 1) {
|
|
815
|
+
dataItems.push({
|
|
816
|
+
dataType: ItemDataType.INT8,
|
|
817
|
+
value: (0, HexToNumber_1.HexToInt8)(value.toString('hex'))
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
else if (integerRealLength === 2) {
|
|
821
|
+
dataItems.push({
|
|
822
|
+
dataType: ItemDataType.INT16,
|
|
823
|
+
value: (0, HexToNumber_1.HexToInt16)(value.toString('hex'))
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
else if (integerRealLength === 4) {
|
|
827
|
+
dataItems.push({
|
|
828
|
+
dataType: ItemDataType.INT32,
|
|
829
|
+
value: (0, HexToNumber_1.HexToInt32)(value.toString('hex'))
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
else if (integerRealLength === 8) {
|
|
833
|
+
dataItems.push({
|
|
834
|
+
dataType: ItemDataType.INT64,
|
|
835
|
+
value: (0, HexToNumber_1.HexToInt64)(value.toString('hex'))
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
break;
|
|
840
|
+
case 0x86:
|
|
841
|
+
{
|
|
842
|
+
const unsignedIntegerRealLength = (0, GetBERIntegerLengthFromBuffer_1.GetBERIntegerLengthFromBuffer)(value);
|
|
843
|
+
switch (unsignedIntegerRealLength) {
|
|
844
|
+
case 1:
|
|
845
|
+
{
|
|
846
|
+
dataItems.push({
|
|
847
|
+
dataType: ItemDataType.INT8U,
|
|
848
|
+
value: (0, HexToNumber_1.HexToUInt8)(value.toString('hex'))
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
break;
|
|
852
|
+
case 2:
|
|
853
|
+
{
|
|
854
|
+
dataItems.push({
|
|
855
|
+
dataType: ItemDataType.INT16U,
|
|
856
|
+
value: (0, HexToNumber_1.HexToUInt16)(value.toString('hex'))
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
break;
|
|
860
|
+
case 4:
|
|
861
|
+
{
|
|
862
|
+
dataItems.push({
|
|
863
|
+
dataType: ItemDataType.INT32U,
|
|
864
|
+
value: (0, HexToNumber_1.HexToUInt32)(value.toString('hex'))
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
break;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
break;
|
|
871
|
+
case 0x87:
|
|
872
|
+
{
|
|
873
|
+
dataItems.push({
|
|
874
|
+
dataType: ItemDataType.FLOAT32,
|
|
875
|
+
value: (0, HexToNumber_1.HexToFloat32)(value.toString('hex'))
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
break;
|
|
879
|
+
case 0x89:
|
|
880
|
+
{
|
|
881
|
+
dataItems.push({
|
|
882
|
+
dataType: ItemDataType.OCTETSTRING,
|
|
883
|
+
value: value.toString('hex')
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
break;
|
|
887
|
+
case 0x8a:
|
|
888
|
+
{
|
|
889
|
+
dataItems.push({
|
|
890
|
+
dataType: ItemDataType.VISIBLESTRING,
|
|
891
|
+
value: value.toString('ascii')
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
break;
|
|
895
|
+
case 0x91:
|
|
896
|
+
{
|
|
897
|
+
dataItems.push({
|
|
898
|
+
dataType: ItemDataType.TimeStamp,
|
|
899
|
+
//BigInt to preserve full 64-bit precision (parseInt would round above 2^53).
|
|
900
|
+
value: value.length ? BigInt(`0x${value.toString('hex')}`).toString() : '0'
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
break;
|
|
904
|
+
case 0xa2:
|
|
905
|
+
{
|
|
906
|
+
const subDataTLVs = node_tlv_1.default.parseList(value);
|
|
907
|
+
dataItems.push({
|
|
908
|
+
dataType: ItemDataType.Structure,
|
|
909
|
+
value: this.decodeDataTLVItem(subDataTLVs)
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
break;
|
|
913
|
+
}
|
|
914
|
+
});
|
|
915
|
+
return dataItems;
|
|
916
|
+
}
|
|
917
|
+
/**
|
|
918
|
+
* Encode data TLV items
|
|
919
|
+
* @param dataItems
|
|
920
|
+
* @protected
|
|
921
|
+
*/
|
|
922
|
+
encodeDataTLVItem(dataItems) {
|
|
923
|
+
return dataItems
|
|
924
|
+
.map((dataItem, index) => {
|
|
925
|
+
const errorNodePath = this.instance.goosePdu.allData.getPath(index);
|
|
926
|
+
switch (dataItem.dataType) {
|
|
927
|
+
case ItemDataType.Boolean: {
|
|
928
|
+
const booleanIntValue = dataItem.value ? 1 : 0;
|
|
929
|
+
return new node_tlv_1.default(0x83, Buffer.from(booleanIntValue.toString(16).padStart(2, '0'), 'hex'));
|
|
930
|
+
}
|
|
931
|
+
case ItemDataType.INT8: {
|
|
932
|
+
let intValue = dataItem.value;
|
|
933
|
+
if (isNaN(intValue))
|
|
934
|
+
this.recordError(errorNodePath, 'Invalid INT8 value');
|
|
935
|
+
intValue = intValue ? intValue : 0;
|
|
936
|
+
if (intValue < -128 || intValue > 127)
|
|
937
|
+
this.recordError(errorNodePath, 'Invalid INT8 value');
|
|
938
|
+
return new node_tlv_1.default(0x85, Buffer.from((0, NumberToBERHex_1.Int8ToBERHex)(intValue), 'hex'));
|
|
939
|
+
}
|
|
940
|
+
case ItemDataType.INT16: {
|
|
941
|
+
let intValue = dataItem.value;
|
|
942
|
+
if (isNaN(intValue))
|
|
943
|
+
this.recordError(errorNodePath, 'Invalid INT16 value');
|
|
944
|
+
intValue = intValue ? intValue : 0;
|
|
945
|
+
if (intValue < -32768 || intValue > 32767)
|
|
946
|
+
this.recordError(errorNodePath, 'Invalid INT16 value');
|
|
947
|
+
return new node_tlv_1.default(0x85, Buffer.from((0, NumberToBERHex_1.Int16ToBERHex)(intValue), 'hex'));
|
|
948
|
+
}
|
|
949
|
+
case ItemDataType.INT32: {
|
|
950
|
+
let intValue = dataItem.value;
|
|
951
|
+
if (isNaN(intValue))
|
|
952
|
+
this.recordError(errorNodePath, 'Invalid INT32 value');
|
|
953
|
+
intValue = intValue ? intValue : 0;
|
|
954
|
+
if (intValue < -2147483648 || intValue > 2147483647)
|
|
955
|
+
this.recordError(errorNodePath, 'Invalid INT32 value');
|
|
956
|
+
return new node_tlv_1.default(0x85, Buffer.from((0, NumberToBERHex_1.Int32ToBERHex)(intValue), 'hex'));
|
|
957
|
+
}
|
|
958
|
+
case ItemDataType.INT64: {
|
|
959
|
+
const intValue = BigInt(dataItem.value);
|
|
960
|
+
if (intValue < BigInt('-9223372036854775808') || intValue > BigInt('9223372036854775807'))
|
|
961
|
+
this.recordError(errorNodePath, 'Invalid INT64 value');
|
|
962
|
+
return new node_tlv_1.default(0x85, Buffer.from((0, NumberToBERHex_1.Int64ToBERHex)(intValue), 'hex'));
|
|
963
|
+
}
|
|
964
|
+
case ItemDataType.INT8U: {
|
|
965
|
+
let uintValue = dataItem.value;
|
|
966
|
+
if (isNaN(uintValue))
|
|
967
|
+
this.recordError(errorNodePath, 'Invalid INT8U value');
|
|
968
|
+
uintValue = uintValue ? uintValue : 0;
|
|
969
|
+
if (uintValue < 0 || uintValue > 255)
|
|
970
|
+
this.recordError(errorNodePath, 'Invalid INT8U value');
|
|
971
|
+
return new node_tlv_1.default(0x86, Buffer.from((0, NumberToBERHex_1.UInt8ToBERHex)(uintValue), 'hex'));
|
|
972
|
+
}
|
|
973
|
+
case ItemDataType.INT16U: {
|
|
974
|
+
let uintValue = dataItem.value;
|
|
975
|
+
if (isNaN(uintValue))
|
|
976
|
+
this.recordError(errorNodePath, 'Invalid INT16U value');
|
|
977
|
+
uintValue = uintValue ? uintValue : 0;
|
|
978
|
+
if (uintValue < 0 || uintValue > 65535)
|
|
979
|
+
this.recordError(errorNodePath, 'Invalid INT16U value');
|
|
980
|
+
return new node_tlv_1.default(0x86, Buffer.from((0, NumberToBERHex_1.UInt16ToBERHex)(uintValue), 'hex'));
|
|
981
|
+
}
|
|
982
|
+
case ItemDataType.INT32U: {
|
|
983
|
+
let uintValue = dataItem.value;
|
|
984
|
+
if (isNaN(uintValue))
|
|
985
|
+
this.recordError(errorNodePath, 'Invalid INT32U value');
|
|
986
|
+
uintValue = uintValue ? uintValue : 0;
|
|
987
|
+
if (uintValue < 0 || uintValue > 4294967295)
|
|
988
|
+
this.recordError(errorNodePath, 'Invalid INT32U value');
|
|
989
|
+
return new node_tlv_1.default(0x86, Buffer.from((0, NumberToBERHex_1.UInt32ToBERHex)(uintValue), 'hex'));
|
|
990
|
+
}
|
|
991
|
+
case ItemDataType.FLOAT32: {
|
|
992
|
+
let float32Value = dataItem.value;
|
|
993
|
+
if (isNaN(float32Value))
|
|
994
|
+
this.recordError(errorNodePath, 'Invalid FLOAT32 value');
|
|
995
|
+
float32Value = float32Value ? float32Value : 0;
|
|
996
|
+
return new node_tlv_1.default(0x87, Buffer.from((0, NumberToBERHex_1.Float32ToBERHex)(float32Value), 'hex'));
|
|
997
|
+
}
|
|
998
|
+
case ItemDataType.CODEDENUM: {
|
|
999
|
+
let codedEnumValue = dataItem.value;
|
|
1000
|
+
if (isNaN(codedEnumValue))
|
|
1001
|
+
this.recordError(errorNodePath, 'Invalid CODED-ENUM value');
|
|
1002
|
+
codedEnumValue = codedEnumValue ? codedEnumValue : 0;
|
|
1003
|
+
return new node_tlv_1.default(0x84, Buffer.from((0, NumberToBERHex_1.UInt16ToBERHex)(codedEnumValue), 'hex'));
|
|
1004
|
+
}
|
|
1005
|
+
case ItemDataType.OCTETSTRING: {
|
|
1006
|
+
const hexText = dataItem.value;
|
|
1007
|
+
if (!hexText) {
|
|
1008
|
+
this.recordError(errorNodePath, 'Empty OCTET-STRING, ignored');
|
|
1009
|
+
return null;
|
|
1010
|
+
}
|
|
1011
|
+
if (hexText.length > 40)
|
|
1012
|
+
this.recordError(errorNodePath, 'OCTET-STRING too long');
|
|
1013
|
+
return new node_tlv_1.default(0x89, Buffer.from(hexText, 'hex').subarray(0, 20));
|
|
1014
|
+
}
|
|
1015
|
+
case ItemDataType.VISIBLESTRING: {
|
|
1016
|
+
const asciiText = dataItem.value;
|
|
1017
|
+
if (!asciiText) {
|
|
1018
|
+
this.recordError(errorNodePath, 'Empty VISIBLE-STRING, ignored');
|
|
1019
|
+
return null;
|
|
1020
|
+
}
|
|
1021
|
+
if (asciiText.length > 35)
|
|
1022
|
+
this.recordError(errorNodePath, 'VISIBLE-STRING too long');
|
|
1023
|
+
//VISIBLE-STRING is variable length (max 35 ASCII bytes); emit the ASCII
|
|
1024
|
+
//bytes directly. The previous padStart(35*2) used a space fill, so
|
|
1025
|
+
//Buffer.from(<space-prefixed hex>,'hex') stopped at the first space and
|
|
1026
|
+
//produced an empty buffer for any string shorter than 35 chars.
|
|
1027
|
+
return new node_tlv_1.default(0x8a, Buffer.from(asciiText, 'ascii').subarray(0, 35));
|
|
1028
|
+
}
|
|
1029
|
+
case ItemDataType.TimeStamp: {
|
|
1030
|
+
//Use BigInt + padStart(16,'0') like the top-level goosePdu.t field: a
|
|
1031
|
+
//64-bit TimeStamp exceeds Number precision, and Number.toString(16) can
|
|
1032
|
+
//produce odd-length hex that Buffer.from(...,'hex') would truncate.
|
|
1033
|
+
let timestamp = 0n;
|
|
1034
|
+
try {
|
|
1035
|
+
timestamp = BigInt(dataItem.value);
|
|
1036
|
+
}
|
|
1037
|
+
catch (e) {
|
|
1038
|
+
this.recordError(errorNodePath, 'Invalid TimeStamp value');
|
|
1039
|
+
}
|
|
1040
|
+
return new node_tlv_1.default(0x91, Buffer.from(timestamp.toString(16).padStart(8 * 2, '0'), 'hex'));
|
|
1041
|
+
}
|
|
1042
|
+
case ItemDataType.Quality: {
|
|
1043
|
+
const bitString = dataItem.value;
|
|
1044
|
+
let intValue = parseInt(bitString, 2);
|
|
1045
|
+
if (isNaN(intValue))
|
|
1046
|
+
this.recordError(errorNodePath, 'Invalid Quality value');
|
|
1047
|
+
intValue = intValue ? intValue : 0;
|
|
1048
|
+
return new node_tlv_1.default(0x84, Buffer.from(intValue.toString(16).padStart(3 * 2, '0'), 'hex'));
|
|
1049
|
+
}
|
|
1050
|
+
case ItemDataType.Structure: {
|
|
1051
|
+
return new node_tlv_1.default(0xa2, Buffer.concat(this.encodeDataTLVItem(dataItem.value).map((tlv) => Buffer.concat([tlv.bTag, tlv.bLength, tlv.bValue]))));
|
|
1052
|
+
}
|
|
1053
|
+
default: {
|
|
1054
|
+
this.recordError(errorNodePath, 'Invalid dataType, ignored');
|
|
1055
|
+
return null;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
})
|
|
1059
|
+
.filter((value) => !!value);
|
|
1060
|
+
}
|
|
1061
|
+
match() {
|
|
1062
|
+
if (!this.prevCodecModule)
|
|
1063
|
+
return false;
|
|
1064
|
+
return this.prevCodecModule.instance.etherType.getValue() === (0, NumberToHex_1.UInt16ToHex)(0x88b8);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
exports.Goose = Goose;
|