Recalculated the maximum message size for write/write raw operations.
Recalculated the threshold value for the message size beyond which raw write operations are likely more effective than plain write operations.
Maximum payload size for raw write operations is now limited both by the maximum raw write size and the maximum buffer size. The smaller of both quantities is used.
Added DUMPSMBLEVEL option which controls how much raw data output is produced. By default (level 0) no raw data output is produced at all. Level 1 will print the contents of the command data area. Level 2 will print the raw data used by the respective commands, with any management/control information stripped off.
The SMB dump output can now be stored in a file, rather than having to be redirected to one. When storing it in a file, the output will be appended to an existing file, otherwise a new file will be created.
The raw read/write functions now respect the upper limit for the amount of data to be written, as given by the server.
Fixed decoding of maximum buffer size; this used to come out as 0, which made smbfs switch back to the default minimum supported (1024 bytes).
Corrected use of the maximum raw write size as the size used by the client to perform raw reads with. The maximum allowed are 65535 bytes for a raw read request. Likewise, the maximum raw write size is 65535 bytes, too.
Recalculated the overhead for the SMB_COM_WRITE_RAW command, and it's 63 bytes, not 4.
Unless smb_proc_write_raw() finds that sending the packet results in a transmission error, it will try to pick up the server responses. Previously, it would not even try that, which could deadlock the client<->server message exchange.
Fixed decoding of maximum buffer size; this used to come out as 0, which made smbfs switch back to the default minimum supported (1024 bytes).
Corrected use of the maximum raw write size as the size used by the client to perform raw reads with. The maximum allowed are 65535 bytes for a raw read request. Likewise, the maximum raw write size is 65535 bytes, too.
Simplified the raw read portion of smba_read() by removing the test that avoids dropping into a read loop below. The loop handles the special case well.
Recalculated the overhead for SMB_COM_READ. It's still 52 bytes, but now the documentation states how this number comes about.
Recalculated the overhead for SMB_COM_WRITE. It's 52 bytes and not 56 bytes.
Fixed decoding of maximum buffer size; this used to come out as 0, which made smbfs switch back to the default minimum supported (1024 bytes).
Corrected use of the maximum raw write size as the size used by the client to perform raw reads with. The maximum allowed are 65535 bytes for a raw read request. Likewise, the maximum raw write size is 65535 bytes, too.
Because the series of write operations are not wrapped into transactions, the cached file size needs to be updated if at least one write access succeeds.
Simplified the directory cache cleanup.
The SMB message length bit #17 is now properly filled in with the respective bit of the payload length.
Added the remaining error codes covered by the "Common Internet File System (CIFS) Protocol" documentation.
smbfs will not work properly with the standard 4K stack size. Testing revealed that 20K are safer, which is why the program startup code now provides as much if needed.
The client capabilities were never properly initialized, which could have led to any number of interesting side-effects, such as NT status information being transmitted instead.
The client now announces itself as a Unix system if the server does so, too.
The record locking command did not initialize the oplock level at all. Fixed.
Other SMB packets were not completely initialized either, which has been corrected.
SMB packet decoder now ignores empty parameter/data and will not try to decode and display these.
SMB_COM_SEARCH decoding had the sources mixed up, decoding client->server traffic as server->client traffic and the other way round.
Decoding of the status field now works properly again in the non-"status32" case.
smba_read() failed to register the number of bytes read successfully by smb_proc_read_raw(). This made all files appear to be empty.
smba_write() did not update the offset value correctly if the first smb_proc_write() call had succeeded.
Decoding is performed before the session header type is checked and, if necessary, rejected.
smb_receive_raw() now only accepts a single session header type (message) and rejects all others. At this stage "positive session response" should no longer appear.
All functions now follow a consistent error reporting scheme. A negative return value always indicates an error condition. A return value of 0 always indicates success, except for the few functions which have to return a count of bytes or directory records upon success.
Previously, it was hard to tell what function returned what in case of error, which led the bugs in smba_write() and smba_read(), neither of which gracefully fell back on SMB_COM_WRITE/SMB_COM_READ, respectively if SMB_COM_WRITE_RAW/SMB_COM_READ_RAW failed.
State variables are now named according to their respective purpose where possible. Previously, it was "rval", "errnum", "result" which were used almost interchangeably regardless of purpose.
Turns out that the length filled in by smb_setup_header() was not actually off by 4 bytes but entirely correct. This caused SMB packets to be sent four bytes short, and probably causing some SMB server implementations to ignore them altogether.
A successful SMB_COM_WRITE_RAW command may cause the server to send interim progress update responses, ending with a final SMB_COM_WRITE_RAW_COMPLETE message. This is now handled correctly.