Skip to content

SshChannelManager

[Source]

Tracks channel state keyed by local channel id. The local id (the map key) is the value we advertise to the peer as sender_channel; the peer echoes it back as the recipient_channel of every message it sends us, so the connection layer uses an inbound recipient_channel directly as the local key. A channel's remote_id is stored only to fill the recipient_channel field of messages we send to the peer. Anyone changing how outbound messages are keyed must preserve this local-id == map-key == peer's recipient_channel invariant, or inbound routing will look up the wrong channel.

class ref SshChannelManager

Constructors

create

[Source]

The receive window is at least 256 bytes, even for smaller inputs.

new ref create(
  initial_window': U32 val = SshChannelWindow.initial())
: SshChannelManager ref^

Parameters

  • initial_window': U32 val = SshChannelWindow.initial()

Returns


Public fields

let initial_window: U32 val

[Source]


Public Functions

open_channel

[Source]

Allocate local channel ID and create pending state.

fun ref open_channel(
  channel_type: String val)
: U32 val

Parameters

Returns


confirm_channel

[Source]

Confirm a pending channel open. The peer accepting the channel we opened is what authorizes it, so this is where a channel of ours becomes usable.

fun ref confirm_channel(
  local_id: U32 val,
  remote_id: U32 val,
  remote_window: U32 val,
  max_packet_size: U32 val)
: (None val | SshChannelError)

Parameters

  • local_id: U32 val
  • remote_id: U32 val
  • remote_window: U32 val
  • max_packet_size: U32 val

Returns


accept_channel

[Source]

Accept an incoming channel open from remote (server side).

fun ref accept_channel(
  local_id: U32 val,
  remote_id: U32 val,
  remote_window: U32 val,
  max_packet_size: U32 val,
  channel_type: String val)
: (U32 val | SshChannelUnsupportedPacketSize val)

Parameters

  • local_id: U32 val
  • remote_id: U32 val
  • remote_window: U32 val
  • max_packet_size: U32 val
  • channel_type: String val

Returns


channel_remote_id_if_open

[Source]

Return the peer's channel ID when the local channel is open.

fun box channel_remote_id_if_open(
  local_id: U32 val)
: (U32 val | SshChannelError)

Parameters

  • local_id: U32 val

Returns


channel_data_admitted

[Source]

Debit the peer window after a segment has been admitted to transport.

fun ref channel_data_admitted(
  local_id: U32 val,
  data_size: USize val)
: (None val | SshChannelError)

Parameters

  • local_id: U32 val
  • data_size: USize val

Returns


clear_send_blocked

[Source]

Clear blocked-send state when the session ends.

fun ref clear_send_blocked()
: None val

Returns


channel_data_received

[Source]

Account for received data against the receive window. Returns the remaining window on success, or SshWindowExhausted if the peer sent more than the window we advertised (a flow-control violation we must not silently absorb).

fun ref channel_data_received(
  local_id: U32 val,
  data_size: USize val)
: (U32 val | SshChannelError)

Parameters

  • local_id: U32 val
  • data_size: USize val

Returns


replenish_local_window

[Source]

If the receive window has fallen below half its initial size, top it back up to the initial size and return the increment to advertise to the peer via SSH_MSG_CHANNEL_WINDOW_ADJUST. Returns None when no adjustment is due. Without this the peer's send window decays to zero and the channel stalls.

fun ref replenish_local_window(
  local_id: U32 val)
: (U32 val | None val)

Parameters

  • local_id: U32 val

Returns


window_adjust

[Source]

Increase the remote send window for a channel. Saturates at U32 max rather than wrapping: a peer that sums WINDOW_ADJUSTs past 2^32 (which RFC 4254 ยง5.2 forbids) must not silently wrap our window back to a small value.

fun ref window_adjust(
  local_id: U32 val,
  bytes: U32 val)
: None val

Parameters

  • local_id: U32 val
  • bytes: U32 val

Returns


close_channel

[Source]

Remove channel state.

fun ref close_channel(
  local_id: U32 val)
: None val

Parameters

  • local_id: U32 val

Returns


get

[Source]

fun ref get(
  local_id: U32 val)
: (SshChannelState ref | None val)

Parameters

  • local_id: U32 val

Returns


channel_count

[Source]

fun box channel_count()
: USize val

Returns


at_capacity

[Source]

True once the concurrent-channel cap is reached; reject further opens.

fun box at_capacity()
: Bool val

Returns