updates.
[crypto.git] / lib / doc / command_reply_args.html
1 <big><b>Command Reply Arguments</b></big>
2
3 <br />&nbsp;<br />
4 The SILC Client Library 'command_reply client operation (which is part of the
5 <a href="silcclient-SilcClientOperations.html">
6 SilcClientOperation</a> callback functions) returns command replies
7 from the SILC Server for commands that the client has earlier sent to the
8 server.  The 'command_reply' client operation implementation has a variable
9 argument list to deliver <a href="silccommand-SilcCommand.html">SilcCommand</a>
10 specific arguments to the application.  This document describes these
11 arguments for all command replies to help SILC client software developers
12 to process them.
13
14 <br />&nbsp;<br />
15 <b>NOTE: </b>The following list of command reply arguments are sent when
16 the command was executed successfully.  If an error occurred, the
17 `command_reply' client operation's 'success' argument is FALSE, and the
18 'status' argument includes the error status.  In this case the arguments
19 returned are dependent of the 'status' argument.  See all
20 <a href="silcstatus_args.html">SilcStatus error arguments</a> for these
21 arguments.
22
23 <br />&nbsp;<br />&nbsp;<br />
24 <b>command_reply Client Library operation</b>
25
26 <br />&nbsp;<br />
27 The 'command_reply' client operation callback function prototype is as follows:
28
29 <br />&nbsp;<br />
30 <tt>
31 &nbsp;&nbsp;
32 void (*command_reply)(SilcClient client, SilcClientConnection conn,<br />
33                       SilcCommand command, SilcStatus status,<br />
34                       SilcStatus error, va_list ap);
35 </tt>
36
37 <br />&nbsp;<br />
38 The first argument 'client' is the SILC Client Library context, the 'conn'
39 is the context for the connection to the remote server, the 'cmd_payload'
40 is the raw SilcCommandPayload and application usually ignores it, the
41 'success' boolean value indicates whether the earlier command was a success
42 or not, the 'command' is the command reply enumeration, and the 'status'
43 indicates the status of the command reply.  If 'success' is FALSE then
44 'status' includes error status (see <a href="silcstatus_args.html">SilcStatus
45 error arguments</a>).
46
47 <br />&nbsp;<br />
48 Rest of the arguments are 'command' specific and implementation should
49 handle them by the SilcCommand for example in a <tt>switch</tt> statement.
50 The commands are defined in lib/silccore/silccomand.h header file.  A short
51 example:
52
53 <br />&nbsp;<br />
54 <tt>
55 &nbsp;&nbsp;switch(type)<br />
56 &nbsp;&nbsp;&nbsp;&nbsp;{<br />
57 &nbsp;&nbsp;&nbsp;&nbsp;case SILC_COMMAND_WHOIS:<br />
58 &nbsp;&nbsp;&nbsp;&nbsp;...<br />
59 &nbsp;&nbsp;&nbsp;&nbsp;break;<br />
60 &nbsp;&nbsp;&nbsp;&nbsp;case SILC_COMMAND_WHOWAS:<br />
61 &nbsp;&nbsp;&nbsp;&nbsp;...<br />
62 &nbsp;&nbsp;&nbsp;&nbsp;break;<br />
63 &nbsp;&nbsp;&nbsp;&nbsp;case SILC_COMMAND_NICK:<br />
64 &nbsp;&nbsp;&nbsp;&nbsp;...<br />
65 &nbsp;&nbsp;&nbsp;&nbsp;break;<br />
66 &nbsp;&nbsp;&nbsp;&nbsp;...<br />
67 &nbsp;&nbsp;&nbsp;&nbsp;}
68 </tt>
69
70 <br />&nbsp;<br />&nbsp;<br />
71 <b>Arguments</b>
72
73 <br />&nbsp;<br />
74 The following table describes all commands and arguments that the client
75 library sends in the 'command_reply' client operation to the application.
76 By default all arguments that the library sends to application are valid
77 pointers.  However, it is possible that some pointers may be NULL.  If
78 this is the case it is separately mentioned that the argument may be NULL.
79 In this case application must ignore that argument.
80
81 <br />&nbsp;<br />
82 The 'command_reply' arguments for successful SilcCommand replies are as
83 follows:
84
85 <br />&nbsp;<br />
86 <table border="1" width="100%" cellpadding="3" cellspacing="0">
87
88 <tr>
89 <td><small>Name</td>
90 <td><small>Description</td>
91 <td width="50%"><small>Variable Arguments</td>
92 </tr>
93
94 <tr>
95 <td><small>SILC_COMMAND_WHOIS</td>
96 <td><small>
97 Returns information about user. The following pointers may be NULL: 'channels',
98 'fingerprint', 'channel_usermodes' and 'attrs'.  If 'fingerprint' is valid its
99 length is 20 bytes. If 'channels' is valid each entry in the list is
100 SilcChannelPayload.  If the `channel_usermodes' is valid then the table
101 has as many entries as there are entries in the `channels' list, and the
102 first entry in the table is the user mode on the first channel in the
103 `channels' list.  The `channel_usermodes' is the table of the user's modes
104 on the joined channels.  The 'attr' is the Requested Attributes that may
105 have been returned by the client and it can be parsed by traversing the
106 SilcDList and using silc_attribute_get_attribute function.  Each entry in
107 the list is SilcAttribute.
108 </td>
109 <td width="50%"><small>SilcClientEntry client_entry, char *nickname,
110 char *username, char *realname, SilcDList channels, SilcUInt32 usermode,
111 SilcUInt32 idletime, unsigned char *fingerprint, SilcUInt32 *channel_usermodes,
112 SilcDList attrs
113 </td>
114 </tr>
115
116 <tr>
117 <td><small>SILC_COMMAND_WHOWAS</td>
118 <td><small>
119 Returns history information about user. The 'client_entry' and 'realname'
120 may be NULL.
121 </td>
122 <td width="50%"><small>SilcClientEntry client_entry, char *nickname,
123 char *username, char *realname
124 </td>
125 </tr>
126
127 <tr>
128 <td><small>SILC_COMMAND_IDENTIFY</td>
129 <td><small>
130 Returns information about user, channel or server.  This is similar to
131 WHOIS command but does not return so much information and can be used to
132 get information about channels and servers too.  Application should ignore
133 this command reply.  The 'name' and 'info' may be NULL.
134 </td>
135 <td width="50%"><small>void *entry, char *name, char *info
136 </td>
137 </tr>
138
139 <tr>
140 <td><small>SILC_COMMAND_NICK</td>
141 <td><small>
142 Returns the new Client ID and new nickname inside the SilcClientEntry.
143 The `old_client_id' is the old Client ID used by the client before the
144 nickname was changed.  The `nickname' is the new nickname.  Note that,
145 when user changes nickname SILC_NOTIFY_TYPE_NICK_CHANGE is not delivered
146 to application.  Instead this SILC_COMMAND_NICK command reply is delivered.
147 </td>
148 <td width="50%"><small>SilcClientEntry local_entry, char *nickname,
149 const SilcClientID *old_client_id
150 </td>
151 </tr>
152
153 <tr>
154 <td><small>SILC_COMMAND_LIST</td>
155 <td><small>
156 Returns the list of channel in the SILC network. Each call of command reply
157 returns one channel. This means that the command reply is called multiple
158 times to return list of channels.  The 'channel', 'channel_name' and
159 'channel_topic' may be NULL.  However, the 'channel' and 'channel_name'
160 are NULL only if there are no channels in the network.  In this case
161 this reply is called once with all arguments set to NULL.  Application
162 must be able to handle this situation correctly.
163 </td>
164 <td width="50%"><small>SilcChannelEntry channel, char *channel_name,
165 char *channel_topic, SilcUInt32 user_count
166 </td>
167 </tr>
168
169 <tr>
170 <td><small>SILC_COMMAND_TOPIC</td>
171 <td><small>
172 Returns the topic of the channel.
173 </td>
174 <td width="50%"><small>SilcChannelEntry channel, char *topic
175 </td>
176 </tr>
177
178 <tr>
179 <td><small>SILC_COMMAND_INVITE</td>
180 <td><small>
181 Returns the invite list of the channel.  Called also even if invite list
182 was not modified but SILC_COMMAND_INVITE command was used to invite a user
183 into a channel.  In this case the invite list is not returned by the
184 server and 'invite_list' is NULL.  The 'invite_list' is SilcArgumenPayload
185 which contains one or more arguments, each is one invite list entry.  The
186 entries can be retrieved with silc_argument_get_first_arg,
187 silc_argument_get_next_arg, silc_argument_get_arg_type and
188 silc_argument_get_decoded functions.
189 </td>
190 <td width="50%"><small>SilcChannelEntry channel,
191 SilcArgumentPayload invite_list
192 </td>
193 </tr>
194
195 <tr>
196 <td><small>SILC_COMMAND_KILL</td>
197 <td><small>
198 Called after killing a client.  Returns the client that was killed.
199 The `client_entry' may be NULL.  The `client_entry' will become invalid
200 after the command reply has returned from application.  The
201 SILC_NOTIFY_TYPE_KILLED will not be delivered for clients that you killed.
202 </td>
203 <td width="50%"><small>SilcClientEntry client_entry
204 </td>
205 </tr>
206
207 <tr>
208 <td><small>SILC_COMMAND_INFO</td>
209 <td><small>
210 Returns information about the server user is connected to.
211 </td>
212 <td width="50%"><small>SilcServerEntry server, char *server_name,
213 char *server_info
214 </td>
215 </tr>
216
217 <tr>
218 <td><small>SILC_COMMAND_STATS</td>
219 <td><small>
220 Returns network statistics from the server.  The `stats' structure contains
221 the statistics returned by the server.
222 </td>
223 <td width="50%"><small>SilcClientStats *stats
224 </td>
225 </tr>
226
227 <tr>
228 <td><small>SILC_COMMAND_PING</td>
229 <td><small>
230 Returns reply to earlier ping.  There is no arguments to this reply.
231 </td>
232 <td width="50%"><small>none
233 </td>
234 </tr>
235
236 <tr>
237 <td><small>SILC_COMMAND_OPER</td>
238 <td><small>
239 Returns reply to earlier SILC_COMMAND_OPER command.  There is no arguments
240 to this reply.
241 </td>
242 <td width="50%"><small>none
243 </td>
244 </tr>
245
246 <tr>
247 <td><small>SILC_COMMAND_JOIN</td>
248 <td><small>
249 Reply received when user joined a channel.  The `channel_mode' contains
250 the current channel mode.  The `user_list' is the user list on the channel
251 and may be traversed with silc_hash_table_get function.  Each entry in the
252 `user_list' is SilcChannelUser structure, which contains the SilcClientEntry
253 and the client's mode on the channel.  The library will free the list.
254 The `topic' is the current topic on channel or NULL if no topic is set.
255 The `cipher' is the encryption algorithm used on channel or NULL if it is
256 not available.  The `hmac' is the HMAC algorithm used on channel or NULL if
257 it is not available.  The `founder_key' is the channel founder's public key
258 or NULL if founder public key has not been set.  The `channel_pubkeys' is
259 a list of channel public keys (for authentication on joining) or NULL if
260 they have not been set.  Each entry in the list is SilcArgumentDecodedList
261 each containing one channel SilcPublicKey.  The library will free the list.
262 </td>
263 <td width="50%"><small>char *channel_name, SilcChannelEntry channel,
264 SilcUInt32 channel_mode, SilcHashTableList *user_list, char *topic,
265 char *cipher, char *hmac, SilcPublicKey founder_key,
266 SilcDList channel_pubkeys, SilcUint32 user_limit
267 </td>
268 </tr>
269
270 <tr>
271 <td><small>SILC_COMMAND_MOTD</td>
272 <td><small>
273 Returns the Message of the Day from the server.  The 'motd' may be NULL.
274 </td>
275 <td width="50%"><small>char *motd
276 </td>
277 </tr>
278
279 <tr>
280 <td><small>SILC_COMMAND_UMODE</td>
281 <td><small>
282 Returns the user mode after changing it.
283 </td>
284 <td width="50%"><small>SilcUInt32 user_mode
285 </td>
286 </tr>
287
288 <tr>
289 <td><small>SILC_COMMAND_CMODE</td>
290 <td><small>
291 Returns channel's mode after changing it.  Optionally may also return
292 founder's public key when it was set.  It may also return the channel
293 public key list when the list was altered.  The 'founder_key' and
294 'channel_pubkeys' arguments may be NULL.  The 'channel_pubkeys' is a list
295 of SilcArgumentDecodedList contexts which each contain one channel public
296 key.  The library will automatically free the list.  If the `founder_key'
297 was present it will be updated to `channel' entry by the library after
298 calling the command_reply callback.  Application may check if the `founder_key'
299 is different from the key in `channel' entry to detect if it was changed.
300 </td>
301 <td width="50%"><small>SilcChannelEntry channel, SilcUInt32 mode,
302 SilcPublicKey founder_key, SilcDList channel_pubkeys, SilcUint32 user_limit
303 </td>
304 </tr>
305
306 <tr>
307 <td><small>SILC_COMMAND_CUMODE</td>
308 <td><small>
309 Returns user's mode on channel after changing it.
310 </td>
311 <td width="50%"><small>SilcUInt32 mode, SilcChannelEntry channel,
312 SilcClientEntry target_client
313 </td>
314 </tr>
315
316 <tr>
317 <td><small>SILC_COMMAND_KICK</td>
318 <td><small>
319 Called after kicking a client.  Returns the client that was kicked from
320 the 'channel'.
321 </td>
322 <td width="50%"><small>SilcChannelEntry channel, SilcClientEntry client_entry
323 </td>
324 </tr>
325
326 <tr>
327 <td><small>SILC_COMMAND_BAN</td>
328 <td><small>
329 Returns channel's ban list.  The 'ban_list' may be NULL.  The construction
330 of that list is equivalent to invite list.  See description of
331 SILC_COMMAND_INVITE command reply.
332 </td>
333 <td width="50%"><small>SilcChannelEntry channel, SilcArgumentPayload ban_list
334 </td>
335 </tr>
336
337 <tr>
338 <td><small>SILC_COMMAND_DETACH</td>
339 <td><small>
340 Called after being detached from the SILC network.  The command reply delivers
341 the detachment data buffer `detach_data' that the application should save
342 for example into a file.  The data will be needed when resuming back to
343 the network.  When resuming the data is saved into SilcClientConnectionParams
344 structure and given as argument to silc_client_connect_to_server or
345 silc_client_key_exchange functions.
346 </td>
347 <td width="50%"><small>SilcBuffer detach_data
348 </td>
349 </tr>
350
351 <tr>
352 <td><small>SILC_COMMAND_WATCH</td>
353 <td><small>
354 Called after modifying the watch list in the server.  There is no arguments
355 to this reply.
356 </td>
357 <td width="50%"><small>none
358 </td>
359 </tr>
360
361 <tr>
362 <td><small>SILC_COMMAND_SILCOPER</td>
363 <td><small>
364 Returns reply to earlier SILC_COMMAND_SILCOPER command.  There is no
365 arguments to this reply.
366 </td>
367 <td width="50%"><small>none
368 </td>
369 </tr>
370
371 <tr>
372 <td><small>SILC_COMMAND_LEAVE</td>
373 <td><small>
374 Called after leaving the channel.  Note that the `channel' will become
375 invalid after command_reply client operation returns.
376 </td>
377 <td width="50%"><small>SilcChannelEntry channel
378 </td>
379 </tr>
380
381 <tr>
382 <td><small>SILC_COMMAND_USERS</td>
383 <td><small>
384 Returns list of users in channel.  The `user_list' may be traversed with
385 silc_hash_table_get function.  Each entry in the `user_list' is
386 SilcChannelUser structure, which contains the SilcClientEntry and the
387 client's mode on the channel.
388 </td>
389 <td width="50%"><small>SilcChannelEntry channel, SilcHashTableList *user_list
390 </td>
391 </tr>
392
393 <tr>
394 <td><small>SILC_COMMAND_GETKEY</td>
395 <td><small>
396 Returns public key of client or server.  The 'public_key' may be NULL.
397 The 'entry_type' is used to check what type of pointer the entry' is.  For
398 SILC_ID_CLIENT SilcClientEntry and for SILC_ID_SERVER SilcServerEntry.
399 </td>
400 <td width="50%"><small>SilcIdType entry_type, void *entry,
401 SilcPublicKey public_key
402 </td>
403 </tr>
404
405 <tr>
406 <td><small>SILC_COMMAND_SERVICE</td>
407 <td><small>
408 Returns the service list in the server, or information on the accepted
409 and authenticated service.  The 'service_list' maybe NULL if server does
410 not support any services.  It is NULL also when 'name' is not NULL.  The
411 'service_list' is a comma separated list of services the server supports.
412 The 'name' MAY be NULL also.  The 'name' is the requested service, and it is
413 non-NULL only if server accepted and authenticated client's request.
414 </td>
415 <td width="50%"><small>const char *server_list, const char *service_name
416 </td>
417 </tr>
418
419 </table>
420
421 <br />&nbsp;<br />
422 SILC protocol defines some additional commands but command replies to
423 those commands are not delivered to the application.  Only the command
424 replies listed above are delivered to application.