Added connection authentication request support.
[silc.git] / lib / silcclient / client_keyagr.c
index 52dca47c040be11f66ac6e3782fbc0fd95c6b742..3effa0569d56607d5c5c2b2a2ec889e2b67d77fe 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2001 - 2006 Pekka Riikonen
+  Copyright (C) 2001 - 2007 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
@@ -186,7 +186,7 @@ static void silc_client_keyagr_completion(SilcSKE ske,
   silc_client_keyagr_free(client, conn, client_entry);
 }
 
-/* Starts key agreement as responder.  */
+/* Starts key agreement as responder. */
 
 static void silc_client_process_key_agreement(SilcClient client,
                                              SilcClientConnection conn,
@@ -362,6 +362,8 @@ void silc_client_send_key_agreement(SilcClient client,
 
   if (!client_entry)
     return;
+  if (conn->internal->disconnected)
+    return;
 
   if (client_entry->internal.ke) {
     completion(client, conn, client_entry, SILC_KEY_AGREEMENT_ALREADY_STARTED,
@@ -414,7 +416,7 @@ void silc_client_send_key_agreement(SilcClient client,
       port = params->local_port;
       if (!port) {
        /* Get listener port */
-       int sock;
+       SilcSocket sock;
        silc_socket_stream_get_info(stream, &sock, NULL, NULL, NULL);
        port = silc_net_get_local_port(sock);
       }
@@ -647,14 +649,14 @@ SILC_FSM_STATE(silc_client_key_agreement)
   if (packet->src_id_type != SILC_ID_CLIENT) {
     /** Invalid packet */
     silc_fsm_next(fsm, silc_client_key_agreement_error);
-    return SILC_FSM_CONTINUE;
+    SILC_FSM_CONTINUE;
   }
 
   if (!silc_id_str2id(packet->src_id, packet->src_id_len, SILC_ID_CLIENT,
                      &remote_id, sizeof(remote_id))) {
     /** Invalid source ID */
     silc_fsm_next(fsm, silc_client_key_agreement_error);
-    return SILC_FSM_CONTINUE;
+    SILC_FSM_CONTINUE;
   }
 
   /* Check whether we know this client already */
@@ -675,7 +677,7 @@ SILC_FSM_STATE(silc_client_key_agreement)
     /** Malformed Payload */
     SILC_LOG_DEBUG(("Malformed key agreement payload"));
     silc_fsm_next(fsm, silc_client_key_agreement_error);
-    return SILC_FSM_CONTINUE;
+    SILC_FSM_CONTINUE;
   }
 
   /* If remote did not provide connection endpoint, we will assume that we
@@ -695,7 +697,7 @@ SILC_FSM_STATE(silc_client_key_agreement)
   silc_key_agreement_payload_free(payload);
 
   silc_packet_free(packet);
-  return SILC_FSM_FINISH;
+  SILC_FSM_FINISH;
 }
 
 /* Key agreement packet processing error */
@@ -704,5 +706,5 @@ SILC_FSM_STATE(silc_client_key_agreement_error)
 {
   SilcPacket packet = state_context;
   silc_packet_free(packet);
-  return SILC_FSM_FINISH;
+  SILC_FSM_FINISH;
 }