From 21a3beb7e6159b9e535c6c6ae4441d7e7f2cd46c Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Tue, 4 Jul 2000 08:29:12 +0000 Subject: [PATCH] Added support for PING command. The ping times are calculated and showed to the user. --- apps/silc/client.c | 23 ++++++++++++++++++++++- apps/silc/client.h | 13 +++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/apps/silc/client.c b/apps/silc/client.c index 91a26845..e4f79fd9 100644 --- a/apps/silc/client.c +++ b/apps/silc/client.c @@ -20,6 +20,10 @@ /* * $Id$ * $Log$ + * Revision 1.3 2000/07/04 08:29:12 priikone + * Added support for PING command. The ping times are calculated + * and showed to the user. + * * Revision 1.2 2000/07/03 05:49:48 priikone * Implemented LEAVE command. Minor bug fixes. * @@ -898,6 +902,8 @@ SILC_TASK_CALLBACK(silc_client_connect_to_server_second) silc_buffer_free(ctx->packet); if (ctx->ske) silc_ske_free(ctx->ske); + if (ctx->dest_id) + silc_free(ctx->dest_id); silc_free(ctx); sock->protocol = NULL; return; @@ -909,6 +915,8 @@ SILC_TASK_CALLBACK(silc_client_connect_to_server_second) proto_ctx->client = (void *)client; proto_ctx->sock = sock = ctx->sock; proto_ctx->ske = ctx->ske; /* Save SKE object from previous protocol */ + proto_ctx->dest_id_type = ctx->dest_id_type; + proto_ctx->dest_id = ctx->dest_id; /* Resolve the authentication method to be used in this connection */ proto_ctx->auth_meth = SILC_PROTOCOL_CONN_AUTH_NONE; @@ -979,6 +987,8 @@ SILC_TASK_CALLBACK(silc_client_connect_to_server_final) silc_free(ctx->auth_data); if (ctx->ske) silc_ske_free(ctx->ske); + if (ctx->dest_id) + silc_free(ctx->dest_id); silc_free(ctx); win->sock->protocol = NULL; return; @@ -1005,6 +1015,11 @@ SILC_TASK_CALLBACK(silc_client_connect_to_server_final) packet->data, packet->len, TRUE); silc_buffer_free(packet); + /* Save remote ID. */ + win->remote_id = ctx->dest_id; + win->remote_id_data = silc_id_id2str(ctx->dest_id, SILC_ID_CHANNEL); + win->remote_id_data_len = SILC_ID_CHANNEL_LEN; + silc_say(client, "Connected to port %d of host %s", win->remote_port, win->remote_host); @@ -1016,6 +1031,8 @@ SILC_TASK_CALLBACK(silc_client_connect_to_server_final) silc_free(ctx->auth_data); if (ctx->ske) silc_ske_free(ctx->ske); + if (ctx->dest_id) + silc_free(ctx->dest_id); silc_free(ctx); win->sock->protocol = NULL; } @@ -1516,7 +1533,7 @@ void silc_client_packet_parse_type(SilcClient client, /* * Recived reply for a command */ - silc_client_command_reply_process(client, sock, buffer); + silc_client_command_reply_process(client, sock, packet); break; case SILC_PACKET_KEY_EXCHANGE: @@ -1525,6 +1542,8 @@ void silc_client_packet_parse_type(SilcClient client, (SilcClientKEInternalContext *)sock->protocol->context; proto_ctx->packet = buffer; + proto_ctx->dest_id_type = packet->src_id_type; + proto_ctx->dest_id = silc_id_str2id(packet->src_id, packet->src_id_type); /* Let the protocol handle the packet */ sock->protocol->execute(client->timeout_queue, 0, @@ -1554,6 +1573,8 @@ void silc_client_packet_parse_type(SilcClient client, silc_buffer_free(proto_ctx->packet); proto_ctx->packet = buffer; + proto_ctx->dest_id_type = packet->src_id_type; + proto_ctx->dest_id = silc_id_str2id(packet->src_id, packet->src_id_type); /* Let the protocol handle the packet */ sock->protocol->execute(client->timeout_queue, 0, diff --git a/apps/silc/client.h b/apps/silc/client.h index 0089dcd0..8c9c4f2d 100644 --- a/apps/silc/client.h +++ b/apps/silc/client.h @@ -21,6 +21,15 @@ #ifndef CLIENT_H #define CLIENT_H +/* Structure to hold ping time information. Every PING command will + add entry of this structure and is removed after reply to the ping + as been received. */ +typedef struct SilcClientPingStruct { + time_t start_time; + void *dest_id; + char *dest_name; +} SilcClientPing; + /* Window structure used in client to associate all the important connection (window) specific data to this structure. How the window actually appears on the screen in handeled by the silc_screen* @@ -87,6 +96,10 @@ typedef struct { referencing (sock->user_data). */ SilcSocketConnection sock; + /* Requested pings. */ + SilcClientPing *ping; + unsigned int ping_count; + /* The actual physical screen. This data is handled by the screen handling routines. */ void *screen; -- 2.43.0