@netkitty/codec 2.0.0 → 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 +136 -0
- package/README.md +10 -6
- package/README.zh-CN.md +9 -6
- package/dist/Codec.js +4 -1
- package/dist/abstracts/BaseHeader.d.ts +26 -0
- package/dist/abstracts/BaseHeader.js +53 -0
- package/dist/headers/AH.js +3 -2
- package/dist/headers/BFD.d.ts +2 -1
- package/dist/headers/BFD.js +30 -4
- package/dist/headers/BGP.js +5 -1
- package/dist/headers/C37118.d.ts +3 -2
- package/dist/headers/C37118.js +34 -15
- package/dist/headers/CDP.d.ts +3 -3
- package/dist/headers/CDP.js +46 -10
- package/dist/headers/CMS.js +25 -10
- package/dist/headers/COTP.js +2 -3
- package/dist/headers/CoAP.js +20 -2
- package/dist/headers/DCCP.d.ts +3 -2
- package/dist/headers/DCCP.js +60 -8
- package/dist/headers/DNP3.d.ts +5 -3
- package/dist/headers/DNP3.js +62 -7
- package/dist/headers/EIGRP.d.ts +3 -2
- package/dist/headers/EIGRP.js +31 -5
- package/dist/headers/EthernetII.js +1 -0
- package/dist/headers/GELF.js +1 -0
- package/dist/headers/GENEVE.js +1 -0
- package/dist/headers/GRE.js +1 -0
- package/dist/headers/GTPv2C.js +1 -0
- package/dist/headers/Goose.js +4 -4
- package/dist/headers/HSR.js +1 -0
- package/dist/headers/HTTP2.js +1 -0
- package/dist/headers/ICMP.js +2 -1
- package/dist/headers/ICMPv6.js +10 -16
- package/dist/headers/IEC104_I_Frame.js +189 -160
- package/dist/headers/IEC104_S_Frame.js +19 -1
- package/dist/headers/IEC104_U_Frame.js +19 -1
- package/dist/headers/IEC61850SampledValues.js +4 -4
- package/dist/headers/IGMP.d.ts +8 -7
- package/dist/headers/IGMP.js +57 -19
- package/dist/headers/IPFIX.js +1 -1
- package/dist/headers/IPv4.js +26 -23
- package/dist/headers/IPv6.js +4 -1
- package/dist/headers/IPv6HopByHopOptions.js +3 -1
- package/dist/headers/ISAKMP.js +1 -0
- package/dist/headers/Kerberos.js +1 -0
- package/dist/headers/L2TP.js +1 -0
- package/dist/headers/LDAP.js +1 -1
- package/dist/headers/LLC.js +1 -0
- package/dist/headers/NHRP.d.ts +1 -1
- package/dist/headers/NHRP.js +29 -4
- package/dist/headers/OSPF.d.ts +3 -3
- package/dist/headers/OSPF.js +72 -7
- package/dist/headers/PIM.d.ts +3 -3
- package/dist/headers/PIM.js +55 -6
- package/dist/headers/PPPoEDiscovery.js +2 -0
- package/dist/headers/PTP.js +5 -1
- package/dist/headers/RDP.js +2 -0
- package/dist/headers/RGoose.js +2 -0
- package/dist/headers/RSVP.d.ts +3 -3
- package/dist/headers/RSVP.js +56 -42
- package/dist/headers/RTCP.js +1 -0
- package/dist/headers/SCTP.d.ts +2 -2
- package/dist/headers/SCTP.js +29 -5
- package/dist/headers/SNAP.js +2 -2
- package/dist/headers/SNMP.js +2 -2
- package/dist/headers/STUN.js +1 -1
- package/dist/headers/SercosIII.d.ts +3 -2
- package/dist/headers/SercosIII.js +41 -5
- package/dist/headers/TCP.js +13 -58
- package/dist/headers/TLS_Alert.js +20 -2
- package/dist/headers/TLS_ApplicationData.d.ts +3 -3
- package/dist/headers/TLS_ApplicationData.js +25 -6
- package/dist/headers/TLS_ChangeCipherSpec.d.ts +2 -2
- package/dist/headers/TLS_ChangeCipherSpec.js +24 -4
- package/dist/headers/TLS_Handshake.js +39 -6
- package/dist/headers/TLS_Heartbeat.d.ts +4 -3
- package/dist/headers/TLS_Heartbeat.js +40 -7
- package/dist/headers/TPKT.js +1 -1
- package/dist/headers/UDP.js +17 -61
- package/dist/headers/VLAN_802dot1Q.js +1 -0
- package/dist/headers/VRRP.d.ts +2 -1
- package/dist/headers/VRRP.js +45 -9
- 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/package.json +2 -2
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);
|
|
@@ -51,10 +50,11 @@ class ICMPv6 extends BaseHeader_1.BaseHeader {
|
|
|
51
50
|
this.instance.checksum.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
|
|
52
51
|
},
|
|
53
52
|
encode: () => {
|
|
53
|
+
const leftOut = this.isLeftOut(this.instance.checksum);
|
|
54
54
|
let checksum = this.instance.checksum.getValue(0);
|
|
55
55
|
this.instance.checksum.setValue(checksum);
|
|
56
56
|
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
57
|
-
if (
|
|
57
|
+
if (leftOut) {
|
|
58
58
|
checksum = this.calculateIcmpv6Checksum();
|
|
59
59
|
this.instance.checksum.setValue(checksum);
|
|
60
60
|
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
@@ -87,21 +87,15 @@ class ICMPv6 extends BaseHeader_1.BaseHeader {
|
|
|
87
87
|
* @protected
|
|
88
88
|
*/
|
|
89
89
|
calculateIcmpv6Checksum() {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
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).
|
|
93
92
|
const messageBody = Buffer.from(this.instance.message.getValue(''), 'hex');
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
(0, NumberToBuffer_1.UInt8ToBuffer)(0x00),
|
|
101
|
-
(0, NumberToBuffer_1.UInt8ToBuffer)(0x00),
|
|
102
|
-
(0, NumberToBuffer_1.UInt8ToBuffer)(0x00),
|
|
103
|
-
(0, NumberToBuffer_1.UInt8ToBuffer)(0x3a)
|
|
104
|
-
]);
|
|
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
|
+
}
|
|
105
99
|
const icmpHeader = Buffer.concat([
|
|
106
100
|
(0, NumberToBuffer_1.UInt8ToBuffer)(this.instance.type.getValue(0)),
|
|
107
101
|
(0, NumberToBuffer_1.UInt8ToBuffer)(this.instance.code.getValue(0)),
|