+
+/* Duplicates packet context. Duplicates the entire context and its
+ contents. */
+
+SilcPacketContext *silc_packet_context_dup(SilcPacketContext *ctx)
+{
+ SilcPacketContext *new;
+
+ new = silc_calloc(1, sizeof(*new));
+ new->buffer = silc_buffer_copy(ctx->buffer);
+ new->type = ctx->type;
+ new->flags = ctx->flags;
+
+ new->src_id = silc_calloc(ctx->src_id_len, sizeof(*new->src_id));
+ memcpy(new->src_id, ctx->src_id, ctx->src_id_len);
+ new->src_id_len = ctx->src_id_len;
+ new->src_id_type = ctx->src_id_type;
+
+ new->dst_id = silc_calloc(ctx->dst_id_len, sizeof(*new->dst_id));
+ memcpy(new->dst_id, ctx->dst_id, ctx->dst_id_len);
+ new->dst_id_len = ctx->dst_id_len;
+ new->dst_id_type = ctx->dst_id_type;
+
+ new->truelen = ctx->truelen;
+ new->padlen = ctx->padlen;
+
+ new->rng = ctx->rng;
+ new->context = ctx->context;
+ new->sock = ctx->sock;
+
+ return new;
+}
+
+