updates.
[silc.git] / lib / silcclient / idlist.h
1 /*
2
3   idlist.h
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 1997 - 2001 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; either version 2 of the License, or
12   (at your option) any later version.
13   
14   This program is distributed in the hope that it will be useful,
15   but WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   GNU General Public License for more details.
18
19 */
20
21 #ifndef IDLIST_H
22 #define IDLIST_H
23
24 /* Client entry context. When client receives information about new client
25    (it receives its ID, for example, by IDENTIFY request) we create new
26    client entry. This entry also includes the private message keys if
27    they are used. */
28 typedef struct {
29   char *nickname;               /* nickname */
30   char *username;               /* username */
31   char *hostname;               /* hostname */
32   char *server;                 /* SILC server name */
33   char *realname;               /* Realname (userinfo) */
34   uint32 num;
35   uint32 mode;                  /* User mode in SILC */
36   SilcClientID *id;             /* The Client ID */
37   SilcCipher send_key;          /* Private message key for sending */
38   SilcCipher receive_key;       /* Private message key for receiving */
39   unsigned char *key;           /* Set only if appliation provided the
40                                    key material. NULL if the library 
41                                    generated the key. */
42   uint32 key_len;
43   int generated;                /* TRUE if library generated the key */
44   SilcClientKeyAgreement ke;    /* Current key agreement context or NULL */
45 } *SilcClientEntry;
46
47 /* Client and its mode on a channel */
48 typedef struct SilcChannelUserStruct {
49   SilcClientEntry client;
50   uint32 mode;
51   struct SilcChannelUserStruct *next;
52 } *SilcChannelUser;
53
54 /* Structure to hold one channel private key. */
55 typedef struct {
56   SilcCipher cipher;                  /* The cipher and key */
57   SilcHmac hmac;                      /* The HMAC and hmac key */
58   unsigned char *key;                 /* The key data */
59   uint32 key_len;                     /* The key length */
60 } *SilcChannelPrivateKey;
61
62 /* Channel entry context. This is allocate for every channel client has
63    joined to. This includes for example the channel specific keys */
64 typedef struct SilcChannelEntryStruct {
65   char *channel_name;
66   SilcChannelID *id;
67   uint32 mode;
68   int on_channel;
69
70   /* Joined clients */
71   SilcList clients;
72
73   /* Channel keys */
74   SilcCipher channel_key;                    /* The channel key */
75   unsigned char *key;                        /* Raw key data */
76   uint32 key_len;
77   unsigned char iv[SILC_CIPHER_MAX_IV_SIZE]; /* Current IV */
78   SilcHmac hmac;                             /* Current HMAC */
79   SilcDList private_keys;                    /* List of private keys or NULL */
80   SilcChannelPrivateKey curr_key;            /* Current private key */
81 } *SilcChannelEntry;
82
83 /* Server entry context. This represents one server. When server information
84    is resolved with INFO command the server info is saved in this context. 
85    Also the connected servers are saved here. */
86 typedef struct {
87   char *server_name;
88   char *server_info;
89   SilcServerID *server_id;
90 } *SilcServerEntry;
91
92 /* Prototypes. These are used only by the library. Application should not
93    call these directly. */
94
95 SilcClientEntry
96 silc_client_add_client(SilcClient client, SilcClientConnection conn,
97                        char *nickname, char *username, 
98                        char *userinfo, SilcClientID *id, uint32 mode);
99 void silc_client_update_client(SilcClient client,
100                                SilcClientConnection conn,
101                                SilcClientEntry client_entry,
102                                const char *nickname,
103                                const char *username,
104                                const char *userinfo,
105                                uint32 mode);
106 void silc_client_del_client_entry(SilcClient client, 
107                                   SilcClientEntry client_entry);
108 SilcClientEntry silc_idlist_get_client(SilcClient client,
109                                        SilcClientConnection conn,
110                                        const char *nickname,
111                                        const char *format,
112                                        bool query);
113 SilcChannelEntry silc_idlist_get_channel_by_id(SilcClient client,
114                                                SilcClientConnection conn,
115                                                SilcChannelID *channel_id,
116                                                int query);
117 void silc_client_nickname_format(SilcClient client, 
118                                  SilcClientConnection conn,
119                                  SilcClientEntry client_entry);
120
121 #endif