/* Callback called after connected to remote host */
-static void silc_client_connect_callback(SilcNetStatus status,
+static void silc_client_connect_callback(SilcResult status,
SilcStream stream, void *context)
{
SilcFSMThread fsm = context;
conn->internal->op = NULL;
if (conn->internal->verbose) {
switch (status) {
- case SILC_NET_OK:
+ case SILC_OK:
break;
- case SILC_NET_UNKNOWN_IP:
+ case SILC_ERR_UNKNOWN_IP:
client->internal->ops->say(
client, conn, SILC_CLIENT_MESSAGE_ERROR,
"Could not connect to host %s: unknown IP address",
conn->remote_host);
break;
- case SILC_NET_UNKNOWN_HOST:
+ case SILC_ERR_UNKNOWN_HOST:
client->internal->ops->say(
client, conn, SILC_CLIENT_MESSAGE_ERROR,
"Could not connect to host %s: unknown host name",
conn->remote_host);
break;
- case SILC_NET_HOST_UNREACHABLE:
+ case SILC_ERR_UNREACHABLE:
client->internal->ops->say(
client, conn, SILC_CLIENT_MESSAGE_ERROR,
"Could not connect to host %s: network unreachable",
conn->remote_host);
break;
- case SILC_NET_CONNECTION_REFUSED:
+ case SILC_ERR_REFUSED:
client->internal->ops->say(
client, conn, SILC_CLIENT_MESSAGE_ERROR,
"Could not connect to host %s: connection refused",
conn->remote_host);
break;
- case SILC_NET_CONNECTION_TIMEOUT:
+ case SILC_ERR_TIMEOUT:
client->internal->ops->say(
client, conn, SILC_CLIENT_MESSAGE_ERROR,
"Could not connect to host %s: connection timeout",
}
}
- if (status != SILC_NET_OK) {
+ if (status != SILC_OK) {
/* Notify application of failure */
SILC_LOG_DEBUG(("Connecting failed"));
conn->internal->status = SILC_CLIENT_CONN_ERROR;
silc_ske_map_status(status));
conn->internal->status = SILC_CLIENT_CONN_ERROR_KE;
- conn->internal->error = status;
silc_ske_free_rekey_material(rekey);
silc_fsm_next(fsm, silc_client_st_connect_error);
- SILC_FSM_CALL_CONTINUE(fsm);
+ SILC_FSM_CALL_CONTINUE_SYNC(fsm);
return;
}
silc_ske_free_rekey_material(rekey);
silc_fsm_next(fsm, silc_client_st_connect_error);
- SILC_FSM_CALL_CONTINUE(fsm);
+ SILC_FSM_CALL_CONTINUE_SYNC(fsm);
return;
}
silc_ske_free_rekey_material(rekey);
silc_fsm_next(fsm, silc_client_st_connect_error);
- SILC_FSM_CALL_CONTINUE(fsm);
+ SILC_FSM_CALL_CONTINUE_SYNC(fsm);
return;
}
/* Callback called by application to return authentication data */
static void silc_client_connect_auth_method(SilcAuthMethod auth_meth,
- void *auth, SilcUInt32 auth_len,
+ const void *auth,
+ SilcUInt32 auth_len,
void *context)
{
SilcFSMThread fsm = context;
SilcClientConnection conn = silc_fsm_get_context(fsm);
conn->internal->params.auth_method = auth_meth;
- conn->internal->params.auth = auth;
+ if (auth_meth == SILC_AUTH_PASSWORD)
+ conn->internal->params.auth = silc_memdup(auth, auth_len);
+ else
+ conn->internal->params.auth = (void *)auth;
conn->internal->params.auth_len = auth_len;
SILC_FSM_CALL_CONTINUE(fsm);
conn->remote_host, conn->remote_port,
conn->internal->schedule);
- SILC_FSM_CALL(silc_client_connect_callback(stream ? SILC_NET_OK :
- SILC_NET_HOST_UNREACHABLE,
+ SILC_FSM_CALL(silc_client_connect_callback(stream ? SILC_OK :
+ SILC_ERR_UNREACHABLE,
stream, fsm));
} else {
/* Connect (TCP) */
SilcClientConnection conn = fsm_context;
SilcClient client = conn->client;
SilcSKEParamsStruct params;
+ SilcClientID cid;
SILC_LOG_DEBUG(("Starting key exchange protocol"));
/** Run key exchange (TCP) */
silc_fsm_next(fsm, silc_client_st_connect_auth_resolve);
+ /* Old server version requires empty Client ID in packets. Remove this
+ backwards support somepoint after 1.1 server is released. */
+ memset(&cid, 0, sizeof(cid));
+ cid.ip.data_len = 4;
+ silc_packet_set_ids(conn->stream, SILC_ID_CLIENT, &cid, 0, NULL);
+
SILC_FSM_CALL(conn->internal->op = silc_ske_initiator(conn->internal->ske,
conn->stream,
¶ms, NULL));
silc_ske_free(conn->internal->ske);
conn->internal->ske = NULL;
+ if (!conn->internal->params.auth_set &&
+ conn->internal->params.auth_method == SILC_AUTH_PASSWORD &&
+ conn->internal->params.auth) {
+ silc_free(conn->internal->params.auth);
+ conn->internal->params.auth = NULL;
+ }
+
if (conn->internal->disconnected) {
/** Disconnected */
silc_fsm_next(fsm, silc_client_st_connect_error);
/* Allocate SKE */
conn->internal->ske =
- silc_ske_alloc(client->rng, conn->internal->schedule,
- conn->internal->params.repository,
- conn->public_key, conn->private_key, fsm);
+ silc_ske_alloc(client->rng, conn->internal->schedule, NULL,
+ conn->public_key, NULL, fsm);
if (!conn->internal->ske)
return SILC_FSM_FINISH;