|
ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
|
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. | |
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.
| #define SSH_ZLIB_HASH_BITS 13 |
| #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) |
| 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.
| work | PROTOCORE_ZLIB_BORROW bytes the caller took. Not held past the call. |
| z | the compressor to initialize |
| win | history+input buffer, >= SSH_ZLIB_WORK_SIZE bytes |
| head | hash heads, SSH_ZLIB_HASH_SIZE uint16 entries |
| prev | hash chain, SSH_ZLIB_WORK_SIZE uint16 entries |
| ll_code | Ll code |
| ll_len | Ll len |
| d_code | D code |
| d_len | D len |
| 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. .
| work | PROTOCORE_ZLIB_BORROW bytes the caller took. Not held past the call. |
| z | the compressor |
| src | Src |
| src_len | Src len |
| dst | Dst |
| dst_cap | Dst cap |
| out_len | set to the compressed length on success |
| PROTOCORE_NS ZlibNs Zlib PROTOCORE_UNUSED = {.init = protocore_zlib_init, .packet = protocore_zlib_packet} |