X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcclient%2Fclient_connect.c;h=9d74e0b317124323dd399e99428cf37db422248a;hb=HEAD;hp=9542363fae0588c2a5930250110d04e016b77982;hpb=890f7e6c710c3126c78fedc91335528c64456b12;p=silc.git diff --git a/lib/silcclient/client_connect.c b/lib/silcclient/client_connect.c index 9542363f..9d74e0b3 100644 --- a/lib/silcclient/client_connect.c +++ b/lib/silcclient/client_connect.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2006 - 2007 Pekka Riikonen + Copyright (C) 2006 - 2008 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ /* 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; @@ -35,33 +35,33 @@ static void silc_client_connect_callback(SilcNetStatus status, 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", @@ -76,7 +76,7 @@ static void silc_client_connect_callback(SilcNetStatus status, } } - 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; @@ -414,8 +414,8 @@ SILC_FSM_STATE(silc_client_st_connect) 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) */ @@ -454,6 +454,11 @@ SILC_FSM_STATE(silc_client_st_connect_set_stream) silc_packet_set_context(conn->stream, conn); + /* Save socket stream and socket into connection context */ + conn->socket_stream = silc_packet_stream_get_stream(conn->stream); + silc_socket_stream_get_info(conn->socket_stream, &conn->sock, NULL, + NULL, NULL); + /** Start key exchange */ silc_fsm_next(fsm, silc_client_st_connect_key_exchange); return SILC_FSM_CONTINUE; @@ -551,6 +556,9 @@ SILC_FSM_STATE(silc_client_st_connect_setup_udp) /* Set the new stream to packet stream */ old = silc_packet_stream_get_stream(conn->stream); silc_packet_stream_set_stream(conn->stream, stream); + conn->socket_stream = stream; + silc_socket_stream_get_info(conn->socket_stream, &conn->sock, NULL, + NULL, NULL); silc_packet_stream_set_iv_included(conn->stream); silc_packet_set_sid(conn->stream, 0); @@ -789,9 +797,8 @@ SILC_FSM_STATE(silc_client_st_rekey) /* 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;