updates.
[silc.git] / apps / silcd / idlist.h
index 6c5d79e7f508b8da8af9a8b62210bbaa4ac8d4a1..bd526b9368ba5732f09953162312f6e7ad15724a 100644 (file)
@@ -30,7 +30,7 @@ typedef struct SilcChannelEntryStruct *SilcChannelEntry;
    the cache. */
 typedef struct {
   SilcIDCache cache;
-  void *timeout_queue;
+  SilcSchedule schedule;
 } *SilcIDListPurge;
 
 /* Channel key re-key context. */
@@ -38,6 +38,7 @@ typedef struct {
   void *context;
   SilcChannelEntry channel;
   uint32 key_len;
+  SilcTask task;
 } *SilcServerChannelRekey;
 
 /* Generic rekey context for connections */
@@ -52,15 +53,24 @@ typedef struct {
   void *context;
 } *SilcServerRekey;
 
+/* ID List Entry status type and all the types. */
+typedef uint8 SilcIDListStatus;
+#define SILC_IDLIST_STATUS_NONE         0x00    /* No status */
+#define SILC_IDLIST_STATUS_REGISTERED   0x01    /* Entry is registered */
+#define SILC_IDLIST_STATUS_RESOLVED     0x02    /* Entry info is resolved */
+#define SILC_IDLIST_STATUS_RESOLVING    0x04    /* Entry is being resolved
+                                                  with WHOIS or IDENTIFY */
+#define SILC_IDLIST_STATUS_DISABLED     0x08    /* Entry is disabled */
+
 /*
    Generic ID list data structure.
 
    This structure is included in all ID list entries and it includes data
    pointers that are common to all ID entries.  This structure is always
    defined to the first field in the ID entries and is used to explicitly
-   cast to this type without first explicitly casting to correct ID entry
-   type.  Hence, the ID list entry is casted to this type to get this data
-   from the ID entry (which is usually opaque pointer).
+   type cast to this type without first explicitly casting to correct ID
+   entry type.  Hence, the ID list entry is type casted to this type to
+   get this data from the ID entry (which is usually opaque pointer).
 
    Note that some of the fields may be NULL.
 
@@ -83,9 +93,12 @@ typedef struct {
   /* Public key */
   SilcPublicKey public_key;
 
-  long last_receive;         /* Time last received data */
-  long last_sent;           /* Time last sent data */
-  bool registered;           /* Boolean whether connection is registered */
+  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;
 
 /* 
@@ -174,7 +187,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
 
@@ -190,21 +203,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;
 
 /* 
@@ -229,6 +232,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:
@@ -290,9 +301,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
 
@@ -301,12 +314,21 @@ typedef struct SilcChannelClientEntryStruct {
        but as just said, this is usually pointer to the socket connection
        list.
 
+   uint16 resolve_cmd_ident
+
+       Command identifier for the entry when the entry's data.status
+       is SILC_IDLIST_STATUS_RESOLVING.  If this entry is asked to be
+       resolved when the status is set then the resolver may attach to
+       this command identifier and handle the process after the resolving
+       is over.
+
 */
 struct SilcClientEntryStruct {
   /* Generic data structure. DO NOT add anything before this! */
   SilcIDListDataStruct data;
 
   unsigned char *nickname;
+  char *servername;
   char *username;
   char *userinfo;
   SilcClientID *id;
@@ -318,11 +340,15 @@ struct SilcClientEntryStruct {
   /* 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;
+
+  /* data.status is RESOLVING and this includes the resolving command 
+     reply identifier. */
+  uint16 resolve_cmd_ident;
 };
 
 /* 
@@ -391,6 +417,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 
@@ -439,8 +471,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;
@@ -453,6 +485,8 @@ struct SilcChannelEntryStruct {
   SilcHmac hmac;
 
   SilcServerChannelRekey rekey;
+
+  unsigned long created;
 };
 
 /* 
@@ -524,20 +558,20 @@ silc_idlist_add_server(SilcIDList id_list,
                       void *connection);
 SilcServerEntry
 silc_idlist_find_server_by_id(SilcIDList id_list, SilcServerID *id,
-                             SilcIDCacheEntry *ret_entry);
+                             bool registered, SilcIDCacheEntry *ret_entry);
 SilcServerEntry
 silc_idlist_find_server_by_name(SilcIDList id_list, char *name,
-                               SilcIDCacheEntry *ret_entry);
+                               bool registered, SilcIDCacheEntry *ret_entry);
 SilcServerEntry
 silc_idlist_find_server_by_conn(SilcIDList id_list, char *hostname,
-                               int port, SilcIDCacheEntry *ret_entry);
+                               int port, bool 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);
 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);
@@ -550,11 +584,8 @@ 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);
+                             bool registered, SilcIDCacheEntry *ret_entry);
 SilcClientEntry
 silc_idlist_replace_client_id(SilcIDList id_list, SilcClientID *old_id,
                              SilcClientID *new_id);