data->public_key = idata->public_key;
data->last_receive = idata->last_receive;
data->last_sent = idata->last_sent;
- data->registered = idata->registered;
+ data->status = idata->status;
+
+ data->created = time(0); /* Update creation time */
}
/* Free's all data in the common ID entry data structure. */
SilcServerEntry
silc_idlist_find_server_by_id(SilcIDList id_list, SilcServerID *id,
- SilcIDCacheEntry *ret_entry)
+ bool registered, SilcIDCacheEntry *ret_entry)
{
SilcIDCacheEntry id_cache = NULL;
SilcServerEntry server;
if (ret_entry)
*ret_entry = id_cache;
+ if (server && registered &&
+ !(server->data.status & SILC_IDLIST_STATUS_REGISTERED))
+ return NULL;
+
SILC_LOG_DEBUG(("Found"));
return server;
SilcServerEntry
silc_idlist_find_server_by_name(SilcIDList id_list, char *name,
- SilcIDCacheEntry *ret_entry)
+ bool registered, SilcIDCacheEntry *ret_entry)
{
SilcIDCacheEntry id_cache = NULL;
SilcServerEntry server;
if (ret_entry)
*ret_entry = id_cache;
+ if (server && registered &&
+ !(server->data.status & SILC_IDLIST_STATUS_REGISTERED))
+ return NULL;
+
SILC_LOG_DEBUG(("Found"));
return server;
SilcServerEntry
silc_idlist_find_server_by_conn(SilcIDList id_list, char *hostname,
- int port, SilcIDCacheEntry *ret_entry)
+ int port, bool registered,
+ SilcIDCacheEntry *ret_entry)
{
SilcIDCacheList list = NULL;
SilcIDCacheEntry id_cache = NULL;
if (ret_entry)
*ret_entry = id_cache;
+ if (server && registered &&
+ !(server->data.status & SILC_IDLIST_STATUS_REGISTERED))
+ return NULL;
+
SILC_LOG_DEBUG(("Found"));
return server;
return FALSE;
/* Free data */
- if (entry->server_name)
- silc_free(entry->server_name);
- if (entry->id)
- silc_free(entry->id);
+ silc_free(entry->server_name);
+ silc_free(entry->id);
memset(entry, 'F', sizeof(*entry));
silc_free(entry);
return FALSE;
/* Free data */
- if (entry->nickname)
- silc_free(entry->nickname);
- if (entry->username)
- silc_free(entry->username);
- if (entry->userinfo)
- silc_free(entry->userinfo);
- if (entry->id)
- silc_free(entry->id);
+ silc_free(entry->nickname);
+ silc_free(entry->username);
+ silc_free(entry->userinfo);
+ silc_free(entry->id);
memset(entry, 'F', sizeof(*entry));
silc_free(entry);
{
SilcIDCacheList list = NULL;
SilcIDCacheEntry id_cache = NULL;
- int i;
SILC_LOG_DEBUG(("Start"));
(silc_idcache_list_count(list) + *clients_count) *
sizeof(**clients));
- i = 0;
silc_idcache_list_first(list, &id_cache);
- (*clients)[i++] = (SilcClientEntry)id_cache->context;
+ (*clients)[(*clients_count)++] = (SilcClientEntry)id_cache->context;
while (silc_idcache_list_next(list, &id_cache))
- (*clients)[i++] = (SilcClientEntry)id_cache->context;
+ (*clients)[(*clients_count)++] = (SilcClientEntry)id_cache->context;
silc_idcache_list_free(list);
- *clients_count += i;
-
- SILC_LOG_DEBUG(("Found %d clients", *clients_count));
+ SILC_LOG_DEBUG(("Found total %d clients", *clients_count));
return TRUE;
}
SilcIDCacheList list = NULL;
SilcIDCacheEntry id_cache = NULL;
unsigned char hash[32];
- int i;
SilcClientID client_id;
SILC_LOG_DEBUG(("Start"));
(silc_idcache_list_count(list) + *clients_count) *
sizeof(**clients));
- i = 0;
silc_idcache_list_first(list, &id_cache);
- (*clients)[i++] = (SilcClientEntry)id_cache->context;
+ (*clients)[(*clients_count)++] = (SilcClientEntry)id_cache->context;
while (silc_idcache_list_next(list, &id_cache))
- (*clients)[i++] = (SilcClientEntry)id_cache->context;
+ (*clients)[(*clients_count)++] = (SilcClientEntry)id_cache->context;
silc_idcache_list_free(list);
- *clients_count += i;
-
- SILC_LOG_DEBUG(("Found %d clients", *clients_count));
+ SILC_LOG_DEBUG(("Found total %d clients", *clients_count));
return TRUE;
}
SilcClientEntry
silc_idlist_find_client_by_id(SilcIDList id_list, SilcClientID *id,
- SilcIDCacheEntry *ret_entry)
+ bool registered, SilcIDCacheEntry *ret_entry)
{
SilcIDCacheEntry id_cache = NULL;
SilcClientEntry client;
if (ret_entry)
*ret_entry = id_cache;
+ if (client && registered &&
+ !(client->data.status & SILC_IDLIST_STATUS_REGISTERED))
+ return NULL;
+
SILC_LOG_DEBUG(("Found"));
return client;
silc_free(client->id);
client->id = new_id;
- silc_idcache_add(id_list->clients, client->nickname, client->id,
- client, FALSE);
+ silc_idcache_add(id_list->clients, NULL, client->id, client, FALSE);
SILC_LOG_DEBUG(("Replaced"));
channel->router = router;
channel->channel_key = channel_key;
channel->hmac = hmac;
+ channel->created = time(0);
if (!channel->hmac)
- if (!silc_hmac_alloc("hmac-sha1-96", NULL, &channel->hmac)) {
+ if (!silc_hmac_alloc(SILC_DEFAULT_HMAC, NULL, &channel->hmac)) {
silc_free(channel);
return NULL;
}
return FALSE;
/* Free data */
- if (entry->channel_name)
- silc_free(entry->channel_name);
- if (entry->id)
- silc_free(entry->id);
- if (entry->topic)
- silc_free(entry->topic);
+ silc_free(entry->channel_name);
+ silc_free(entry->id);
+ silc_free(entry->topic);
if (entry->channel_key)
silc_cipher_free(entry->channel_key);
if (entry->key) {
memset(entry->key, 0, entry->key_len / 8);
silc_free(entry->key);
}
- if (entry->cipher)
- silc_free(entry->cipher);
- if (entry->hmac_name)
- silc_free(entry->hmac_name);
- if (entry->rekey)
- silc_free(entry->rekey);
+ silc_free(entry->cipher);
+ silc_free(entry->hmac_name);
+ silc_free(entry->rekey);
/* Free all client entrys from the users list. The silc_hash_table_free
will free all the entries so they are not freed at the foreach