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 {
54 struct SilcServerConfigServerInfoInterfaceStruct *next;
55 } SilcServerConfigServerInfoInterface;
57 typedef struct SilcServerConfigServerInfoStruct {
59 SilcServerConfigServerInfoInterface *primary;
60 SilcServerConfigServerInfoInterface *secondary;
61 char *server_type; /* E.g. "Test Server" */
62 char *location; /* geographic location */
63 char *admin; /* admin full name */
64 char *email; /* admin's email address */
65 char *user; /* userid the server should be runned at */
66 char *group; /* ditto, but about groupid */
67 SilcPublicKey public_key;
68 SilcPrivateKey private_key;
69 char *motd_file; /* path to text motd file (reading only) */
70 char *pid_file; /* path to the pid file (for reading and writing) */
71 } SilcServerConfigServerInfo;
73 typedef struct SilcServerConfigLoggingStruct {
76 } SilcServerConfigLogging;
78 /* Connection parameters */
79 typedef struct SilcServerConfigConnParams {
80 struct SilcServerConfigConnParams *next;
82 char *version_protocol;
83 char *version_software;
84 char *version_software_vendor;
85 SilcUInt32 connections_max;
86 SilcUInt32 connections_max_per_host;
87 SilcUInt32 keepalive_secs;
88 SilcUInt32 reconnect_count;
89 SilcUInt32 reconnect_interval;
90 SilcUInt32 reconnect_interval_max;
91 SilcUInt32 key_exchange_rekey;
92 SilcUInt32 qos_rate_limit;
93 SilcUInt32 qos_bytes_limit;
94 SilcUInt32 qos_limit_sec;
95 SilcUInt32 qos_limit_usec;
97 unsigned int key_exchange_pfs : 1;
98 unsigned int reconnect_keep_trying : 1;
99 unsigned int anonymous : 1;
100 unsigned int qos : 1;
101 } SilcServerConfigConnParams;
103 /* Holds all client authentication data from config file */
104 typedef struct SilcServerConfigClientStruct {
106 unsigned char *passphrase;
107 SilcUInt32 passphrase_len;
109 SilcServerConfigConnParams *param;
110 struct SilcServerConfigClientStruct *next;
111 } SilcServerConfigClient;
113 /* Holds all server's administrators authentication data from config file */
114 typedef struct SilcServerConfigAdminStruct {
118 unsigned char *passphrase;
119 SilcUInt32 passphrase_len;
121 struct SilcServerConfigAdminStruct *next;
122 } SilcServerConfigAdmin;
124 /* Holds all configured denied connections from config file */
125 typedef struct SilcServerConfigDenyStruct {
128 struct SilcServerConfigDenyStruct *next;
129 } SilcServerConfigDeny;
131 /* Holds all configured server connections from config file */
132 typedef struct SilcServerConfigServerStruct {
134 unsigned char *passphrase;
135 SilcUInt32 passphrase_len;
137 SilcServerConfigConnParams *param;
138 SilcBool backup_router;
139 struct SilcServerConfigServerStruct *next;
140 } SilcServerConfigServer;
142 /* Holds all configured router connections from config file */
143 typedef struct SilcServerConfigRouterStruct {
145 unsigned char *passphrase;
146 SilcUInt32 passphrase_len;
149 SilcServerConfigConnParams *param;
151 SilcBool backup_router;
152 char *backup_replace_ip;
153 SilcUInt16 backup_replace_port;
154 SilcBool backup_local;
155 struct SilcServerConfigRouterStruct *next;
156 } SilcServerConfigRouter;
158 /* define the SilcServerConfig object */
163 /* Reference count (when this reaches zero, config object is destroyed) */
166 /* The General section */
168 SilcBool prefer_passphrase_auth;
169 SilcBool require_reverse_lookup;
170 SilcUInt32 channel_rekey_secs;
171 SilcUInt32 key_exchange_timeout;
172 SilcUInt32 conn_auth_timeout;
173 SilcServerConfigConnParams param;
174 SilcBool detach_disabled;
175 SilcUInt32 detach_timeout;
176 SilcBool logging_timestamp;
177 SilcBool logging_quick;
178 long logging_flushdelay;
181 /* Other configuration sections */
182 SilcServerConfigCipher *cipher;
183 SilcServerConfigHash *hash;
184 SilcServerConfigHmac *hmac;
185 SilcServerConfigPkcs *pkcs;
186 SilcServerConfigLogging *logging_info;
187 SilcServerConfigLogging *logging_warnings;
188 SilcServerConfigLogging *logging_errors;
189 SilcServerConfigLogging *logging_fatals;
190 SilcServerConfigServerInfo *server_info;
191 SilcServerConfigConnParams *conn_params;
192 SilcServerConfigClient *clients;
193 SilcServerConfigAdmin *admins;
194 SilcServerConfigDeny *denied;
195 SilcServerConfigServer *servers;
196 SilcServerConfigRouter *routers;
200 SilcServerConfig config;
202 } SilcServerConfigRef;
206 /* Basic config operations */
207 SilcServerConfig silc_server_config_alloc(const char *filename,
209 void silc_server_config_destroy(SilcServerConfig config);
210 void silc_server_config_ref(SilcServerConfigRef *ref, SilcServerConfig config,
212 void silc_server_config_unref(SilcServerConfigRef *ref);
214 /* Algorithm registering and reset functions */
215 SilcBool silc_server_config_register_ciphers(SilcServer server);
216 SilcBool silc_server_config_register_hashfuncs(SilcServer server);
217 SilcBool silc_server_config_register_hmacs(SilcServer server);
218 SilcBool silc_server_config_register_pkcs(SilcServer server);
219 void silc_server_config_setlogfiles(SilcServer server);
221 /* Run-time config access functions */
222 SilcServerConfigClient *
223 silc_server_config_find_client(SilcServer server, char *host);
224 SilcServerConfigAdmin *
225 silc_server_config_find_admin(SilcServer server, char *host, char *user,
227 SilcServerConfigDeny *
228 silc_server_config_find_denied(SilcServer server, char *host);
229 SilcServerConfigServer *
230 silc_server_config_find_server_conn(SilcServer server, char *host);
231 SilcServerConfigRouter *
232 silc_server_config_find_router_conn(SilcServer server, char *host, int port);
233 SilcServerConfigRouter *
234 silc_server_config_find_backup_conn(SilcServer server, char *host);
235 SilcBool silc_server_config_is_primary_route(SilcServer server);
236 SilcServerConfigRouter *
237 silc_server_config_get_primary_router(SilcServer server);
238 SilcServerConfigRouter *
239 silc_server_config_get_backup_router(SilcServer server);
241 #endif /* !SERVERCONFIG_H */