Negotiating the TDS protocol level in passthrough mode

When Sybase clients and servers connect, they first agree upon the TDS protocol level to use, usually the latest version of the protocol that both programs recognize. See “Negotiated behavior” for more information on initial protocol negotiation.

When an Open Server gateway application operates in passthrough mode, the TDS packets are created and interpreted by the remote Sybase client and Adaptive Server—not by the gateway. Therefore, TDS negotiation occurs between the two remote programs. The gateway must facilitate this negotiation by relaying responses between the two parties. The TDS negotiation process must occur inside a SRV_CONNECT event handler and involves the following steps:

  1. Set one of these properties:

    You must set one of these properties for srv_getloginfo and ct_setloginfo to negotiate client/server capabilities correctly for passthrough mode.

  2. srv_getloginfo – allocate a CS_LOGINFO structure and fill it with login information from the client thread.

  3. ct_setloginfo – prepare a CS_LOGINFO structure with the login information retrieved in step 2.

  4. If the client application is using network-based authentication, perform these steps to transfer the client’s security principal name. These steps are required because the security principal name is not part of the CS_LOGINFO structure.

  5. Log in to the remote server by calling ct_connect.

  6. ct_getloginfo – transfer login response information from a CS_CONNECTION structure to the newly allocated CS_LOGINFO structure.

  7. srv_setloginfo – send the remote server’s response, retrieved in step 6, to the client, then release the CS_LOGINFO structure.