@netkitty/codec 2.1.0 → 2.2.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.
Files changed (76) hide show
  1. package/CHANGELOG.md +188 -0
  2. package/README.md +21 -1
  3. package/README.zh-CN.md +19 -1
  4. package/dist/Codec.d.ts +4 -3
  5. package/dist/Codec.js +44 -5
  6. package/dist/PacketHeaders.d.ts +2 -0
  7. package/dist/PacketHeaders.js +8 -4
  8. package/dist/abstracts/BaseHeader.d.ts +17 -0
  9. package/dist/abstracts/BaseHeader.js +22 -0
  10. package/dist/headers/ARP.d.ts +3 -1
  11. package/dist/headers/ARP.js +8 -1
  12. package/dist/headers/BACnetIP.js +2 -1
  13. package/dist/headers/BGP.js +3 -2
  14. package/dist/headers/Babel.js +1 -1
  15. package/dist/headers/Codesys.js +3 -2
  16. package/dist/headers/DHCP.js +2 -1
  17. package/dist/headers/DNP3.d.ts +12 -7
  18. package/dist/headers/DNP3.js +98 -18
  19. package/dist/headers/DTLS.js +5 -3
  20. package/dist/headers/Diameter.js +2 -1
  21. package/dist/headers/Elasticsearch.js +3 -2
  22. package/dist/headers/EthernetII.d.ts +1 -0
  23. package/dist/headers/EthernetII.js +3 -0
  24. package/dist/headers/Goose.d.ts +31 -7
  25. package/dist/headers/Goose.js +409 -168
  26. package/dist/headers/HARTIP.js +2 -2
  27. package/dist/headers/IEC104_I_Frame.d.ts +28 -0
  28. package/dist/headers/IEC104_I_Frame.js +246 -160
  29. package/dist/headers/IEC104_S_Frame.js +3 -3
  30. package/dist/headers/IEC104_U_Frame.js +5 -3
  31. package/dist/headers/IEC61850SampledValues.d.ts +1 -0
  32. package/dist/headers/IEC61850SampledValues.js +16 -1
  33. package/dist/headers/IPFIX.js +2 -1
  34. package/dist/headers/IPv4.d.ts +1 -0
  35. package/dist/headers/IPv4.js +6 -0
  36. package/dist/headers/IPv6.d.ts +1 -0
  37. package/dist/headers/IPv6.js +6 -0
  38. package/dist/headers/IPv6HopByHopOptions.js +8 -0
  39. package/dist/headers/KNXnetIP.js +3 -2
  40. package/dist/headers/LACP.js +2 -1
  41. package/dist/headers/LDP.js +2 -2
  42. package/dist/headers/MQTT.js +3 -1
  43. package/dist/headers/MarkerProtocol.js +2 -1
  44. package/dist/headers/NetFlowV5.js +2 -1
  45. package/dist/headers/OPCUA.js +4 -0
  46. package/dist/headers/OSPF.d.ts +2 -2
  47. package/dist/headers/OSPF.js +26 -5
  48. package/dist/headers/OSPFv3.d.ts +37 -0
  49. package/dist/headers/OSPFv3.js +314 -0
  50. package/dist/headers/PPTP.js +2 -2
  51. package/dist/headers/QUIC.js +8 -3
  52. package/dist/headers/RGoose.js +2 -1
  53. package/dist/headers/RIP.js +3 -2
  54. package/dist/headers/RIPng.js +3 -2
  55. package/dist/headers/RTCP.js +3 -2
  56. package/dist/headers/RTP.js +3 -2
  57. package/dist/headers/SFlow.js +4 -2
  58. package/dist/headers/SLMP.js +2 -1
  59. package/dist/headers/SLP.js +2 -1
  60. package/dist/headers/SLPv1.js +2 -1
  61. package/dist/headers/SMB1.js +3 -2
  62. package/dist/headers/SMB2.js +3 -2
  63. package/dist/headers/STUN.js +2 -1
  64. package/dist/headers/TLS_Handshake.d.ts +6 -0
  65. package/dist/headers/TLS_Handshake.js +28 -3
  66. package/dist/headers/TacacsPlus.js +3 -1
  67. package/dist/headers/Trailer.d.ts +30 -0
  68. package/dist/headers/Trailer.js +63 -0
  69. package/dist/headers/VLAN_802dot1Q.d.ts +1 -0
  70. package/dist/headers/VLAN_802dot1Q.js +3 -0
  71. package/dist/headers/WakeOnLAN.js +2 -1
  72. package/dist/headers/WireGuard.js +3 -2
  73. package/dist/headers/Zabbix.js +2 -2
  74. package/dist/lib/BERElement.d.ts +51 -0
  75. package/dist/lib/BERElement.js +125 -0
  76. package/package.json +2 -2
@@ -69,14 +69,16 @@ class IEC104_S_Frame extends BaseHeader_1.BaseHeader {
69
69
  });
70
70
  }
71
71
  },
72
+ //Default 01000000: the S-format bits match() requires, acknowledging N(R) 0.
72
73
  controlField: {
73
74
  type: 'string',
74
75
  label: 'Control Field',
76
+ default: '01000000',
75
77
  decode: () => {
76
78
  this.instance.controlField.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(2, 4)));
77
79
  },
78
80
  encode: () => {
79
- this.writeBytes(2, (0, HexToBuffer_1.HexToBuffer)(this.instance.controlField.getValue('0', (nodePath) => this.recordError(nodePath, 'Not Found'))));
81
+ this.writeBytes(2, (0, HexToBuffer_1.HexToBuffer)(this.instance.controlField.getValue('01000000', (nodePath) => this.recordError(nodePath, 'Not Found'))));
80
82
  }
81
83
  },
82
84
  //Receive sequence number N(R): a 15-bit value in control octets 3-4, stored
@@ -93,8 +95,6 @@ class IEC104_S_Frame extends BaseHeader_1.BaseHeader {
93
95
  apciType: {
94
96
  type: 'string',
95
97
  label: 'APCI Type',
96
- minimum: 0,
97
- maximum: 3,
98
98
  decode: () => {
99
99
  const controlType = this.readBits(2, 1, 7, 1);
100
100
  switch (controlType) {
@@ -70,21 +70,23 @@ class IEC104_U_Frame extends BaseHeader_1.BaseHeader {
70
70
  });
71
71
  }
72
72
  },
73
+ //Default 07000000 (STARTDT act): a U-frame needs both low bits of the first control octet set,
74
+ //which match() requires. The default sits here, not on apciType, which overrides this field
75
+ //when given and leaves it alone when left out.
73
76
  controlField: {
74
77
  type: 'string',
75
78
  label: 'Control Field',
79
+ default: '07000000',
76
80
  decode: () => {
77
81
  this.instance.controlField.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(2, 4)));
78
82
  },
79
83
  encode: () => {
80
- this.writeBytes(2, (0, HexToBuffer_1.HexToBuffer)(this.instance.controlField.getValue('00000000', (nodePath) => this.recordError(nodePath, 'Not Found'))));
84
+ this.writeBytes(2, (0, HexToBuffer_1.HexToBuffer)(this.instance.controlField.getValue('07000000', (nodePath) => this.recordError(nodePath, 'Not Found'))));
81
85
  }
82
86
  },
83
87
  apciType: {
84
88
  type: 'string',
85
89
  label: 'APCI Type',
86
- minimum: 0,
87
- maximum: 3,
88
90
  decode: () => {
89
91
  const uframeType = (0, BufferToHex_1.BufferToHex)(this.readBytes(2, 4));
90
92
  switch (uframeType) {
@@ -17,4 +17,5 @@ export declare class IEC61850SampledValues extends BaseHeader {
17
17
  readonly name: string;
18
18
  readonly nickname: string;
19
19
  match(): boolean;
20
+ payloadEnd(): number | undefined;
20
21
  }
@@ -13,6 +13,7 @@ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
13
13
  const BufferToNumber_1 = require("../helper/BufferToNumber");
14
14
  const BufferToHex_1 = require("../helper/BufferToHex");
15
15
  const NumberToBuffer_1 = require("../helper/NumberToBuffer");
16
+ const BERElement_1 = require("../lib/BERElement");
16
17
  class IEC61850SampledValues extends BaseHeader_1.BaseHeader {
17
18
  constructor() {
18
19
  super(...arguments);
@@ -113,7 +114,14 @@ class IEC61850SampledValues extends BaseHeader_1.BaseHeader {
113
114
  //non-standard SV PDU whose BER cannot be parsed is recorded as an error.
114
115
  const buffer = this.readBytes(8, (this.instance.length.getValue()) - 8);
115
116
  try {
116
- this.TLVInstance = node_tlv_1.default.parse(buffer);
117
+ const svPduTLV = node_tlv_1.default.parse(buffer);
118
+ //node-tlv clips an element that runs past the octets available instead of failing,
119
+ //so a savPdu truncated by Length decoded with a shortened last field and lost
120
+ //octets on re-encode. Only BER that fills Length exactly is parsed into fields.
121
+ const malformed = (0, BERElement_1.MalformedBER)(buffer);
122
+ if (malformed)
123
+ throw new Error(malformed);
124
+ this.TLVInstance = svPduTLV;
117
125
  this.TLVChild = this.TLVInstance.getChild();
118
126
  }
119
127
  catch (e) {
@@ -417,5 +425,12 @@ class IEC61850SampledValues extends BaseHeader_1.BaseHeader {
417
425
  return false;
418
426
  return this.prevCodecModule.instance.etherType.getValue() === (0, NumberToHex_1.UInt16ToHex)(0x88ba);
419
427
  }
428
+ payloadEnd() {
429
+ //Length counts the octets from APPID on: the 8-octet header plus the savPdu (IEC 61850-9-2).
430
+ //Bytes past it (Ethernet padding, a trailer) are not SV. A Length shorter than the header sets
431
+ //no bound.
432
+ const length = this.instance.length.getValue(0);
433
+ return length >= 8 ? this.startPos + length : undefined;
434
+ }
420
435
  }
421
436
  exports.IEC61850SampledValues = IEC61850SampledValues;
@@ -44,7 +44,8 @@ class IPFIX extends BaseHeader_1.BaseHeader {
44
44
  properties: {
45
45
  //Version Number (RFC 7011 §3.1): always 10 for IPFIX. Kept as a plain uint16 (clamped in
46
46
  //the closure, no hard enum) so a crafted non-10 value still round-trips byte-for-byte.
47
- version: this.fieldUInt('version', 0, 2, 'Version'),
47
+ //Default 10: what match() requires.
48
+ version: { ...this.fieldUInt('version', 0, 2, 'Version'), default: 10 },
48
49
  length: {
49
50
  type: 'integer',
50
51
  autoCalculated: true,
@@ -16,5 +16,6 @@ export declare class IPv4 extends BaseHeader {
16
16
  readonly demuxProducers: DemuxProducer[];
17
17
  readonly name: string;
18
18
  readonly nickname: string;
19
+ payloadEnd(): number | undefined;
19
20
  match(): boolean;
20
21
  }
@@ -360,6 +360,12 @@ class IPv4 extends BaseHeader_1.BaseHeader {
360
360
  }
361
361
  };
362
362
  }
363
+ payloadEnd() {
364
+ //Total Length counts this header and its payload. 0 (a segmentation-offload capture) or a value
365
+ //shorter than the header sets no bound.
366
+ const totalLength = this.instance.length.getValue(0);
367
+ return totalLength >= this.length ? this.startPos + totalLength : undefined;
368
+ }
363
369
  match() {
364
370
  if (!this.prevCodecModule)
365
371
  return false;
@@ -25,5 +25,6 @@ export declare class IPv6 extends BaseHeader {
25
25
  readonly demuxProducers: DemuxProducer[];
26
26
  name: string;
27
27
  nickname: string;
28
+ payloadEnd(): number | undefined;
28
29
  match(): boolean;
29
30
  }
@@ -193,6 +193,12 @@ class IPv6 extends BaseHeader_1.BaseHeader {
193
193
  this.name = 'Internet Protocol Version 6';
194
194
  this.nickname = 'IPv6';
195
195
  }
196
+ payloadEnd() {
197
+ //Payload Length counts everything after this 40-octet header, extension headers included. 0 (a
198
+ //Jumbo Payload, or a segmentation-offload capture) sets no bound.
199
+ const payloadLength = this.instance.plen.getValue(0);
200
+ return payloadLength > 0 ? this.endPos + payloadLength : undefined;
201
+ }
196
202
  match() {
197
203
  if (!this.prevCodecModule)
198
204
  return false;
@@ -34,6 +34,8 @@ var Type;
34
34
  Type["IPv6_DFF_Header"] = "IPv6-DFF-Header";
35
35
  Type["Endpoint_Identification"] = "Endpoint-Identification";
36
36
  })(Type || (Type = {}));
37
+ //Value octets of the options whose item has a fixed-size value, by option type
38
+ const FIXED_OPTION_LENGTHS = { 0x04: 1, 0x05: 2, 0x07: 8, 0x0C: 6, 0x0D: 4, 0x8A: 16 };
37
39
  class IPv6HopByHopOptions extends BaseHeader_1.BaseHeader {
38
40
  constructor() {
39
41
  super(...arguments);
@@ -475,6 +477,12 @@ class IPv6HopByHopOptions extends BaseHeader_1.BaseHeader {
475
477
  * Unknown types become a Custom item so they still round-trip.
476
478
  */
477
479
  decodeHbhOption(type, length, valueHex) {
480
+ //An option whose item has a fixed size (Tunnel Encapsulation Limit 1 octet, Router Alert 2,
481
+ //CALIPSO tag 8, ILNP Nonce 6, Line-Identification 4, Endpoint Identification 16) but arrived
482
+ //with another size is kept as a Custom item: the typed item's schema would reject its value.
483
+ const fixedLength = FIXED_OPTION_LENGTHS[type];
484
+ if (fixedLength !== undefined && valueHex.length !== fixedLength * 2)
485
+ return { type: type, data: valueHex };
478
486
  switch (type) {
479
487
  case 0x01: return { type: Type.PadN, n: length };
480
488
  case 0x04: return { type: Type.Tunnel_Encapsulation_Limit, limit: (0, HexToNumber_1.HexToUInt8)(valueHex) };
@@ -65,9 +65,10 @@ class KNXnetIP extends BaseHeader_1.BaseHeader {
65
65
  properties: {
66
66
  //Header Length — the size of this header in octets, 0x06 for the current KNXnet/IP spec.
67
67
  //Kept as a plain clamped byte (honored verbatim) so a crafted frame still round-trips.
68
- headerLength: this.fieldUInt('headerLength', 0, 1, 'Header Length'),
68
+ //Defaults 0x06 and 0x10 here and below: the signature match() requires.
69
+ headerLength: { ...this.fieldUInt('headerLength', 0, 1, 'Header Length'), default: 0x06 },
69
70
  //Protocol Version — 0x10 (1.0) for the current spec. Kept verbatim.
70
- protocolVersion: this.fieldUInt('protocolVersion', 1, 1, 'Protocol Version'),
71
+ protocolVersion: { ...this.fieldUInt('protocolVersion', 1, 1, 'Protocol Version'), default: 0x10 },
71
72
  //Service Type Identifier (e.g. 0x0201 SEARCH_REQUEST, 0x0420 TUNNELLING_REQUEST). Kept as a
72
73
  //plain clamped uint16 (NOT an Ajv enum) so any non-standard / crafted service type decoded
73
74
  //from the wire still re-encodes without being rejected — decode never fails, encode faithful.
@@ -44,7 +44,8 @@ class LACP extends BaseHeader_1.BaseHeader {
44
44
  type: 'object',
45
45
  summary: 'LACP v${version} ${tlvs.length} TLVs',
46
46
  properties: {
47
- subtype: this.fieldUInt('subtype', 0, 1, 'Subtype'),
47
+ //Default 1: the Slow Protocols subtype of LACP, and what match() requires.
48
+ subtype: { ...this.fieldUInt('subtype', 0, 1, 'Subtype'), default: 1 },
48
49
  version: this.fieldUInt('version', 1, 1, 'Version'),
49
50
  tlvs: {
50
51
  type: 'array',
@@ -62,8 +62,8 @@ class LDP extends BaseHeader_1.BaseHeader {
62
62
  type: 'object',
63
63
  summary: 'LDP lsr=${lsrId}:${labelSpace}',
64
64
  properties: {
65
- //Version of the LDP protocol; RFC 5036 defines version 1.
66
- version: this.fieldUInt('version', 0, 2, 'Version'),
65
+ //Version of the LDP protocol; RFC 5036 defines version 1. Default 1: what match() requires.
66
+ version: { ...this.fieldUInt('version', 0, 2, 'Version'), default: 1 },
67
67
  pduLength: {
68
68
  type: 'integer',
69
69
  autoCalculated: true,
@@ -80,12 +80,14 @@ class MQTT extends BaseHeader_1.BaseHeader {
80
80
  type: 'object',
81
81
  summary: 'MQTT type=${messageType}',
82
82
  properties: {
83
- //First byte, high nibble (bits 7-4): the Control Packet type.
83
+ //First byte, high nibble (bits 7-4): the Control Packet type. Default 12 (PINGREQ, complete
84
+ //without a payload): match() rejects the reserved type 0.
84
85
  messageType: {
85
86
  type: 'integer',
86
87
  label: 'Message Type',
87
88
  minimum: 0,
88
89
  maximum: 15,
90
+ default: 12,
89
91
  decode: function () {
90
92
  this.instance.messageType.setValue(this.readBits(0, 1, 0, 4));
91
93
  },
@@ -45,7 +45,8 @@ class MarkerProtocol extends BaseHeader_1.BaseHeader {
45
45
  type: 'object',
46
46
  summary: 'Marker v${version} ${tlvs.length} TLVs',
47
47
  properties: {
48
- subtype: this.fieldUInt('subtype', 0, 1, 'Subtype'),
48
+ //Default 2: the Slow Protocols subtype of the Marker Protocol, and what match() requires.
49
+ subtype: { ...this.fieldUInt('subtype', 0, 1, 'Subtype'), default: 2 },
49
50
  version: this.fieldUInt('version', 1, 1, 'Version'),
50
51
  tlvs: {
51
52
  type: 'array',
@@ -85,7 +85,8 @@ class NetFlowV5 extends BaseHeader_1.BaseHeader {
85
85
  type: 'object',
86
86
  summary: 'NetFlow v5 ${count} flows',
87
87
  properties: {
88
- version: this.fieldUInt('version', 0, 2, 'Version'),
88
+ //Default 5: the NetFlow v5 version, and what match() requires.
89
+ version: { ...this.fieldUInt('version', 0, 2, 'Version'), default: 5 },
89
90
  count: {
90
91
  type: 'integer',
91
92
  autoCalculated: true,
@@ -51,9 +51,11 @@ class OPCUA extends BaseHeader_1.BaseHeader {
51
51
  //3-byte ASCII message type (HEL/ACK/ERR/OPN/MSG/CLO/RHE/RHF). Kept as a string; encode
52
52
  //writes exactly 3 bytes (a decoded value is always 3 chars; a crafted value is truncated
53
53
  //or zero-padded to 3) so a well-formed message round-trips byte-for-byte.
54
+ //Default HEL (Hello, the first message of a connection): match() requires a known type.
54
55
  messageType: {
55
56
  type: 'string',
56
57
  label: 'Message Type',
58
+ default: 'HEL',
57
59
  minLength: 3,
58
60
  maxLength: 3,
59
61
  contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.ASCII,
@@ -71,9 +73,11 @@ class OPCUA extends BaseHeader_1.BaseHeader {
71
73
  },
72
74
  //1-byte ASCII chunk / IsFinal indicator (F/C/A). Kept as a string; encode writes exactly
73
75
  //1 byte.
76
+ //Default F (final chunk): match() requires a known chunk type.
74
77
  chunk: {
75
78
  type: 'string',
76
79
  label: 'Chunk',
80
+ default: 'F',
77
81
  minLength: 1,
78
82
  maxLength: 1,
79
83
  contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.ASCII,
@@ -16,8 +16,8 @@ import { DemuxProducer } from '../types/DemuxProducer';
16
16
  * Neighbors list (4-octet Router IDs from offset 44 onward). For all other types the payload is kept
17
17
  * verbatim as `rawBody` hex from offset 24. Both are bounded by min(Packet Length, the bytes the IP layer
18
18
  * below actually made available) and never below the 24-octet header, so a lying length field can't read
19
- * past the real IP payload. match() fires on IPv4 protocol 89 or IPv6 Next Header 89 with a full common
20
- * header present.
19
+ * past the real IP payload. match() fires on IPv4 protocol 89 or IPv6 Next Header 89 with Version 2 and a
20
+ * full common header present; Version 3 on the same protocol number is OSPFv3, a separate header.
21
21
  */
22
22
  export declare class OSPF extends BaseHeader {
23
23
  #private;
@@ -24,8 +24,8 @@ const Checksum_1 = require("../helper/Checksum");
24
24
  * Neighbors list (4-octet Router IDs from offset 44 onward). For all other types the payload is kept
25
25
  * verbatim as `rawBody` hex from offset 24. Both are bounded by min(Packet Length, the bytes the IP layer
26
26
  * below actually made available) and never below the 24-octet header, so a lying length field can't read
27
- * past the real IP payload. match() fires on IPv4 protocol 89 or IPv6 Next Header 89 with a full common
28
- * header present.
27
+ * past the real IP payload. match() fires on IPv4 protocol 89 or IPv6 Next Header 89 with Version 2 and a
28
+ * full common header present; Version 3 on the same protocol number is OSPFv3, a separate header.
29
29
  */
30
30
  class OSPF extends BaseHeader_1.BaseHeader {
31
31
  constructor() {
@@ -96,7 +96,25 @@ class OSPF extends BaseHeader_1.BaseHeader {
96
96
  summary: 'OSPF type=${type} rid=${routerId}',
97
97
  properties: {
98
98
  //==== Common header (24 bytes, RFC 2328 §A.3.1) ====
99
- version: this.fieldUInt('version', 0, 1, 'Version'),
99
+ //Default 2, what match() requires. Version 3 is still written in the OSPFv2 layout given
100
+ //here, with a warning: OSPFv3 (RFC 5340) has its own header and checksum, see OSPFv3.
101
+ version: {
102
+ type: 'integer',
103
+ label: 'Version',
104
+ minimum: 0,
105
+ maximum: 255,
106
+ default: 2,
107
+ decode: function () {
108
+ this.instance.version.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(0, 1)));
109
+ },
110
+ encode: function () {
111
+ const version = this.instance.version.getValue(2);
112
+ this.instance.version.setValue(version);
113
+ this.writeBytes(0, (0, NumberToBuffer_1.UInt8ToBuffer)(version));
114
+ if (version === 3)
115
+ this.recordError(this.instance.version.getPath(), 'Version 3 is OSPFv3, whose header and checksum differ from OSPFv2: encode it as \'ospfv3\'. This layer writes the OSPFv2 layout');
116
+ }
117
+ },
100
118
  type: this.fieldUInt('type', 1, 1, 'Message Type'),
101
119
  //The whole OSPF packet including this header; left out, the bytes actually written, filled
102
120
  //once every field is encoded (before the checksum); a given value is written as given.
@@ -419,12 +437,15 @@ class OSPF extends BaseHeader_1.BaseHeader {
419
437
  return false;
420
438
  //OSPF sits directly on IP (protocol 89). Accept the demux value from either the IPv4
421
439
  //protocol field or the IPv6 next-header field, and require at least a full 24-byte common
422
- //header of IP payload to be present.
440
+ //header of IP payload to be present. Version 2 only: version 3 on protocol 89 is the separate
441
+ //OSPFv3 header.
423
442
  const protocol = this.prevCodecModule.instance.protocol.getValue(0);
424
443
  const nextHeader = this.prevCodecModule.instance.nxt.getValue(0);
425
444
  if (protocol !== 89 && nextHeader !== 89)
426
445
  return false;
427
- return this.#available() >= 24;
446
+ if (this.#available() < 24)
447
+ return false;
448
+ return this.readBytes(0, 1, true)[0] === 2;
428
449
  }
429
450
  }
430
451
  exports.OSPF = OSPF;
@@ -0,0 +1,37 @@
1
+ import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
2
+ import { BaseHeader } from '../abstracts/BaseHeader';
3
+ import { DemuxProducer } from '../types/DemuxProducer';
4
+ /**
5
+ * OSPFv3 — Open Shortest Path First for IPv6 (RFC 5340), carried on IPv6 as Next Header 89 (the same
6
+ * protocol number as OSPFv2, told apart by the Version octet). This codec decodes the 16-octet common
7
+ * header (RFC 5340 §A.3.1): an 8-bit Version (`version`, offset 0, 3), an 8-bit Message Type (`type`,
8
+ * offset 1; 1 Hello, 2 Database Description, 3 LS Request, 4 LS Update, 5 LS Ack), a 16-bit Packet Length
9
+ * (`packetLength`, offset 2), the Router ID (`routerId`, offset 4) and Area ID (`areaId`, offset 8) in
10
+ * dotted-quad form, a 16-bit Checksum (`checksum`, offset 12), an 8-bit Instance ID (`instanceId`, offset
11
+ * 14) and a Reserved octet (`reserved`, hex, offset 15). Unlike OSPFv2 there is no authentication in the
12
+ * header (RFC 4552 IPsec, or the RFC 7166 trailer after the packet, does that job). Packet Length and
13
+ * Checksum are computed on encode when left out and written as given otherwise; the checksum is the
14
+ * Internet checksum of the whole packet with the IPv6 pseudo-header prepended, its Upper-Layer Packet
15
+ * Length being the Packet Length field (§A.3.1).
16
+ *
17
+ * For a Hello (type 1, §A.3.2) the body is decoded field by field: Interface ID (offset 16), Router
18
+ * Priority (offset 20), the 24-bit Options (offset 21; V6 0x01, E 0x02, MC 0x04, N 0x08, R 0x10, DC 0x20,
19
+ * AF 0x100, L 0x200, AT 0x400), Hello Interval and Router Dead Interval (16 bits each, offsets 24 and 26),
20
+ * Designated and Backup Designated Router IDs (offsets 28 and 32), then the Router IDs of the neighbours
21
+ * (4 octets each from offset 36). Built from defaults, a Hello carries priority 1, Options V6|E|R, hello
22
+ * interval 10 and dead interval 40. For all other types the body is kept verbatim as `rawBody` hex from
23
+ * offset 16. Both are bounded by min(Packet Length, the end of the IPv6 payload) and never below the
24
+ * 16-octet header, so a lying length can't read past the real IP payload. match() fires on Next Header
25
+ * 89 with an IPv6 layer beneath (directly, or behind AH / an extension header), Version 3 and a full
26
+ * common header present.
27
+ */
28
+ export declare class OSPFv3 extends BaseHeader {
29
+ #private;
30
+ get SCHEMA(): ProtocolJSONSchema;
31
+ readonly id: string;
32
+ readonly matchKeys: string[];
33
+ readonly name: string;
34
+ readonly nickname: string;
35
+ readonly demuxProducers: DemuxProducer[];
36
+ match(): boolean;
37
+ }