1d4afb5ceSopenharmony_ci/*
2d4afb5ceSopenharmony_ci * libwebsockets - small server side websockets and web server implementation
3d4afb5ceSopenharmony_ci *
4d4afb5ceSopenharmony_ci * Copyright (C) 2010 - 2019 Andy Green <andy@warmcat.com>
5d4afb5ceSopenharmony_ci *
6d4afb5ceSopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy
7d4afb5ceSopenharmony_ci * of this software and associated documentation files (the "Software"), to
8d4afb5ceSopenharmony_ci * deal in the Software without restriction, including without limitation the
9d4afb5ceSopenharmony_ci * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10d4afb5ceSopenharmony_ci * sell copies of the Software, and to permit persons to whom the Software is
11d4afb5ceSopenharmony_ci * furnished to do so, subject to the following conditions:
12d4afb5ceSopenharmony_ci *
13d4afb5ceSopenharmony_ci * The above copyright notice and this permission notice shall be included in
14d4afb5ceSopenharmony_ci * all copies or substantial portions of the Software.
15d4afb5ceSopenharmony_ci *
16d4afb5ceSopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17d4afb5ceSopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18d4afb5ceSopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19d4afb5ceSopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20d4afb5ceSopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21d4afb5ceSopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22d4afb5ceSopenharmony_ci * IN THE SOFTWARE.
23d4afb5ceSopenharmony_ci */
24d4afb5ceSopenharmony_ci
25d4afb5ceSopenharmony_ci#if defined(LWS_WITH_MINIZ)
26d4afb5ceSopenharmony_ci#include <miniz.h>
27d4afb5ceSopenharmony_ci#else
28d4afb5ceSopenharmony_ci#include <zlib.h>
29d4afb5ceSopenharmony_ci#endif
30d4afb5ceSopenharmony_ci
31d4afb5ceSopenharmony_ci#define DEFLATE_FRAME_COMPRESSION_LEVEL_SERVER 1
32d4afb5ceSopenharmony_ci#define DEFLATE_FRAME_COMPRESSION_LEVEL_CLIENT Z_DEFAULT_COMPRESSION
33d4afb5ceSopenharmony_ci
34d4afb5ceSopenharmony_cienum arg_indexes {
35d4afb5ceSopenharmony_ci	PMD_SERVER_NO_CONTEXT_TAKEOVER,
36d4afb5ceSopenharmony_ci	PMD_CLIENT_NO_CONTEXT_TAKEOVER,
37d4afb5ceSopenharmony_ci	PMD_SERVER_MAX_WINDOW_BITS,
38d4afb5ceSopenharmony_ci	PMD_CLIENT_MAX_WINDOW_BITS,
39d4afb5ceSopenharmony_ci	PMD_RX_BUF_PWR2,
40d4afb5ceSopenharmony_ci	PMD_TX_BUF_PWR2,
41d4afb5ceSopenharmony_ci	PMD_COMP_LEVEL,
42d4afb5ceSopenharmony_ci	PMD_MEM_LEVEL,
43d4afb5ceSopenharmony_ci
44d4afb5ceSopenharmony_ci	PMD_ARG_COUNT
45d4afb5ceSopenharmony_ci};
46d4afb5ceSopenharmony_ci
47d4afb5ceSopenharmony_cistruct lws_ext_pm_deflate_priv {
48d4afb5ceSopenharmony_ci	z_stream rx;
49d4afb5ceSopenharmony_ci	z_stream tx;
50d4afb5ceSopenharmony_ci
51d4afb5ceSopenharmony_ci	unsigned char *buf_rx_inflated; /* RX inflated output buffer */
52d4afb5ceSopenharmony_ci	unsigned char *buf_tx_deflated; /* TX deflated output buffer */
53d4afb5ceSopenharmony_ci
54d4afb5ceSopenharmony_ci	unsigned char *buf_tx_holding;
55d4afb5ceSopenharmony_ci
56d4afb5ceSopenharmony_ci	size_t count_rx_between_fin;
57d4afb5ceSopenharmony_ci	size_t count_tx_between_fin;
58d4afb5ceSopenharmony_ci
59d4afb5ceSopenharmony_ci	size_t len_tx_holding;
60d4afb5ceSopenharmony_ci
61d4afb5ceSopenharmony_ci	unsigned char args[PMD_ARG_COUNT];
62d4afb5ceSopenharmony_ci
63d4afb5ceSopenharmony_ci	unsigned char tx_first_frame_type;
64d4afb5ceSopenharmony_ci
65d4afb5ceSopenharmony_ci	unsigned char tx_init:1;
66d4afb5ceSopenharmony_ci	unsigned char rx_init:1;
67d4afb5ceSopenharmony_ci	unsigned char compressed_out:1;
68d4afb5ceSopenharmony_ci};
69d4afb5ceSopenharmony_ci
70