netkitty 0.0.14 → 0.0.16
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/.idea/inspectionProfiles/Project_Default.xml +1 -1
- package/dist/NetKitty.d.ts +12 -0
- package/dist/NetKitty.d.ts.map +1 -1
- package/dist/NetKitty.js +74 -1
- package/dist/lib/codec/Codec.d.ts.map +1 -1
- package/dist/lib/codec/Codec.js +8 -0
- package/dist/lib/codec/abstracts/BaseHeader.d.ts +2 -1
- package/dist/lib/codec/abstracts/BaseHeader.d.ts.map +1 -1
- package/dist/lib/codec/abstracts/BaseHeader.js +19 -10
- package/dist/lib/codec/headers/Goose.d.ts.map +1 -1
- package/dist/lib/codec/headers/Goose.js +26 -8
- package/dist/lib/codec/headers/ICMP.d.ts +15 -0
- package/dist/lib/codec/headers/ICMP.d.ts.map +1 -0
- package/dist/lib/codec/headers/ICMP.js +147 -0
- package/dist/lib/codec/headers/ICMPv6.d.ts +15 -0
- package/dist/lib/codec/headers/ICMPv6.d.ts.map +1 -0
- package/dist/lib/codec/headers/ICMPv6.js +128 -0
- package/dist/lib/codec/headers/IPv6.d.ts +10 -0
- package/dist/lib/codec/headers/IPv6.d.ts.map +1 -0
- package/dist/lib/codec/headers/IPv6.js +177 -0
- package/dist/lib/codec/headers/IPv6HopByHopOptions.d.ts +71 -0
- package/dist/lib/codec/headers/IPv6HopByHopOptions.d.ts.map +1 -0
- package/dist/lib/codec/headers/IPv6HopByHopOptions.js +497 -0
- package/dist/lib/codec/headers/TCP.d.ts.map +1 -1
- package/dist/lib/codec/headers/TCP.js +1 -0
- package/dist/tests/units/Codec.spec.js +19 -21
- package/package.json +1 -1
- package/src/NetKitty.ts +61 -0
- package/src/lib/codec/Codec.ts +8 -0
- package/src/lib/codec/abstracts/BaseHeader.ts +17 -9
- package/src/lib/codec/headers/Goose.ts +21 -9
- package/src/lib/codec/headers/ICMP.ts +151 -0
- package/src/lib/codec/headers/ICMPv6.ts +128 -0
- package/src/lib/codec/headers/IPv6.ts +176 -0
- package/src/lib/codec/headers/IPv6HopByHopOptions.ts +532 -0
- package/src/lib/codec/headers/TCP.ts +1 -0
- package/src/tests/units/Codec.spec.ts +21 -21
- package/src/tests/units/ReadPCAP.spec.ts +1 -2
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<option name="myName" value="Project Default" />
|
|
4
4
|
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
|
5
5
|
<Languages>
|
|
6
|
-
<language minSize="
|
|
6
|
+
<language minSize="249" name="TypeScript" />
|
|
7
7
|
</Languages>
|
|
8
8
|
</inspection_tool>
|
|
9
9
|
</profile>
|
package/dist/NetKitty.d.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
export { BufferToHex } from './lib/codec/lib/BufferToHex';
|
|
2
|
+
export { BufferToIPv4, BufferToIPv6 } from './lib/codec/lib/BufferToIP';
|
|
3
|
+
export { BufferToFloat32, BufferToInt16, BufferToInt32, BufferToInt64, BufferToInt8, BufferToUInt16, BufferToUInt32, BufferToUInt64, BufferToUInt8 } from './lib/codec/lib/BufferToNumber';
|
|
4
|
+
export { FixHexString } from './lib/codec/lib/FixHexString';
|
|
5
|
+
export { FlexibleObject } from './lib/codec/lib/FlexibleObject';
|
|
6
|
+
export { HexToFloat32, HexToInt16, HexToInt32, HexToInt64, HexToInt8, HexToUInt16, HexToUInt32, HexToUInt64, HexToUInt8 } from './lib/codec/lib/HexToNumber';
|
|
7
|
+
export { IPv4ToBuffer, IPv6ToBuffer } from './lib/codec/lib/IPToBuffer';
|
|
8
|
+
export { Int16ToBERBuffer, Int32ToBERBuffer, Int64ToBERBuffer, Int8ToBERBuffer, UInt16ToBERBuffer, UInt32ToBERBuffer, UInt64ToBERBuffer, UInt8ToBERBuffer } from './lib/codec/lib/NumberToBERBuffer';
|
|
9
|
+
export { Int16ToBERHex, Int32ToBERHex, Int64ToBERHex, Int8ToBERHex, UInt16ToBERHex, UInt32ToBERHex, UInt64ToBERHex, UInt8ToBERHex } from './lib/codec/lib/NumberToBERHex';
|
|
10
|
+
export { Float32ToBuffer, Int16ToBuffer, Int32ToBuffer, Int64ToBuffer, Int8ToBuffer, UInt16ToBuffer, UInt32ToBuffer, UInt64ToBuffer, UInt8ToBuffer } from './lib/codec/lib/NumberToBuffer';
|
|
11
|
+
export { Float32ToHex, Int16ToHex, Int32ToHex, Int64ToHex, Int8ToHex, UInt16ToHex, UInt32ToHex, UInt64ToHex, UInt8ToHex } from './lib/codec/lib/NumberToHex';
|
|
12
|
+
export { StringContentEncodingEnum } from './lib/codec/lib/StringContentEncodingEnum';
|
|
1
13
|
export { type INetworkInterface } from './lib/nodepcap/interfaces/INetworkInterface';
|
|
2
14
|
export { type CodecEncodeResult } from './lib/codec/types/CodecEncodeResult';
|
|
3
15
|
export { type CodecEncodeInput } from './lib/codec/types/CodecEncodeInput';
|
package/dist/NetKitty.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NetKitty.d.ts","sourceRoot":"","sources":["../src/NetKitty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,iBAAiB,EAAC,MAAM,6CAA6C,CAAA;AAClF,OAAO,EAAC,KAAK,iBAAiB,EAAC,MAAM,qCAAqC,CAAA;AAC1E,OAAO,EAAC,KAAK,gBAAgB,EAAC,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAAC,KAAK,iBAAiB,EAAC,MAAM,qCAAqC,CAAA;AAC1E,OAAO,EAAC,KAAK,WAAW,EAAC,MAAM,+BAA+B,CAAA;AAC9D,OAAO,EAAC,KAAK,cAAc,EAAC,MAAM,kCAAkC,CAAA;AACpE,OAAO,EAAC,KAAK,eAAe,EAAC,MAAM,uCAAuC,CAAA;AAC1E;;GAEG;AACH,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAA;AAChD;;GAEG;AACH,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,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|
3
|
+
exports.UInt8ToBuffer = exports.UInt64ToBuffer = exports.UInt32ToBuffer = exports.UInt16ToBuffer = exports.Int8ToBuffer = exports.Int64ToBuffer = exports.Int32ToBuffer = exports.Int16ToBuffer = exports.Float32ToBuffer = exports.UInt8ToBERHex = exports.UInt64ToBERHex = exports.UInt32ToBERHex = exports.UInt16ToBERHex = exports.Int8ToBERHex = exports.Int64ToBERHex = exports.Int32ToBERHex = exports.Int16ToBERHex = exports.UInt8ToBERBuffer = exports.UInt64ToBERBuffer = exports.UInt32ToBERBuffer = exports.UInt16ToBERBuffer = exports.Int8ToBERBuffer = exports.Int64ToBERBuffer = exports.Int32ToBERBuffer = exports.Int16ToBERBuffer = exports.IPv6ToBuffer = exports.IPv4ToBuffer = exports.HexToUInt8 = exports.HexToUInt64 = exports.HexToUInt32 = exports.HexToUInt16 = exports.HexToInt8 = exports.HexToInt64 = exports.HexToInt32 = exports.HexToInt16 = exports.HexToFloat32 = exports.FlexibleObject = exports.FixHexString = exports.BufferToUInt8 = exports.BufferToUInt64 = exports.BufferToUInt32 = exports.BufferToUInt16 = exports.BufferToInt8 = exports.BufferToInt64 = exports.BufferToInt32 = exports.BufferToInt16 = exports.BufferToFloat32 = exports.BufferToIPv6 = exports.BufferToIPv4 = exports.BufferToHex = void 0;
|
|
4
|
+
exports.Headers = exports.Codec = exports.Capture = exports.GetNetworkInterfaces = exports.PcapParser = exports.PcapWriter = exports.PcapReader = exports.StringContentEncodingEnum = exports.UInt8ToHex = exports.UInt64ToHex = exports.UInt32ToHex = exports.UInt16ToHex = exports.Int8ToHex = exports.Int64ToHex = exports.Int32ToHex = exports.Int16ToHex = exports.Float32ToHex = void 0;
|
|
5
|
+
var BufferToHex_1 = require("./lib/codec/lib/BufferToHex");
|
|
6
|
+
Object.defineProperty(exports, "BufferToHex", { enumerable: true, get: function () { return BufferToHex_1.BufferToHex; } });
|
|
7
|
+
var BufferToIP_1 = require("./lib/codec/lib/BufferToIP");
|
|
8
|
+
Object.defineProperty(exports, "BufferToIPv4", { enumerable: true, get: function () { return BufferToIP_1.BufferToIPv4; } });
|
|
9
|
+
Object.defineProperty(exports, "BufferToIPv6", { enumerable: true, get: function () { return BufferToIP_1.BufferToIPv6; } });
|
|
10
|
+
var BufferToNumber_1 = require("./lib/codec/lib/BufferToNumber");
|
|
11
|
+
Object.defineProperty(exports, "BufferToFloat32", { enumerable: true, get: function () { return BufferToNumber_1.BufferToFloat32; } });
|
|
12
|
+
Object.defineProperty(exports, "BufferToInt16", { enumerable: true, get: function () { return BufferToNumber_1.BufferToInt16; } });
|
|
13
|
+
Object.defineProperty(exports, "BufferToInt32", { enumerable: true, get: function () { return BufferToNumber_1.BufferToInt32; } });
|
|
14
|
+
Object.defineProperty(exports, "BufferToInt64", { enumerable: true, get: function () { return BufferToNumber_1.BufferToInt64; } });
|
|
15
|
+
Object.defineProperty(exports, "BufferToInt8", { enumerable: true, get: function () { return BufferToNumber_1.BufferToInt8; } });
|
|
16
|
+
Object.defineProperty(exports, "BufferToUInt16", { enumerable: true, get: function () { return BufferToNumber_1.BufferToUInt16; } });
|
|
17
|
+
Object.defineProperty(exports, "BufferToUInt32", { enumerable: true, get: function () { return BufferToNumber_1.BufferToUInt32; } });
|
|
18
|
+
Object.defineProperty(exports, "BufferToUInt64", { enumerable: true, get: function () { return BufferToNumber_1.BufferToUInt64; } });
|
|
19
|
+
Object.defineProperty(exports, "BufferToUInt8", { enumerable: true, get: function () { return BufferToNumber_1.BufferToUInt8; } });
|
|
20
|
+
var FixHexString_1 = require("./lib/codec/lib/FixHexString");
|
|
21
|
+
Object.defineProperty(exports, "FixHexString", { enumerable: true, get: function () { return FixHexString_1.FixHexString; } });
|
|
22
|
+
var FlexibleObject_1 = require("./lib/codec/lib/FlexibleObject");
|
|
23
|
+
Object.defineProperty(exports, "FlexibleObject", { enumerable: true, get: function () { return FlexibleObject_1.FlexibleObject; } });
|
|
24
|
+
var HexToNumber_1 = require("./lib/codec/lib/HexToNumber");
|
|
25
|
+
Object.defineProperty(exports, "HexToFloat32", { enumerable: true, get: function () { return HexToNumber_1.HexToFloat32; } });
|
|
26
|
+
Object.defineProperty(exports, "HexToInt16", { enumerable: true, get: function () { return HexToNumber_1.HexToInt16; } });
|
|
27
|
+
Object.defineProperty(exports, "HexToInt32", { enumerable: true, get: function () { return HexToNumber_1.HexToInt32; } });
|
|
28
|
+
Object.defineProperty(exports, "HexToInt64", { enumerable: true, get: function () { return HexToNumber_1.HexToInt64; } });
|
|
29
|
+
Object.defineProperty(exports, "HexToInt8", { enumerable: true, get: function () { return HexToNumber_1.HexToInt8; } });
|
|
30
|
+
Object.defineProperty(exports, "HexToUInt16", { enumerable: true, get: function () { return HexToNumber_1.HexToUInt16; } });
|
|
31
|
+
Object.defineProperty(exports, "HexToUInt32", { enumerable: true, get: function () { return HexToNumber_1.HexToUInt32; } });
|
|
32
|
+
Object.defineProperty(exports, "HexToUInt64", { enumerable: true, get: function () { return HexToNumber_1.HexToUInt64; } });
|
|
33
|
+
Object.defineProperty(exports, "HexToUInt8", { enumerable: true, get: function () { return HexToNumber_1.HexToUInt8; } });
|
|
34
|
+
var IPToBuffer_1 = require("./lib/codec/lib/IPToBuffer");
|
|
35
|
+
Object.defineProperty(exports, "IPv4ToBuffer", { enumerable: true, get: function () { return IPToBuffer_1.IPv4ToBuffer; } });
|
|
36
|
+
Object.defineProperty(exports, "IPv6ToBuffer", { enumerable: true, get: function () { return IPToBuffer_1.IPv6ToBuffer; } });
|
|
37
|
+
var NumberToBERBuffer_1 = require("./lib/codec/lib/NumberToBERBuffer");
|
|
38
|
+
Object.defineProperty(exports, "Int16ToBERBuffer", { enumerable: true, get: function () { return NumberToBERBuffer_1.Int16ToBERBuffer; } });
|
|
39
|
+
Object.defineProperty(exports, "Int32ToBERBuffer", { enumerable: true, get: function () { return NumberToBERBuffer_1.Int32ToBERBuffer; } });
|
|
40
|
+
Object.defineProperty(exports, "Int64ToBERBuffer", { enumerable: true, get: function () { return NumberToBERBuffer_1.Int64ToBERBuffer; } });
|
|
41
|
+
Object.defineProperty(exports, "Int8ToBERBuffer", { enumerable: true, get: function () { return NumberToBERBuffer_1.Int8ToBERBuffer; } });
|
|
42
|
+
Object.defineProperty(exports, "UInt16ToBERBuffer", { enumerable: true, get: function () { return NumberToBERBuffer_1.UInt16ToBERBuffer; } });
|
|
43
|
+
Object.defineProperty(exports, "UInt32ToBERBuffer", { enumerable: true, get: function () { return NumberToBERBuffer_1.UInt32ToBERBuffer; } });
|
|
44
|
+
Object.defineProperty(exports, "UInt64ToBERBuffer", { enumerable: true, get: function () { return NumberToBERBuffer_1.UInt64ToBERBuffer; } });
|
|
45
|
+
Object.defineProperty(exports, "UInt8ToBERBuffer", { enumerable: true, get: function () { return NumberToBERBuffer_1.UInt8ToBERBuffer; } });
|
|
46
|
+
var NumberToBERHex_1 = require("./lib/codec/lib/NumberToBERHex");
|
|
47
|
+
Object.defineProperty(exports, "Int16ToBERHex", { enumerable: true, get: function () { return NumberToBERHex_1.Int16ToBERHex; } });
|
|
48
|
+
Object.defineProperty(exports, "Int32ToBERHex", { enumerable: true, get: function () { return NumberToBERHex_1.Int32ToBERHex; } });
|
|
49
|
+
Object.defineProperty(exports, "Int64ToBERHex", { enumerable: true, get: function () { return NumberToBERHex_1.Int64ToBERHex; } });
|
|
50
|
+
Object.defineProperty(exports, "Int8ToBERHex", { enumerable: true, get: function () { return NumberToBERHex_1.Int8ToBERHex; } });
|
|
51
|
+
Object.defineProperty(exports, "UInt16ToBERHex", { enumerable: true, get: function () { return NumberToBERHex_1.UInt16ToBERHex; } });
|
|
52
|
+
Object.defineProperty(exports, "UInt32ToBERHex", { enumerable: true, get: function () { return NumberToBERHex_1.UInt32ToBERHex; } });
|
|
53
|
+
Object.defineProperty(exports, "UInt64ToBERHex", { enumerable: true, get: function () { return NumberToBERHex_1.UInt64ToBERHex; } });
|
|
54
|
+
Object.defineProperty(exports, "UInt8ToBERHex", { enumerable: true, get: function () { return NumberToBERHex_1.UInt8ToBERHex; } });
|
|
55
|
+
var NumberToBuffer_1 = require("./lib/codec/lib/NumberToBuffer");
|
|
56
|
+
Object.defineProperty(exports, "Float32ToBuffer", { enumerable: true, get: function () { return NumberToBuffer_1.Float32ToBuffer; } });
|
|
57
|
+
Object.defineProperty(exports, "Int16ToBuffer", { enumerable: true, get: function () { return NumberToBuffer_1.Int16ToBuffer; } });
|
|
58
|
+
Object.defineProperty(exports, "Int32ToBuffer", { enumerable: true, get: function () { return NumberToBuffer_1.Int32ToBuffer; } });
|
|
59
|
+
Object.defineProperty(exports, "Int64ToBuffer", { enumerable: true, get: function () { return NumberToBuffer_1.Int64ToBuffer; } });
|
|
60
|
+
Object.defineProperty(exports, "Int8ToBuffer", { enumerable: true, get: function () { return NumberToBuffer_1.Int8ToBuffer; } });
|
|
61
|
+
Object.defineProperty(exports, "UInt16ToBuffer", { enumerable: true, get: function () { return NumberToBuffer_1.UInt16ToBuffer; } });
|
|
62
|
+
Object.defineProperty(exports, "UInt32ToBuffer", { enumerable: true, get: function () { return NumberToBuffer_1.UInt32ToBuffer; } });
|
|
63
|
+
Object.defineProperty(exports, "UInt64ToBuffer", { enumerable: true, get: function () { return NumberToBuffer_1.UInt64ToBuffer; } });
|
|
64
|
+
Object.defineProperty(exports, "UInt8ToBuffer", { enumerable: true, get: function () { return NumberToBuffer_1.UInt8ToBuffer; } });
|
|
65
|
+
var NumberToHex_1 = require("./lib/codec/lib/NumberToHex");
|
|
66
|
+
Object.defineProperty(exports, "Float32ToHex", { enumerable: true, get: function () { return NumberToHex_1.Float32ToHex; } });
|
|
67
|
+
Object.defineProperty(exports, "Int16ToHex", { enumerable: true, get: function () { return NumberToHex_1.Int16ToHex; } });
|
|
68
|
+
Object.defineProperty(exports, "Int32ToHex", { enumerable: true, get: function () { return NumberToHex_1.Int32ToHex; } });
|
|
69
|
+
Object.defineProperty(exports, "Int64ToHex", { enumerable: true, get: function () { return NumberToHex_1.Int64ToHex; } });
|
|
70
|
+
Object.defineProperty(exports, "Int8ToHex", { enumerable: true, get: function () { return NumberToHex_1.Int8ToHex; } });
|
|
71
|
+
Object.defineProperty(exports, "UInt16ToHex", { enumerable: true, get: function () { return NumberToHex_1.UInt16ToHex; } });
|
|
72
|
+
Object.defineProperty(exports, "UInt32ToHex", { enumerable: true, get: function () { return NumberToHex_1.UInt32ToHex; } });
|
|
73
|
+
Object.defineProperty(exports, "UInt64ToHex", { enumerable: true, get: function () { return NumberToHex_1.UInt64ToHex; } });
|
|
74
|
+
Object.defineProperty(exports, "UInt8ToHex", { enumerable: true, get: function () { return NumberToHex_1.UInt8ToHex; } });
|
|
75
|
+
var StringContentEncodingEnum_1 = require("./lib/codec/lib/StringContentEncodingEnum");
|
|
76
|
+
Object.defineProperty(exports, "StringContentEncodingEnum", { enumerable: true, get: function () { return StringContentEncodingEnum_1.StringContentEncodingEnum; } });
|
|
4
77
|
/**
|
|
5
78
|
* PCAP reader
|
|
6
79
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Codec.d.ts","sourceRoot":"","sources":["../../../src/lib/codec/Codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,gCAAgC,CAAA;AAErE,OAAO,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAA;AAMzD,OAAO,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAA;AAE/C,OAAO,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"Codec.d.ts","sourceRoot":"","sources":["../../../src/lib/codec/Codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,gCAAgC,CAAA;AAErE,OAAO,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAA;AAMzD,OAAO,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAA;AAE/C,OAAO,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAA;AAe3D,eAAO,MAAM,OAAO,EAAE,sBAAsB,EAc3C,CAAA;AAED,qBAAa,KAAK;;IAMd,SAAS,KAAK,aAAa,IAAI,sBAAsB,EAAE,CAEtD;IAED,IAAW,aAAa,IAAI,WAAW,EAAE,CAExC;gBAEW,uBAAuB,GAAE,sBAAsB,EAAO;IAoBlE;;;OAGG;IACH,SAAS,CAAC,gBAAgB,IAAI,WAAW,EAAE;IAQ3C;;;OAGG;IACH,SAAS,CAAC,gBAAgB,IAAI,sBAAsB,EAAE;IAoDtD;;;OAGG;IACU,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAwBjE;;;OAGG;IACU,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAc9E"}
|
package/dist/lib/codec/Codec.js
CHANGED
|
@@ -13,12 +13,20 @@ const RawData_1 = require("./headers/RawData");
|
|
|
13
13
|
const TCP_1 = require("./headers/TCP");
|
|
14
14
|
const UDP_1 = require("./headers/UDP");
|
|
15
15
|
const VLAN_802dot1Q_1 = require("./headers/VLAN_802dot1Q");
|
|
16
|
+
const IPv6_1 = require("./headers/IPv6");
|
|
17
|
+
const IPv6HopByHopOptions_1 = require("./headers/IPv6HopByHopOptions");
|
|
18
|
+
const ICMPv6_1 = require("./headers/ICMPv6");
|
|
19
|
+
const ICMP_1 = require("./headers/ICMP");
|
|
16
20
|
exports.Headers = [
|
|
17
21
|
ARP_1.ARP,
|
|
18
22
|
EthernetII_1.EthernetII,
|
|
19
23
|
Goose_1.Goose,
|
|
20
24
|
IEC61850SampledValues_1.IEC61850SampledValues,
|
|
25
|
+
ICMP_1.ICMP,
|
|
21
26
|
IPv4_1.IPv4,
|
|
27
|
+
IPv6_1.IPv6,
|
|
28
|
+
IPv6HopByHopOptions_1.IPv6HopByHopOptions,
|
|
29
|
+
ICMPv6_1.ICMPv6,
|
|
22
30
|
RawData_1.RawData,
|
|
23
31
|
TCP_1.TCP,
|
|
24
32
|
UDP_1.UDP,
|
|
@@ -124,9 +124,10 @@ export declare abstract class BaseHeader {
|
|
|
124
124
|
* Read bytes from buffer
|
|
125
125
|
* @param offset
|
|
126
126
|
* @param length
|
|
127
|
+
* @param dryRun
|
|
127
128
|
* @protected
|
|
128
129
|
*/
|
|
129
|
-
protected readBytes(offset: number, length: number): Buffer;
|
|
130
|
+
protected readBytes(offset: number, length: number, dryRun?: boolean): Buffer;
|
|
130
131
|
/**
|
|
131
132
|
* Write bytes to buffer
|
|
132
133
|
* @param offset
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseHeader.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/abstracts/BaseHeader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAC,uBAAuB,EAAC,MAAM,sCAAsC,CAAA;AAC5E,OAAO,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAA;AACtD,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAA;AAExD,OAAO,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAA;AAEpD,OAAO,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAA;AAKtD,8BAAsB,UAAU;;IAE5B,SAAS,CAAC,MAAM,KAAK,cAAc,IAAI,WAAW,CAEjD;IAED,SAAS,CAAC,MAAM,CAAC,yCAAyC,CAAC,YAAY,EAAE,WAAW,EAAE,GAAG,WAAW;IAIpG,WAAkB,WAAW,IAAI,MAAM,CAEtC;IAED,WAAkB,aAAa,IAAI,MAAM,CAExC;IAED,WAAkB,eAAe,IAAI,kBAAkB,CAetD;W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;;;OAKG;IACH,SAAS,CAAC,wBAAwB,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAE,MAAU,GAAG,IAAI;IAOnG;;;;;;OAMG;IACH,SAAS,CAAC,0BAA0B,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAE,MAAU,GAAG,IAAI;IAOrG;;;;;;OAMG;IACH,SAAS,CAAC,0BAA0B,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAE,MAAU,GAAG,IAAI;IAOrG;;;OAGG;IACI,QAAQ,CAAC,cAAc,EAAE,cAAc,GAAG,cAAc;IAoB/D;;OAEG;IACU,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAapC;;OAEG;IACU,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAYvC"}
|
|
@@ -134,25 +134,34 @@ class BaseHeader {
|
|
|
134
134
|
* @param offset
|
|
135
135
|
* @param length
|
|
136
136
|
* @param expandBufferLength
|
|
137
|
+
* @param changeHeaderLength
|
|
137
138
|
* @private
|
|
138
139
|
*/
|
|
139
|
-
#readBytes(offset, length, expandBufferLength) {
|
|
140
|
+
#readBytes(offset, length, expandBufferLength, changeHeaderLength) {
|
|
140
141
|
const packetOffset = this.getPacketOffset(offset);
|
|
141
|
-
|
|
142
|
-
if (this.packet.length < readEndPos
|
|
143
|
-
|
|
142
|
+
let readEndPos = packetOffset + length;
|
|
143
|
+
if (this.packet.length < readEndPos) {
|
|
144
|
+
if (expandBufferLength) {
|
|
145
|
+
this.packet = Buffer.concat([this.packet, Buffer.alloc(readEndPos - this.packet.length, 0)]);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
readEndPos = this.packet.length;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
144
151
|
const headerLength = readEndPos - this.startPos;
|
|
145
|
-
|
|
152
|
+
if (changeHeaderLength)
|
|
153
|
+
this.headerLength = this.headerLength < headerLength ? headerLength : this.headerLength;
|
|
146
154
|
return this.packet.subarray(packetOffset, packetOffset + length);
|
|
147
155
|
}
|
|
148
156
|
/**
|
|
149
157
|
* Read bytes from buffer
|
|
150
158
|
* @param offset
|
|
151
159
|
* @param length
|
|
160
|
+
* @param dryRun
|
|
152
161
|
* @protected
|
|
153
162
|
*/
|
|
154
|
-
readBytes(offset, length) {
|
|
155
|
-
return this.#readBytes(offset, length, false);
|
|
163
|
+
readBytes(offset, length, dryRun = false) {
|
|
164
|
+
return this.#readBytes(offset, length, false, !dryRun);
|
|
156
165
|
}
|
|
157
166
|
/**
|
|
158
167
|
* Write bytes to buffer
|
|
@@ -163,7 +172,7 @@ class BaseHeader {
|
|
|
163
172
|
writeBytes(offset, buffer) {
|
|
164
173
|
const packetOffset = this.getPacketOffset(offset);
|
|
165
174
|
const writeEndPos = packetOffset + buffer.length;
|
|
166
|
-
this.#readBytes(offset, buffer.length, true);
|
|
175
|
+
this.#readBytes(offset, buffer.length, true, true);
|
|
167
176
|
this.packet.fill(buffer, packetOffset, writeEndPos);
|
|
168
177
|
}
|
|
169
178
|
/**
|
|
@@ -175,7 +184,7 @@ class BaseHeader {
|
|
|
175
184
|
* @protected
|
|
176
185
|
*/
|
|
177
186
|
readBits(offset, length, bitOffset, bitLength) {
|
|
178
|
-
const buffer = this.#readBytes(offset, length, false);
|
|
187
|
+
const buffer = this.#readBytes(offset, length, false, true);
|
|
179
188
|
const bitString = parseInt(buffer.toString('hex'), 16).toString(2).padStart(length * 8, '0');
|
|
180
189
|
return parseInt(bitString.substring(bitOffset, bitOffset + bitLength), 2);
|
|
181
190
|
}
|
|
@@ -189,7 +198,7 @@ class BaseHeader {
|
|
|
189
198
|
* @protected
|
|
190
199
|
*/
|
|
191
200
|
writeBits(offset, length, bitOffset, bitLength, value) {
|
|
192
|
-
const buffer = this.#readBytes(offset, length, true);
|
|
201
|
+
const buffer = this.#readBytes(offset, length, true, true);
|
|
193
202
|
let bitArray = Array.from(parseInt(buffer.toString('hex'), 16).toString(2).padStart(buffer.length * 8, '0'));
|
|
194
203
|
const valueBitArray = Array.from(value.toString(2).padStart(bitLength, '0'));
|
|
195
204
|
bitArray = bitArray.map((bit, index) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Goose.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/headers/Goose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAClD,OAAO,GAAG,MAAM,UAAU,CAAA;AA+B1B,qBAAa,KAAM,SAAQ,UAAU;IAEjC,SAAS,CAAC,WAAW,EAAE,GAAG,CAAA;IAE1B,SAAS,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAK;IAEvB,MAAM,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"Goose.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/headers/Goose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAClD,OAAO,GAAG,MAAM,UAAU,CAAA;AA+B1B,qBAAa,KAAM,SAAQ,UAAU;IAEjC,SAAS,CAAC,WAAW,EAAE,GAAG,CAAA;IAE1B,SAAS,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAK;IAEvB,MAAM,EAAE,kBAAkB,CA4mBhC;IAED,SAAgB,EAAE,EAAE,MAAM,CAAU;IAEpC,SAAgB,IAAI,EAAE,MAAM,CAAmB;IAE/C,SAAgB,QAAQ,EAAE,MAAM,CAAU;IAEnC,KAAK,IAAI,OAAO;CAI1B"}
|
|
@@ -109,9 +109,20 @@ class Goose extends BaseHeader_1.BaseHeader {
|
|
|
109
109
|
type: 'object',
|
|
110
110
|
label: 'GOOSE PDU',
|
|
111
111
|
decode: () => {
|
|
112
|
-
|
|
113
|
-
this.TLVInstance
|
|
114
|
-
|
|
112
|
+
let redTLVBufferLength = this.instance.length.getValue() - 8;
|
|
113
|
+
while (!this.TLVInstance) {
|
|
114
|
+
try {
|
|
115
|
+
const buffer = this.readBytes(8, redTLVBufferLength, true);
|
|
116
|
+
this.TLVInstance = node_tlv_1.default.parse(buffer);
|
|
117
|
+
this.readBytes(8, this.TLVInstance.length, false); //Update header length
|
|
118
|
+
}
|
|
119
|
+
catch (e) {
|
|
120
|
+
redTLVBufferLength -= 1;
|
|
121
|
+
if (!redTLVBufferLength)
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
this.TLVChild = this.TLVInstance ? this.TLVInstance.getChild() : [];
|
|
115
126
|
},
|
|
116
127
|
encode: () => {
|
|
117
128
|
let buffers = Buffer.from([]);
|
|
@@ -254,6 +265,8 @@ class Goose extends BaseHeader_1.BaseHeader {
|
|
|
254
265
|
},
|
|
255
266
|
encode: () => {
|
|
256
267
|
let stNumValue = this.instance.goosePdu.stNum.getValue(-1, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
268
|
+
if (stNumValue < 0)
|
|
269
|
+
return;
|
|
257
270
|
if (stNumValue < 1 || stNumValue > 4294967295) {
|
|
258
271
|
stNumValue = 4294967295;
|
|
259
272
|
this.recordError(this.instance.goosePdu.stNum.getPath(), 'This INTEGER value shall have a range of 1 to 4294967295');
|
|
@@ -277,6 +290,8 @@ class Goose extends BaseHeader_1.BaseHeader {
|
|
|
277
290
|
},
|
|
278
291
|
encode: () => {
|
|
279
292
|
let sqNumValue = this.instance.goosePdu.sqNum.getValue(-1, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
293
|
+
if (sqNumValue < 0)
|
|
294
|
+
return;
|
|
280
295
|
if (sqNumValue < 0 || sqNumValue > 4294967295) {
|
|
281
296
|
sqNumValue = 4294967295;
|
|
282
297
|
this.recordError(this.instance.goosePdu.sqNum.getPath(), 'This INTEGER value shall have a range of 1 to 4294967295');
|
|
@@ -540,7 +555,8 @@ class Goose extends BaseHeader_1.BaseHeader {
|
|
|
540
555
|
return;
|
|
541
556
|
allData.push(dataItem);
|
|
542
557
|
});
|
|
543
|
-
|
|
558
|
+
if (allData.length)
|
|
559
|
+
this.instance.goosePdu.allData.setValue(allData);
|
|
544
560
|
},
|
|
545
561
|
encode: () => {
|
|
546
562
|
const allData = this.instance.goosePdu.allData.getValue([], (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
@@ -679,10 +695,12 @@ class Goose extends BaseHeader_1.BaseHeader {
|
|
|
679
695
|
}
|
|
680
696
|
})
|
|
681
697
|
.filter((dataItemTLV) => !!dataItemTLV);
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
698
|
+
if (dataItemTLVs.length) {
|
|
699
|
+
let dataItemsHex = '';
|
|
700
|
+
dataItemTLVs.forEach(dataItemTLV => dataItemsHex = `${dataItemsHex}${dataItemTLV.toString()}`);
|
|
701
|
+
const allDataTLV = new node_tlv_1.default(0xAB, dataItemsHex);
|
|
702
|
+
this.TLVChild.push(allDataTLV);
|
|
703
|
+
}
|
|
686
704
|
}
|
|
687
705
|
}
|
|
688
706
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ProtocolJSONSchema } from '../../schema/ProtocolJSONSchema';
|
|
2
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
3
|
+
export declare class ICMP extends BaseHeader {
|
|
4
|
+
/**
|
|
5
|
+
* Calculate ICMPv4 checksum
|
|
6
|
+
* @protected
|
|
7
|
+
*/
|
|
8
|
+
protected calculateIcmpChecksum(): number;
|
|
9
|
+
SCHEMA: ProtocolJSONSchema;
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
nickname: string;
|
|
13
|
+
match(): boolean;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ICMP.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ICMP.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/headers/ICMP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAMlD,qBAAa,IAAK,SAAQ,UAAU;IAEhC;;;OAGG;IACH,SAAS,CAAC,qBAAqB,IAAI,MAAM;IA+BlC,MAAM,EAAE,kBAAkB,CA6FhC;IAEM,EAAE,EAAE,MAAM,CAAS;IAEnB,IAAI,EAAE,MAAM,CAAsC;IAElD,QAAQ,EAAE,MAAM,CAAS;IAEzB,KAAK,IAAI,OAAO;CAK1B"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ICMP = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const BufferToNumber_1 = require("../lib/BufferToNumber");
|
|
6
|
+
const NumberToBuffer_1 = require("../lib/NumberToBuffer");
|
|
7
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
8
|
+
const BufferToHex_1 = require("../lib/BufferToHex");
|
|
9
|
+
class ICMP extends BaseHeader_1.BaseHeader {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.SCHEMA = {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
type: {
|
|
16
|
+
type: 'integer',
|
|
17
|
+
label: 'Type',
|
|
18
|
+
minimum: 0,
|
|
19
|
+
maximum: 255,
|
|
20
|
+
decode: () => {
|
|
21
|
+
this.instance.type.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(0, 1)));
|
|
22
|
+
},
|
|
23
|
+
encode: () => {
|
|
24
|
+
const type = this.instance.type.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
25
|
+
this.instance.type.setValue(type);
|
|
26
|
+
this.writeBytes(0, (0, NumberToBuffer_1.UInt8ToBuffer)(type));
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
code: {
|
|
30
|
+
type: 'integer',
|
|
31
|
+
label: 'Code',
|
|
32
|
+
minimum: 0,
|
|
33
|
+
maximum: 255,
|
|
34
|
+
decode: () => {
|
|
35
|
+
this.instance.code.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(1, 1)));
|
|
36
|
+
},
|
|
37
|
+
encode: () => {
|
|
38
|
+
const code = this.instance.code.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
39
|
+
this.instance.code.setValue(code);
|
|
40
|
+
this.writeBytes(1, (0, NumberToBuffer_1.UInt8ToBuffer)(code));
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
checksum: {
|
|
44
|
+
type: 'integer',
|
|
45
|
+
label: 'Checksum',
|
|
46
|
+
minimum: 0,
|
|
47
|
+
maximum: 65535,
|
|
48
|
+
decode: () => {
|
|
49
|
+
this.instance.checksum.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
|
|
50
|
+
},
|
|
51
|
+
encode: () => {
|
|
52
|
+
let checksum = this.instance.checksum.getValue(0);
|
|
53
|
+
this.instance.checksum.setValue(checksum);
|
|
54
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
55
|
+
if (!checksum) {
|
|
56
|
+
checksum = this.calculateIcmpChecksum();
|
|
57
|
+
this.instance.checksum.setValue(checksum);
|
|
58
|
+
this.writeBytes(2, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
ident: {
|
|
63
|
+
type: 'number',
|
|
64
|
+
label: 'Identifier (BE)',
|
|
65
|
+
minimum: 0,
|
|
66
|
+
maximum: 65535,
|
|
67
|
+
decode: () => {
|
|
68
|
+
this.instance.ident.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(4, 2)));
|
|
69
|
+
},
|
|
70
|
+
encode: () => {
|
|
71
|
+
const ident = this.instance.ident.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
72
|
+
this.instance.ident.setValue(ident);
|
|
73
|
+
this.writeBytes(4, (0, NumberToBuffer_1.UInt16ToBuffer)(ident));
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
seq: {
|
|
77
|
+
type: 'number',
|
|
78
|
+
label: 'Sequence Number (BE)',
|
|
79
|
+
minimum: 0,
|
|
80
|
+
maximum: 65535,
|
|
81
|
+
decode: () => {
|
|
82
|
+
this.instance.seq.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(6, 2)));
|
|
83
|
+
},
|
|
84
|
+
encode: () => {
|
|
85
|
+
const seq = this.instance.seq.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
86
|
+
this.instance.seq.setValue(seq);
|
|
87
|
+
this.writeBytes(6, (0, NumberToBuffer_1.UInt16ToBuffer)(seq));
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
message: {
|
|
91
|
+
type: 'string',
|
|
92
|
+
label: 'Message Body',
|
|
93
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
94
|
+
decode: () => {
|
|
95
|
+
const messageDataLength = this.packet.length - this.startPos - 8;
|
|
96
|
+
this.instance.message.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(8, messageDataLength)));
|
|
97
|
+
},
|
|
98
|
+
encode: () => {
|
|
99
|
+
const messageHex = this.instance.message.getValue('');
|
|
100
|
+
this.instance.message.setValue(messageHex);
|
|
101
|
+
this.writeBytes(8, Buffer.from(messageHex, 'hex'));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
this.id = 'icmp';
|
|
107
|
+
this.name = 'Internet Control Message Protocol';
|
|
108
|
+
this.nickname = 'ICMP';
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Calculate ICMPv4 checksum
|
|
112
|
+
* @protected
|
|
113
|
+
*/
|
|
114
|
+
calculateIcmpChecksum() {
|
|
115
|
+
const icmpHeader = Buffer.concat([
|
|
116
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(this.instance.type.getValue(0)),
|
|
117
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(this.instance.code.getValue(0)),
|
|
118
|
+
(0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.checksum.getValue(0)),
|
|
119
|
+
(0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.ident.getValue(0)),
|
|
120
|
+
(0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.seq.getValue(0)),
|
|
121
|
+
Buffer.from(this.instance.message.getValue(''), 'hex')
|
|
122
|
+
]);
|
|
123
|
+
const paddedBuffer = icmpHeader.length % 2 === 1 ?
|
|
124
|
+
Buffer.concat([
|
|
125
|
+
icmpHeader,
|
|
126
|
+
(0, NumberToBuffer_1.UInt8ToBuffer)(0)
|
|
127
|
+
]) : icmpHeader;
|
|
128
|
+
// 4. 计算 checksum
|
|
129
|
+
let checksum = 0;
|
|
130
|
+
for (let i = 0; i < paddedBuffer.length; i += 2) {
|
|
131
|
+
const word = (paddedBuffer[i] << 8) | (paddedBuffer[i + 1] || 0);
|
|
132
|
+
checksum += word;
|
|
133
|
+
// 处理溢出
|
|
134
|
+
if (checksum > 0xFFFF) {
|
|
135
|
+
checksum = (checksum & 0xFFFF) + 1;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// 取反得到最终 checksum
|
|
139
|
+
return (~checksum) & 0xFFFF;
|
|
140
|
+
}
|
|
141
|
+
match() {
|
|
142
|
+
if (!this.prevCodecModule)
|
|
143
|
+
return false;
|
|
144
|
+
return this.prevCodecModule.instance.protocol.getValue() === 0x01;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.ICMP = ICMP;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ProtocolJSONSchema } from '../../schema/ProtocolJSONSchema';
|
|
2
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
3
|
+
export declare class ICMPv6 extends BaseHeader {
|
|
4
|
+
/**
|
|
5
|
+
* Calculate ICMPv6 checksum
|
|
6
|
+
* @protected
|
|
7
|
+
*/
|
|
8
|
+
protected calculateIcmpv6Checksum(): number;
|
|
9
|
+
SCHEMA: ProtocolJSONSchema;
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
nickname: string;
|
|
13
|
+
match(): boolean;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ICMPv6.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ICMPv6.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/headers/ICMPv6.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAQlD,qBAAa,MAAO,SAAQ,UAAU;IAElC;;;OAGG;IACH,SAAS,CAAC,uBAAuB,IAAI,MAAM;IAmCpC,MAAM,EAAE,kBAAkB,CAiEhC;IAEM,EAAE,EAAE,MAAM,CAAW;IAErB,IAAI,EAAE,MAAM,CAAyC;IAErD,QAAQ,EAAE,MAAM,CAAW;IAE3B,KAAK,IAAI,OAAO;CAI1B"}
|