X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=apps%2Fsilcd%2Fidlist.h;h=7b9c2ad139647bd385ee5e09369d5d4e7b130666;hb=805fddcf6431e784f9f77114782a90c9d12f9cbe;hp=cfb46feaddf2847f56cea06e3aba6296646dfbd1;hpb=413da0f8686910f5e627393157566ae729ca99c4;p=silc.git diff --git a/apps/silcd/idlist.h b/apps/silcd/idlist.h index cfb46fea..7b9c2ad1 100644 --- a/apps/silcd/idlist.h +++ b/apps/silcd/idlist.h @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2003 Pekka Riikonen + Copyright (C) 1997 - 2005, 2007 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,10 +21,7 @@ #ifndef IDLIST_H #define IDLIST_H -/* Forward declarations */ -typedef struct SilcServerEntryStruct *SilcServerEntry; -typedef struct SilcClientEntryStruct *SilcClientEntry; -typedef struct SilcChannelEntryStruct *SilcChannelEntry; +#include "serverconfig.h" /* Context for holding cache information to periodically purge the cache. */ @@ -40,18 +37,6 @@ typedef struct { SilcTask task; } *SilcServerChannelRekey; -/* Generic rekey context for connections */ -typedef struct { - /* Current sending encryption key, provided for re-key. The `pfs' - is TRUE if the Perfect Forward Secrecy is performed in re-key. */ - unsigned char *send_enc_key; - SilcUInt32 enc_key_len; - int ske_group; - bool pfs; - SilcUInt32 timeout; - void *context; -} *SilcServerRekey; - /* ID List Entry status flags. */ typedef SilcUInt8 SilcIDListStatus; #define SILC_IDLIST_STATUS_NONE 0x00 /* No status */ @@ -80,36 +65,23 @@ typedef SilcUInt8 SilcIDListStatus; Note that some of the fields may be NULL. */ -typedef struct { - /* Send and receive symmetric keys */ - SilcCipher send_key; - SilcCipher receive_key; - - /* HMAC */ - SilcHmac hmac_send; - SilcHmac hmac_receive; - - /* Packet sequence numbers */ - SilcUInt32 psn_send; - SilcUInt32 psn_receive; - - /* Hash selected in the SKE protocol, NULL if not needed at all */ +struct SilcIDListDataObject { + SilcConnectionType conn_type; /* Connection type */ + SilcServerConnection sconn; /* Connection context */ + SilcSKERekeyMaterial rekey; /* Rekey material */ SilcHash hash; /* Public key */ SilcPublicKey public_key; unsigned char fingerprint[20]; - /* Re-key context */ - SilcServerRekey rekey; - long last_receive; /* Time last received data */ long last_sent; /* Time last sent data */ unsigned long created; /* Time when entry was created */ SilcIDListStatus status; /* Status mask of the entry */ -} *SilcIDListData, SilcIDListDataStruct; +}; /* SILC Server entry object. @@ -190,6 +162,9 @@ struct SilcServerEntryStruct { /* Connection data */ void *connection; + + void *backup_proto; + unsigned int backup : 1; /* Set when executing backup protocol */ }; /* @@ -244,7 +219,10 @@ typedef struct SilcChannelClientEntryStruct { unsigned char *nickname - The nickname of the client. + The nickname of the client. This is nickname in original format, + not casefolded or normalized. However, it is checked to assure + that prohibited characters do not exist. The casefolded version + is in the ID Cache. char *servername @@ -366,6 +344,10 @@ struct SilcClientEntryStruct { /* data.status is RESOLVING and this includes the resolving command reply identifier. */ SilcUInt16 resolve_cmd_ident; + + /* we need this so nobody can resume more than once at the same time - + * server crashes, really odd behaviour, ... */ + SilcClientEntry resuming_client; }; /* @@ -388,7 +370,10 @@ struct SilcClientEntryStruct { char *channel_name - Logical name of the channel. + Logical name of the channel. This is the original format, not + the casefolded or normalized. However, this is checked to assure + that prohibited characters do not exist. The casefolded version + is in the ID Cache. SilcUInt32 mode @@ -400,7 +385,7 @@ struct SilcClientEntryStruct { ID of the channel. This includes all the information SILC will ever need. - bool global_users + SilcBool global_users Boolean value to tell whether there are users outside this server on this channel. This is set to TRUE if router sends message to @@ -442,7 +427,8 @@ struct SilcClientEntryStruct { whose cell this channel belongs to. This is used to route messages to this channel. - SilcCipher channel_key + SilcCipher send_key + SilcCipher receive_key The key of the channel (the cipher actually). @@ -488,7 +474,8 @@ struct SilcChannelEntryStruct { SilcServerEntry router; /* Channel keys */ - SilcCipher channel_key; + SilcCipher send_key; + SilcCipher receive_key; unsigned char *key; SilcUInt32 key_len; SilcHmac hmac; @@ -539,11 +526,11 @@ struct SilcChannelEntryStruct { channel entry). */ -typedef struct SilcIDListStruct { +struct SilcIDListStruct { SilcIDCache servers; SilcIDCache clients; SilcIDCache channels; -} *SilcIDList; +}; /* ID Entry for Unknown connections. @@ -559,12 +546,21 @@ typedef struct SilcIDListStruct { typedef struct { /* Generic data structure. DO NOT add anything before this! */ SilcIDListDataStruct data; + SilcAsyncOperation op; + SilcServerConfigRef cconfig; + SilcServerConfigRef sconfig; + SilcServerConfigRef rconfig; + SilcServer server; + const char *hostname; + const char *ip; + SilcUInt16 port; + SilcConnectionType conn_type; } *SilcUnknownEntry; /* Prototypes */ void silc_idlist_add_data(void *entry, SilcIDListData idata); void silc_idlist_del_data(void *entry); -SILC_TASK_CALLBACK_GLOBAL(silc_idlist_purge); +SILC_TASK_CALLBACK(silc_idlist_purge); SilcServerEntry silc_idlist_add_server(SilcIDList id_list, char *server_name, int server_type, @@ -572,46 +568,56 @@ silc_idlist_add_server(SilcIDList id_list, void *connection); SilcServerEntry silc_idlist_find_server_by_id(SilcIDList id_list, SilcServerID *id, - bool registered, SilcIDCacheEntry *ret_entry); + SilcBool registered, SilcIDCacheEntry *ret_entry); SilcServerEntry silc_idlist_find_server_by_name(SilcIDList id_list, char *name, - bool registered, SilcIDCacheEntry *ret_entry); + SilcBool registered, SilcIDCacheEntry *ret_entry); SilcServerEntry silc_idlist_find_server_by_conn(SilcIDList id_list, char *hostname, - int port, bool registered, + int port, SilcBool registered, SilcIDCacheEntry *ret_entry); SilcServerEntry silc_idlist_replace_server_id(SilcIDList id_list, SilcServerID *old_id, SilcServerID *new_id); int silc_idlist_del_server(SilcIDList id_list, SilcServerEntry entry); +void silc_idlist_server_destructor(SilcIDCache cache, + SilcIDCacheEntry entry, + void *dest_context, + void *app_context); SilcClientEntry silc_idlist_add_client(SilcIDList id_list, char *nickname, char *username, char *userinfo, SilcClientID *id, - SilcServerEntry router, void *connection, - int expire); + SilcServerEntry router, void *connection); int silc_idlist_del_client(SilcIDList id_list, SilcClientEntry entry); int silc_idlist_get_clients_by_nickname(SilcIDList id_list, char *nickname, char *server, SilcClientEntry **clients, SilcUInt32 *clients_count); -int silc_idlist_get_clients_by_hash(SilcIDList id_list, char *nickname, +int silc_idlist_get_clients_by_hash(SilcIDList id_list, + char *nickname, char *server, SilcHash md5hash, SilcClientEntry **clients, SilcUInt32 *clients_count); SilcClientEntry silc_idlist_find_client_by_id(SilcIDList id_list, SilcClientID *id, - bool registered, SilcIDCacheEntry *ret_entry); + SilcBool registered, SilcIDCacheEntry *ret_entry); SilcClientEntry silc_idlist_replace_client_id(SilcServer server, SilcIDList id_list, SilcClientID *old_id, SilcClientID *new_id, const char *nickname); void silc_idlist_client_destructor(SilcIDCache cache, - SilcIDCacheEntry entry); + SilcIDCacheEntry entry, + void *dest_context, + void *app_context); SilcChannelEntry silc_idlist_add_channel(SilcIDList id_list, char *channel_name, int mode, SilcChannelID *id, SilcServerEntry router, - SilcCipher channel_key, SilcHmac hmac, - int expire); + SilcCipher send_key, SilcCipher receive_key, + SilcHmac hmac); +void silc_idlist_channel_destructor(SilcIDCache cache, + SilcIDCacheEntry entry, + void *dest_context, + void *app_context); int silc_idlist_del_channel(SilcIDList id_list, SilcChannelEntry entry); SilcChannelEntry silc_idlist_find_channel_by_name(SilcIDList id_list, char *name,