@netkitty/codec 1.2.0 → 2.0.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 (179) hide show
  1. package/CHANGELOG.md +170 -0
  2. package/README.md +58 -10
  3. package/README.zh-CN.md +52 -9
  4. package/dist/Codec.d.ts +3 -2
  5. package/dist/Codec.js +106 -10
  6. package/dist/abstracts/BaseHeader.d.ts +28 -2
  7. package/dist/abstracts/BaseHeader.js +132 -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 +1 -0
  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/BGP.js +1 -0
  16. package/dist/headers/Babel.js +2 -1
  17. package/dist/headers/BitTorrent.d.ts +2 -0
  18. package/dist/headers/BitTorrent.js +4 -2
  19. package/dist/headers/C37118.js +1 -0
  20. package/dist/headers/CAPWAP.js +1 -0
  21. package/dist/headers/CDP.js +1 -1
  22. package/dist/headers/CMS.js +2 -2
  23. package/dist/headers/COTP.d.ts +2 -0
  24. package/dist/headers/COTP.js +6 -1
  25. package/dist/headers/CassandraCQL.js +1 -0
  26. package/dist/headers/Codesys.js +1 -0
  27. package/dist/headers/Collectd.js +1 -1
  28. package/dist/headers/DCCP.js +1 -0
  29. package/dist/headers/DHCPFailover.js +1 -0
  30. package/dist/headers/DNS.js +3 -3
  31. package/dist/headers/DTLS.js +1 -0
  32. package/dist/headers/Diameter.js +3 -2
  33. package/dist/headers/EAPOL.js +1 -1
  34. package/dist/headers/EIGRP.js +1 -1
  35. package/dist/headers/ENIP.js +1 -0
  36. package/dist/headers/Elasticsearch.js +1 -0
  37. package/dist/headers/EtherCAT.js +1 -0
  38. package/dist/headers/EthernetII.js +6 -0
  39. package/dist/headers/FTP.js +6 -6
  40. package/dist/headers/Finger.js +3 -3
  41. package/dist/headers/FoundationFieldbusHSE.js +1 -0
  42. package/dist/headers/GELF.js +7 -1
  43. package/dist/headers/GENEVE.js +1 -1
  44. package/dist/headers/GLBP.js +1 -1
  45. package/dist/headers/GTPU.js +1 -0
  46. package/dist/headers/GTPv2C.js +1 -0
  47. package/dist/headers/GitProtocol.js +2 -2
  48. package/dist/headers/Goose.d.ts +32 -2
  49. package/dist/headers/Goose.js +116 -89
  50. package/dist/headers/Gopher.js +6 -6
  51. package/dist/headers/HARTIP.js +1 -0
  52. package/dist/headers/HSR.js +2 -0
  53. package/dist/headers/HTTP.js +6 -6
  54. package/dist/headers/HTTP2.js +1 -0
  55. package/dist/headers/ICMP.js +1 -0
  56. package/dist/headers/ICMPv6.js +1 -0
  57. package/dist/headers/IEC104_I_Frame.js +26 -3
  58. package/dist/headers/IEC104_S_Frame.js +7 -2
  59. package/dist/headers/IEC104_U_Frame.js +14 -3
  60. package/dist/headers/IEC61850SampledValues.js +2 -1
  61. package/dist/headers/IGMP.js +1 -0
  62. package/dist/headers/IMAP.js +5 -5
  63. package/dist/headers/IPFIX.js +2 -1
  64. package/dist/headers/IPv4.js +18 -1
  65. package/dist/headers/IPv6.js +1 -0
  66. package/dist/headers/IPv6HopByHopOptions.js +12 -11
  67. package/dist/headers/IRC.js +4 -4
  68. package/dist/headers/ISAKMP.js +2 -1
  69. package/dist/headers/ISCSI.js +2 -0
  70. package/dist/headers/ISIS.js +2 -1
  71. package/dist/headers/ISOSession.d.ts +2 -0
  72. package/dist/headers/ISOSession.js +14 -10
  73. package/dist/headers/Ident.js +8 -8
  74. package/dist/headers/KNXnetIP.js +1 -0
  75. package/dist/headers/Kafka.js +1 -0
  76. package/dist/headers/Kerberos.js +1 -0
  77. package/dist/headers/L2TP.js +2 -2
  78. package/dist/headers/LACP.js +1 -1
  79. package/dist/headers/LDAP.js +2 -3
  80. package/dist/headers/LDP.js +1 -0
  81. package/dist/headers/LLC.d.ts +2 -0
  82. package/dist/headers/LLC.js +2 -0
  83. package/dist/headers/LPD.js +3 -3
  84. package/dist/headers/MGCP.js +7 -7
  85. package/dist/headers/MMS.d.ts +2 -0
  86. package/dist/headers/MMS.js +10 -6
  87. package/dist/headers/MQTT.js +1 -0
  88. package/dist/headers/MQTTSN.js +1 -0
  89. package/dist/headers/MarkerProtocol.js +1 -1
  90. package/dist/headers/Megaco.js +3 -3
  91. package/dist/headers/Memcached.js +3 -2
  92. package/dist/headers/ModbusTCP.js +1 -0
  93. package/dist/headers/ModbusUDP.js +1 -0
  94. package/dist/headers/MongoDB.js +1 -0
  95. package/dist/headers/MySQL.js +1 -0
  96. package/dist/headers/NATS.js +2 -2
  97. package/dist/headers/NBDS.js +1 -0
  98. package/dist/headers/NBSS.js +1 -0
  99. package/dist/headers/NFS.js +1 -0
  100. package/dist/headers/NHRP.js +1 -0
  101. package/dist/headers/NNTP.js +6 -6
  102. package/dist/headers/NetFlowV5.js +1 -0
  103. package/dist/headers/OLSR.js +2 -1
  104. package/dist/headers/OPCUA.js +1 -0
  105. package/dist/headers/OpenFlow.js +1 -0
  106. package/dist/headers/OpenVPN.js +1 -0
  107. package/dist/headers/PCWorx.js +1 -0
  108. package/dist/headers/POP3.js +5 -5
  109. package/dist/headers/PPPoEDiscovery.js +2 -1
  110. package/dist/headers/PPPoESession.js +1 -0
  111. package/dist/headers/PPTP.js +1 -0
  112. package/dist/headers/PTP.js +1 -0
  113. package/dist/headers/PostgreSQL.js +2 -0
  114. package/dist/headers/QUIC.js +2 -0
  115. package/dist/headers/RADIUS.js +1 -0
  116. package/dist/headers/RDP.d.ts +2 -0
  117. package/dist/headers/RDP.js +4 -1
  118. package/dist/headers/RFB.js +4 -4
  119. package/dist/headers/RGoose.js +6 -1
  120. package/dist/headers/RSVP.js +3 -2
  121. package/dist/headers/RTCP.js +1 -0
  122. package/dist/headers/RTP.js +2 -1
  123. package/dist/headers/RTPS.d.ts +2 -0
  124. package/dist/headers/RTPS.js +4 -1
  125. package/dist/headers/RTSP.js +7 -7
  126. package/dist/headers/RawData.js +1 -1
  127. package/dist/headers/Redis.js +4 -4
  128. package/dist/headers/Rlogin.js +5 -5
  129. package/dist/headers/Rsync.js +2 -2
  130. package/dist/headers/S7comm.d.ts +2 -0
  131. package/dist/headers/S7comm.js +5 -1
  132. package/dist/headers/SCTP.js +2 -2
  133. package/dist/headers/SFlow.js +2 -1
  134. package/dist/headers/SIP.js +6 -6
  135. package/dist/headers/SLMP.js +1 -0
  136. package/dist/headers/SLP.js +2 -0
  137. package/dist/headers/SLPv1.js +1 -0
  138. package/dist/headers/SMB1.js +1 -0
  139. package/dist/headers/SMB2.js +1 -0
  140. package/dist/headers/SMPP.js +1 -0
  141. package/dist/headers/SMTP.js +6 -6
  142. package/dist/headers/SNAP.js +18 -5
  143. package/dist/headers/SNMP.js +4 -4
  144. package/dist/headers/SOCKS4.js +11 -5
  145. package/dist/headers/SSDP.js +7 -7
  146. package/dist/headers/SSH.js +5 -4
  147. package/dist/headers/STOMP.js +5 -5
  148. package/dist/headers/STUN.js +2 -0
  149. package/dist/headers/Skinny.js +1 -0
  150. package/dist/headers/StatsD.js +4 -4
  151. package/dist/headers/SunRPC.js +1 -0
  152. package/dist/headers/Syslog.js +2 -2
  153. package/dist/headers/TCP.js +18 -6
  154. package/dist/headers/TLS_Alert.js +23 -11
  155. package/dist/headers/TLS_ApplicationData.js +9 -4
  156. package/dist/headers/TLS_ChangeCipherSpec.js +10 -5
  157. package/dist/headers/TLS_Handshake.js +41 -26
  158. package/dist/headers/TLS_Heartbeat.js +10 -1
  159. package/dist/headers/TPKT.js +3 -1
  160. package/dist/headers/TacacsPlus.js +1 -0
  161. package/dist/headers/Telnet.js +2 -1
  162. package/dist/headers/Teredo.js +2 -2
  163. package/dist/headers/UDP.js +8 -0
  164. package/dist/headers/VLAN_802dot1Q.js +7 -0
  165. package/dist/headers/WCCP.js +1 -0
  166. package/dist/headers/WHOIS.js +3 -3
  167. package/dist/headers/WSDiscovery.js +2 -2
  168. package/dist/headers/XMPP.js +3 -3
  169. package/dist/headers/Zabbix.js +1 -0
  170. package/dist/index.d.ts +3 -3
  171. package/dist/lib/SchemaValidator.d.ts +31 -0
  172. package/dist/lib/SchemaValidator.js +137 -0
  173. package/dist/schema/ProtocolFieldJSONSchema.d.ts +4 -1
  174. package/dist/schema/ProtocolJSONSchema.d.ts +1 -1
  175. package/dist/types/CodecErrorInfo.d.ts +11 -0
  176. package/dist/types/LayerGraph.d.ts +14 -1
  177. package/package.json +2 -2
  178. package/dist/lib/GetBERIntegerLengthFromBuffer.d.ts +0 -6
  179. package/dist/lib/GetBERIntegerLengthFromBuffer.js +0 -16
@@ -36,6 +36,7 @@ class IEC61850SampledValues extends BaseHeader_1.BaseHeader {
36
36
  },
37
37
  length: {
38
38
  type: 'integer',
39
+ autoCalculated: true,
39
40
  label: 'Length',
40
41
  decode: () => {
41
42
  this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(2, 2)));
@@ -152,7 +153,7 @@ class IEC61850SampledValues extends BaseHeader_1.BaseHeader {
152
153
  properties: {
153
154
  noASDU: {
154
155
  type: 'integer',
155
- minimum: 1,
156
+ minimum: 0,
156
157
  maximum: 65535,
157
158
  label: 'Number of ASDU',
158
159
  decode: () => {
@@ -137,6 +137,7 @@ class IGMP extends BaseHeader_1.BaseHeader {
137
137
  },
138
138
  numSources: {
139
139
  type: 'integer',
140
+ autoCalculated: true,
140
141
  label: 'Number of Sources',
141
142
  minimum: 0,
142
143
  maximum: 65535,
@@ -149,11 +149,11 @@ class IMAP extends BaseHeader_1.BaseHeader {
149
149
  //message field above, never read back). kind distinguishes the four line shapes; tag is the
150
150
  //command/response tag (empty for untagged/continuation); command/status/text describe the
151
151
  //recognized tokens.
152
- kind: { type: 'string', label: 'Kind' },
153
- tag: { type: 'string', label: 'Tag' },
154
- command: { type: 'string', label: 'Command' },
155
- status: { type: 'string', label: 'Status' },
156
- text: { type: 'string', label: 'Text' }
152
+ kind: { type: 'string', label: 'Kind', readOnly: true },
153
+ tag: { type: 'string', label: 'Tag', readOnly: true },
154
+ command: { type: 'string', label: 'Command', readOnly: true },
155
+ status: { type: 'string', label: 'Status', readOnly: true },
156
+ text: { type: 'string', label: 'Text', readOnly: true }
157
157
  }
158
158
  };
159
159
  }
@@ -47,6 +47,7 @@ class IPFIX extends BaseHeader_1.BaseHeader {
47
47
  version: this.fieldUInt('version', 0, 2, 'Version'),
48
48
  length: {
49
49
  type: 'integer',
50
+ autoCalculated: true,
50
51
  label: 'Length',
51
52
  minimum: 0,
52
53
  maximum: 65535,
@@ -85,7 +86,7 @@ class IPFIX extends BaseHeader_1.BaseHeader {
85
86
  label: 'Set',
86
87
  properties: {
87
88
  setId: { type: 'integer', label: 'Set ID', minimum: 0, maximum: 65535 },
88
- setLength: { type: 'integer', label: 'Set Length', minimum: 0, maximum: 65535 },
89
+ setLength: { type: 'integer', label: 'Set Length', autoCalculated: true, minimum: 0, maximum: 65535 },
89
90
  body: { type: 'string', label: 'Body', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
90
91
  }
91
92
  },
@@ -77,14 +77,19 @@ class IPv4 extends BaseHeader_1.BaseHeader {
77
77
  },
78
78
  hdrLen: {
79
79
  type: 'integer',
80
+ autoCalculated: true,
80
81
  label: 'Header Length',
81
- minimum: 20,
82
+ //The field floor (IHL 0), not the protocol minimum of 20: a decoded malformed header (IHL
83
+ //1–4) must re-encode. 0 means "compute"; a value below 20 is written as given, flagged.
84
+ minimum: 0,
82
85
  maximum: 60,
83
86
  decode: function () {
84
87
  this.instance.hdrLen.setValue(this.readBits(0, 1, 4, 4) * 4);
85
88
  },
86
89
  encode: function () {
87
90
  let headerLength = this.instance.hdrLen.getValue(0);
91
+ if (headerLength && headerLength < 20)
92
+ this.recordError(this.instance.hdrLen.getPath(), 'Header length should be at least 20');
88
93
  if (headerLength)
89
94
  headerLength = headerLength ? Math.floor(headerLength / 4) : 0;
90
95
  this.writeBits(0, 1, 4, 4, headerLength);
@@ -129,6 +134,7 @@ class IPv4 extends BaseHeader_1.BaseHeader {
129
134
  },
130
135
  length: {
131
136
  type: 'integer',
137
+ autoCalculated: true,
132
138
  label: 'Total Length',
133
139
  minimum: 0,
134
140
  maximum: 65535,
@@ -261,6 +267,7 @@ class IPv4 extends BaseHeader_1.BaseHeader {
261
267
  },
262
268
  checksum: {
263
269
  type: 'integer',
270
+ autoCalculated: true,
264
271
  label: 'Header Checksum',
265
272
  minimum: 0,
266
273
  maximum: 65535,
@@ -320,6 +327,7 @@ class IPv4 extends BaseHeader_1.BaseHeader {
320
327
  },
321
328
  options: {
322
329
  type: 'string',
330
+ byteAlignment: 4,
323
331
  label: 'Options',
324
332
  minLength: 0,
325
333
  maxLength: 40 * 2,
@@ -352,6 +360,15 @@ class IPv4 extends BaseHeader_1.BaseHeader {
352
360
  match() {
353
361
  if (!this.prevCodecModule)
354
362
  return false;
363
+ //A header these fields cannot reproduce is left to raw (byte-exact) instead: IHL 0 — the encode
364
+ //"compute" sentinel, so it would come back as 5 — or fewer bytes than the header (20, or IHL×4),
365
+ //since encode always writes a whole header. IHL 1–4 is kept (it re-encodes as given).
366
+ const available = this.packet.length - this.startPos;
367
+ if (available < 20)
368
+ return false;
369
+ const ihl = this.readBytes(0, 1, true)[0] & 0x0f;
370
+ if (ihl === 0 || available < ihl * 4)
371
+ return false;
355
372
  //Normal path (unchanged): a parent that demuxed to IPv4 via its etherType field.
356
373
  if (this.prevCodecModule.instance.etherType.getValue() === (0, NumberToHex_1.UInt16ToHex)(0x0800))
357
374
  return true;
@@ -94,6 +94,7 @@ class IPv6 extends BaseHeader_1.BaseHeader {
94
94
  },
95
95
  plen: {
96
96
  type: 'integer',
97
+ autoCalculated: true,
97
98
  label: 'Payload Length',
98
99
  minimum: 0,
99
100
  maximum: 65535,
@@ -60,6 +60,7 @@ class IPv6HopByHopOptions extends BaseHeader_1.BaseHeader {
60
60
  },
61
61
  len: {
62
62
  type: 'integer',
63
+ autoCalculated: true,
63
64
  label: 'Length',
64
65
  minimum: 0,
65
66
  maximum: 255,
@@ -376,68 +377,68 @@ class IPv6HopByHopOptions extends BaseHeader_1.BaseHeader {
376
377
  case Type.PadN:
377
378
  {
378
379
  const typedItem = { ...item };
379
- parts.push(tlvBytes(new node_tlv_1.default(0x01, Buffer.alloc(typedItem.n, 0))));
380
+ parts.push(tlvBytes(new node_tlv_1.default(0x01, Buffer.alloc(typedItem.n ?? 0, 0))));
380
381
  }
381
382
  break;
382
383
  case Type.Tunnel_Encapsulation_Limit:
383
384
  {
384
385
  const typedItem = { ...item };
385
- parts.push(tlvBytes(new node_tlv_1.default(0x04, (0, NumberToBuffer_1.UInt8ToBuffer)(typedItem.limit))));
386
+ parts.push(tlvBytes(new node_tlv_1.default(0x04, (0, NumberToBuffer_1.UInt8ToBuffer)(typedItem.limit ?? 0))));
386
387
  }
387
388
  break;
388
389
  case Type.Router_Alert:
389
390
  {
390
391
  const typedItem = { ...item };
391
- parts.push(tlvBytes(new node_tlv_1.default(0x05, (0, NumberToBuffer_1.UInt16ToBuffer)((0, HexToNumber_1.HexToUInt16)(typedItem.alert)))));
392
+ parts.push(tlvBytes(new node_tlv_1.default(0x05, (0, NumberToBuffer_1.UInt16ToBuffer)((0, HexToNumber_1.HexToUInt16)(typedItem.alert ?? '0000')))));
392
393
  }
393
394
  break;
394
395
  case Type.CALIPSO:
395
396
  {
396
397
  const typedItem = { ...item };
397
- parts.push(tlvBytes(new node_tlv_1.default(0x07, (0, NumberToBuffer_1.UInt64ToBuffer)((0, HexToNumber_1.HexToUInt64)(typedItem.tag)))));
398
+ parts.push(tlvBytes(new node_tlv_1.default(0x07, (0, NumberToBuffer_1.UInt64ToBuffer)((0, HexToNumber_1.HexToUInt64)(typedItem.tag ?? '0000000000000000')))));
398
399
  }
399
400
  break;
400
401
  case Type.SMF_DPD:
401
402
  {
402
403
  const typedItem = { ...item };
403
- parts.push(tlvBytes(new node_tlv_1.default(0x08, Buffer.from(typedItem.hash, 'hex'))));
404
+ parts.push(tlvBytes(new node_tlv_1.default(0x08, Buffer.from(typedItem.hash ?? '', 'hex'))));
404
405
  }
405
406
  break;
406
407
  case Type.MPL_Option:
407
408
  {
408
409
  const typedItem = { ...item };
409
- parts.push(tlvBytes(new node_tlv_1.default(0x0B, Buffer.from(typedItem.value, 'hex'))));
410
+ parts.push(tlvBytes(new node_tlv_1.default(0x0B, Buffer.from(typedItem.value ?? '', 'hex'))));
410
411
  }
411
412
  break;
412
413
  case Type.ILNP_Nonce:
413
414
  {
414
415
  const typedItem = { ...item };
415
- parts.push(tlvBytes(new node_tlv_1.default(0x0C, Buffer.from(typedItem.nonce.padStart(12, '0'), 'hex'))));
416
+ parts.push(tlvBytes(new node_tlv_1.default(0x0C, Buffer.from((typedItem.nonce ?? '').padStart(12, '0'), 'hex'))));
416
417
  }
417
418
  break;
418
419
  case Type.Line_Identification_Option:
419
420
  {
420
421
  const typedItem = { ...item };
421
- parts.push(tlvBytes(new node_tlv_1.default(0x0D, (0, NumberToBuffer_1.UInt32ToBuffer)((0, HexToNumber_1.HexToUInt32)(typedItem.id)))));
422
+ parts.push(tlvBytes(new node_tlv_1.default(0x0D, (0, NumberToBuffer_1.UInt32ToBuffer)((0, HexToNumber_1.HexToUInt32)(typedItem.id ?? '00000000')))));
422
423
  }
423
424
  break;
424
425
  case Type.IPv6_DFF_Header:
425
426
  {
426
427
  const typedItem = { ...item };
427
- parts.push(tlvBytes(new node_tlv_1.default(0x1E, Buffer.from(typedItem.message, 'hex'))));
428
+ parts.push(tlvBytes(new node_tlv_1.default(0x1E, Buffer.from(typedItem.message ?? '', 'hex'))));
428
429
  }
429
430
  break;
430
431
  case Type.Endpoint_Identification:
431
432
  {
432
433
  const typedItem = { ...item };
433
- parts.push(tlvBytes(new node_tlv_1.default(0x8A, Buffer.from(typedItem.id.padStart(32, '0'), 'hex'))));
434
+ parts.push(tlvBytes(new node_tlv_1.default(0x8A, Buffer.from((typedItem.id ?? '').padStart(32, '0'), 'hex'))));
434
435
  }
435
436
  break;
436
437
  default: {
437
438
  if (typeof item.type !== 'number')
438
439
  return;
439
440
  const customItem = { ...item };
440
- parts.push(tlvBytes(new node_tlv_1.default(customItem.type, Buffer.from(customItem.data, 'hex'))));
441
+ parts.push(tlvBytes(new node_tlv_1.default(customItem.type, Buffer.from(customItem.data ?? '', 'hex'))));
441
442
  }
442
443
  }
443
444
  });
@@ -134,10 +134,10 @@ class IRC extends BaseHeader_1.BaseHeader {
134
134
  //message field above, never read back). prefix is the optional message source; command is
135
135
  //the verb word or numeric reply code; params is the remainder (including any :trailing);
136
136
  //isNumeric marks a 3-digit numeric reply.
137
- prefix: { type: 'string', label: 'Prefix' },
138
- command: { type: 'string', label: 'Command' },
139
- params: { type: 'string', label: 'Params' },
140
- isNumeric: { type: 'boolean', label: 'Is Numeric' }
137
+ prefix: { type: 'string', label: 'Prefix', readOnly: true },
138
+ command: { type: 'string', label: 'Command', readOnly: true },
139
+ params: { type: 'string', label: 'Params', readOnly: true },
140
+ isNumeric: { type: 'boolean', label: 'Is Numeric', readOnly: true }
141
141
  }
142
142
  };
143
143
  }
@@ -85,6 +85,7 @@ class ISAKMP extends BaseHeader_1.BaseHeader {
85
85
  messageId: this.fieldUInt('messageId', 20, 4, 'Message ID'),
86
86
  length: {
87
87
  type: 'integer',
88
+ autoCalculated: true,
88
89
  label: 'Length',
89
90
  minimum: 0,
90
91
  maximum: 4294967295,
@@ -119,7 +120,7 @@ class ISAKMP extends BaseHeader_1.BaseHeader {
119
120
  nextPayload: { type: 'integer', label: 'Next Payload', minimum: 0, maximum: 255 },
120
121
  critical: { type: 'boolean', label: 'Critical' },
121
122
  reserved: { type: 'integer', label: 'Reserved', minimum: 0, maximum: 127, hidden: true },
122
- payloadLength: { type: 'integer', label: 'Payload Length', minimum: 0, maximum: 65535 },
123
+ payloadLength: { type: 'integer', label: 'Payload Length', autoCalculated: true, minimum: 0, maximum: 65535 },
123
124
  body: { type: 'string', label: 'Body', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
124
125
  }
125
126
  },
@@ -181,6 +181,7 @@ class ISCSI extends BaseHeader_1.BaseHeader {
181
181
  //derived from the actual data segment length.
182
182
  dataSegmentLength: {
183
183
  type: 'integer',
184
+ autoCalculated: true,
184
185
  label: 'Data Segment Length',
185
186
  minimum: 0,
186
187
  maximum: 16777215,
@@ -244,6 +245,7 @@ class ISCSI extends BaseHeader_1.BaseHeader {
244
245
  //TCP payload so a lying DataSegmentLength can't read past the datagram.
245
246
  dataSegment: {
246
247
  type: 'string',
248
+ byteAlignment: 4,
247
249
  label: 'Data Segment',
248
250
  minLength: 0,
249
251
  contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
@@ -36,7 +36,8 @@ class ISIS extends BaseHeader_1.BaseHeader {
36
36
  type: 'object',
37
37
  summary: 'IS-IS type=${pduType}',
38
38
  properties: {
39
- irpDiscriminator: this.fieldHex('irpDiscriminator', 0, 1, 'IRP Discriminator'),
39
+ //Default 0x83: the IS-IS Intradomain Routeing Protocol Discriminator match() requires.
40
+ irpDiscriminator: { ...this.fieldHex('irpDiscriminator', 0, 1, 'IRP Discriminator'), default: '83' },
40
41
  lengthIndicator: this.fieldUInt('lengthIndicator', 1, 1, 'Length Indicator'),
41
42
  versionProtocolIdExtension: this.fieldUInt('versionProtocolIdExtension', 2, 1, 'Version/Protocol Id Extension'),
42
43
  idLength: this.fieldUInt('idLength', 3, 1, 'ID Length'),
@@ -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
  /**
@@ -21,6 +22,7 @@ export declare class ISOSession extends BaseHeader {
21
22
  readonly name: string;
22
23
  readonly nickname: string;
23
24
  readonly matchKeys: string[];
25
+ readonly heuristicParents: HeuristicParent[];
24
26
  readonly heuristicFallback: boolean;
25
27
  match(): boolean;
26
28
  readonly demuxProducers: DemuxProducer[];
@@ -25,6 +25,8 @@ class ISOSession extends BaseHeader_1.BaseHeader {
25
25
  this.nickname = 'ISO-SES';
26
26
  //A content-heuristic child of COTP (unkeyed), selected by a session SI at the start of the COTP payload.
27
27
  this.matchKeys = [];
28
+ //Editor graph: matched by content, so list it under these parents in allowedNextLayers().
29
+ this.heuristicParents = [{ parent: 'cotp', discriminator: { field: 'pduType', value: 0xf0 } }];
28
30
  this.heuristicFallback = true;
29
31
  //The Presentation/MMS PDU follows as a child — nothing demuxes off Session by a field value.
30
32
  this.demuxProducers = [];
@@ -223,11 +225,13 @@ class ISOSession extends BaseHeader_1.BaseHeader {
223
225
  spdus: {
224
226
  type: 'array',
225
227
  label: 'SPDUs',
228
+ //Default: Give Tokens + Data Transfer, the SPDU pair that carries MMS/ACSE data.
229
+ default: [{ si: 1, li: 0, params: '' }, { si: 1, li: 0, params: '' }],
226
230
  items: {
227
231
  type: 'object',
228
232
  properties: {
229
233
  si: { type: 'integer', label: 'SPDU Identifier', minimum: 0, maximum: 255 },
230
- li: { type: 'integer', label: 'Length Indicator', minimum: 0, maximum: 255 },
234
+ li: { type: 'integer', label: 'Length Indicator', autoCalculated: true, minimum: 0, maximum: 255 },
231
235
  params: { type: 'string', label: 'Parameters', contentEncoding: 'hex' }
232
236
  }
233
237
  },
@@ -319,15 +323,15 @@ class ISOSession extends BaseHeader_1.BaseHeader {
319
323
  //Display-only: the ACSE APDU type (AARQ/AARE/…) and application-context-name OID parsed from
320
324
  //a CONNECT/ACCEPT SPDU's user data on decode. No encode closure — the SPDU params above stay
321
325
  //the encode authority.
322
- acseType: { type: 'string', label: 'ACSE APDU' },
323
- acseAppContext: { type: 'string', label: 'ACSE Application Context' },
324
- acseCalledApTitle: { type: 'string', label: 'ACSE Called AP-Title' },
325
- acseCallingApTitle: { type: 'string', label: 'ACSE Calling AP-Title' },
326
- acseRespondingApTitle: { type: 'string', label: 'ACSE Responding AP-Title' },
327
- mmsInitMaxServOutstandingCalling: { type: 'integer', label: 'MMS Init Max Serv Outstanding Calling' },
328
- mmsInitMaxServOutstandingCalled: { type: 'integer', label: 'MMS Init Max Serv Outstanding Called' },
329
- mmsInitNestingLevel: { type: 'integer', label: 'MMS Init Data Structure Nesting Level' },
330
- mmsInitVersion: { type: 'integer', label: 'MMS Init Version' }
326
+ acseType: { type: 'string', label: 'ACSE APDU', readOnly: true },
327
+ acseAppContext: { type: 'string', label: 'ACSE Application Context', readOnly: true },
328
+ acseCalledApTitle: { type: 'string', label: 'ACSE Called AP-Title', readOnly: true },
329
+ acseCallingApTitle: { type: 'string', label: 'ACSE Calling AP-Title', readOnly: true },
330
+ acseRespondingApTitle: { type: 'string', label: 'ACSE Responding AP-Title', readOnly: true },
331
+ mmsInitMaxServOutstandingCalling: { type: 'integer', label: 'MMS Init Max Serv Outstanding Calling', readOnly: true },
332
+ mmsInitMaxServOutstandingCalled: { type: 'integer', label: 'MMS Init Max Serv Outstanding Called', readOnly: true },
333
+ mmsInitNestingLevel: { type: 'integer', label: 'MMS Init Data Structure Nesting Level', readOnly: true },
334
+ mmsInitVersion: { type: 'integer', label: 'MMS Init Version', readOnly: true }
331
335
  }
332
336
  };
333
337
  }
@@ -133,15 +133,15 @@ class Ident extends BaseHeader_1.BaseHeader {
133
133
  //`message` field below, never read back). isQuery distinguishes the client query from the
134
134
  //server reply; responseType/opsys/userId apply to a USERID reply, errorType to an ERROR
135
135
  //reply. The two ports are present in both directions.
136
- serverPort: { type: 'integer', label: 'Server Port', minimum: 0, maximum: 65535, default: 0 },
137
- clientPort: { type: 'integer', label: 'Client Port', minimum: 0, maximum: 65535, default: 0 },
138
- isQuery: { type: 'boolean', label: 'Is Query', default: false },
139
- responseType: { type: 'string', label: 'Response Type', default: '' },
140
- opsys: { type: 'string', label: 'Operating System', default: '' },
141
- userId: { type: 'string', label: 'User ID', default: '' },
142
- errorType: { type: 'string', label: 'Error Type', default: '' },
136
+ serverPort: { type: 'integer', label: 'Server Port', readOnly: true, minimum: 0, maximum: 65535, default: 0 },
137
+ clientPort: { type: 'integer', label: 'Client Port', readOnly: true, minimum: 0, maximum: 65535, default: 0 },
138
+ isQuery: { type: 'boolean', label: 'Is Query', readOnly: true, default: false },
139
+ responseType: { type: 'string', label: 'Response Type', readOnly: true, default: '' },
140
+ opsys: { type: 'string', label: 'Operating System', readOnly: true, default: '' },
141
+ userId: { type: 'string', label: 'User ID', readOnly: true, default: '' },
142
+ errorType: { type: 'string', label: 'Error Type', readOnly: true, default: '' },
143
143
  //Drives the one-line summary (query ports / USERID username / ERROR error-type).
144
- summaryInfo: { type: 'string', label: 'Summary', hidden: true, default: '' },
144
+ summaryInfo: { type: 'string', label: 'Summary', readOnly: true, hidden: true, default: '' },
145
145
  //The whole raw payload is the single source of truth: decoded verbatim to hex and
146
146
  //re-emitted untouched (byte-perfect for any Ident payload). The first line is parsed into
147
147
  //the display-only metadata above, which carry no codec of their own.
@@ -74,6 +74,7 @@ class KNXnetIP extends BaseHeader_1.BaseHeader {
74
74
  serviceType: this.fieldUInt('serviceType', 2, 2, 'Service Type'),
75
75
  totalLength: {
76
76
  type: 'integer',
77
+ autoCalculated: true,
77
78
  label: 'Total Length',
78
79
  //minimum 0 (not 6): a crafted/corrupt frame may carry a Total Length below the 6-byte
79
80
  //header, and that value must round-trip (honored verbatim) rather than be rejected by
@@ -56,6 +56,7 @@ class Kafka extends BaseHeader_1.BaseHeader {
56
56
  //as 8 (the fixed apiKey + apiVersion + correlationId header) + payload bytes.
57
57
  messageSize: {
58
58
  type: 'integer',
59
+ autoCalculated: true,
59
60
  label: 'Message Size',
60
61
  minimum: 0,
61
62
  maximum: 4294967295,
@@ -94,6 +94,7 @@ class Kerberos extends BaseHeader_1.BaseHeader {
94
94
  //lie); else derived at self-post-encode time as the encoded message length.
95
95
  recordLength: {
96
96
  type: 'integer',
97
+ autoCalculated: true,
97
98
  label: 'Record Length',
98
99
  minimum: 0,
99
100
  maximum: 4294967295,
@@ -102,12 +102,12 @@ class L2TP extends BaseHeader_1.BaseHeader {
102
102
  }
103
103
  }
104
104
  },
105
- length: { type: 'integer', label: 'Length', minimum: 0, maximum: 65535 },
105
+ length: { type: 'integer', label: 'Length', autoCalculated: true, minimum: 0, maximum: 65535 },
106
106
  tunnelId: { type: 'integer', label: 'Tunnel ID', minimum: 0, maximum: 65535 },
107
107
  sessionId: { type: 'integer', label: 'Session ID', minimum: 0, maximum: 65535 },
108
108
  ns: { type: 'integer', label: 'Ns', minimum: 0, maximum: 65535 },
109
109
  nr: { type: 'integer', label: 'Nr', minimum: 0, maximum: 65535 },
110
- offsetSize: { type: 'integer', label: 'Offset Size', minimum: 0, maximum: 65535 },
110
+ offsetSize: { type: 'integer', label: 'Offset Size', autoCalculated: true, minimum: 0, maximum: 65535 },
111
111
  offsetPad: { type: 'string', label: 'Offset Pad', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX, hidden: true },
112
112
  avps: {
113
113
  type: 'array',
@@ -54,7 +54,7 @@ class LACP extends BaseHeader_1.BaseHeader {
54
54
  label: 'TLV',
55
55
  properties: {
56
56
  type: { type: 'integer', label: 'Type', minimum: 0, maximum: 255 },
57
- length: { type: 'integer', label: 'Length', minimum: 0, maximum: 255 },
57
+ length: { type: 'integer', label: 'Length', autoCalculated: true, minimum: 0, maximum: 255 },
58
58
  value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
59
59
  }
60
60
  },
@@ -147,9 +147,8 @@ class LDAP extends BaseHeader_1.BaseHeader {
147
147
  //A real LDAP messageID is 0..maxInt, but the on-wire field is a signed BER INTEGER, so a
148
148
  //malformed frame can carry a negative value. The bounds match the signed 32-bit range the
149
149
  //#berInt/#intToBer helpers support, so decode of a malformed negative messageID re-encodes
150
- //faithfully instead of tripping the encode-entry Ajv gate (keeping decode→encode total).
151
- minimum: -2147483648,
152
- maximum: 2147483647,
150
+ //faithfully instead of tripping the encode-entry Ajv gate (keeping decode→encode total). A
151
+ //longer INTEGER can decode too (to a large number), so no bounds at all.
153
152
  decode: function () {
154
153
  const available = this.packet.length - this.startPos;
155
154
  if (available <= 0)
@@ -66,6 +66,7 @@ class LDP extends BaseHeader_1.BaseHeader {
66
66
  version: this.fieldUInt('version', 0, 2, 'Version'),
67
67
  pduLength: {
68
68
  type: 'integer',
69
+ autoCalculated: true,
69
70
  label: 'PDU Length',
70
71
  minimum: 0,
71
72
  maximum: 65535,
@@ -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
  /**
@@ -22,6 +23,7 @@ export declare class LLC extends BaseHeader {
22
23
  readonly name: string;
23
24
  readonly nickname: string;
24
25
  readonly matchKeys: string[];
26
+ readonly heuristicParents: HeuristicParent[];
25
27
  readonly demuxProducers: DemuxProducer[];
26
28
  match(): boolean;
27
29
  }
@@ -28,6 +28,8 @@ class LLC extends BaseHeader_1.BaseHeader {
28
28
  //A content-heuristic child (no matchKeys) — claimed when the Ethernet/VLAN parent's EtherType is a
29
29
  //length (≤ 0x05DC), which cannot be a real EtherType.
30
30
  this.matchKeys = [];
31
+ //Editor graph: matched by content, so list it under these parents in allowedNextLayers().
32
+ this.heuristicParents = ['eth', 'vlan'];
31
33
  this.demuxProducers = [{ field: 'dsap', namespace: 'llcsap', kind: 'uint' }];
32
34
  }
33
35
  static #schemaCache;
@@ -121,9 +121,9 @@ class LPD extends BaseHeader_1.BaseHeader {
121
121
  //Display-only metadata parsed from the payload on decode (no encode — populated by the
122
122
  //message field above, never read back). command is the 1-byte code, commandName its
123
123
  //RFC 1179 label, operands the ASCII operand line up to the first line feed.
124
- command: { type: 'integer', label: 'Command', minimum: 0, maximum: 255 },
125
- commandName: { type: 'string', label: 'Command Name' },
126
- operands: { type: 'string', label: 'Operands' }
124
+ command: { type: 'integer', label: 'Command', readOnly: true, minimum: 0, maximum: 255 },
125
+ commandName: { type: 'string', label: 'Command Name', readOnly: true },
126
+ operands: { type: 'string', label: 'Operands', readOnly: true }
127
127
  }
128
128
  };
129
129
  }
@@ -119,13 +119,13 @@ class MGCP extends BaseHeader_1.BaseHeader {
119
119
  //Display-only metadata parsed from the first line on decode (no encode — populated by the
120
120
  //message field above, never read back). isResponse distinguishes a response line from a
121
121
  //command line; verb/endpoint/version are for commands, responseCode/comment for responses.
122
- isResponse: { type: 'boolean', label: 'Is Response' },
123
- verb: { type: 'string', label: 'Verb' },
124
- transactionId: { type: 'string', label: 'Transaction ID' },
125
- endpoint: { type: 'string', label: 'Endpoint' },
126
- version: { type: 'string', label: 'Version' },
127
- responseCode: { type: 'integer', label: 'Response Code', minimum: 0, maximum: 999 },
128
- comment: { type: 'string', label: 'Comment' }
122
+ isResponse: { type: 'boolean', label: 'Is Response', readOnly: true },
123
+ verb: { type: 'string', label: 'Verb', readOnly: true },
124
+ transactionId: { type: 'string', label: 'Transaction ID', readOnly: true },
125
+ endpoint: { type: 'string', label: 'Endpoint', readOnly: true },
126
+ version: { type: 'string', label: 'Version', readOnly: true },
127
+ responseCode: { type: 'integer', label: 'Response Code', readOnly: true, minimum: 0, maximum: 999 },
128
+ comment: { type: 'string', label: 'Comment', readOnly: true }
129
129
  }
130
130
  };
131
131
  }
@@ -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
  /**
@@ -23,6 +24,7 @@ export declare class MMS extends BaseHeader {
23
24
  readonly name: string;
24
25
  readonly nickname: string;
25
26
  readonly matchKeys: string[];
27
+ readonly heuristicParents: HeuristicParent[];
26
28
  readonly heuristicFallback: boolean;
27
29
  match(): boolean;
28
30
  readonly demuxProducers: DemuxProducer[];
@@ -28,6 +28,8 @@ class MMS extends BaseHeader_1.BaseHeader {
28
28
  //A content-heuristic child of ISO Session (unkeyed), selected by the Presentation fully-encoded-data
29
29
  //BER tag 0x61 (the MMS data-transfer phase).
30
30
  this.matchKeys = [];
31
+ //Editor graph: matched by content, so list it under these parents in allowedNextLayers().
32
+ this.heuristicParents = ['iso-session'];
31
33
  this.heuristicFallback = true;
32
34
  //A leaf for this slice — the MMS service body is kept verbatim inside `message`.
33
35
  this.demuxProducers = [];
@@ -199,7 +201,9 @@ class MMS extends BaseHeader_1.BaseHeader {
199
201
  //The whole Presentation + MMS BER blob is the authoritative source: decoded verbatim to hex
200
202
  //and re-emitted untouched, so any (even malformed) frame round-trips byte-for-byte.
201
203
  message: {
202
- type: 'string', label: 'Message', contentEncoding: 'hex',
204
+ //Default: an empty presentation fully-encoded-data PDU ([APPLICATION 1], 0x61), the
205
+ //form match() recognizes, so a fresh layer re-decodes as MMS.
206
+ type: 'string', label: 'Message', contentEncoding: 'hex', default: '6100',
203
207
  decode: function () {
204
208
  const available = this.packet.length - this.startPos;
205
209
  const buf = this.readBytes(0, available);
@@ -221,11 +225,11 @@ class MMS extends BaseHeader_1.BaseHeader {
221
225
  //Display-only metadata parsed from the BER blob on decode (no encode — populated by the
222
226
  //message field above), so they never affect the re-emitted bytes. invokeID / service are
223
227
  //present only for a confirmed request/response/error PDU.
224
- presentationContext: { type: 'integer', label: 'Presentation Context' },
225
- mmsPduType: { type: 'integer', label: 'MMS PDU Type' },
226
- mmsInvokeID: { type: 'integer', label: 'Invoke ID' },
227
- mmsService: { type: 'string', label: 'MMS Service' },
228
- mmsObjectNames: { type: 'array', label: 'Object Names', items: { type: 'string' } }
228
+ presentationContext: { type: 'integer', label: 'Presentation Context', readOnly: true },
229
+ mmsPduType: { type: 'integer', label: 'MMS PDU Type', readOnly: true },
230
+ mmsInvokeID: { type: 'integer', label: 'Invoke ID', readOnly: true },
231
+ mmsService: { type: 'string', label: 'MMS Service', readOnly: true },
232
+ mmsObjectNames: { type: 'array', label: 'Object Names', readOnly: true, items: { type: 'string' } }
229
233
  }
230
234
  };
231
235
  }
@@ -110,6 +110,7 @@ class MQTT extends BaseHeader_1.BaseHeader {
110
110
  //The decoded value of the Remaining Length varint (length of Variable Header + Payload).
111
111
  remainingLength: {
112
112
  type: 'integer',
113
+ autoCalculated: true,
113
114
  label: 'Remaining Length',
114
115
  minimum: 0,
115
116
  maximum: 268435455,
@@ -73,6 +73,7 @@ class MQTTSN extends BaseHeader_1.BaseHeader {
73
73
  //supplied (a crafted datagram may lie); else derived from the body byte length.
74
74
  length: {
75
75
  type: 'integer',
76
+ autoCalculated: true,
76
77
  label: 'Length',
77
78
  minimum: 0,
78
79
  maximum: 65535,
@@ -55,7 +55,7 @@ class MarkerProtocol extends BaseHeader_1.BaseHeader {
55
55
  label: 'TLV',
56
56
  properties: {
57
57
  type: { type: 'integer', label: 'Type', minimum: 0, maximum: 255 },
58
- length: { type: 'integer', label: 'Length', minimum: 0, maximum: 255 },
58
+ length: { type: 'integer', label: 'Length', autoCalculated: true, minimum: 0, maximum: 255 },
59
59
  value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
60
60
  }
61
61
  },
@@ -118,9 +118,9 @@ class Megaco extends BaseHeader_1.BaseHeader {
118
118
  //Display-only metadata parsed from the header line on decode (no encode — populated by the
119
119
  //message field above, never read back). startToken is "MEGACO" (or "!" short form),
120
120
  //version is the protocol version, messageId is the message identifier (mId).
121
- startToken: { type: 'string', label: 'Start Token' },
122
- version: { type: 'string', label: 'Version' },
123
- messageId: { type: 'string', label: 'Message Identifier' }
121
+ startToken: { type: 'string', label: 'Start Token', readOnly: true },
122
+ version: { type: 'string', label: 'Version', readOnly: true },
123
+ messageId: { type: 'string', label: 'Message Identifier', readOnly: true }
124
124
  }
125
125
  };
126
126
  }