|
ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
|
Low-level field-coding primitives shared by HPACK and QPACK. More...
#include "protocore_config.h"Go to the source code of this file.
Classes | |
| struct | HpackPrimNs |
| Dispatch table. Addressed by offset, so the layout is asserted below. More... | |
Functions | |
| PROTOCORE_NS_LAYOUT (HpackPrimNs, encode_int, decode_int, huff_encode, huff_len, huff_decode, decode_str, encode_str) | |
| size_t | protocore_hpack_prim_encode_int (uint8_t *work, uint8_t *out, size_t cap, uint8_t prefix_bits, uint8_t flags, uint32_t value) |
| A prefix-prefix_bits integer with the high flags bits set in byte 0. | |
| proto_bool | protocore_hpack_prim_decode_int (uint8_t *work, const uint8_t *in, size_t len, uint8_t prefix_bits, size_t *consumed, uint32_t *value) |
| The same integer back; sets consumed and value, false if malformed. | |
| size_t | protocore_hpack_prim_huff_encode (uint8_t *work, uint8_t *out, size_t cap, const char *s, size_t n) |
| Huffman-encode n bytes of s (RFC 7541 Appendix B); bytes written,. | |
| size_t | protocore_hpack_prim_huff_len (uint8_t *work, const char *s, size_t n) |
| The Huffman byte length of s without encoding it, which is what. | |
| proto_bool | protocore_hpack_prim_huff_decode (uint8_t *work, const uint8_t *in, size_t n, char *out, size_t cap, size_t *out_len) |
| Huffman-decode n bytes into out; sets out_len, false on a bad code. | |
| proto_bool | protocore_hpack_prim_decode_str (uint8_t *work, const uint8_t *block, size_t len, size_t *pos, char *out, size_t cap, size_t *out_len) |
| A length-prefixed string literal (H bit at 0x80 + a 7-bit length . | |
| size_t | protocore_hpack_prim_encode_str (uint8_t *work, uint8_t *out, size_t cap, const char *s, size_t n) |
| The same literal out, Huffman-coded when that is the shorter of the . | |
Variables | |
| PROTOCORE_NS HpackPrimNs HpackPrim | PROTOCORE_UNUSED |
| Module namespace. | |
Low-level field-coding primitives shared by HPACK and QPACK.
RFC 7541 defines two primitives that RFC 9204 (QPACK) reuses verbatim: the prefix-integer coding (RFC 7541 sec 5.1) and the canonical Huffman code (RFC 7541 Appendix B, referenced by RFC 9204 sec 5). This module is the single copy of both, so HTTP/2's HPACK and HTTP/3's QPACK share one implementation and one Huffman table instead of duplicating ~1 KB of tables.
Pure and host-tested (via the HPACK and QPACK codec tests). Zero heap.
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 hpack_prim.h.
| PROTOCORE_NS_LAYOUT | ( | HpackPrimNs | , |
| encode_int | , | ||
| decode_int | , | ||
| huff_encode | , | ||
| huff_len | , | ||
| huff_decode | , | ||
| decode_str | , | ||
| encode_str | |||
| ) |
| size_t protocore_hpack_prim_encode_int | ( | uint8_t * | work, |
| uint8_t * | out, | ||
| size_t | cap, | ||
| uint8_t | prefix_bits, | ||
| uint8_t | flags, | ||
| uint32_t | value | ||
| ) |
A prefix-prefix_bits integer with the high flags bits set in byte 0.
| work | PROTOCORE_HPACK_PRIM_BORROW bytes the caller took. Not held past the call. |
| out | Out |
| cap | Cap |
| prefix_bits | Prefix bits |
| flags | Flags |
| value | Value |
| proto_bool protocore_hpack_prim_decode_int | ( | uint8_t * | work, |
| const uint8_t * | in, | ||
| size_t | len, | ||
| uint8_t | prefix_bits, | ||
| size_t * | consumed, | ||
| uint32_t * | value | ||
| ) |
The same integer back; sets consumed and value, false if malformed.
| work | PROTOCORE_HPACK_PRIM_BORROW bytes the caller took. Not held past the call. |
| in | In |
| len | Len |
| prefix_bits | Prefix bits |
| consumed | Consumed |
| value | Value |
| size_t protocore_hpack_prim_huff_encode | ( | uint8_t * | work, |
| uint8_t * | out, | ||
| size_t | cap, | ||
| const char * | s, | ||
| size_t | n | ||
| ) |
Huffman-encode n bytes of s (RFC 7541 Appendix B); bytes written,.
| work | PROTOCORE_HPACK_PRIM_BORROW bytes the caller took. Not held past the call. |
| out | Out |
| cap | Cap |
| s | S |
| n | N |
| size_t protocore_hpack_prim_huff_len | ( | uint8_t * | work, |
| const char * | s, | ||
| size_t | n | ||
| ) |
The Huffman byte length of s without encoding it, which is what.
| work | PROTOCORE_HPACK_PRIM_BORROW bytes the caller took. Not held past the call. |
| s | S |
| n | N |
| proto_bool protocore_hpack_prim_huff_decode | ( | uint8_t * | work, |
| const uint8_t * | in, | ||
| size_t | n, | ||
| char * | out, | ||
| size_t | cap, | ||
| size_t * | out_len | ||
| ) |
Huffman-decode n bytes into out; sets out_len, false on a bad code.
| work | PROTOCORE_HPACK_PRIM_BORROW bytes the caller took. Not held past the call. |
| in | In |
| n | N |
| out | Out |
| cap | Cap |
| out_len | Out len |
| proto_bool protocore_hpack_prim_decode_str | ( | uint8_t * | work, |
| const uint8_t * | block, | ||
| size_t | len, | ||
| size_t * | pos, | ||
| char * | out, | ||
| size_t | cap, | ||
| size_t * | out_len | ||
| ) |
A length-prefixed string literal (H bit at 0x80 + a 7-bit length .
| work | PROTOCORE_HPACK_PRIM_BORROW bytes the caller took. Not held past the call. |
| block | Block |
| len | Len |
| pos | Pos |
| out | Out |
| cap | Cap |
| out_len | Out len |
| size_t protocore_hpack_prim_encode_str | ( | uint8_t * | work, |
| uint8_t * | out, | ||
| size_t | cap, | ||
| const char * | s, | ||
| size_t | n | ||
| ) |
The same literal out, Huffman-coded when that is the shorter of the .
| work | PROTOCORE_HPACK_PRIM_BORROW bytes the caller took. Not held past the call. |
| out | Out |
| cap | Cap |
| s | S |
| n | N |
| PROTOCORE_NS HpackPrimNs HpackPrim PROTOCORE_UNUSED |
Module namespace.
Definition at line 126 of file hpack_prim.h.