Expand description
SMB3 compression: the COMPRESSION_TRANSFORM_HEADER ([MS-SMB2] §2.2.42) and SMB2_COMPRESSION_CAPABILITIES negotiate context ([MS-SMB2] §2.2.3.1.3).
LZNT1 (compress + decompress) is delegated to the lznt1 crate; Pattern_V1
(a repeated-byte payload, §2.2.42.1) is expanded inline. Only the unchained
transform form is produced; both forms are accepted on receive.
Modules§
- algo
- Compression algorithm ids ([MS-SMB2] §2.2.3.1.3).
Constants§
- CAP_
FLAG_ CHAINED - SMB2_COMPRESSION_CAPABILITIES_FLAG_CHAINED ([MS-SMB2] §2.2.3.1.3): advertised in the negotiate context Flags field when chained compression is supported.
- PROTOCOL_
ID - COMPRESSION_TRANSFORM ProtocolId:
0xFC 'S' 'M' 'B'. - SUPPORTED
- Algorithms this server can both send and receive.
Functions§
- build_
compression_ caps - Encode the server
SMB2_COMPRESSION_CAPABILITIEScontext data advertisingalgos, setting SMB2_COMPRESSION_CAPABILITIES_FLAG_CHAINED whenchained. - compress_
message - Wrap
msgin an unchained LZNT1 COMPRESSION_TRANSFORM. ReturnsNonewhen the algorithm is unsupported or compression does not shrink the message (the caller then sends it uncompressed). - compress_
message_ chained - Wrap
msgin a chained COMPRESSION_TRANSFORM_HEADER ([MS-SMB2] \u00a72.2.42.2), emitting a Pattern_V1 payload for each long single-byte run and analgorithm(or uncompressed NONE) payload for the data between runs ([MS-SMB2] \u00a73.1.4.4). For a READ response the SMB2 header and READ structure are carried in a leading NONE payload so only the file data is compressed. ReturnsNonewhen the result would not shrink the message. - decompress_
message - Decompress a whole
\xFCSMBCOMPRESSION_TRANSFORM frame into the original SMB2 message.Noneon malformed input or an unsupported algorithm. - negotiate_
algos - Intersect the client’s offered algorithms with the server’s, preserving the client’s order so the negotiate response echoes the requested CompressionIds when all are supported ([MS-SMB2] §3.3.5.4).
- parse_
compression_ caps - Parse a client
SMB2_COMPRESSION_CAPABILITIEScontext (§2.2.3.1.3) into its advertised algorithm list. - parse_
compression_ flags - Read the Flags field of a client
SMB2_COMPRESSION_CAPABILITIEScontext (§2.2.3.1.3).