Minor ops API change and bugfixes.
authorPekka Riikonen <priikone@silcnet.org>
Thu, 5 Oct 2000 07:26:43 +0000 (07:26 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 5 Oct 2000 07:26:43 +0000 (07:26 +0000)
lib/silcclient/client.c
lib/silcclient/command_reply.c
lib/silcclient/ops.h
lib/silcclient/protocol.c

index 39147b26a0899580990a97bfcc2bee0c55bc0b4c..0bb10c78ca9a6212e69342c25b5b1824386bcedc 100644 (file)
@@ -126,7 +126,7 @@ void silc_client_run(SilcClient client)
 SilcClientConnection silc_client_add_connection(SilcClient client,
                                                char *hostname,
                                                int port,
-                                               void *context);
+                                               void *context)
 {
   SilcClientConnection conn;
   int i;
index 604389376afaa09e6ac221de992ab4d4e297ddff..b9c897a0b44ad9771fc593479f59f689df693b65 100644 (file)
@@ -108,11 +108,12 @@ const SilcCommandStatusMessage silc_command_status_messages[] = {
    Usage: COMMAND_REPLY((ARGS, argument1, argument2, etc...)), */
 #define COMMAND_REPLY(args) cmd->client->ops->command_reply args
 #define ARGS cmd->client, cmd->sock->user_data, \
-             cmd->payload, TRUE, silc_command_get(cmd->payload)
+             cmd->payload, TRUE, status, silc_command_get(cmd->payload)
 
 /* Error reply to application. Usage: COMMAND_REPLY_ERROR; */
 #define COMMAND_REPLY_ERROR cmd->client->ops->command_reply(cmd->client, \
-  cmd->sock->user_data, cmd->payload, FALSE, silc_command_get(cmd->payload))
+  cmd->sock->user_data, cmd->payload, FALSE, status, \
+  silc_command_get(cmd->payload))
 
 /* Process received command reply. */
 
index 69eb54e5df1621614f19fd112950b0cf957ddfc1..69da2416cd2b305a1af5a1fb0499116872b1718b 100644 (file)
@@ -44,7 +44,7 @@ typedef struct {
                  SilcCommand command);
   void (*command_reply)(SilcClient client, SilcClientConnection conn,
                        SilcCommandPayload cmd_payload, int success,
-                       SilcCommand command, ...);
+                       SilcCommandStatus status, SilcCommand command, ...);
   void (*connect)(SilcClient client, SilcClientConnection conn, int success);
   void (*disconnect)(SilcClient client, SilcClientConnection conn);
   int (*get_auth_method)(SilcClient client, SilcClientConnection conn,
@@ -105,7 +105,7 @@ typedef struct {
 
    void (*command_reply)(SilcClient client, SilcClientConnection conn,
                         SilcCommandPayload cmd_payload, int success,
-                        SilcCommand command, ...);
+                        SilcCommandStatus status, SilcCommand command, ...);
 
    Command reply handler. This function is called always in the command reply
    function. If error occurs it will be called as well. Normal scenario
@@ -118,9 +118,10 @@ typedef struct {
    if the application would like to re-parse the received command data,
    however, it must be noted that the data is parsed already by the library
    thus the payload can be ignored. `success' is FALSE if error occured.
-   In this case arguments are not sent to the application. `command' is the
-   command reply being processed. The function has variable argument list
-   and each command defines the number and type of arguments it passes to the
+   In this case arguments are not sent to the application. The `status' is
+   the command reply status server returned. The `command' is the command
+   reply being processed. The function has variable argument list and each
+   command defines the number and type of arguments it passes to the
    application (on error they are not sent).
 
 
index d0b8064c1093adc736e96f4cd8dbd5f3bd179f79..43fb6282e656309ca306ef3a1649169726c95761 100644 (file)
@@ -129,7 +129,7 @@ SILC_TASK_CALLBACK(silc_client_protocol_key_exchange)
     (SilcClientKEInternalContext *)protocol->context;
   SilcClient client = (SilcClient)ctx->client;
   SilcClientConnection conn = ctx->sock->user_data;
-  SilcSKEStatus status;
+  SilcSKEStatus status = 0;
 
   SILC_LOG_DEBUG(("Start"));
 
@@ -176,11 +176,14 @@ SILC_TASK_CALLBACK(silc_client_protocol_key_exchange)
       }
 
       if (status != SILC_SKE_STATUS_OK) {
-       switch(status) {
-         
-       default:
-         break;
-       }
+       SILC_LOG_WARNING(("Error (type %d) during Key Exchange protocol",
+                         status));
+       SILC_LOG_DEBUG(("Error (type %d) during Key Exchange protocol",
+                       status));
+
+       protocol->state = SILC_PROTOCOL_STATE_ERROR;
+       protocol->execute(client->timeout_queue, 0, protocol, fd, 0, 0);
+       return;
       }
 
       /* Advance the state of the protocol. */
@@ -208,9 +211,15 @@ SILC_TASK_CALLBACK(silc_client_protocol_key_exchange)
        status = silc_ske_initiator_phase_1(ctx->ske, ctx->packet, NULL, NULL);
       }
 
-      switch(status) {
-      default:
-       break;
+      if (status != SILC_SKE_STATUS_OK) {
+       SILC_LOG_WARNING(("Error (type %d) during Key Exchange protocol",
+                         status));
+       SILC_LOG_DEBUG(("Error (type %d) during Key Exchange protocol",
+                       status));
+
+       protocol->state = SILC_PROTOCOL_STATE_ERROR;
+       protocol->execute(client->timeout_queue, 0, protocol, fd, 0, 0);
+       return;
       }
 
       /* Advance the state of the protocol and call the next state. */
@@ -242,9 +251,15 @@ SILC_TASK_CALLBACK(silc_client_protocol_key_exchange)
                                     context);
       }
 
-      switch(status) {
-      default:
-       break;
+      if (status != SILC_SKE_STATUS_OK) {
+       SILC_LOG_WARNING(("Error (type %d) during Key Exchange protocol",
+                         status));
+       SILC_LOG_DEBUG(("Error (type %d) during Key Exchange protocol",
+                       status));
+
+       protocol->state = SILC_PROTOCOL_STATE_ERROR;
+       protocol->execute(client->timeout_queue, 0, protocol, fd, 0, 0);
+       return;
       }
 
       /* Advance the state of the protocol. */