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 *external_ip; /* E.g. public IP if we're in a NAT */
63 char *server_type; /* E.g. "Test Server" */
64 char *location; /* geographic location */
65 char *admin; /* admin full name */
66 char *email; /* admin's email address */
67 char *user; /* userid the server should be runned at */
68 char *group; /* ditto, but about groupid */
69 SilcPublicKey public_key;
70 SilcPrivateKey private_key;
71 char *motd_file; /* path to text motd file (reading only) */
72 char *pid_file; /* path to the pid file (for reading and writing) */
73 } SilcServerConfigServerInfo;
75 typedef struct SilcServerConfigLoggingStruct {
78 } SilcServerConfigLogging;
80 /* Connection parameters */
81 typedef struct SilcServerConfigConnParams {
82 struct SilcServerConfigConnParams *next;
84 char *version_protocol;
85 char *version_software;
86 char *version_software_vendor;
87 SilcUInt32 connections_max;
88 SilcUInt32 connections_max_per_host;
89 SilcUInt32 keepalive_secs;
90 SilcUInt32 reconnect_count;
91 SilcUInt32 reconnect_interval;
92 SilcUInt32 reconnect_interval_max;
93 SilcUInt32 key_exchange_rekey;
94 SilcUInt32 qos_rate_limit;
95 SilcUInt32 qos_bytes_limit;
96 SilcUInt32 qos_limit_sec;
97 SilcUInt32 qos_limit_usec;
99 unsigned int key_exchange_pfs : 1;
100 unsigned int reconnect_keep_trying : 1;
101 unsigned int anonymous : 1;
102 unsigned int qos : 1;
103 } SilcServerConfigConnParams;
105 /* Holds all client authentication data from config file */
106 typedef struct SilcServerConfigClientStruct {
108 unsigned char *passphrase;
109 SilcUInt32 passphrase_len;
111 SilcServerConfigConnParams *param;
112 struct SilcServerConfigClientStruct *next;
113 } SilcServerConfigClient;
115 /* Holds all server's administrators authentication data from config file */
116 typedef struct SilcServerConfigAdminStruct {
120 unsigned char *passphrase;
121 SilcUInt32 passphrase_len;
123 struct SilcServerConfigAdminStruct *next;
124 } SilcServerConfigAdmin;
126 /* Holds all configured denied connections from config file */
127 typedef struct SilcServerConfigDenyStruct {
130 struct SilcServerConfigDenyStruct *next;
131 } SilcServerConfigDeny;
133 /* Holds all configured server connections from config file */
134 typedef struct SilcServerConfigServerStruct {
136 unsigned char *passphrase;
137 SilcUInt32 passphrase_len;
139 SilcServerConfigConnParams *param;
140 SilcBool backup_router;
141 struct SilcServerConfigServerStruct *next;
142 } SilcServerConfigServer;
144 /* Holds all configured router connections from config file */
145 typedef struct SilcServerConfigRouterStruct {
147 unsigned char *passphrase;
148 SilcUInt32 passphrase_len;
151 SilcServerConfigConnParams *param;
153 SilcBool backup_router;
154 SilcBool dynamic_connection;
155 char *backup_replace_ip;
156 SilcUInt16 backup_replace_port;
157 SilcBool backup_local;
158 struct SilcServerConfigRouterStruct *next;
159 } SilcServerConfigRouter;
161 /* define the SilcServerConfig object */
166 /* Reference count (when this reaches zero, config object is destroyed) */
169 /* The General section */
171 SilcBool prefer_passphrase_auth;
172 SilcBool require_reverse_lookup;
173 SilcUInt32 channel_rekey_secs;
174 SilcUInt32 key_exchange_timeout;
175 SilcUInt32 conn_auth_timeout;
176 SilcServerConfigConnParams param;
177 SilcBool detach_disabled;
178 SilcUInt32 detach_timeout;
179 SilcBool logging_timestamp;
180 SilcBool logging_quick;
181 long logging_flushdelay;
185 SilcUInt16 httpd_port;
186 SilcBool dynamic_server;
187 SilcBool local_channels;
189 /* Other configuration sections */
190 SilcServerConfigCipher *cipher;
191 SilcServerConfigHash *hash;
192 SilcServerConfigHmac *hmac;
193 SilcServerConfigPkcs *pkcs;
194 SilcServerConfigLogging *logging_info;
195 SilcServerConfigLogging *logging_warnings;
196 SilcServerConfigLogging *logging_errors;
197 SilcServerConfigLogging *logging_fatals;
198 SilcServerConfigServerInfo *server_info;
199 SilcServerConfigConnParams *conn_params;
200 SilcServerConfigClient *clients;
201 SilcServerConfigAdmin *admins;
202 SilcServerConfigDeny *denied;
203 SilcServerConfigServer *servers;
204 SilcServerConfigRouter *routers;
208 SilcServerConfig config;
210 } SilcServerConfigRef;
214 /* Basic config operations */
215 SilcServerConfig silc_server_config_alloc(const char *filename,
217 void silc_server_config_destroy(SilcServerConfig config);
218 void silc_server_config_ref(SilcServerConfigRef *ref, SilcServerConfig config,
220 void silc_server_config_unref(SilcServerConfigRef *ref);
222 /* Algorithm registering and reset functions */
223 SilcBool silc_server_config_register_ciphers(SilcServer server);
224 SilcBool silc_server_config_register_hashfuncs(SilcServer server);
225 SilcBool silc_server_config_register_hmacs(SilcServer server);
226 SilcBool silc_server_config_register_pkcs(SilcServer server);
227 void silc_server_config_setlogfiles(SilcServer server);
229 /* Run-time config access functions */
230 SilcServerConfigClient *
231 silc_server_config_find_client(SilcServer server, char *host);
232 SilcServerConfigAdmin *
233 silc_server_config_find_admin(SilcServer server, char *host, char *user,
235 SilcServerConfigDeny *
236 silc_server_config_find_denied(SilcServer server, char *host);
237 SilcServerConfigServer *
238 silc_server_config_find_server_conn(SilcServer server, char *host);
239 SilcServerConfigRouter *
240 silc_server_config_find_router_conn(SilcServer server, char *host, int port);
241 SilcServerConfigRouter *
242 silc_server_config_find_backup_conn(SilcServer server, char *host);
243 SilcBool silc_server_config_is_primary_route(SilcServer server);
244 SilcServerConfigRouter *
245 silc_server_config_get_primary_router(SilcServer server);
246 SilcServerConfigRouter *
247 silc_server_config_get_backup_router(SilcServer server);
249 #endif /* !SERVERCONFIG_H */