1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (C) 2026 Namjae Jeon <linkinjeon@kernel.org>
4 */
5 #ifndef _COMMON_SMB_COMPRESS_H
6 #define _COMMON_SMB_COMPRESS_H
7
8 #include "../smb2pdu.h"
9
10 /*
11 * SMB3_COMPRESS_NONE is valid only in chained payload headers. It is never
12 * negotiated as a compression algorithm.
13 */
smb_compress_alg_valid(__le16 alg,bool valid_none)14 static __always_inline bool smb_compress_alg_valid(__le16 alg, bool valid_none)
15 {
16 if (alg == SMB3_COMPRESS_NONE)
17 return valid_none;
18
19 return alg == SMB3_COMPRESS_LZ77 || alg == SMB3_COMPRESS_PATTERN;
20 }
21
22 int smb_compression_decompress(__le16 alg, bool allow_chained,
23 bool allow_pattern, const void *src, u32 slen,
24 void *dst, u32 dlen);
25 int smb_compression_compress_chained(__le16 alg, bool allow_pattern,
26 const void *src, u32 slen,
27 void *dst, u32 *dlen);
28
29 #endif /* _COMMON_SMB_COMPRESS_H */
30