A LOT updates. Cannot separate. :)
[silc.git] / apps / silcd / idlist.h
index d9bfe339fa219f416b41eb93c829c078e34bb6ab..aa444f46f59b78a92ad7f440f83780407bbf4ea2 100644 (file)
@@ -61,6 +61,10 @@ typedef struct SilcChannelEntryStruct *SilcChannelEntry;
        the server SILC will ever need. These are also the informations
        that is broadcasted between servers and routers in the SILC network.
 
+   long last_receive
+
+       Time when data was received from the server last time.
+
    SilcServerEntry router
 
        This is a pointer back to the server list. This is the router server 
@@ -68,9 +72,10 @@ typedef struct SilcChannelEntryStruct *SilcChannelEntry;
        it doesn't have a route this is NULL.
 
    SilcCipher send_key
-   
    SilcCipher receive_key
 
+       Data sending and receiving keys.
+
    void *connection
 
        A pointer, usually, to the socket list for fast referencing to
@@ -83,6 +88,7 @@ struct SilcServerEntryStruct {
   char *server_name;
   int server_type;
   SilcServerID *id;
+  long last_receive;
 
   /* TRUE when server is registered to server */
   int registered;
@@ -165,6 +171,23 @@ struct SilcServerEntryStruct {
        Client's mode.  Client maybe for example server operator or
        router operator (SILC operator).
 
+   long last_receive
+
+       Time of last time data was received from the client. This is
+       result of normal time().
+
+   long last_command
+
+       Time of last time client executed command. We are strict and will
+       not allow any command to be exeucted more than once in about
+       2 seconds. This is result of normal time().
+
+   int registered
+
+       Boolean value to indicate whether this client has registered itself
+       to the server. After KE and authentication protocols has been
+       successfully completed will client become registered.
+
    SilcServerEntry router
 
        This is a pointer to the server list. This is the router server whose 
@@ -181,8 +204,6 @@ struct SilcServerEntryStruct {
        PKCS of the client. This maybe NULL.
 
    SilcHmac hmac
-   unsigned char *hmac_key
-   unsigned int hmac_key_len
 
        MAC key used to compute MAC's for packets. 
 
@@ -201,13 +222,17 @@ struct SilcClientEntryStruct {
   SilcClientID *id;
   int mode;
 
+  /* Time of last accesses of the client */
+  long last_receive;
+  long last_command;
+
   /* TRUE when client is registered to server */
   int registered;
 
   /* Pointer to the router */
   SilcServerEntry router;
 
-  /* Pointers to channels this client has joined */
+  /* List of channels client has joined to */
   SilcChannelEntry *channel;
   unsigned int channel_count;
 
@@ -217,8 +242,6 @@ struct SilcClientEntryStruct {
   SilcPKCS pkcs;
   SilcHmac hmac;
   SilcPublicKey public_key;
-  unsigned char *hmac_key;
-  unsigned int hmac_key_len;
 
   /* Connection data */
   void *connection;
@@ -235,14 +258,15 @@ struct SilcClientEntryStruct {
 
        Pointer to the client list. This is the client currently on channel.
 
-   int mode
+   unsigned int mode
 
        Client's current mode on the channel.
 
 */
 typedef struct SilcChannelClientEntryStruct {
   SilcClientEntry client;
-  int mode;
+  unsigned int mode;
+  struct SilcChannelClientEntryStruct *next;
 } *SilcChannelClientEntry;
 
 /* 
@@ -267,9 +291,10 @@ typedef struct SilcChannelClientEntryStruct {
 
        Logical name of the channel.
 
-   int mode
+   unsigned int mode
 
-       Current mode of the channel.
+       Current mode of the channel.  See lib/silccore/silcchannel.h for
+       all modes.
 
    SilcChannelID *id
 
@@ -290,6 +315,11 @@ typedef struct SilcChannelClientEntryStruct {
 
        Current topic of the channel.
 
+   char *cipher
+
+       Default cipher of the channel. If this is NULL then server picks
+       the cipher to be used. This can be set at SILC_COMMAND_JOIN.
+
    SilcServerEntry router
 
        This is a pointer to the server list. This is the router server 
@@ -313,14 +343,24 @@ typedef struct SilcChannelClientEntryStruct {
 */
 struct SilcChannelEntryStruct {
   char *channel_name;
-  int mode;
+  unsigned int mode;
   SilcChannelID *id;
   int global_users;
   char *topic;
+  char *cipher;
+
+  /* Data that is related to different channel modes. */
+  struct {
+    unsigned int user_limit;
+    unsigned char *passphrase;
+    unsigned char *ban_list;
+    unsigned char *invite_list;
+    unsigned char *cipher;
+    unsigned int key_len;
+  } mode_data;
 
   /* List of users on channel */
-  SilcChannelClientEntry user_list;
-  unsigned int user_list_count;
+  SilcList user_list;
 
   /* Pointer to the router */
   SilcServerEntry router;
@@ -406,6 +446,11 @@ silc_idlist_add_server(SilcIDList id_list,
                       SilcCipher send_key, SilcCipher receive_key,
                       SilcPKCS pkcs, SilcHmac hmac, 
                       SilcPublicKey public_key, void *connection);
+SilcServerEntry
+silc_idlist_find_server_by_id(SilcIDList id_list, SilcServerID *id);
+SilcServerEntry
+silc_idlist_replace_server_id(SilcIDList id_list, SilcServerID *old_id,
+                             SilcServerID *new_id);
 SilcClientEntry
 silc_idlist_add_client(SilcIDList id_list, char *nickname, char *username,
                       char *userinfo, SilcClientID *id, 
@@ -414,14 +459,20 @@ silc_idlist_add_client(SilcIDList id_list, char *nickname, char *username,
                       SilcPKCS pkcs, SilcHmac hmac, 
                       SilcPublicKey public_key, void *connection);
 void silc_idlist_del_client(SilcIDList id_list, SilcClientEntry entry);
+SilcClientEntry *
+silc_idlist_get_clients_by_nickname(SilcIDList id_list, char *nickname,
+                                   char *server, unsigned int *clients_count);
 SilcClientEntry
 silc_idlist_find_client_by_nickname(SilcIDList id_list, char *nickname,
                                    char *server);
 SilcClientEntry
-silc_idlist_find_client_by_hash(SilcIDList id_list, unsigned char *hash,
+silc_idlist_find_client_by_hash(SilcIDList id_list, char *nickname,
                                SilcHash md5hash);
 SilcClientEntry
 silc_idlist_find_client_by_id(SilcIDList id_list, SilcClientID *id);
+SilcClientEntry
+silc_idlist_replace_client_id(SilcIDList id_list, SilcClientID *old_id,
+                             SilcClientID *new_id);
 SilcChannelEntry
 silc_idlist_add_channel(SilcIDList id_list, char *channel_name, int mode,
                        SilcChannelID *id, SilcServerEntry router,