projects
/
silc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge commit 'origin/silc.1.1.branch'
[silc.git]
/
lib
/
silcclient
/
client_connect.c
diff --git
a/lib/silcclient/client_connect.c
b/lib/silcclient/client_connect.c
index f1aedcbb8c563481eb50b485283fec5c60852814..9d74e0b317124323dd399e99428cf37db422248a 100644
(file)
--- a/
lib/silcclient/client_connect.c
+++ b/
lib/silcclient/client_connect.c
@@
-4,7
+4,7
@@
Author: Pekka Riikonen <priikone@silcnet.org>
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2006 - 200
7
Pekka Riikonen
+ Copyright (C) 2006 - 200
8
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
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 */
/* Callback called after connected to remote host */
-static void silc_client_connect_callback(Silc
NetStatus
status,
+static void silc_client_connect_callback(Silc
Result
status,
SilcStream stream, void *context)
{
SilcFSMThread fsm = context;
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) {
conn->internal->op = NULL;
if (conn->internal->verbose) {
switch (status) {
- case SILC_
NET_
OK:
+ case SILC_OK:
break;
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;
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;
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;
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;
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",
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;
/* Notify application of failure */
SILC_LOG_DEBUG(("Connecting failed"));
conn->internal->status = SILC_CLIENT_CONN_ERROR;
@@
-280,14
+280,18
@@
static void silc_client_rekey_completion(SilcSKE ske,
/* Callback called by application to return authentication data */
static void silc_client_connect_auth_method(SilcAuthMethod auth_meth,
/* 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;
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->internal->params.auth_len = auth_len;
SILC_FSM_CALL_CONTINUE(fsm);
@@
-410,8
+414,8
@@
SILC_FSM_STATE(silc_client_st_connect)
conn->remote_host, conn->remote_port,
conn->internal->schedule);
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) */
stream, fsm));
} else {
/* Connect (TCP) */
@@
-450,6
+454,11
@@
SILC_FSM_STATE(silc_client_st_connect_set_stream)
silc_packet_set_context(conn->stream, conn);
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;
/** Start key exchange */
silc_fsm_next(fsm, silc_client_st_connect_key_exchange);
return SILC_FSM_CONTINUE;
@@
-547,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);
/* 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);
silc_packet_stream_set_iv_included(conn->stream);
silc_packet_set_sid(conn->stream, 0);
@@
-676,6
+688,13
@@
SILC_FSM_STATE(silc_client_st_connected)
silc_ske_free(conn->internal->ske);
conn->internal->ske = 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);
if (conn->internal->disconnected) {
/** Disconnected */
silc_fsm_next(fsm, silc_client_st_connect_error);
@@
-778,9
+797,8
@@
SILC_FSM_STATE(silc_client_st_rekey)
/* Allocate SKE */
conn->internal->ske =
/* 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;
if (!conn->internal->ske)
return SILC_FSM_FINISH;