updates.
[silc.git] / apps / silcd / idlist.h
index eff107b6aae2d84327a9792653dd3ffee5713a90..f701514bc7fd6314b7f61cc72bfbc0efd469b92b 100644 (file)
@@ -40,6 +40,18 @@ typedef struct {
   uint32 key_len;
 } *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;
+  uint32 enc_key_len;
+  int ske_group;
+  bool pfs;
+  uint32 timeout;
+  void *context;
+} *SilcServerRekey;
+
 /*
    Generic ID list data structure.
 
@@ -58,20 +70,22 @@ typedef struct {
   SilcCipher send_key;
   SilcCipher receive_key;
 
+  /* Re-key context */
+  SilcServerRekey rekey;
+
   /* Hash selected in the SKE protocol, NULL if not needed at all */
   SilcHash hash;
 
-  /* HMAC and raw key data */
-  SilcHmac hmac;
-  unsigned char *hmac_key;
-  uint32 hmac_key_len;
+  /* HMAC */
+  SilcHmac hmac_send;
+  SilcHmac hmac_receive;
 
-  /* public key */
+  /* Public key */
   SilcPublicKey public_key;
 
   long last_receive;         /* Time last received data */
   long last_sent;           /* Time last sent data */
-  unsigned char registered;  /* Boolean whether connection is registered */
+  bool registered;           /* Boolean whether connection is registered */
 } *SilcIDListData, SilcIDListDataStruct;
 
 /* 
@@ -102,7 +116,7 @@ typedef struct {
        Logical name of the server. There is no limit of the length of the
        server name. This is usually the same name as defined in DNS.
 
-   int server_type
+   uint8 server_type
 
        Type of the server. SILC_SERVER or SILC_ROUTER are the possible
        choices for this.
@@ -143,7 +157,7 @@ struct SilcServerEntryStruct {
   SilcIDListDataStruct data;
 
   char *server_name;
-  int server_type;
+  uint8 server_type;
   SilcServerID *id;
   char *server_info;
   char *motd;
@@ -160,7 +174,7 @@ struct SilcServerEntryStruct {
 
    This entry used only by the SilcChannelEntry object and it holds
    information about current clients (ie. users) on channel. Following
-   short description  of the fields:
+   short description of the fields:
 
    SilcClientEntry client
 
@@ -176,21 +190,11 @@ struct SilcServerEntryStruct {
        SilcClientEntry we have this here for fast access to the channel when
        used by SilcClientEntry.
 
-  struct SilcChannelClientEntryStruct *client_list
-  struct SilcChannelClientEntryStruct *channel_list
-
-       List member pointers. This structure is used by channel entry and
-       client entry thus we must have separate list member pointers for
-       them since we are using same entry for both lists (the entry is not
-       duplicated). SilcList requires this.
-
 */
 typedef struct SilcChannelClientEntryStruct {
   SilcClientEntry client;
   uint32 mode;
   SilcChannelEntry channel;
-  struct SilcChannelClientEntryStruct *client_list;
-  struct SilcChannelClientEntryStruct *channel_list;
 } *SilcChannelClientEntry;
 
 /* 
@@ -215,6 +219,14 @@ typedef struct SilcChannelClientEntryStruct {
 
        Generic data structure to hold data common to all ID entries.
 
+   unsigned char *nickname
+
+       The nickname of the client.
+
+   char *servername
+
+       The name of the server where the client is from. MAy be NULL.
+
    char username
 
        Client's usename. This is defined in the following manner:
@@ -253,7 +265,7 @@ typedef struct SilcChannelClientEntryStruct {
        nickname. Nickname is not relevant information that would need to be 
        saved as plain.
 
-   int mode
+   uint32 mode
 
        Client's mode.  Client maybe for example server operator or
        router operator (SILC operator).
@@ -264,7 +276,7 @@ typedef struct SilcChannelClientEntryStruct {
        not allow any command to be exeucted more than once in about
        2 seconds. This is result of normal time().
 
-   char fast_command
+   uint8 fast_command
 
        Counter to check command bursts.  By default, up to 5 commands
        are allowed before limiting the execution.  See command flags
@@ -276,9 +288,11 @@ typedef struct SilcChannelClientEntryStruct {
        cell this client is coming from. This is used to route messages to 
        this client.
 
-   SilcList channels
+   SilcHashTable channels;
 
-       List of channels this client has joined.
+       All the channels this client has joined.  The context saved in the
+       hash table shares memory with the channel entrys `user_list' hash
+       table.
 
    void *connection
 
@@ -293,19 +307,20 @@ struct SilcClientEntryStruct {
   SilcIDListDataStruct data;
 
   unsigned char *nickname;
+  char *servername;
   char *username;
   char *userinfo;
   SilcClientID *id;
-  int mode;
+  uint32 mode;
 
   long last_command;
-  char fast_command;
+  uint8 fast_command;
 
   /* Pointer to the router */
   SilcServerEntry router;
 
-  /* List of channels client has joined to */
-  SilcList channels;
+  /* All channels this client has joined */
+  SilcHashTable channels;
 
   /* Connection data */
   void *connection;
@@ -343,7 +358,7 @@ struct SilcClientEntryStruct {
        ID of the channel. This includes all the information SILC will ever
        need.
 
-   int global_users
+   bool 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
@@ -377,6 +392,12 @@ struct SilcClientEntryStruct {
        if the method is SILC_AUTH_PASSWORD.  If it is SILC_AUTH_PUBLIC_KEY
        then the `founder_passwd' is NULL.
 
+   SilcHashTable user_list
+
+       All users joined on this channel.  Note that the context saved to
+       this entry shares memory with the client entrys `channels' hash
+       table.
+
    SilcServerEntry router
 
        This is a pointer to the server list. This is the router server 
@@ -410,7 +431,7 @@ struct SilcChannelEntryStruct {
   char *channel_name;
   uint32 mode;
   SilcChannelID *id;
-  int global_users;
+  bool global_users;
   char *topic;
   char *cipher;
   char *hmac_name;
@@ -425,8 +446,8 @@ struct SilcChannelEntryStruct {
   char *invite_list;
   char *ban_list;
 
-  /* List of users on channel */
-  SilcList user_list;
+  /* All users on this channel */
+  SilcHashTable user_list;
 
   /* Pointer to the router */
   SilcServerEntry router;
@@ -522,8 +543,7 @@ silc_idlist_replace_server_id(SilcIDList id_list, SilcServerID *old_id,
                              SilcServerID *new_id);
 int silc_idlist_del_server(SilcIDList id_list, SilcServerEntry entry);
 SilcClientEntry
-silc_idlist_add_client(SilcIDList id_list, unsigned char *nickname, 
-                      uint32 nickname_len, char *username, 
+silc_idlist_add_client(SilcIDList id_list, char *nickname, char *username, 
                       char *userinfo, SilcClientID *id, 
                       SilcServerEntry router, void *connection);
 int silc_idlist_del_client(SilcIDList id_list, SilcClientEntry entry);
@@ -536,9 +556,6 @@ int silc_idlist_get_clients_by_hash(SilcIDList id_list, char *nickname,
                                    SilcClientEntry **clients,
                                    uint32 *clients_count);
 SilcClientEntry
-silc_idlist_find_client_by_hash(SilcIDList id_list, char *nickname,
-                               SilcHash md5hash, SilcIDCacheEntry *ret_entry);
-SilcClientEntry
 silc_idlist_find_client_by_id(SilcIDList id_list, SilcClientID *id,
                              SilcIDCacheEntry *ret_entry);
 SilcClientEntry