Merged silc_1_1_branch to trunk.
[silc.git] / apps / silcd / serverconfig.h
index 4508c71783d748007a9821c034fec8556a3f041f..183f6501634cc1263bf8be9dc56265b61370a66f 100644 (file)
@@ -2,14 +2,13 @@
 
   serverconfig.h
 
-  Author: Johnny Mnemonic <johnny@themnemonic.org>
+  Author: Giovanni Giacobbi <giovanni@giacobbi.net>
 
-  Copyright (C) 1997 - 2002 Johnny Mnemonic
+  Copyright (C) 1997 - 2007 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
+  the Free Software Foundation; version 2 of the License.
 
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 typedef struct SilcServerConfigCipherStruct {
   char *name;
   char *module;
-  uint32 key_length;
-  uint32 block_length;
+  SilcUInt32 key_length;
+  SilcUInt32 block_length;
   struct SilcServerConfigCipherStruct *next;
 } SilcServerConfigCipher;
 
 typedef struct SilcServerConfigHashStruct {
   char *name;
   char *module;
-  uint32 block_length;
-  uint32 digest_length;
+  SilcUInt32 block_length;
+  SilcUInt32 digest_length;
   struct SilcServerConfigHashStruct *next;
 } SilcServerConfigHash;
 
 typedef struct SilcServerConfigHmacStruct {
   char *name;
   char *hash;
-  uint32 mac_length;
+  SilcUInt32 mac_length;
   struct SilcServerConfigHmacStruct *next;
 } SilcServerConfigHmac;
 
@@ -49,10 +48,17 @@ typedef struct SilcServerConfigPkcsStruct {
   struct SilcServerConfigPkcsStruct *next;
 } SilcServerConfigPkcs;
 
+typedef struct SilcServerConfigServerInfoInterfaceStruct {
+  char *server_ip;
+  char *public_ip;
+  SilcUInt16 port;
+  struct SilcServerConfigServerInfoInterfaceStruct *next;
+} SilcServerConfigServerInfoInterface;
+
 typedef struct SilcServerConfigServerInfoStruct {
   char *server_name;
-  char *server_ip;
-  uint16 port;
+  SilcServerConfigServerInfoInterface *primary;
+  SilcServerConfigServerInfoInterface *secondary;
   char *server_type;   /* E.g. "Test Server" */
   char *location;      /* geographic location */
   char *admin;         /* admin full name */
@@ -67,30 +73,40 @@ typedef struct SilcServerConfigServerInfoStruct {
 
 typedef struct SilcServerConfigLoggingStruct {
   char *file;
-  uint32 maxsize;
+  SilcUInt32 maxsize;
 } SilcServerConfigLogging;
 
 /* Connection parameters */
 typedef struct SilcServerConfigConnParams {
-  char *name;
-  uint32 connections_max;
-  uint32 connections_max_per_host;
-  uint32 keepalive_secs;
-  uint32 reconnect_count;
-  uint32 reconnect_interval;
-  uint32 reconnect_interval_max;
-  bool reconnect_keep_trying;
-  uint32 key_exchange_rekey;
-  bool key_exchange_pfs;
   struct SilcServerConfigConnParams *next;
+  char *name;
+  char *version_protocol;
+  char *version_software;
+  char *version_software_vendor;
+  SilcUInt32 connections_max;
+  SilcUInt32 connections_max_per_host;
+  SilcUInt32 keepalive_secs;
+  SilcUInt32 reconnect_count;
+  SilcUInt32 reconnect_interval;
+  SilcUInt32 reconnect_interval_max;
+  SilcUInt32 key_exchange_rekey;
+  SilcUInt32 qos_rate_limit;
+  SilcUInt32 qos_bytes_limit;
+  SilcUInt32 qos_limit_sec;
+  SilcUInt32 qos_limit_usec;
+  SilcUInt32 chlimit;
+  unsigned int key_exchange_pfs      : 1;
+  unsigned int reconnect_keep_trying : 1;
+  unsigned int anonymous             : 1;
+  unsigned int qos                   : 1;
 } SilcServerConfigConnParams;
 
 /* Holds all client authentication data from config file */
 typedef struct SilcServerConfigClientStruct {
   char *host;
   unsigned char *passphrase;
-  uint32 passphrase_len;
-  void *publickey;
+  SilcUInt32 passphrase_len;
+  SilcBool publickeys;
   SilcServerConfigConnParams *param;
   struct SilcServerConfigClientStruct *next;
 } SilcServerConfigClient;
@@ -101,15 +117,14 @@ typedef struct SilcServerConfigAdminStruct {
   char *user;
   char *nick;
   unsigned char *passphrase;
-  uint32 passphrase_len;
-  void *publickey;
+  SilcUInt32 passphrase_len;
+  SilcBool publickeys;
   struct SilcServerConfigAdminStruct *next;
 } SilcServerConfigAdmin;
 
 /* Holds all configured denied connections from config file */
 typedef struct SilcServerConfigDenyStruct {
   char *host;
-  uint16 port;
   char *reason;
   struct SilcServerConfigDenyStruct *next;
 } SilcServerConfigDeny;
@@ -118,11 +133,10 @@ typedef struct SilcServerConfigDenyStruct {
 typedef struct SilcServerConfigServerStruct {
   char *host;
   unsigned char *passphrase;
-  uint32 passphrase_len;
-  void *publickey;
-  char *version;
+  SilcUInt32 passphrase_len;
+  SilcBool publickeys;
   SilcServerConfigConnParams *param;
-  bool backup_router;
+  SilcBool backup_router;
   struct SilcServerConfigServerStruct *next;
 } SilcServerConfigServer;
 
@@ -130,31 +144,46 @@ typedef struct SilcServerConfigServerStruct {
 typedef struct SilcServerConfigRouterStruct {
   char *host;
   unsigned char *passphrase;
-  uint32 passphrase_len;
-  void *publickey;
-  uint16 port;
-  char *version;
+  SilcUInt32 passphrase_len;
+  SilcBool publickeys;
+  SilcUInt16 port;
   SilcServerConfigConnParams *param;
-  bool initiator;
-  bool backup_router;
+  SilcBool initiator;
+  SilcBool backup_router;
+  SilcBool dynamic_connection;
   char *backup_replace_ip;
-  uint16 backup_replace_port;
-  bool backup_local;
+  SilcUInt16 backup_replace_port;
+  SilcBool backup_local;
   struct SilcServerConfigRouterStruct *next;
 } SilcServerConfigRouter;
 
 /* define the SilcServerConfig object */
 typedef struct {
+  SilcServer server;
   void *tmp;
 
+  /* Reference count (when this reaches zero, config object is destroyed) */
+  SilcInt32 refcount;
+
   /* The General section */
   char *module_path;
-  bool prefer_passphrase_auth;
-  bool require_reverse_lookup;
-  uint32 channel_rekey_secs;
-  uint32 key_exchange_timeout;
-  uint32 conn_auth_timeout;
+  SilcBool prefer_passphrase_auth;
+  SilcBool require_reverse_lookup;
+  SilcUInt32 channel_rekey_secs;
+  SilcUInt32 key_exchange_timeout;
+  SilcUInt32 conn_auth_timeout;
   SilcServerConfigConnParams param;
+  SilcBool detach_disabled;
+  SilcUInt32 detach_timeout;
+  SilcBool logging_timestamp;
+  SilcBool logging_quick;
+  long logging_flushdelay;
+  char *debug_string;
+  SilcBool httpd;
+  char *httpd_ip;
+  SilcUInt16 httpd_port;
+  SilcBool dynamic_server;
+  SilcBool local_channels;
 
   /* Other configuration sections */
   SilcServerConfigCipher *cipher;
@@ -174,34 +203,46 @@ typedef struct {
   SilcServerConfigRouter *routers;
 } *SilcServerConfig;
 
+typedef struct {
+  SilcServerConfig config;
+  void *ref_ptr;
+} SilcServerConfigRef;
+
 /* Prototypes */
 
 /* Basic config operations */
-SilcServerConfig silc_server_config_alloc(char *filename);
+SilcServerConfig silc_server_config_alloc(const char *filename,
+                                         SilcServer server);
 void silc_server_config_destroy(SilcServerConfig config);
+void silc_server_config_ref(SilcServerConfigRef *ref, SilcServerConfig config,
+                           void *ref_ptr);
+void silc_server_config_unref(SilcServerConfigRef *ref);
 
 /* Algorithm registering and reset functions */
-bool silc_server_config_register_ciphers(SilcServer server);
-bool silc_server_config_register_hashfuncs(SilcServer server);
-bool silc_server_config_register_hmacs(SilcServer server);
-bool silc_server_config_register_pkcs(SilcServer server);
+SilcBool silc_server_config_register_ciphers(SilcServer server);
+SilcBool silc_server_config_register_hashfuncs(SilcServer server);
+SilcBool silc_server_config_register_hmacs(SilcServer server);
+SilcBool silc_server_config_register_pkcs(SilcServer server);
 void silc_server_config_setlogfiles(SilcServer server);
 
 /* Run-time config access functions */
 SilcServerConfigClient *
 silc_server_config_find_client(SilcServer server, char *host);
 SilcServerConfigAdmin *
-silc_server_config_find_admin(SilcServer server, char *host, char *user, 
+silc_server_config_find_admin(SilcServer server, char *host, char *user,
                              char *nick);
 SilcServerConfigDeny *
-silc_server_config_find_denied(SilcServer server, char *host, uint16 port);
+silc_server_config_find_denied(SilcServer server, char *host);
 SilcServerConfigServer *
 silc_server_config_find_server_conn(SilcServer server, char *host);
 SilcServerConfigRouter *
 silc_server_config_find_router_conn(SilcServer server, char *host, int port);
-bool silc_server_config_is_primary_route(SilcServer server);
+SilcServerConfigRouter *
+silc_server_config_find_backup_conn(SilcServer server, char *host);
+SilcBool silc_server_config_is_primary_route(SilcServer server);
 SilcServerConfigRouter *
 silc_server_config_get_primary_router(SilcServer server);
-bool silc_server_config_set_defaults(SilcServer server);
+SilcServerConfigRouter *
+silc_server_config_get_backup_router(SilcServer server);
 
 #endif /* !SERVERCONFIG_H */