@netkitty/codec 1.2.1 → 2.1.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 +295 -0
- package/README.md +62 -10
- package/README.zh-CN.md +55 -9
- package/dist/Codec.d.ts +3 -2
- package/dist/Codec.js +109 -10
- package/dist/abstracts/BaseHeader.d.ts +54 -2
- package/dist/abstracts/BaseHeader.js +185 -43
- package/dist/errors/CodecSchemaValidateError.d.ts +34 -1
- package/dist/errors/CodecSchemaValidateError.js +26 -3
- package/dist/headers/ADSAMS.js +2 -0
- package/dist/headers/AH.js +4 -2
- package/dist/headers/AMQP.js +2 -1
- package/dist/headers/ARP.js +16 -10
- package/dist/headers/BACnetIP.js +1 -0
- package/dist/headers/BFD.d.ts +2 -1
- package/dist/headers/BFD.js +30 -4
- package/dist/headers/BGP.js +6 -1
- package/dist/headers/Babel.js +2 -1
- package/dist/headers/BitTorrent.d.ts +2 -0
- package/dist/headers/BitTorrent.js +4 -2
- package/dist/headers/C37118.d.ts +3 -2
- package/dist/headers/C37118.js +35 -15
- package/dist/headers/CAPWAP.js +1 -0
- package/dist/headers/CDP.d.ts +3 -3
- package/dist/headers/CDP.js +47 -11
- package/dist/headers/CMS.js +27 -12
- package/dist/headers/COTP.d.ts +2 -0
- package/dist/headers/COTP.js +8 -4
- package/dist/headers/CassandraCQL.js +1 -0
- package/dist/headers/CoAP.js +20 -2
- package/dist/headers/Codesys.js +1 -0
- package/dist/headers/Collectd.js +1 -1
- package/dist/headers/DCCP.d.ts +3 -2
- package/dist/headers/DCCP.js +61 -8
- package/dist/headers/DHCPFailover.js +1 -0
- package/dist/headers/DNP3.d.ts +5 -3
- package/dist/headers/DNP3.js +62 -7
- package/dist/headers/DNS.js +3 -3
- package/dist/headers/DTLS.js +1 -0
- package/dist/headers/Diameter.js +3 -2
- package/dist/headers/EAPOL.js +1 -1
- package/dist/headers/EIGRP.d.ts +3 -2
- package/dist/headers/EIGRP.js +32 -6
- package/dist/headers/ENIP.js +1 -0
- package/dist/headers/Elasticsearch.js +1 -0
- package/dist/headers/EtherCAT.js +1 -0
- package/dist/headers/EthernetII.js +7 -0
- package/dist/headers/FTP.js +6 -6
- package/dist/headers/Finger.js +3 -3
- package/dist/headers/FoundationFieldbusHSE.js +1 -0
- package/dist/headers/GELF.js +8 -1
- package/dist/headers/GENEVE.js +2 -1
- package/dist/headers/GLBP.js +1 -1
- package/dist/headers/GRE.js +1 -0
- package/dist/headers/GTPU.js +1 -0
- package/dist/headers/GTPv2C.js +2 -0
- package/dist/headers/GitProtocol.js +2 -2
- package/dist/headers/Goose.js +24 -12
- package/dist/headers/Gopher.js +6 -6
- package/dist/headers/HARTIP.js +1 -0
- package/dist/headers/HSR.js +3 -0
- package/dist/headers/HTTP.js +6 -6
- package/dist/headers/HTTP2.js +2 -0
- package/dist/headers/ICMP.js +3 -1
- package/dist/headers/ICMPv6.js +11 -16
- package/dist/headers/IEC104_I_Frame.js +215 -163
- package/dist/headers/IEC104_S_Frame.js +26 -3
- package/dist/headers/IEC104_U_Frame.js +33 -4
- package/dist/headers/IEC61850SampledValues.js +6 -5
- package/dist/headers/IGMP.d.ts +8 -7
- package/dist/headers/IGMP.js +58 -19
- package/dist/headers/IMAP.js +5 -5
- package/dist/headers/IPFIX.js +3 -2
- package/dist/headers/IPv4.js +41 -21
- package/dist/headers/IPv6.js +5 -1
- package/dist/headers/IPv6HopByHopOptions.js +15 -12
- package/dist/headers/IRC.js +4 -4
- package/dist/headers/ISAKMP.js +3 -1
- package/dist/headers/ISCSI.js +2 -0
- package/dist/headers/ISIS.js +2 -1
- package/dist/headers/ISOSession.d.ts +2 -0
- package/dist/headers/ISOSession.js +14 -10
- package/dist/headers/Ident.js +8 -8
- package/dist/headers/KNXnetIP.js +1 -0
- package/dist/headers/Kafka.js +1 -0
- package/dist/headers/Kerberos.js +2 -0
- package/dist/headers/L2TP.js +3 -2
- package/dist/headers/LACP.js +1 -1
- package/dist/headers/LDAP.js +3 -4
- package/dist/headers/LDP.js +1 -0
- package/dist/headers/LLC.d.ts +2 -0
- package/dist/headers/LLC.js +3 -0
- package/dist/headers/LPD.js +3 -3
- package/dist/headers/MGCP.js +7 -7
- package/dist/headers/MMS.d.ts +2 -0
- package/dist/headers/MMS.js +10 -6
- package/dist/headers/MQTT.js +1 -0
- package/dist/headers/MQTTSN.js +1 -0
- package/dist/headers/MarkerProtocol.js +1 -1
- package/dist/headers/Megaco.js +3 -3
- package/dist/headers/Memcached.js +3 -2
- package/dist/headers/ModbusTCP.js +1 -0
- package/dist/headers/ModbusUDP.js +1 -0
- package/dist/headers/MongoDB.js +1 -0
- package/dist/headers/MySQL.js +1 -0
- package/dist/headers/NATS.js +2 -2
- package/dist/headers/NBDS.js +1 -0
- package/dist/headers/NBSS.js +1 -0
- package/dist/headers/NFS.js +1 -0
- package/dist/headers/NHRP.d.ts +1 -1
- package/dist/headers/NHRP.js +30 -4
- package/dist/headers/NNTP.js +6 -6
- package/dist/headers/NetFlowV5.js +1 -0
- package/dist/headers/OLSR.js +2 -1
- package/dist/headers/OPCUA.js +1 -0
- package/dist/headers/OSPF.d.ts +3 -3
- package/dist/headers/OSPF.js +72 -7
- package/dist/headers/OpenFlow.js +1 -0
- package/dist/headers/OpenVPN.js +1 -0
- package/dist/headers/PCWorx.js +1 -0
- package/dist/headers/PIM.d.ts +3 -3
- package/dist/headers/PIM.js +55 -6
- package/dist/headers/POP3.js +5 -5
- package/dist/headers/PPPoEDiscovery.js +4 -1
- package/dist/headers/PPPoESession.js +1 -0
- package/dist/headers/PPTP.js +1 -0
- package/dist/headers/PTP.js +6 -1
- package/dist/headers/PostgreSQL.js +2 -0
- package/dist/headers/QUIC.js +2 -0
- package/dist/headers/RADIUS.js +1 -0
- package/dist/headers/RDP.d.ts +2 -0
- package/dist/headers/RDP.js +6 -1
- package/dist/headers/RFB.js +4 -4
- package/dist/headers/RGoose.js +8 -1
- package/dist/headers/RSVP.d.ts +3 -3
- package/dist/headers/RSVP.js +59 -44
- package/dist/headers/RTCP.js +2 -0
- package/dist/headers/RTP.js +2 -1
- package/dist/headers/RTPS.d.ts +2 -0
- package/dist/headers/RTPS.js +4 -1
- package/dist/headers/RTSP.js +7 -7
- package/dist/headers/RawData.js +1 -1
- package/dist/headers/Redis.js +4 -4
- package/dist/headers/Rlogin.js +5 -5
- package/dist/headers/Rsync.js +2 -2
- package/dist/headers/S7comm.d.ts +2 -0
- package/dist/headers/S7comm.js +5 -1
- package/dist/headers/SCTP.d.ts +2 -2
- package/dist/headers/SCTP.js +31 -7
- package/dist/headers/SFlow.js +2 -1
- package/dist/headers/SIP.js +6 -6
- package/dist/headers/SLMP.js +1 -0
- package/dist/headers/SLP.js +2 -0
- package/dist/headers/SLPv1.js +1 -0
- package/dist/headers/SMB1.js +1 -0
- package/dist/headers/SMB2.js +1 -0
- package/dist/headers/SMPP.js +1 -0
- package/dist/headers/SMTP.js +6 -6
- package/dist/headers/SNAP.js +18 -5
- package/dist/headers/SNMP.js +6 -6
- package/dist/headers/SOCKS4.js +11 -5
- package/dist/headers/SSDP.js +7 -7
- package/dist/headers/SSH.js +5 -4
- package/dist/headers/STOMP.js +5 -5
- package/dist/headers/STUN.js +3 -1
- package/dist/headers/SercosIII.d.ts +3 -2
- package/dist/headers/SercosIII.js +41 -5
- package/dist/headers/Skinny.js +1 -0
- package/dist/headers/StatsD.js +4 -4
- package/dist/headers/SunRPC.js +1 -0
- package/dist/headers/Syslog.js +2 -2
- package/dist/headers/TCP.js +31 -64
- package/dist/headers/TLS_Alert.js +42 -12
- package/dist/headers/TLS_ApplicationData.d.ts +3 -3
- package/dist/headers/TLS_ApplicationData.js +32 -8
- package/dist/headers/TLS_ChangeCipherSpec.d.ts +2 -2
- package/dist/headers/TLS_ChangeCipherSpec.js +33 -8
- package/dist/headers/TLS_Handshake.js +78 -30
- package/dist/headers/TLS_Heartbeat.d.ts +4 -3
- package/dist/headers/TLS_Heartbeat.js +50 -8
- package/dist/headers/TPKT.js +4 -2
- package/dist/headers/TacacsPlus.js +1 -0
- package/dist/headers/Telnet.js +2 -1
- package/dist/headers/Teredo.js +2 -2
- package/dist/headers/UDP.js +20 -56
- package/dist/headers/VLAN_802dot1Q.js +8 -0
- package/dist/headers/VRRP.d.ts +2 -1
- package/dist/headers/VRRP.js +45 -9
- package/dist/headers/WCCP.js +1 -0
- package/dist/headers/WHOIS.js +3 -3
- package/dist/headers/WSDiscovery.js +2 -2
- package/dist/headers/XMPP.js +3 -3
- package/dist/headers/Zabbix.js +1 -0
- package/dist/helper/Checksum.d.ts +15 -0
- package/dist/helper/Checksum.js +56 -0
- package/dist/helper/Crc.d.ts +18 -0
- package/dist/helper/Crc.js +58 -0
- package/dist/index.d.ts +3 -3
- package/dist/lib/SchemaValidator.d.ts +31 -0
- package/dist/lib/SchemaValidator.js +137 -0
- package/dist/schema/ProtocolFieldJSONSchema.d.ts +4 -1
- package/dist/schema/ProtocolJSONSchema.d.ts +1 -1
- package/dist/types/CodecErrorInfo.d.ts +11 -0
- package/dist/types/LayerGraph.d.ts +14 -1
- package/package.json +2 -2
package/dist/headers/EIGRP.d.ts
CHANGED
|
@@ -13,8 +13,9 @@ import { DemuxProducer } from '../types/DemuxProducer';
|
|
|
13
13
|
* OSPF #available) — a lying Length near the end never reads into a trailing FCS/padding. TLV values are
|
|
14
14
|
* kept verbatim as hex (per-TLV route/parameter bodies are opaque here), so every TLV round-trips
|
|
15
15
|
* byte-for-byte; the Length is honored when supplied (a crafted TLV may lie) else derived from the value
|
|
16
|
-
* byte count. The Checksum is
|
|
17
|
-
* well-formed packet round-trips byte-for-byte. Leaf header —
|
|
16
|
+
* byte count. The Checksum is computed over the whole EIGRP packet when left out (no pseudo-header, over
|
|
17
|
+
* IPv4 or IPv6), else written as given. A well-formed packet round-trips byte-for-byte. Leaf header —
|
|
18
|
+
* TLV sub-structures are not sub-decoded.
|
|
18
19
|
*/
|
|
19
20
|
export declare class EIGRP extends BaseHeader {
|
|
20
21
|
#private;
|
package/dist/headers/EIGRP.js
CHANGED
|
@@ -6,6 +6,7 @@ const BufferToHex_1 = require("../helper/BufferToHex");
|
|
|
6
6
|
const HexToBuffer_1 = require("../helper/HexToBuffer");
|
|
7
7
|
const BufferToNumber_1 = require("../helper/BufferToNumber");
|
|
8
8
|
const NumberToBuffer_1 = require("../helper/NumberToBuffer");
|
|
9
|
+
const Checksum_1 = require("../helper/Checksum");
|
|
9
10
|
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
10
11
|
/**
|
|
11
12
|
* EIGRP — Enhanced Interior Gateway Routing Protocol (Cisco), carried directly over IP as protocol 88.
|
|
@@ -19,8 +20,9 @@ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
|
19
20
|
* OSPF #available) — a lying Length near the end never reads into a trailing FCS/padding. TLV values are
|
|
20
21
|
* kept verbatim as hex (per-TLV route/parameter bodies are opaque here), so every TLV round-trips
|
|
21
22
|
* byte-for-byte; the Length is honored when supplied (a crafted TLV may lie) else derived from the value
|
|
22
|
-
* byte count. The Checksum is
|
|
23
|
-
* well-formed packet round-trips byte-for-byte. Leaf header —
|
|
23
|
+
* byte count. The Checksum is computed over the whole EIGRP packet when left out (no pseudo-header, over
|
|
24
|
+
* IPv4 or IPv6), else written as given. A well-formed packet round-trips byte-for-byte. Leaf header —
|
|
25
|
+
* TLV sub-structures are not sub-decoded.
|
|
24
26
|
*/
|
|
25
27
|
class EIGRP extends BaseHeader_1.BaseHeader {
|
|
26
28
|
constructor() {
|
|
@@ -66,9 +68,33 @@ class EIGRP extends BaseHeader_1.BaseHeader {
|
|
|
66
68
|
//==== Fixed 20-byte header ====
|
|
67
69
|
version: this.fieldUInt('version', 0, 1, 'Version'),
|
|
68
70
|
opcode: this.fieldUInt('opcode', 1, 1, 'Opcode'),
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
checksum:
|
|
71
|
+
//Internet checksum over the whole EIGRP packet (header + TLVs, checksum field zeroed),
|
|
72
|
+
//computed once every field is written when left out; a given value is written as given.
|
|
73
|
+
checksum: {
|
|
74
|
+
type: 'integer',
|
|
75
|
+
autoCalculated: true,
|
|
76
|
+
label: 'Checksum',
|
|
77
|
+
minimum: 0,
|
|
78
|
+
maximum: 65535,
|
|
79
|
+
decode: function () {
|
|
80
|
+
this.instance.checksum.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
|
|
81
|
+
},
|
|
82
|
+
encode: function () {
|
|
83
|
+
if (!this.isLeftOut(this.instance.checksum)) {
|
|
84
|
+
const checksum = this.instance.checksum.getValue(0);
|
|
85
|
+
this.instance.checksum.setValue(checksum);
|
|
86
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
this.instance.checksum.setValue(0);
|
|
90
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(0));
|
|
91
|
+
this.addPostSelfEncodeHandler(() => {
|
|
92
|
+
const checksum = (0, Checksum_1.InternetChecksum)(this.packet.subarray(this.startPos, this.endPos));
|
|
93
|
+
this.instance.checksum.setValue(checksum);
|
|
94
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
},
|
|
72
98
|
flags: this.fieldUInt('flags', 4, 4, 'Flags'),
|
|
73
99
|
sequence: this.fieldUInt('sequence', 8, 4, 'Sequence'),
|
|
74
100
|
ack: this.fieldUInt('ack', 12, 4, 'Acknowledge'),
|
|
@@ -83,7 +109,7 @@ class EIGRP extends BaseHeader_1.BaseHeader {
|
|
|
83
109
|
label: 'TLV',
|
|
84
110
|
properties: {
|
|
85
111
|
type: { type: 'integer', label: 'Type', minimum: 0, maximum: 65535 },
|
|
86
|
-
length: { type: 'integer', label: 'Length', minimum: 0, maximum: 65535 },
|
|
112
|
+
length: { type: 'integer', label: 'Length', autoCalculated: true, minimum: 0, maximum: 65535 },
|
|
87
113
|
value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
|
|
88
114
|
}
|
|
89
115
|
},
|
package/dist/headers/ENIP.js
CHANGED
|
@@ -47,6 +47,7 @@ class Elasticsearch extends BaseHeader_1.BaseHeader {
|
|
|
47
47
|
magic: this.fieldHex('magic', 0, 2, 'Magic'),
|
|
48
48
|
messageLength: {
|
|
49
49
|
type: 'integer',
|
|
50
|
+
autoCalculated: true,
|
|
50
51
|
label: 'Message Length',
|
|
51
52
|
//Wire field: never constrain below the true lower bound. A truncated/crafted message
|
|
52
53
|
//may decode any value in [0, 0xffffffff]; keep the full uint32 range so a decoded
|
package/dist/headers/EtherCAT.js
CHANGED
|
@@ -57,6 +57,7 @@ class EtherCAT extends BaseHeader_1.BaseHeader {
|
|
|
57
57
|
//(so the three fields never clobber each other). reserved/type are decode-only.
|
|
58
58
|
length: {
|
|
59
59
|
type: 'integer',
|
|
60
|
+
autoCalculated: true,
|
|
60
61
|
label: 'Length',
|
|
61
62
|
minimum: 0,
|
|
62
63
|
//The on-wire field is 11 bits (max 0x7FF); the schema bound is left wider (uint16) so an
|
|
@@ -79,6 +79,7 @@ class EthernetII extends BaseHeader_1.BaseHeader {
|
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
81
|
etherType: {
|
|
82
|
+
autoCalculated: true,
|
|
82
83
|
type: 'string',
|
|
83
84
|
minLength: 4,
|
|
84
85
|
maxLength: 4,
|
|
@@ -88,6 +89,8 @@ class EthernetII extends BaseHeader_1.BaseHeader {
|
|
|
88
89
|
this.instance.etherType.setValue(this.readBytes(12, 2).toString('hex').padStart(4, '0'));
|
|
89
90
|
},
|
|
90
91
|
encode: function () {
|
|
92
|
+
if (this.instance.etherType.isUndefined())
|
|
93
|
+
return this.encodeOmittedEtherType(this.instance.etherType, 12);
|
|
91
94
|
const etherType = this.instance.etherType.getValue((0, NumberToHex_1.UInt16ToHex)(0x0000), (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
92
95
|
const typeBuffer = Buffer.from(etherType, 'hex');
|
|
93
96
|
if (typeBuffer.length < 2)
|
|
@@ -99,6 +102,10 @@ class EthernetII extends BaseHeader_1.BaseHeader {
|
|
|
99
102
|
};
|
|
100
103
|
}
|
|
101
104
|
match() {
|
|
105
|
+
//Fewer bytes than the 14-octet header cannot be reproduced by these fields (encode always writes
|
|
106
|
+
//a whole header): leave them to raw so they round-trip byte-exact.
|
|
107
|
+
if (this.packet.length - this.startPos < 14)
|
|
108
|
+
return false;
|
|
102
109
|
if (!this.prevCodecModule)
|
|
103
110
|
return true;
|
|
104
111
|
//Tunnels that carry a bare Ethernet frame with no inner protocol-type field: claim their payload
|
package/dist/headers/FTP.js
CHANGED
|
@@ -126,12 +126,12 @@ class FTP extends BaseHeader_1.BaseHeader {
|
|
|
126
126
|
//message field above, never read back). isReply distinguishes a server reply from a
|
|
127
127
|
//client command; replyCode/isMultiline/replyText describe a reply, command/argument a
|
|
128
128
|
//command.
|
|
129
|
-
isReply: { type: 'boolean', label: 'Is Reply' },
|
|
130
|
-
replyCode: { type: 'integer', label: 'Reply Code', minimum: 0, maximum: 999 },
|
|
131
|
-
isMultiline: { type: 'boolean', label: 'Is Multiline' },
|
|
132
|
-
replyText: { type: 'string', label: 'Reply Text' },
|
|
133
|
-
command: { type: 'string', label: 'Command' },
|
|
134
|
-
argument: { type: 'string', label: 'Argument' }
|
|
129
|
+
isReply: { type: 'boolean', label: 'Is Reply', readOnly: true },
|
|
130
|
+
replyCode: { type: 'integer', label: 'Reply Code', readOnly: true, minimum: 0, maximum: 999 },
|
|
131
|
+
isMultiline: { type: 'boolean', label: 'Is Multiline', readOnly: true },
|
|
132
|
+
replyText: { type: 'string', label: 'Reply Text', readOnly: true },
|
|
133
|
+
command: { type: 'string', label: 'Command', readOnly: true },
|
|
134
|
+
argument: { type: 'string', label: 'Argument', readOnly: true }
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
137
|
}
|
package/dist/headers/Finger.js
CHANGED
|
@@ -90,10 +90,10 @@ class Finger extends BaseHeader_1.BaseHeader {
|
|
|
90
90
|
//Display-only metadata parsed from the first line on decode (no encode — populated by the
|
|
91
91
|
//`message` field below, never read back). isVerbose flags a query opening with "/W"; query
|
|
92
92
|
//is the username text with the verbose switch and surrounding whitespace removed.
|
|
93
|
-
isVerbose: { type: 'boolean', label: 'Is Verbose', default: false },
|
|
94
|
-
query: { type: 'string', label: 'Query', default: '' },
|
|
93
|
+
isVerbose: { type: 'boolean', label: 'Is Verbose', readOnly: true, default: false },
|
|
94
|
+
query: { type: 'string', label: 'Query', readOnly: true, default: '' },
|
|
95
95
|
//Drives the one-line summary: the query text, or 'list all' for the empty query.
|
|
96
|
-
summaryInfo: { type: 'string', label: 'Summary', hidden: true, default: '' },
|
|
96
|
+
summaryInfo: { type: 'string', label: 'Summary', readOnly: true, hidden: true, default: '' },
|
|
97
97
|
//The whole raw payload is the single source of truth: decoded verbatim to hex and re-emitted
|
|
98
98
|
//untouched (byte-perfect for any Finger payload). The first line is parsed into the
|
|
99
99
|
//display-only metadata above, which carry no codec of their own.
|
package/dist/headers/GELF.js
CHANGED
|
@@ -74,10 +74,13 @@ class GELF extends BaseHeader_1.BaseHeader {
|
|
|
74
74
|
//Discriminant chosen at decode from the leading magic (chunked / gzip / uncompressed).
|
|
75
75
|
//It writes no bytes; on encode it is honored when supplied, else inferred from which
|
|
76
76
|
//form-specific fields are present (a chunk has a Message ID; a gzip form has payload).
|
|
77
|
-
//
|
|
77
|
+
//A closed enum: decode only ever yields these three, and any other value would match no
|
|
78
|
+
//form-specific field, silently encoding an empty layer.
|
|
78
79
|
form: {
|
|
79
80
|
type: 'string',
|
|
81
|
+
autoCalculated: true,
|
|
80
82
|
label: 'Form',
|
|
83
|
+
enum: ['chunked', 'gzip', 'uncompressed'],
|
|
81
84
|
decode: function () {
|
|
82
85
|
this.instance.form.setValue(this.#detectForm());
|
|
83
86
|
},
|
|
@@ -91,6 +94,9 @@ class GELF extends BaseHeader_1.BaseHeader {
|
|
|
91
94
|
else
|
|
92
95
|
form = 'uncompressed';
|
|
93
96
|
}
|
|
97
|
+
if (form !== 'chunked' && form !== 'gzip' && form !== 'uncompressed') {
|
|
98
|
+
this.recordError(this.instance.form.getPath(), `Unknown form '${form}', no GELF payload encoded`, 'error');
|
|
99
|
+
}
|
|
94
100
|
this.instance.form.setValue(form);
|
|
95
101
|
}
|
|
96
102
|
},
|
|
@@ -98,6 +104,7 @@ class GELF extends BaseHeader_1.BaseHeader {
|
|
|
98
104
|
//when the form is chunked; otherwise it stays unset so it neither decodes phantom values
|
|
99
105
|
//nor writes bytes for the gzip/uncompressed forms.
|
|
100
106
|
magic: {
|
|
107
|
+
default: '1e0f',
|
|
101
108
|
type: 'string',
|
|
102
109
|
label: 'Magic',
|
|
103
110
|
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
package/dist/headers/GENEVE.js
CHANGED
|
@@ -58,7 +58,7 @@ class GENEVE extends BaseHeader_1.BaseHeader {
|
|
|
58
58
|
},
|
|
59
59
|
//Opt Len (options length in 4-byte units) — metadata; the value is derived from the
|
|
60
60
|
//options list by the `body` master on encode and read from the wire on decode.
|
|
61
|
-
optLen: { type: 'integer', label: 'Option Length', minimum: 0, maximum: 63 },
|
|
61
|
+
optLen: { type: 'integer', label: 'Option Length', readOnly: true, minimum: 0, maximum: 63 },
|
|
62
62
|
oam: {
|
|
63
63
|
type: 'boolean', label: 'OAM',
|
|
64
64
|
decode: function () { this.instance.oam.setValue(!!this.readBits(1, 1, 0, 1)); },
|
|
@@ -86,6 +86,7 @@ class GENEVE extends BaseHeader_1.BaseHeader {
|
|
|
86
86
|
//Protocol Type is the EtherType of the inner frame — stored as a lowercase hex string
|
|
87
87
|
//(like eth.etherType) so it can drive the `ethertype` demux dimension to the inner codec.
|
|
88
88
|
protocolType: {
|
|
89
|
+
autoCalculated: true,
|
|
89
90
|
type: 'string', label: 'Protocol Type', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
90
91
|
decode: function () { this.instance.protocolType.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(2, 2))); },
|
|
91
92
|
encode: function () {
|
package/dist/headers/GLBP.js
CHANGED
|
@@ -70,7 +70,7 @@ class GLBP extends BaseHeader_1.BaseHeader {
|
|
|
70
70
|
label: 'TLV',
|
|
71
71
|
properties: {
|
|
72
72
|
type: { type: 'integer', label: 'Type', minimum: 0, maximum: 255 },
|
|
73
|
-
length: { type: 'integer', label: 'Length', minimum: 0, maximum: 255 },
|
|
73
|
+
length: { type: 'integer', label: 'Length', autoCalculated: true, minimum: 0, maximum: 255 },
|
|
74
74
|
value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
|
|
75
75
|
}
|
|
76
76
|
},
|
package/dist/headers/GRE.js
CHANGED
|
@@ -109,6 +109,7 @@ class GRE extends BaseHeader_1.BaseHeader {
|
|
|
109
109
|
//Protocol Type is the EtherType of the inner frame — stored as a lowercase hex string
|
|
110
110
|
//(like eth.etherType) so it can drive the `ethertype` demux dimension to the inner codec.
|
|
111
111
|
protocolType: {
|
|
112
|
+
autoCalculated: true,
|
|
112
113
|
type: 'string', label: 'Protocol Type', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
113
114
|
decode: function () { this.instance.protocolType.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(2, 2))); },
|
|
114
115
|
encode: function () {
|
package/dist/headers/GTPU.js
CHANGED
package/dist/headers/GTPv2C.js
CHANGED
|
@@ -90,6 +90,7 @@ class GTPv2C extends BaseHeader_1.BaseHeader {
|
|
|
90
90
|
label: 'Flags',
|
|
91
91
|
properties: {
|
|
92
92
|
version: {
|
|
93
|
+
default: 2,
|
|
93
94
|
type: 'integer',
|
|
94
95
|
label: 'Version',
|
|
95
96
|
minimum: 0,
|
|
@@ -114,6 +115,7 @@ class GTPv2C extends BaseHeader_1.BaseHeader {
|
|
|
114
115
|
messageType: this.fieldUInt('messageType', 1, 1, 'Message Type'),
|
|
115
116
|
messageLength: {
|
|
116
117
|
type: 'integer',
|
|
118
|
+
autoCalculated: true,
|
|
117
119
|
label: 'Message Length',
|
|
118
120
|
minimum: 0,
|
|
119
121
|
maximum: 65535,
|
|
@@ -116,8 +116,8 @@ class GitProtocol extends BaseHeader_1.BaseHeader {
|
|
|
116
116
|
//the message field above, never read back). firstPktLineLength is the declared 4-hex-char
|
|
117
117
|
//length prefix; firstCommand is the pkt-line payload up to the first NUL (the service
|
|
118
118
|
//command + repository path for a request line).
|
|
119
|
-
firstPktLineLength: { type: 'integer', label: 'First pkt-line Length', minimum: 0, maximum: 65535 },
|
|
120
|
-
firstCommand: { type: 'string', label: 'First Command' }
|
|
119
|
+
firstPktLineLength: { type: 'integer', label: 'First pkt-line Length', readOnly: true, minimum: 0, maximum: 65535 },
|
|
120
|
+
firstCommand: { type: 'string', label: 'First Command', readOnly: true }
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
123
|
}
|
package/dist/headers/Goose.js
CHANGED
|
@@ -57,13 +57,14 @@ class Goose extends BaseHeader_1.BaseHeader {
|
|
|
57
57
|
type: 'integer',
|
|
58
58
|
minimum: 0,
|
|
59
59
|
maximum: 65535,
|
|
60
|
+
autoCalculated: true,
|
|
60
61
|
label: 'Length',
|
|
61
62
|
decode: () => {
|
|
62
63
|
this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
|
|
63
64
|
},
|
|
64
65
|
encode: () => {
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
if (!this.isLeftOut(this.instance.length)) {
|
|
67
|
+
const length = this.instance.length.getValue(0);
|
|
67
68
|
this.instance.length.setValue(length);
|
|
68
69
|
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(length));
|
|
69
70
|
}
|
|
@@ -133,9 +134,10 @@ class Goose extends BaseHeader_1.BaseHeader {
|
|
|
133
134
|
try {
|
|
134
135
|
const buffer = this.readBytes(8, readTLVBufferLength, true);
|
|
135
136
|
this.TLVInstance = node_tlv_1.default.parse(buffer);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
//Consume exactly the outer TLV's own span (tag + length + value). Anything after
|
|
138
|
+
//it (Ethernet padding, trailing bytes) is not part of the goosePdu and must be
|
|
139
|
+
//left for the next layer (raw) so it survives re-encode.
|
|
140
|
+
const TLVBufferLength = this.TLVInstance.bTag.length + this.TLVInstance.bLength.length + this.TLVInstance.bValue.length;
|
|
139
141
|
this.TLVInstance = node_tlv_1.default.parse(this.readBytes(8, TLVBufferLength, false));
|
|
140
142
|
}
|
|
141
143
|
catch (e) {
|
|
@@ -167,7 +169,7 @@ class Goose extends BaseHeader_1.BaseHeader {
|
|
|
167
169
|
//decoded (it may itself be inconsistent in a malformed frame).
|
|
168
170
|
const rawBuffer = Buffer.from(this.instance.goosePdu.raw.getValue().toString(), 'hex');
|
|
169
171
|
this.writeBytes(8, rawBuffer);
|
|
170
|
-
if (this.instance.length
|
|
172
|
+
if (!this.isLeftOut(this.instance.length))
|
|
171
173
|
return;
|
|
172
174
|
this.instance.length.setValue(8 + rawBuffer.length);
|
|
173
175
|
return;
|
|
@@ -181,14 +183,14 @@ class Goose extends BaseHeader_1.BaseHeader {
|
|
|
181
183
|
* Update the length only if it is not set
|
|
182
184
|
* Update length(APPID's length + Length's length + Reserved1's length + Reserved2's length + goosePdu's length)
|
|
183
185
|
*/
|
|
184
|
-
if (this.instance.length
|
|
186
|
+
if (!this.isLeftOut(this.instance.length))
|
|
185
187
|
return;
|
|
186
188
|
this.instance.length.setValue(2 + 2 + 2 + 2 + goosePduBuffer.length);
|
|
187
189
|
},
|
|
188
190
|
properties: {
|
|
189
191
|
gocbRef: {
|
|
190
192
|
type: 'string',
|
|
191
|
-
maxLength:
|
|
193
|
+
//Not a hard maxLength: a decoded over-long value must re-encode; encode flags it instead.
|
|
192
194
|
label: 'GoCBReference',
|
|
193
195
|
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.ASCII,
|
|
194
196
|
decode: () => {
|
|
@@ -234,7 +236,7 @@ class Goose extends BaseHeader_1.BaseHeader {
|
|
|
234
236
|
},
|
|
235
237
|
datSet: {
|
|
236
238
|
type: 'string',
|
|
237
|
-
maxLength:
|
|
239
|
+
//Not a hard maxLength: a decoded over-long value must re-encode; encode flags it instead.
|
|
238
240
|
label: 'DatSet',
|
|
239
241
|
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.ASCII,
|
|
240
242
|
decode: () => {
|
|
@@ -257,7 +259,7 @@ class Goose extends BaseHeader_1.BaseHeader {
|
|
|
257
259
|
},
|
|
258
260
|
goID: {
|
|
259
261
|
type: 'string',
|
|
260
|
-
maxLength:
|
|
262
|
+
//Not a hard maxLength: a decoded over-long value must re-encode; encode flags it instead.
|
|
261
263
|
label: 'GoID',
|
|
262
264
|
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.ASCII,
|
|
263
265
|
decode: () => {
|
|
@@ -962,7 +964,13 @@ class Goose extends BaseHeader_1.BaseHeader {
|
|
|
962
964
|
return new node_tlv_1.default(0x85, Buffer.from((0, NumberToBERHex_1.Int32ToBERHex)(intValue), 'hex'));
|
|
963
965
|
}
|
|
964
966
|
case ItemDataType.INT64: {
|
|
965
|
-
|
|
967
|
+
let intValue = 0n;
|
|
968
|
+
try {
|
|
969
|
+
intValue = BigInt(dataItem.value ?? 0);
|
|
970
|
+
}
|
|
971
|
+
catch (e) {
|
|
972
|
+
this.recordError(errorNodePath, 'Invalid INT64 value');
|
|
973
|
+
}
|
|
966
974
|
if (intValue < BigInt('-9223372036854775808') || intValue > BigInt('9223372036854775807'))
|
|
967
975
|
this.recordError(errorNodePath, 'Invalid INT64 value');
|
|
968
976
|
return new node_tlv_1.default(0x85, Buffer.from((0, NumberToBERHex_1.Int64ToBERHex)(intValue), 'hex'));
|
|
@@ -1063,7 +1071,11 @@ class Goose extends BaseHeader_1.BaseHeader {
|
|
|
1063
1071
|
return new node_tlv_1.default(0x84, Buffer.from(BigInt(`0b${bitString}`).toString(16).padStart(octets * 2, '0'), 'hex'));
|
|
1064
1072
|
}
|
|
1065
1073
|
case ItemDataType.Structure: {
|
|
1066
|
-
|
|
1074
|
+
//A Structure without members (value omitted) is an empty SEQUENCE, not an error.
|
|
1075
|
+
const members = Array.isArray(dataItem.value) ? dataItem.value : [];
|
|
1076
|
+
if (dataItem.value !== undefined && !Array.isArray(dataItem.value))
|
|
1077
|
+
this.recordError(errorNodePath, 'Invalid Structure value, encoded as empty');
|
|
1078
|
+
return new node_tlv_1.default(0xa2, Buffer.concat(this.encodeDataTLVItem(members).map((tlv) => Buffer.concat([tlv.bTag, tlv.bLength, tlv.bValue]))));
|
|
1067
1079
|
}
|
|
1068
1080
|
default: {
|
|
1069
1081
|
this.recordError(errorNodePath, 'Invalid dataType, ignored');
|
package/dist/headers/Gopher.js
CHANGED
|
@@ -133,13 +133,13 @@ class Gopher extends BaseHeader_1.BaseHeader {
|
|
|
133
133
|
//Display-only metadata parsed on decode (no encode — populated by the `message` field
|
|
134
134
|
//below, never read back). isRequest is decided by the TCP port direction; selector and
|
|
135
135
|
//searchTerm apply to a request; itemCount to a response; hasTerminator flags the "." end.
|
|
136
|
-
isRequest: { type: 'boolean', label: 'Is Request', default: false },
|
|
137
|
-
selector: { type: 'string', label: 'Selector', default: '' },
|
|
138
|
-
searchTerm: { type: 'string', label: 'Search Term', default: '' },
|
|
139
|
-
itemCount: { type: 'integer', label: 'Item Count', minimum: 0, default: 0 },
|
|
140
|
-
hasTerminator: { type: 'boolean', label: 'Has Terminator', default: false },
|
|
136
|
+
isRequest: { type: 'boolean', label: 'Is Request', readOnly: true, default: false },
|
|
137
|
+
selector: { type: 'string', label: 'Selector', readOnly: true, default: '' },
|
|
138
|
+
searchTerm: { type: 'string', label: 'Search Term', readOnly: true, default: '' },
|
|
139
|
+
itemCount: { type: 'integer', label: 'Item Count', readOnly: true, minimum: 0, default: 0 },
|
|
140
|
+
hasTerminator: { type: 'boolean', label: 'Has Terminator', readOnly: true, default: false },
|
|
141
141
|
//Drives the one-line summary (request selector / response line count).
|
|
142
|
-
summaryInfo: { type: 'string', label: 'Summary', hidden: true, default: '' },
|
|
142
|
+
summaryInfo: { type: 'string', label: 'Summary', readOnly: true, hidden: true, default: '' },
|
|
143
143
|
//The whole raw payload is the single source of truth: decoded verbatim to hex and
|
|
144
144
|
//re-emitted untouched (byte-perfect for any Gopher payload). The first line is parsed into
|
|
145
145
|
//the display-only metadata above, which carry no codec of their own.
|
package/dist/headers/HARTIP.js
CHANGED
|
@@ -75,6 +75,7 @@ class HARTIP extends BaseHeader_1.BaseHeader {
|
|
|
75
75
|
sequenceNumber: this.fieldUInt('sequenceNumber', 4, 2, 'Sequence Number'),
|
|
76
76
|
byteCount: {
|
|
77
77
|
type: 'integer',
|
|
78
|
+
autoCalculated: true,
|
|
78
79
|
label: 'Byte Count',
|
|
79
80
|
//minimum 0 (not 8): a crafted/corrupt message may carry a Byte Count below the 8-byte
|
|
80
81
|
//header, and such a value must round-trip (honored verbatim) rather than being rejected
|
package/dist/headers/HSR.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HSR = void 0;
|
|
4
4
|
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
5
6
|
const NumberToHex_1 = require("../helper/NumberToHex");
|
|
6
7
|
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
7
8
|
/**
|
|
@@ -63,10 +64,12 @@ class HSR extends BaseHeader_1.BaseHeader {
|
|
|
63
64
|
},
|
|
64
65
|
seqNr: BaseHeader_1.BaseHeader.fieldUInt('seqNr', 2, 2, 'Sequence Number'),
|
|
65
66
|
etherType: {
|
|
67
|
+
autoCalculated: true,
|
|
66
68
|
type: 'string',
|
|
67
69
|
minLength: 4,
|
|
68
70
|
maxLength: 4,
|
|
69
71
|
label: 'EtherType',
|
|
72
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
70
73
|
//The ORIGINAL EtherType of the carried frame. MUST be named `etherType` and stored as a
|
|
71
74
|
//lowercase 4-hex string exactly like VLAN/Ethernet, because L2 children (GOOSE, SV,
|
|
72
75
|
//VLAN, ARP) discriminate by reading prevCodecModule.instance.etherType — a different
|
package/dist/headers/HTTP.js
CHANGED
|
@@ -119,12 +119,12 @@ class HTTP extends BaseHeader_1.BaseHeader {
|
|
|
119
119
|
//Display-only metadata parsed from the start-line on decode (no encode — populated by the
|
|
120
120
|
//message field above, never read back). isRequest distinguishes a Request-Line from a
|
|
121
121
|
//Status-Line; method/requestUri are for requests, statusCode/reasonPhrase for responses.
|
|
122
|
-
isRequest: { type: 'boolean', label: 'Is Request' },
|
|
123
|
-
method: { type: 'string', label: 'Method' },
|
|
124
|
-
requestUri: { type: 'string', label: 'Request URI' },
|
|
125
|
-
version: { type: 'string', label: 'Version' },
|
|
126
|
-
statusCode: { type: 'integer', label: 'Status Code', minimum: 0, maximum: 999 },
|
|
127
|
-
reasonPhrase: { type: 'string', label: 'Reason Phrase' }
|
|
122
|
+
isRequest: { type: 'boolean', label: 'Is Request', readOnly: true },
|
|
123
|
+
method: { type: 'string', label: 'Method', readOnly: true },
|
|
124
|
+
requestUri: { type: 'string', label: 'Request URI', readOnly: true },
|
|
125
|
+
version: { type: 'string', label: 'Version', readOnly: true },
|
|
126
|
+
statusCode: { type: 'integer', label: 'Status Code', readOnly: true, minimum: 0, maximum: 999 },
|
|
127
|
+
reasonPhrase: { type: 'string', label: 'Reason Phrase', readOnly: true }
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
130
|
}
|
package/dist/headers/HTTP2.js
CHANGED
|
@@ -61,6 +61,7 @@ class HTTP2 extends BaseHeader_1.BaseHeader {
|
|
|
61
61
|
//The 24-byte connection preface, kept verbatim. match() requires it, so it is always
|
|
62
62
|
//present on decode; the default lets a crafted frame re-emit the standard preface.
|
|
63
63
|
preface: {
|
|
64
|
+
default: HTTP2.#PREFACE_HEX,
|
|
64
65
|
type: 'string',
|
|
65
66
|
label: 'Connection Preface',
|
|
66
67
|
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
@@ -76,6 +77,7 @@ class HTTP2 extends BaseHeader_1.BaseHeader {
|
|
|
76
77
|
//frame may lie); else derived from the payload byte length.
|
|
77
78
|
length: {
|
|
78
79
|
type: 'integer',
|
|
80
|
+
autoCalculated: true,
|
|
79
81
|
label: 'Length',
|
|
80
82
|
minimum: 0,
|
|
81
83
|
maximum: 16777215,
|
package/dist/headers/ICMP.js
CHANGED
|
@@ -42,6 +42,7 @@ class ICMP extends BaseHeader_1.BaseHeader {
|
|
|
42
42
|
},
|
|
43
43
|
checksum: {
|
|
44
44
|
type: 'integer',
|
|
45
|
+
autoCalculated: true,
|
|
45
46
|
label: 'Checksum',
|
|
46
47
|
minimum: 0,
|
|
47
48
|
maximum: 65535,
|
|
@@ -49,10 +50,11 @@ class ICMP extends BaseHeader_1.BaseHeader {
|
|
|
49
50
|
this.instance.checksum.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
|
|
50
51
|
},
|
|
51
52
|
encode: () => {
|
|
53
|
+
const leftOut = this.isLeftOut(this.instance.checksum);
|
|
52
54
|
let checksum = this.instance.checksum.getValue(0);
|
|
53
55
|
this.instance.checksum.setValue(checksum);
|
|
54
56
|
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
55
|
-
if (
|
|
57
|
+
if (leftOut) {
|
|
56
58
|
checksum = this.calculateIcmpChecksum();
|
|
57
59
|
this.instance.checksum.setValue(checksum);
|
|
58
60
|
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
package/dist/headers/ICMPv6.js
CHANGED
|
@@ -6,7 +6,6 @@ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
|
6
6
|
const BufferToNumber_1 = require("../helper/BufferToNumber");
|
|
7
7
|
const NumberToBuffer_1 = require("../helper/NumberToBuffer");
|
|
8
8
|
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
9
|
-
const IPToBuffer_1 = require("../helper/IPToBuffer");
|
|
10
9
|
class ICMPv6 extends BaseHeader_1.BaseHeader {
|
|
11
10
|
constructor() {
|
|
12
11
|
super(...arguments);
|
|
@@ -43,6 +42,7 @@ class ICMPv6 extends BaseHeader_1.BaseHeader {
|
|
|
43
42
|
},
|
|
44
43
|
checksum: {
|
|
45
44
|
type: 'integer',
|
|
45
|
+
autoCalculated: true,
|
|
46
46
|
label: 'Checksum',
|
|
47
47
|
minimum: 0,
|
|
48
48
|
maximum: 65535,
|
|
@@ -50,10 +50,11 @@ class ICMPv6 extends BaseHeader_1.BaseHeader {
|
|
|
50
50
|
this.instance.checksum.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
|
|
51
51
|
},
|
|
52
52
|
encode: () => {
|
|
53
|
+
const leftOut = this.isLeftOut(this.instance.checksum);
|
|
53
54
|
let checksum = this.instance.checksum.getValue(0);
|
|
54
55
|
this.instance.checksum.setValue(checksum);
|
|
55
56
|
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
56
|
-
if (
|
|
57
|
+
if (leftOut) {
|
|
57
58
|
checksum = this.calculateIcmpv6Checksum();
|
|
58
59
|
this.instance.checksum.setValue(checksum);
|
|
59
60
|
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
@@ -86,21 +87,15 @@ class ICMPv6 extends BaseHeader_1.BaseHeader {
|
|
|
86
87
|
* @protected
|
|
87
88
|
*/
|
|
88
89
|
calculateIcmpv6Checksum() {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return 0;
|
|
90
|
+
//The pseudo-header comes from the nearest IPv6 layer beneath (past extension headers or an
|
|
91
|
+
//IPv6-in-IPv6 tunnel's outer header).
|
|
92
92
|
const messageBody = Buffer.from(this.instance.message.getValue(''), 'hex');
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
(0, NumberToBuffer_1.UInt8ToBuffer)(0x00),
|
|
100
|
-
(0, NumberToBuffer_1.UInt8ToBuffer)(0x00),
|
|
101
|
-
(0, NumberToBuffer_1.UInt8ToBuffer)(0x00),
|
|
102
|
-
(0, NumberToBuffer_1.UInt8ToBuffer)(0x3a)
|
|
103
|
-
]);
|
|
93
|
+
const ip = this.nearestIPModule();
|
|
94
|
+
const pseudoHeader = ip && ip.id === 'ipv6' ? this.ipPseudoHeader(0x3a, messageBody.length + 4) : undefined;
|
|
95
|
+
if (!pseudoHeader) {
|
|
96
|
+
this.recordError(this.instance.checksum.getPath(), 'Cannot compute ICMPv6 checksum: no IPv6 layer beneath ICMPv6');
|
|
97
|
+
return 0;
|
|
98
|
+
}
|
|
104
99
|
const icmpHeader = Buffer.concat([
|
|
105
100
|
(0, NumberToBuffer_1.UInt8ToBuffer)(this.instance.type.getValue(0)),
|
|
106
101
|
(0, NumberToBuffer_1.UInt8ToBuffer)(this.instance.code.getValue(0)),
|