Logo Search packages:      
Sourcecode: freetds version File versions

int tds_process_login_tokens ( TDSSOCKET *  tds  ) 

tds_process_login_tokens() is called after sending the login packet to the server. It returns the success or failure of the login dependent on the protocol version. 4.2 sends an ACK token only when successful, TDS 5.0 sends it always with a success byte within

Definition at line 225 of file token.c.

References tds_get_n(), tds_get_smallint(), tds_process_default_tokens(), and tds_process_login_tokens().

Referenced by tds_connect(), and tds_process_login_tokens().

{
int succeed = TDS_FAIL;
int marker;
int len, product_name_len;
unsigned char major_ver, minor_ver;
unsigned char ack;
TDS_UINT product_version;

      tdsdump_log(TDS_DBG_FUNC, "%L inside tds_process_login_tokens()\n");
      /* get_incoming(tds->s); */
      do {
            marker = tds_get_byte(tds);
            switch (marker) {
            case TDS_AUTH_TOKEN:
                  tds_process_auth(tds);
                  break;
            case TDS_LOGINACK_TOKEN:
                  /* TODO function */
                  len = tds_get_smallint(tds);
                  ack = tds_get_byte(tds);
                  major_ver = tds_get_byte(tds);
                  minor_ver = tds_get_byte(tds);
                  tds_get_n(tds, NULL, 2);
                  product_name_len = tds_get_byte(tds);
                  product_version = 0;
                  /* TODO get server product and string */
                  len -= 10;
                  if (major_ver >= 7) {
                        product_version |= 0x80000000u;
                        tds_get_n(tds, NULL, len);
                  } else if (major_ver >= 5) {
                        tds_get_n(tds, NULL, len);
                  } else {
char buf[32 + 1];
int l = len > 32 ? 32 : len;

                        tds_get_n(tds, buf, l);
                        buf[l] = 0;
                        if (strstr(buf, "Microsoft"))
                              product_version |= 0x80000000u;
                        if (l < len)
                              tds_get_n(tds, NULL, len - l);
                  }
                  /* FIXME MSSQL 6.5 and 7.0 seem to return strange values for this 
                   * using TDS 4.2, something like 5F 06 32 FF for 65 */
                  product_version |= ((TDS_UINT) tds_get_byte(tds)) << 24;
                  product_version |= ((TDS_UINT) tds_get_byte(tds)) << 16;
                  product_version |= ((TDS_UINT) tds_get_byte(tds)) << 8;
                  product_version |= tds_get_byte(tds);
                  tds->product_version = product_version;
#ifdef WORDS_BIGENDIAN
                  /* do a best check */
/*
                        
                        if (major_ver==7) {
                              tds->broken_dates=1;
                        }
*/
#endif
                  /* TDS 5.0 reports 5 on success 6 on failure
                   * TDS 4.2 reports 1 on success and is not
                   * present on failure */
                  if (ack == 5 || ack == 1)
                        succeed = TDS_SUCCEED;
                  break;
            default:
                  if (tds_process_default_tokens(tds, marker) == TDS_FAIL)
                        return TDS_FAIL;
                  break;
            }
      } while (marker != TDS_DONE_TOKEN);
      tds->spid = tds->rows_affected;
      if (tds->spid == 0) {
            if (tds_set_spid(tds) != TDS_SUCCEED) {
                  tdsdump_log(TDS_DBG_ERROR, "%L tds_set_spid() failed\n");
                  succeed = TDS_FAIL;
            }
      }
      tdsdump_log(TDS_DBG_FUNC, "%L leaving tds_process_login_tokens() returning %d\n", succeed);
      return succeed;
}


Generated by  Doxygen 1.6.0   Back to index