4#ifndef PROTOCORE_TRANSPORT_ZLIB_H
5#define PROTOCORE_TRANSPORT_ZLIB_H
25#define SSH_ZLIB_HASH_BITS 13
26#define SSH_ZLIB_HASH_SIZE (1 << SSH_ZLIB_HASH_BITS)
29#define SSH_ZLIB_WORK_SIZE ((size_t)PROTOCORE_SSH_ZLIB_WINDOW + (size_t)PROTOCORE_SSH_ZLIB_MAX_IN)
57static inline size_t ssh_deflate_bound(
size_t src_len)
59 return 2 + src_len + (src_len >> 3) + 32;
65 void (*init)(uint8_t *,
SshDeflate *, uint8_t *, uint16_t *, uint16_t *, uint16_t *, uint8_t *, uint16_t *,
67 int (*packet)(uint8_t *,
SshDeflate *,
const uint8_t *, size_t, uint8_t *, size_t,
size_t *);
84 uint8_t *ll_len, uint16_t *d_code, uint8_t *d_len);
97 size_t dst_cap,
size_t *out_len);
#define PROTOCORE_NS_LAYOUT(T,...)
Pin every dispatch slot of a table that is nothing but function pointers.
#define PROTOCORE_NS
Storage for a dispatch table. The const is load bearing.
Streaming server-to-client DEFLATE compressor (one per SSH connection).
uint8_t * d_len
their bit lengths, 30 entries.
uint16_t * prev
hash chain (absolute-position indexed), SSH_ZLIB_WORK_SIZE entries.
proto_bool header_sent
true once the leading 2-byte zlib header has been emitted.
size_t hist
bytes of history currently at the front of work.
uint8_t * work
history+input work buffer, capacity SSH_ZLIB_WORK_SIZE.
uint16_t * ll_code
fixed literal/length Huffman codes (bit-reversed), 288 entries.
uint16_t * d_code
fixed distance Huffman codes (bit-reversed), 30 entries.
uint8_t * ll_len
their bit lengths, 288 entries.
uint16_t * head
hash bucket heads, SSH_ZLIB_HASH_SIZE entries.
Dispatch table. Addressed by offset, so the layout is asserted below.
void(* init)(uint8_t *, SshDeflate *, uint8_t *, uint16_t *, uint16_t *, uint16_t *, uint8_t *, uint16_t *, uint8_t *)
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTOCORE_END_DECLS
void protocore_zlib_init(uint8_t *work, SshDeflate *z, uint8_t *win, uint16_t *head, uint16_t *prev, uint16_t *ll_code, uint8_t *ll_len, uint16_t *d_code, uint8_t *d_len)
Bind caller memory to a compressor and reset it to stream start.
int protocore_zlib_packet(uint8_t *work, SshDeflate *z, const uint8_t *src, size_t src_len, uint8_t *dst, size_t dst_cap, size_t *out_len)
Compress one packet payload, continuing the session's zlib stream. .
PROTOCORE_NS ZlibNs Zlib PROTOCORE_UNUSED
Module namespace.