From: Pekka Riikonen Date: Tue, 21 Nov 2000 20:45:08 +0000 (+0000) Subject: Change code to use new SilcPacketContext reference count system. X-Git-Tag: SILC.0.1~317 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=b9e8e107d851a216c060c4c36f94279bba6ffd3d Change code to use new SilcPacketContext reference count system. --- diff --git a/lib/silcclient/client.c b/lib/silcclient/client.c index 92fac57b..6f3d608e 100644 --- a/lib/silcclient/client.c +++ b/lib/silcclient/client.c @@ -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 */ diff --git a/lib/silcclient/protocol.c b/lib/silcclient/protocol.c index 33203777..bd52fcc5 100644 --- a/lib/silcclient/protocol.c +++ b/lib/silcclient/protocol.c @@ -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); } diff --git a/lib/silcclient/protocol.h b/lib/silcclient/protocol.h index 87c2573a..92847902 100644 --- a/lib/silcclient/protocol.h +++ b/lib/silcclient/protocol.h @@ -39,7 +39,7 @@ typedef struct { void *dest_id; SilcIdType dest_id_type; - SilcBuffer packet; + SilcPacketContext *packet; SilcSKE ske; } SilcClientKEInternalContext;