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 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 bool key_exchange_pfs;
93 bool reconnect_keep_trying;
95 struct SilcServerConfigConnParams *next;
96 } SilcServerConfigConnParams;
98 /* Holds all client authentication data from config file */
99 typedef struct SilcServerConfigClientStruct {
101 unsigned char *passphrase;
102 SilcUInt32 passphrase_len;
103 SilcHashTable publickeys;
104 SilcServerConfigConnParams *param;
105 struct SilcServerConfigClientStruct *next;
106 } SilcServerConfigClient;
108 /* Holds all server's administrators authentication data from config file */
109 typedef struct SilcServerConfigAdminStruct {
113 unsigned char *passphrase;
114 SilcUInt32 passphrase_len;
115 SilcHashTable publickeys;
116 struct SilcServerConfigAdminStruct *next;
117 } SilcServerConfigAdmin;
119 /* Holds all configured denied connections from config file */
120 typedef struct SilcServerConfigDenyStruct {
123 struct SilcServerConfigDenyStruct *next;
124 } SilcServerConfigDeny;
126 /* Holds all configured server connections from config file */
127 typedef struct SilcServerConfigServerStruct {
129 unsigned char *passphrase;
130 SilcUInt32 passphrase_len;
131 SilcHashTable publickeys;
132 SilcServerConfigConnParams *param;
134 struct SilcServerConfigServerStruct *next;
135 } SilcServerConfigServer;
137 /* Holds all configured router connections from config file */
138 typedef struct SilcServerConfigRouterStruct {
140 unsigned char *passphrase;
141 SilcUInt32 passphrase_len;
142 SilcHashTable publickeys;
144 SilcServerConfigConnParams *param;
147 char *backup_replace_ip;
148 SilcUInt16 backup_replace_port;
150 struct SilcServerConfigRouterStruct *next;
151 } SilcServerConfigRouter;
153 /* define the SilcServerConfig object */
157 /* Reference count (when this reaches zero, config object is destroyed) */
160 /* The General section */
162 bool prefer_passphrase_auth;
163 bool require_reverse_lookup;
164 SilcUInt32 channel_rekey_secs;
165 SilcUInt32 key_exchange_timeout;
166 SilcUInt32 conn_auth_timeout;
167 SilcServerConfigConnParams param;
168 bool detach_disabled;
169 SilcUInt32 detach_timeout;
170 bool logging_timestamp;
172 long logging_flushdelay;
174 /* Other configuration sections */
175 SilcServerConfigCipher *cipher;
176 SilcServerConfigHash *hash;
177 SilcServerConfigHmac *hmac;
178 SilcServerConfigPkcs *pkcs;
179 SilcServerConfigLogging *logging_info;
180 SilcServerConfigLogging *logging_warnings;
181 SilcServerConfigLogging *logging_errors;
182 SilcServerConfigLogging *logging_fatals;
183 SilcServerConfigServerInfo *server_info;
184 SilcServerConfigConnParams *conn_params;
185 SilcServerConfigClient *clients;
186 SilcServerConfigAdmin *admins;
187 SilcServerConfigDeny *denied;
188 SilcServerConfigServer *servers;
189 SilcServerConfigRouter *routers;
193 SilcServerConfig config;
195 } SilcServerConfigRef;
199 /* Basic config operations */
200 SilcServerConfig silc_server_config_alloc(const char *filename);
201 void silc_server_config_destroy(SilcServerConfig config);
202 void silc_server_config_ref(SilcServerConfigRef *ref, SilcServerConfig config,
204 void silc_server_config_unref(SilcServerConfigRef *ref);
206 /* Algorithm registering and reset functions */
207 bool silc_server_config_register_ciphers(SilcServer server);
208 bool silc_server_config_register_hashfuncs(SilcServer server);
209 bool silc_server_config_register_hmacs(SilcServer server);
210 bool silc_server_config_register_pkcs(SilcServer server);
211 void silc_server_config_setlogfiles(SilcServer server);
213 /* Run-time config access functions */
214 SilcServerConfigClient *
215 silc_server_config_find_client(SilcServer server, char *host);
216 SilcServerConfigAdmin *
217 silc_server_config_find_admin(SilcServer server, char *host, char *user,
219 SilcServerConfigDeny *
220 silc_server_config_find_denied(SilcServer server, char *host);
221 SilcServerConfigServer *
222 silc_server_config_find_server_conn(SilcServer server, char *host);
223 SilcServerConfigRouter *
224 silc_server_config_find_router_conn(SilcServer server, char *host, int port);
225 SilcServerConfigRouter *
226 silc_server_config_find_backup_conn(SilcServer server, char *host);
227 bool silc_server_config_is_primary_route(SilcServer server);
228 SilcServerConfigRouter *
229 silc_server_config_get_primary_router(SilcServer server);
230 SilcServerConfigRouter *
231 silc_server_config_get_backup_router(SilcServer server);
233 #endif /* !SERVERCONFIG_H */