5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 1997 - 2003 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 bool silc_server_remove_clients_by_server(SilcServer server,
28 SilcServerEntry router,
29 SilcServerEntry entry,
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
38 void silc_server_update_clients_by_server(SilcServer server,
41 bool resolve_real_server);
43 /* Updates servers that are from `from' to be originated from `to'. This
44 will also update the server's connection to `to's connection. */
45 void silc_server_update_servers_by_server(SilcServer server,
49 /* Toggles the enabled/disabled status of local server connections. Packets
50 can be sent to the servers when `toggle_enabled' is TRUE and will be
51 dropped if `toggle_enabled' is FALSE, after this function is called. */
52 void silc_server_local_servers_toggle_enabled(SilcServer server,
55 /* Removes servers that are originated from the `from'. The server
56 entry is deleted in this function. If `remove_clients' is TRUE then
57 all clients originated from the server are removed too, and server
58 signoff is sent. Note that this does not remove the `from'. This
59 also does not remove locally connected servers. */
60 void silc_server_remove_servers_by_server(SilcServer server,
64 /* Removes channels that are from `from. */
65 void silc_server_remove_channels_by_server(SilcServer server,
66 SilcServerEntry from);
68 /* Updates channels that are from `from' to be originated from `to'. */
69 void silc_server_update_channels_by_server(SilcServer server,
73 /* Checks whether given channel has global users. If it does this returns
74 TRUE and FALSE if there is only locally connected clients on the channel. */
75 bool silc_server_channel_has_global(SilcChannelEntry channel);
77 /* Checks whether given channel has locally connected users. If it does this
78 returns TRUE and FALSE if there is not one locally connected client. */
79 bool silc_server_channel_has_local(SilcChannelEntry channel);
81 /* This function removes the channel and all users on the channel, unless
82 the channel is permanent. In this case the channel is disabled but all
83 users are removed from the channel. Returns TRUE if the channel is
84 destroyed totally, and FALSE if it is permanent and remains. */
85 bool silc_server_channel_delete(SilcServer server,
86 SilcChannelEntry channel);
88 /* Returns TRUE if the given client is on the channel. FALSE if not.
89 This works because we assure that the user list on the channel is
90 always in up to date thus we can only check the channel list from
91 `client' which is faster than checking the user list from `channel'. */
92 bool silc_server_client_on_channel(SilcClientEntry client,
93 SilcChannelEntry channel,
94 SilcChannelClientEntry *chl);
96 /* Checks string for bad characters and returns TRUE if they are found. */
97 bool silc_server_name_bad_chars(const char *name, SilcUInt32 name_len);
98 bool silc_server_name_bad_chchars(const char *name, SilcUInt32 name_len);
100 /* Modifies the `nick' if it includes bad characters and returns new
101 allocated nickname that does not include bad characters. */
102 char *silc_server_name_modify_bad(const char *name, SilcUInt32 name_len);
104 /* Find number of sockets by IP address indicated by `ip'. Returns 0 if
105 socket connections with the IP address does not exist. */
106 SilcUInt32 silc_server_num_sockets_by_ip(SilcServer server, const char *ip,
107 SilcSocketType type);
109 /* Find number of sockets by IP address indicated by remote host, indicated
110 by `ip' or `hostname', `port', and `type'. Returns 0 if socket connections
111 does not exist. If `ip' is provided then `hostname' is ignored. */
112 SilcUInt32 silc_server_num_sockets_by_remote(SilcServer server,
114 const char *hostname,
116 SilcSocketType type);
118 /* Finds locally cached public key by the public key received in the SKE.
119 If we have it locally cached then we trust it and will use it in the
120 authentication protocol. Returns the locally cached public key or NULL
121 if we do not find the public key. */
122 SilcPublicKey silc_server_find_public_key(SilcServer server,
123 SilcHashTable local_public_keys,
124 SilcPublicKey remote_public_key);
126 /* This returns the first public key from the table of public keys. This
127 is used only in cases where single public key exists in the table and
128 we want to get a pointer to it. For public key tables that has multiple
129 keys in it the silc_server_find_public_key must be used. */
130 SilcPublicKey silc_server_get_public_key(SilcServer server,
131 SilcHashTable local_public_keys);
133 /* Check whether the connection `sock' is allowed to connect to us. This
134 checks for example whether there is too much connections for this host,
135 and required version for the host etc. */
136 bool silc_server_connection_allowed(SilcServer server,
137 SilcSocketConnection sock,
139 SilcServerConfigConnParams *global,
140 SilcServerConfigConnParams *params,
143 /* Checks that client has rights to add or remove channel modes. If any
144 of the checks fails FALSE is returned. */
145 bool silc_server_check_cmode_rights(SilcServer server,
146 SilcChannelEntry channel,
147 SilcChannelClientEntry client,
150 /* Check that the client has rights to change its user mode. Returns
151 FALSE if setting some mode is not allowed. */
152 bool silc_server_check_umode_rights(SilcServer server,
153 SilcClientEntry client,
156 /* This function is used to send the notify packets and motd to the
157 incoming client connection. */
158 void silc_server_send_connect_notifys(SilcServer server,
159 SilcSocketConnection sock,
160 SilcClientEntry client);
162 /* Kill the client indicated by `remote_client' sending KILLED notify
163 to the client, to all channels client has joined and to primary
164 router if needed. The killed client is also removed from all channels. */
165 void silc_server_kill_client(SilcServer server,
166 SilcClientEntry remote_client,
169 SilcIdType killer_id_type);
171 /* This function checks whether the `client' nickname is being watched
172 by someone, and notifies the watcher of the notify change of notify
173 type indicated by `notify'. */
174 bool silc_server_check_watcher_list(SilcServer server,
175 SilcClientEntry client,
176 const char *new_nick,
177 SilcNotifyType notify);
179 /* Remove the `client' from watcher list. After calling this the `client'
180 is not watching any nicknames. */
181 bool silc_server_del_from_watcher_list(SilcServer server,
182 SilcClientEntry client);
184 /* Force the client indicated by `chl' to change the channel user mode
185 on channel indicated by `channel' to `forced_mode'. */
186 bool silc_server_force_cumode_change(SilcServer server,
187 SilcSocketConnection sock,
188 SilcChannelEntry channel,
189 SilcChannelClientEntry chl,
190 SilcUInt32 forced_mode);
192 /* Find active socket connection by the IP address and port indicated by
193 `ip' and `port', and socket connection type of `type'. */
195 silc_server_find_socket_by_host(SilcServer server,
197 const char *ip, SilcUInt16 port);
199 /* This function can be used to match the invite and ban lists. */
200 bool silc_server_inviteban_match(SilcServer server, SilcHashTable list,
201 SilcUInt8 type, void *check);
203 /* Process invite or ban information */
204 void silc_server_inviteban_process(SilcServer server, SilcHashTable list,
205 SilcUInt8 action, SilcArgumentPayload args);
207 /* Destructor for invite or ban list entrys */
208 void silc_server_inviteban_destruct(void *key, void *context,
211 /* Creates connections according to configuration. */
212 void silc_server_create_connections(SilcServer server);
215 /* Processes a channel public key, either adds or removes it. */
217 silc_server_process_channel_pk(SilcServer server,
218 SilcChannelEntry channel,
219 SilcUInt32 type, const unsigned char *pk,
222 /* Returns the channel public keys as Argument List payload. */
223 SilcBuffer silc_server_get_channel_pk_list(SilcServer server,
224 SilcChannelEntry channel,
228 /* Sets the channel public keys into channel from the list of public keys. */
229 SilcStatus silc_server_set_channel_pk_list(SilcServer server,
230 SilcSocketConnection sender,
231 SilcChannelEntry channel,
232 const unsigned char *pklist,
233 SilcUInt32 pklist_len);
235 /* Verifies the Authentication Payload `auth' with one of the public keys
236 on the `channel' public key list. */
237 bool silc_server_verify_channel_auth(SilcServer server,
238 SilcChannelEntry channel,
239 SilcClientID *client_id,
240 const unsigned char *auth,
241 SilcUInt32 auth_len);
243 #endif /* SERVER_UTIL_H */