Integer type name change.
[silc.git] / apps / silcd / serverconfig.h
1 /*
2
3   serverconfig.h
4
5   Author: Johnny Mnemonic <johnny@themnemonic.org>
6
7   Copyright (C) 1997 - 2002 Johnny Mnemonic
8
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.
13
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.
18
19 */
20
21 #ifndef SERVERCONFIG_H
22 #define SERVERCONFIG_H
23
24 typedef struct SilcServerConfigCipherStruct {
25   char *name;
26   char *module;
27   SilcUInt32 key_length;
28   SilcUInt32 block_length;
29   struct SilcServerConfigCipherStruct *next;
30 } SilcServerConfigCipher;
31
32 typedef struct SilcServerConfigHashStruct {
33   char *name;
34   char *module;
35   SilcUInt32 block_length;
36   SilcUInt32 digest_length;
37   struct SilcServerConfigHashStruct *next;
38 } SilcServerConfigHash;
39
40 typedef struct SilcServerConfigHmacStruct {
41   char *name;
42   char *hash;
43   SilcUInt32 mac_length;
44   struct SilcServerConfigHmacStruct *next;
45 } SilcServerConfigHmac;
46
47 typedef struct SilcServerConfigPkcsStruct {
48   char *name;
49   struct SilcServerConfigPkcsStruct *next;
50 } SilcServerConfigPkcs;
51
52 typedef struct SilcServerConfigServerInfoStruct {
53   char *server_name;
54   char *server_ip;
55   SilcUInt16 port;
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;
67
68 typedef struct SilcServerConfigLoggingStruct {
69   char *file;
70   SilcUInt32 maxsize;
71 } SilcServerConfigLogging;
72
73 /* Connection parameters */
74 typedef struct SilcServerConfigConnParams {
75   char *name;
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   struct SilcServerConfigConnParams *next;
86 } SilcServerConfigConnParams;
87
88 /* Holds all client authentication data from config file */
89 typedef struct SilcServerConfigClientStruct {
90   char *host;
91   unsigned char *passphrase;
92   SilcUInt32 passphrase_len;
93   void *publickey;
94   SilcServerConfigConnParams *param;
95   struct SilcServerConfigClientStruct *next;
96 } SilcServerConfigClient;
97
98 /* Holds all server's administrators authentication data from config file */
99 typedef struct SilcServerConfigAdminStruct {
100   char *host;
101   char *user;
102   char *nick;
103   unsigned char *passphrase;
104   SilcUInt32 passphrase_len;
105   void *publickey;
106   struct SilcServerConfigAdminStruct *next;
107 } SilcServerConfigAdmin;
108
109 /* Holds all configured denied connections from config file */
110 typedef struct SilcServerConfigDenyStruct {
111   char *host;
112   char *reason;
113   struct SilcServerConfigDenyStruct *next;
114 } SilcServerConfigDeny;
115
116 /* Holds all configured server connections from config file */
117 typedef struct SilcServerConfigServerStruct {
118   char *host;
119   unsigned char *passphrase;
120   SilcUInt32 passphrase_len;
121   void *publickey;
122   char *version;
123   SilcServerConfigConnParams *param;
124   bool backup_router;
125   struct SilcServerConfigServerStruct *next;
126 } SilcServerConfigServer;
127
128 /* Holds all configured router connections from config file */
129 typedef struct SilcServerConfigRouterStruct {
130   char *host;
131   unsigned char *passphrase;
132   SilcUInt32 passphrase_len;
133   void *publickey;
134   SilcUInt16 port;
135   char *version;
136   SilcServerConfigConnParams *param;
137   bool initiator;
138   bool backup_router;
139   char *backup_replace_ip;
140   SilcUInt16 backup_replace_port;
141   bool backup_local;
142   struct SilcServerConfigRouterStruct *next;
143 } SilcServerConfigRouter;
144
145 /* define the SilcServerConfig object */
146 typedef struct {
147   void *tmp;
148
149   /* The General section */
150   char *module_path;
151   bool prefer_passphrase_auth;
152   bool require_reverse_lookup;
153   SilcUInt32 channel_rekey_secs;
154   SilcUInt32 key_exchange_timeout;
155   SilcUInt32 conn_auth_timeout;
156   SilcServerConfigConnParams param;
157
158   /* Other configuration sections */
159   SilcServerConfigCipher *cipher;
160   SilcServerConfigHash *hash;
161   SilcServerConfigHmac *hmac;
162   SilcServerConfigPkcs *pkcs;
163   SilcServerConfigLogging *logging_info;
164   SilcServerConfigLogging *logging_warnings;
165   SilcServerConfigLogging *logging_errors;
166   SilcServerConfigLogging *logging_fatals;
167   SilcServerConfigServerInfo *server_info;
168   SilcServerConfigConnParams *conn_params;
169   SilcServerConfigClient *clients;
170   SilcServerConfigAdmin *admins;
171   SilcServerConfigDeny *denied;
172   SilcServerConfigServer *servers;
173   SilcServerConfigRouter *routers;
174 } *SilcServerConfig;
175
176 /* Prototypes */
177
178 /* Basic config operations */
179 SilcServerConfig silc_server_config_alloc(char *filename);
180 void silc_server_config_destroy(SilcServerConfig config);
181
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);
188
189 /* Run-time config access functions */
190 SilcServerConfigClient *
191 silc_server_config_find_client(SilcServer server, char *host);
192 SilcServerConfigAdmin *
193 silc_server_config_find_admin(SilcServer server, char *host, char *user, 
194                               char *nick);
195 SilcServerConfigDeny *
196 silc_server_config_find_denied(SilcServer server, char *host);
197 SilcServerConfigServer *
198 silc_server_config_find_server_conn(SilcServer server, char *host);
199 SilcServerConfigRouter *
200 silc_server_config_find_router_conn(SilcServer server, char *host, int port);
201 bool silc_server_config_is_primary_route(SilcServer server);
202 SilcServerConfigRouter *
203 silc_server_config_get_primary_router(SilcServer server);
204 bool silc_server_config_set_defaults(SilcServer server);
205
206 #endif  /* !SERVERCONFIG_H */