5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 1997 - 2009 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; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
23 /* This function removes all client entries that are originated from
24 `router' and are owned by `entry'. `router' and `entry' can be same
25 too. If `server_signoff' is TRUE then SERVER_SIGNOFF notify is
26 distributed to our local clients. */
27 SilcBool silc_server_remove_clients_by_server(SilcServer server,
28 SilcServerEntry router,
29 SilcServerEntry entry,
30 SilcBool server_signoff);
32 /* Updates the clients that are originated from the `from' to be originated
33 from the `to'. If the `resolve_real_server' is TRUE then this will
34 attempt to figure out which clients really are originated from the
35 `from' and which are originated from a server that we have connection
36 to, when we've acting as backup router. If it is FALSE the `to' will
37 be the new source. If `from' is NULL then all clients (except locally
38 connected) are updated `to'. */
39 void silc_server_update_clients_by_server(SilcServer server,
42 SilcBool resolve_real_server);
44 /* Updates servers that are from `from' to be originated from `to'. This
45 will also update the server's connection to `to's connection. */
46 void silc_server_update_servers_by_server(SilcServer server,
50 /* Toggles the enabled/disabled status of local server connections. Packets
51 can be sent to the servers when `toggle_enabled' is TRUE and will be
52 dropped if `toggle_enabled' is FALSE, after this function is called. */
53 void silc_server_local_servers_toggle_enabled(SilcServer server,
54 SilcBool toggle_enabled);
56 /* Removes servers that are originated from the `from'. The server
57 entry is deleted in this function. If `remove_clients' is TRUE then
58 all clients originated from the server are removed too, and server
59 signoff is sent. Note that this does not remove the `from'. This
60 also does not remove locally connected servers. */
61 void silc_server_remove_servers_by_server(SilcServer server,
63 SilcBool remove_clients);
65 /* Removes channels that are from `from. */
66 void silc_server_remove_channels_by_server(SilcServer server,
67 SilcServerEntry from);
69 /* Updates channels that are from `from' to be originated from `to'. */
70 void silc_server_update_channels_by_server(SilcServer server,
74 /* Checks whether given channel has global users. If it does this returns
75 TRUE and FALSE if there is only locally connected clients on the channel. */
76 SilcBool silc_server_channel_has_global(SilcChannelEntry channel);
78 /* Checks whether given channel has locally connected users. If it does this
79 returns TRUE and FALSE if there is not one locally connected client. */
80 SilcBool silc_server_channel_has_local(SilcChannelEntry channel);
82 /* This function removes the channel and all users on the channel, unless
83 the channel is permanent. In this case the channel is disabled but all
84 users are removed from the channel. Returns TRUE if the channel is
85 destroyed totally, and FALSE if it is permanent and remains. */
86 SilcBool silc_server_channel_delete(SilcServer server,
87 SilcChannelEntry channel);
89 /* Returns TRUE if the given client is on the channel. FALSE if not.
90 This works because we assure that the user list on the channel is
91 always in up to date thus we can only check the channel list from
92 `client' which is faster than checking the user list from `channel'. */
93 SilcBool silc_server_client_on_channel(SilcClientEntry client,
94 SilcChannelEntry channel,
95 SilcChannelClientEntry *chl);
97 /* Find number of sockets by IP address indicated by `ip'. Returns 0 if
98 socket connections with the IP address does not exist. */
99 SilcUInt32 silc_server_num_sockets_by_ip(SilcServer server, const char *ip,
100 SilcConnectionType type);
102 /* Find number of sockets by IP address indicated by remote host, indicated
103 by `ip' or `hostname', `port', and `type'. Returns 0 if socket connections
104 does not exist. If `ip' is provided then `hostname' is ignored. */
105 SilcUInt32 silc_server_num_sockets_by_remote(SilcServer server,
107 const char *hostname,
109 SilcConnectionType type);
111 /* Get public key by key usage and key context. */
112 SilcPublicKey silc_server_get_public_key(SilcServer server,
113 SilcSKRKeyUsage usage,
116 /* Find public key by client for identification purposes. Finds keys
117 with SILC_SKR_USAGE_IDENTIFICATION. */
118 SilcBool silc_server_get_public_key_by_client(SilcServer server,
119 SilcClientEntry client,
120 SilcPublicKey *public_key);
122 /* Check whether the connection `sock' is allowed to connect to us. This
123 checks for example whether there is too much connections for this host,
124 and required version for the host etc. */
125 SilcBool silc_server_connection_allowed(SilcServer server,
126 SilcPacketStream sock,
127 SilcConnectionType type,
128 SilcServerConfigConnParams *global,
129 SilcServerConfigConnParams *params,
132 /* Checks that client has rights to add or remove channel modes. If any
133 of the checks fails FALSE is returned. */
134 SilcBool silc_server_check_cmode_rights(SilcServer server,
135 SilcChannelEntry channel,
136 SilcChannelClientEntry client,
139 /* Check that the client has rights to change its user mode. Returns
140 FALSE if setting some mode is not allowed. */
141 SilcBool silc_server_check_umode_rights(SilcServer server,
142 SilcClientEntry client,
145 /* Send the heartbeat packet. */
146 void silc_server_send_heartbeat(SilcServer server,
147 SilcPacketStream sock);
149 /* This function is used to send the notify packets and motd to the
150 incoming client connection. */
151 void silc_server_send_connect_notifys(SilcServer server,
152 SilcPacketStream sock,
153 SilcClientEntry client);
155 /* Kill the client indicated by `remote_client' sending KILLED notify
156 to the client, to all channels client has joined and to primary
157 router if needed. The killed client is also removed from all channels. */
158 void silc_server_kill_client(SilcServer server,
159 SilcClientEntry remote_client,
162 SilcIdType killer_id_type);
164 /* This function checks whether the `client' nickname is being watched
165 by someone, and notifies the watcher of the notify change of notify
166 type indicated by `notify'. */
167 SilcBool silc_server_check_watcher_list(SilcServer server,
168 SilcClientEntry client,
169 const char *new_nick,
170 SilcNotifyType notify);
172 /* Remove the `client' from watcher list. After calling this the `client'
173 is not watching any nicknames. */
174 SilcBool silc_server_del_from_watcher_list(SilcServer server,
175 SilcClientEntry client);
177 /* Force the client indicated by `chl' to change the channel user mode
178 on channel indicated by `channel' to `forced_mode'. */
179 SilcBool silc_server_force_cumode_change(SilcServer server,
180 SilcPacketStream sock,
181 SilcChannelEntry channel,
182 SilcChannelClientEntry chl,
183 SilcUInt32 forced_mode);
185 /* Find active socket connection by the IP address and port indicated by
186 `ip' and `port', and socket connection type of `type'. */
188 silc_server_find_socket_by_host(SilcServer server,
189 SilcConnectionType type,
190 const char *ip, SilcUInt16 port);
192 /* This function can be used to match the invite and ban lists. */
193 SilcBool silc_server_inviteban_match(SilcServer server, SilcHashTable list,
194 SilcUInt8 type, void *check);
196 /* Process invite or ban information */
197 SilcBool silc_server_inviteban_process(SilcServer server, SilcHashTable list,
198 SilcUInt8 action, SilcArgumentPayload args);
200 /* Destructor for invite or ban list entrys */
201 void silc_server_inviteban_destruct(void *key, void *context,
204 /* Creates connections according to configuration. */
205 void silc_server_create_connections(SilcServer server);
208 /* Processes a channel public key, either adds or removes it. */
210 silc_server_process_channel_pk(SilcServer server,
211 SilcChannelEntry channel,
212 SilcUInt32 type, const unsigned char *pk,
215 /* Returns the channel public keys as Argument List payload. */
216 SilcBuffer silc_server_get_channel_pk_list(SilcServer server,
217 SilcChannelEntry channel,
221 /* Sets the channel public keys into channel from the list of public keys. */
222 SilcStatus silc_server_set_channel_pk_list(SilcServer server,
223 SilcPacketStream sender,
224 SilcChannelEntry channel,
225 const unsigned char *pklist,
226 SilcUInt32 pklist_len);
228 /* Verifies the Authentication Payload `auth' with one of the public keys
229 on the `channel' public key list. */
230 SilcBool silc_server_verify_channel_auth(SilcServer server,
231 SilcChannelEntry channel,
232 SilcClientID *client_id,
233 const unsigned char *auth,
234 SilcUInt32 auth_len);
236 #endif /* SERVER_UTIL_H */