5 Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
7 Copyright (C) 2000 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; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
25 * SILC Client Operations
27 * These functions must be implemented by the application calling the
28 * SILC client library. The client library can call these functions at
31 * To use this structure: define a static SilcClientOperations variable,
32 * fill it and pass its pointer to silc_client_alloc function.
35 void (*say)(SilcClient client, SilcClientConnection conn, char *msg, ...);
36 void (*channel_message)(SilcClient client, SilcClientConnection conn,
37 char *sender, char *channel_name, char *msg);
38 void (*private_message)(SilcClient client, SilcClientConnection conn,
39 char *sender, char *msg);
40 void (*notify)(SilcClient client, SilcClientConnection conn,
41 SilcNotifyType type, ...);
42 void (*command)(SilcClient client, SilcClientConnection conn,
43 SilcClientCommandContext cmd_context, int success,
45 void (*command_reply)(SilcClient client, SilcClientConnection conn,
46 SilcCommandPayload cmd_payload, int success,
47 SilcCommand command, SilcCommandStatus status, ...);
48 void (*connect)(SilcClient client, SilcClientConnection conn, int success);
49 void (*disconnect)(SilcClient client, SilcClientConnection conn);
50 int (*get_auth_method)(SilcClient client, SilcClientConnection conn,
51 char *hostname, unsigned short port,
52 SilcProtocolAuthMeth *auth_meth,
53 unsigned char **auth_data,
54 unsigned int *auth_data_len);
55 int (*verify_server_key)(SilcClient client, SilcClientConnection conn,
56 unsigned char *pk, unsigned int pk_len,
57 SilcSKEPKType pk_type);
58 unsigned char *(*ask_passphrase)(SilcClient client,
59 SilcClientConnection conn);
60 void (*failure)(SilcClient client, SilcClientConnection conn,
61 SilcProtocol protocol, void *failure);
62 } SilcClientOperations;
65 Descriptions of above operation functions:
67 void (*say)(SilcClient client, SilcClientConnection conn, char *msg, ...);
69 Message sent to the application by library. `conn' associates the
70 message to a specific connection. `conn', however, may be NULL.
73 void (*channel_message)(client, SilcClientConnection conn,
74 char *sender, char *channel_name, char *msg);
76 Message for a channel. The `sender' is the nickname of the sender
77 received in the packet. The `channel_name' is the name of the channel.
80 void (*private_message)(client, SilcClientConnection conn,
81 char *sender, char *msg);
83 Private message to the client. The `sender' is the nickname of the
84 sender received in the packet.
87 void (*notify)(SilcClient client, SilcClientConnection conn, ...);
89 Notify message to the client. The notify arguments are sent in the
90 same order as servers sends them. The arguments are same as received
91 from the server except for ID's. If ID is received application receives
92 the corresponding entry to the ID. For example, if Client ID is received
93 application receives SilcClientEntry. Also, if the notify type is
94 for channel the channel entry is sent to application (even if server
95 does not send it because client library gets the channel entry from
96 the Channel ID in the packet's header).
99 void (*command)(SilcClient client, SilcClientConnection conn,
100 SilcClientCommandContext cmd_context, int success,
101 SilcCommand command);
103 Command handler. This function is called always in the command function.
104 If error occurs it will be called as well. `conn' is the associated
105 client connection. `cmd_context' is the command context that was
106 originally sent to the command. `success' is FALSE if error occured
107 during command. `command' is the command being processed. It must be
108 noted that this is not reply from server. This is merely called just
109 after application has called the command. Just to tell application
110 that the command really was processed.
113 void (*command_reply)(SilcClient client, SilcClientConnection conn,
114 SilcCommandPayload cmd_payload, int success,
115 SilcCommandStatus status, SilcCommand command, ...);
117 Command reply handler. This function is called always in the command reply
118 function. If error occurs it will be called as well. Normal scenario
119 is that it will be called after the received command data has been parsed
120 and processed. The function is used to pass the received command data to
123 `conn' is the associated client connection. `cmd_payload' is the command
124 payload data received from server and it can be ignored. It is provided
125 if the application would like to re-parse the received command data,
126 however, it must be noted that the data is parsed already by the library
127 thus the payload can be ignored. `success' is FALSE if error occured.
128 In this case arguments are not sent to the application. The `status' is
129 the command reply status server returned. The `command' is the command
130 reply being processed. The function has variable argument list and each
131 command defines the number and type of arguments it passes to the
132 application (on error they are not sent).
135 void (*connect)(SilcClient client, SilcClientConnection conn, int success);
137 Called to indicate that connection was either successfully established
138 or connecting failed. This is also the first time application receives
139 the SilcClientConnection objecet which it should save somewhere.
142 void (*disconnect)(SilcClient client, SilcClientConnection conn);
144 Called to indicate that connection was disconnected to the server.
147 int (*get_auth_method)(SilcClient client, SilcClientConnection conn,
148 char *hostname, unsigned short port,
149 SilcProtocolAuthMeth *auth_meth,
150 unsigned char **auth_data,
151 unsigned int *auth_data_len);
153 Find authentication method and authentication data by hostname and
154 port. The hostname may be IP address as well. The found authentication
155 method and authentication data is returned to `auth_meth', `auth_data'
156 and `auth_data_len'. The function returns TRUE if authentication method
157 is found and FALSE if not. `conn' may be NULL.
160 int (*verify_server_key)(SilcClient client, SilcClientConnection conn,
161 unsigned char *pk, unsigned int pk_len,
162 SilcSKEPKType pk_type);
164 Verifies received public key. The public key has been received from
165 a server. If user decides to trust the key may be saved as trusted
166 server key for later use. If user does not trust the key this returns
167 FALSE. If everything is Ok this returns TRUE.
170 unsigned char *(*ask_passphrase)(SilcClient client,
171 SilcClientConnection conn);
173 Ask (interact, that is) a passphrase from user. Returns the passphrase
177 void (*failure)(SilcClient client, SilcClientConnection conn,
178 SilcProtocol protocol, void *failure);
180 Notifies application that failure packet was received. This is called
181 if there is some protocol active in the client. The `protocol' is the
182 protocol context. The `failure' is opaque pointer to the failure
183 indication. Note, that the `failure' is protocol dependant and application
184 must explicitly cast it to correct type. Usually `failure' is 32 bit
185 failure type (see protocol specs for all protocol failure types).