5 Author: Johnny Mnemonic <johnny@themnemonic.org>
7 Copyright (C) 1997 - 2002 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; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
21 #ifndef SERVERCONFIG_H
22 #define SERVERCONFIG_H
24 typedef struct SilcServerConfigCipherStruct {
27 SilcUInt32 key_length;
28 SilcUInt32 block_length;
29 struct SilcServerConfigCipherStruct *next;
30 } SilcServerConfigCipher;
32 typedef struct SilcServerConfigHashStruct {
35 SilcUInt32 block_length;
36 SilcUInt32 digest_length;
37 struct SilcServerConfigHashStruct *next;
38 } SilcServerConfigHash;
40 typedef struct SilcServerConfigHmacStruct {
43 SilcUInt32 mac_length;
44 struct SilcServerConfigHmacStruct *next;
45 } SilcServerConfigHmac;
47 typedef struct SilcServerConfigPkcsStruct {
49 struct SilcServerConfigPkcsStruct *next;
50 } SilcServerConfigPkcs;
52 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 {
82 SilcUInt32 connections_max;
83 SilcUInt32 connections_max_per_host;
84 SilcUInt32 keepalive_secs;
85 SilcUInt32 reconnect_count;
86 SilcUInt32 reconnect_interval;
87 SilcUInt32 reconnect_interval_max;
88 bool reconnect_keep_trying;
89 SilcUInt32 key_exchange_rekey;
90 bool key_exchange_pfs;
91 char *version_protocol;
92 char *version_software;
93 char *version_software_vendor;
94 struct SilcServerConfigConnParams *next;
95 } SilcServerConfigConnParams;
97 /* Holds all client authentication data from config file */
98 typedef struct SilcServerConfigClientStruct {
100 unsigned char *passphrase;
101 SilcUInt32 passphrase_len;
102 SilcHashTable publickeys;
103 SilcServerConfigConnParams *param;
104 struct SilcServerConfigClientStruct *next;
105 } SilcServerConfigClient;
107 /* Holds all server's administrators authentication data from config file */
108 typedef struct SilcServerConfigAdminStruct {
112 unsigned char *passphrase;
113 SilcUInt32 passphrase_len;
114 SilcHashTable publickeys;
115 struct SilcServerConfigAdminStruct *next;
116 } SilcServerConfigAdmin;
118 /* Holds all configured denied connections from config file */
119 typedef struct SilcServerConfigDenyStruct {
122 struct SilcServerConfigDenyStruct *next;
123 } SilcServerConfigDeny;
125 /* Holds all configured server connections from config file */
126 typedef struct SilcServerConfigServerStruct {
128 unsigned char *passphrase;
129 SilcUInt32 passphrase_len;
130 SilcHashTable publickeys;
131 SilcServerConfigConnParams *param;
133 struct SilcServerConfigServerStruct *next;
134 } SilcServerConfigServer;
136 /* Holds all configured router connections from config file */
137 typedef struct SilcServerConfigRouterStruct {
139 unsigned char *passphrase;
140 SilcUInt32 passphrase_len;
141 SilcHashTable publickeys;
143 SilcServerConfigConnParams *param;
146 char *backup_replace_ip;
147 SilcUInt16 backup_replace_port;
149 struct SilcServerConfigRouterStruct *next;
150 } SilcServerConfigRouter;
152 /* define the SilcServerConfig object */
156 /* Reference count (when this reaches zero, config object is destroyed) */
159 /* The General section */
161 bool prefer_passphrase_auth;
162 bool require_reverse_lookup;
163 SilcUInt32 channel_rekey_secs;
164 SilcUInt32 key_exchange_timeout;
165 SilcUInt32 conn_auth_timeout;
166 SilcServerConfigConnParams param;
167 bool detach_disabled;
168 SilcUInt32 detach_timeout;
170 long logging_flushdelay;
172 /* Other configuration sections */
173 SilcServerConfigCipher *cipher;
174 SilcServerConfigHash *hash;
175 SilcServerConfigHmac *hmac;
176 SilcServerConfigPkcs *pkcs;
177 SilcServerConfigLogging *logging_info;
178 SilcServerConfigLogging *logging_warnings;
179 SilcServerConfigLogging *logging_errors;
180 SilcServerConfigLogging *logging_fatals;
181 SilcServerConfigServerInfo *server_info;
182 SilcServerConfigConnParams *conn_params;
183 SilcServerConfigClient *clients;
184 SilcServerConfigAdmin *admins;
185 SilcServerConfigDeny *denied;
186 SilcServerConfigServer *servers;
187 SilcServerConfigRouter *routers;
191 SilcServerConfig config;
193 } SilcServerConfigRef;
197 /* Basic config operations */
198 SilcServerConfig silc_server_config_alloc(const char *filename);
199 void silc_server_config_destroy(SilcServerConfig config);
200 void silc_server_config_ref(SilcServerConfigRef *ref, SilcServerConfig config,
202 void silc_server_config_unref(SilcServerConfigRef *ref);
204 /* Algorithm registering and reset functions */
205 bool silc_server_config_register_ciphers(SilcServer server);
206 bool silc_server_config_register_hashfuncs(SilcServer server);
207 bool silc_server_config_register_hmacs(SilcServer server);
208 bool silc_server_config_register_pkcs(SilcServer server);
209 void silc_server_config_setlogfiles(SilcServer server);
211 /* Run-time config access functions */
212 SilcServerConfigClient *
213 silc_server_config_find_client(SilcServer server, char *host);
214 SilcServerConfigAdmin *
215 silc_server_config_find_admin(SilcServer server, char *host, char *user,
217 SilcServerConfigDeny *
218 silc_server_config_find_denied(SilcServer server, char *host);
219 SilcServerConfigServer *
220 silc_server_config_find_server_conn(SilcServer server, char *host);
221 SilcServerConfigRouter *
222 silc_server_config_find_router_conn(SilcServer server, char *host, int port);
223 bool silc_server_config_is_primary_route(SilcServer server);
224 SilcServerConfigRouter *
225 silc_server_config_get_primary_router(SilcServer server);
226 SilcServerConfigRouter *
227 silc_server_config_get_backup_router(SilcServer server);
229 #endif /* !SERVERCONFIG_H */