@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
@@ -26,6 +26,8 @@ class BitTorrent extends BaseHeader_1.BaseHeader {
26
26
  //No fixed port — BitTorrent peers connect on dynamic/ephemeral ports. Selection is by the
27
27
  //content signature (0x13 + "BitTorrent protocol") via heuristicFallback + match().
28
28
  this.matchKeys = [];
29
+ //Editor graph: matched by content, so list it under these parents in allowedNextLayers().
30
+ this.heuristicParents = ['tcp'];
29
31
  this.heuristicFallback = true;
30
32
  //A leaf header — only the handshake is decoded; subsequent peer messages are left to raw.
31
33
  this.demuxProducers = [];
@@ -41,10 +43,10 @@ class BitTorrent extends BaseHeader_1.BaseHeader {
41
43
  properties: {
42
44
  //Protocol string length — always 0x13 (19) for the BEP 3 handshake. Kept as a plain uint8
43
45
  //(a crafted handshake may lie); the signature match already guards real traffic.
44
- pstrlen: this.fieldUInt('pstrlen', 0, 1, 'Protocol String Length'),
46
+ pstrlen: { ...this.fieldUInt('pstrlen', 0, 1, 'Protocol String Length'), default: 19 },
45
47
  //The 19-byte protocol identifier "BitTorrent protocol". Kept verbatim as hex so any
46
48
  //byte edit round-trips; the human-readable form is UI enrichment for later.
47
- pstr: this.fieldHex('pstr', 1, 19, 'Protocol String'),
49
+ pstr: { ...this.fieldHex('pstr', 1, 19, 'Protocol String'), default: '426974546f7272656e742070726f746f636f6c' },
48
50
  //8 reserved bytes carrying extension bit-flags (BEP 4/5/6/10: DHT, Fast, Extension
49
51
  //Protocol). Opaque here and re-emitted verbatim.
50
52
  reserved: this.fieldHex('reserved', 20, 8, 'Reserved'),
@@ -65,6 +65,7 @@ class C37118 extends BaseHeader_1.BaseHeader {
65
65
  },
66
66
  framesize: {
67
67
  type: 'integer',
68
+ autoCalculated: true,
68
69
  label: 'Frame Size',
69
70
  minimum: 0,
70
71
  maximum: 65535,
@@ -106,6 +106,7 @@ class CAPWAP extends BaseHeader_1.BaseHeader {
106
106
  //header plus the verbatim optional (headerRemainder) bytes. HLEN × 4 delimits the header.
107
107
  hlen: {
108
108
  type: 'integer',
109
+ autoCalculated: true,
109
110
  label: 'HLEN',
110
111
  minimum: 0,
111
112
  maximum: 31,
@@ -50,7 +50,7 @@ class CDP extends BaseHeader_1.BaseHeader {
50
50
  type: 'object',
51
51
  properties: {
52
52
  type: { type: 'integer', label: 'Type', minimum: 0, maximum: 65535 },
53
- length: { type: 'integer', label: 'Length', minimum: 0, maximum: 65535 },
53
+ length: { type: 'integer', label: 'Length', autoCalculated: true, minimum: 0, maximum: 65535 },
54
54
  value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
55
55
  }
56
56
  },
@@ -157,10 +157,10 @@ class CMS extends BaseHeader_1.BaseHeader {
157
157
  //(DL/T 2811 §6.10) per the Service Code. Populated on decode by the serviceData closure
158
158
  //above; it has no encode closure, so `serviceData` (hex) stays the authoritative encode
159
159
  //form and the structured view can never perturb the re-emitted bytes.
160
- serviceDataDecoded: { type: 'object', label: 'Service Data (decoded)' },
160
+ serviceDataDecoded: { type: 'object', label: 'Service Data (decoded)', readOnly: true, properties: {}, additionalProperties: true },
161
161
  //Display-only best-effort readable identifiers extracted from a service data area that has
162
162
  //no transcribed structure (the GB/T 33603 M-coded responses). No encode closure.
163
- serviceDataStrings: { type: 'array', label: 'Readable Identifiers', items: { type: 'string' } }
163
+ serviceDataStrings: { type: 'array', label: 'Readable Identifiers', readOnly: true, items: { type: 'string' } }
164
164
  }
165
165
  };
166
166
  }
@@ -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,
@@ -76,11 +79,13 @@ class COTP extends BaseHeader_1.BaseHeader {
76
79
  }
77
80
  },
78
81
  //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'),
82
+ //Default DT (0xF0) with EOT set: the TPDU that carries S7comm / ISO-Session / MMS above it.
83
+ pduType: { ...this.fieldUInt('pduType', 1, 1, 'PDU Type'), default: 0xf0 },
80
84
  //DT only: bit 7 of the octet at offset 2 — "end of TSDU". Meaningless for other types (left false).
81
85
  eot: {
82
86
  type: 'boolean',
83
87
  label: 'EOT',
88
+ default: true,
84
89
  decode: function () {
85
90
  const dt = COTP.#isDT(this.instance.pduType.getValue(0));
86
91
  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,
@@ -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
  },
@@ -108,6 +108,7 @@ class DCCP extends BaseHeader_1.BaseHeader {
108
108
  //plus the verbatim headerOptions bytes, rounded up to a word.
109
109
  dataOffset: {
110
110
  type: 'integer',
111
+ autoCalculated: true,
111
112
  label: 'Data Offset',
112
113
  minimum: 0,
113
114
  maximum: 255,
@@ -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,
@@ -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,
@@ -83,7 +83,7 @@ class EIGRP extends BaseHeader_1.BaseHeader {
83
83
  label: 'TLV',
84
84
  properties: {
85
85
  type: { type: 'integer', label: 'Type', minimum: 0, maximum: 65535 },
86
- length: { type: 'integer', label: 'Length', minimum: 0, maximum: 65535 },
86
+ length: { type: 'integer', label: 'Length', autoCalculated: true, minimum: 0, maximum: 65535 },
87
87
  value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
88
88
  }
89
89
  },
@@ -100,6 +100,7 @@ class ENIP extends BaseHeader_1.BaseHeader {
100
100
  command: this.#fieldUInt16LE('command', 0, 'Command'),
101
101
  length: {
102
102
  type: 'integer',
103
+ autoCalculated: true,
103
104
  label: 'Length',
104
105
  minimum: 0,
105
106
  maximum: 65535,
@@ -47,6 +47,7 @@ class Elasticsearch extends BaseHeader_1.BaseHeader {
47
47
  magic: this.fieldHex('magic', 0, 2, 'Magic'),
48
48
  messageLength: {
49
49
  type: 'integer',
50
+ autoCalculated: true,
50
51
  label: 'Message Length',
51
52
  //Wire field: never constrain below the true lower bound. A truncated/crafted message
52
53
  //may decode any value in [0, 0xffffffff]; keep the full uint32 range so a decoded
@@ -57,6 +57,7 @@ class EtherCAT extends BaseHeader_1.BaseHeader {
57
57
  //(so the three fields never clobber each other). reserved/type are decode-only.
58
58
  length: {
59
59
  type: 'integer',
60
+ autoCalculated: true,
60
61
  label: 'Length',
61
62
  minimum: 0,
62
63
  //The on-wire field is 11 bits (max 0x7FF); the schema bound is left wider (uint16) so an
@@ -88,6 +88,8 @@ class EthernetII extends BaseHeader_1.BaseHeader {
88
88
  this.instance.etherType.setValue(this.readBytes(12, 2).toString('hex').padStart(4, '0'));
89
89
  },
90
90
  encode: function () {
91
+ if (this.instance.etherType.isUndefined())
92
+ return this.encodeOmittedEtherType(this.instance.etherType, 12);
91
93
  const etherType = this.instance.etherType.getValue((0, NumberToHex_1.UInt16ToHex)(0x0000), (nodePath) => this.recordError(nodePath, 'Not Found'));
92
94
  const typeBuffer = Buffer.from(etherType, 'hex');
93
95
  if (typeBuffer.length < 2)
@@ -99,6 +101,10 @@ class EthernetII extends BaseHeader_1.BaseHeader {
99
101
  };
100
102
  }
101
103
  match() {
104
+ //Fewer bytes than the 14-octet header cannot be reproduced by these fields (encode always writes
105
+ //a whole header): leave them to raw so they round-trip byte-exact.
106
+ if (this.packet.length - this.startPos < 14)
107
+ return false;
102
108
  if (!this.prevCodecModule)
103
109
  return true;
104
110
  //Tunnels that carry a bare Ethernet frame with no inner protocol-type field: claim their payload
@@ -126,12 +126,12 @@ class FTP extends BaseHeader_1.BaseHeader {
126
126
  //message field above, never read back). isReply distinguishes a server reply from a
127
127
  //client command; replyCode/isMultiline/replyText describe a reply, command/argument a
128
128
  //command.
129
- isReply: { type: 'boolean', label: 'Is Reply' },
130
- replyCode: { type: 'integer', label: 'Reply Code', minimum: 0, maximum: 999 },
131
- isMultiline: { type: 'boolean', label: 'Is Multiline' },
132
- replyText: { type: 'string', label: 'Reply Text' },
133
- command: { type: 'string', label: 'Command' },
134
- argument: { type: 'string', label: 'Argument' }
129
+ isReply: { type: 'boolean', label: 'Is Reply', readOnly: true },
130
+ replyCode: { type: 'integer', label: 'Reply Code', readOnly: true, minimum: 0, maximum: 999 },
131
+ isMultiline: { type: 'boolean', label: 'Is Multiline', readOnly: true },
132
+ replyText: { type: 'string', label: 'Reply Text', readOnly: true },
133
+ command: { type: 'string', label: 'Command', readOnly: true },
134
+ argument: { type: 'string', label: 'Argument', readOnly: true }
135
135
  }
136
136
  };
137
137
  }
@@ -90,10 +90,10 @@ class Finger extends BaseHeader_1.BaseHeader {
90
90
  //Display-only metadata parsed from the first line on decode (no encode — populated by the
91
91
  //`message` field below, never read back). isVerbose flags a query opening with "/W"; query
92
92
  //is the username text with the verbose switch and surrounding whitespace removed.
93
- isVerbose: { type: 'boolean', label: 'Is Verbose', default: false },
94
- query: { type: 'string', label: 'Query', default: '' },
93
+ isVerbose: { type: 'boolean', label: 'Is Verbose', readOnly: true, default: false },
94
+ query: { type: 'string', label: 'Query', readOnly: true, default: '' },
95
95
  //Drives the one-line summary: the query text, or 'list all' for the empty query.
96
- summaryInfo: { type: 'string', label: 'Summary', hidden: true, default: '' },
96
+ summaryInfo: { type: 'string', label: 'Summary', readOnly: true, hidden: true, default: '' },
97
97
  //The whole raw payload is the single source of truth: decoded verbatim to hex and re-emitted
98
98
  //untouched (byte-perfect for any Finger payload). The first line is parsed into the
99
99
  //display-only metadata above, which carry no codec of their own.
@@ -93,6 +93,7 @@ class FoundationFieldbusHSE extends BaseHeader_1.BaseHeader {
93
93
  fdaAddress: this.fieldHex('fdaAddress', 4, 4, 'FDA Address'),
94
94
  messageLength: {
95
95
  type: 'integer',
96
+ autoCalculated: true,
96
97
  label: 'Message Length',
97
98
  minimum: 0,
98
99
  maximum: 4294967295,
@@ -74,10 +74,13 @@ class GELF extends BaseHeader_1.BaseHeader {
74
74
  //Discriminant chosen at decode from the leading magic (chunked / gzip / uncompressed).
75
75
  //It writes no bytes; on encode it is honored when supplied, else inferred from which
76
76
  //form-specific fields are present (a chunk has a Message ID; a gzip form has payload).
77
- //No enum: it never gates re-encoding of a decoded value.
77
+ //A closed enum: decode only ever yields these three, and any other value would match no
78
+ //form-specific field, silently encoding an empty layer.
78
79
  form: {
79
80
  type: 'string',
81
+ autoCalculated: true,
80
82
  label: 'Form',
83
+ enum: ['chunked', 'gzip', 'uncompressed'],
81
84
  decode: function () {
82
85
  this.instance.form.setValue(this.#detectForm());
83
86
  },
@@ -91,6 +94,9 @@ class GELF extends BaseHeader_1.BaseHeader {
91
94
  else
92
95
  form = 'uncompressed';
93
96
  }
97
+ if (form !== 'chunked' && form !== 'gzip' && form !== 'uncompressed') {
98
+ this.recordError(this.instance.form.getPath(), `Unknown form '${form}', no GELF payload encoded`, 'error');
99
+ }
94
100
  this.instance.form.setValue(form);
95
101
  }
96
102
  },
@@ -58,7 +58,7 @@ class GENEVE extends BaseHeader_1.BaseHeader {
58
58
  },
59
59
  //Opt Len (options length in 4-byte units) — metadata; the value is derived from the
60
60
  //options list by the `body` master on encode and read from the wire on decode.
61
- optLen: { type: 'integer', label: 'Option Length', minimum: 0, maximum: 63 },
61
+ optLen: { type: 'integer', label: 'Option Length', readOnly: true, minimum: 0, maximum: 63 },
62
62
  oam: {
63
63
  type: 'boolean', label: 'OAM',
64
64
  decode: function () { this.instance.oam.setValue(!!this.readBits(1, 1, 0, 1)); },
@@ -70,7 +70,7 @@ class GLBP extends BaseHeader_1.BaseHeader {
70
70
  label: 'TLV',
71
71
  properties: {
72
72
  type: { type: 'integer', label: 'Type', minimum: 0, maximum: 255 },
73
- length: { type: 'integer', label: 'Length', minimum: 0, maximum: 255 },
73
+ length: { type: 'integer', label: 'Length', autoCalculated: true, minimum: 0, maximum: 255 },
74
74
  value: { type: 'string', label: 'Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX }
75
75
  }
76
76
  },
@@ -85,6 +85,7 @@ class GTPU extends BaseHeader_1.BaseHeader {
85
85
  msgType: this.fieldUInt('msgType', 1, 1, 'Message Type'),
86
86
  length: {
87
87
  type: 'integer',
88
+ autoCalculated: true,
88
89
  label: 'Length',
89
90
  minimum: 0,
90
91
  maximum: 65535,
@@ -114,6 +114,7 @@ class GTPv2C extends BaseHeader_1.BaseHeader {
114
114
  messageType: this.fieldUInt('messageType', 1, 1, 'Message Type'),
115
115
  messageLength: {
116
116
  type: 'integer',
117
+ autoCalculated: true,
117
118
  label: 'Message Length',
118
119
  minimum: 0,
119
120
  maximum: 65535,
@@ -116,8 +116,8 @@ class GitProtocol extends BaseHeader_1.BaseHeader {
116
116
  //the message field above, never read back). firstPktLineLength is the declared 4-hex-char
117
117
  //length prefix; firstCommand is the pkt-line payload up to the first NUL (the service
118
118
  //command + repository path for a request line).
119
- firstPktLineLength: { type: 'integer', label: 'First pkt-line Length', minimum: 0, maximum: 65535 },
120
- firstCommand: { type: 'string', label: 'First Command' }
119
+ firstPktLineLength: { type: 'integer', label: 'First pkt-line Length', readOnly: true, minimum: 0, maximum: 65535 },
120
+ firstCommand: { type: 'string', label: 'First Command', readOnly: true }
121
121
  }
122
122
  };
123
123
  }
@@ -36,7 +36,7 @@ type INT32DataItem = {
36
36
  };
37
37
  type INT64DataItem = {
38
38
  dataType: ItemDataType.INT64;
39
- value: bigint;
39
+ value: string;
40
40
  };
41
41
  type INT8UDataItem = {
42
42
  dataType: ItemDataType.INT8U;
@@ -99,7 +99,37 @@ export declare class Goose extends BaseHeader {
99
99
  * @param dataTLVs
100
100
  * @protected
101
101
  */
102
- protected decodeDataTLVItem(dataTLVs: TLV[]): DataItem[];
102
+ protected decodeDataTLVItem(dataTLVs: TLV[], path: string): DataItem[];
103
+ /**
104
+ * Decode a BIT STRING (tag 0x84) data item
105
+ * CODED-ENUM is 2 octets and Quality 3 octets (the leading unused-bits octet included in the
106
+ * value). A 1-octet content is still a CODED-ENUM; longer bit strings are kept as a Quality bit
107
+ * string of the full content width so no bits are lost.
108
+ * @param value
109
+ * @param path
110
+ * @protected
111
+ */
112
+ protected decodeBitStringItem(value: Buffer, path: string): DataItem;
113
+ /**
114
+ * Decode a signed BER INTEGER (tag 0x85) data item
115
+ * The content is two's complement (X.690 8.3), so a leading 00 is the sign-extension byte of a
116
+ * positive value and must be kept (00 c8 = +200). The data type is inferred from the content
117
+ * length since the minimal BER encoding carries no declared width.
118
+ * @param value
119
+ * @param path
120
+ * @protected
121
+ */
122
+ protected decodeSignedIntegerItem(value: Buffer, path: string): DataItem;
123
+ /**
124
+ * Decode an unsigned BER INTEGER (tag 0x86) data item
125
+ * A leading 00 is dropped only when it is the mandatory positive-sign pad (next byte has its high
126
+ * bit set), so fixed-width encodings keep their declared width. The data type is then inferred
127
+ * from the remaining content length.
128
+ * @param value
129
+ * @param path
130
+ * @protected
131
+ */
132
+ protected decodeUnsignedIntegerItem(value: Buffer, path: string): DataItem;
103
133
  /**
104
134
  * Encode data TLV items
105
135
  * @param dataItems