update.
[silc.git] / lib / silcclient / idlist.h
1 /*
2
3   idlist.h
4
5   Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
6
7   Copyright (C) 1997 - 2000 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 SilcClientEntryStruct {
29   char *nickname;               /* nickname */
30   char *username;               /* username[@host] */
31   char *server;                 /* SILC server name */
32   char *realname;               /* Realname (userinfo) */
33   unsigned int num;
34   unsigned int mode;            /* User mode in SILC */
35   SilcClientID *id;             /* The Client ID */
36   SilcCipher send_key;          /* Private message key for sending */
37   SilcCipher receive_key;       /* Private message key for receiving */
38   unsigned char *key;           /* Set only if appliation provided the
39                                    key material. NULL if the library 
40                                    generated the key. */
41   unsigned int key_len;
42   int generated;                /* TRUE if library generated the key */
43   SilcClientKeyAgreement ke;    /* Current key agreement context or NULL */
44 } *SilcClientEntry;
45
46 /* Client and its mode on a channel */
47 typedef struct SilcChannelUserStruct {
48   SilcClientEntry client;
49   unsigned int mode;
50   struct SilcChannelUserStruct *next;
51 } *SilcChannelUser;
52
53 /* Structure to hold one channel private key. */
54 typedef struct {
55   SilcCipher cipher;                  /* The cipher and key */
56   SilcHmac hmac;                      /* The HMAC and hmac key */
57   unsigned char *key;                 /* The key data */
58   unsigned int key_len;               /* The key length */
59 } *SilcChannelPrivateKey;
60
61 /* Channel entry context. This is allocate for every channel client has
62    joined to. This includes for example the channel specific keys */
63 typedef struct SilcChannelEntryStruct {
64   char *channel_name;
65   SilcChannelID *id;
66   unsigned int mode;
67   int on_channel;
68
69   /* Joined clients */
70   SilcList clients;
71
72   /* Channel keys */
73   SilcCipher channel_key;                    /* The channel key */
74   unsigned char *key;                        /* Raw key data */
75   unsigned int key_len;
76   unsigned char iv[SILC_CIPHER_MAX_IV_SIZE]; /* Current IV */
77   SilcHmac hmac;                             /* Current HMAC */
78   SilcDList private_keys;                    /* List of private keys or NULL */
79   SilcChannelPrivateKey curr_key;            /* Current private key */
80 } *SilcChannelEntry;
81
82 /* Prototypes (some functions are defined in the silcapi.h) */
83
84 SilcClientEntry silc_idlist_get_client(SilcClient client,
85                                        SilcClientConnection conn,
86                                        char *nickname,
87                                        char *server,
88                                        unsigned int num,
89                                        int query);
90
91 #endif