X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=apps%2Fsilcd%2Fserver.h;h=8cdf3b0352f35603cc4f4520f8a4d7f5b80628d4;hb=413da0f8686910f5e627393157566ae729ca99c4;hp=5ce8bbe582029cc3cec46e72b940c9d1a8bad121;hpb=3d0125f89ea94b53825ff5d1b9e4329619a5f0fc;p=silc.git diff --git a/apps/silcd/server.h b/apps/silcd/server.h index 5ce8bbe5..8cdf3b03 100644 --- a/apps/silcd/server.h +++ b/apps/silcd/server.h @@ -2,9 +2,9 @@ server.h - Author: Pekka Riikonen + Author: Pekka Riikonen - 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 @@ -26,7 +26,7 @@ typedef struct SilcServerBackupStruct *SilcServerBackup; /* Callback function that is called after the key exchange and connection authentication protocols has been completed with a remote router. The - `server_entry' is the remote router entry. */ + `server_entry' is the remote router entry or NULL on error. */ typedef void (*SilcServerConnectRouterCallback)(SilcServer server, SilcServerEntry server_entry, void *context); @@ -50,9 +50,6 @@ typedef struct { SilcUInt32 retry_count; SilcUInt32 retry_timeout; - /* Back pointer to server */ - SilcServer server; - SilcServerConnectRouterCallback callback; void *callback_context; } *SilcServerConnection; @@ -60,7 +57,7 @@ typedef struct { /* General definitions */ /* SILC port */ -#define SILC_PORT 768; +#define SILC_PORT 706 /* Server and router. Used internally by the code. */ #define SILC_SERVER 0 @@ -85,6 +82,11 @@ 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 */ +#define SILC_SERVER_QOS_RATE_LIMIT 10 /* Default QoS rate limit */ +#define SILC_SERVER_QOS_BYTES_LIMIT 2048 /* Default QoS bytes limit */ +#define SILC_SERVER_QOS_LIMIT_SEC 0 /* Default QoS limit sec */ +#define SILC_SERVER_QOS_LIMIT_USEC 500000 /* Default QoS limit usec */ /* Macros */ @@ -97,29 +99,45 @@ do { \ silc_server_send_notify(server, sock, FALSE, \ type, 1, __fmt__, strlen(__fmt__)); \ silc_free(__fmt__); \ -} while(0); +} while(0) + +/* Send notify to operators */ +#define SILC_SERVER_SEND_OPERS(server, route, local, type, fmt) \ +do { \ + char *__fmt__ = silc_format fmt; \ + silc_server_send_opers_notify(server, route, local, \ + type, 1, __fmt__, strlen(__fmt__)); \ + silc_free(__fmt__); \ +} while(0) /* Check whether rekey protocol is active */ #define SILC_SERVER_IS_REKEY(sock) \ (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) - +/* Check whether backup resuming protocol is active */ +#define SILC_SERVER_IS_BACKUP(sock) \ + (sock->protocol && sock->protocol->protocol && \ + sock->protocol->protocol->type == SILC_PROTOCOL_SERVER_BACKUP) +/* Output a message to stderr or to the appropriate log facility wether + we are in the background or not. */ +#define SILC_SERVER_LOG_INFO(fmt) \ + silc_server_stderr(SILC_LOG_INFO, silc_format fmt) +#define SILC_SERVER_LOG_WARNING(fmt) \ + silc_server_stderr(SILC_LOG_WARNING, silc_format fmt) +#define SILC_SERVER_LOG_ERROR(fmt) \ + silc_server_stderr(SILC_LOG_ERROR, silc_format fmt) +#define SILC_SERVER_LOG_FATAL(fmt) \ + silc_server_stderr(SILC_LOG_WARNING, silc_format fmt) /* Prototypes */ int silc_server_alloc(SilcServer *new_server); void silc_server_free(SilcServer server); bool silc_server_init(SilcServer server); bool silc_server_rehash(SilcServer server); -void silc_server_drop(SilcServer server); -void silc_server_daemonise(SilcServer server); void silc_server_run(SilcServer server); void silc_server_stop(SilcServer server); -void silc_server_stderr(char *message); void silc_server_start_key_exchange(SilcServer server, SilcServerConnection sconn, int sock); @@ -143,17 +161,17 @@ void silc_server_free_sock_user_data(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, - SilcSocketConnection sock, - SilcChannelEntry channel, - SilcClientEntry client, - int notify); + bool notify, + const char *signoff_message, + bool keygen, bool killed); +bool silc_server_remove_from_one_channel(SilcServer server, + SilcSocketConnection sock, + SilcChannelEntry channel, + SilcClientEntry client, + bool notify); void silc_server_disconnect_remote(SilcServer server, SilcSocketConnection sock, - const char *fmt, ...); + SilcStatus status, ...); SilcChannelEntry silc_server_create_new_channel(SilcServer server, SilcServerID *router_id, char *cipher, @@ -180,15 +198,19 @@ void silc_server_announce_get_channel_topic(SilcServer server, SilcBuffer *topic); void silc_server_announce_get_channel_users(SilcServer server, SilcChannelEntry channel, + SilcBuffer *channel_modes, SilcBuffer *channel_users, SilcBuffer *channel_users_modes); void silc_server_announce_get_channels(SilcServer server, SilcIDList id_list, SilcBuffer *channels, + SilcBuffer **channel_modes, SilcBuffer *channel_users, SilcBuffer **channel_users_modes, SilcUInt32 *channel_users_modes_c, SilcBuffer **channel_topics, + SilcBuffer **channel_invites, + SilcBuffer **channel_bans, SilcChannelID ***channel_ids, unsigned long creation_time); void silc_server_announce_servers(SilcServer server, bool global, @@ -200,7 +222,7 @@ void silc_server_announce_clients(SilcServer server, void silc_server_announce_channels(SilcServer server, unsigned long creation_time, SilcSocketConnection remote); -void silc_server_get_users_on_channel(SilcServer server, +bool silc_server_get_users_on_channel(SilcServer server, SilcChannelEntry channel, SilcBuffer *user_list, SilcBuffer *mode_list, @@ -212,15 +234,23 @@ void silc_server_save_users_on_channel(SilcServer server, SilcBuffer user_list, SilcBuffer mode_list, SilcUInt32 user_count); -SilcSocketConnection silc_server_get_client_route(SilcServer server, - unsigned char *id_data, - SilcUInt32 id_len, - SilcClientID *client_id, - SilcIDListData *idata); +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 silc_server_get_client_resolve(SilcServer server, - SilcClientID *client_id, - bool *resolved); + SilcClientEntry client, + bool get_private, + bool get_secret, + SilcBuffer *user_mode_list); +void silc_server_stderr(SilcLogType type, char *message); #endif