updates.
[silc.git] / apps / silcd / server.h
index 9e626f5e3949bcdd4bf046bd8455a300e750b53b..c965967645ebe31eaf2564a713ed710ce3203a77 100644 (file)
@@ -2,15 +2,15 @@
 
   server.h
 
-  Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
+  Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 1997 - 2001 Pekka Riikonen
+  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
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
-  
+
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 #ifndef SERVER_H
 #define SERVER_H
 
-/* Forward declaration for SILC Server object. The actual object is
-   defined in internal header file for server routines. I want to keep
-   the object private hence this declaration. */
-typedef struct SilcServerStruct *SilcServer;
-
 /* Forward declaration of backup server context */
 typedef struct SilcServerBackupStruct *SilcServerBackup;
 
@@ -48,13 +43,12 @@ typedef struct {
   int backup_replace_port;
   bool no_reconnect;
 
-  /* Connection configuration (maybe NULL), and connection params */
-  void *conn;
-  void *param;
+  /* Connection configuration (maybe NULL) */
+  SilcServerConfigRef conn;
 
   /* Current connection retry info */
-  uint32 retry_count;
-  uint32 retry_timeout;
+  SilcUInt32 retry_count;
+  SilcUInt32 retry_timeout;
 
   /* Back pointer to server */
   SilcServer server;
@@ -91,6 +85,7 @@ typedef struct {
 #define SILC_SERVER_CONNAUTH_TIMEOUT   60       /* CONN_AUTH timeout */
 #define SILC_SERVER_MAX_CONNECTIONS    1000     /* Max connections */
 #define SILC_SERVER_MAX_CONNECTIONS_SINGLE 1000  /* Max connections per host */
+#define SILC_SERVER_LOG_FLUSH_DELAY    300       /* Default log flush delay */
 
 /* Macros */
 
@@ -110,12 +105,15 @@ do {                                                              \
   (sock->protocol && sock->protocol->protocol &&                       \
    sock->protocol->protocol->type == SILC_PROTOCOL_SERVER_REKEY)
 
+/* Output an error message wether to stderr or LOG_ERROR if we are in the
+   background. */
+#define SILC_SERVER_LOG_ERROR(fmt) silc_server_stderr(silc_format fmt)
+
 /* Prototypes */
 int silc_server_alloc(SilcServer *new_server);
 void silc_server_free(SilcServer server);
-int silc_server_init(SilcServer server);
-void silc_server_daemonise(SilcServer server);
-void silc_server_drop(SilcServer server);
+bool silc_server_init(SilcServer server);
+bool silc_server_rehash(SilcServer server);
 void silc_server_run(SilcServer server);
 void silc_server_stop(SilcServer server);
 void silc_server_start_key_exchange(SilcServer server,
@@ -123,51 +121,51 @@ void silc_server_start_key_exchange(SilcServer server,
                                    int sock);
 bool silc_server_packet_parse(SilcPacketParserContext *parser_context,
                              void *context);
-void silc_server_packet_parse_type(SilcServer server, 
+void silc_server_packet_parse_type(SilcServer server,
                                   SilcSocketConnection sock,
                                   SilcPacketContext *packet);
 void silc_server_create_connection(SilcServer server,
-                                  const char *remote_host, uint32 port);
+                                  const char *remote_host, SilcUInt32 port);
 void silc_server_close_connection(SilcServer server,
                                  SilcSocketConnection sock);
-void silc_server_free_client_data(SilcServer server, 
+void silc_server_free_client_data(SilcServer server,
                                  SilcSocketConnection sock,
-                                 SilcClientEntry client, 
+                                 SilcClientEntry client,
                                  int notify,
                                  const char *signoff);
-void silc_server_free_sock_user_data(SilcServer server, 
+void silc_server_free_sock_user_data(SilcServer server,
                                     SilcSocketConnection sock,
                                     const char *signoff_message);
-void silc_server_remove_from_channels(SilcServer server, 
+void silc_server_remove_from_channels(SilcServer server,
                                      SilcSocketConnection sock,
                                      SilcClientEntry client,
                                      int notify,
                                      char *signoff_message,
                                      int keygen);
-int silc_server_remove_from_one_channel(SilcServer server, 
+int silc_server_remove_from_one_channel(SilcServer server,
                                        SilcSocketConnection sock,
                                        SilcChannelEntry channel,
                                        SilcClientEntry client,
                                        int notify);
 void silc_server_disconnect_remote(SilcServer server,
                                   SilcSocketConnection sock,
-                                  const char *fmt, ...);
-SilcChannelEntry silc_server_create_new_channel(SilcServer server, 
+                                  SilcStatus status, ...);
+SilcChannelEntry silc_server_create_new_channel(SilcServer server,
                                                SilcServerID *router_id,
-                                               char *cipher, 
+                                               char *cipher,
                                                char *hmac,
                                                char *channel_name,
                                                int broadcast);
-SilcChannelEntry 
-silc_server_create_new_channel_with_id(SilcServer server, 
-                                      char *cipher, 
+SilcChannelEntry
+silc_server_create_new_channel_with_id(SilcServer server,
+                                      char *cipher,
                                       char *hmac,
                                       char *channel_name,
                                       SilcChannelID *channel_id,
                                       int broadcast);
-bool silc_server_create_channel_key(SilcServer server, 
+bool silc_server_create_channel_key(SilcServer server,
                                    SilcChannelEntry channel,
-                                   uint32 key_len);
+                                   SilcUInt32 key_len);
 SilcChannelEntry silc_server_save_channel_key(SilcServer server,
                                              SilcBuffer key_payload,
                                              SilcChannelEntry channel);
@@ -185,7 +183,7 @@ void silc_server_announce_get_channels(SilcServer server,
                                       SilcBuffer *channels,
                                       SilcBuffer *channel_users,
                                       SilcBuffer **channel_users_modes,
-                                      uint32 *channel_users_modes_c,
+                                      SilcUInt32 *channel_users_modes_c,
                                       SilcBuffer **channel_topics,
                                       SilcChannelID ***channel_ids,
                                       unsigned long creation_time);
@@ -202,23 +200,35 @@ void silc_server_get_users_on_channel(SilcServer server,
                                      SilcChannelEntry channel,
                                      SilcBuffer *user_list,
                                      SilcBuffer *mode_list,
-                                     uint32 *user_count);
+                                     SilcUInt32 *user_count);
 void silc_server_save_users_on_channel(SilcServer server,
                                       SilcSocketConnection sock,
                                       SilcChannelEntry channel,
                                       SilcClientID *noadd,
                                       SilcBuffer user_list,
                                       SilcBuffer mode_list,
-                                      uint32 user_count);
-SilcSocketConnection silc_server_get_client_route(SilcServer server,
-                                                 unsigned char *id_data,
-                                                 uint32 id_len,
-                                                 SilcClientID *client_id,
-                                                 SilcIDListData *idata);
+                                      SilcUInt32 user_count);
+void silc_server_save_user_channels(SilcServer server,
+                                   SilcSocketConnection sock,
+                                   SilcClientEntry client,
+                                   SilcBuffer channels,
+                                   SilcBuffer channels_user_modes);
+SilcSocketConnection
+silc_server_get_client_route(SilcServer server,
+                            unsigned char *id_data,
+                            SilcUInt32 id_len,
+                            SilcClientID *client_id,
+                            SilcIDListData *idata,
+                            SilcClientEntry *client_entry);
 SilcBuffer silc_server_get_client_channel_list(SilcServer server,
-                                              SilcClientEntry client);
+                                              SilcClientEntry client,
+                                              bool get_private,
+                                              bool get_secret,
+                                              SilcBuffer *user_mode_list);
 SilcClientEntry silc_server_get_client_resolve(SilcServer server,
                                               SilcClientID *client_id,
+                                              bool always_resolve,
                                               bool *resolved);
+void silc_server_stderr(char *message);
 
 #endif