3.2.6.3.3 TsProxyCloseTunnel (Opnum 7)

The TsProxyCloseTunnel method is used to terminate the tunnel (1) between the RDG client and the RDG server. All communication between the RDG client and RDG server MUST stop after the RDG server executes this method. The RDG client MUST NOT use this tunnel context handle in any subsequent operations after this method call. This MUST be the final tear down phase of the RDG client to RDG server tunnel. If the ADM element Reauthentication Connection is FALSE, then the ADM element Number of Connections MUST be decremented by 1 in this call. If there is an existing channel within the tunnel, it SHOULD first be closed using TsProxyCloseChannel. If the RDG client calls the TsProxyCloseTunnel method before calling the TsProxyCloseChannel method, the RDG server MUST close the channel and then close the tunnel.

Prerequisites: The connection MUST be in any of the following states: Connected state, Authorized state, Channel Created state, Pipe Created state, Channel Close Pending state, or Tunnel Close Pending state.

Sequential Processing Rules:

  1. The RDG server MUST check whether the tunnel context handle is NULL or not a valid context handle. If so, it MUST return ERROR_ACCESS_DENIED.

  2. If there are any channels in the tunnel then the RDG server MUST disconnect them. If TsProxyCloseChannel has not already been called then the RDG server MUST close the RPC out pipe and return ERROR_GRACEFUL_DISCONNECT for the TsProxySetupReceivePipe.

  3. The RDG server MUST disconnect the tunnel.

  4. If the ADM element Reauthentication Connection is FALSE:

    1. The RDG server MUST decrement the ADM element Number of Connections by 1.

  5. The connection MUST transition to the End state.

  6. The RDG server MUST return ERROR_SUCCESS.

     HRESULT TsProxyCloseTunnel(
       [in, out] PTUNNEL_CONTEXT_HANDLE_SERIALIZE* context
     );
    

context: The RDG client MUST provide the RDG server with the same context handle it received from the TsProxyCreateTunnel method call.

Return Values: The method MUST return 0 on success. This function SHOULD NOT fail from a RDG protocol perspective. If TsProxyCloseTunnel is called while any of the channels are not closed, then the RDG server MUST close all the channels and then close the tunnel.

Return value

State transition

Description

ERROR_SUCCESS (0x00000000)

The connection MUST transition to the end state.

Returned when a call to the TsProxyCloseTunnel method succeeds.

ERROR_ACCESS_DENIED (0x00000005)

The connection MUST NOT transition its state.

Returned when the provided context parameter is NULL or not a valid tunnel context handle.