5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 1997 - 2005 Pekka Riikonen
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.
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.
20 #ifndef SILCSERVER_PARAMS_H
21 #define SILCSERVER_PARAMS_H
23 typedef struct SilcServerParamCipherStruct {
26 SilcUInt32 key_length;
27 SilcUInt32 block_length;
28 struct SilcServerParamCipherStruct *next;
29 } *SilcServerParamCipher;
31 typedef struct SilcServerParamHashStruct {
34 SilcUInt32 block_length;
35 SilcUInt32 digest_length;
36 struct SilcServerParamHashStruct *next;
37 } *SilcServerParamHash;
39 typedef struct SilcServerParamHmacStruct {
42 SilcUInt32 mac_length;
43 struct SilcServerParamHmacStruct *next;
44 } *SilcServerParamHmac;
46 typedef struct SilcServerParamPkcsStruct {
48 struct SilcServerParamPkcsStruct *next;
49 } *SilcServerParamPkcs;
51 typedef struct SilcServerParamInterfaceStruct {
52 char *ip; /* IP address */
53 SilcUInt16 port; /* Port */
54 struct SilcServerParamInterfaceStruct *next;
55 } *SilcServerParamInterface;
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;
72 typedef struct SilcServerParamLoggingStruct {
75 } *SilcServerParamLogging;
77 /* Connection parameters */
78 typedef struct SilcServerParamConnParamsObject {
79 struct SilcServerParamConnParams *next;
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;
96 unsigned int key_exchange_pfs : 1;
97 unsigned int reconnect_keep_trying : 1;
98 unsigned int anonymous : 1;
100 } *SilcServerParamConnParams, SilcServerParamConnParamsStruct;
102 /* Holds all client authentication data from config file */
103 typedef struct SilcServerParamClientStruct {
105 unsigned char *passphrase;
106 SilcUInt32 passphrase_len;
107 SilcHashTable publickeys;
108 SilcBool pubkey_auth;
109 SilcServerParamConnParams param;
110 struct SilcServerParamClientStruct *next;
111 } *SilcServerParamClient;
113 /* Holds all server's administrators authentication data from config file */
114 typedef struct SilcServerParamAdminStruct {
118 unsigned char *passphrase;
119 SilcUInt32 passphrase_len;
120 SilcHashTable publickeys;
121 struct SilcServerParamAdminStruct *next;
122 } *SilcServerParamAdmin;
124 /* Holds all configured denied connections from config file */
125 typedef struct SilcServerParamDenyStruct {
128 struct SilcServerParamDenyStruct *next;
129 } *SilcServerParamDeny;
131 /* Holds all configured server connections from config file */
132 typedef struct SilcServerParamServerStruct {
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;
143 /* Holds all configured router connections from config file */
144 typedef struct SilcServerParamRouterStruct {
146 unsigned char *passphrase;
147 SilcUInt32 passphrase_len;
148 SilcHashTable publickeys;
149 SilcBool pubkey_auth;
151 SilcServerParamConnParams param;
153 SilcBool backup_router;
154 char *backup_replace_ip;
155 SilcUInt16 backup_replace_port;
156 SilcBool backup_local;
157 struct SilcServerParamRouterStruct *next;
158 } *SilcServerParamRouter;
161 /* Server information */
162 SilcServerParamServerInfo server_info;
165 unsigned int prefer_passphrase_auth : 1;
166 unsigned int require_reverse_lookup : 1;
167 unsigned int detach_disabled : 1;
169 /* Threads support */
170 unsigned int use_threads : 1;
171 SilcUInt32 connections_per_thread;
173 /* Default connection parameters */
174 SilcServerParamConnParamsStruct param;
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;
185 /* Supported ciphers, hashes, hmacs and PKCS's */
186 SilcList cipher; /* SilcServerParamCipher */
187 SilcList hash; /* SilcServerParamHash */
188 SilcList hmac; /* SilcServerParamHmac */
189 SilcList pkcs; /* SilcServerParamPkcs */
191 /* Configured client, server and router connections */
192 SilcList clients; /* SilcServerParamClient */
193 SilcList servers; /* SilcServerParamServer */
194 SilcList routers; /* SilcServerParamRouter */
196 /* Configured connections parameters */
197 SilcList conn_params; /* SilcServerParamConnParams */
199 /* Denied connections */
200 SilcList denied; /* SilcServerParamDeny */
202 /* Configured server administrators */
203 SilcList admins; /* SilcServerParamAdmin */
205 SilcServerParamLogging *logging_info;
206 SilcServerParamLogging *logging_warnings;
207 SilcServerParamLogging *logging_errors;
208 SilcServerParamLogging *logging_fatals;
210 SilcUInt8 refcnt; /* Reference counter */
213 /****f* silcserver/SilcServerParamsAPI/silc_server_params_alloc
217 * SilcServerParams silc_server_params_alloc(void);
221 * Allocates server parameters context.
224 SilcServerParams silc_server_params_alloc(void);
226 /****f* silcserver/SilcServerParamsAPI/silc_server_params_free
230 * void silc_server_params_free(SilcServerParams params);
234 * Frees server parameters and all allocated resources in it.
237 void silc_server_params_free(SilcServerParams params);
239 /****f* silcserver/SilcServerParamsAPI/silc_server_params_serverinfo_alloc
243 * SilcServerParamServerInfo silc_server_params_serverinfo_alloc(void);
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.
251 SilcServerParamServerInfo silc_server_params_serverinfo_alloc(void);
253 /****f* silcserver/SilcServerParamsAPI/silc_server_params_serverinfo_alloc
258 * silc_server_params_serverinfo_add_iface(SilcServerParamServerInfo info,
259 * SilcServerParamInterface iface);
263 * Adds interface to server information parameters. The first added
264 * interface is the primary interface.
267 void silc_server_params_serverinfo_add_iface(SilcServerParamServerInfo info,
268 SilcServerParamInterface iface);
270 /****f* silcserver/SilcServerParamsAPI/silc_server_params_set_serverinfo
275 * silc_server_params_set_serverinfo(SilcServerParams params,
276 * SilcServerParamServerInfo
281 * Set server's information to server parameters.
284 void silc_server_params_set_serverinfo(SilcServerParams params,
285 SilcServerParamServerInfo server_info);
287 /****f* silcserver/SilcServerParamsAPI/silc_server_params_add_cipher
291 * void silc_server_params_add_cipher(SilcServerParams params,
292 * SilcServerParamCipher cipher);
296 * Adds a cipher to server parameters.
299 void silc_server_params_add_cipher(SilcServerParams params,
300 SilcServerParamCipher cipher);
302 /****f* silcserver/SilcServerParamsAPI/silc_server_params_add_hash
306 * void silc_server_params_add_hash(SilcServerParams params,
307 * SilcServerParamHash hash);
311 * Adds a hash function to server parameters.
314 void silc_server_params_add_hash(SilcServerParams params,
315 SilcServerParamHash hash);
317 /****f* silcserver/SilcServerParamsAPI/silc_server_params_add_hmac
321 * void silc_server_params_add_hmac(SilcServerParams params,
322 * SilcServerParamHmac hmac);
326 * Adds a HMAC to server parameters.
329 void silc_server_params_add_hmac(SilcServerParams params,
330 SilcServerParamHmac hmac);
332 /****f* silcserver/SilcServerParamsAPI/silc_server_params_add_pkcs
336 * void silc_server_params_add_pkcs(SilcServerParams params,
337 * SilcServerParamPkcs pkcs);
341 * Adds a HMAC to server parameters.
344 void silc_server_params_add_pkcs(SilcServerParams params,
345 SilcServerParamPkcs pkcs);
347 /****f* silcserver/SilcServerParamsAPI/silc_server_params_add_client
351 * void silc_server_params_add_client(SilcServerParams params,
352 * SilcServerParamClient client);
356 * Adds a client connection to server parameters.
359 void silc_server_params_add_client(SilcServerParams params,
360 SilcServerParamClient client);
362 /****f* silcserver/SilcServerParamsAPI/silc_server_params_add_server
366 * void silc_server_params_add_server(SilcServerParams params,
367 * SilcServerParamServer server);
371 * Adds a server connection to server parameters.
374 void silc_server_params_add_server(SilcServerParams params,
375 SilcServerParamServer server);
377 /****f* silcserver/SilcServerParamsAPI/silc_server_params_add_router
381 * void silc_server_params_add_router(SilcServerParams params,
382 * SilcServerParamRouter router);
386 * Adds a router connection to server parameters.
389 void silc_server_params_add_router(SilcServerParams params,
390 SilcServerParamRouter router);
392 /****f* silcserver/SilcServerParamsAPI/silc_server_params_add_connparam
396 * void silc_server_params_add_connparam(SilcServerParams params,
397 * SilcServerParamConnParams param);
401 * Adds a connection parameters to server parameters.
404 void silc_server_params_add_connparam(SilcServerParams params,
405 SilcServerParamConnParams param);
407 /****f* silcserver/SilcServerParamsAPI/silc_server_params_add_deny
411 * void silc_server_params_add_deny(SilcServerParams params,
412 * SilcServerParamDeny deny);
416 * Adds a denied connection to server parameters.
419 void silc_server_params_add_deny(SilcServerParams params,
420 SilcServerParamDeny deny);
422 /****f* silcserver/SilcServerParamsAPI/silc_server_params_add_admin
426 * void silc_server_params_add_admin(SilcServerParams params,
427 * SilcServerParamAdmin admin);
431 * Adds an server administrator to server parameters.
434 void silc_server_params_add_admin(SilcServerParams params,
435 SilcServerParamAdmin admin);
437 #endif /* SILCSERVER_PARAMS_H */