From: Pekka Riikonen Date: Wed, 10 Apr 2002 09:28:03 +0000 (+0000) Subject: updates X-Git-Tag: silc.client.0.8.6~4^2~11 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=0bec4ad52aee68c17d256ab266ff0bfda338dd52 updates --- diff --git a/apps/irssi/src/silc/core/silc-servers.c b/apps/irssi/src/silc/core/silc-servers.c index f24ba508..e92ae9ba 100644 --- a/apps/irssi/src/silc/core/silc-servers.c +++ b/apps/irssi/src/silc/core/silc-servers.c @@ -197,7 +197,7 @@ static void sig_connected(SILC_SERVER_REC *server) if (!IS_SILC_SERVER(server)) return; - conn = silc_client_add_connection(silc_client, + conn = silc_client_add_connection(silc_client, NULL, server->connrec->address, server->connrec->port, server); diff --git a/lib/silcclient/client.c b/lib/silcclient/client.c index 4875e8e2..c5b13236 100644 --- a/lib/silcclient/client.c +++ b/lib/silcclient/client.c @@ -186,10 +186,10 @@ static void silc_client_entry_destructor(SilcIDCache cache, application performed the connecting outside the library. The library however may use this internally. */ -SilcClientConnection silc_client_add_connection(SilcClient client, - char *hostname, - int port, - void *context) +SilcClientConnection +silc_client_add_connection(SilcClient client, + SilcClientConnectionParams *params, + char *hostname, int port, void *context) { SilcClientConnection conn; int i; @@ -208,6 +208,13 @@ SilcClientConnection silc_client_add_connection(SilcClient client, conn->pending_commands = silc_dlist_init(); conn->ftp_sessions = silc_dlist_init(); + if (params) { + if (params->detach_data) + conn->params.detach_data = silc_memdup(params->detach_data, + params->detach_data_len); + conn->params.detach_data_len = params->detach_data_len; + } + /* Add the connection to connections table */ for (i = 0; i < client->internal->conns_count; i++) if (client->internal->conns && !client->internal->conns[i]) { @@ -330,8 +337,9 @@ silc_client_connect_to_server_internal(SilcClientInternalConnectContext *ctx) case then this function is not used at all. When the connecting is done the `connect' client operation is called. */ -int silc_client_connect_to_server(SilcClient client, int port, - char *host, void *context) +int silc_client_connect_to_server(SilcClient client, + SilcClientConnectionParams *params, + int port, char *host, void *context) { SilcClientInternalConnectContext *ctx; SilcClientConnection conn; @@ -340,7 +348,7 @@ int silc_client_connect_to_server(SilcClient client, int port, SILC_LOG_DEBUG(("Connecting to port %d of server %s", port, host)); - conn = silc_client_add_connection(client, host, port, context); + conn = silc_client_add_connection(client, params, host, port, context); client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT, "Connecting to port %d of server %s", port, host); diff --git a/lib/silcclient/client.h b/lib/silcclient/client.h index 7868d460..2073bc5a 100644 --- a/lib/silcclient/client.h +++ b/lib/silcclient/client.h @@ -135,6 +135,9 @@ struct SilcClientConnectionStruct { and the actual client object is accesible through this pointer. */ SilcClient client; + /* Connection parameters */ + SilcClientConnectionParams params; + /* User data context. Library does not touch this. */ void *context; }; diff --git a/lib/silcclient/client_ftp.c b/lib/silcclient/client_ftp.c index 6d63544d..87a1f4c9 100644 --- a/lib/silcclient/client_ftp.c +++ b/lib/silcclient/client_ftp.c @@ -542,7 +542,7 @@ static void silc_client_ftp_start_key_agreement(SilcClientFtpSession session, NULL, session->monitor_context); /* Add new connection for this session */ - conn = silc_client_add_connection(client, session->hostname, + conn = silc_client_add_connection(client, NULL, session->hostname, session->port, session); /* Allocate new socket connection object */ @@ -640,7 +640,7 @@ SILC_TASK_CALLBACK(silc_client_ftp_process_key_agreement) NULL, session->monitor_context); /* Add new connection for this session */ - conn = silc_client_add_connection(client, newsocket->hostname, + conn = silc_client_add_connection(client, NULL, newsocket->hostname, newsocket->port, session); conn->sock = newsocket; conn->sock->user_data = conn; diff --git a/lib/silcclient/silcclient.h b/lib/silcclient/silcclient.h index a1f8e48b..87c3b97c 100644 --- a/lib/silcclient/silcclient.h +++ b/lib/silcclient/silcclient.h @@ -622,12 +622,38 @@ void silc_client_stop(SilcClient client); /* Connecting functions (client.c) */ +/****s* silcclient/SilcClientAPI/SilcClientConnectionParams + * + * NAME + * + * typedef struct { ... } SilcClientConnectionParams; + * + * DESCRIPTION + * + * Client connection parameters. This can be filled by the application + * and given as argument to silc_client_connect_to_server or to + * silc_client_add_connection. + * + * SOURCE + */ +typedef struct { + /* The SILC session detachment data that was returned by `detach' client + operation when the application detached from the network. Application + is responsible of saving the data and giving it as argument here + for resuming the session in the SILC network. */ + unsigned char *detach_data; + SilcUInt32 detach_data_len; + +} SilcClientConnectionParams; +/***/ + /****f* silcclient/SilcClientAPI/silc_client_connect_to_server * * SYNOPSIS * - * int silc_client_connect_to_server(SilcClient client, int port, - * char *host, void *context); + * int silc_client_connect_to_server(SilcClient client, + * SilcClientConnectionParams *params, + * int port, char *host, void *context); * * DESCRIPTION * @@ -637,20 +663,24 @@ void silc_client_stop(SilcClient client); * that is created after the connection is created. Note that application * may handle the connecting process outside the library. If this is the * case then this function is not used at all. When the connecting is - * done the `connect' client operation is called. + * done the `connect' client operation is called, and the `context' is + * accessible with conn->context, conn being SilcClientConnection. + * If the `params' is provided they are used by the routine. * ***/ -int silc_client_connect_to_server(SilcClient client, int port, - char *host, void *context); +int silc_client_connect_to_server(SilcClient client, + SilcClientConnectionParams *params, + int port, char *host, void *context); /****f* silcclient/SilcClientAPI/silc_client_add_connection * * SYNOPSIS * - * SilcClientConnection silc_client_add_connection(SilcClient client, - * char *hostname, - * int port, - * void *context); + * + * SilcClientConnection + * silc_client_add_connection(SilcClient client, + * SilcClientConnectionParams *params, + * char *hostname, int port, void *context); * * DESCRIPTION * @@ -658,15 +688,21 @@ int silc_client_connect_to_server(SilcClient client, int port, * connection to the connection table and returns a pointer to it. A client * can have multiple connections to multiple servers. Every connection must * be added to the client using this function. User data `context' may - * be sent as argument. This function is normally used only if the - * application performed the connecting outside the library. The library + * be sent as argument. If the `params' is provided they are used by + * the routine. + * + * NOTES + * + * This function is normally used only if the application performed + * the connecting outside the library, and did not called the + * silc_client_connect_to_server function at all. The library * however may use this internally. * ***/ -SilcClientConnection silc_client_add_connection(SilcClient client, - char *hostname, - int port, - void *context); +SilcClientConnection +silc_client_add_connection(SilcClient client, + SilcClientConnectionParams *params, + char *hostname, int port, void *context); /****f* silcclient/SilcClientAPI/silc_client_del_connection *