019bd3c23f4be5e65c9c2dfdd13996378c170667
[silc.git] / lib / silcclient / client.h
1 /*
2
3   client.h
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 1997 - 2014 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; version 2 of the License.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18 */
19
20 #ifndef CLIENT_H
21 #define CLIENT_H
22
23 #ifndef SILCCLIENT_H
24 #error "Do not include this header directly"
25 #endif
26
27 /* Forward declarations */
28 typedef struct SilcClientStruct *SilcClient;
29 typedef struct SilcClientConnectionStruct *SilcClientConnection;
30 typedef struct SilcClientEntryStruct *SilcClientEntry;
31 typedef struct SilcChannelEntryStruct *SilcChannelEntry;
32 typedef struct SilcServerEntryStruct *SilcServerEntry;
33
34 typedef struct SilcClientKeyAgreementStruct *SilcClientKeyAgreement;
35 typedef struct SilcClientFtpSessionStruct *SilcClientFtpSession;
36 typedef struct SilcClientCommandReplyContextStruct
37                                            *SilcClientCommandReplyContext;
38 typedef struct SilcChannelUserStruct *SilcChannelUser;
39 typedef struct SilcClientInternalStruct *SilcClientInternal;
40 typedef struct SilcClientConnectionInternalStruct
41      *SilcClientConnectionInternal;
42 typedef struct SilcChannelPrivateKeyStruct *SilcChannelPrivateKey;
43
44 /* Internal client entry context */
45 typedef struct SilcClientEntryInternalStruct {
46   void *prv_waiter;             /* Private message packet waiter */
47   SilcRwLock lock;              /* Read/write lock */
48   SilcCipher send_key;          /* Private message key for sending */
49   SilcCipher receive_key;       /* Private message key for receiving */
50   SilcHmac hmac_send;           /* Private mesage key HMAC for sending */
51   SilcHmac hmac_receive;        /* Private mesage key HMAC for receiving */
52   unsigned char *key;           /* Valid if application provided the key */
53   SilcUInt32 key_len;           /* Key data length */
54   SilcClientKeyAgreement ke;    /* Current key agreement context or NULL */
55   SilcAsyncOperation op;        /* Asynchronous operation with this client */
56
57   SilcAtomic32 refcnt;          /* Reference counter */
58   SilcAtomic32 deleted;         /* Flag indicating whether the client object is
59                                    already scheduled for deletion */
60   SilcUInt16 resolve_cmd_ident; /* Command identifier when resolving */
61
62   /* Flags */
63   unsigned int valid       : 1; /* FALSE if this entry is not valid.  Entry
64                                    without nickname is not valid. */
65   unsigned int generated   : 1; /* TRUE if library generated `key' */
66   unsigned int prv_resp    : 1; /* TRUE if we are responder when using
67                                    private message keys. */
68 } SilcClientEntryInternal;
69
70 /* Internal channel entry context */
71 typedef struct SilcChannelEntryInternalStruct {
72   SilcRwLock lock;                           /* Read/write lock */
73
74   /* SilcChannelEntry status information */
75   SilcDList old_channel_keys;
76   SilcDList old_hmacs;
77
78   /* Channel private keys */
79   SilcDList private_keys;                    /* List of private keys or NULL */
80   SilcChannelPrivateKey curr_key;            /* Current private key */
81
82   /* Channel keys */
83   SilcCipher send_key;                       /* The channel key */
84   SilcCipher receive_key;                    /* The channel key */
85   SilcHmac hmac;                             /* Current HMAC */
86   unsigned char iv[SILC_CIPHER_MAX_IV_SIZE]; /* Current IV */
87
88   SilcAtomic32 refcnt;                       /* Reference counter */
89   SilcAtomic32 deleted;                      /* Flag indicating whether the
90                                                 channel object is already
91                                                 scheduled for deletion */
92   SilcUInt16 resolve_cmd_ident;              /* Channel information resolving
93                                                 identifier. This is used when
94                                                 resolving users, and other
95                                                 stuff that relates to the
96                                                 channel. Not used for the
97                                                 channel resolving itself. */
98 } SilcChannelEntryInternal;
99
100 /* Internal server entry context */
101 typedef struct SilcServerEntryInternalStruct {
102   SilcRwLock lock;                           /* Read/write lock */
103   SilcUInt16 resolve_cmd_ident;              /* Resolving identifier */
104   SilcAtomic32 refcnt;                       /* Reference counter */
105   SilcAtomic32 deleted;                      /* Flag indicating whether the
106                                                 server object is already
107                                                 scheduled for deletion. */
108 } SilcServerEntryInternal;
109
110 #endif /* CLIENT_H */