ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
zlib.h File Reference

RFC 1950 / 1951 deflate, as SSH negotiates it. More...

#include "protocore_config.h"

Go to the source code of this file.

Classes

struct  SshDeflate
 Streaming server-to-client DEFLATE compressor (one per SSH connection). More...
 
struct  ZlibNs
 Dispatch table. Addressed by offset, so the layout is asserted below. More...
 

Macros

#define SSH_ZLIB_HASH_BITS   13
 Hash-table buckets for the LZ77 3-byte match search (2^bits).
 
#define SSH_ZLIB_HASH_SIZE   (1 << SSH_ZLIB_HASH_BITS)
 
#define SSH_ZLIB_WORK_SIZE   ((size_t)PROTOCORE_SSH_ZLIB_WINDOW + (size_t)PROTOCORE_SSH_ZLIB_MAX_IN)
 Work buffer capacity the compressor needs: window history + one input payload.
 

Functions

 PROTOCORE_NS_LAYOUT (ZlibNs, init, packet)
 
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. .
 

Variables

PROTOCORE_NS ZlibNs Zlib PROTOCORE_UNUSED = {.init = protocore_zlib_init, .packet = protocore_zlib_packet}
 Module namespace.
 

Detailed Description

RFC 1950 / 1951 deflate, as SSH negotiates it.

work is bytes the CALLER holds. This module reads none of them: it carries nothing between calls, so there is no state to keep and nothing to wipe. The parameter is there so a caller drives every namespace the same way.

Definition in file zlib.h.

Macro Definition Documentation

◆ SSH_ZLIB_HASH_BITS

#define SSH_ZLIB_HASH_BITS   13

Hash-table buckets for the LZ77 3-byte match search (2^bits).

Definition at line 25 of file zlib.h.

◆ SSH_ZLIB_HASH_SIZE

#define SSH_ZLIB_HASH_SIZE   (1 << SSH_ZLIB_HASH_BITS)

Definition at line 26 of file zlib.h.

◆ SSH_ZLIB_WORK_SIZE

#define SSH_ZLIB_WORK_SIZE   ((size_t)PROTOCORE_SSH_ZLIB_WINDOW + (size_t)PROTOCORE_SSH_ZLIB_MAX_IN)

Work buffer capacity the compressor needs: window history + one input payload.

Definition at line 29 of file zlib.h.

Function Documentation

◆ PROTOCORE_NS_LAYOUT()

PROTOCORE_NS_LAYOUT ( ZlibNs  ,
init  ,
packet   
)

◆ protocore_zlib_init()

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.

Parameters
workPROTOCORE_ZLIB_BORROW bytes the caller took. Not held past the call.
zthe compressor to initialize
winhistory+input buffer, >= SSH_ZLIB_WORK_SIZE bytes
headhash heads, SSH_ZLIB_HASH_SIZE uint16 entries
prevhash chain, SSH_ZLIB_WORK_SIZE uint16 entries
ll_codeLl code
ll_lenLl len
d_codeD code
d_lenD len

◆ protocore_zlib_packet()

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. .

Parameters
workPROTOCORE_ZLIB_BORROW bytes the caller took. Not held past the call.
zthe compressor
srcSrc
src_lenSrc len
dstDst
dst_capDst cap
out_lenset to the compressed length on success
Returns
The int.

Variable Documentation

◆ PROTOCORE_UNUSED

PROTOCORE_NS ZlibNs Zlib PROTOCORE_UNUSED = {.init = protocore_zlib_init, .packet = protocore_zlib_packet}

Module namespace.

Definition at line 100 of file zlib.h.