Change code to use new SilcPacketContext reference count system.
authorPekka Riikonen <priikone@silcnet.org>
Tue, 21 Nov 2000 20:45:08 +0000 (20:45 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Tue, 21 Nov 2000 20:45:08 +0000 (20:45 +0000)
lib/silcclient/client.c
lib/silcclient/protocol.c
lib/silcclient/protocol.h

index 92fac57bc5e0d83bbb78cfefe473bbf9429fb942..6f3d608ebccff626b9a861f11082ffea6b3b628a 100644 (file)
@@ -414,7 +414,7 @@ SILC_TASK_CALLBACK(silc_client_connect_to_server_second)
   /* Free old protocol as it is finished now */
   silc_protocol_free(protocol);
   if (ctx->packet)
-    silc_buffer_free(ctx->packet);
+    silc_packet_context_free(ctx->packet);
   silc_free(ctx);
   /* silc_free(ctx->keymat....); */
   sock->protocol = NULL;
@@ -648,12 +648,8 @@ SILC_TASK_CALLBACK(silc_client_packet_parse_real)
   silc_client_packet_parse_type(client, sock, packet);
 
  out:
-  silc_buffer_clear(buffer);
-  if (packet->src_id)
-    silc_free(packet->src_id);
-  if (packet->dst_id)
-    silc_free(packet->dst_id);
-  silc_free(packet);
+  silc_buffer_clear(sock->inbuf);
+  silc_packet_context_free(packet);
   silc_free(parse_ctx);
 }
 
@@ -780,7 +776,7 @@ void silc_client_packet_parse_type(SilcClient client,
       SilcClientKEInternalContext *proto_ctx = 
        (SilcClientKEInternalContext *)sock->protocol->context;
 
-      proto_ctx->packet = buffer;
+      proto_ctx->packet = silc_packet_context_dup(packet);
       proto_ctx->dest_id_type = packet->src_id_type;
       proto_ctx->dest_id = silc_id_str2id(packet->src_id, packet->src_id_type);
 
@@ -809,9 +805,9 @@ void silc_client_packet_parse_type(SilcClient client,
        (SilcClientKEInternalContext *)sock->protocol->context;
 
       if (proto_ctx->packet)
-       silc_buffer_free(proto_ctx->packet);
+       silc_packet_context_free(proto_ctx->packet);
 
-      proto_ctx->packet = buffer;
+      proto_ctx->packet = silc_packet_context_dup(packet);
       proto_ctx->dest_id_type = packet->src_id_type;
       proto_ctx->dest_id = silc_id_str2id(packet->src_id, packet->src_id_type);
 
@@ -1267,12 +1263,7 @@ static void silc_client_notify_by_server_pending(void *context)
 {
   SilcPacketContext *p = (SilcPacketContext *)context;
   silc_client_notify_by_server(p->context, p->sock, p);
-  if (p->src_id)
-    silc_free(p->src_id);
-  if (p->dst_id)
-    silc_free(p->dst_id);
-  silc_buffer_free(p->buffer);
-  silc_free(p);
+  silc_packet_context_free(p);
 }
 
 /* Received notify message from server */
index 33203777ca9172e94b6ebb2c2727d6da88cdee6b..bd52fcc5beea2e922317cdd8d8b6753eaf4a3e62 100644 (file)
@@ -218,7 +218,8 @@ SILC_TASK_CALLBACK(silc_client_protocol_key_exchange)
           paylaod reply we just got from the responder. The callback
           function will receive the processed payload where we will
           save it. */
-       status = silc_ske_initiator_phase_1(ctx->ske, ctx->packet, NULL, NULL);
+       status = silc_ske_initiator_phase_1(ctx->ske, ctx->packet->buffer, 
+                                           NULL, NULL);
       }
 
       if (status != SILC_SKE_STATUS_OK) {
@@ -293,7 +294,7 @@ SILC_TASK_CALLBACK(silc_client_protocol_key_exchange)
       } else {
        /* Finish the protocol. This verifies the Key Exchange 2 payload
           sent by responder. */
-       status = silc_ske_initiator_finish(ctx->ske, ctx->packet,
+       status = silc_ske_initiator_finish(ctx->ske, ctx->packet->buffer,
                                           silc_client_protocol_ke_verify_key,
                                           context, NULL, NULL);
       }
index 87c2573ad06230c76a31d335085248a3309a3ce2..928479023a4bcd93e5dca733cbfec44f3ea4e10f 100644 (file)
@@ -39,7 +39,7 @@ typedef struct {
   void *dest_id;
   SilcIdType dest_id_type;
 
-  SilcBuffer packet;
+  SilcPacketContext *packet;
   SilcSKE ske;
 } SilcClientKEInternalContext;