@jsonjoy.com/json-pack 1.20.0 → 1.21.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 (122) hide show
  1. package/lib/json/JsonEncoder.js +9 -3
  2. package/lib/json/JsonEncoder.js.map +1 -1
  3. package/lib/nfs/v4/Nfsv4Decoder.d.ts +14 -10
  4. package/lib/nfs/v4/Nfsv4Decoder.js +156 -74
  5. package/lib/nfs/v4/Nfsv4Decoder.js.map +1 -1
  6. package/lib/nfs/v4/Nfsv4Encoder.d.ts +4 -91
  7. package/lib/nfs/v4/Nfsv4Encoder.js +7 -823
  8. package/lib/nfs/v4/Nfsv4Encoder.js.map +1 -1
  9. package/lib/nfs/v4/Nfsv4FullEncoder.d.ts +32 -0
  10. package/lib/nfs/v4/Nfsv4FullEncoder.js +72 -0
  11. package/lib/nfs/v4/Nfsv4FullEncoder.js.map +1 -0
  12. package/lib/nfs/v4/attributes.d.ts +17 -0
  13. package/lib/nfs/v4/attributes.js +203 -0
  14. package/lib/nfs/v4/attributes.js.map +1 -0
  15. package/lib/nfs/v4/builder.d.ts +60 -0
  16. package/lib/nfs/v4/builder.js +187 -0
  17. package/lib/nfs/v4/builder.js.map +1 -0
  18. package/lib/nfs/v4/client/NfsFsDir.d.ts +20 -0
  19. package/lib/nfs/v4/client/NfsFsDir.js +129 -0
  20. package/lib/nfs/v4/client/NfsFsDir.js.map +1 -0
  21. package/lib/nfs/v4/client/NfsFsDirent.d.ts +14 -0
  22. package/lib/nfs/v4/client/NfsFsDirent.js +32 -0
  23. package/lib/nfs/v4/client/NfsFsDirent.js.map +1 -0
  24. package/lib/nfs/v4/client/NfsFsFileHandle.d.ts +34 -0
  25. package/lib/nfs/v4/client/NfsFsFileHandle.js +268 -0
  26. package/lib/nfs/v4/client/NfsFsFileHandle.js.map +1 -0
  27. package/lib/nfs/v4/client/NfsFsStats.d.ts +31 -0
  28. package/lib/nfs/v4/client/NfsFsStats.js +49 -0
  29. package/lib/nfs/v4/client/NfsFsStats.js.map +1 -0
  30. package/lib/nfs/v4/client/Nfsv4FsClient.d.ts +54 -0
  31. package/lib/nfs/v4/client/Nfsv4FsClient.js +812 -0
  32. package/lib/nfs/v4/client/Nfsv4FsClient.js.map +1 -0
  33. package/lib/nfs/v4/client/Nfsv4TcpClient.d.ts +41 -0
  34. package/lib/nfs/v4/client/Nfsv4TcpClient.js +216 -0
  35. package/lib/nfs/v4/client/Nfsv4TcpClient.js.map +1 -0
  36. package/lib/nfs/v4/client/types.d.ts +9 -0
  37. package/lib/nfs/v4/client/types.js +3 -0
  38. package/lib/nfs/v4/client/types.js.map +1 -0
  39. package/lib/nfs/v4/constants.d.ts +3 -0
  40. package/lib/nfs/v4/constants.js +4 -0
  41. package/lib/nfs/v4/constants.js.map +1 -1
  42. package/lib/nfs/v4/format.d.ts +23 -0
  43. package/lib/nfs/v4/format.js +870 -0
  44. package/lib/nfs/v4/format.js.map +1 -0
  45. package/lib/nfs/v4/index.d.ts +3 -1
  46. package/lib/nfs/v4/index.js +3 -1
  47. package/lib/nfs/v4/index.js.map +1 -1
  48. package/lib/nfs/v4/messages.d.ts +208 -90
  49. package/lib/nfs/v4/messages.js +585 -1
  50. package/lib/nfs/v4/messages.js.map +1 -1
  51. package/lib/nfs/v4/server/Nfsv4CompoundProcCtx.d.ts +11 -0
  52. package/lib/nfs/v4/server/Nfsv4CompoundProcCtx.js +155 -0
  53. package/lib/nfs/v4/server/Nfsv4CompoundProcCtx.js.map +1 -0
  54. package/lib/nfs/v4/server/Nfsv4Connection.d.ts +42 -0
  55. package/lib/nfs/v4/server/Nfsv4Connection.js +160 -0
  56. package/lib/nfs/v4/server/Nfsv4Connection.js.map +1 -0
  57. package/lib/nfs/v4/server/Nfsv4TcpServer.d.ts +26 -0
  58. package/lib/nfs/v4/server/Nfsv4TcpServer.js +91 -0
  59. package/lib/nfs/v4/server/Nfsv4TcpServer.js.map +1 -0
  60. package/lib/nfs/v4/server/operations/ByteRangeLock.d.ts +11 -0
  61. package/lib/nfs/v4/server/operations/ByteRangeLock.js +21 -0
  62. package/lib/nfs/v4/server/operations/ByteRangeLock.js.map +1 -0
  63. package/lib/nfs/v4/server/operations/ClientRecord.d.ts +13 -0
  64. package/lib/nfs/v4/server/operations/ClientRecord.js +17 -0
  65. package/lib/nfs/v4/server/operations/ClientRecord.js.map +1 -0
  66. package/lib/nfs/v4/server/operations/FilesystemStats.d.ts +9 -0
  67. package/lib/nfs/v4/server/operations/FilesystemStats.js +15 -0
  68. package/lib/nfs/v4/server/operations/FilesystemStats.js.map +1 -0
  69. package/lib/nfs/v4/server/operations/LockOwnerState.d.ts +9 -0
  70. package/lib/nfs/v4/server/operations/LockOwnerState.js +15 -0
  71. package/lib/nfs/v4/server/operations/LockOwnerState.js.map +1 -0
  72. package/lib/nfs/v4/server/operations/LockStateid.d.ts +10 -0
  73. package/lib/nfs/v4/server/operations/LockStateid.js +22 -0
  74. package/lib/nfs/v4/server/operations/LockStateid.js.map +1 -0
  75. package/lib/nfs/v4/server/operations/Nfsv4Operations.d.ts +44 -0
  76. package/lib/nfs/v4/server/operations/Nfsv4Operations.js +3 -0
  77. package/lib/nfs/v4/server/operations/Nfsv4Operations.js.map +1 -0
  78. package/lib/nfs/v4/server/operations/Nfsv4OperationsNotImpl.d.ts +42 -0
  79. package/lib/nfs/v4/server/operations/Nfsv4OperationsNotImpl.js +159 -0
  80. package/lib/nfs/v4/server/operations/Nfsv4OperationsNotImpl.js.map +1 -0
  81. package/lib/nfs/v4/server/operations/OpenFileState.d.ts +14 -0
  82. package/lib/nfs/v4/server/operations/OpenFileState.js +17 -0
  83. package/lib/nfs/v4/server/operations/OpenFileState.js.map +1 -0
  84. package/lib/nfs/v4/server/operations/OpenOwnerState.d.ts +9 -0
  85. package/lib/nfs/v4/server/operations/OpenOwnerState.js +15 -0
  86. package/lib/nfs/v4/server/operations/OpenOwnerState.js.map +1 -0
  87. package/lib/nfs/v4/server/operations/node/Nfsv4OperationsNode.d.ts +99 -0
  88. package/lib/nfs/v4/server/operations/node/Nfsv4OperationsNode.js +1400 -0
  89. package/lib/nfs/v4/server/operations/node/Nfsv4OperationsNode.js.map +1 -0
  90. package/lib/nfs/v4/server/operations/node/attrs.d.ts +5 -0
  91. package/lib/nfs/v4/server/operations/node/attrs.js +262 -0
  92. package/lib/nfs/v4/server/operations/node/attrs.js.map +1 -0
  93. package/lib/nfs/v4/server/operations/node/fh.d.ts +28 -0
  94. package/lib/nfs/v4/server/operations/node/fh.js +147 -0
  95. package/lib/nfs/v4/server/operations/node/fh.js.map +1 -0
  96. package/lib/nfs/v4/server/operations/node/util.d.ts +4 -0
  97. package/lib/nfs/v4/server/operations/node/util.js +17 -0
  98. package/lib/nfs/v4/server/operations/node/util.js.map +1 -0
  99. package/lib/nfs/v4/server/types.d.ts +4 -0
  100. package/lib/nfs/v4/server/types.js +3 -0
  101. package/lib/nfs/v4/server/types.js.map +1 -0
  102. package/lib/nfs/v4/server/util.d.ts +6 -0
  103. package/lib/nfs/v4/server/util.js +184 -0
  104. package/lib/nfs/v4/server/util.js.map +1 -0
  105. package/lib/nfs/v4/structs.d.ts +106 -51
  106. package/lib/nfs/v4/structs.js +237 -16
  107. package/lib/nfs/v4/structs.js.map +1 -1
  108. package/lib/rm/RmRecordDecoder.js.map +1 -1
  109. package/lib/rm/RmRecordEncoder.d.ts +2 -0
  110. package/lib/rm/RmRecordEncoder.js +25 -0
  111. package/lib/rm/RmRecordEncoder.js.map +1 -1
  112. package/lib/rpc/RpcMessageDecoder.js +3 -1
  113. package/lib/rpc/RpcMessageDecoder.js.map +1 -1
  114. package/lib/ssh/SshDecoder.d.ts +1 -1
  115. package/lib/ssh/SshDecoder.js.map +1 -1
  116. package/lib/ssh/SshEncoder.d.ts +1 -1
  117. package/lib/ssh/SshEncoder.js.map +1 -1
  118. package/lib/xdr/types.d.ts +6 -0
  119. package/package.json +4 -2
  120. package/lib/nfs/v4/FullNfsv4Encoder.d.ts +0 -28
  121. package/lib/nfs/v4/FullNfsv4Encoder.js +0 -73
  122. package/lib/nfs/v4/FullNfsv4Encoder.js.map +0 -1
@@ -1,842 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Nfsv4Encoder = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const Writer_1 = require("@jsonjoy.com/util/lib/buffers/Writer");
6
5
  const XdrEncoder_1 = require("../../xdr/XdrEncoder");
7
- const errors_1 = require("./errors");
8
- const msg = tslib_1.__importStar(require("./messages"));
9
- const structs = tslib_1.__importStar(require("./structs"));
10
6
  class Nfsv4Encoder {
11
7
  constructor(writer = new Writer_1.Writer()) {
12
8
  this.writer = writer;
13
9
  this.xdr = new XdrEncoder_1.XdrEncoder(writer);
14
10
  }
15
11
  encodeCompound(compound, isRequest) {
16
- if (isRequest)
17
- this.writeCompoundRequest(compound);
18
- else
19
- this.writeCompoundResponse(compound);
12
+ compound.encode(this.xdr);
20
13
  return this.writer.flush();
21
14
  }
22
15
  writeCompound(compound, isRequest) {
23
- if (isRequest)
24
- this.writeCompoundRequest(compound);
25
- else
26
- this.writeCompoundResponse(compound);
16
+ compound.encode(this.xdr);
27
17
  }
28
- writeCompoundRequest(request) {
29
- const xdr = this.xdr;
30
- xdr.writeStr(request.tag);
31
- xdr.writeUnsignedInt(request.minorversion);
32
- xdr.writeUnsignedInt(request.argarray.length);
33
- for (const arg of request.argarray) {
34
- this.writeRequest(arg);
35
- }
36
- }
37
- writeCompoundResponse(response) {
38
- const xdr = this.xdr;
39
- xdr.writeUnsignedInt(response.status);
40
- xdr.writeStr(response.tag);
41
- xdr.writeUnsignedInt(response.resarray.length);
42
- for (const res of response.resarray) {
43
- this.writeResponse(res);
44
- }
45
- }
46
- writeRequest(request) {
47
- if (request instanceof msg.Nfsv4AccessRequest) {
48
- this.xdr.writeUnsignedInt(3);
49
- this.writeAccessRequest(request);
50
- }
51
- else if (request instanceof msg.Nfsv4CloseRequest) {
52
- this.xdr.writeUnsignedInt(4);
53
- this.writeCloseRequest(request);
54
- }
55
- else if (request instanceof msg.Nfsv4CommitRequest) {
56
- this.xdr.writeUnsignedInt(5);
57
- this.writeCommitRequest(request);
58
- }
59
- else if (request instanceof msg.Nfsv4CreateRequest) {
60
- this.xdr.writeUnsignedInt(6);
61
- this.writeCreateRequest(request);
62
- }
63
- else if (request instanceof msg.Nfsv4DelegreturnRequest) {
64
- this.xdr.writeUnsignedInt(8);
65
- this.writeDelegreturnRequest(request);
66
- }
67
- else if (request instanceof msg.Nfsv4GetattrRequest) {
68
- this.xdr.writeUnsignedInt(9);
69
- this.writeGetattrRequest(request);
70
- }
71
- else if (request instanceof msg.Nfsv4GetfhRequest) {
72
- this.xdr.writeUnsignedInt(10);
73
- this.writeGetfhRequest(request);
74
- }
75
- else if (request instanceof msg.Nfsv4LinkRequest) {
76
- this.xdr.writeUnsignedInt(11);
77
- this.writeLinkRequest(request);
78
- }
79
- else if (request instanceof msg.Nfsv4LockRequest) {
80
- this.xdr.writeUnsignedInt(12);
81
- this.writeLockRequest(request);
82
- }
83
- else if (request instanceof msg.Nfsv4LocktRequest) {
84
- this.xdr.writeUnsignedInt(13);
85
- this.writeLocktRequest(request);
86
- }
87
- else if (request instanceof msg.Nfsv4LockuRequest) {
88
- this.xdr.writeUnsignedInt(14);
89
- this.writeLockuRequest(request);
90
- }
91
- else if (request instanceof msg.Nfsv4LookupRequest) {
92
- this.xdr.writeUnsignedInt(15);
93
- this.writeLookupRequest(request);
94
- }
95
- else if (request instanceof msg.Nfsv4LookuppRequest) {
96
- this.xdr.writeUnsignedInt(16);
97
- this.writeLookuppRequest(request);
98
- }
99
- else if (request instanceof msg.Nfsv4NverifyRequest) {
100
- this.xdr.writeUnsignedInt(17);
101
- this.writeNverifyRequest(request);
102
- }
103
- else if (request instanceof msg.Nfsv4OpenRequest) {
104
- this.xdr.writeUnsignedInt(18);
105
- this.writeOpenRequest(request);
106
- }
107
- else if (request instanceof msg.Nfsv4OpenConfirmRequest) {
108
- this.xdr.writeUnsignedInt(20);
109
- this.writeOpenConfirmRequest(request);
110
- }
111
- else if (request instanceof msg.Nfsv4OpenDowngradeRequest) {
112
- this.xdr.writeUnsignedInt(21);
113
- this.writeOpenDowngradeRequest(request);
114
- }
115
- else if (request instanceof msg.Nfsv4PutfhRequest) {
116
- this.xdr.writeUnsignedInt(22);
117
- this.writePutfhRequest(request);
118
- }
119
- else if (request instanceof msg.Nfsv4PutpubfhRequest) {
120
- this.xdr.writeUnsignedInt(23);
121
- this.writePutpubfhRequest(request);
122
- }
123
- else if (request instanceof msg.Nfsv4PutrootfhRequest) {
124
- this.xdr.writeUnsignedInt(24);
125
- this.writePutrootfhRequest(request);
126
- }
127
- else if (request instanceof msg.Nfsv4ReadRequest) {
128
- this.xdr.writeUnsignedInt(25);
129
- this.writeReadRequest(request);
130
- }
131
- else if (request instanceof msg.Nfsv4ReaddirRequest) {
132
- this.xdr.writeUnsignedInt(26);
133
- this.writeReaddirRequest(request);
134
- }
135
- else if (request instanceof msg.Nfsv4ReadlinkRequest) {
136
- this.xdr.writeUnsignedInt(27);
137
- this.writeReadlinkRequest(request);
138
- }
139
- else if (request instanceof msg.Nfsv4RemoveRequest) {
140
- this.xdr.writeUnsignedInt(28);
141
- this.writeRemoveRequest(request);
142
- }
143
- else if (request instanceof msg.Nfsv4RenameRequest) {
144
- this.xdr.writeUnsignedInt(29);
145
- this.writeRenameRequest(request);
146
- }
147
- else if (request instanceof msg.Nfsv4RenewRequest) {
148
- this.xdr.writeUnsignedInt(30);
149
- this.writeRenewRequest(request);
150
- }
151
- else if (request instanceof msg.Nfsv4RestorefhRequest) {
152
- this.xdr.writeUnsignedInt(31);
153
- this.writeRestorefhRequest(request);
154
- }
155
- else if (request instanceof msg.Nfsv4SavefhRequest) {
156
- this.xdr.writeUnsignedInt(32);
157
- this.writeSavefhRequest(request);
158
- }
159
- else if (request instanceof msg.Nfsv4SecinfoRequest) {
160
- this.xdr.writeUnsignedInt(33);
161
- this.writeSecinfoRequest(request);
162
- }
163
- else if (request instanceof msg.Nfsv4SetattrRequest) {
164
- this.xdr.writeUnsignedInt(34);
165
- this.writeSetattrRequest(request);
166
- }
167
- else if (request instanceof msg.Nfsv4SetclientidRequest) {
168
- this.xdr.writeUnsignedInt(35);
169
- this.writeSetclientidRequest(request);
170
- }
171
- else if (request instanceof msg.Nfsv4SetclientidConfirmRequest) {
172
- this.xdr.writeUnsignedInt(36);
173
- this.writeSetclientidConfirmRequest(request);
174
- }
175
- else if (request instanceof msg.Nfsv4VerifyRequest) {
176
- this.xdr.writeUnsignedInt(37);
177
- this.writeVerifyRequest(request);
178
- }
179
- else if (request instanceof msg.Nfsv4WriteRequest) {
180
- this.xdr.writeUnsignedInt(38);
181
- this.writeWriteRequest(request);
182
- }
183
- else {
184
- throw new errors_1.Nfsv4EncodingError(`Unknown request type: ${request.constructor.name}`);
185
- }
186
- }
187
- writeResponse(response) {
188
- if (response instanceof msg.Nfsv4AccessResponse) {
189
- this.xdr.writeUnsignedInt(3);
190
- this.writeAccessResponse(response);
191
- }
192
- else if (response instanceof msg.Nfsv4CloseResponse) {
193
- this.xdr.writeUnsignedInt(4);
194
- this.writeCloseResponse(response);
195
- }
196
- else if (response instanceof msg.Nfsv4CommitResponse) {
197
- this.xdr.writeUnsignedInt(5);
198
- this.writeCommitResponse(response);
199
- }
200
- else if (response instanceof msg.Nfsv4CreateResponse) {
201
- this.xdr.writeUnsignedInt(6);
202
- this.writeCreateResponse(response);
203
- }
204
- else if (response instanceof msg.Nfsv4DelegreturnResponse) {
205
- this.xdr.writeUnsignedInt(8);
206
- this.writeDelegreturnResponse(response);
207
- }
208
- else if (response instanceof msg.Nfsv4GetattrResponse) {
209
- this.xdr.writeUnsignedInt(9);
210
- this.writeGetattrResponse(response);
211
- }
212
- else if (response instanceof msg.Nfsv4GetfhResponse) {
213
- this.xdr.writeUnsignedInt(10);
214
- this.writeGetfhResponse(response);
215
- }
216
- else if (response instanceof msg.Nfsv4LinkResponse) {
217
- this.xdr.writeUnsignedInt(11);
218
- this.writeLinkResponse(response);
219
- }
220
- else if (response instanceof msg.Nfsv4LockResponse) {
221
- this.xdr.writeUnsignedInt(12);
222
- this.writeLockResponse(response);
223
- }
224
- else if (response instanceof msg.Nfsv4LocktResponse) {
225
- this.xdr.writeUnsignedInt(13);
226
- this.writeLocktResponse(response);
227
- }
228
- else if (response instanceof msg.Nfsv4LockuResponse) {
229
- this.xdr.writeUnsignedInt(14);
230
- this.writeLockuResponse(response);
231
- }
232
- else if (response instanceof msg.Nfsv4LookupResponse) {
233
- this.xdr.writeUnsignedInt(15);
234
- this.writeLookupResponse(response);
235
- }
236
- else if (response instanceof msg.Nfsv4LookuppResponse) {
237
- this.xdr.writeUnsignedInt(16);
238
- this.writeLookuppResponse(response);
239
- }
240
- else if (response instanceof msg.Nfsv4NverifyResponse) {
241
- this.xdr.writeUnsignedInt(17);
242
- this.writeNverifyResponse(response);
243
- }
244
- else if (response instanceof msg.Nfsv4OpenResponse) {
245
- this.xdr.writeUnsignedInt(18);
246
- this.writeOpenResponse(response);
247
- }
248
- else if (response instanceof msg.Nfsv4OpenConfirmResponse) {
249
- this.xdr.writeUnsignedInt(20);
250
- this.writeOpenConfirmResponse(response);
251
- }
252
- else if (response instanceof msg.Nfsv4OpenDowngradeResponse) {
253
- this.xdr.writeUnsignedInt(21);
254
- this.writeOpenDowngradeResponse(response);
255
- }
256
- else if (response instanceof msg.Nfsv4PutfhResponse) {
257
- this.xdr.writeUnsignedInt(22);
258
- this.writePutfhResponse(response);
259
- }
260
- else if (response instanceof msg.Nfsv4PutpubfhResponse) {
261
- this.xdr.writeUnsignedInt(23);
262
- this.writePutpubfhResponse(response);
263
- }
264
- else if (response instanceof msg.Nfsv4PutrootfhResponse) {
265
- this.xdr.writeUnsignedInt(24);
266
- this.writePutrootfhResponse(response);
267
- }
268
- else if (response instanceof msg.Nfsv4ReadResponse) {
269
- this.xdr.writeUnsignedInt(25);
270
- this.writeReadResponse(response);
271
- }
272
- else if (response instanceof msg.Nfsv4ReaddirResponse) {
273
- this.xdr.writeUnsignedInt(26);
274
- this.writeReaddirResponse(response);
275
- }
276
- else if (response instanceof msg.Nfsv4ReadlinkResponse) {
277
- this.xdr.writeUnsignedInt(27);
278
- this.writeReadlinkResponse(response);
279
- }
280
- else if (response instanceof msg.Nfsv4RemoveResponse) {
281
- this.xdr.writeUnsignedInt(28);
282
- this.writeRemoveResponse(response);
283
- }
284
- else if (response instanceof msg.Nfsv4RenameResponse) {
285
- this.xdr.writeUnsignedInt(29);
286
- this.writeRenameResponse(response);
287
- }
288
- else if (response instanceof msg.Nfsv4RenewResponse) {
289
- this.xdr.writeUnsignedInt(30);
290
- this.writeRenewResponse(response);
291
- }
292
- else if (response instanceof msg.Nfsv4RestorefhResponse) {
293
- this.xdr.writeUnsignedInt(31);
294
- this.writeRestorefhResponse(response);
295
- }
296
- else if (response instanceof msg.Nfsv4SavefhResponse) {
297
- this.xdr.writeUnsignedInt(32);
298
- this.writeSavefhResponse(response);
299
- }
300
- else if (response instanceof msg.Nfsv4SecinfoResponse) {
301
- this.xdr.writeUnsignedInt(33);
302
- this.writeSecinfoResponse(response);
303
- }
304
- else if (response instanceof msg.Nfsv4SetattrResponse) {
305
- this.xdr.writeUnsignedInt(34);
306
- this.writeSetattrResponse(response);
307
- }
308
- else if (response instanceof msg.Nfsv4SetclientidResponse) {
309
- this.xdr.writeUnsignedInt(35);
310
- this.writeSetclientidResponse(response);
311
- }
312
- else if (response instanceof msg.Nfsv4SetclientidConfirmResponse) {
313
- this.xdr.writeUnsignedInt(36);
314
- this.writeSetclientidConfirmResponse(response);
315
- }
316
- else if (response instanceof msg.Nfsv4VerifyResponse) {
317
- this.xdr.writeUnsignedInt(37);
318
- this.writeVerifyResponse(response);
319
- }
320
- else if (response instanceof msg.Nfsv4WriteResponse) {
321
- this.xdr.writeUnsignedInt(38);
322
- this.writeWriteResponse(response);
323
- }
324
- else {
325
- throw new errors_1.Nfsv4EncodingError(`Unknown response type: ${response.constructor.name}`);
326
- }
327
- }
328
- writeFh(fh) {
329
- this.xdr.writeVarlenOpaque(fh.data);
330
- }
331
- writeVerifier(verifier) {
332
- this.xdr.writeOpaque(verifier.data);
333
- }
334
- writeTime(time) {
335
- const xdr = this.xdr;
336
- xdr.writeHyper(time.seconds);
337
- xdr.writeUnsignedInt(time.nseconds);
338
- }
339
- writeStateid(stateid) {
340
- const xdr = this.xdr;
341
- xdr.writeUnsignedInt(stateid.seqid);
342
- xdr.writeOpaque(stateid.other);
343
- }
344
- writeBitmap(bitmap) {
345
- const xdr = this.xdr;
346
- xdr.writeUnsignedInt(bitmap.mask.length);
347
- for (const m of bitmap.mask) {
348
- xdr.writeUnsignedInt(m);
349
- }
350
- }
351
- writeFattr(fattr) {
352
- this.writeBitmap(fattr.attrmask);
353
- this.xdr.writeVarlenOpaque(fattr.attrVals);
354
- }
355
- writeChangeInfo(changeInfo) {
356
- const xdr = this.xdr;
357
- xdr.writeBoolean(changeInfo.atomic);
358
- xdr.writeUnsignedHyper(changeInfo.before);
359
- xdr.writeUnsignedHyper(changeInfo.after);
360
- }
361
- writeClientAddr(clientAddr) {
362
- const xdr = this.xdr;
363
- xdr.writeStr(clientAddr.rNetid);
364
- xdr.writeStr(clientAddr.rAddr);
365
- }
366
- writeCbClient(cbClient) {
367
- const xdr = this.xdr;
368
- xdr.writeUnsignedInt(cbClient.cbProgram);
369
- this.writeClientAddr(cbClient.cbLocation);
370
- }
371
- writeClientId(clientId) {
372
- this.writeVerifier(clientId.verifier);
373
- this.xdr.writeVarlenOpaque(clientId.id);
374
- }
375
- writeOpenOwner(openOwner) {
376
- const xdr = this.xdr;
377
- xdr.writeUnsignedHyper(openOwner.clientid);
378
- xdr.writeVarlenOpaque(openOwner.owner);
379
- }
380
- writeLockOwner(lockOwner) {
381
- const xdr = this.xdr;
382
- xdr.writeUnsignedHyper(lockOwner.clientid);
383
- xdr.writeVarlenOpaque(lockOwner.owner);
384
- }
385
- writeOpenToLockOwner(openToLockOwner) {
386
- const xdr = this.xdr;
387
- xdr.writeUnsignedInt(openToLockOwner.openSeqid);
388
- this.writeStateid(openToLockOwner.openStateid);
389
- xdr.writeUnsignedInt(openToLockOwner.lockSeqid);
390
- this.writeLockOwner(openToLockOwner.lockOwner);
391
- }
392
- writeExistingLockOwner(existingLockOwner) {
393
- this.writeStateid(existingLockOwner.lockStateid);
394
- this.xdr.writeUnsignedInt(existingLockOwner.lockSeqid);
395
- }
396
- writeOpenClaim(openClaim) {
397
- const xdr = this.xdr;
398
- xdr.writeUnsignedInt(openClaim.claimType);
399
- const claim = openClaim.claim;
400
- if (claim instanceof structs.Nfsv4OpenClaimNull) {
401
- xdr.writeStr(claim.file);
402
- }
403
- else if (claim instanceof structs.Nfsv4OpenClaimPrevious) {
404
- xdr.writeUnsignedInt(claim.delegateType);
405
- }
406
- else if (claim instanceof structs.Nfsv4OpenClaimDelegateCur) {
407
- this.writeStateid(claim.delegateStateid);
408
- xdr.writeStr(claim.file);
409
- }
410
- else if (claim instanceof structs.Nfsv4OpenClaimDelegatePrev) {
411
- xdr.writeStr(claim.file);
412
- }
413
- }
414
- writeAccessRequest(req) {
415
- this.xdr.writeUnsignedInt(req.access);
416
- }
417
- writeAccessResponse(res) {
418
- const xdr = this.xdr;
419
- xdr.writeUnsignedInt(res.status);
420
- if (res.status === 0 && res.resok) {
421
- xdr.writeUnsignedInt(res.resok.supported);
422
- xdr.writeUnsignedInt(res.resok.access);
423
- }
424
- }
425
- writeCloseRequest(req) {
426
- const xdr = this.xdr;
427
- xdr.writeUnsignedInt(req.seqid);
428
- this.writeStateid(req.openStateid);
429
- }
430
- writeCloseResponse(res) {
431
- const xdr = this.xdr;
432
- xdr.writeUnsignedInt(res.status);
433
- if (res.status === 0 && res.resok) {
434
- this.writeStateid(res.resok.openStateid);
435
- }
436
- }
437
- writeCommitRequest(req) {
438
- const xdr = this.xdr;
439
- xdr.writeUnsignedHyper(req.offset);
440
- xdr.writeUnsignedInt(req.count);
441
- }
442
- writeCommitResponse(res) {
443
- const xdr = this.xdr;
444
- xdr.writeUnsignedInt(res.status);
445
- if (res.status === 0 && res.resok) {
446
- this.writeVerifier(res.resok.writeverf);
447
- }
448
- }
449
- writeCreateRequest(req) {
450
- const xdr = this.xdr;
451
- const createType = req.objtype;
452
- xdr.writeUnsignedInt(createType.type);
453
- const objtype = createType.objtype;
454
- if (objtype instanceof structs.Nfsv4CreateTypeLink) {
455
- xdr.writeStr(objtype.linkdata);
456
- }
457
- else if (objtype instanceof structs.Nfsv4CreateTypeDevice) {
458
- xdr.writeUnsignedInt(objtype.devdata.specdata1);
459
- xdr.writeUnsignedInt(objtype.devdata.specdata2);
460
- }
461
- xdr.writeStr(req.objname);
462
- if (objtype instanceof structs.Nfsv4CreateTypeLink) {
463
- this.writeFattr(objtype.createattrs);
464
- }
465
- else if (objtype instanceof structs.Nfsv4CreateTypeDevice) {
466
- this.writeFattr(objtype.createattrs);
467
- }
468
- else if (objtype instanceof structs.Nfsv4CreateTypeOther) {
469
- this.writeFattr(objtype.createattrs);
470
- }
471
- }
472
- writeCreateResponse(res) {
473
- const xdr = this.xdr;
474
- xdr.writeUnsignedInt(res.status);
475
- if (res.status === 0 && res.resok) {
476
- this.writeChangeInfo(res.resok.cinfo);
477
- this.writeBitmap(res.resok.attrset);
478
- }
479
- }
480
- writeDelegreturnRequest(req) {
481
- this.writeStateid(req.delegStateid);
482
- }
483
- writeDelegreturnResponse(res) {
484
- this.xdr.writeUnsignedInt(res.status);
485
- }
486
- writeGetattrRequest(req) {
487
- this.writeBitmap(req.attrRequest);
488
- }
489
- writeGetattrResponse(res) {
490
- const xdr = this.xdr;
491
- xdr.writeUnsignedInt(res.status);
492
- if (res.status === 0 && res.resok) {
493
- this.writeFattr(res.resok.objAttributes);
494
- }
495
- }
496
- writeGetfhRequest(req) {
497
- }
498
- writeGetfhResponse(res) {
499
- const xdr = this.xdr;
500
- xdr.writeUnsignedInt(res.status);
501
- if (res.status === 0 && res.resok) {
502
- this.writeFh(res.resok.object);
503
- }
504
- }
505
- writeLinkRequest(req) {
506
- this.xdr.writeStr(req.newname);
507
- }
508
- writeLinkResponse(res) {
509
- const xdr = this.xdr;
510
- xdr.writeUnsignedInt(res.status);
511
- if (res.status === 0 && res.resok) {
512
- this.writeChangeInfo(res.resok.cinfo);
513
- }
514
- }
515
- writeLockRequest(req) {
516
- const xdr = this.xdr;
517
- xdr.writeUnsignedInt(req.locktype);
518
- xdr.writeBoolean(req.reclaim);
519
- xdr.writeUnsignedHyper(req.offset);
520
- xdr.writeUnsignedHyper(req.length);
521
- xdr.writeBoolean(req.locker.newLockOwner);
522
- const owner = req.locker.owner;
523
- if (owner instanceof structs.Nfsv4LockNewOwner) {
524
- this.writeOpenToLockOwner(owner.openToLockOwner);
525
- }
526
- else if (owner instanceof structs.Nfsv4LockExistingOwner) {
527
- this.writeExistingLockOwner(owner);
528
- }
529
- }
530
- writeLockResponse(res) {
531
- const xdr = this.xdr;
532
- xdr.writeUnsignedInt(res.status);
533
- if (res.status === 0 && res.resok) {
534
- this.writeStateid(res.resok.lockStateid);
535
- }
536
- else if (res.denied) {
537
- xdr.writeUnsignedHyper(res.denied.offset);
538
- xdr.writeUnsignedHyper(res.denied.length);
539
- xdr.writeUnsignedInt(res.denied.locktype);
540
- this.writeLockOwner(res.denied.owner);
541
- }
542
- }
543
- writeLocktRequest(req) {
544
- const xdr = this.xdr;
545
- xdr.writeUnsignedInt(req.locktype);
546
- xdr.writeUnsignedHyper(req.offset);
547
- xdr.writeUnsignedHyper(req.length);
548
- this.writeLockOwner(req.owner);
549
- }
550
- writeLocktResponse(res) {
551
- const xdr = this.xdr;
552
- xdr.writeUnsignedInt(res.status);
553
- if (res.denied) {
554
- xdr.writeUnsignedHyper(res.denied.offset);
555
- xdr.writeUnsignedHyper(res.denied.length);
556
- xdr.writeUnsignedInt(res.denied.locktype);
557
- this.writeLockOwner(res.denied.owner);
558
- }
559
- }
560
- writeLockuRequest(req) {
561
- const xdr = this.xdr;
562
- xdr.writeUnsignedInt(req.locktype);
563
- xdr.writeUnsignedInt(req.seqid);
564
- this.writeStateid(req.lockStateid);
565
- xdr.writeUnsignedHyper(req.offset);
566
- xdr.writeUnsignedHyper(req.length);
567
- }
568
- writeLockuResponse(res) {
569
- const xdr = this.xdr;
570
- xdr.writeUnsignedInt(res.status);
571
- if (res.status === 0 && res.resok) {
572
- this.writeStateid(res.resok.lockStateid);
573
- }
574
- }
575
- writeLookupRequest(req) {
576
- this.xdr.writeStr(req.objname);
577
- }
578
- writeLookupResponse(res) {
579
- this.xdr.writeUnsignedInt(res.status);
580
- }
581
- writeLookuppRequest(req) {
582
- }
583
- writeLookuppResponse(res) {
584
- this.xdr.writeUnsignedInt(res.status);
585
- }
586
- writeNverifyRequest(req) {
587
- this.writeFattr(req.objAttributes);
588
- }
589
- writeNverifyResponse(res) {
590
- this.xdr.writeUnsignedInt(res.status);
591
- }
592
- writeOpenRequest(req) {
593
- const xdr = this.xdr;
594
- xdr.writeUnsignedInt(req.seqid);
595
- xdr.writeUnsignedInt(req.shareAccess);
596
- xdr.writeUnsignedInt(req.shareDeny);
597
- this.writeOpenOwner(req.owner);
598
- xdr.writeUnsignedInt(req.openhow);
599
- this.writeOpenClaim(req.claim);
600
- }
601
- writeOpenResponse(res) {
602
- const xdr = this.xdr;
603
- xdr.writeUnsignedInt(res.status);
604
- if (res.status === 0 && res.resok) {
605
- this.writeStateid(res.resok.stateid);
606
- this.writeChangeInfo(res.resok.cinfo);
607
- xdr.writeUnsignedInt(res.resok.rflags);
608
- this.writeBitmap(res.resok.attrset);
609
- this.writeOpenDelegation(res.resok.delegation);
610
- }
611
- }
612
- writeOpenDelegation(delegation) {
613
- const xdr = this.xdr;
614
- xdr.writeUnsignedInt(delegation.delegationType);
615
- if (delegation.delegation) {
616
- const deleg = delegation.delegation;
617
- if (deleg instanceof structs.Nfsv4OpenReadDelegation) {
618
- this.writeStateid(deleg.stateid);
619
- xdr.writeBoolean(deleg.recall);
620
- xdr.writeUnsignedInt(deleg.permissions.length);
621
- for (const ace of deleg.permissions) {
622
- this.writeAce(ace);
623
- }
624
- }
625
- else if (deleg instanceof structs.Nfsv4OpenWriteDelegation) {
626
- this.writeStateid(deleg.stateid);
627
- xdr.writeBoolean(deleg.recall);
628
- xdr.writeUnsignedHyper(deleg.spaceLimit);
629
- xdr.writeUnsignedInt(deleg.permissions.length);
630
- for (const ace of deleg.permissions) {
631
- this.writeAce(ace);
632
- }
633
- }
634
- }
635
- }
636
- writeAce(ace) {
637
- const xdr = this.xdr;
638
- xdr.writeUnsignedInt(ace.type);
639
- xdr.writeUnsignedInt(ace.flag);
640
- xdr.writeUnsignedInt(ace.accessMask);
641
- xdr.writeStr(ace.who);
642
- }
643
- writeOpenConfirmRequest(req) {
644
- this.writeStateid(req.openStateid);
645
- this.xdr.writeUnsignedInt(req.seqid);
646
- }
647
- writeOpenConfirmResponse(res) {
648
- const xdr = this.xdr;
649
- xdr.writeUnsignedInt(res.status);
650
- if (res.status === 0 && res.resok) {
651
- this.writeStateid(res.resok.openStateid);
652
- }
653
- }
654
- writeOpenDowngradeRequest(req) {
655
- const xdr = this.xdr;
656
- this.writeStateid(req.openStateid);
657
- xdr.writeUnsignedInt(req.seqid);
658
- xdr.writeUnsignedInt(req.shareAccess);
659
- xdr.writeUnsignedInt(req.shareDeny);
660
- }
661
- writeOpenDowngradeResponse(res) {
662
- const xdr = this.xdr;
663
- xdr.writeUnsignedInt(res.status);
664
- if (res.status === 0 && res.resok) {
665
- this.writeStateid(res.resok.openStateid);
666
- }
667
- }
668
- writePutfhRequest(req) {
669
- this.writeFh(req.object);
670
- }
671
- writePutfhResponse(res) {
672
- this.xdr.writeUnsignedInt(res.status);
673
- }
674
- writePutpubfhRequest(req) {
675
- }
676
- writePutpubfhResponse(res) {
677
- this.xdr.writeUnsignedInt(res.status);
678
- }
679
- writePutrootfhRequest(req) {
680
- }
681
- writePutrootfhResponse(res) {
682
- this.xdr.writeUnsignedInt(res.status);
683
- }
684
- writeReadRequest(req) {
685
- const xdr = this.xdr;
686
- this.writeStateid(req.stateid);
687
- xdr.writeUnsignedHyper(req.offset);
688
- xdr.writeUnsignedInt(req.count);
689
- }
690
- writeReadResponse(res) {
691
- const xdr = this.xdr;
692
- xdr.writeUnsignedInt(res.status);
693
- if (res.status === 0 && res.resok) {
694
- xdr.writeBoolean(res.resok.eof);
695
- xdr.writeVarlenOpaque(res.resok.data);
696
- }
697
- }
698
- writeReaddirRequest(req) {
699
- const xdr = this.xdr;
700
- xdr.writeUnsignedHyper(req.cookie);
701
- this.writeVerifier(req.cookieverf);
702
- xdr.writeUnsignedInt(req.dircount);
703
- xdr.writeUnsignedInt(req.maxcount);
704
- this.writeBitmap(req.attrRequest);
705
- }
706
- writeReaddirResponse(res) {
707
- const xdr = this.xdr;
708
- xdr.writeUnsignedInt(res.status);
709
- if (res.status === 0 && res.resok) {
710
- this.writeVerifier(res.resok.cookieverf);
711
- for (const entry of res.resok.entries) {
712
- xdr.writeBoolean(true);
713
- xdr.writeUnsignedHyper(entry.cookie);
714
- xdr.writeStr(entry.name);
715
- this.writeFattr(entry.attrs);
716
- }
717
- xdr.writeBoolean(false);
718
- xdr.writeBoolean(res.resok.eof);
719
- }
720
- }
721
- writeReadlinkRequest(req) {
722
- }
723
- writeReadlinkResponse(res) {
724
- const xdr = this.xdr;
725
- xdr.writeUnsignedInt(res.status);
726
- if (res.status === 0 && res.resok) {
727
- xdr.writeStr(res.resok.link);
728
- }
729
- }
730
- writeRemoveRequest(req) {
731
- this.xdr.writeStr(req.target);
732
- }
733
- writeRemoveResponse(res) {
734
- const xdr = this.xdr;
735
- xdr.writeUnsignedInt(res.status);
736
- if (res.status === 0 && res.resok) {
737
- this.writeChangeInfo(res.resok.cinfo);
738
- }
739
- }
740
- writeRenameRequest(req) {
741
- const xdr = this.xdr;
742
- xdr.writeStr(req.oldname);
743
- xdr.writeStr(req.newname);
744
- }
745
- writeRenameResponse(res) {
746
- const xdr = this.xdr;
747
- xdr.writeUnsignedInt(res.status);
748
- if (res.status === 0 && res.resok) {
749
- this.writeChangeInfo(res.resok.sourceCinfo);
750
- this.writeChangeInfo(res.resok.targetCinfo);
751
- }
752
- }
753
- writeRenewRequest(req) {
754
- this.xdr.writeUnsignedHyper(req.clientid);
755
- }
756
- writeRenewResponse(res) {
757
- this.xdr.writeUnsignedInt(res.status);
758
- }
759
- writeRestorefhRequest(req) {
760
- }
761
- writeRestorefhResponse(res) {
762
- this.xdr.writeUnsignedInt(res.status);
763
- }
764
- writeSavefhRequest(req) {
765
- }
766
- writeSavefhResponse(res) {
767
- this.xdr.writeUnsignedInt(res.status);
768
- }
769
- writeSecinfoRequest(req) {
770
- this.xdr.writeStr(req.name);
771
- }
772
- writeSecinfoResponse(res) {
773
- const xdr = this.xdr;
774
- xdr.writeUnsignedInt(res.status);
775
- if (res.status === 0 && res.resok) {
776
- xdr.writeUnsignedInt(res.resok.flavors.length);
777
- for (const flavor of res.resok.flavors) {
778
- xdr.writeUnsignedInt(flavor.flavor);
779
- if (flavor.flavorInfo) {
780
- xdr.writeVarlenOpaque(flavor.flavorInfo.oid);
781
- xdr.writeUnsignedInt(flavor.flavorInfo.qop);
782
- xdr.writeUnsignedInt(flavor.flavorInfo.service);
783
- }
784
- }
785
- }
786
- }
787
- writeSetattrRequest(req) {
788
- this.writeStateid(req.stateid);
789
- this.writeFattr(req.objAttributes);
790
- }
791
- writeSetattrResponse(res) {
792
- const xdr = this.xdr;
793
- xdr.writeUnsignedInt(res.status);
794
- if (res.resok) {
795
- this.writeBitmap(res.resok.attrsset);
796
- }
797
- }
798
- writeSetclientidRequest(req) {
799
- this.writeClientId(req.client);
800
- this.writeCbClient(req.callback);
801
- this.xdr.writeUnsignedInt(req.callbackIdent);
802
- }
803
- writeSetclientidResponse(res) {
804
- const xdr = this.xdr;
805
- xdr.writeUnsignedInt(res.status);
806
- if (res.status === 0 && res.resok) {
807
- xdr.writeUnsignedHyper(res.resok.clientid);
808
- this.writeVerifier(res.resok.setclientidConfirm);
809
- }
810
- }
811
- writeSetclientidConfirmRequest(req) {
812
- const xdr = this.xdr;
813
- xdr.writeUnsignedHyper(req.clientid);
814
- this.writeVerifier(req.setclientidConfirm);
815
- }
816
- writeSetclientidConfirmResponse(res) {
817
- this.xdr.writeUnsignedInt(res.status);
818
- }
819
- writeVerifyRequest(req) {
820
- this.writeFattr(req.objAttributes);
821
- }
822
- writeVerifyResponse(res) {
823
- this.xdr.writeUnsignedInt(res.status);
824
- }
825
- writeWriteRequest(req) {
826
- const xdr = this.xdr;
827
- this.writeStateid(req.stateid);
828
- xdr.writeUnsignedHyper(req.offset);
829
- xdr.writeUnsignedInt(req.stable);
830
- xdr.writeVarlenOpaque(req.data);
18
+ encodeCbCompound(compound, isRequest) {
19
+ compound.encode(this.xdr);
20
+ return this.writer.flush();
831
21
  }
832
- writeWriteResponse(res) {
833
- const xdr = this.xdr;
834
- xdr.writeUnsignedInt(res.status);
835
- if (res.status === 0 && res.resok) {
836
- xdr.writeUnsignedInt(res.resok.count);
837
- xdr.writeUnsignedInt(res.resok.committed);
838
- this.writeVerifier(res.resok.writeverf);
839
- }
22
+ writeCbCompound(compound, isRequest) {
23
+ compound.encode(this.xdr);
840
24
  }
841
25
  }
842
26
  exports.Nfsv4Encoder = Nfsv4Encoder;