Type Alias openthread_sys::otTcpAcceptReady

source ·
pub type otTcpAcceptReady = Option<unsafe extern "C" fn(aListener: *mut otTcpListener, aPeer: *const otSockAddr, aAcceptInto: *mut *mut otTcpEndpoint) -> otTcpIncomingConnectionAction>;
Expand description

This callback indicates that an incoming connection that matches this TCP listener has arrived.

The typical response is for the application to accept the incoming connection. It does so by populating @p aAcceptInto with a pointer to the otTcpEndpoint into which to accept the incoming connection. This otTcpEndpoint must already be initialized using otTcpEndpointInitialize(). Then, the application returns OT_TCP_INCOMING_CONNECTION_ACTION_ACCEPT.

Alternatively, the application can decline to accept the incoming connection. There are two ways for the application to do this. First, if the application returns OT_TCP_INCOMING_CONNECTION_ACTION_DEFER, then OpenThread silently ignores the connection establishment request; the connection peer will likely retransmit the request, at which point the callback will be called again. This is valuable if resources are not presently available to accept the connection, but they may be available when the connection peer retransmits its connection establishment attempt. Second, if the application returns OT_TCP_INCOMING_CONNECTION_ACTION_REFUSE, then OpenThread sends a “connection refused” message to the host that attempted to establish a connection. If the application declines the incoming connection, it is not required to populate @p aAcceptInto.

@param[in] aListener The TCP listener that matches the incoming connection. @param[in] aPeer The host and port from which the incoming connection originates. @param[out] aAcceptInto The TCP endpoint into which to accept the incoming connection.

@returns Description of how to handle the incoming connection.

Aliased Type§

enum otTcpAcceptReady {
    None,
    Some(unsafe extern "C" fn(_: *mut otTcpListener, _: *const otSockAddr, _: *mut *mut otTcpEndpoint) -> u32),
}

Variants§

§1.0.0

None

No value.

§1.0.0

Some(unsafe extern "C" fn(_: *mut otTcpListener, _: *const otSockAddr, _: *mut *mut otTcpEndpoint) -> u32)

Some value of type T.