netkitty 0.0.15 → 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/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 +10 -13
- package/package.json +1 -1
- package/src/NetKitty.ts +61 -0
- package/src/lib/codec/Codec.ts +8 -0
- 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 +12 -13
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IPv6 = void 0;
|
|
4
|
+
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const NumberToHex_1 = require("../lib/NumberToHex");
|
|
6
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
7
|
+
const BufferToNumber_1 = require("../lib/BufferToNumber");
|
|
8
|
+
const NumberToBuffer_1 = require("../lib/NumberToBuffer");
|
|
9
|
+
const BufferToIP_1 = require("../lib/BufferToIP");
|
|
10
|
+
const IPToBuffer_1 = require("../lib/IPToBuffer");
|
|
11
|
+
class IPv6 extends BaseHeader_1.BaseHeader {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.SCHEMA = {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
version: {
|
|
18
|
+
type: 'integer',
|
|
19
|
+
label: 'Version',
|
|
20
|
+
minimum: 0,
|
|
21
|
+
maximum: 15,
|
|
22
|
+
decode: () => {
|
|
23
|
+
this.instance.version.setValue(this.readBits(0, 1, 0, 4));
|
|
24
|
+
},
|
|
25
|
+
encode: () => {
|
|
26
|
+
const version = this.instance.version.getValue(6, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
27
|
+
this.instance.version.setValue(version);
|
|
28
|
+
this.writeBits(0, 1, 0, 4, version);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
tclass: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
label: 'Traffic Class',
|
|
34
|
+
properties: {
|
|
35
|
+
dscp: {
|
|
36
|
+
type: 'integer',
|
|
37
|
+
minimum: 0,
|
|
38
|
+
maximum: 63,
|
|
39
|
+
label: 'Differentiated Services Codepoint',
|
|
40
|
+
decode: () => {
|
|
41
|
+
this.instance.tclass.dscp.setValue(this.readBits(0, 4, 4, 6));
|
|
42
|
+
},
|
|
43
|
+
encode: () => {
|
|
44
|
+
const dscp = this.instance.tclass.dscp.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
45
|
+
this.instance.tclass.dscp.setValue(dscp);
|
|
46
|
+
this.writeBits(0, 4, 4, 6, dscp);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
ecn: {
|
|
50
|
+
type: 'integer',
|
|
51
|
+
label: 'Explicit Congestion Notification',
|
|
52
|
+
minimum: 0,
|
|
53
|
+
maximum: 3,
|
|
54
|
+
decode: () => {
|
|
55
|
+
this.instance.tclass.ecn.setValue(this.readBits(0, 4, 10, 2));
|
|
56
|
+
},
|
|
57
|
+
encode: () => {
|
|
58
|
+
const ecn = this.instance.tclass.ecn.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
59
|
+
this.instance.tclass.ecn.setValue(ecn);
|
|
60
|
+
this.writeBits(0, 4, 10, 2, ecn);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
flow: {
|
|
66
|
+
type: 'integer',
|
|
67
|
+
label: 'Flow Label',
|
|
68
|
+
minimum: 0,
|
|
69
|
+
maximum: 1048575,
|
|
70
|
+
decode: () => {
|
|
71
|
+
this.instance.flow.setValue(this.readBits(1, 3, 4, 20));
|
|
72
|
+
},
|
|
73
|
+
encode: () => {
|
|
74
|
+
const flow = this.instance.flow.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
75
|
+
this.instance.flow.setValue(flow);
|
|
76
|
+
this.writeBits(1, 3, 4, 20, flow);
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
plen: {
|
|
80
|
+
type: 'integer',
|
|
81
|
+
label: 'Payload Length',
|
|
82
|
+
minimum: 0,
|
|
83
|
+
maximum: 65535,
|
|
84
|
+
decode: () => {
|
|
85
|
+
this.instance.plen.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(4, 2)));
|
|
86
|
+
},
|
|
87
|
+
encode: () => {
|
|
88
|
+
const plen = this.instance.plen.getValue(0);
|
|
89
|
+
this.instance.plen.setValue(plen);
|
|
90
|
+
this.writeBytes(4, (0, NumberToBuffer_1.UInt16ToBuffer)(plen));
|
|
91
|
+
if (!plen) {
|
|
92
|
+
this.addPostPacketEncodeHandler(() => {
|
|
93
|
+
let startCount = false;
|
|
94
|
+
let totalLength = 0;
|
|
95
|
+
this.codecModules.forEach((codecModule) => {
|
|
96
|
+
if (codecModule === this)
|
|
97
|
+
startCount = true;
|
|
98
|
+
if (startCount)
|
|
99
|
+
totalLength += codecModule.length;
|
|
100
|
+
});
|
|
101
|
+
let payloadLength = totalLength - 40;
|
|
102
|
+
//The length is set to zero when a Hop-by-Hop extension header carries a Jumbo Payload option
|
|
103
|
+
if (payloadLength > 65535)
|
|
104
|
+
payloadLength = 0;
|
|
105
|
+
this.instance.plen.setValue(payloadLength);
|
|
106
|
+
this.writeBytes(4, (0, NumberToBuffer_1.UInt16ToBuffer)(payloadLength));
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
nxt: {
|
|
112
|
+
type: 'integer',
|
|
113
|
+
label: 'Next Header',
|
|
114
|
+
minimum: 0,
|
|
115
|
+
maximum: 255,
|
|
116
|
+
decode: () => {
|
|
117
|
+
this.instance.nxt.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(6, 1)));
|
|
118
|
+
},
|
|
119
|
+
encode: () => {
|
|
120
|
+
const nxt = this.instance.nxt.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
121
|
+
this.instance.nxt.setValue(nxt);
|
|
122
|
+
this.writeBytes(6, (0, NumberToBuffer_1.UInt8ToBuffer)(nxt));
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
hllm: {
|
|
126
|
+
type: 'integer',
|
|
127
|
+
label: 'Hop Limit',
|
|
128
|
+
minimum: 0,
|
|
129
|
+
maximum: 255,
|
|
130
|
+
decode: () => {
|
|
131
|
+
this.instance.hllm.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(7, 1)));
|
|
132
|
+
},
|
|
133
|
+
encode: () => {
|
|
134
|
+
const hllm = this.instance.hllm.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
135
|
+
this.instance.hllm.setValue(hllm);
|
|
136
|
+
this.writeBytes(7, (0, NumberToBuffer_1.UInt8ToBuffer)(hllm));
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
sip: {
|
|
140
|
+
type: 'string',
|
|
141
|
+
label: 'Source Address',
|
|
142
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.IPv6,
|
|
143
|
+
decode: () => {
|
|
144
|
+
this.instance.sip.setValue((0, BufferToIP_1.BufferToIPv6)(this.readBytes(8, 16)));
|
|
145
|
+
},
|
|
146
|
+
encode: () => {
|
|
147
|
+
const sip = this.instance.sip.getValue('0000:0000:0000:0000:0000:0000:0000:0000', (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
148
|
+
this.instance.sip.setValue(sip);
|
|
149
|
+
this.writeBytes(8, (0, IPToBuffer_1.IPv6ToBuffer)(sip));
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
dip: {
|
|
153
|
+
type: 'string',
|
|
154
|
+
label: 'Destination Address',
|
|
155
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.IPv6,
|
|
156
|
+
decode: () => {
|
|
157
|
+
this.instance.dip.setValue((0, BufferToIP_1.BufferToIPv6)(this.readBytes(24, 16)));
|
|
158
|
+
},
|
|
159
|
+
encode: () => {
|
|
160
|
+
const dip = this.instance.dip.getValue('0000:0000:0000:0000:0000:0000:0000:0000', (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
161
|
+
this.instance.dip.setValue(dip);
|
|
162
|
+
this.writeBytes(24, (0, IPToBuffer_1.IPv6ToBuffer)(dip));
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
this.id = 'ipv6';
|
|
168
|
+
this.name = 'Internet Protocol Version 6';
|
|
169
|
+
this.nickname = 'IPv6';
|
|
170
|
+
}
|
|
171
|
+
match() {
|
|
172
|
+
if (!this.prevCodecModule)
|
|
173
|
+
return false;
|
|
174
|
+
return this.prevCodecModule.instance.etherType.getValue() === (0, NumberToHex_1.UInt16ToHex)(0x86dd);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
exports.IPv6 = IPv6;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ProtocolJSONSchema } from '../../schema/ProtocolJSONSchema';
|
|
2
|
+
import { BaseHeader } from '../abstracts/BaseHeader';
|
|
3
|
+
import TLV from 'node-tlv';
|
|
4
|
+
declare enum Type {
|
|
5
|
+
PadN = "PadN",
|
|
6
|
+
Tunnel_Encapsulation_Limit = "Tunnel-Encapsulation-Limit",
|
|
7
|
+
Router_Alert = "Router-Alert",
|
|
8
|
+
CALIPSO = "CALIPSO",
|
|
9
|
+
SMF_DPD = "SMF_DPD",
|
|
10
|
+
MPL_Option = "MPL-Option",
|
|
11
|
+
ILNP_Nonce = "ILNP-Nonce",
|
|
12
|
+
Line_Identification_Option = "Line-Identification-Option",
|
|
13
|
+
IPv6_DFF_Header = "IPv6-DFF-Header",
|
|
14
|
+
Endpoint_Identification = "Endpoint-Identification"
|
|
15
|
+
}
|
|
16
|
+
type PadN = {
|
|
17
|
+
type: Type.PadN;
|
|
18
|
+
n: number;
|
|
19
|
+
};
|
|
20
|
+
type Tunnel_Encapsulation_Limit = {
|
|
21
|
+
type: Type.Tunnel_Encapsulation_Limit;
|
|
22
|
+
limit: number;
|
|
23
|
+
};
|
|
24
|
+
type Router_Alert = {
|
|
25
|
+
type: Type.Router_Alert;
|
|
26
|
+
alert: string;
|
|
27
|
+
};
|
|
28
|
+
type CALIPSO = {
|
|
29
|
+
type: Type.CALIPSO;
|
|
30
|
+
tag: string;
|
|
31
|
+
};
|
|
32
|
+
type SMF_DPD = {
|
|
33
|
+
type: Type.SMF_DPD;
|
|
34
|
+
hash: string;
|
|
35
|
+
};
|
|
36
|
+
type MPL_Option = {
|
|
37
|
+
type: Type.MPL_Option;
|
|
38
|
+
value: string;
|
|
39
|
+
};
|
|
40
|
+
type ILNP_Nonce = {
|
|
41
|
+
type: Type.ILNP_Nonce;
|
|
42
|
+
nonce: string;
|
|
43
|
+
};
|
|
44
|
+
type Line_Identification_Option = {
|
|
45
|
+
type: Type.Line_Identification_Option;
|
|
46
|
+
id: string;
|
|
47
|
+
};
|
|
48
|
+
type IPv6_DFF_Header = {
|
|
49
|
+
type: Type.IPv6_DFF_Header;
|
|
50
|
+
message: string;
|
|
51
|
+
};
|
|
52
|
+
type Endpoint_Identification = {
|
|
53
|
+
type: Type.Endpoint_Identification;
|
|
54
|
+
id: string;
|
|
55
|
+
};
|
|
56
|
+
type Custom = {
|
|
57
|
+
type: number;
|
|
58
|
+
data: string;
|
|
59
|
+
};
|
|
60
|
+
export declare class IPv6HopByHopOptions extends BaseHeader {
|
|
61
|
+
protected itemTLVs: TLV[];
|
|
62
|
+
protected items: (PadN | Tunnel_Encapsulation_Limit | Router_Alert | CALIPSO | SMF_DPD | MPL_Option | ILNP_Nonce | Line_Identification_Option | IPv6_DFF_Header | Endpoint_Identification | Custom)[];
|
|
63
|
+
SCHEMA: ProtocolJSONSchema;
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
nickname: string;
|
|
67
|
+
readonly isProtocol: boolean;
|
|
68
|
+
match(): boolean;
|
|
69
|
+
}
|
|
70
|
+
export {};
|
|
71
|
+
//# sourceMappingURL=IPv6HopByHopOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IPv6HopByHopOptions.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/headers/IPv6HopByHopOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAIlD,OAAO,GAAG,MAAM,UAAU,CAAA;AAc1B,aAAK,IAAI;IAC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