@netkitty/codec 2.1.0 → 2.3.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 +249 -0
- package/README.md +30 -1
- package/README.zh-CN.md +26 -1
- package/dist/Codec.d.ts +25 -7
- package/dist/Codec.js +151 -18
- package/dist/PacketHeaders.d.ts +2 -0
- package/dist/PacketHeaders.js +8 -4
- package/dist/abstracts/BaseHeader.d.ts +34 -0
- package/dist/abstracts/BaseHeader.js +43 -0
- package/dist/headers/ARP.d.ts +3 -1
- package/dist/headers/ARP.js +8 -1
- package/dist/headers/BACnetIP.js +2 -1
- package/dist/headers/BGP.js +3 -2
- package/dist/headers/Babel.js +1 -1
- package/dist/headers/Codesys.js +3 -2
- package/dist/headers/DHCP.js +2 -1
- package/dist/headers/DNP3.d.ts +12 -7
- package/dist/headers/DNP3.js +98 -18
- package/dist/headers/DTLS.js +5 -3
- package/dist/headers/Diameter.js +2 -1
- package/dist/headers/Elasticsearch.js +3 -2
- package/dist/headers/EthernetII.d.ts +1 -0
- package/dist/headers/EthernetII.js +3 -0
- package/dist/headers/Goose.d.ts +31 -7
- package/dist/headers/Goose.js +409 -168
- package/dist/headers/HARTIP.js +2 -2
- package/dist/headers/ICMP.d.ts +1 -0
- package/dist/headers/ICMP.js +9 -1
- package/dist/headers/ICMPv6.d.ts +1 -0
- package/dist/headers/ICMPv6.js +1 -0
- package/dist/headers/IEC104_I_Frame.d.ts +28 -0
- package/dist/headers/IEC104_I_Frame.js +246 -160
- package/dist/headers/IEC104_S_Frame.js +3 -3
- package/dist/headers/IEC104_U_Frame.js +5 -3
- package/dist/headers/IEC61850SampledValues.d.ts +1 -0
- package/dist/headers/IEC61850SampledValues.js +16 -1
- package/dist/headers/IPFIX.js +2 -1
- package/dist/headers/IPv4.d.ts +1 -0
- package/dist/headers/IPv4.js +6 -0
- package/dist/headers/IPv6.d.ts +1 -0
- package/dist/headers/IPv6.js +6 -0
- package/dist/headers/IPv6HopByHopOptions.d.ts +2 -0
- package/dist/headers/IPv6HopByHopOptions.js +11 -0
- package/dist/headers/KNXnetIP.js +3 -2
- package/dist/headers/LACP.js +2 -1
- package/dist/headers/LDP.js +2 -2
- package/dist/headers/MQTT.js +3 -1
- package/dist/headers/MarkerProtocol.js +2 -1
- package/dist/headers/NHRP.js +7 -15
- package/dist/headers/NetFlowV5.js +2 -1
- package/dist/headers/OPCUA.js +4 -0
- package/dist/headers/OSPF.d.ts +2 -2
- package/dist/headers/OSPF.js +32 -20
- package/dist/headers/OSPFv3.d.ts +38 -0
- package/dist/headers/OSPFv3.js +316 -0
- package/dist/headers/PPTP.js +2 -2
- package/dist/headers/QUIC.js +8 -3
- package/dist/headers/RGoose.js +2 -1
- package/dist/headers/RIP.js +3 -2
- package/dist/headers/RIPng.js +3 -2
- package/dist/headers/RTCP.js +3 -2
- package/dist/headers/RTP.js +3 -2
- package/dist/headers/SFlow.js +4 -2
- package/dist/headers/SLMP.js +2 -1
- package/dist/headers/SLP.js +2 -1
- package/dist/headers/SLPv1.js +2 -1
- package/dist/headers/SMB1.js +3 -2
- package/dist/headers/SMB2.js +3 -2
- package/dist/headers/STUN.js +2 -1
- package/dist/headers/TLS_Handshake.d.ts +6 -0
- package/dist/headers/TLS_Handshake.js +28 -3
- package/dist/headers/TacacsPlus.js +3 -1
- package/dist/headers/Trailer.d.ts +30 -0
- package/dist/headers/Trailer.js +63 -0
- package/dist/headers/VLAN_802dot1Q.d.ts +1 -0
- package/dist/headers/VLAN_802dot1Q.js +3 -0
- package/dist/headers/WakeOnLAN.js +2 -1
- package/dist/headers/WireGuard.js +3 -2
- package/dist/headers/Zabbix.js +2 -2
- package/dist/lib/BERElement.d.ts +51 -0
- package/dist/lib/BERElement.js +125 -0
- package/dist/types/LayerGraph.d.ts +10 -5
- package/package.json +2 -2
package/dist/Codec.js
CHANGED
|
@@ -38,6 +38,8 @@ exports.Codec = void 0;
|
|
|
38
38
|
const FlexibleObject_1 = require("./lib/FlexibleObject");
|
|
39
39
|
const ProcessPacketPostHandlers_1 = require("./lib/ProcessPacketPostHandlers");
|
|
40
40
|
const RawData_1 = require("./headers/RawData");
|
|
41
|
+
const Trailer_1 = require("./headers/Trailer");
|
|
42
|
+
const BaseHeader_1 = require("./abstracts/BaseHeader");
|
|
41
43
|
const CodecSchemaValidateError_1 = require("./errors/CodecSchemaValidateError");
|
|
42
44
|
const packetHeaders = __importStar(require("./PacketHeaders"));
|
|
43
45
|
/**
|
|
@@ -95,6 +97,11 @@ class Codec {
|
|
|
95
97
|
* used explicitly as the final fallback so decode never fails.
|
|
96
98
|
*/
|
|
97
99
|
#rawDataCodec = RawData_1.RawData;
|
|
100
|
+
/**
|
|
101
|
+
* The Trailer layer: bytes past the end a layer's own length field gives (Ethernet padding). Not
|
|
102
|
+
* part of the dispatch table or heuristic list; decode places it (see #decode), never selects it.
|
|
103
|
+
*/
|
|
104
|
+
#trailerCodec = Trailer_1.Trailer;
|
|
98
105
|
get HEADER_CODECS() {
|
|
99
106
|
return this.#codecModuleConstructors;
|
|
100
107
|
}
|
|
@@ -168,6 +175,10 @@ class Codec {
|
|
|
168
175
|
this.#rawDataCodec = codecModuleConstructor;
|
|
169
176
|
continue;
|
|
170
177
|
}
|
|
178
|
+
if (protocolId === Trailer_1.Trailer.PROTOCOL_ID) {
|
|
179
|
+
this.#trailerCodec = codecModuleConstructor;
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
171
182
|
for (const heuristicParent of codecModuleConstructor.HEURISTIC_PARENTS || []) {
|
|
172
183
|
const parentId = typeof heuristicParent === 'string' ? heuristicParent : heuristicParent.parent;
|
|
173
184
|
const entry = {
|
|
@@ -412,16 +423,26 @@ class Codec {
|
|
|
412
423
|
return { ...data, [discriminator.field]: discriminator.value };
|
|
413
424
|
}
|
|
414
425
|
/**
|
|
415
|
-
*
|
|
416
|
-
* dispatch table, which is too much work to repeat for every
|
|
426
|
+
* The parent field value that routes decode to the child, memoised per parent/child pair for the
|
|
427
|
+
* encode path: it reverses the whole dispatch table, which is too much work to repeat for every
|
|
428
|
+
* encoded layer. Cleared with the table. Read from the unfiltered graph, not from childDiscriminator():
|
|
429
|
+
* a child the editor menu leaves out on this carrier (OSPFv3 over IPv4) still gets its parent field
|
|
430
|
+
* filled, so a deliberately unusual stack can be crafted.
|
|
417
431
|
* @private
|
|
418
432
|
*/
|
|
419
433
|
#childDiscriminatorCached(parentLayerId, childLayerId) {
|
|
420
434
|
const key = `${parentLayerId}\u0000${childLayerId}`;
|
|
421
435
|
if (!this.#discriminatorCache.has(key))
|
|
422
|
-
this.#discriminatorCache.set(key, this
|
|
436
|
+
this.#discriminatorCache.set(key, _a.#discriminatorIn(this.#nextLayers(parentLayerId), childLayerId));
|
|
423
437
|
return this.#discriminatorCache.get(key);
|
|
424
438
|
}
|
|
439
|
+
static #discriminatorIn(nextLayers, childLayerId) {
|
|
440
|
+
for (const next of nextLayers) {
|
|
441
|
+
if (next.id === childLayerId && next.discriminator)
|
|
442
|
+
return next.discriminator;
|
|
443
|
+
}
|
|
444
|
+
return null;
|
|
445
|
+
}
|
|
425
446
|
/**
|
|
426
447
|
* Internal decode packet
|
|
427
448
|
* @param codecData
|
|
@@ -440,6 +461,25 @@ class Codec {
|
|
|
440
461
|
codecModules.push(codecModule);
|
|
441
462
|
if (codecData.startPos >= codecData.packet.length)
|
|
442
463
|
return;
|
|
464
|
+
const payloadEnd = codecModule.payloadEnd();
|
|
465
|
+
if (payloadEnd !== undefined && payloadEnd >= codecData.startPos && payloadEnd < codecData.packet.length) {
|
|
466
|
+
//The layer's own length ends its payload before the bytes do (Ethernet padding, a trailer).
|
|
467
|
+
//Decode the layers above on a view cut at that end, so neither they nor their post-decode
|
|
468
|
+
//handlers see the extra bytes, then keep those bytes as a trailer layer. Nested bounds (IP in
|
|
469
|
+
//IP) cut the view again, each level adding its own trailer.
|
|
470
|
+
if (payloadEnd > codecData.startPos) {
|
|
471
|
+
const payloadData = { packet: codecData.packet.subarray(0, payloadEnd), startPos: codecData.startPos, postHandlers: codecData.postHandlers };
|
|
472
|
+
await this.#decode(payloadData, codecModules, collectRanges);
|
|
473
|
+
}
|
|
474
|
+
codecData.startPos = payloadEnd;
|
|
475
|
+
const trailer = this.#trailerCodec.CREATE_INSTANCE(codecData, codecModules);
|
|
476
|
+
if (collectRanges)
|
|
477
|
+
trailer.enableByteRangeTracking();
|
|
478
|
+
await trailer.decode();
|
|
479
|
+
codecData.startPos = trailer.endPos;
|
|
480
|
+
codecModules.push(trailer);
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
443
483
|
return this.#decode(codecData, codecModules, collectRanges, rootLinktype);
|
|
444
484
|
}
|
|
445
485
|
/**
|
|
@@ -484,6 +524,13 @@ class Codec {
|
|
|
484
524
|
await postEncodeHandler.handler();
|
|
485
525
|
postEncodeHandler = postEncodeHandlers.shift();
|
|
486
526
|
}
|
|
527
|
+
//Trailer layers are written only now, once every packet-level post handler has run, so no
|
|
528
|
+
//computed length or checksum counted their bytes (see Trailer).
|
|
529
|
+
reports.forEach((report, index) => {
|
|
530
|
+
if (!(report instanceof Trailer_1.Trailer))
|
|
531
|
+
return;
|
|
532
|
+
report.appendToPacket(reports.slice(index + 1).some((later) => later instanceof BaseHeader_1.BaseHeader && !(later instanceof Trailer_1.Trailer)));
|
|
533
|
+
});
|
|
487
534
|
//Collect each layer's errors only now, so those recorded by packet-level post handlers (which
|
|
488
535
|
//run after every layer is encoded) are reported too; layer order is preserved.
|
|
489
536
|
const errors = [];
|
|
@@ -513,10 +560,55 @@ class Codec {
|
|
|
513
560
|
* may follow `parentLayerId`, each tagged with the {field,value} to set on the parent so decode
|
|
514
561
|
* would route to it. Derived by reversing the dispatch table over the parent's producer fields,
|
|
515
562
|
* plus the content-heuristic children that declare this parent in `heuristicParents` (listed with a
|
|
516
|
-
* null discriminator). RawData
|
|
563
|
+
* null discriminator). RawData (the custom/fallback layer) and Trailer (padding written after every
|
|
564
|
+
* other layer) are always appended: either may follow anything.
|
|
565
|
+
*
|
|
566
|
+
* Headers that run over one IP version only (`ipVersions`: ICMP over IPv4; ICMPv6, OSPFv3 and the
|
|
567
|
+
* IPv6 Hop-by-Hop header over IPv6) are left out when the IP version beneath is known to be the
|
|
568
|
+
* other one, and a header that must directly follow its IP header (`directlyAfterIP`) is listed only
|
|
569
|
+
* under ipv4 / ipv6. The version is known when the parent is ipv4 / ipv6 or runs over one version
|
|
570
|
+
* itself (ipv6-hopopt), or from `options.ancestors`; under AH with no ancestors given, both
|
|
571
|
+
* versions' children are listed (checkConsistency() flags a wrong pick).
|
|
517
572
|
* @param parentLayerId
|
|
573
|
+
* @param options `ancestors`: the ids of the layers beneath the parent, outermost first (e.g.
|
|
574
|
+
* ['eth', 'ipv4'] for parent 'ah'), so a parent such as AH can be placed over its IP version
|
|
575
|
+
*/
|
|
576
|
+
allowedNextLayers(parentLayerId, options = {}) {
|
|
577
|
+
const ipVersion = this.#ipVersionAt([...(options.ancestors || []), parentLayerId]);
|
|
578
|
+
const parentIsIP = parentLayerId === 'ipv4' || parentLayerId === 'ipv6';
|
|
579
|
+
return this.#nextLayers(parentLayerId).filter((next) => {
|
|
580
|
+
const codecModuleConstructor = this.#codecConstructorById.get(next.id);
|
|
581
|
+
if (!codecModuleConstructor)
|
|
582
|
+
return true;
|
|
583
|
+
if (codecModuleConstructor.DIRECTLY_AFTER_IP && !parentIsIP)
|
|
584
|
+
return false;
|
|
585
|
+
const ipVersions = codecModuleConstructor.IP_VERSIONS;
|
|
586
|
+
return !ipVersions.length || ipVersion === undefined || ipVersions.includes(ipVersion);
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* The IP version of the nearest IP layer in a stack of layer ids (outermost first): 4 or 6 for
|
|
591
|
+
* ipv4 / ipv6, or the single version a layer runs over (ipv6-hopopt); undefined when none says.
|
|
592
|
+
* @private
|
|
518
593
|
*/
|
|
519
|
-
|
|
594
|
+
#ipVersionAt(stack) {
|
|
595
|
+
for (let i = stack.length - 1; i >= 0; i--) {
|
|
596
|
+
if (stack[i] === 'ipv4')
|
|
597
|
+
return 4;
|
|
598
|
+
if (stack[i] === 'ipv6')
|
|
599
|
+
return 6;
|
|
600
|
+
const ipVersions = this.#codecConstructorById.get(stack[i])?.IP_VERSIONS || [];
|
|
601
|
+
if (ipVersions.length === 1)
|
|
602
|
+
return ipVersions[0];
|
|
603
|
+
}
|
|
604
|
+
return undefined;
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* The unfiltered parent→child graph allowedNextLayers() projects (see there).
|
|
608
|
+
* @param parentLayerId
|
|
609
|
+
* @private
|
|
610
|
+
*/
|
|
611
|
+
#nextLayers(parentLayerId) {
|
|
520
612
|
const result = [];
|
|
521
613
|
const seen = new Set();
|
|
522
614
|
for (const producer of this.#producersOf(parentLayerId)) {
|
|
@@ -557,29 +649,30 @@ class Codec {
|
|
|
557
649
|
result.push({ id: codecModuleConstructor.PROTOCOL_ID, name: codecModuleConstructor.PROTOCOL_NAME, discriminator: discriminator });
|
|
558
650
|
}
|
|
559
651
|
result.push({ id: this.#rawDataCodec.PROTOCOL_ID, name: this.#rawDataCodec.PROTOCOL_NAME, discriminator: null });
|
|
652
|
+
result.push({ id: this.#trailerCodec.PROTOCOL_ID, name: this.#trailerCodec.PROTOCOL_NAME, discriminator: null });
|
|
560
653
|
return result;
|
|
561
654
|
}
|
|
562
655
|
/**
|
|
563
656
|
* The {field,value} to set on `parentLayerId` so `childLayerId` follows it — used to auto-fill
|
|
564
657
|
* the parent discriminator when a child is added, and to suggest a fix for a consistency issue.
|
|
565
658
|
* Null when the child is not reachable from that parent via the demux graph (RawData, or a
|
|
566
|
-
* content-heuristic child such as TLS/IEC104 whose match is port/content based)
|
|
659
|
+
* content-heuristic child such as TLS/IEC104 whose match is port/content based), or when
|
|
660
|
+
* allowedNextLayers() leaves it out on that carrier (OSPFv3 under ipv4).
|
|
567
661
|
* @param parentLayerId
|
|
568
662
|
* @param childLayerId
|
|
663
|
+
* @param options as for allowedNextLayers()
|
|
569
664
|
*/
|
|
570
|
-
childDiscriminator(parentLayerId, childLayerId) {
|
|
571
|
-
|
|
572
|
-
if (next.id === childLayerId && next.discriminator)
|
|
573
|
-
return next.discriminator;
|
|
574
|
-
}
|
|
575
|
-
return null;
|
|
665
|
+
childDiscriminator(parentLayerId, childLayerId, options = {}) {
|
|
666
|
+
return _a.#discriminatorIn(this.allowedNextLayers(parentLayerId, options), childLayerId);
|
|
576
667
|
}
|
|
577
668
|
/**
|
|
578
669
|
* Editor helper: report parent layers whose discriminator field does not point at the child that
|
|
579
670
|
* actually follows (e.g. eth.etherType says IPv6 but the next layer is IPv4). This is advisory
|
|
580
671
|
* only — encode never blocks on it, since a deliberately-inconsistent packet is a valid crafted
|
|
581
672
|
* packet. Only demux-based relationships are checked; content-heuristic children (TLS/IEC104) are
|
|
582
|
-
* not flagged. RawData may follow anything and
|
|
673
|
+
* not flagged. RawData and Trailer may follow anything and are never flagged. Also reports a header
|
|
674
|
+
* placed on a carrier it does not run over (`kind: 'carrier'`, see ConsistencyIssue). Accepts decode
|
|
675
|
+
* results or encode input (only `id` and `data` are read).
|
|
583
676
|
* @param decoded
|
|
584
677
|
*/
|
|
585
678
|
checkConsistency(decoded) {
|
|
@@ -587,7 +680,7 @@ class Codec {
|
|
|
587
680
|
for (let i = 0; i < decoded.length - 1; i++) {
|
|
588
681
|
const parent = decoded[i];
|
|
589
682
|
const child = decoded[i + 1];
|
|
590
|
-
if (child.id === this.#rawDataCodec.PROTOCOL_ID)
|
|
683
|
+
if (child.id === this.#rawDataCodec.PROTOCOL_ID || child.id === this.#trailerCodec.PROTOCOL_ID)
|
|
591
684
|
continue;
|
|
592
685
|
//A content-heuristic child (no matchKeys, or heuristicFallback dual) is legitimately
|
|
593
686
|
//reachable off its well-known demux value (e.g. TLS on a non-443 port). Never flag it as
|
|
@@ -626,10 +719,50 @@ class Codec {
|
|
|
626
719
|
field: representative.producer.field,
|
|
627
720
|
actual: representative.actual,
|
|
628
721
|
suggestion: this.childDiscriminator(parent.id, child.id),
|
|
629
|
-
message: `${parent.id}.${representative.producer.field}=${representative.actual} 与下一层 '${child.id}'
|
|
722
|
+
message: `${parent.id}.${representative.producer.field}=${representative.actual} 与下一层 '${child.id}' 不符`,
|
|
723
|
+
kind: 'discriminator'
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
//Carrier: a header that runs over one IP version only, or that must directly follow its IP
|
|
727
|
+
//header, placed elsewhere. Decode never yields such a stack (match() rejects it and the bytes
|
|
728
|
+
//become raw), so this is for encode input an editor is about to save.
|
|
729
|
+
for (let i = 1; i < decoded.length; i++) {
|
|
730
|
+
const parent = decoded[i - 1];
|
|
731
|
+
const child = decoded[i];
|
|
732
|
+
const codecModuleConstructor = this.#codecConstructorById.get(child.id);
|
|
733
|
+
if (!codecModuleConstructor)
|
|
734
|
+
continue;
|
|
735
|
+
let message = undefined;
|
|
736
|
+
const ipVersions = codecModuleConstructor.IP_VERSIONS;
|
|
737
|
+
if (ipVersions.length) {
|
|
738
|
+
const ipVersion = this.#ipVersionAt(decoded.slice(0, i).map((layer) => layer.id));
|
|
739
|
+
const carriers = ipVersions.map((version) => `IPv${version}`).join(' / ');
|
|
740
|
+
if (ipVersion === undefined)
|
|
741
|
+
message = `'${child.id}' 只能承载在 ${carriers} 上,但下面没有 IP 层`;
|
|
742
|
+
else if (!ipVersions.includes(ipVersion))
|
|
743
|
+
message = `'${child.id}' 只能承载在 ${carriers} 上,但下面最近的 IP 层是 IPv${ipVersion}`;
|
|
744
|
+
}
|
|
745
|
+
if (!message && codecModuleConstructor.DIRECTLY_AFTER_IP && parent.id !== 'ipv4' && parent.id !== 'ipv6') {
|
|
746
|
+
message = `'${child.id}' 必须紧跟在 IP 头后面,但前一层是 '${parent.id}'`;
|
|
747
|
+
}
|
|
748
|
+
if (!message)
|
|
749
|
+
continue;
|
|
750
|
+
const producer = this.#producersOf(parent.id).find((demuxProducer) => {
|
|
751
|
+
const value = parent.data ? parent.data[demuxProducer.field] : undefined;
|
|
752
|
+
return value !== undefined && value !== null;
|
|
753
|
+
});
|
|
754
|
+
issues.push({
|
|
755
|
+
index: i - 1,
|
|
756
|
+
parentId: parent.id,
|
|
757
|
+
childId: child.id,
|
|
758
|
+
field: producer ? producer.field : '',
|
|
759
|
+
actual: producer ? parent.data[producer.field] : '',
|
|
760
|
+
suggestion: null,
|
|
761
|
+
message: message,
|
|
762
|
+
kind: 'carrier'
|
|
630
763
|
});
|
|
631
764
|
}
|
|
632
|
-
return issues;
|
|
765
|
+
return issues.sort((a, b) => a.index - b.index);
|
|
633
766
|
}
|
|
634
767
|
/**
|
|
635
768
|
* Wireshark-style dissection: decode the packet with byte-range tracking on, then project each
|
|
@@ -705,7 +838,7 @@ class Codec {
|
|
|
705
838
|
* One-line human summary of a decoded packet (Wireshark's Info column). The innermost layer that
|
|
706
839
|
* declares a `summary` template in its schema wins (the most specific layer describes the packet);
|
|
707
840
|
* the template's ${dotted.field} placeholders are filled from that layer's decoded data. Falls back
|
|
708
|
-
* to the innermost
|
|
841
|
+
* to the innermost layer that is neither raw nor a trailer when no template is declared. Read-only projection.
|
|
709
842
|
* @param decoded
|
|
710
843
|
*/
|
|
711
844
|
summary(decoded) {
|
|
@@ -715,7 +848,7 @@ class Codec {
|
|
|
715
848
|
return this.#renderSummary(schema.summary, decoded[i].data);
|
|
716
849
|
}
|
|
717
850
|
for (let i = decoded.length - 1; i >= 0; i--) {
|
|
718
|
-
if (decoded[i].id !== this.#rawDataCodec.PROTOCOL_ID)
|
|
851
|
+
if (decoded[i].id !== this.#rawDataCodec.PROTOCOL_ID && decoded[i].id !== this.#trailerCodec.PROTOCOL_ID)
|
|
719
852
|
return decoded[i].name;
|
|
720
853
|
}
|
|
721
854
|
return decoded.length ? decoded[decoded.length - 1].name : '';
|
package/dist/PacketHeaders.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { IPv6 } from './headers/IPv6';
|
|
|
8
8
|
export { IPv6HopByHopOptions } from './headers/IPv6HopByHopOptions';
|
|
9
9
|
export { ICMPv6 } from './headers/ICMPv6';
|
|
10
10
|
export { RawData } from './headers/RawData';
|
|
11
|
+
export { Trailer } from './headers/Trailer';
|
|
11
12
|
export { TCP } from './headers/TCP';
|
|
12
13
|
export { UDP } from './headers/UDP';
|
|
13
14
|
export { NTP } from './headers/NTP';
|
|
@@ -48,6 +49,7 @@ export { GRE } from './headers/GRE';
|
|
|
48
49
|
export { BFD } from './headers/BFD';
|
|
49
50
|
export { VRRP } from './headers/VRRP';
|
|
50
51
|
export { OSPF } from './headers/OSPF';
|
|
52
|
+
export { OSPFv3 } from './headers/OSPFv3';
|
|
51
53
|
export { ModbusTCP } from './headers/ModbusTCP';
|
|
52
54
|
export { DNP3 } from './headers/DNP3';
|
|
53
55
|
export { C37118 } from './headers/C37118';
|
package/dist/PacketHeaders.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
6
|
-
exports.IEC104_U_Frame = exports.IEC104_S_Frame = exports.IEC104_I_Frame = exports.TLS_Heartbeat = exports.TLS_Handshake = exports.TLS_ChangeCipherSpec = exports.TLS_ApplicationData = exports.TLS_Alert = exports.VLAN_802dot1Q = exports.MMS = exports.CMS = exports.ISOSession = exports.RDP = exports.SNAP = exports.ISIS = exports.CDP = exports.S7comm = exports.STP = exports.LLC = exports.SMB1 = exports.SCTP = exports.RTP = exports.RTCP = exports.QUIC = exports.NFS = exports.WakeOnLAN = exports.WSDiscovery = exports.Teredo = exports.SLPv1 = exports.SLP = exports.PCWorx = exports.ModbusUDP = exports.Megaco = exports.MarkerProtocol = exports.HTTP2 = exports.GESRTP = exports.GELF = exports.DHCPFailover = exports.Codesys = void 0;
|
|
3
|
+
exports.VRRP = exports.BFD = exports.GRE = exports.GENEVE = exports.SOCKS5 = exports.Memcached = exports.Telnet = exports.Kerberos = exports.LDAP = exports.SSH = exports.RFB = exports.Kafka = exports.AMQP = exports.SFlow = exports.WireGuard = exports.ISAKMP = exports.Diameter = exports.PostgreSQL = exports.MySQL = exports.NetFlowV5 = exports.RGoose = exports.L2TP = exports.RMCP = exports.GTPU = exports.VXLAN = exports.RADIUS = exports.Syslog = exports.NBNS = exports.LLMNR = exports.TFTP = exports.DHCPv6 = exports.MDNS = exports.SNMP = exports.DNS = exports.DHCP = exports.STUN = exports.NTP = exports.UDP = exports.TCP = exports.Trailer = exports.RawData = exports.ICMPv6 = exports.IPv6HopByHopOptions = exports.IPv6 = exports.IPv4 = exports.ICMP = exports.IEC61850SampledValues = exports.Goose = exports.EthernetII = exports.ARP = void 0;
|
|
4
|
+
exports.RSVP = exports.RIPng = exports.PTP = exports.PPPoESession = exports.PPPoEDiscovery = exports.PIM = exports.MPLS = exports.LACP = exports.Ident = exports.IGMP = exports.HSRP = exports.GTPv2C = exports.EIGRP = exports.DCCP = exports.WHOIS = exports.SOCKS4 = exports.Rlogin = exports.RIP = exports.Finger = exports.ESP = exports.EAPOL = exports.BGP = exports.AH = exports.HSR = exports.IRC = exports.NNTP = exports.IMAP = exports.POP3 = exports.SMTP = exports.COTP = exports.TPKT = exports.RTSP = exports.FTP = exports.HTTP = exports.EtherCAT = exports.PROFINETRT = exports.SIP = exports.LLDP = exports.TacacsPlus = exports.Redis = exports.MQTT = exports.CoAP = exports.OPCUA = exports.ENIP = exports.BACnetIP = exports.C37118 = exports.DNP3 = exports.ModbusTCP = exports.OSPFv3 = exports.OSPF = void 0;
|
|
5
|
+
exports.ADSAMS = exports.Zabbix = exports.TimeProtocol = exports.StatsD = exports.Skinny = exports.OPCUAPubSub = exports.OLSR = exports.NHRP = exports.NATS = exports.MGCP = exports.MACsec = exports.IPFIX = exports.IAX2 = exports.GLBP = exports.FCoE = exports.Elasticsearch = exports.Collectd = exports.SMPP = exports.SMB2 = exports.SLMP = exports.Rsync = exports.RTPS = exports.OpenFlow = exports.OmronFINS = exports.NBDS = exports.MongoDB = exports.MQTTSN = exports.LISP = exports.KNXnetIP = exports.GitProtocol = exports.CassandraCQL = exports.CAPWAP = exports.XMPP = exports.WCCP = exports.SercosIII = exports.STOMP = exports.PPTP = exports.POWERLINK = exports.OpenVPN = exports.NBSS = exports.LPD = exports.LDP = exports.ISCSI = exports.HARTIP = exports.Gopher = exports.FoundationFieldbusHSE = exports.DTLS = exports.Babel = exports.SunRPC = exports.SSDP = void 0;
|
|
6
|
+
exports.IEC104_U_Frame = exports.IEC104_S_Frame = exports.IEC104_I_Frame = exports.TLS_Heartbeat = exports.TLS_Handshake = exports.TLS_ChangeCipherSpec = exports.TLS_ApplicationData = exports.TLS_Alert = exports.VLAN_802dot1Q = exports.MMS = exports.CMS = exports.ISOSession = exports.RDP = exports.SNAP = exports.ISIS = exports.CDP = exports.S7comm = exports.STP = exports.LLC = exports.SMB1 = exports.SCTP = exports.RTP = exports.RTCP = exports.QUIC = exports.NFS = exports.WakeOnLAN = exports.WSDiscovery = exports.Teredo = exports.SLPv1 = exports.SLP = exports.PCWorx = exports.ModbusUDP = exports.Megaco = exports.MarkerProtocol = exports.HTTP2 = exports.GESRTP = exports.GELF = exports.DHCPFailover = exports.Codesys = exports.BitTorrent = exports.BSAPIP = void 0;
|
|
7
7
|
var ARP_1 = require("./headers/ARP");
|
|
8
8
|
Object.defineProperty(exports, "ARP", { enumerable: true, get: function () { return ARP_1.ARP; } });
|
|
9
9
|
var EthernetII_1 = require("./headers/EthernetII");
|
|
@@ -24,6 +24,8 @@ var ICMPv6_1 = require("./headers/ICMPv6");
|
|
|
24
24
|
Object.defineProperty(exports, "ICMPv6", { enumerable: true, get: function () { return ICMPv6_1.ICMPv6; } });
|
|
25
25
|
var RawData_1 = require("./headers/RawData");
|
|
26
26
|
Object.defineProperty(exports, "RawData", { enumerable: true, get: function () { return RawData_1.RawData; } });
|
|
27
|
+
var Trailer_1 = require("./headers/Trailer");
|
|
28
|
+
Object.defineProperty(exports, "Trailer", { enumerable: true, get: function () { return Trailer_1.Trailer; } });
|
|
27
29
|
var TCP_1 = require("./headers/TCP");
|
|
28
30
|
Object.defineProperty(exports, "TCP", { enumerable: true, get: function () { return TCP_1.TCP; } });
|
|
29
31
|
var UDP_1 = require("./headers/UDP");
|
|
@@ -104,6 +106,8 @@ var VRRP_1 = require("./headers/VRRP");
|
|
|
104
106
|
Object.defineProperty(exports, "VRRP", { enumerable: true, get: function () { return VRRP_1.VRRP; } });
|
|
105
107
|
var OSPF_1 = require("./headers/OSPF");
|
|
106
108
|
Object.defineProperty(exports, "OSPF", { enumerable: true, get: function () { return OSPF_1.OSPF; } });
|
|
109
|
+
var OSPFv3_1 = require("./headers/OSPFv3");
|
|
110
|
+
Object.defineProperty(exports, "OSPFv3", { enumerable: true, get: function () { return OSPFv3_1.OSPFv3; } });
|
|
107
111
|
var ModbusTCP_1 = require("./headers/ModbusTCP");
|
|
108
112
|
Object.defineProperty(exports, "ModbusTCP", { enumerable: true, get: function () { return ModbusTCP_1.ModbusTCP; } });
|
|
109
113
|
var DNP3_1 = require("./headers/DNP3");
|
|
@@ -57,6 +57,10 @@ export declare abstract class BaseHeader {
|
|
|
57
57
|
static get HEURISTIC_FALLBACK(): boolean;
|
|
58
58
|
/** Parent layer ids a content-heuristic header can follow (see the instance field heuristicParents). */
|
|
59
59
|
static get HEURISTIC_PARENTS(): HeuristicParent[];
|
|
60
|
+
/** The IP versions this header runs over (see the instance field ipVersions). */
|
|
61
|
+
static get IP_VERSIONS(): number[];
|
|
62
|
+
/** Whether this header must directly follow an IP header (see the instance field directlyAfterIP). */
|
|
63
|
+
static get DIRECTLY_AFTER_IP(): boolean;
|
|
60
64
|
/** Higher is tried first within a demux bucket and within the heuristic chain; ties keep registration order. */
|
|
61
65
|
static get MATCH_PRIORITY(): number;
|
|
62
66
|
static get PROTOCOL_SCHEMA(): ProtocolJSONSchema;
|
|
@@ -113,6 +117,19 @@ export declare abstract class BaseHeader {
|
|
|
113
117
|
* for an entry {parent, discriminator}, with that parent field value the child needs.
|
|
114
118
|
*/
|
|
115
119
|
readonly heuristicParents: HeuristicParent[];
|
|
120
|
+
/**
|
|
121
|
+
* Editor graph and checkConsistency() only (decode still routes by match()): the IP versions this
|
|
122
|
+
* header runs over, i.e. what the nearest IPv4 / IPv6 layer beneath it must be — 4 for ICMP, 6 for
|
|
123
|
+
* ICMPv6, OSPFv3 and the IPv6 Hop-by-Hop header. Several headers share one IP protocol number
|
|
124
|
+
* namespace (ipproto), so without this the menu would offer them under either IP version.
|
|
125
|
+
* Empty (the default): either version, or a header IP does not carry.
|
|
126
|
+
*/
|
|
127
|
+
readonly ipVersions: number[];
|
|
128
|
+
/**
|
|
129
|
+
* Editor graph and checkConsistency() only: true for a header that must directly follow its IP
|
|
130
|
+
* header, not AH or an extension header (IPv6 Hop-by-Hop Options, RFC 8200 4.3).
|
|
131
|
+
*/
|
|
132
|
+
readonly directlyAfterIP: boolean;
|
|
116
133
|
/**
|
|
117
134
|
* Encode/Decode error info objects
|
|
118
135
|
*/
|
|
@@ -149,6 +166,15 @@ export declare abstract class BaseHeader {
|
|
|
149
166
|
* Readonly Header length
|
|
150
167
|
*/
|
|
151
168
|
get length(): number;
|
|
169
|
+
/**
|
|
170
|
+
* Decode only: the packet offset where this layer's payload ends by its own length field (IPv4
|
|
171
|
+
* Total Length, IPv6 Payload Length, an 802.3 length), read after decode(). The codec decodes the
|
|
172
|
+
* layers above inside that bound and keeps any bytes past it as a `trailer` layer (Ethernet padding
|
|
173
|
+
* and the like). Undefined, the default, means the payload runs to the end of the bytes available.
|
|
174
|
+
* The codec ignores a bound outside [endPos, the bytes available), so a zero, overstated or
|
|
175
|
+
* truncated length decodes as it would without one.
|
|
176
|
+
*/
|
|
177
|
+
payloadEnd(): number | undefined;
|
|
152
178
|
/**
|
|
153
179
|
* Header length
|
|
154
180
|
* @protected
|
|
@@ -295,6 +321,14 @@ export declare abstract class BaseHeader {
|
|
|
295
321
|
* @protected
|
|
296
322
|
*/
|
|
297
323
|
protected encodeOmittedEtherType(field: FlexibleObject, offset: number): void;
|
|
324
|
+
/**
|
|
325
|
+
* payloadEnd() for a header whose `etherType` field doubles as an IEEE 802.3 length (Ethernet,
|
|
326
|
+
* 802.1Q): a value of 3–1500 gives the octets of LLC data that follow this header. Anything else
|
|
327
|
+
* (an EtherType, or a length too short for an LLC header) sets no bound.
|
|
328
|
+
* @param field the etherType field
|
|
329
|
+
* @protected
|
|
330
|
+
*/
|
|
331
|
+
protected ieee802dot3PayloadEnd(field: FlexibleObject): number | undefined;
|
|
298
332
|
/**
|
|
299
333
|
* True when `field` was left out of the encode input, which is what asks encode to calculate an
|
|
300
334
|
* autoCalculated length, count or checksum. Any value given, 0 included, is written as given, so a
|
|
@@ -76,6 +76,14 @@ class BaseHeader {
|
|
|
76
76
|
static get HEURISTIC_PARENTS() {
|
|
77
77
|
return this.CODEC_INSTANCE.heuristicParents;
|
|
78
78
|
}
|
|
79
|
+
/** The IP versions this header runs over (see the instance field ipVersions). */
|
|
80
|
+
static get IP_VERSIONS() {
|
|
81
|
+
return this.CODEC_INSTANCE.ipVersions;
|
|
82
|
+
}
|
|
83
|
+
/** Whether this header must directly follow an IP header (see the instance field directlyAfterIP). */
|
|
84
|
+
static get DIRECTLY_AFTER_IP() {
|
|
85
|
+
return this.CODEC_INSTANCE.directlyAfterIP;
|
|
86
|
+
}
|
|
79
87
|
/** Higher is tried first within a demux bucket and within the heuristic chain; ties keep registration order. */
|
|
80
88
|
static get MATCH_PRIORITY() {
|
|
81
89
|
return this.CODEC_INSTANCE.matchPriority;
|
|
@@ -157,6 +165,17 @@ class BaseHeader {
|
|
|
157
165
|
get length() {
|
|
158
166
|
return this.headerLength;
|
|
159
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Decode only: the packet offset where this layer's payload ends by its own length field (IPv4
|
|
170
|
+
* Total Length, IPv6 Payload Length, an 802.3 length), read after decode(). The codec decodes the
|
|
171
|
+
* layers above inside that bound and keeps any bytes past it as a `trailer` layer (Ethernet padding
|
|
172
|
+
* and the like). Undefined, the default, means the payload runs to the end of the bytes available.
|
|
173
|
+
* The codec ignores a bound outside [endPos, the bytes available), so a zero, overstated or
|
|
174
|
+
* truncated length decodes as it would without one.
|
|
175
|
+
*/
|
|
176
|
+
payloadEnd() {
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
160
179
|
/**
|
|
161
180
|
* Post packet handlers
|
|
162
181
|
* @protected
|
|
@@ -202,6 +221,19 @@ class BaseHeader {
|
|
|
202
221
|
* for an entry {parent, discriminator}, with that parent field value the child needs.
|
|
203
222
|
*/
|
|
204
223
|
this.heuristicParents = [];
|
|
224
|
+
/**
|
|
225
|
+
* Editor graph and checkConsistency() only (decode still routes by match()): the IP versions this
|
|
226
|
+
* header runs over, i.e. what the nearest IPv4 / IPv6 layer beneath it must be — 4 for ICMP, 6 for
|
|
227
|
+
* ICMPv6, OSPFv3 and the IPv6 Hop-by-Hop header. Several headers share one IP protocol number
|
|
228
|
+
* namespace (ipproto), so without this the menu would offer them under either IP version.
|
|
229
|
+
* Empty (the default): either version, or a header IP does not carry.
|
|
230
|
+
*/
|
|
231
|
+
this.ipVersions = [];
|
|
232
|
+
/**
|
|
233
|
+
* Editor graph and checkConsistency() only: true for a header that must directly follow its IP
|
|
234
|
+
* header, not AH or an extension header (IPv6 Hop-by-Hop Options, RFC 8200 4.3).
|
|
235
|
+
*/
|
|
236
|
+
this.directlyAfterIP = false;
|
|
205
237
|
/**
|
|
206
238
|
* Encode/Decode error info objects
|
|
207
239
|
*/
|
|
@@ -606,6 +638,17 @@ class BaseHeader {
|
|
|
606
638
|
this.writeBytes(offset, (0, NumberToBuffer_1.UInt16ToBuffer)(Math.min(length, 0xffff)));
|
|
607
639
|
});
|
|
608
640
|
}
|
|
641
|
+
/**
|
|
642
|
+
* payloadEnd() for a header whose `etherType` field doubles as an IEEE 802.3 length (Ethernet,
|
|
643
|
+
* 802.1Q): a value of 3–1500 gives the octets of LLC data that follow this header. Anything else
|
|
644
|
+
* (an EtherType, or a length too short for an LLC header) sets no bound.
|
|
645
|
+
* @param field the etherType field
|
|
646
|
+
* @protected
|
|
647
|
+
*/
|
|
648
|
+
ieee802dot3PayloadEnd(field) {
|
|
649
|
+
const length = parseInt(field.getValue('').toString(), 16);
|
|
650
|
+
return length >= 3 && length <= 0x05dc ? this.endPos + length : undefined;
|
|
651
|
+
}
|
|
609
652
|
/**
|
|
610
653
|
* True when `field` was left out of the encode input, which is what asks encode to calculate an
|
|
611
654
|
* autoCalculated length, count or checksum. Any value given, 0 included, is written as given, so a
|
package/dist/headers/ARP.d.ts
CHANGED
|
@@ -14,7 +14,8 @@ import { BaseHeader } from '../abstracts/BaseHeader';
|
|
|
14
14
|
*
|
|
15
15
|
* The 6-octet MAC and 4-octet IPv4 widths are fixed here (Ethernet + IPv4 ARP), independent of the
|
|
16
16
|
* declared hardware/protocol sizes. Values are range-clamped rather than rejected. match() keys purely
|
|
17
|
-
* on the parent's EtherType being 0x0806.
|
|
17
|
+
* on the parent's EtherType being 0x0806. When the declared sizes are 6 and 4, the bytes after the 28
|
|
18
|
+
* octets (Ethernet padding) decode as a `trailer` layer (see payloadEnd).
|
|
18
19
|
*/
|
|
19
20
|
export declare class ARP extends BaseHeader {
|
|
20
21
|
SCHEMA: ProtocolJSONSchema;
|
|
@@ -22,5 +23,6 @@ export declare class ARP extends BaseHeader {
|
|
|
22
23
|
readonly matchKeys: string[];
|
|
23
24
|
readonly name: string;
|
|
24
25
|
readonly nickname: string;
|
|
26
|
+
payloadEnd(): number | undefined;
|
|
25
27
|
match(): boolean;
|
|
26
28
|
}
|
package/dist/headers/ARP.js
CHANGED
|
@@ -24,7 +24,8 @@ const IPToBuffer_1 = require("../helper/IPToBuffer");
|
|
|
24
24
|
*
|
|
25
25
|
* The 6-octet MAC and 4-octet IPv4 widths are fixed here (Ethernet + IPv4 ARP), independent of the
|
|
26
26
|
* declared hardware/protocol sizes. Values are range-clamped rather than rejected. match() keys purely
|
|
27
|
-
* on the parent's EtherType being 0x0806.
|
|
27
|
+
* on the parent's EtherType being 0x0806. When the declared sizes are 6 and 4, the bytes after the 28
|
|
28
|
+
* octets (Ethernet padding) decode as a `trailer` layer (see payloadEnd).
|
|
28
29
|
*/
|
|
29
30
|
class ARP extends BaseHeader_1.BaseHeader {
|
|
30
31
|
constructor() {
|
|
@@ -237,6 +238,12 @@ class ARP extends BaseHeader_1.BaseHeader {
|
|
|
237
238
|
this.name = 'Address Resolution Protocol';
|
|
238
239
|
this.nickname = 'ARP';
|
|
239
240
|
}
|
|
241
|
+
payloadEnd() {
|
|
242
|
+
//An Ethernet/IPv4 ARP packet ends after its 28 octets, so what follows is Ethernet padding. Other
|
|
243
|
+
//declared address sizes set no bound: the fixed-width fields do not cover such a packet.
|
|
244
|
+
const ethernetIPv4 = this.instance.hardware.size.getValue() === 6 && this.instance.protocol.size.getValue() === 4;
|
|
245
|
+
return ethernetIPv4 ? this.endPos : undefined;
|
|
246
|
+
}
|
|
240
247
|
match() {
|
|
241
248
|
if (!this.prevCodecModule)
|
|
242
249
|
return false;
|
package/dist/headers/BACnetIP.js
CHANGED
|
@@ -40,7 +40,8 @@ class BACnetIP extends BaseHeader_1.BaseHeader {
|
|
|
40
40
|
type: 'object',
|
|
41
41
|
summary: 'BACnet/IP func=${function}',
|
|
42
42
|
properties: {
|
|
43
|
-
|
|
43
|
+
//Default 0x81: the BVLC type of BACnet/IP, and what match() requires.
|
|
44
|
+
type: { ...this.fieldHex('type', 0, 1, 'Type'), default: '81' },
|
|
44
45
|
'function': this.fieldUInt('function', 1, 1, 'Function'),
|
|
45
46
|
length: {
|
|
46
47
|
type: 'integer',
|
package/dist/headers/BGP.js
CHANGED
|
@@ -41,8 +41,9 @@ class BGP extends BaseHeader_1.BaseHeader {
|
|
|
41
41
|
summary: 'BGP type=${type} len=${length}',
|
|
42
42
|
properties: {
|
|
43
43
|
//The 16-byte Marker. In RFC 4271 (no authentication) it is all ones (0xFF); kept
|
|
44
|
-
//verbatim so any legacy/authenticated marker still round-trips.
|
|
45
|
-
|
|
44
|
+
//verbatim so any legacy/authenticated marker still round-trips. Default all ones: what
|
|
45
|
+
//match() requires.
|
|
46
|
+
marker: { ...this.fieldHex('marker', 0, 16, 'Marker'), default: 'ff'.repeat(16) },
|
|
46
47
|
length: {
|
|
47
48
|
type: 'integer',
|
|
48
49
|
autoCalculated: true,
|
package/dist/headers/Babel.js
CHANGED
|
@@ -61,7 +61,7 @@ class Babel extends BaseHeader_1.BaseHeader {
|
|
|
61
61
|
summary: 'Babel v${version} ${tlvs.length} TLVs',
|
|
62
62
|
properties: {
|
|
63
63
|
//The Magic byte, always 42 (0x2a) for Babel — also the match signature on UDP 6696.
|
|
64
|
-
magic: this.fieldUInt('magic', 0, 1, 'Magic'),
|
|
64
|
+
magic: { ...this.fieldUInt('magic', 0, 1, 'Magic'), default: 42 },
|
|
65
65
|
//The protocol version, always 2 (RFC 8966).
|
|
66
66
|
version: this.fieldUInt('version', 1, 1, 'Version'),
|
|
67
67
|
//The octet count of the packet body (the TLV sequence) following this 4-byte header, NOT
|
package/dist/headers/Codesys.js
CHANGED
|
@@ -47,8 +47,9 @@ class Codesys extends BaseHeader_1.BaseHeader {
|
|
|
47
47
|
summary: 'CODESYS len=${length}',
|
|
48
48
|
properties: {
|
|
49
49
|
//The 4-byte block-driver magic (00 01 17 e8). Kept verbatim (not enum-constrained) so any
|
|
50
|
-
//observed frame round-trips even if a variant carries a different signature.
|
|
51
|
-
|
|
50
|
+
//observed frame round-trips even if a variant carries a different signature. Default
|
|
51
|
+
//000117e8: what match() requires.
|
|
52
|
+
magic: { ...this.fieldHex('magic', 0, 4, 'Block Driver Magic'), default: Codesys.#MAGIC },
|
|
52
53
|
//Block-driver payload byte count that follows the 8-byte header. LITTLE-ENDIAN 32-bit.
|
|
53
54
|
//Honored when supplied (a crafted frame may lie); else derived from the payload bytes.
|
|
54
55
|
length: {
|
package/dist/headers/DHCP.js
CHANGED
|
@@ -53,7 +53,8 @@ class DHCP extends BaseHeader_1.BaseHeader {
|
|
|
53
53
|
chaddr: this.fieldHex('chaddr', 28, 16, 'Client Hardware Address'),
|
|
54
54
|
sname: this.fieldHex('sname', 44, 64, 'Server Host Name'),
|
|
55
55
|
file: this.fieldHex('file', 108, 128, 'Boot File Name'),
|
|
56
|
-
|
|
56
|
+
//Default 0x63825363: the DHCP Magic Cookie (RFC 2131 §3), and what match() requires.
|
|
57
|
+
magicCookie: { ...this.fieldHex('magicCookie', 236, 4, 'Magic Cookie'), default: '63825363' },
|
|
57
58
|
options: {
|
|
58
59
|
type: 'array',
|
|
59
60
|
label: 'Options',
|
package/dist/headers/DNP3.d.ts
CHANGED
|
@@ -9,13 +9,18 @@ import { DemuxProducer } from '../types/DemuxProducer';
|
|
|
9
9
|
* Source address, and a header CRC. The user data that follows is carried in blocks of up to 16 octets
|
|
10
10
|
* each with its own trailing 2-byte CRC.
|
|
11
11
|
*
|
|
12
|
-
* This codec decodes the link header structurally and
|
|
13
|
-
*
|
|
14
|
-
* the transport/application layer is a cross-frame
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
12
|
+
* This codec decodes the link header structurally and carries the data-block region in one of two hex
|
|
13
|
+
* fields. `userData` is the user data with the block CRCs removed (transport header + application data,
|
|
14
|
+
* not decoded further: reassembling the transport/application layer is a cross-frame concern); `payload`
|
|
15
|
+
* is the region verbatim, block CRCs included. Decode emits exactly one of them: `userData` when the
|
|
16
|
+
* region is complete and every block CRC verifies, otherwise `payload` plus a warning naming each bad or
|
|
17
|
+
* truncated block. On encode a given `payload` wins and is written as given (how a frame with a wrong
|
|
18
|
+
* block CRC is crafted; a `userData` given alongside it is ignored with a warning); otherwise `userData`
|
|
19
|
+
* is split into 16-octet blocks, each followed by its CRC-16/DNP, low octet first. Length and the header
|
|
20
|
+
* CRC are written as given; left out, Length counts the user data octets (the block CRCs excluded) and
|
|
21
|
+
* the header CRC is computed (CRC-16/DNP over the first 8 octets). A frame round-trips byte-for-byte
|
|
22
|
+
* either way; the frame's extent is derived from the Length field so a pipelined/trailing frame is left
|
|
23
|
+
* to RawData.
|
|
19
24
|
*/
|
|
20
25
|
export declare class DNP3 extends BaseHeader {
|
|
21
26
|
#private;
|