mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-29 06:55:45 -04:00
Implement common validation, compression and decompression for SMB2 compression transforms. Support unchained LZ77 and chained NONE, LZ77 and Pattern_V1 payloads. Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
29 lines
824 B
C
29 lines
824 B
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (C) 2026 Namjae Jeon <linkinjeon@kernel.org>
|
|
*/
|
|
#ifndef _COMMON_SMB_COMPRESS_H
|
|
#define _COMMON_SMB_COMPRESS_H
|
|
|
|
#include "../smb2pdu.h"
|
|
|
|
/*
|
|
* SMB3_COMPRESS_NONE is valid only in chained payload headers. It is never
|
|
* negotiated as a compression algorithm.
|
|
*/
|
|
static __always_inline bool smb_compress_alg_valid(__le16 alg, bool valid_none)
|
|
{
|
|
if (alg == SMB3_COMPRESS_NONE)
|
|
return valid_none;
|
|
|
|
return alg == SMB3_COMPRESS_LZ77 || alg == SMB3_COMPRESS_PATTERN;
|
|
}
|
|
|
|
int smb_compression_decompress(__le16 alg, bool allow_chained,
|
|
const void *src, u32 slen, void *dst, u32 dlen);
|
|
int smb_compression_compress_chained(__le16 alg, bool allow_pattern,
|
|
const void *src, u32 slen,
|
|
void *dst, u32 *dlen);
|
|
|
|
#endif /* _COMMON_SMB_COMPRESS_H */
|