Added SILC Server library.
[silc.git] / lib / silcserver / silcserver_params.h
1 /*
2
3   silcserver_params.h
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 1997 - 2005 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 SILCSERVER_PARAMS_H
21 #define SILCSERVER_PARAMS_H
22
23 typedef struct SilcServerParamCipherStruct {
24   char *name;
25   char *module;
26   SilcUInt32 key_length;
27   SilcUInt32 block_length;
28   struct SilcServerParamCipherStruct *next;
29 } *SilcServerParamCipher;
30
31 typedef struct SilcServerParamHashStruct {
32   char *name;
33   char *module;
34   SilcUInt32 block_length;
35   SilcUInt32 digest_length;
36   struct SilcServerParamHashStruct *next;
37 } *SilcServerParamHash;
38
39 typedef struct SilcServerParamHmacStruct {
40   char *name;
41   char *hash;
42   SilcUInt32 mac_length;
43   struct SilcServerParamHmacStruct *next;
44 } *SilcServerParamHmac;
45
46 typedef struct SilcServerParamPkcsStruct {
47   char *name;
48   struct SilcServerParamPkcsStruct *next;
49 } *SilcServerParamPkcs;
50
51 typedef struct SilcServerParamInterfaceStruct {
52   char *ip;                             /* IP address */
53   SilcUInt16 port;                      /* Port */
54   struct SilcServerParamInterfaceStruct *next;
55 } *SilcServerParamInterface;
56
57 typedef struct SilcServerParamServerInfoStruct {
58   char *server_name;                    /* Server name */
59   SilcList interfaces;                  /* SilcServerParamInterface */
60   char *server_type;                    /* E.g. "Test Server" */
61   char *location;                       /* Geographic location */
62   char *admin;                          /* Admin's full name */
63   char *email;                          /* Admin's email address */
64   char *user;                           /* Userid the server use */
65   char *group;                          /* Groupid the server use  */
66   char *motd_file;                      /* Path to text MOTD file */
67   char *pid_file;                       /* Path to the PID file */
68   SilcPublicKey public_key;             /* Server's public key */
69   SilcPrivateKey private_key;           /* Server's private key */
70 } *SilcServerParamServerInfo;
71
72 typedef struct SilcServerParamLoggingStruct {
73   char *file;
74   SilcUInt32 maxsize;
75 } *SilcServerParamLogging;
76
77 /* Connection parameters */
78 typedef struct SilcServerParamConnParamsObject {
79   struct SilcServerParamConnParams *next;
80   char *name;
81   char *version_protocol;
82   char *version_software;
83   char *version_software_vendor;
84   SilcUInt32 connections_max;
85   SilcUInt32 connections_max_per_host;
86   SilcUInt32 keepalive_secs;
87   SilcUInt32 reconnect_count;
88   SilcUInt32 reconnect_interval;
89   SilcUInt32 reconnect_interval_max;
90   SilcUInt32 key_exchange_rekey;
91   SilcUInt32 qos_rate_limit;
92   SilcUInt32 qos_bytes_limit;
93   SilcUInt32 qos_limit_sec;
94   SilcUInt32 qos_limit_usec;
95   SilcUInt32 chlimit;
96   unsigned int key_exchange_pfs      : 1;
97   unsigned int reconnect_keep_trying : 1;
98   unsigned int anonymous             : 1;
99   unsigned int qos                   : 1;
100 } *SilcServerParamConnParams, SilcServerParamConnParamsStruct;
101
102 /* Holds all client authentication data from config file */
103 typedef struct SilcServerParamClientStruct {
104   char *host;
105   unsigned char *passphrase;
106   SilcUInt32 passphrase_len;
107   SilcHashTable publickeys;
108   SilcBool pubkey_auth;
109   SilcServerParamConnParams param;
110   struct SilcServerParamClientStruct *next;
111 } *SilcServerParamClient;
112
113 /* Holds all server's administrators authentication data from config file */
114 typedef struct SilcServerParamAdminStruct {
115   char *host;
116   char *user;
117   char *nick;
118   unsigned char *passphrase;
119   SilcUInt32 passphrase_len;
120   SilcHashTable publickeys;
121   struct SilcServerParamAdminStruct *next;
122 } *SilcServerParamAdmin;
123
124 /* Holds all configured denied connections from config file */
125 typedef struct SilcServerParamDenyStruct {
126   char *host;
127   char *reason;
128   struct SilcServerParamDenyStruct *next;
129 } *SilcServerParamDeny;
130
131 /* Holds all configured server connections from config file */
132 typedef struct SilcServerParamServerStruct {
133   char *host;
134   unsigned char *passphrase;
135   SilcUInt32 passphrase_len;
136   SilcHashTable publickeys;
137   SilcBool pubkey_auth;
138   SilcServerParamConnParams param;
139   SilcBool backup_router;
140   struct SilcServerParamServerStruct *next;
141 } *SilcServerParamServer;
142
143 /* Holds all configured router connections from config file */
144 typedef struct SilcServerParamRouterStruct {
145   char *host;
146   unsigned char *passphrase;
147   SilcUInt32 passphrase_len;
148   SilcHashTable publickeys;
149   SilcBool pubkey_auth;
150   SilcUInt16 port;
151   SilcServerParamConnParams param;
152   SilcBool initiator;
153   SilcBool backup_router;
154   char *backup_replace_ip;
155   SilcUInt16 backup_replace_port;
156   SilcBool backup_local;
157   struct SilcServerParamRouterStruct *next;
158 } *SilcServerParamRouter;
159
160 typedef struct {
161   /* Server information */
162   SilcServerParamServerInfo server_info;
163
164   /* Global flags */
165   unsigned int prefer_passphrase_auth   : 1;
166   unsigned int require_reverse_lookup   : 1;
167   unsigned int detach_disabled          : 1;
168
169   /* Threads support */
170   unsigned int use_threads              : 1;
171   SilcUInt32 connections_per_thread;
172
173   /* Default connection parameters */
174   SilcServerParamConnParamsStruct param;
175
176   SilcUInt32 channel_rekey_secs;
177   SilcUInt32 key_exchange_timeout;
178   SilcUInt32 conn_auth_timeout;
179   SilcUInt32 detach_timeout;
180   SilcBool logging_timestamp;
181   SilcBool logging_quick;
182   long logging_flushdelay;
183   char *debug_string;
184
185   /* Supported ciphers, hashes, hmacs and PKCS's */
186   SilcList cipher;                     /* SilcServerParamCipher */
187   SilcList hash;                       /* SilcServerParamHash */
188   SilcList hmac;                       /* SilcServerParamHmac */
189   SilcList pkcs;                       /* SilcServerParamPkcs */
190
191   /* Configured client, server and router connections */
192   SilcList clients;                    /* SilcServerParamClient */
193   SilcList servers;                    /* SilcServerParamServer */
194   SilcList routers;                    /* SilcServerParamRouter */
195
196   /* Configured connections parameters */
197   SilcList conn_params;                /* SilcServerParamConnParams */
198
199   /* Denied connections */
200   SilcList denied;                     /* SilcServerParamDeny */
201
202   /* Configured server administrators */
203   SilcList admins;                     /* SilcServerParamAdmin */
204
205   SilcServerParamLogging *logging_info;
206   SilcServerParamLogging *logging_warnings;
207   SilcServerParamLogging *logging_errors;
208   SilcServerParamLogging *logging_fatals;
209
210   SilcUInt8 refcnt;                    /* Reference counter */
211 } *SilcServerParams;
212
213 /****f* silcserver/SilcServerParamsAPI/silc_server_params_alloc
214  *
215  * SYNOPSIS
216  *
217  *    SilcServerParams silc_server_params_alloc(void);
218  *
219  * DESCRIPTION
220  *
221  *    Allocates server parameters context.
222  *
223  ***/
224 SilcServerParams silc_server_params_alloc(void);
225
226 /****f* silcserver/SilcServerParamsAPI/silc_server_params_free
227  *
228  * SYNOPSIS
229  *
230  *    void silc_server_params_free(SilcServerParams params);
231  *
232  * DESCRIPTION
233  *
234  *    Frees server parameters and all allocated resources in it.
235  *
236  ***/
237 void silc_server_params_free(SilcServerParams params);
238
239 /****f* silcserver/SilcServerParamsAPI/silc_server_params_serverinfo_alloc
240  *
241  * SYNOPSIS
242  *
243  *    SilcServerParamServerInfo silc_server_params_serverinfo_alloc(void);
244  *
245  * DESCRIPTION
246  *
247  *    Allocates server information context.  This does not have to be freed
248  *    by the caller.  It is freed when the server parameters are freed.
249  *
250  ***/
251 SilcServerParamServerInfo silc_server_params_serverinfo_alloc(void);
252
253 /****f* silcserver/SilcServerParamsAPI/silc_server_params_serverinfo_alloc
254  *
255  * SYNOPSIS
256  *
257  *    void
258  *    silc_server_params_serverinfo_add_iface(SilcServerParamServerInfo info,
259  *                                            SilcServerParamInterface iface);
260  *
261  * DESCRIPTION
262  *
263  *    Adds interface to server information parameters.  The first added
264  *    interface is the primary interface.
265  *
266  ***/
267 void silc_server_params_serverinfo_add_iface(SilcServerParamServerInfo info,
268                                              SilcServerParamInterface iface);
269
270 /****f* silcserver/SilcServerParamsAPI/silc_server_params_set_serverinfo
271  *
272  * SYNOPSIS
273  *
274  *    void
275  *    silc_server_params_set_serverinfo(SilcServerParams params,
276  *                                      SilcServerParamServerInfo
277  *                                                       server_info);
278  *
279  * DESCRIPTION
280  *
281  *    Set server's information to server parameters.
282  *
283  ***/
284 void silc_server_params_set_serverinfo(SilcServerParams params,
285                                        SilcServerParamServerInfo server_info);
286
287 /****f* silcserver/SilcServerParamsAPI/silc_server_params_add_cipher
288  *
289  * SYNOPSIS
290  *
291  *    void silc_server_params_add_cipher(SilcServerParams params,
292  *                                       SilcServerParamCipher cipher);
293  *
294  * DESCRIPTION
295  *
296  *    Adds a cipher to server parameters.
297  *
298  ***/
299 void silc_server_params_add_cipher(SilcServerParams params,
300                                    SilcServerParamCipher cipher);
301
302 /****f* silcserver/SilcServerParamsAPI/silc_server_params_add_hash
303  *
304  * SYNOPSIS
305  *
306  *    void silc_server_params_add_hash(SilcServerParams params,
307  *                                     SilcServerParamHash hash);
308  *
309  * DESCRIPTION
310  *
311  *    Adds a hash function to server parameters.
312  *
313  ***/
314 void silc_server_params_add_hash(SilcServerParams params,
315                                  SilcServerParamHash hash);
316
317 /****f* silcserver/SilcServerParamsAPI/silc_server_params_add_hmac
318  *
319  * SYNOPSIS
320  *
321  *    void silc_server_params_add_hmac(SilcServerParams params,
322  *                                     SilcServerParamHmac hmac);
323  *
324  * DESCRIPTION
325  *
326  *    Adds a HMAC to server parameters.
327  *
328  ***/
329 void silc_server_params_add_hmac(SilcServerParams params,
330                                  SilcServerParamHmac hmac);
331
332 /****f* silcserver/SilcServerParamsAPI/silc_server_params_add_pkcs
333  *
334  * SYNOPSIS
335  *
336  *    void silc_server_params_add_pkcs(SilcServerParams params,
337  *                                     SilcServerParamPkcs pkcs);
338  *
339  * DESCRIPTION
340  *
341  *    Adds a HMAC to server parameters.
342  *
343  ***/
344 void silc_server_params_add_pkcs(SilcServerParams params,
345                                  SilcServerParamPkcs pkcs);
346
347 /****f* silcserver/SilcServerParamsAPI/silc_server_params_add_client
348  *
349  * SYNOPSIS
350  *
351  *    void silc_server_params_add_client(SilcServerParams params,
352  *                                       SilcServerParamClient client);
353  *
354  * DESCRIPTION
355  *
356  *    Adds a client connection to server parameters.
357  *
358  ***/
359 void silc_server_params_add_client(SilcServerParams params,
360                                    SilcServerParamClient client);
361
362 /****f* silcserver/SilcServerParamsAPI/silc_server_params_add_server
363  *
364  * SYNOPSIS
365  *
366  *    void silc_server_params_add_server(SilcServerParams params,
367  *                                       SilcServerParamServer server);
368  *
369  * DESCRIPTION
370  *
371  *    Adds a server connection to server parameters.
372  *
373  ***/
374 void silc_server_params_add_server(SilcServerParams params,
375                                    SilcServerParamServer server);
376
377 /****f* silcserver/SilcServerParamsAPI/silc_server_params_add_router
378  *
379  * SYNOPSIS
380  *
381  *    void silc_server_params_add_router(SilcServerParams params,
382  *                                       SilcServerParamRouter router);
383  *
384  * DESCRIPTION
385  *
386  *    Adds a router connection to server parameters.
387  *
388  ***/
389 void silc_server_params_add_router(SilcServerParams params,
390                                    SilcServerParamRouter router);
391
392 /****f* silcserver/SilcServerParamsAPI/silc_server_params_add_connparam
393  *
394  * SYNOPSIS
395  *
396  *    void silc_server_params_add_connparam(SilcServerParams params,
397  *                                          SilcServerParamConnParams param);
398  *
399  * DESCRIPTION
400  *
401  *    Adds a connection parameters to server parameters.
402  *
403  ***/
404 void silc_server_params_add_connparam(SilcServerParams params,
405                                       SilcServerParamConnParams param);
406
407 /****f* silcserver/SilcServerParamsAPI/silc_server_params_add_deny
408  *
409  * SYNOPSIS
410  *
411  *    void silc_server_params_add_deny(SilcServerParams params,
412  *                                     SilcServerParamDeny deny);
413  *
414  * DESCRIPTION
415  *
416  *    Adds a denied connection to server parameters.
417  *
418  ***/
419 void silc_server_params_add_deny(SilcServerParams params,
420                                  SilcServerParamDeny deny);
421
422 /****f* silcserver/SilcServerParamsAPI/silc_server_params_add_admin
423  *
424  * SYNOPSIS
425  *
426  *    void silc_server_params_add_admin(SilcServerParams params,
427  *                                      SilcServerParamAdmin admin);
428  *
429  * DESCRIPTION
430  *
431  *    Adds an server administrator to server parameters.
432  *
433  ***/
434 void silc_server_params_add_admin(SilcServerParams params,
435                                   SilcServerParamAdmin admin);
436
437 #endif  /* SILCSERVER_PARAMS_H */