1 /* Predefined stub functions for the SilcClientOperation callbacks.
2 You can freely use this template in your application. These are
3 the functions that you as an application programmer need to implement
4 for the library. The library may call these functions at any time.
6 At the end of this file SilcClientOperation structure is defined, and
7 it is the one the you will give as an argument to the silc_client_alloc
8 function. See also lib/silcclient/README file, and silcclient.h.
10 You may freely use this file in your application. */
13 /* Message sent to the application by library. `conn' associates the
14 message to a specific connection. `conn', however, may be NULL.
15 The `type' indicates the type of the message sent by the library.
16 The application can for example filter the message according the
17 type. The variable argument list is arguments to the formatted
18 message that `msg' may be. */
19 void silc_say(SilcClient client, SilcClientConnection conn,
20 SilcClientMessageType type, char *msg, ...);
22 /* Message for a channel. The `sender' is the sender of the message
23 The `channel' is the channel. The `message' is the message. Note
24 that `message' maybe NULL. The `flags' indicates message flags
25 and it is used to determine how the message can be interpreted
26 (like it may tell the message is multimedia message). */
27 void silc_channel_message(SilcClient client, SilcClientConnection conn,
28 SilcClientEntry sender, SilcChannelEntry channel,
29 SilcMessagePayload payload,
30 SilcChannelPrivateKey key, SilcMessageFlags flags,
31 const unsigned char *message,
32 SilcUInt32 message_len);
34 /* Private message to the client. The `sender' is the sender of the
35 message. The message is `message'and maybe NULL. The `flags'
36 indicates message flags and it is used to determine how the message
37 can be interpreted (like it may tell the message is multimedia
39 void silc_private_message(SilcClient client, SilcClientConnection conn,
40 SilcClientEntry sender, SilcMessagePayload payload,
41 SilcMessageFlags flags, const unsigned char *message,
42 SilcUInt32 message_len);
44 /* Notify message to the client. The notify arguments are sent in the
45 same order as servers sends them. The arguments are same as received
46 from the server except for ID's. If ID is received application receives
47 the corresponding entry to the ID. For example, if Client ID is received
48 application receives SilcClientEntry. Also, if the notify type is
49 for channel the channel entry is sent to application (even if server
50 does not send it because client library gets the channel entry from
51 the Channel ID in the packet's header). */
52 void silc_notify(SilcClient client, SilcClientConnection conn,
53 SilcNotifyType type, ...);
55 /* Command handler. This function is called always after application has
56 called a command. It will be called to indicate that the command
57 was processed. It will also be called if error occurs while processing
58 the command. The `success' indicates whether the command was sent
59 or if error occurred. The `status' indicates the actual error.
60 The `argc' and `argv' are the command line arguments sent to the
61 command by application. Note that, this is not reply to the command
62 from server, this is merely and indication to application that the
63 command was processed. */
64 void silc_command(SilcClient client, SilcClientConnection conn,
65 SilcBool success, SilcCommand command, SilcStatus status,
66 SilcUInt32 argc, unsigned char **argv);
68 /* Command reply handler. This function is called always in the command reply
69 function. If error occurs it will be called as well. Normal scenario
70 is that it will be called after the received command data has been parsed
71 and processed. The function is used to pass the received command data to
74 `conn' is the associated client connection. `cmd_payload' is the command
75 payload data received from server and it can be ignored. It is provided
76 if the application would like to re-parse the received command data,
77 however, it must be noted that the data is parsed already by the library
78 thus the payload can be ignored. `success' is FALSE if error occurred.
79 In this case arguments are not sent to the application. The `status' is
80 the command reply status server returned. The `command' is the command
81 reply being processed. The function has variable argument list and each
82 command defines the number and type of arguments it passes to the
83 application (on error they are not sent).
85 The arguments are sent in the same order as servers sends them. The
86 arguments are same as received from the server except for ID's. If
87 ID is received application receives the corresponding entry to the
88 ID. For example, if Client ID is receives application receives
90 void silc_command_reply(SilcClient client, SilcClientConnection conn,
91 SilcCommand command, SilcStatus status,
92 SilcStatus error, va_list ap);
94 /* Find authentication method and authentication data by hostname and
95 port. The hostname may be IP address as well. The `auth_method' is
96 the authentication method the remote connection requires. It is
97 however possible that remote accepts also some other authentication
98 method. Application should use the method that may have been
99 configured for this connection. If none has been configured it should
100 use the required `auth_method'. If the `auth_method' is
101 SILC_AUTH_NONE, server does not require any authentication or the
102 required authentication method is not known. The `completion'
103 callback must be called to deliver the chosen authentication method
104 and data. The `conn' may be NULL. */
105 void silc_get_auth_method(SilcClient client, SilcClientConnection conn,
106 char *hostname, SilcUInt16 port,
107 SilcAuthMethod auth_method,
108 SilcGetAuthMeth completion, void *context);
110 /* Verifies received public key. The `conn_type' indicates which entity
111 (server or client) has sent the public key. If user decides to trust
112 the key the application may save the key as trusted public key for
113 later use. The `completion' must be called after the public key has
115 void silc_verify_public_key(SilcClient client, SilcClientConnection conn,
116 SilcConnectionType conn_type,
117 SilcPublicKey public_key,
118 SilcVerifyPublicKey completion, void *context);
120 /* Ask (interact, that is) a passphrase from user. The passphrase is
121 returned to the library by calling the `completion' callback with
122 the `context'. The returned passphrase SHOULD be in UTF-8 encoded,
123 if not then the library will attempt to encode. */
124 void silc_ask_passphrase(SilcClient client, SilcClientConnection conn,
125 SilcAskPassphrase completion, void *context);
127 /* Called to indicate that incoming key agreement request has been
128 received. If the application wants to perform key agreement it may
129 call silc_client_perform_key_agreement to initiate key agreementn or
130 silc_client_send_key_agreement to provide connection point to the
131 remote client in case the `hostname' is NULL. If key agreement is
132 not desired this request can be ignored. The `protocol' is either
133 value 0 for TCP or value 1 for UDP. */
134 void silc_key_agreement(SilcClient client, SilcClientConnection conn,
135 SilcClientEntry client_entry,
136 const char *hostname, SilcUInt16 protocol,
139 /* Notifies application that file transfer protocol session is being
140 requested by the remote client indicated by the `client_entry' from
141 the `hostname' and `port'. The `session_id' is the file transfer
142 session and it can be used to either accept or reject the file
143 transfer request, by calling the silc_client_file_receive or
144 silc_client_file_close, respectively. */
145 void silc_ftp(SilcClient client, SilcClientConnection conn,
146 SilcClientEntry client_entry, SilcUInt32 session_id,
147 const char *hostname, SilcUInt16 port);
149 /* The SilcClientOperation structure containing the operation functions.
150 You will give this as an argument to silc_client_alloc function. */
151 SilcClientOperations ops = {
153 silc_channel_message,
154 silc_private_message,
158 silc_get_auth_method,
159 silc_verify_public_key,