5 Author: Johnny Mnemonic <johnny@themnemonic.org>
7 Copyright (C) 1997 - 2002 Johnny Mnemonic
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 SilcServerConfigServerInfoStruct {
56 char *server_type; /* E.g. "Test Server" */
57 char *location; /* geographic location */
58 char *admin; /* admin full name */
59 char *email; /* admin's email address */
60 char *user; /* userid the server should be runned at */
61 char *group; /* ditto, but about groupid */
62 SilcPublicKey public_key;
63 SilcPrivateKey private_key;
64 char *motd_file; /* path to text motd file (reading only) */
65 char *pid_file; /* path to the pid file (for reading and writing) */
66 } SilcServerConfigServerInfo;
68 typedef struct SilcServerConfigLoggingStruct {
71 } SilcServerConfigLogging;
73 /* Connection parameters */
74 typedef struct SilcServerConfigConnParams {
76 SilcUInt32 connections_max;
77 SilcUInt32 connections_max_per_host;
78 SilcUInt32 keepalive_secs;
79 SilcUInt32 reconnect_count;
80 SilcUInt32 reconnect_interval;
81 SilcUInt32 reconnect_interval_max;
82 bool reconnect_keep_trying;
83 SilcUInt32 key_exchange_rekey;
84 bool key_exchange_pfs;
85 char *version_protocol;
86 char *version_software;
87 char *version_software_vendor;
88 struct SilcServerConfigConnParams *next;
89 } SilcServerConfigConnParams;
91 /* Holds all client authentication data from config file */
92 typedef struct SilcServerConfigClientStruct {
94 unsigned char *passphrase;
95 SilcUInt32 passphrase_len;
96 SilcHashTable publickeys;
97 SilcServerConfigConnParams *param;
98 struct SilcServerConfigClientStruct *next;
99 } SilcServerConfigClient;
101 /* Holds all server's administrators authentication data from config file */
102 typedef struct SilcServerConfigAdminStruct {
106 unsigned char *passphrase;
107 SilcUInt32 passphrase_len;
108 SilcHashTable publickeys;
109 struct SilcServerConfigAdminStruct *next;
110 } SilcServerConfigAdmin;
112 /* Holds all configured denied connections from config file */
113 typedef struct SilcServerConfigDenyStruct {
116 struct SilcServerConfigDenyStruct *next;
117 } SilcServerConfigDeny;
119 /* Holds all configured server connections from config file */
120 typedef struct SilcServerConfigServerStruct {
122 unsigned char *passphrase;
123 SilcUInt32 passphrase_len;
124 SilcHashTable publickeys;
125 SilcServerConfigConnParams *param;
127 struct SilcServerConfigServerStruct *next;
128 } SilcServerConfigServer;
130 /* Holds all configured router connections from config file */
131 typedef struct SilcServerConfigRouterStruct {
133 unsigned char *passphrase;
134 SilcUInt32 passphrase_len;
135 SilcHashTable publickeys;
137 SilcServerConfigConnParams *param;
140 char *backup_replace_ip;
141 SilcUInt16 backup_replace_port;
143 struct SilcServerConfigRouterStruct *next;
144 } SilcServerConfigRouter;
146 /* define the SilcServerConfig object */
150 /* Reference count (when this reaches zero, config object is destroyed) */
153 /* The General section */
155 bool prefer_passphrase_auth;
156 bool require_reverse_lookup;
157 SilcUInt32 channel_rekey_secs;
158 SilcUInt32 key_exchange_timeout;
159 SilcUInt32 conn_auth_timeout;
160 SilcServerConfigConnParams param;
162 long logging_flushdelay;
164 /* Other configuration sections */
165 SilcServerConfigCipher *cipher;
166 SilcServerConfigHash *hash;
167 SilcServerConfigHmac *hmac;
168 SilcServerConfigPkcs *pkcs;
169 SilcServerConfigLogging *logging_info;
170 SilcServerConfigLogging *logging_warnings;
171 SilcServerConfigLogging *logging_errors;
172 SilcServerConfigLogging *logging_fatals;
173 SilcServerConfigServerInfo *server_info;
174 SilcServerConfigConnParams *conn_params;
175 SilcServerConfigClient *clients;
176 SilcServerConfigAdmin *admins;
177 SilcServerConfigDeny *denied;
178 SilcServerConfigServer *servers;
179 SilcServerConfigRouter *routers;
183 SilcServerConfig config;
185 } SilcServerConfigRef;
189 /* Basic config operations */
190 SilcServerConfig silc_server_config_alloc(const char *filename);
191 void silc_server_config_destroy(SilcServerConfig config);
192 void silc_server_config_ref(SilcServerConfigRef *ref, SilcServerConfig config,
194 void silc_server_config_unref(SilcServerConfigRef *ref);
196 /* Algorithm registering and reset functions */
197 bool silc_server_config_register_ciphers(SilcServer server);
198 bool silc_server_config_register_hashfuncs(SilcServer server);
199 bool silc_server_config_register_hmacs(SilcServer server);
200 bool silc_server_config_register_pkcs(SilcServer server);
201 void silc_server_config_setlogfiles(SilcServer server);
203 /* Run-time config access functions */
204 SilcServerConfigClient *
205 silc_server_config_find_client(SilcServer server, char *host);
206 SilcServerConfigAdmin *
207 silc_server_config_find_admin(SilcServer server, char *host, char *user,
209 SilcServerConfigDeny *
210 silc_server_config_find_denied(SilcServer server, char *host);
211 SilcServerConfigServer *
212 silc_server_config_find_server_conn(SilcServer server, char *host);
213 SilcServerConfigRouter *
214 silc_server_config_find_router_conn(SilcServer server, char *host, int port);
215 bool silc_server_config_is_primary_route(SilcServer server);
216 SilcServerConfigRouter *
217 silc_server_config_get_primary_router(SilcServer server);
219 #endif /* !SERVERCONFIG_H */