+ if (server && registered &&
+ !(server->data.status & SILC_IDLIST_STATUS_REGISTERED))
+ return NULL;
+
+ if (ret_entry)
+ *ret_entry = id_cache;
+
+ SILC_LOG_DEBUG(("Found"));
+
+ return server;
+}
+
+/* Find server by connection parameters, hostname and port */
+
+SilcServerEntry
+silc_idlist_find_server_by_conn(SilcIDList id_list, char *hostname,
+ int port, SilcBool registered,
+ SilcIDCacheEntry *ret_entry)
+{
+ SilcList list;
+ SilcIDCacheEntry id_cache = NULL;
+ SilcServerEntry server = NULL;
+ SilcPacketStream sock;
+ const char *host = NULL, *ip = NULL;
+
+ SILC_LOG_DEBUG(("Server by hostname %s and port %d", hostname, port));
+
+ if (!silc_idcache_get_all(id_list->servers, &list))
+ return NULL;
+
+ silc_list_start(list);
+ while ((id_cache = silc_list_get(list))) {
+ server = id_cache->context;
+ sock = server->connection;
+
+ if (sock && silc_socket_stream_get_info(
+ silc_packet_stream_get_stream(sock),
+ NULL, &host, &ip, NULL)) {
+ if (((host && !strcasecmp(host, hostname)) ||
+ (ip && !strcasecmp(ip, hostname))) &&
+ server->id->port == SILC_SWAB_16(port))
+ break;
+ }
+
+ id_cache = NULL;
+ server = NULL;
+ }
+
+ if (server && registered &&
+ !(server->data.status & SILC_IDLIST_STATUS_REGISTERED))
+ return NULL;
+