serverconfig.h
- Author: Johnny Mnemonic <johnny@themnemonic.org>
+ Author: Giovanni Giacobbi <giovanni@giacobbi.net>
- Copyright (C) 1997 - 2002 Johnny Mnemonic
+ Copyright (C) 1997 - 2002 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
#ifndef SERVERCONFIG_H
#define SERVERCONFIG_H
-typedef struct SilcServerConfigSectionCipherStruct {
+typedef struct SilcServerConfigCipherStruct {
char *name;
char *module;
- uint32 key_length;
- uint32 block_length;
- struct SilcServerConfigSectionCipherStruct *next;
-} SilcServerConfigSectionCipher;
+ SilcUInt32 key_length;
+ SilcUInt32 block_length;
+ struct SilcServerConfigCipherStruct *next;
+} SilcServerConfigCipher;
-typedef struct SilcServerConfigSectionHashStruct {
+typedef struct SilcServerConfigHashStruct {
char *name;
char *module;
- uint32 block_length;
- uint32 digest_length;
- struct SilcServerConfigSectionHashStruct *next;
-} SilcServerConfigSectionHash;
+ SilcUInt32 block_length;
+ SilcUInt32 digest_length;
+ struct SilcServerConfigHashStruct *next;
+} SilcServerConfigHash;
-typedef struct SilcServerConfigSectionHmacStruct {
+typedef struct SilcServerConfigHmacStruct {
char *name;
char *hash;
- uint32 mac_length;
- struct SilcServerConfigSectionHmacStruct *next;
-} SilcServerConfigSectionHmac;
+ SilcUInt32 mac_length;
+ struct SilcServerConfigHmacStruct *next;
+} SilcServerConfigHmac;
-typedef struct SilcServerConfigSectionPkcsStruct {
+typedef struct SilcServerConfigPkcsStruct {
char *name;
- struct SilcServerConfigSectionPkcsStruct *next;
-} SilcServerConfigSectionPkcs;
+ struct SilcServerConfigPkcsStruct *next;
+} SilcServerConfigPkcs;
-typedef struct SilcServerConfigSectionServerInfoStruct {
- char *server_name;
+typedef struct SilcServerConfigServerInfoInterfaceStruct {
char *server_ip;
- uint16 port;
+ SilcUInt16 port;
+ struct SilcServerConfigServerInfoInterfaceStruct *next;
+} SilcServerConfigServerInfoInterface;
+
+typedef struct SilcServerConfigServerInfoStruct {
+ char *server_name;
+ SilcServerConfigServerInfoInterface *primary;
+ SilcServerConfigServerInfoInterface *secondary;
char *server_type; /* E.g. "Test Server" */
char *location; /* geographic location */
char *admin; /* admin full name */
SilcPrivateKey private_key;
char *motd_file; /* path to text motd file (reading only) */
char *pid_file; /* path to the pid file (for reading and writing) */
-} SilcServerConfigSectionServerInfo;
+} SilcServerConfigServerInfo;
-typedef struct SilcServerConfigSectionLoggingStruct {
+typedef struct SilcServerConfigLoggingStruct {
char *file;
- uint32 maxsize;
-} SilcServerConfigSectionLogging;
-
-/* Holds all configured connection classes */
-/* typedef struct SilcServerConfigSectionClassStruct {
- uint32 class;
- uint32 ping_freq;
- uint32 connect_freq;
- uint32 max_links;
- struct SilcServerConfigSectionClassStruct *next;
-} SilcServerConfigSectionClass; */
+ SilcUInt32 maxsize;
+} SilcServerConfigLogging;
+
+/* Connection parameters */
+typedef struct SilcServerConfigConnParams {
+ 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;
+ 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 SilcServerConfigSectionClientStruct {
+typedef struct SilcServerConfigClientStruct {
char *host;
unsigned char *passphrase;
- uint32 passphrase_len;
- void *publickey;
- uint16 port;
- uint32 class;
- struct SilcServerConfigSectionClientStruct *next;
-} SilcServerConfigSectionClient;
+ SilcUInt32 passphrase_len;
+ SilcHashTable publickeys;
+ SilcServerConfigConnParams *param;
+ struct SilcServerConfigClientStruct *next;
+} SilcServerConfigClient;
/* Holds all server's administrators authentication data from config file */
-typedef struct SilcServerConfigSectionAdminStruct {
+typedef struct SilcServerConfigAdminStruct {
char *host;
char *user;
char *nick;
unsigned char *passphrase;
- uint32 passphrase_len;
- void *publickey;
- struct SilcServerConfigSectionAdminStruct *next;
-} SilcServerConfigSectionAdmin;
+ SilcUInt32 passphrase_len;
+ SilcHashTable publickeys;
+ struct SilcServerConfigAdminStruct *next;
+} SilcServerConfigAdmin;
/* Holds all configured denied connections from config file */
-typedef struct SilcServerConfigSectionDenyStruct {
+typedef struct SilcServerConfigDenyStruct {
char *host;
- uint16 port;
char *reason;
- struct SilcServerConfigSectionDenyStruct *next;
-} SilcServerConfigSectionDeny;
+ struct SilcServerConfigDenyStruct *next;
+} SilcServerConfigDeny;
/* Holds all configured server connections from config file */
-typedef struct SilcServerConfigSectionServerStruct {
+typedef struct SilcServerConfigServerStruct {
char *host;
unsigned char *passphrase;
- uint32 passphrase_len;
- void *publickey;
- char *version;
- uint32 class;
+ SilcUInt32 passphrase_len;
+ SilcHashTable publickeys;
+ SilcServerConfigConnParams *param;
bool backup_router;
- struct SilcServerConfigSectionServerStruct *next;
-} SilcServerConfigSectionServer;
+ struct SilcServerConfigServerStruct *next;
+} SilcServerConfigServer;
/* Holds all configured router connections from config file */
-typedef struct SilcServerConfigSectionRouterStruct {
+typedef struct SilcServerConfigRouterStruct {
char *host;
unsigned char *passphrase;
- uint32 passphrase_len;
- void *publickey;
- uint16 port;
- char *version;
- uint32 class;
+ SilcUInt32 passphrase_len;
+ SilcHashTable publickeys;
+ SilcUInt16 port;
+ SilcServerConfigConnParams *param;
bool initiator;
bool backup_router;
char *backup_replace_ip;
- uint16 backup_replace_port;
+ SilcUInt16 backup_replace_port;
bool backup_local;
- struct SilcServerConfigSectionRouterStruct *next;
-} SilcServerConfigSectionRouter;
+ struct SilcServerConfigRouterStruct *next;
+} SilcServerConfigRouter;
/* define the SilcServerConfig object */
typedef struct {
void *tmp;
+
+ /* Reference count (when this reaches zero, config object is destroyed) */
+ SilcInt32 refcount;
+
+ /* The General section */
char *module_path;
bool prefer_passphrase_auth;
-
- SilcServerConfigSectionCipher *cipher;
- SilcServerConfigSectionHash *hash;
- SilcServerConfigSectionHmac *hmac;
- SilcServerConfigSectionPkcs *pkcs;
- SilcServerConfigSectionLogging *logging_info;
- SilcServerConfigSectionLogging *logging_warnings;
- SilcServerConfigSectionLogging *logging_errors;
- SilcServerConfigSectionLogging *logging_fatals;
- SilcServerConfigSectionServerInfo *server_info;
-/*SilcServerConfigSectionClass *conn_class; */
- SilcServerConfigSectionClient *clients;
- SilcServerConfigSectionAdmin *admins;
- SilcServerConfigSectionDeny *denied;
- SilcServerConfigSectionServer *servers;
- SilcServerConfigSectionRouter *routers;
+ bool require_reverse_lookup;
+ SilcUInt32 channel_rekey_secs;
+ SilcUInt32 key_exchange_timeout;
+ SilcUInt32 conn_auth_timeout;
+ SilcServerConfigConnParams param;
+ bool detach_disabled;
+ SilcUInt32 detach_timeout;
+ bool logging_timestamp;
+ bool logging_quick;
+ long logging_flushdelay;
+ char *debug_string;
+
+ /* Other configuration sections */
+ SilcServerConfigCipher *cipher;
+ SilcServerConfigHash *hash;
+ SilcServerConfigHmac *hmac;
+ SilcServerConfigPkcs *pkcs;
+ SilcServerConfigLogging *logging_info;
+ SilcServerConfigLogging *logging_warnings;
+ SilcServerConfigLogging *logging_errors;
+ SilcServerConfigLogging *logging_fatals;
+ SilcServerConfigServerInfo *server_info;
+ SilcServerConfigConnParams *conn_params;
+ SilcServerConfigClient *clients;
+ SilcServerConfigAdmin *admins;
+ SilcServerConfigDeny *denied;
+ SilcServerConfigServer *servers;
+ 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);
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);
void silc_server_config_setlogfiles(SilcServer server);
/* Run-time config access functions */
-SilcServerConfigSectionClient *
-silc_server_config_find_client(SilcServer server, char *host, int port);
-SilcServerConfigSectionAdmin *
-silc_server_config_find_admin(SilcServer server, char *host, char *user,
+SilcServerConfigClient *
+silc_server_config_find_client(SilcServer server, char *host);
+SilcServerConfigAdmin *
+silc_server_config_find_admin(SilcServer server, char *host, char *user,
char *nick);
-SilcServerConfigSectionDeny *
-silc_server_config_find_denied(SilcServer server, char *host, uint16 port);
-SilcServerConfigSectionServer *
+SilcServerConfigDeny *
+silc_server_config_find_denied(SilcServer server, char *host);
+SilcServerConfigServer *
silc_server_config_find_server_conn(SilcServer server, char *host);
-SilcServerConfigSectionRouter *
+SilcServerConfigRouter *
silc_server_config_find_router_conn(SilcServer server, char *host, int port);
+SilcServerConfigRouter *
+silc_server_config_find_backup_conn(SilcServer server, char *host);
bool silc_server_config_is_primary_route(SilcServer server);
-SilcServerConfigSectionRouter *
+SilcServerConfigRouter *
silc_server_config_get_primary_router(SilcServer server);
+SilcServerConfigRouter *
+silc_server_config_get_backup_router(SilcServer server);
#endif /* !SERVERCONFIG_H */