75 f->
peer_window = (w + add < w) ? 0xFFFFFFFFu : (w + add);
132 memcpy(out + 9, data, len);
Fixed-width integer serializers into a raw uint8_t* buffer - one source of truth.
size_t pc_wr32be(uint8_t *p, uint32_t v)
Write v big-endian at p.
User-facing configuration for ProtoCore.
#define SSH_CHAN_MAX_PACKET
Maximum SSH channel data payload the server advertises it can receive per message.
void pc_ssh_flow_init(SshFlow *f, uint32_t local_window, uint32_t peer_window, uint32_t peer_max_pkt)
Start a channel's windows: ours at local_window, the peer's at what it advertised.
void pc_ssh_flow_local_credit(SshFlow *f, uint32_t add)
Credit our window by add, once that WINDOW_ADJUST has actually been sent.
int32_t pc_ssh_sig_build_window_adjust(uint32_t peer_id, uint32_t add, uint8_t *out, size_t cap, size_t *out_len)
CHANNEL_WINDOW_ADJUST granting add more bytes. Credit the window only once this is sent.
bool pc_ssh_flow_recv_take(SshFlow *f, uint32_t n)
Account n inbound bytes against our window.
int32_t pc_ssh_sig_build_open_confirm(const SshFlow *f, uint32_t peer_id, uint32_t local_id, uint8_t *out, size_t cap, size_t *out_len)
CHANNEL_OPEN_CONFIRMATION, advertising our current window and maximum packet size.
int32_t pc_ssh_sig_build_open_failure(uint8_t *out, size_t cap, uint32_t peer_id, uint32_t reason, size_t *out_len)
CHANNEL_OPEN_FAILURE. reason: 1 admin-prohibited, 2 connect-failed, 3 unknown-type,...
uint32_t pc_ssh_flow_send_cap(const SshFlow *f, uint32_t want)
Clamp a would-be send to what the peer currently permits.
int32_t pc_ssh_sig_build_data(SshFlow *f, uint32_t peer_id, const uint8_t *data, size_t len, uint8_t *out, size_t cap, size_t *out_len)
CHANNEL_DATA carrying len bytes, and account them against the peer's window.
bool pc_ssh_flow_send_allows(const SshFlow *f, size_t len)
True if len bytes fit both the peer's remaining window and its maximum packet size.
void pc_ssh_flow_send_take(SshFlow *f, uint32_t n)
Account n outbound bytes against the peer's window (call only after send_allows()).
uint32_t pc_ssh_flow_peer_window(const SshFlow *f)
Bytes we may still send the peer - the bound a producer sizes its next read to.
void pc_ssh_flow_peer_add(SshFlow *f, uint32_t add)
Credit the peer's window from an inbound WINDOW_ADJUST.
bool pc_ssh_flow_replenish_due(const SshFlow *f, uint32_t *add)
Decide whether a WINDOW_ADJUST is due, and for how much. Does not mutate.
int32_t pc_ssh_sig_build_close(uint32_t peer_id, uint8_t *out, size_t cap, size_t *out_len)
CHANNEL_EOF followed by CHANNEL_CLOSE, as one 10-byte pair.
SSH channel flow control - the RFC 4254 sec 5.2 window pair and nothing else.
SSH binary packet protocol: framing, AES-256-CTR encryption, HMAC-SHA2-256 integrity,...
#define SSH_MSG_CHANNEL_EOF
#define SSH_MSG_CHANNEL_DATA
#define SSH_MSG_CHANNEL_OPEN_CONFIRM
#define SSH_MSG_CHANNEL_OPEN_FAILURE
#define SSH_MSG_CHANNEL_CLOSE
#define SSH_MSG_CHANNEL_WINDOW_ADJUST
One channel's flow-control state (RFC 4254 sec 5.2).
uint32_t peer_max_pkt
Peer's maximum packet size; caps a single send independently of the window.
uint32_t local_max
The window we advertised, and replenish back up to.
uint32_t peer_window
Bytes we may still send the peer.
uint32_t local_window
Bytes the peer may still send us before we WINDOW_ADJUST.