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 SilcServerConfigSectionCipherStruct {
29 struct SilcServerConfigSectionCipherStruct *next;
30 } SilcServerConfigSectionCipher;
32 typedef struct SilcServerConfigSectionHashStruct {
37 struct SilcServerConfigSectionHashStruct *next;
38 } SilcServerConfigSectionHash;
40 typedef struct SilcServerConfigSectionHmacStruct {
44 struct SilcServerConfigSectionHmacStruct *next;
45 } SilcServerConfigSectionHmac;
47 typedef struct SilcServerConfigSectionPkcsStruct {
49 struct SilcServerConfigSectionPkcsStruct *next;
50 } SilcServerConfigSectionPkcs;
52 typedef struct SilcServerConfigSectionServerInfoStruct {
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 } SilcServerConfigSectionServerInfo;
68 typedef struct SilcServerConfigSectionLoggingStruct {
71 } SilcServerConfigSectionLogging;
73 /* Connection parameters */
74 typedef struct SilcServerConfigSectionConnectionParam {
76 uint32 keepalive_secs;
77 uint32 reconnect_count;
78 uint32 reconnect_interval;
79 uint32 reconnect_interval_max;
80 bool reconnect_keep_trying;
85 struct SilcServerConfigSectionConnectionParam *next;
86 } SilcServerConfigSectionConnectionParam;
88 /* Holds all client authentication data from config file */
89 typedef struct SilcServerConfigSectionClientStruct {
91 unsigned char *passphrase;
92 uint32 passphrase_len;
96 SilcServerConfigSectionConnectionParam *param;
97 struct SilcServerConfigSectionClientStruct *next;
98 } SilcServerConfigSectionClient;
100 /* Holds all server's administrators authentication data from config file */
101 typedef struct SilcServerConfigSectionAdminStruct {
105 unsigned char *passphrase;
106 uint32 passphrase_len;
108 struct SilcServerConfigSectionAdminStruct *next;
109 } SilcServerConfigSectionAdmin;
111 /* Holds all configured denied connections from config file */
112 typedef struct SilcServerConfigSectionDenyStruct {
116 struct SilcServerConfigSectionDenyStruct *next;
117 } SilcServerConfigSectionDeny;
119 /* Holds all configured server connections from config file */
120 typedef struct SilcServerConfigSectionServerStruct {
122 unsigned char *passphrase;
123 uint32 passphrase_len;
127 SilcServerConfigSectionConnectionParam *param;
129 struct SilcServerConfigSectionServerStruct *next;
130 } SilcServerConfigSectionServer;
132 /* Holds all configured router connections from config file */
133 typedef struct SilcServerConfigSectionRouterStruct {
135 unsigned char *passphrase;
136 uint32 passphrase_len;
141 SilcServerConfigSectionConnectionParam *param;
144 char *backup_replace_ip;
145 uint16 backup_replace_port;
147 struct SilcServerConfigSectionRouterStruct *next;
148 } SilcServerConfigSectionRouter;
150 /* define the SilcServerConfig object */
154 /* The General section */
156 bool prefer_passphrase_auth;
157 bool require_reverse_lookup;
158 /* XXX Still think whether to actually have params in general... -Pekka */
159 SilcServerConfigSectionConnectionParam param;
161 /* Other configuration sections */
162 SilcServerConfigSectionCipher *cipher;
163 SilcServerConfigSectionHash *hash;
164 SilcServerConfigSectionHmac *hmac;
165 SilcServerConfigSectionPkcs *pkcs;
166 SilcServerConfigSectionLogging *logging_info;
167 SilcServerConfigSectionLogging *logging_warnings;
168 SilcServerConfigSectionLogging *logging_errors;
169 SilcServerConfigSectionLogging *logging_fatals;
170 SilcServerConfigSectionServerInfo *server_info;
171 SilcServerConfigSectionConnectionParam *conn_params;
172 SilcServerConfigSectionClient *clients;
173 SilcServerConfigSectionAdmin *admins;
174 SilcServerConfigSectionDeny *denied;
175 SilcServerConfigSectionServer *servers;
176 SilcServerConfigSectionRouter *routers;
181 /* Basic config operations */
182 SilcServerConfig silc_server_config_alloc(char *filename);
183 void silc_server_config_destroy(SilcServerConfig config);
185 /* Algorithm registering and reset functions */
186 bool silc_server_config_register_ciphers(SilcServer server);
187 bool silc_server_config_register_hashfuncs(SilcServer server);
188 bool silc_server_config_register_hmacs(SilcServer server);
189 bool silc_server_config_register_pkcs(SilcServer server);
190 void silc_server_config_setlogfiles(SilcServer server);
192 /* Run-time config access functions */
193 SilcServerConfigSectionClient *
194 silc_server_config_find_client(SilcServer server, char *host, int port);
195 SilcServerConfigSectionAdmin *
196 silc_server_config_find_admin(SilcServer server, char *host, char *user,
198 SilcServerConfigSectionDeny *
199 silc_server_config_find_denied(SilcServer server, char *host, uint16 port);
200 SilcServerConfigSectionServer *
201 silc_server_config_find_server_conn(SilcServer server, char *host);
202 SilcServerConfigSectionRouter *
203 silc_server_config_find_router_conn(SilcServer server, char *host, int port);
204 bool silc_server_config_is_primary_route(SilcServer server);
205 SilcServerConfigSectionRouter *
206 silc_server_config_get_primary_router(SilcServer server);
207 bool silc_server_config_set_defaults(SilcServer server);
209 #endif /* !SERVERCONFIG_H */