updates.
[silc.git] / apps / silcd / serverconfig.h
index 77644e4fae1f1250276353c9fd26faffabfda43f..0c424a43b21ad1bfc9e328cbcda091b4ab909466 100644 (file)
 typedef struct SilcServerConfigSectionAlgStruct {
   char *alg_name;
   char *sim_name;
-  unsigned int block_len;
-  unsigned int key_len;
+  uint32 block_len;
+  uint32 key_len;
   struct SilcServerConfigSectionAlgStruct *next;
   struct SilcServerConfigSectionAlgStruct *prev;
 #define SILC_CONFIG_SERVER_MODNAME "builtin"
 } SilcServerConfigSectionAlg;
 
+/* Holds server keys from config file */
+typedef struct {
+  SilcPublicKey public_key;
+  SilcPrivateKey private_key;
+} SilcServerConfigSectionServerKeys;
+
 /* Holds server information from config file */
 typedef struct {
   char *server_name;
   char *server_ip;
   char *location;
-  unsigned short port;
+  uint16 port;
 } SilcServerConfigSectionServerInfo;
 
 /* Holds server's administrative information from config file */
@@ -50,9 +56,9 @@ typedef struct {
 
 /* Holds all the ports the server is listenning on */
 typedef struct SilcServerConfigSectionListenPortStruct {
-  char *host;
-  char *remote_ip;
-  unsigned short port;
+  char *local_ip;
+  char *listener_ip;
+  uint16 port;
   struct SilcServerConfigSectionListenPortStruct *next;
   struct SilcServerConfigSectionListenPortStruct *prev;
 } SilcServerConfigSectionListenPort;
@@ -60,15 +66,15 @@ typedef struct SilcServerConfigSectionListenPortStruct {
 /* Holds server's execution identity, or the user and group which
    to change from root when server starts */
 typedef struct {
- char *user;
- char *group;
 char *user;
 char *group;
 } SilcServerConfigSectionIdentity;
 
 /* Holds all the configured log files. */
 typedef struct SilcServerConfigSectionLoggingStruct {
   char *logtype;
   char *filename;
-  unsigned int maxsize;
+  uint32 maxsize;
   struct SilcServerConfigSectionLoggingStruct *next;
   struct SilcServerConfigSectionLoggingStruct *prev;
 
@@ -76,15 +82,15 @@ typedef struct SilcServerConfigSectionLoggingStruct {
 #define SILC_CONFIG_SERVER_LF_INFO "infologfile"
 #define SILC_CONFIG_SERVER_LF_WARNING "warninglogfile"
 #define SILC_CONFIG_SERVER_LF_ERROR "errorlogfile"
-#define SILC_CONFIG_SERVER_LF_FATAL "fatalogfile"
+#define SILC_CONFIG_SERVER_LF_FATAL "fatallogfile"
 } SilcServerConfigSectionLogging;
 
 /* Holds all configured connection classes */
 typedef struct SilcServerConfigSectionConnectionClassStruct {
-  unsigned int class;
-  unsigned int ping_freq;
-  unsigned int connect_freq;
-  unsigned int max_links;
+  uint32 class;
+  uint32 ping_freq;
+  uint32 connect_freq;
+  uint32 max_links;
   struct SilcServerConfigSectionConnectionClassStruct *next;
   struct SilcServerConfigSectionConnectionClassStruct *prev;
 } SilcServerConfigSectionConnectionClass;
@@ -97,9 +103,9 @@ typedef struct SilcServerConfigSectionClientConnectionStruct {
   char *host;
   SilcAuthMethod auth_meth;
   void *auth_data;
-  unsigned int auth_data_len;
-  unsigned short port;
-  unsigned int class;
+  uint32 auth_data_len;
+  uint16 port;
+  uint32 class;
   struct SilcServerConfigSectionClientConnectionStruct *next;
   struct SilcServerConfigSectionClientConnectionStruct *prev;
 } SilcServerConfigSectionClientConnection;
@@ -111,7 +117,7 @@ typedef struct SilcServerConfigSectionAdminConnectionStruct {
   char *nickname;
   SilcAuthMethod auth_meth;
   void *auth_data;
-  unsigned int auth_data_len;
+  uint32 auth_data_len;
   struct SilcServerConfigSectionAdminConnectionStruct *next;
   struct SilcServerConfigSectionAdminConnectionStruct *prev;
 } SilcServerConfigSectionAdminConnection;
@@ -121,29 +127,26 @@ typedef struct SilcServerConfigSectionServerConnectionStruct {
   char *host;
   SilcAuthMethod auth_meth;
   void *auth_data;
-  unsigned int auth_data_len;
-  unsigned short port;
+  uint32 auth_data_len;
+  uint16 port;
   char *version;
-  unsigned int class;
-  int initiator;
+  uint32 class;
+  bool initiator;
+  bool backup_router;
+  bool backup_local;
   struct SilcServerConfigSectionServerConnectionStruct *next;
   struct SilcServerConfigSectionServerConnectionStruct *prev;
 } SilcServerConfigSectionServerConnection;
 
 /* Holds all configured denied connections from config file */
-typedef struct {
+typedef struct SilcServerConfigSectionDenyConnectionStruct {
   char *host;
-  char *time;
   char *comment;
-  unsigned short port;
+  uint16 port;
+  struct SilcServerConfigSectionDenyConnectionStruct *next;
+  struct SilcServerConfigSectionDenyConnectionStruct *prev;
 } SilcServerConfigSectionDenyConnection;
 
-/* Holds all client redirections from config file */
-typedef struct {
-  char *host;
-  unsigned short port;
-} SilcServerConfigSectionRedirectClient;
-
 /* Holds motd file */
 typedef struct {
   char *motd_file;
@@ -168,6 +171,7 @@ typedef struct {
   SilcServerConfigSectionAlg *pkcs;
   SilcServerConfigSectionAlg *hash_func;
   SilcServerConfigSectionAlg *hmac;
+  SilcServerConfigSectionServerKeys *server_keys;
   SilcServerConfigSectionServerInfo *server_info;
   SilcServerConfigSectionAdminInfo *admin_info;
   SilcServerConfigSectionListenPort *listen_port;
@@ -179,7 +183,6 @@ typedef struct {
   SilcServerConfigSectionServerConnection *routers;
   SilcServerConfigSectionAdminConnection *admins;
   SilcServerConfigSectionDenyConnection *denied;
-  SilcServerConfigSectionRedirectClient *redirect;
   SilcServerConfigSectionMotd *motd;
 } SilcServerConfigObject;
 
@@ -192,6 +195,7 @@ typedef enum {
   SILC_CONFIG_SERVER_SECTION_TYPE_PKCS,
   SILC_CONFIG_SERVER_SECTION_TYPE_HASH_FUNCTION,
   SILC_CONFIG_SERVER_SECTION_TYPE_HMAC,
+  SILC_CONFIG_SERVER_SECTION_TYPE_SERVER_KEYS,
   SILC_CONFIG_SERVER_SECTION_TYPE_SERVER_INFO,
   SILC_CONFIG_SERVER_SECTION_TYPE_ADMIN_INFO,
   SILC_CONFIG_SERVER_SECTION_TYPE_LISTEN_PORT,
@@ -203,7 +207,6 @@ typedef enum {
   SILC_CONFIG_SERVER_SECTION_TYPE_ROUTER_CONNECTION,
   SILC_CONFIG_SERVER_SECTION_TYPE_ADMIN_CONNECTION,
   SILC_CONFIG_SERVER_SECTION_TYPE_DENY_CONNECTION,
-  SILC_CONFIG_SERVER_SECTION_TYPE_REDIRECT_CLIENT,
   SILC_CONFIG_SERVER_SECTION_TYPE_MOTD,
 } SilcServerConfigSectionType;
 
@@ -211,7 +214,7 @@ typedef enum {
 typedef struct {
   const char *section;
   SilcServerConfigSectionType type;
-  unsigned int maxfields;
+  int maxfields;
 } SilcServerConfigSection;
 
 /* LIst of all possible config sections in SILC server. */
@@ -221,7 +224,7 @@ extern SilcServerConfigSection silc_server_config_sections[];
    from a file to this structure before parsing it further. */
 typedef struct SilcServerConfigParseStruct {
   SilcBuffer line;
-  unsigned int linenum;
+  int linenum;
   SilcServerConfigSection *section;
   struct SilcServerConfigParseStruct *next;
   struct SilcServerConfigParseStruct *prev;
@@ -254,12 +257,12 @@ int silc_server_config_parse(SilcServerConfig config, SilcBuffer buffer,
                             SilcServerConfigParse *return_config);
 int silc_server_config_parse_lines(SilcServerConfig config, 
                                   SilcServerConfigParse parse_config);
-int silc_server_config_check_sections(unsigned int checkmask);
+int silc_server_config_check_sections(uint32 checkmask);
 void silc_server_config_setlogfiles(SilcServerConfig config);
-void silc_server_config_register_ciphers(SilcServerConfig config);
-void silc_server_config_register_pkcs(SilcServerConfig config);
-void silc_server_config_register_hashfuncs(SilcServerConfig config);
-void silc_server_config_register_hmacs(SilcServerConfig config);
+bool silc_server_config_register_ciphers(SilcServerConfig config);
+bool silc_server_config_register_pkcs(SilcServerConfig config);
+bool silc_server_config_register_hashfuncs(SilcServerConfig config);
+bool silc_server_config_register_hmacs(SilcServerConfig config);
 SilcServerConfigSectionClientConnection *
 silc_server_config_find_client_conn(SilcServerConfig config, 
                                    char *host, int port);
@@ -269,9 +272,14 @@ silc_server_config_find_server_conn(SilcServerConfig config,
 SilcServerConfigSectionServerConnection *
 silc_server_config_find_router_conn(SilcServerConfig config, 
                                    char *host, int port);
+bool silc_server_config_is_primary_route(SilcServerConfig config);
+SilcServerConfigSectionServerConnection *
+silc_server_config_get_primary_router(SilcServerConfig config);
 SilcServerConfigSectionAdminConnection *
 silc_server_config_find_admin(SilcServerConfig config,
                              char *host, char *username, char *nickname);
-void silc_server_config_print();
+SilcServerConfigSectionDenyConnection *
+silc_server_config_denied_conn(SilcServerConfig config, char *host,
+                              int port);
 
 #endif