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