- if (!silc_idcache_find_by_id_one(conn->client_cache, remote_id,
- SILC_ID_CLIENT, &id_cache))
- {
- /* Allocate client entry */
- remote_client = silc_calloc(1, sizeof(*remote_client));
- remote_client->id = remote_id;
- silc_parse_nickname(nickname, &remote_client->nickname,
- &remote_client->server, &remote_client->num);
-
- /* Save the client to cache */
- silc_idcache_add(conn->client_cache, remote_client->nickname,
- SILC_ID_CLIENT, remote_client->id, remote_client,
- TRUE);
- } else {
- remote_client = (SilcClientEntry)id_cache->context;
- }
+ if (!silc_idcache_find_by_id_one_ext(conn->client_cache, (void *)remote_id,
+ NULL, NULL,
+ silc_hash_client_id_compare, NULL,
+ &id_cache)) {
+ /* Resolve the client info */
+ silc_client_get_client_by_id_resolve(client, conn, remote_id,
+ silc_client_private_message_cb,
+ silc_packet_context_dup(packet));
+ return;
+ }
+
+ remote_client = (SilcClientEntry)id_cache->context;
+
+ /* Parse the payload and decrypt it also if private message key is set */
+ payload = silc_private_message_payload_parse(packet->buffer,
+ remote_client->receive_key);
+ if (!payload) {
+ silc_free(remote_id);
+ return;
+ }
+
+ flags = silc_private_message_get_flags(payload);