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;
95 SilcServerConfigSectionConnectionParam *param;
96 struct SilcServerConfigSectionClientStruct *next;
97 } SilcServerConfigSectionClient;
99 /* Holds all server's administrators authentication data from config file */
100 typedef struct SilcServerConfigSectionAdminStruct {
104 unsigned char *passphrase;
105 uint32 passphrase_len;
107 struct SilcServerConfigSectionAdminStruct *next;
108 } SilcServerConfigSectionAdmin;
110 /* Holds all configured denied connections from config file */
111 typedef struct SilcServerConfigSectionDenyStruct {
115 struct SilcServerConfigSectionDenyStruct *next;
116 } SilcServerConfigSectionDeny;
118 /* Holds all configured server connections from config file */
119 typedef struct SilcServerConfigSectionServerStruct {
121 unsigned char *passphrase;
122 uint32 passphrase_len;
125 SilcServerConfigSectionConnectionParam *param;
127 struct SilcServerConfigSectionServerStruct *next;
128 } SilcServerConfigSectionServer;
130 /* Holds all configured router connections from config file */
131 typedef struct SilcServerConfigSectionRouterStruct {
133 unsigned char *passphrase;
134 uint32 passphrase_len;
138 SilcServerConfigSectionConnectionParam *param;
141 char *backup_replace_ip;
142 uint16 backup_replace_port;
144 struct SilcServerConfigSectionRouterStruct *next;
145 } SilcServerConfigSectionRouter;
147 /* define the SilcServerConfig object */
151 /* The General section */
153 bool prefer_passphrase_auth;
154 bool require_reverse_lookup;
155 /* XXX Still think whether to actually have params in general... -Pekka */
156 SilcServerConfigSectionConnectionParam param;
158 /* Other configuration sections */
159 SilcServerConfigSectionCipher *cipher;
160 SilcServerConfigSectionHash *hash;
161 SilcServerConfigSectionHmac *hmac;
162 SilcServerConfigSectionPkcs *pkcs;
163 SilcServerConfigSectionLogging *logging_info;
164 SilcServerConfigSectionLogging *logging_warnings;
165 SilcServerConfigSectionLogging *logging_errors;
166 SilcServerConfigSectionLogging *logging_fatals;
167 SilcServerConfigSectionServerInfo *server_info;
168 SilcServerConfigSectionConnectionParam *conn_params;
169 SilcServerConfigSectionClient *clients;
170 SilcServerConfigSectionAdmin *admins;
171 SilcServerConfigSectionDeny *denied;
172 SilcServerConfigSectionServer *servers;
173 SilcServerConfigSectionRouter *routers;
178 /* Basic config operations */
179 SilcServerConfig silc_server_config_alloc(char *filename);
180 void silc_server_config_destroy(SilcServerConfig config);
182 /* Algorithm registering and reset functions */
183 bool silc_server_config_register_ciphers(SilcServer server);
184 bool silc_server_config_register_hashfuncs(SilcServer server);
185 bool silc_server_config_register_hmacs(SilcServer server);
186 bool silc_server_config_register_pkcs(SilcServer server);
187 void silc_server_config_setlogfiles(SilcServer server);
189 /* Run-time config access functions */
190 SilcServerConfigSectionClient *
191 silc_server_config_find_client(SilcServer server, char *host, int port);
192 SilcServerConfigSectionAdmin *
193 silc_server_config_find_admin(SilcServer server, char *host, char *user,
195 SilcServerConfigSectionDeny *
196 silc_server_config_find_denied(SilcServer server, char *host, uint16 port);
197 SilcServerConfigSectionServer *
198 silc_server_config_find_server_conn(SilcServer server, char *host);
199 SilcServerConfigSectionRouter *
200 silc_server_config_find_router_conn(SilcServer server, char *host, int port);
201 bool silc_server_config_is_primary_route(SilcServer server);
202 SilcServerConfigSectionRouter *
203 silc_server_config_get_primary_router(SilcServer server);
204 bool silc_server_config_set_defaults(SilcServer server);
206 #endif /* !SERVERCONFIG_H */