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 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 /* Holds all configured connection classes */
74 /* typedef struct SilcServerConfigSectionClassStruct {
79 struct SilcServerConfigSectionClassStruct *next;
80 } SilcServerConfigSectionClass; */
82 /* Holds all client authentication data from config file */
83 typedef struct SilcServerConfigSectionClientStruct {
85 SilcAuthMethod auth_meth;
90 struct SilcServerConfigSectionClientStruct *next;
91 } SilcServerConfigSectionClient;
93 /* Holds all server's administrators authentication data from config file */
94 typedef struct SilcServerConfigSectionAdminStruct {
98 SilcAuthMethod auth_meth;
100 uint32 auth_data_len;
101 struct SilcServerConfigSectionAdminStruct *next;
102 } SilcServerConfigSectionAdmin;
104 /* Holds all configured denied connections from config file */
105 typedef struct SilcServerConfigSectionDenyStruct {
109 struct SilcServerConfigSectionDenyStruct *next;
110 } SilcServerConfigSectionDeny;
112 /* Holds all configured server connections from config file */
113 typedef struct SilcServerConfigSectionServerStruct {
115 SilcAuthMethod auth_meth;
117 uint32 auth_data_len;
122 struct SilcServerConfigSectionServerStruct *next;
123 } SilcServerConfigSectionServer;
125 /* Holds all configured router connections from config file */
126 typedef struct SilcServerConfigSectionRouterStruct {
128 SilcAuthMethod auth_meth;
130 uint32 auth_data_len;
136 char *backup_replace_ip;
137 uint16 backup_replace_port;
139 struct SilcServerConfigSectionRouterStruct *next;
140 } SilcServerConfigSectionRouter;
142 /* define the SilcServerConfig object */
147 SilcServerConfigSectionCipher *cipher;
148 SilcServerConfigSectionHash *hash;
149 SilcServerConfigSectionHmac *hmac;
150 SilcServerConfigSectionPkcs *pkcs;
151 SilcServerConfigSectionLogging *logging_info;
152 SilcServerConfigSectionLogging *logging_warnings;
153 SilcServerConfigSectionLogging *logging_errors;
154 SilcServerConfigSectionLogging *logging_fatals;
155 SilcServerConfigSectionServerInfo *server_info;
156 /*SilcServerConfigSectionClass *conn_class; */
157 SilcServerConfigSectionClient *clients;
158 SilcServerConfigSectionAdmin *admins;
159 SilcServerConfigSectionDeny *denied;
160 SilcServerConfigSectionServer *servers;
161 SilcServerConfigSectionRouter *routers;
166 /* basic config operations */
167 SilcServerConfig silc_server_config_alloc(char *filename);
168 void silc_server_config_destroy(SilcServerConfig config);
170 /* algorithm registering and reset functions */
171 bool silc_server_config_register_ciphers(SilcServer server);
172 bool silc_server_config_register_hashfuncs(SilcServer server);
173 bool silc_server_config_register_hmacs(SilcServer server);
174 bool silc_server_config_register_pkcs(SilcServer server);
175 void silc_server_config_setlogfiles(SilcServerConfig config, SilcSchedule sked);
177 /* run-time config access functions */
178 SilcServerConfigSectionClient *
179 silc_server_config_find_client(SilcServerConfig config, char *host, int port);
181 SilcServerConfigSectionAdmin *
182 silc_server_config_find_admin(SilcServerConfig config,
183 char *host, char *user, char *nick);
185 SilcServerConfigSectionDeny *
186 silc_server_config_find_denied(SilcServerConfig config,
187 char *host, uint16 port);
189 /* Prototypes - OLD */
190 SilcServerConfigSectionServer *
191 silc_server_config_find_server_conn(SilcServerConfig config,
192 char *host, int port);
193 SilcServerConfigSectionRouter *
194 silc_server_config_find_router_conn(SilcServerConfig config,
195 char *host, int port);
196 bool silc_server_config_is_primary_route(SilcServerConfig config);
197 SilcServerConfigSectionRouter *
198 silc_server_config_get_primary_router(SilcServerConfig config);
200 #endif /* !SERVERCONFIG_H */