X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcclient%2Fclient.c;h=33d51e100bf8d48c6bc274157af95c390298738a;hb=789adec4bf1addc3ef7fb47d6370f5b3fe308376;hp=5b68a7715232c3399075bd1d5c7f8fffff855352;hpb=4760d6aa6c3248d7e6757d2e7e7a19a834b2dc34;p=silc.git diff --git a/lib/silcclient/client.c b/lib/silcclient/client.c index 5b68a771..33d51e10 100644 --- a/lib/silcclient/client.c +++ b/lib/silcclient/client.c @@ -625,6 +625,31 @@ SILC_TASK_CALLBACK_GLOBAL(silc_client_packet_process) } } +/* Callback function that the silc_packet_decrypt will call to make the + decision whether the packet is normal or special packet. We will + return TRUE if it is normal and FALSE if it is special */ + +static int silc_client_packet_decrypt_check(SilcPacketType packet_type, + SilcBuffer buffer, + SilcPacketContext *packet, + void *context) +{ + + /* Packet is normal packet, if: + + 1) packet is private message packet and does not have private key set + 2) is other packet than channel message packet + + all other packets are special packets + */ + if ((packet_type == SILC_PACKET_PRIVATE_MESSAGE && + !(buffer->data[2] & SILC_PACKET_FLAG_PRIVMSG_KEY)) || + packet_type != SILC_PACKET_CHANNEL_MESSAGE) + return TRUE; + + return FALSE; +} + /* Parses whole packet, received earlier. */ SILC_TASK_CALLBACK(silc_client_packet_parse_real) @@ -640,7 +665,8 @@ SILC_TASK_CALLBACK(silc_client_packet_parse_real) SILC_LOG_DEBUG(("Start")); /* Decrypt the received packet */ - ret = silc_packet_decrypt(conn->receive_key, conn->hmac, buffer, packet); + ret = silc_packet_decrypt(conn->receive_key, conn->hmac, buffer, packet, + silc_client_packet_decrypt_check, parse_ctx); if (ret < 0) goto out;