5 Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
7 Copyright (C) 1997 - 2001 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
24 /* Forward declaration for SILC Server object. The actual object is
25 defined in internal header file for server routines. I want to keep
26 the object private hence this declaration. */
27 typedef struct SilcServerStruct *SilcServer;
29 #define SILC_SERVER_MAX_CONNECTIONS 10000
31 /* General definitions */
33 /* Server and router. Used internally by the code. */
37 /* Connection retry timeout. We implement exponential backoff algorithm
38 in connection retry. The interval of timeuot grows when retry count
40 #define SILC_SERVER_RETRY_COUNT 4 /* Max retry count */
41 #define SILC_SERVER_RETRY_MULTIPLIER 7 / 4 /* Interval growth */
42 #define SILC_SERVER_RETRY_RANDOMIZER 2 /* timeout += rnd % 2 */
43 #define SILC_SERVER_RETRY_INTERVAL_MIN 10 /* Min retry timeout */
44 #define SILC_SERVER_RETRY_INTERVAL_MAX 600 /* Max generated timeout */
49 Structure to hold various default parameters for server that can be
50 given before running the server.
54 unsigned int retry_count;
55 unsigned long retry_interval_min;
56 unsigned long retry_interval_min_usec;
57 unsigned long retry_interval_max;
58 char retry_keep_trying;
60 unsigned long protocol_timeout;
61 unsigned long protocol_timeout_usec;
63 char require_reverse_mapping;
68 /* This macro is used to send notify messages with formatted string. The
69 string is formatted with arguments and the formatted string is sent as
71 #define SILC_SERVER_SEND_NOTIFY(server, sock, type, fmt) \
73 char *__fmt__ = silc_format fmt; \
74 silc_server_send_notify(server, sock, type, 1, __fmt__, strlen(__fmt__)); \
79 int silc_server_alloc(SilcServer *new_server);
80 void silc_server_free(SilcServer server);
81 int silc_server_init(SilcServer server);
82 void silc_server_daemonise(SilcServer server);
83 void silc_server_run(SilcServer server);
84 void silc_server_stop(SilcServer server);
85 void silc_server_packet_parse(SilcPacketParserContext *parser_context);
86 void silc_server_packet_parse_type(SilcServer server,
87 SilcSocketConnection sock,
88 SilcPacketContext *packet);
89 void silc_server_close_connection(SilcServer server,
90 SilcSocketConnection sock);
91 void silc_server_free_sock_user_data(SilcServer server,
92 SilcSocketConnection sock);
93 int silc_server_channel_has_global(SilcChannelEntry channel);
94 int silc_server_channel_has_local(SilcChannelEntry channel);
95 int silc_server_remove_clients_by_server(SilcServer server,
96 SilcServerEntry entry);
97 void silc_server_remove_from_channels(SilcServer server,
98 SilcSocketConnection sock,
99 SilcClientEntry client);
100 int silc_server_remove_from_one_channel(SilcServer server,
101 SilcSocketConnection sock,
102 SilcChannelEntry channel,
103 SilcClientEntry client,
105 int silc_server_client_on_channel(SilcClientEntry client,
106 SilcChannelEntry channel);
107 void silc_server_disconnect_remote(SilcServer server,
108 SilcSocketConnection sock,
109 const char *fmt, ...);
110 SilcChannelEntry silc_server_create_new_channel(SilcServer server,
111 SilcServerID *router_id,
114 void silc_server_create_channel_key(SilcServer server,
115 SilcChannelEntry channel,
116 unsigned int key_len);
117 SilcChannelEntry silc_server_save_channel_key(SilcServer server,
118 SilcBuffer key_payload,
119 SilcChannelEntry channel);