5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 1997 - 2002 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 is used to remove all client entries by the server `entry'.
24 This is called when the connection is lost to the server. In this case
25 we must invalidate all the client entries owned by the server `entry'.
26 If the `server_signoff' is TRUE then the SERVER_SIGNOFF notify is
27 distributed to our local clients. */
28 bool silc_server_remove_clients_by_server(SilcServer server,
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
37 be the new source. This function also removes the clients that are
38 *really* originated from `from' if `remove_from' is TRUE. These are
39 clients that the `from' owns, and not just clients that are behind
40 the `from'. If `from' is NULL then all non-local clients are switched
42 void silc_server_update_clients_by_server(SilcServer server,
45 bool resolve_real_server,
48 /* Updates servers that are from `from' to be originated from `to'. This
49 will also update the server's connection to `to's connection. If
50 `local_toggle_enabled' is TRUE then local server's connections are
51 enabled, if FALSE they are disabled. */
52 void silc_server_update_servers_by_server(SilcServer server,
55 bool local_toggle_enabled);
57 /* Removes channels that are from `from. */
58 void silc_server_remove_channels_by_server(SilcServer server,
59 SilcServerEntry from);
61 /* Updates channels that are from `from' to be originated from `to'. */
62 void silc_server_update_channels_by_server(SilcServer server,
66 /* Checks whether given channel has global users. If it does this returns
67 TRUE and FALSE if there is only locally connected clients on the channel. */
68 bool silc_server_channel_has_global(SilcChannelEntry channel);
70 /* Checks whether given channel has locally connected users. If it does this
71 returns TRUE and FALSE if there is not one locally connected client. */
72 bool silc_server_channel_has_local(SilcChannelEntry channel);
74 /* This function removes the channel and all users on the channel, unless
75 the channel is permanent. In this case the channel is disabled but all
76 users are removed from the channel. Returns TRUE if the channel is
77 destroyed totally, and FALSE if it is permanent and remains. */
78 bool silc_server_channel_delete(SilcServer server,
79 SilcChannelEntry channel);
81 /* Returns TRUE if the given client is on the channel. FALSE if not.
82 This works because we assure that the user list on the channel is
83 always in up to date thus we can only check the channel list from
84 `client' which is faster than checking the user list from `channel'. */
85 bool silc_server_client_on_channel(SilcClientEntry client,
86 SilcChannelEntry channel,
87 SilcChannelClientEntry *chl);
89 /* Checks string for bad characters and returns TRUE if they are found. */
90 bool silc_server_name_bad_chars(const char *name, SilcUInt32 name_len);
92 /* Modifies the `nick' if it includes bad characters and returns new
93 allocated nickname that does not include bad characters. */
94 char *silc_server_name_modify_bad(const char *name, SilcUInt32 name_len);
96 /* Find number of sockets by IP address indicated by `ip'. Returns 0 if
97 socket connections with the IP address does not exist. */
98 SilcUInt32 silc_server_num_sockets_by_ip(SilcServer server, const char *ip,
101 /* Find number of sockets by IP address indicated by remote host, indicated
102 by `ip' or `hostname', `port', and `type'. Returns 0 if socket connections
103 does not exist. If `ip' is provided then `hostname' is ignored. */
104 SilcUInt32 silc_server_num_sockets_by_remote(SilcServer server,
106 const char *hostname,
108 SilcSocketType type);
110 /* Finds locally cached public key by the public key received in the SKE.
111 If we have it locally cached then we trust it and will use it in the
112 authentication protocol. Returns the locally cached public key or NULL
113 if we do not find the public key. */
114 SilcPublicKey silc_server_find_public_key(SilcServer server,
115 SilcHashTable local_public_keys,
116 SilcPublicKey remote_public_key);
118 /* This returns the first public key from the table of public keys. This
119 is used only in cases where single public key exists in the table and
120 we want to get a pointer to it. For public key tables that has multiple
121 keys in it the silc_server_find_public_key must be used. */
122 SilcPublicKey silc_server_get_public_key(SilcServer server,
123 SilcHashTable local_public_keys);
125 /* Check whether the connection `sock' is allowed to connect to us. This
126 checks for example whether there is too much connections for this host,
127 and required version for the host etc. */
128 bool silc_server_connection_allowed(SilcServer server,
129 SilcSocketConnection sock,
131 SilcServerConfigConnParams *global,
132 SilcServerConfigConnParams *params,
135 /* Checks that client has rights to add or remove channel modes. If any
136 of the checks fails FALSE is returned. */
137 bool silc_server_check_cmode_rights(SilcServer server,
138 SilcChannelEntry channel,
139 SilcChannelClientEntry client,
142 /* Check that the client has rights to change its user mode. Returns
143 FALSE if setting some mode is not allowed. */
144 bool silc_server_check_umode_rights(SilcServer server,
145 SilcClientEntry client,
148 /* This function is used to send the notify packets and motd to the
149 incoming client connection. */
150 void silc_server_send_connect_notifys(SilcServer server,
151 SilcSocketConnection sock,
152 SilcClientEntry client);
154 /* Kill the client indicated by `remote_client' sending KILLED notify
155 to the client, to all channels client has joined and to primary
156 router if needed. The killed client is also removed from all channels. */
157 void silc_server_kill_client(SilcServer server,
158 SilcClientEntry remote_client,
161 SilcIdType killer_id_type);
163 /* This function checks whether the `client' nickname is being watched
164 by someone, and notifies the watcher of the notify change of notify
165 type indicated by `notify'. */
166 bool silc_server_check_watcher_list(SilcServer server,
167 SilcClientEntry client,
168 const char *new_nick,
169 SilcNotifyType notify);
171 /* Remove the `client' from watcher list. After calling this the `client'
172 is not watching any nicknames. */
173 bool silc_server_del_from_watcher_list(SilcServer server,
174 SilcClientEntry client);
176 /* Force the client indicated by `chl' to change the channel user mode
177 on channel indicated by `channel' to `forced_mode'. */
178 bool silc_server_force_cumode_change(SilcServer server,
179 SilcSocketConnection sock,
180 SilcChannelEntry channel,
181 SilcChannelClientEntry chl,
182 SilcUInt32 forced_mode);
184 /* Find active socket connection by the IP address and port indicated by
185 `ip' and `port', and socket connection type of `type'. */
187 silc_server_find_socket_by_host(SilcServer server,
189 const char *ip, SilcUInt16 port);
191 #endif /* SERVER_UTIL_H */