pub enum SessionRequest {
Attach {
port: PortId,
rx_frames: Vec<FrameType>,
responder: SessionAttachResponder,
},
Detach {
port: PortId,
responder: SessionDetachResponder,
},
Close {
control_handle: SessionControlHandle,
},
WatchDelegatedRxLease {
responder: SessionWatchDelegatedRxLeaseResponder,
},
}
Expand description
Represents a session with a Network device.
A session has a data plane and a control plane. The Session
protocol
represents the control plane of the session and the FIFOs and VMOs exchanged
during the [Device.OpenSession
] call are the data plane. Lifetime of the
session is controlled by a Session
protocol handle.
Sessions must attach to ports of interest to start receiving and sending data. Sessions are always created with no ports attached.
If a port is destroyed from the underlying device, it is automatically detached from the session.
Inbound traffic is dispatched to all open sessions. Devices typically
operate with a single primary session, see [SessionFlags.PRIMARY
]. Each
additional open session to the same device causes data copy overhead on the
device’s data path.
The session is closed with an error epitaph if an invalid buffer descriptor is sent over either the tx or rx FIFOs. Invalid descriptors include:
- Descriptor index larger than [
SessionInfo.descriptor_count
]. - Descriptor chains larger than
MAX_DESCRIPTOR_CHAIN
. - rx buffers smaller than [
Info.min_rx_buffer_length
]. - tx buffers smaller than [
Info.min_tx_buffer_length
]. - tx buffers not respecting [
Info.min_tx_buffer_head
] or [Info.min_tx_buffer_tail
].
Variants§
Attach
Attaches the session to port
.
Once attached, the session starts to receive the subscribed frames over
the data FIFOs and it may send frames destined to the specified port
.
- request
port
port to subscribe to. - request
rx_frames
Frame types of interest on the port.
- error
ZX_ERR_NOT_FOUND
ifport
is not valid. - error
ZX_ERR_INVALID_ARGS
ifrx_frames
is not a subset of the port’s supported frames. - error
ZX_ERR_ALREADY_BOUND
ifport
is already attached.
Detach
Detaches the session from port
.
Once detached, the session stops receiving frames from port
. Frames
sent to a detached port may be returned with an error. It is not
necessary to call Detach
on ports that are removed from the device,
doing so causes ZX_ERR_NOT_FOUND
to be returned.
- request
port
port to subscribe to.
- error
ZX_ERR_NOT_FOUND
if the session is not currently attached to the port.
Close
Cleanly closes a session.
This will cause the session to send a ZX_ERR_CANCELLED
epitaph and
proceed to close the Session channel. Clients may only assume that they
own all the buffers that are currently owned by the session (sent over
either the rx or tx FIFOs) once the epitaph is received. Closing the rx
or tx FIFO is equivalent to calling Close
.
Fields
control_handle: SessionControlHandle
WatchDelegatedRxLease
Watchers for delegated receive wakeup leases.
Calls block until a lease is delegated by the device. If a call to
WatchDelegatedRxLease
is made while a previous call is blocking, the
session is closed with ZX_ERR_BAD_STATE
. Will never yield any values
for sessions created without [SessionFlags.RECEIVE_RX_POWER_LEASES
].
Given a single lease is assumed sufficient to keep the system awake, the
server only keeps a single lease in its buffer. If a new delegated lease
becomes available and the client hasn’t popped the previous one with a
call to WatchDelegatedRxLease
, the server drops the previously pending
lease.
See DelegatedRxLease
for how to handle delegated leases.
Fields
responder: SessionWatchDelegatedRxLeaseResponder
Implementations§
Source§impl SessionRequest
impl SessionRequest
pub fn into_attach( self, ) -> Option<(PortId, Vec<FrameType>, SessionAttachResponder)>
pub fn into_detach(self) -> Option<(PortId, SessionDetachResponder)>
pub fn into_close(self) -> Option<SessionControlHandle>
pub fn into_watch_delegated_rx_lease( self, ) -> Option<SessionWatchDelegatedRxLeaseResponder>
Sourcepub fn method_name(&self) -> &'static str
pub fn method_name(&self) -> &'static str
Name of the method defined in FIDL