5 Author: Giovanni Giacobbi <giovanni@giacobbi.net>
7 Copyright (C) 1997 - 2007 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 SERVERCONFIG_H
21 #define SERVERCONFIG_H
23 typedef struct SilcServerConfigCipherStruct {
26 SilcUInt32 key_length;
27 SilcUInt32 block_length;
28 struct SilcServerConfigCipherStruct *next;
29 } SilcServerConfigCipher;
31 typedef struct SilcServerConfigHashStruct {
34 SilcUInt32 block_length;
35 SilcUInt32 digest_length;
36 struct SilcServerConfigHashStruct *next;
37 } SilcServerConfigHash;
39 typedef struct SilcServerConfigHmacStruct {
42 SilcUInt32 mac_length;
43 struct SilcServerConfigHmacStruct *next;
44 } SilcServerConfigHmac;
46 typedef struct SilcServerConfigPkcsStruct {
48 struct SilcServerConfigPkcsStruct *next;
49 } SilcServerConfigPkcs;
51 typedef struct SilcServerConfigServerInfoInterfaceStruct {
55 struct SilcServerConfigServerInfoInterfaceStruct *next;
56 } SilcServerConfigServerInfoInterface;
58 typedef struct SilcServerConfigServerInfoStruct {
60 SilcServerConfigServerInfoInterface *primary;
61 SilcServerConfigServerInfoInterface *secondary;
62 char *server_type; /* E.g. "Test Server" */
63 char *location; /* geographic location */
64 char *admin; /* admin full name */
65 char *email; /* admin's email address */
66 char *user; /* userid the server should be runned at */
67 char *group; /* ditto, but about groupid */
68 SilcPublicKey public_key;
69 SilcPrivateKey private_key;
70 char *motd_file; /* path to text motd file (reading only) */
71 char *pid_file; /* path to the pid file (for reading and writing) */
72 } SilcServerConfigServerInfo;
74 typedef struct SilcServerConfigLoggingStruct {
77 } SilcServerConfigLogging;
79 /* Connection parameters */
80 typedef struct SilcServerConfigConnParams {
81 struct SilcServerConfigConnParams *next;
83 char *version_protocol;
84 char *version_software;
85 char *version_software_vendor;
86 SilcUInt32 connections_max;
87 SilcUInt32 connections_max_per_host;
88 SilcUInt32 keepalive_secs;
89 SilcUInt32 reconnect_count;
90 SilcUInt32 reconnect_interval;
91 SilcUInt32 reconnect_interval_max;
92 SilcUInt32 key_exchange_rekey;
93 SilcUInt32 qos_rate_limit;
94 SilcUInt32 qos_bytes_limit;
95 SilcUInt32 qos_limit_sec;
96 SilcUInt32 qos_limit_usec;
98 unsigned int key_exchange_pfs : 1;
99 unsigned int reconnect_keep_trying : 1;
100 unsigned int anonymous : 1;
101 unsigned int qos : 1;
102 } SilcServerConfigConnParams;
104 /* Holds all client authentication data from config file */
105 typedef struct SilcServerConfigClientStruct {
107 unsigned char *passphrase;
108 SilcUInt32 passphrase_len;
110 SilcServerConfigConnParams *param;
111 struct SilcServerConfigClientStruct *next;
112 } SilcServerConfigClient;
114 /* Holds all server's administrators authentication data from config file */
115 typedef struct SilcServerConfigAdminStruct {
119 unsigned char *passphrase;
120 SilcUInt32 passphrase_len;
122 struct SilcServerConfigAdminStruct *next;
123 } SilcServerConfigAdmin;
125 /* Holds all configured denied connections from config file */
126 typedef struct SilcServerConfigDenyStruct {
129 struct SilcServerConfigDenyStruct *next;
130 } SilcServerConfigDeny;
132 /* Holds all configured server connections from config file */
133 typedef struct SilcServerConfigServerStruct {
135 unsigned char *passphrase;
136 SilcUInt32 passphrase_len;
138 SilcServerConfigConnParams *param;
139 SilcBool backup_router;
140 struct SilcServerConfigServerStruct *next;
141 } SilcServerConfigServer;
143 /* Holds all configured router connections from config file */
144 typedef struct SilcServerConfigRouterStruct {
146 unsigned char *passphrase;
147 SilcUInt32 passphrase_len;
150 SilcServerConfigConnParams *param;
152 SilcBool backup_router;
153 SilcBool dynamic_connection;
154 char *backup_replace_ip;
155 SilcUInt16 backup_replace_port;
156 SilcBool backup_local;
157 struct SilcServerConfigRouterStruct *next;
158 } SilcServerConfigRouter;
160 /* define the SilcServerConfig object */
165 /* Reference count (when this reaches zero, config object is destroyed) */
168 /* The General section */
170 SilcBool prefer_passphrase_auth;
171 SilcBool require_reverse_lookup;
172 SilcUInt32 channel_rekey_secs;
173 SilcUInt32 key_exchange_timeout;
174 SilcUInt32 conn_auth_timeout;
175 SilcServerConfigConnParams param;
176 SilcBool detach_disabled;
177 SilcUInt32 detach_timeout;
178 SilcBool logging_timestamp;
179 SilcBool logging_quick;
180 long logging_flushdelay;
184 SilcUInt16 httpd_port;
185 SilcBool dynamic_server;
186 SilcBool local_channels;
188 /* Other configuration sections */
189 SilcServerConfigCipher *cipher;
190 SilcServerConfigHash *hash;
191 SilcServerConfigHmac *hmac;
192 SilcServerConfigPkcs *pkcs;
193 SilcServerConfigLogging *logging_info;
194 SilcServerConfigLogging *logging_warnings;
195 SilcServerConfigLogging *logging_errors;
196 SilcServerConfigLogging *logging_fatals;
197 SilcServerConfigServerInfo *server_info;
198 SilcServerConfigConnParams *conn_params;
199 SilcServerConfigClient *clients;
200 SilcServerConfigAdmin *admins;
201 SilcServerConfigDeny *denied;
202 SilcServerConfigServer *servers;
203 SilcServerConfigRouter *routers;
207 SilcServerConfig config;
209 } SilcServerConfigRef;
213 /* Basic config operations */
214 SilcServerConfig silc_server_config_alloc(const char *filename,
216 void silc_server_config_destroy(SilcServerConfig config);
217 void silc_server_config_ref(SilcServerConfigRef *ref, SilcServerConfig config,
219 void silc_server_config_unref(SilcServerConfigRef *ref);
221 /* Algorithm registering and reset functions */
222 SilcBool silc_server_config_register_ciphers(SilcServer server);
223 SilcBool silc_server_config_register_hashfuncs(SilcServer server);
224 SilcBool silc_server_config_register_hmacs(SilcServer server);
225 SilcBool silc_server_config_register_pkcs(SilcServer server);
226 void silc_server_config_setlogfiles(SilcServer server);
228 /* Run-time config access functions */
229 SilcServerConfigClient *
230 silc_server_config_find_client(SilcServer server, char *host);
231 SilcServerConfigAdmin *
232 silc_server_config_find_admin(SilcServer server, char *host, char *user,
234 SilcServerConfigDeny *
235 silc_server_config_find_denied(SilcServer server, char *host);
236 SilcServerConfigServer *
237 silc_server_config_find_server_conn(SilcServer server, char *host);
238 SilcServerConfigRouter *
239 silc_server_config_find_router_conn(SilcServer server, char *host, int port);
240 SilcServerConfigRouter *
241 silc_server_config_find_backup_conn(SilcServer server, char *host);
242 SilcBool silc_server_config_is_primary_route(SilcServer server);
243 SilcServerConfigRouter *
244 silc_server_config_get_primary_router(SilcServer server);
245 SilcServerConfigRouter *
246 silc_server_config_get_backup_router(SilcServer server);
248 #endif /* !SERVERCONFIG_H */