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

RFC 4253 sec 6.2 compression: the negotiated stream, both directions. More...

#include "protocore_config.h"

Go to the source code of this file.

Classes

struct  CompNs
 Dispatch table. Addressed by offset, so the layout is asserted below. More...
 

Typedefs

typedef enum PROTO_ENUM_PACKED SshCompAlg
 Negotiated compression algorithm, held per direction.
 

Enumerations

enum  PROTO_ENUM_PACKED { SSH_COMP_NONE = 0 , SSH_COMP_ZLIB = 1 , SSH_COMP_ZLIB_DELAYED = 2 }
 Negotiated compression algorithm, held per direction. More...
 

Functions

 PROTOCORE_NS_LAYOUT (CompNs, reset, set_s2c, on_newkeys, on_auth_success, s2c_active, s2c, set_c2s, c2s_active, c2s)
 
void protocore_comp_reset (uint8_t *work, uint8_t i)
 Reset compression state for slot i (fresh connection). Does NOT run .
 
void protocore_comp_set_s2c (uint8_t *work, uint8_t i, SshCompAlg alg)
 Record the s2c algorithm negotiated in KEXINIT (SshCompAlg).
 
void protocore_comp_on_newkeys (uint8_t *work, uint8_t i)
 NEWKEYS completed: start the stream now if zlib was negotiated .
 
void protocore_comp_on_auth_success (uint8_t *work, uint8_t i)
 SSH_MSG_USERAUTH_SUCCESS sent: start the stream if .
 
proto_bool protocore_comp_s2c_active (uint8_t *work, uint8_t i)
 True once the s2c stream is active and outbound payloads must be .
 
int protocore_comp_s2c (uint8_t *work, uint8_t i, const uint8_t *src, size_t src_len, uint8_t *dst, size_t dst_cap, size_t *out_len)
 Compress one outbound payload, continuing the session's zlib stream.
 
void protocore_comp_set_c2s (uint8_t *work, uint8_t i, SshCompAlg alg)
 Record the client-to-server algorithm negotiated in KEXINIT .
 
proto_bool protocore_comp_c2s_active (uint8_t *work, uint8_t i)
 True once the c2s stream is active and inbound payloads must be .
 
int protocore_comp_c2s (uint8_t *work, uint8_t i, const uint8_t *src, size_t src_len, uint8_t *dst, size_t dst_cap, size_t *out_len)
 Decompress one inbound payload, continuing the session's .
 
uint8_t * protocore_ssh_comp_span (void)
 The bytes every entry here runs out of: one compressor per SSH connection.
 

Variables

PROTOCORE_NS CompNs Comp PROTOCORE_UNUSED
 Module namespace.
 

Detailed Description

RFC 4253 sec 6.2 compression: the negotiated stream, both directions.

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

Typedef Documentation

◆ SshCompAlg

Negotiated compression algorithm, held per direction.

Enumeration Type Documentation

◆ PROTO_ENUM_PACKED

Negotiated compression algorithm, held per direction.

Enumerator
SSH_COMP_NONE 

no compression

SSH_COMP_ZLIB 

"zlib" (RFC 4253) - starts right after NEWKEYS

SSH_COMP_ZLIB_DELAYED 

"zlib@openssh.com" - starts after SSH_MSG_USERAUTH_SUCCESS

Definition at line 25 of file comp.h.

Function Documentation

◆ PROTOCORE_NS_LAYOUT()

PROTOCORE_NS_LAYOUT ( CompNs  ,
reset  ,
set_s2c  ,
on_newkeys  ,
on_auth_success  ,
s2c_active  ,
s2c  ,
set_c2s  ,
c2s_active  ,
c2s   
)

◆ protocore_comp_reset()

void protocore_comp_reset ( uint8_t *  work,
uint8_t  i 
)

Reset compression state for slot i (fresh connection). Does NOT run .

Parameters
workPROTOCORE_COMP_BORROW bytes the caller took. Not held past the call.
iI

◆ protocore_comp_set_s2c()

void protocore_comp_set_s2c ( uint8_t *  work,
uint8_t  i,
SshCompAlg  alg 
)

Record the s2c algorithm negotiated in KEXINIT (SshCompAlg).

Parameters
workPROTOCORE_COMP_BORROW bytes the caller took. Not held past the call.
iI
algAlg

◆ protocore_comp_on_newkeys()

void protocore_comp_on_newkeys ( uint8_t *  work,
uint8_t  i 
)

NEWKEYS completed: start the stream now if zlib was negotiated .

Parameters
workPROTOCORE_COMP_BORROW bytes the caller took. Not held past the call.
iI

◆ protocore_comp_on_auth_success()

void protocore_comp_on_auth_success ( uint8_t *  work,
uint8_t  i 
)

SSH_MSG_USERAUTH_SUCCESS sent: start the stream if .

Parameters
workPROTOCORE_COMP_BORROW bytes the caller took. Not held past the call.
iI

◆ protocore_comp_s2c_active()

proto_bool protocore_comp_s2c_active ( uint8_t *  work,
uint8_t  i 
)

True once the s2c stream is active and outbound payloads must be .

Parameters
workPROTOCORE_COMP_BORROW bytes the caller took. Not held past the call.
iI
Returns
PROTO_TRUE on success.

◆ protocore_comp_s2c()

int protocore_comp_s2c ( uint8_t *  work,
uint8_t  i,
const uint8_t *  src,
size_t  src_len,
uint8_t *  dst,
size_t  dst_cap,
size_t *  out_len 
)

Compress one outbound payload, continuing the session's zlib stream.

Parameters
workPROTOCORE_COMP_BORROW bytes the caller took. Not held past the call.
iI
srcSrc
src_lenSrc len
dstDst
dst_capDst cap
out_lenOut len
Returns
The int.

◆ protocore_comp_set_c2s()

void protocore_comp_set_c2s ( uint8_t *  work,
uint8_t  i,
SshCompAlg  alg 
)

Record the client-to-server algorithm negotiated in KEXINIT .

Parameters
workPROTOCORE_COMP_BORROW bytes the caller took. Not held past the call.
iI
algAlg

◆ protocore_comp_c2s_active()

proto_bool protocore_comp_c2s_active ( uint8_t *  work,
uint8_t  i 
)

True once the c2s stream is active and inbound payloads must be .

Parameters
workPROTOCORE_COMP_BORROW bytes the caller took. Not held past the call.
iI
Returns
PROTO_TRUE on success.

◆ protocore_comp_c2s()

int protocore_comp_c2s ( uint8_t *  work,
uint8_t  i,
const uint8_t *  src,
size_t  src_len,
uint8_t *  dst,
size_t  dst_cap,
size_t *  out_len 
)

Decompress one inbound payload, continuing the session's .

Parameters
workPROTOCORE_COMP_BORROW bytes the caller took. Not held past the call.
iI
srcSrc
src_lenSrc len
dstDst
dst_capDst cap
out_lenOut len
Returns
The int.

◆ protocore_ssh_comp_span()

uint8_t * protocore_ssh_comp_span ( void  )

The bytes every entry here runs out of: one compressor per SSH connection.

Stated beside the namespace rather than on it: an entry takes a borrow, and this is where that borrow comes from. The transport and the server both drive the same connection's streams, so the bytes belong to this module rather than to either caller. Taken once from the end of the plaintext pool, which no mark and no release walks, because a zlib@.nosp@m.open.nosp@m.ssh.c.nosp@m.om stream takes its window over from one packet to the next.

Returns
the span.

Variable Documentation

◆ PROTOCORE_UNUSED

PROTOCORE_NS CompNs Comp PROTOCORE_UNUSED
Initial value:
.on_auth_success = protocore_comp_on_auth_success,
int protocore_comp_s2c(uint8_t *work, uint8_t i, const uint8_t *src, size_t src_len, uint8_t *dst, size_t dst_cap, size_t *out_len)
Compress one outbound payload, continuing the session's zlib stream.
proto_bool protocore_comp_c2s_active(uint8_t *work, uint8_t i)
True once the c2s stream is active and inbound payloads must be .
void protocore_comp_set_c2s(uint8_t *work, uint8_t i, SshCompAlg alg)
Record the client-to-server algorithm negotiated in KEXINIT .
void protocore_comp_on_auth_success(uint8_t *work, uint8_t i)
SSH_MSG_USERAUTH_SUCCESS sent: start the stream if .
void protocore_comp_set_s2c(uint8_t *work, uint8_t i, SshCompAlg alg)
Record the s2c algorithm negotiated in KEXINIT (SshCompAlg).
proto_bool protocore_comp_s2c_active(uint8_t *work, uint8_t i)
True once the s2c stream is active and outbound payloads must be .
void protocore_comp_reset(uint8_t *work, uint8_t i)
Reset compression state for slot i (fresh connection). Does NOT run .
int protocore_comp_c2s(uint8_t *work, uint8_t i, const uint8_t *src, size_t src_len, uint8_t *dst, size_t dst_cap, size_t *out_len)
Decompress one inbound payload, continuing the session's .
void protocore_comp_on_newkeys(uint8_t *work, uint8_t i)
NEWKEYS completed: start the stream now if zlib was negotiated .

Module namespace.

Definition at line 134 of file comp.h.