@netkitty/codec 1.2.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/CHANGELOG.md +295 -0
  2. package/README.md +62 -10
  3. package/README.zh-CN.md +55 -9
  4. package/dist/Codec.d.ts +3 -2
  5. package/dist/Codec.js +109 -10
  6. package/dist/abstracts/BaseHeader.d.ts +54 -2
  7. package/dist/abstracts/BaseHeader.js +185 -43
  8. package/dist/errors/CodecSchemaValidateError.d.ts +34 -1
  9. package/dist/errors/CodecSchemaValidateError.js +26 -3
  10. package/dist/headers/ADSAMS.js +2 -0
  11. package/dist/headers/AH.js +4 -2
  12. package/dist/headers/AMQP.js +2 -1
  13. package/dist/headers/ARP.js +16 -10
  14. package/dist/headers/BACnetIP.js +1 -0
  15. package/dist/headers/BFD.d.ts +2 -1
  16. package/dist/headers/BFD.js +30 -4
  17. package/dist/headers/BGP.js +6 -1
  18. package/dist/headers/Babel.js +2 -1
  19. package/dist/headers/BitTorrent.d.ts +2 -0
  20. package/dist/headers/BitTorrent.js +4 -2
  21. package/dist/headers/C37118.d.ts +3 -2
  22. package/dist/headers/C37118.js +35 -15
  23. package/dist/headers/CAPWAP.js +1 -0
  24. package/dist/headers/CDP.d.ts +3 -3
  25. package/dist/headers/CDP.js +47 -11
  26. package/dist/headers/CMS.js +27 -12
  27. package/dist/headers/COTP.d.ts +2 -0
  28. package/dist/headers/COTP.js +8 -4
  29. package/dist/headers/CassandraCQL.js +1 -0
  30. package/dist/headers/CoAP.js +20 -2
  31. package/dist/headers/Codesys.js +1 -0
  32. package/dist/headers/Collectd.js +1 -1
  33. package/dist/headers/DCCP.d.ts +3 -2
  34. package/dist/headers/DCCP.js +61 -8
  35. package/dist/headers/DHCPFailover.js +1 -0
  36. package/dist/headers/DNP3.d.ts +5 -3
  37. package/dist/headers/DNP3.js +62 -7
  38. package/dist/headers/DNS.js +3 -3
  39. package/dist/headers/DTLS.js +1 -0
  40. package/dist/headers/Diameter.js +3 -2
  41. package/dist/headers/EAPOL.js +1 -1
  42. package/dist/headers/EIGRP.d.ts +3 -2
  43. package/dist/headers/EIGRP.js +32 -6
  44. package/dist/headers/ENIP.js +1 -0
  45. package/dist/headers/Elasticsearch.js +1 -0
  46. package/dist/headers/EtherCAT.js +1 -0
  47. package/dist/headers/EthernetII.js +7 -0
  48. package/dist/headers/FTP.js +6 -6
  49. package/dist/headers/Finger.js +3 -3
  50. package/dist/headers/FoundationFieldbusHSE.js +1 -0
  51. package/dist/headers/GELF.js +8 -1
  52. package/dist/headers/GENEVE.js +2 -1
  53. package/dist/headers/GLBP.js +1 -1
  54. package/dist/headers/GRE.js +1 -0
  55. package/dist/headers/GTPU.js +1 -0
  56. package/dist/headers/GTPv2C.js +2 -0
  57. package/dist/headers/GitProtocol.js +2 -2
  58. package/dist/headers/Goose.js +24 -12
  59. package/dist/headers/Gopher.js +6 -6
  60. package/dist/headers/HARTIP.js +1 -0
  61. package/dist/headers/HSR.js +3 -0
  62. package/dist/headers/HTTP.js +6 -6
  63. package/dist/headers/HTTP2.js +2 -0
  64. package/dist/headers/ICMP.js +3 -1
  65. package/dist/headers/ICMPv6.js +11 -16
  66. package/dist/headers/IEC104_I_Frame.js +215 -163
  67. package/dist/headers/IEC104_S_Frame.js +26 -3
  68. package/dist/headers/IEC104_U_Frame.js +33 -4
  69. package/dist/headers/IEC61850SampledValues.js +6 -5
  70. package/dist/headers/IGMP.d.ts +8 -7
  71. package/dist/headers/IGMP.js +58 -19
  72. package/dist/headers/IMAP.js +5 -5
  73. package/dist/headers/IPFIX.js +3 -2
  74. package/dist/headers/IPv4.js +41 -21
  75. package/dist/headers/IPv6.js +5 -1
  76. package/dist/headers/IPv6HopByHopOptions.js +15 -12
  77. package/dist/headers/IRC.js +4 -4
  78. package/dist/headers/ISAKMP.js +3 -1
  79. package/dist/headers/ISCSI.js +2 -0
  80. package/dist/headers/ISIS.js +2 -1
  81. package/dist/headers/ISOSession.d.ts +2 -0
  82. package/dist/headers/ISOSession.js +14 -10
  83. package/dist/headers/Ident.js +8 -8
  84. package/dist/headers/KNXnetIP.js +1 -0
  85. package/dist/headers/Kafka.js +1 -0
  86. package/dist/headers/Kerberos.js +2 -0
  87. package/dist/headers/L2TP.js +3 -2
  88. package/dist/headers/LACP.js +1 -1
  89. package/dist/headers/LDAP.js +3 -4
  90. package/dist/headers/LDP.js +1 -0
  91. package/dist/headers/LLC.d.ts +2 -0
  92. package/dist/headers/LLC.js +3 -0
  93. package/dist/headers/LPD.js +3 -3
  94. package/dist/headers/MGCP.js +7 -7
  95. package/dist/headers/MMS.d.ts +2 -0
  96. package/dist/headers/MMS.js +10 -6
  97. package/dist/headers/MQTT.js +1 -0
  98. package/dist/headers/MQTTSN.js +1 -0
  99. package/dist/headers/MarkerProtocol.js +1 -1
  100. package/dist/headers/Megaco.js +3 -3
  101. package/dist/headers/Memcached.js +3 -2
  102. package/dist/headers/ModbusTCP.js +1 -0
  103. package/dist/headers/ModbusUDP.js +1 -0
  104. package/dist/headers/MongoDB.js +1 -0
  105. package/dist/headers/MySQL.js +1 -0
  106. package/dist/headers/NATS.js +2 -2
  107. package/dist/headers/NBDS.js +1 -0
  108. package/dist/headers/NBSS.js +1 -0
  109. package/dist/headers/NFS.js +1 -0
  110. package/dist/headers/NHRP.d.ts +1 -1
  111. package/dist/headers/NHRP.js +30 -4
  112. package/dist/headers/NNTP.js +6 -6
  113. package/dist/headers/NetFlowV5.js +1 -0
  114. package/dist/headers/OLSR.js +2 -1
  115. package/dist/headers/OPCUA.js +1 -0
  116. package/dist/headers/OSPF.d.ts +3 -3
  117. package/dist/headers/OSPF.js +72 -7
  118. package/dist/headers/OpenFlow.js +1 -0
  119. package/dist/headers/OpenVPN.js +1 -0
  120. package/dist/headers/PCWorx.js +1 -0
  121. package/dist/headers/PIM.d.ts +3 -3
  122. package/dist/headers/PIM.js +55 -6
  123. package/dist/headers/POP3.js +5 -5
  124. package/dist/headers/PPPoEDiscovery.js +4 -1
  125. package/dist/headers/PPPoESession.js +1 -0
  126. package/dist/headers/PPTP.js +1 -0
  127. package/dist/headers/PTP.js +6 -1
  128. package/dist/headers/PostgreSQL.js +2 -0
  129. package/dist/headers/QUIC.js +2 -0
  130. package/dist/headers/RADIUS.js +1 -0
  131. package/dist/headers/RDP.d.ts +2 -0
  132. package/dist/headers/RDP.js +6 -1
  133. package/dist/headers/RFB.js +4 -4
  134. package/dist/headers/RGoose.js +8 -1
  135. package/dist/headers/RSVP.d.ts +3 -3
  136. package/dist/headers/RSVP.js +59 -44
  137. package/dist/headers/RTCP.js +2 -0
  138. package/dist/headers/RTP.js +2 -1
  139. package/dist/headers/RTPS.d.ts +2 -0
  140. package/dist/headers/RTPS.js +4 -1
  141. package/dist/headers/RTSP.js +7 -7
  142. package/dist/headers/RawData.js +1 -1
  143. package/dist/headers/Redis.js +4 -4
  144. package/dist/headers/Rlogin.js +5 -5
  145. package/dist/headers/Rsync.js +2 -2
  146. package/dist/headers/S7comm.d.ts +2 -0
  147. package/dist/headers/S7comm.js +5 -1
  148. package/dist/headers/SCTP.d.ts +2 -2
  149. package/dist/headers/SCTP.js +31 -7
  150. package/dist/headers/SFlow.js +2 -1
  151. package/dist/headers/SIP.js +6 -6
  152. package/dist/headers/SLMP.js +1 -0
  153. package/dist/headers/SLP.js +2 -0
  154. package/dist/headers/SLPv1.js +1 -0
  155. package/dist/headers/SMB1.js +1 -0
  156. package/dist/headers/SMB2.js +1 -0
  157. package/dist/headers/SMPP.js +1 -0
  158. package/dist/headers/SMTP.js +6 -6
  159. package/dist/headers/SNAP.js +18 -5
  160. package/dist/headers/SNMP.js +6 -6
  161. package/dist/headers/SOCKS4.js +11 -5
  162. package/dist/headers/SSDP.js +7 -7
  163. package/dist/headers/SSH.js +5 -4
  164. package/dist/headers/STOMP.js +5 -5
  165. package/dist/headers/STUN.js +3 -1
  166. package/dist/headers/SercosIII.d.ts +3 -2
  167. package/dist/headers/SercosIII.js +41 -5
  168. package/dist/headers/Skinny.js +1 -0
  169. package/dist/headers/StatsD.js +4 -4
  170. package/dist/headers/SunRPC.js +1 -0
  171. package/dist/headers/Syslog.js +2 -2
  172. package/dist/headers/TCP.js +31 -64
  173. package/dist/headers/TLS_Alert.js +42 -12
  174. package/dist/headers/TLS_ApplicationData.d.ts +3 -3
  175. package/dist/headers/TLS_ApplicationData.js +32 -8
  176. package/dist/headers/TLS_ChangeCipherSpec.d.ts +2 -2
  177. package/dist/headers/TLS_ChangeCipherSpec.js +33 -8
  178. package/dist/headers/TLS_Handshake.js +78 -30
  179. package/dist/headers/TLS_Heartbeat.d.ts +4 -3
  180. package/dist/headers/TLS_Heartbeat.js +50 -8
  181. package/dist/headers/TPKT.js +4 -2
  182. package/dist/headers/TacacsPlus.js +1 -0
  183. package/dist/headers/Telnet.js +2 -1
  184. package/dist/headers/Teredo.js +2 -2
  185. package/dist/headers/UDP.js +20 -56
  186. package/dist/headers/VLAN_802dot1Q.js +8 -0
  187. package/dist/headers/VRRP.d.ts +2 -1
  188. package/dist/headers/VRRP.js +45 -9
  189. package/dist/headers/WCCP.js +1 -0
  190. package/dist/headers/WHOIS.js +3 -3
  191. package/dist/headers/WSDiscovery.js +2 -2
  192. package/dist/headers/XMPP.js +3 -3
  193. package/dist/headers/Zabbix.js +1 -0
  194. package/dist/helper/Checksum.d.ts +15 -0
  195. package/dist/helper/Checksum.js +56 -0
  196. package/dist/helper/Crc.d.ts +18 -0
  197. package/dist/helper/Crc.js +58 -0
  198. package/dist/index.d.ts +3 -3
  199. package/dist/lib/SchemaValidator.d.ts +31 -0
  200. package/dist/lib/SchemaValidator.js +137 -0
  201. package/dist/schema/ProtocolFieldJSONSchema.d.ts +4 -1
  202. package/dist/schema/ProtocolJSONSchema.d.ts +1 -1
  203. package/dist/types/CodecErrorInfo.d.ts +11 -0
  204. package/dist/types/LayerGraph.d.ts +14 -1
  205. package/package.json +2 -2
@@ -6,6 +6,7 @@ const BufferToHex_1 = require("../helper/BufferToHex");
6
6
  const HexToBuffer_1 = require("../helper/HexToBuffer");
7
7
  const BufferToNumber_1 = require("../helper/BufferToNumber");
8
8
  const NumberToBuffer_1 = require("../helper/NumberToBuffer");
9
+ const Checksum_1 = require("../helper/Checksum");
9
10
  const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
10
11
  /**
11
12
  * CDP — Cisco Discovery Protocol, carried in an 802.3 frame over LLC/SNAP with OUI 0x00000C and PID
@@ -15,9 +16,9 @@ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
15
16
  * Capabilities, 0x0005 Software Version, 0x0006 Platform.
16
17
  *
17
18
  * The TLV values are kept verbatim as hex (device names, address lists and capability bitmaps need no
18
- * form structure), the Checksum is honored verbatim (never recomputed), and the TLV walk is bounded by
19
- * the captured bytes so a corrupt Length can't run past the frame. A well-formed CDP frame round-trips
20
- * byte-for-byte.
19
+ * form structure), and the TLV walk is bounded by the captured bytes so a corrupt Length can't run past
20
+ * the frame. The Checksum and each TLV Length are computed on encode when left out and written as given
21
+ * otherwise. A well-formed CDP frame round-trips byte-for-byte.
21
22
  */
22
23
  class CDP extends BaseHeader_1.BaseHeader {
23
24
  constructor() {
@@ -33,6 +34,21 @@ class CDP extends BaseHeader_1.BaseHeader {
33
34
  get SCHEMA() {
34
35
  return (CDP.#schemaCache ??= CDP.#buildSchema());
35
36
  }
37
+ /**
38
+ * The CDP checksum: the Internet checksum of the whole CDP message, except for an odd trailing
39
+ * octet. RFC 1071 pads it with a zero octet (word 0xXX00); Cisco adds it as a signed low byte
40
+ * instead, which comes out as the word 0x00XX below 0x80 and 0xFF(XX-1) from 0x80 on. This is what
41
+ * Wireshark's CDP dissector checks, and real Cisco captures carry it.
42
+ * @param message the CDP message with the checksum field zeroed
43
+ * @private
44
+ */
45
+ static #checksum(message) {
46
+ if (message.length % 2 === 0)
47
+ return (0, Checksum_1.InternetChecksum)(message);
48
+ const last = message[message.length - 1];
49
+ const finalWord = (last & 0x80) ? Buffer.from([0xFF, last - 1]) : Buffer.from([0x00, last]);
50
+ return (0, Checksum_1.InternetChecksum)(message.subarray(0, message.length - 1), finalWord);
51
+ }
36
52
  static #buildSchema() {
37
53
  return {
38
54
  type: 'object',
@@ -40,9 +56,29 @@ class CDP extends BaseHeader_1.BaseHeader {
40
56
  properties: {
41
57
  version: this.fieldUInt('version', 0, 1, 'Version'),
42
58
  ttl: this.fieldUInt('ttl', 1, 1, 'TTL'),
43
- //Honored verbatim — the ones-complement checksum is never recomputed, so a captured frame
44
- //round-trips byte-for-byte.
45
- checksum: this.fieldHex('checksum', 2, 2, 'Checksum'),
59
+ //Left out, computed once every TLV is written (#checksum); a given value is written as given.
60
+ checksum: {
61
+ type: 'string',
62
+ autoCalculated: true,
63
+ label: 'Checksum',
64
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
65
+ decode: function () {
66
+ this.instance.checksum.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(2, 2)));
67
+ },
68
+ encode: function () {
69
+ if (!this.isLeftOut(this.instance.checksum)) {
70
+ this.writeBytes(2, (0, HexToBuffer_1.HexToBuffer)(this.instance.checksum.getValue('0000')));
71
+ return;
72
+ }
73
+ this.instance.checksum.setValue('0000');
74
+ this.writeBytes(2, Buffer.alloc(2, 0));
75
+ this.addPostSelfEncodeHandler(() => {
76
+ const checksum = (0, NumberToBuffer_1.UInt16ToBuffer)(CDP.#checksum(this.packet.subarray(this.startPos, this.endPos)));
77
+ this.instance.checksum.setValue((0, BufferToHex_1.BufferToHex)(checksum));
78
+ this.writeBytes(2, checksum);
79
+ });
80
+ }
81
+ },
46
82
  tlvs: {
47
83
  type: 'array',
48
84
  label: 'TLVs',
@@ -50,7 +86,7 @@ class CDP extends BaseHeader_1.BaseHeader {
50
86
  type: 'object',
51
87
  properties: {
52
88
  type: { type: 'integer', label: 'Type', minimum: 0, maximum: 65535 },
53
- length: { type: 'integer', label: 'Length', minimum: 0, maximum: 65535 },
89
+ length: { type: 'integer', label: 'Length', autoCalculated: true, minimum: 0, maximum: 65535 },
54
90
  value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
55
91
  }
56
92
  },
@@ -87,10 +123,10 @@ class CDP extends BaseHeader_1.BaseHeader {
87
123
  let offset = 4;
88
124
  for (const tlv of tlvs) {
89
125
  const valueBuffer = (0, HexToBuffer_1.HexToBuffer)(tlv && tlv.value ? String(tlv.value) : '');
90
- const providedLength = Number(tlv && tlv.length);
91
- const lengthValue = (Number.isFinite(providedLength) && providedLength > 0)
92
- ? providedLength
93
- : 4 + valueBuffer.length;
126
+ //Length written as given, 0 included (a crafted TLV may lie); left out, derived
127
+ //from the 4-byte header + value.
128
+ const lengthLeftOut = !tlv || tlv.length === undefined || tlv.length === null;
129
+ const lengthValue = lengthLeftOut ? 4 + valueBuffer.length : (Number(tlv.length) || 0);
94
130
  const type = Number(tlv && tlv.type) || 0;
95
131
  this.writeBytes(offset, (0, NumberToBuffer_1.UInt16ToBuffer)(type & 0xffff));
96
132
  this.writeBytes(offset + 2, (0, NumberToBuffer_1.UInt16ToBuffer)(lengthValue > 65535 ? 65535 : lengthValue));
@@ -66,9 +66,9 @@ class CMS extends BaseHeader_1.BaseHeader {
66
66
  err: this.#bit('err', 2, 'Err'),
67
67
  //bak: reserved.
68
68
  bak: this.#bit('bak', 3, 'bak'),
69
- //Protocol type PI — the low nibble, 0x01 for DL/T 2811.
69
+ //Protocol type PI — the low nibble, 0x01 for DL/T 2811 (the default, and what match() requires).
70
70
  protocolType: {
71
- type: 'integer', label: 'Protocol Type', minimum: 0, maximum: 15,
71
+ type: 'integer', label: 'Protocol Type', minimum: 0, maximum: 15, default: 1,
72
72
  decode: function () {
73
73
  this.instance.protocolType.setValue(this.readBits(0, 1, 4, 4));
74
74
  },
@@ -79,20 +79,35 @@ class CMS extends BaseHeader_1.BaseHeader {
79
79
  //Service Code SC (byte 2) — the service in the data area (Table 1).
80
80
  serviceCode: this.fieldUInt('serviceCode', 1, 1, 'Service Code'),
81
81
  //Frame Length FL (bytes 3-4, LITTLE-ENDIAN) — the APDU length excluding the 4-byte APCH,
82
- //i.e. the ASDU length. Honored verbatim.
82
+ //i.e. the ASDU length. Written as given; left out, it is the ASDU this layer writes
83
+ //(ReqID + service data), known once the whole layer is encoded.
83
84
  frameLength: {
84
- type: 'integer', label: 'Frame Length', minimum: 0, maximum: 65535,
85
+ type: 'integer', autoCalculated: true, label: 'Frame Length', minimum: 0, maximum: 65535,
85
86
  decode: function () {
86
87
  const b = this.readBytes(2, 2);
87
88
  this.instance.frameLength.setValue((b[0] | (b[1] << 8)) & 0xffff);
88
89
  },
89
90
  encode: function () {
90
- let value = this.instance.frameLength.getValue(0);
91
- if (value > 65535)
92
- value = 65535;
93
- if (value < 0)
94
- value = 0;
95
- this.writeBytes(2, Buffer.from([value & 0xff, (value >> 8) & 0xff]));
91
+ const write = (value) => this.writeBytes(2, Buffer.from([value & 0xff, (value >> 8) & 0xff]));
92
+ if (!this.isLeftOut(this.instance.frameLength)) {
93
+ let value = this.instance.frameLength.getValue(0);
94
+ if (value > 65535)
95
+ value = 65535;
96
+ if (value < 0)
97
+ value = 0;
98
+ write(value);
99
+ return;
100
+ }
101
+ write(0);
102
+ this.addPostSelfEncodeHandler(() => {
103
+ let value = this.length - 4;
104
+ if (value > 65535) {
105
+ this.recordError(this.instance.frameLength.getPath(), 'Maximum value is 65535');
106
+ value = 65535;
107
+ }
108
+ this.instance.frameLength.setValue(value);
109
+ write(value);
110
+ });
96
111
  }
97
112
  },
98
113
  //==== ASDU ====
@@ -157,10 +172,10 @@ class CMS extends BaseHeader_1.BaseHeader {
157
172
  //(DL/T 2811 §6.10) per the Service Code. Populated on decode by the serviceData closure
158
173
  //above; it has no encode closure, so `serviceData` (hex) stays the authoritative encode
159
174
  //form and the structured view can never perturb the re-emitted bytes.
160
- serviceDataDecoded: { type: 'object', label: 'Service Data (decoded)' },
175
+ serviceDataDecoded: { type: 'object', label: 'Service Data (decoded)', readOnly: true, properties: {}, additionalProperties: true },
161
176
  //Display-only best-effort readable identifiers extracted from a service data area that has
162
177
  //no transcribed structure (the GB/T 33603 M-coded responses). No encode closure.
163
- serviceDataStrings: { type: 'array', label: 'Readable Identifiers', items: { type: 'string' } }
178
+ serviceDataStrings: { type: 'array', label: 'Readable Identifiers', readOnly: true, items: { type: 'string' } }
164
179
  }
165
180
  };
166
181
  }
@@ -1,4 +1,5 @@
1
1
  import { BaseHeader } from '../abstracts/BaseHeader';
2
+ import { HeuristicParent } from '../types/LayerGraph';
2
3
  import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
3
4
  import { DemuxProducer } from '../types/DemuxProducer';
4
5
  /**
@@ -25,6 +26,7 @@ export declare class COTP extends BaseHeader {
25
26
  readonly name: string;
26
27
  readonly nickname: string;
27
28
  readonly matchKeys: string[];
29
+ readonly heuristicParents: HeuristicParent[];
28
30
  match(): boolean;
29
31
  readonly demuxProducers: DemuxProducer[];
30
32
  }
@@ -32,6 +32,8 @@ class COTP extends BaseHeader_1.BaseHeader {
32
32
  this.nickname = 'COTP';
33
33
  //No demux keys: COTP is an unkeyed content-heuristic child that only rides on top of TPKT.
34
34
  this.matchKeys = [];
35
+ //Editor graph: matched by content, so list it under these parents in allowedNextLayers().
36
+ this.heuristicParents = ['tpkt'];
35
37
  //Effectively a leaf for now — the session/MMS layers above are kept verbatim and decoded later.
36
38
  this.demuxProducers = [];
37
39
  }
@@ -52,6 +54,7 @@ class COTP extends BaseHeader_1.BaseHeader {
52
54
  //Honoured when supplied; else derived from the PDU Type + any verbatim header bytes.
53
55
  li: {
54
56
  type: 'integer',
57
+ autoCalculated: true,
55
58
  label: 'Length Indicator',
56
59
  minimum: 0,
57
60
  maximum: 255,
@@ -59,9 +62,8 @@ class COTP extends BaseHeader_1.BaseHeader {
59
62
  this.instance.li.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(0, 1)));
60
63
  },
61
64
  encode: function () {
62
- const provided = this.instance.li.getValue(0);
63
- let value = provided;
64
- if (!value) {
65
+ let value = this.instance.li.getValue(0);
66
+ if (this.isLeftOut(this.instance.li)) {
65
67
  const dt = COTP.#isDT(this.instance.pduType.getValue(0));
66
68
  const headerRest = (0, HexToBuffer_1.HexToBuffer)(this.instance.headerRest.getValue(''));
67
69
  //pduType(1) + (DT ? the EOT/TPDU-NR octet(1) : 0) + verbatim header bytes.
@@ -76,11 +78,13 @@ class COTP extends BaseHeader_1.BaseHeader {
76
78
  }
77
79
  },
78
80
  //Full PDU Type octet (high nibble = type code, low nibble kept verbatim), e.g. DT = 0xF0 = 240.
79
- pduType: this.fieldUInt('pduType', 1, 1, 'PDU Type'),
81
+ //Default DT (0xF0) with EOT set: the TPDU that carries S7comm / ISO-Session / MMS above it.
82
+ pduType: { ...this.fieldUInt('pduType', 1, 1, 'PDU Type'), default: 0xf0 },
80
83
  //DT only: bit 7 of the octet at offset 2 — "end of TSDU". Meaningless for other types (left false).
81
84
  eot: {
82
85
  type: 'boolean',
83
86
  label: 'EOT',
87
+ default: true,
84
88
  decode: function () {
85
89
  const dt = COTP.#isDT(this.instance.pduType.getValue(0));
86
90
  this.instance.eot.setValue(dt ? !!this.readBits(2, 1, 0, 1) : false);
@@ -55,6 +55,7 @@ class CassandraCQL extends BaseHeader_1.BaseHeader {
55
55
  opcode: this.fieldUInt('opcode', 4, 1, 'Opcode'),
56
56
  length: {
57
57
  type: 'integer',
58
+ autoCalculated: true,
58
59
  label: 'Length',
59
60
  minimum: 0,
60
61
  maximum: 4294967295,
@@ -78,9 +78,27 @@ class CoAP extends BaseHeader_1.BaseHeader {
78
78
  summary: 'CoAP type=${type} code=${code}',
79
79
  properties: {
80
80
  //Byte 0 (MSB first): Version (bits 7:6, always 1), Type (bits 5:4), Token Length (bits 3:0).
81
- version: this.#bitField('version', 0, 2, 3, 'Version'),
81
+ //Default version 1: the only CoAP version (RFC 7252), and what match() requires.
82
+ version: { ...this.#bitField('version', 0, 2, 3, 'Version'), default: 1 },
82
83
  type: this.#bitField('type', 2, 2, 3, 'Type'),
83
- tokenLength: this.#bitField('tokenLength', 4, 4, 15, 'Token Length'),
84
+ //Written as given (a crafted TKL may disagree with the token); left out, the token's octet count.
85
+ tokenLength: {
86
+ ...this.#bitField('tokenLength', 4, 4, 15, 'Token Length'),
87
+ autoCalculated: true,
88
+ encode: function () {
89
+ if (!this.isLeftOut(this.instance.tokenLength)) {
90
+ this.writeBits(0, 1, 4, 4, this.instance.tokenLength.getValue(0));
91
+ return;
92
+ }
93
+ let tokenLength = (0, HexToBuffer_1.HexToBuffer)(this.instance.token.getValue('')).length;
94
+ if (tokenLength > 8)
95
+ this.recordError(this.instance.tokenLength.getPath(), 'A CoAP token is at most 8 octets (RFC 7252 section 3)');
96
+ if (tokenLength > 15)
97
+ tokenLength = 15;
98
+ this.instance.tokenLength.setValue(tokenLength);
99
+ this.writeBits(0, 1, 4, 4, tokenLength);
100
+ }
101
+ },
84
102
  //Byte 1: Code — a 3-bit class and 5-bit detail packed as one octet (e.g. 0x01 = 0.01 GET).
85
103
  code: this.fieldUInt('code', 1, 1, 'Code'),
86
104
  //Bytes 2-3: Message ID (big-endian uint16).
@@ -53,6 +53,7 @@ class Codesys extends BaseHeader_1.BaseHeader {
53
53
  //Honored when supplied (a crafted frame may lie); else derived from the payload bytes.
54
54
  length: {
55
55
  type: 'integer',
56
+ autoCalculated: true,
56
57
  label: 'Length',
57
58
  minimum: 0,
58
59
  maximum: 4294967295,
@@ -51,7 +51,7 @@ class Collectd extends BaseHeader_1.BaseHeader {
51
51
  type: { type: 'integer', label: 'Type', minimum: 0, maximum: 65535 },
52
52
  //On-wire Length INCLUDING the 4-byte part header (Type + Length). Honored
53
53
  //verbatim on encode; derived as 4 + value bytes when omitted.
54
- length: { type: 'integer', label: 'Length', minimum: 0, maximum: 65535 },
54
+ length: { type: 'integer', label: 'Length', autoCalculated: true, minimum: 0, maximum: 65535 },
55
55
  value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
56
56
  }
57
57
  },
@@ -15,8 +15,9 @@ import { DemuxProducer } from '../types/DemuxProducer';
15
15
  * the header — Reserved, the Sequence/Ack numbers, per-type fields and options — verbatim as
16
16
  * `headerOptions` hex (bytes 9 .. DataOffset*4). Application data after the header is kept as `payload`
17
17
  * hex, bounded by the enclosing IP datagram so an inflated Data Offset can't read past the IP payload.
18
- * The Checksum is honored verbatim, never recomputed; Data Offset is honored when supplied, else derived
19
- * from the actual bytes. A well-formed datagram round-trips byte-for-byte.
18
+ * The Checksum and Data Offset are computed on encode when left out (the checksum per RFC 4340 §9, Data
19
+ * Offset from the actual bytes) and written as given otherwise. A well-formed datagram round-trips
20
+ * byte-for-byte.
20
21
  */
21
22
  export declare class DCCP extends BaseHeader {
22
23
  #private;
@@ -4,7 +4,9 @@ exports.DCCP = void 0;
4
4
  const BaseHeader_1 = require("../abstracts/BaseHeader");
5
5
  const BufferToHex_1 = require("../helper/BufferToHex");
6
6
  const HexToBuffer_1 = require("../helper/HexToBuffer");
7
+ const BufferToNumber_1 = require("../helper/BufferToNumber");
7
8
  const NumberToBuffer_1 = require("../helper/NumberToBuffer");
9
+ const Checksum_1 = require("../helper/Checksum");
8
10
  const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
9
11
  /**
10
12
  * DCCP — Datagram Congestion Control Protocol (RFC 4340), carried directly over IP as protocol 33. The
@@ -20,8 +22,9 @@ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
20
22
  * the header — Reserved, the Sequence/Ack numbers, per-type fields and options — verbatim as
21
23
  * `headerOptions` hex (bytes 9 .. DataOffset*4). Application data after the header is kept as `payload`
22
24
  * hex, bounded by the enclosing IP datagram so an inflated Data Offset can't read past the IP payload.
23
- * The Checksum is honored verbatim, never recomputed; Data Offset is honored when supplied, else derived
24
- * from the actual bytes. A well-formed datagram round-trips byte-for-byte.
25
+ * The Checksum and Data Offset are computed on encode when left out (the checksum per RFC 4340 §9, Data
26
+ * Offset from the actual bytes) and written as given otherwise. A well-formed datagram round-trips
27
+ * byte-for-byte.
25
28
  */
26
29
  class DCCP extends BaseHeader_1.BaseHeader {
27
30
  constructor() {
@@ -73,6 +76,28 @@ class DCCP extends BaseHeader_1.BaseHeader {
73
76
  end = 0;
74
77
  return end;
75
78
  }
79
+ /**
80
+ * The DCCP checksum (RFC 4340 §9): the Internet checksum of the nearest IP layer's pseudo-header
81
+ * (protocol 33, length = the whole DCCP packet), the DCCP header and the application data Checksum
82
+ * Coverage selects — all of it when CsCov is 0, else the first (CsCov - 1) × 4 bytes after the Data
83
+ * Offset × 4 header, capped at the packet. Called once every field is written, checksum still zero.
84
+ */
85
+ #calculateChecksum() {
86
+ const packet = this.packet.subarray(this.startPos, this.endPos);
87
+ const pseudoHeader = this.ipPseudoHeader(33, packet.length);
88
+ if (!pseudoHeader) {
89
+ this.recordError(this.instance.checksum.getPath(), 'Cannot compute DCCP checksum: no IP layer beneath DCCP');
90
+ return 0;
91
+ }
92
+ const cscov = this.instance.cscov.getValue(0);
93
+ let covered = packet.length;
94
+ if (cscov) {
95
+ const coverage = (this.instance.dataOffset.getValue(0) + cscov - 1) * 4;
96
+ if (coverage < covered)
97
+ covered = coverage;
98
+ }
99
+ return (0, Checksum_1.InternetChecksum)(pseudoHeader, packet.subarray(0, covered));
100
+ }
76
101
  /** A big-endian bit-slice within a single octet at `offset`, read/written in place. */
77
102
  static #bitField(name, offset, bitOffset, bitLength, label) {
78
103
  const maximum = (2 ** bitLength) - 1;
@@ -105,9 +130,11 @@ class DCCP extends BaseHeader_1.BaseHeader {
105
130
  dstPort: this.fieldUInt('dstPort', 2, 2, 'Destination Port'),
106
131
  //Data Offset (32-bit words) = the length of the whole DCCP header incl. options. Honored
107
132
  //when supplied (a crafted datagram may lie); else derived from the fixed 9-byte prefix
108
- //plus the verbatim headerOptions bytes, rounded up to a word.
133
+ //plus the verbatim headerOptions bytes, rounded up to a word, and the header is
134
+ //zero-filled up to that word so it is as long as the Data Offset says.
109
135
  dataOffset: {
110
136
  type: 'integer',
137
+ autoCalculated: true,
111
138
  label: 'Data Offset',
112
139
  minimum: 0,
113
140
  maximum: 255,
@@ -121,8 +148,10 @@ class DCCP extends BaseHeader_1.BaseHeader {
121
148
  value = provided;
122
149
  }
123
150
  else {
124
- const optBytes = (0, HexToBuffer_1.HexToBuffer)(this.instance.headerOptions.getValue('')).length;
125
- value = Math.ceil((9 + optBytes) / 4);
151
+ const headerBytes = 9 + (0, HexToBuffer_1.HexToBuffer)(this.instance.headerOptions.getValue('')).length;
152
+ value = Math.ceil(headerBytes / 4);
153
+ if (value * 4 > headerBytes)
154
+ this.writeBytes(headerBytes, Buffer.alloc(value * 4 - headerBytes, 0));
126
155
  }
127
156
  if (value > 255) {
128
157
  this.recordError(this.instance.dataOffset.getPath(), 'Maximum value is 255');
@@ -137,9 +166,33 @@ class DCCP extends BaseHeader_1.BaseHeader {
137
166
  //Byte 5: CCVal (high 4 bits) + CsCov (low 4 bits).
138
167
  ccval: this.#bitField('ccval', 5, 0, 4, 'CCVal'),
139
168
  cscov: this.#bitField('cscov', 5, 4, 4, 'Checksum Coverage'),
140
- //Honored verbatim: the DCCP checksum (ones-complement over pseudo-header + coverage) is
141
- //never recomputed, so a captured datagram round-trips byte-for-byte.
142
- checksum: this.fieldUInt('checksum', 6, 2, 'Checksum'),
169
+ //Left out, computed once every field is written (#calculateChecksum); a given value is
170
+ //written as given, so a captured datagram round-trips byte-for-byte.
171
+ checksum: {
172
+ type: 'integer',
173
+ autoCalculated: true,
174
+ label: 'Checksum',
175
+ minimum: 0,
176
+ maximum: 65535,
177
+ decode: function () {
178
+ this.instance.checksum.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(6, 2)));
179
+ },
180
+ encode: function () {
181
+ if (!this.isLeftOut(this.instance.checksum)) {
182
+ const checksum = this.instance.checksum.getValue(0);
183
+ this.instance.checksum.setValue(checksum);
184
+ this.writeBytes(6, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
185
+ return;
186
+ }
187
+ this.instance.checksum.setValue(0);
188
+ this.writeBytes(6, (0, NumberToBuffer_1.UInt16ToBuffer)(0));
189
+ this.addPostSelfEncodeHandler(() => {
190
+ const checksum = this.#calculateChecksum();
191
+ this.instance.checksum.setValue(checksum);
192
+ this.writeBytes(6, (0, NumberToBuffer_1.UInt16ToBuffer)(checksum));
193
+ });
194
+ }
195
+ },
143
196
  //Byte 8: Res (3 bits) + Type (4 bits) + X (1 bit, Extended Sequence Numbers).
144
197
  res: this.#bitField('res', 8, 0, 3, 'Reserved'),
145
198
  type: this.#bitField('type', 8, 3, 4, 'Type'),
@@ -45,6 +45,7 @@ class DHCPFailover extends BaseHeader_1.BaseHeader {
45
45
  properties: {
46
46
  length: {
47
47
  type: 'integer',
48
+ autoCalculated: true,
48
49
  label: 'Message Length',
49
50
  minimum: 0,
50
51
  maximum: 65535,
@@ -11,9 +11,11 @@ import { DemuxProducer } from '../types/DemuxProducer';
11
11
  *
12
12
  * This codec decodes the link header structurally and keeps the data-block region (transport header +
13
13
  * application data + the per-block CRCs) verbatim as `payload` hex — de-blocking those CRCs to recover
14
- * the transport/application layer is a cross-frame reassembly concern, not a single-packet one. The CRCs
15
- * are honored verbatim (never recomputed), so a well-formed frame round-trips byte-for-byte; the frame's
16
- * extent is derived from the Length field so a pipelined/trailing frame is left to RawData.
14
+ * the transport/application layer is a cross-frame reassembly concern, not a single-packet one. The block
15
+ * CRCs stay inside `payload` exactly as given. Length and the header CRC are written as given; left out,
16
+ * Length counts the payload's data octets (its block CRCs excluded) and the header CRC is computed
17
+ * (CRC-16/DNP over the first 8 octets). A well-formed frame round-trips byte-for-byte; the frame's extent is
18
+ * derived from the Length field so a pipelined/trailing frame is left to RawData.
17
19
  */
18
20
  export declare class DNP3 extends BaseHeader {
19
21
  #private;
@@ -5,6 +5,9 @@ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
5
  const BufferToHex_1 = require("../helper/BufferToHex");
6
6
  const HexToBuffer_1 = require("../helper/HexToBuffer");
7
7
  const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
8
+ const BufferToNumber_1 = require("../helper/BufferToNumber");
9
+ const NumberToBuffer_1 = require("../helper/NumberToBuffer");
10
+ const Crc_1 = require("../helper/Crc");
8
11
  /**
9
12
  * DNP3 — Distributed Network Protocol 3 (IEEE 1815), a SCADA protocol common in electric/water
10
13
  * utilities, on TCP/UDP port 20000. Each frame begins with a 10-byte Data Link Layer header: the start
@@ -15,9 +18,11 @@ const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
15
18
  *
16
19
  * This codec decodes the link header structurally and keeps the data-block region (transport header +
17
20
  * application data + the per-block CRCs) verbatim as `payload` hex — de-blocking those CRCs to recover
18
- * the transport/application layer is a cross-frame reassembly concern, not a single-packet one. The CRCs
19
- * are honored verbatim (never recomputed), so a well-formed frame round-trips byte-for-byte; the frame's
20
- * extent is derived from the Length field so a pipelined/trailing frame is left to RawData.
21
+ * the transport/application layer is a cross-frame reassembly concern, not a single-packet one. The block
22
+ * CRCs stay inside `payload` exactly as given. Length and the header CRC are written as given; left out,
23
+ * Length counts the payload's data octets (its block CRCs excluded) and the header CRC is computed
24
+ * (CRC-16/DNP over the first 8 octets). A well-formed frame round-trips byte-for-byte; the frame's extent is
25
+ * derived from the Length field so a pipelined/trailing frame is left to RawData.
21
26
  */
22
27
  class DNP3 extends BaseHeader_1.BaseHeader {
23
28
  constructor() {
@@ -56,13 +61,44 @@ class DNP3 extends BaseHeader_1.BaseHeader {
56
61
  const blocks = Math.ceil(userData / 16);
57
62
  return 10 + userData + blocks * 2;
58
63
  }
64
+ /** The user data octets a data-block region of `payloadOctets` carries: every block is up to 16 data
65
+ * octets followed by their 2-octet CRC. A trailing block too short to hold a data octet and its CRC
66
+ * (malformed) contributes none. */
67
+ static #userDataOctets(payloadOctets) {
68
+ const rest = payloadOctets % 18;
69
+ return Math.floor(payloadOctets / 18) * 16 + (rest > 2 ? rest - 2 : 0);
70
+ }
59
71
  static #buildSchema() {
60
72
  return {
61
73
  type: 'object',
62
74
  summary: 'DNP3 func=${control.functionCode} ${source}->${destination}',
63
75
  properties: {
64
- start: this.fieldHex('start', 0, 2, 'Start'),
65
- length: this.fieldUInt('length', 2, 1, 'Length'),
76
+ //Default 0x0564: the start octets every DNP3 frame begins with, and what match() requires.
77
+ start: { ...this.fieldHex('start', 0, 2, 'Start'), default: '0564' },
78
+ //Octets from Control through the user data, the block CRCs excluded: 5 + user data octets.
79
+ length: {
80
+ type: 'integer',
81
+ autoCalculated: true,
82
+ label: 'Length',
83
+ minimum: 0,
84
+ maximum: 255,
85
+ decode: function () {
86
+ this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(2, 1)));
87
+ },
88
+ encode: function () {
89
+ if (!this.isLeftOut(this.instance.length)) {
90
+ this.writeBytes(2, (0, NumberToBuffer_1.UInt8ToBuffer)(this.instance.length.getValue(0)));
91
+ return;
92
+ }
93
+ let length = 5 + DNP3.#userDataOctets((0, HexToBuffer_1.HexToBuffer)(this.instance.payload.getValue('')).length);
94
+ if (length > 255) {
95
+ this.recordError(this.instance.length.getPath(), 'Maximum value is 255');
96
+ length = 255;
97
+ }
98
+ this.instance.length.setValue(length);
99
+ this.writeBytes(2, (0, NumberToBuffer_1.UInt8ToBuffer)(length));
100
+ }
101
+ },
66
102
  //Control octet (byte 3, MSB first): DIR / PRM / FCB / FCV(or DFC) / Function Code(4 bits).
67
103
  control: {
68
104
  type: 'object',
@@ -111,8 +147,27 @@ class DNP3 extends BaseHeader_1.BaseHeader {
111
147
  this.writeBytes(6, Buffer.from([value & 0xff, (value >> 8) & 0xff]));
112
148
  }
113
149
  },
114
- //Header CRC over the preceding 8 octets, honored verbatim (never recomputed).
115
- headerCrc: this.fieldHex('headerCrc', 8, 2, 'Header CRC'),
150
+ //Header CRC: CRC-16/DNP over the preceding 8 octets (start through source), low octet first.
151
+ //Those octets are all written when this runs, so a left-out CRC is computed right here.
152
+ headerCrc: {
153
+ type: 'string',
154
+ autoCalculated: true,
155
+ label: 'Header CRC',
156
+ contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
157
+ decode: function () {
158
+ this.instance.headerCrc.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(8, 2)));
159
+ },
160
+ encode: function () {
161
+ if (!this.isLeftOut(this.instance.headerCrc)) {
162
+ this.writeBytes(8, (0, HexToBuffer_1.HexToBuffer)(this.instance.headerCrc.getValue()));
163
+ return;
164
+ }
165
+ const crc = (0, Crc_1.Crc16Dnp)(this.readBytes(0, 8));
166
+ const crcBuffer = Buffer.from([crc & 0xff, (crc >> 8) & 0xff]);
167
+ this.instance.headerCrc.setValue((0, BufferToHex_1.BufferToHex)(crcBuffer));
168
+ this.writeBytes(8, crcBuffer);
169
+ }
170
+ },
116
171
  //The data-block region: transport header + application data + per-block CRCs, kept verbatim.
117
172
  //Bounded by the Length-derived frame extent so a pipelined/trailing frame is left to raw.
118
173
  payload: {
@@ -76,7 +76,7 @@ class DNS extends BaseHeader_1.BaseHeader {
76
76
  label: 'Name',
77
77
  properties: {
78
78
  value: { type: 'string', label: 'Name' },
79
- raw: { type: 'string', label: 'Raw', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX, hidden: true }
79
+ raw: { type: 'string', label: 'Raw', autoCalculated: true, contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX, hidden: true }
80
80
  }
81
81
  };
82
82
  return {
@@ -164,7 +164,7 @@ class DNS extends BaseHeader_1.BaseHeader {
164
164
  label: 'Name',
165
165
  properties: {
166
166
  value: { type: 'string', label: 'Name' },
167
- raw: { type: 'string', label: 'Raw', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX, hidden: true }
167
+ raw: { type: 'string', label: 'Raw', autoCalculated: true, contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX, hidden: true }
168
168
  }
169
169
  };
170
170
  return {
@@ -178,7 +178,7 @@ class DNS extends BaseHeader_1.BaseHeader {
178
178
  type: { type: 'integer', label: 'Type', minimum: 0, maximum: 65535 },
179
179
  class: { type: 'integer', label: 'Class', minimum: 0, maximum: 65535 },
180
180
  ttl: { type: 'integer', label: 'Time to Live', minimum: 0, maximum: 4294967295 },
181
- rdlength: { type: 'integer', label: 'Data Length', minimum: 0, maximum: 65535 },
181
+ rdlength: { type: 'integer', label: 'Data Length', readOnly: true, minimum: 0, maximum: 65535 },
182
182
  rdata: { type: 'string', label: 'Data', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
183
183
  }
184
184
  },
@@ -74,6 +74,7 @@ class DTLS extends BaseHeader_1.BaseHeader {
74
74
  sequenceNumber: this.fieldHex('sequenceNumber', 5, 6, 'Sequence Number'),
75
75
  length: {
76
76
  type: 'integer',
77
+ autoCalculated: true,
77
78
  label: 'Length',
78
79
  minimum: 0,
79
80
  maximum: 65535,
@@ -68,6 +68,7 @@ class Diameter extends BaseHeader_1.BaseHeader {
68
68
  version: this.fieldUInt('version', 0, 1, 'Version'),
69
69
  messageLength: {
70
70
  type: 'integer',
71
+ autoCalculated: true,
71
72
  label: 'Message Length',
72
73
  minimum: 0,
73
74
  maximum: 16777215,
@@ -129,10 +130,10 @@ class Diameter extends BaseHeader_1.BaseHeader {
129
130
  properties: {
130
131
  code: { type: 'integer', label: 'AVP Code', minimum: 0, maximum: 4294967295 },
131
132
  flags: { type: 'integer', label: 'AVP Flags', minimum: 0, maximum: 255 },
132
- length: { type: 'integer', label: 'AVP Length', minimum: 0, maximum: 16777215 },
133
+ length: { type: 'integer', label: 'AVP Length', autoCalculated: true, minimum: 0, maximum: 16777215 },
133
134
  vendorId: { type: 'integer', label: 'Vendor-Id', minimum: 0, maximum: 4294967295 },
134
135
  data: { type: 'string', label: 'Data', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX },
135
- padding: { type: 'string', label: 'Padding', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
136
+ padding: { type: 'string', label: 'Padding', autoCalculated: true, contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
136
137
  }
137
138
  },
138
139
  decode: function () {
@@ -52,7 +52,6 @@ class EAPOL extends BaseHeader_1.BaseHeader {
52
52
  label: 'Packet Type',
53
53
  minimum: 0,
54
54
  maximum: 255,
55
- enum: [0, 1, 2, 3, 4],
56
55
  decode: function () {
57
56
  this.instance.packetType.setValue(this.readBytes(1, 1)[0]);
58
57
  },
@@ -72,6 +71,7 @@ class EAPOL extends BaseHeader_1.BaseHeader {
72
71
  },
73
72
  bodyLength: {
74
73
  type: 'integer',
74
+ autoCalculated: true,
75
75
  label: 'Body Length',
76
76
  minimum: 0,
77
77
  maximum: 65535,