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
91 See: http://silcnet.org/docs/toolkit/command_reply_args.html */
92 void silc_command_reply(SilcClient client, SilcClientConnection conn,
93 SilcCommand command, SilcStatus status,
94 SilcStatus error, va_list ap);
96 /* Find authentication method and authentication data by hostname and
97 port. The hostname may be IP address as well. The `auth_method' is
98 the authentication method the remote connection requires. It is
99 however possible that remote accepts also some other authentication
100 method. Application should use the method that may have been
101 configured for this connection. If none has been configured it should
102 use the required `auth_method'. If the `auth_method' is
103 SILC_AUTH_NONE, server does not require any authentication or the
104 required authentication method is not known. The `completion'
105 callback must be called to deliver the chosen authentication method
106 and data. The `conn' may be NULL. */
107 void silc_get_auth_method(SilcClient client, SilcClientConnection conn,
108 char *hostname, SilcUInt16 port,
109 SilcAuthMethod auth_method,
110 SilcGetAuthMeth completion, void *context);
112 /* Verifies received public key. The `conn_type' indicates which entity
113 (server or client) has sent the public key. If user decides to trust
114 the key the application may save the key as trusted public key for
115 later use. The `completion' must be called after the public key has
117 void silc_verify_public_key(SilcClient client, SilcClientConnection conn,
118 SilcConnectionType conn_type,
119 SilcPublicKey public_key,
120 SilcVerifyPublicKey completion, void *context);
122 /* Ask (interact, that is) a passphrase from user. The passphrase is
123 returned to the library by calling the `completion' callback with
124 the `context'. The returned passphrase SHOULD be in UTF-8 encoded,
125 if not then the library will attempt to encode. */
126 void silc_ask_passphrase(SilcClient client, SilcClientConnection conn,
127 SilcAskPassphrase completion, void *context);
129 /* Called to indicate that incoming key agreement request has been
130 received. If the application wants to perform key agreement it may
131 call silc_client_perform_key_agreement to initiate key agreementn or
132 silc_client_send_key_agreement to provide connection point to the
133 remote client in case the `hostname' is NULL. If key agreement is
134 not desired this request can be ignored. The `protocol' is either
135 value 0 for TCP or value 1 for UDP. */
136 void silc_key_agreement(SilcClient client, SilcClientConnection conn,
137 SilcClientEntry client_entry,
138 const char *hostname, SilcUInt16 protocol,
141 /* Notifies application that file transfer protocol session is being
142 requested by the remote client indicated by the `client_entry' from
143 the `hostname' and `port'. The `session_id' is the file transfer
144 session and it can be used to either accept or reject the file
145 transfer request, by calling the silc_client_file_receive or
146 silc_client_file_close, respectively. */
147 void silc_ftp(SilcClient client, SilcClientConnection conn,
148 SilcClientEntry client_entry, SilcUInt32 session_id,
149 const char *hostname, SilcUInt16 port);
151 /* The SilcClientOperation structure containing the operation functions.
152 You will give this as an argument to silc_client_alloc function. */
153 SilcClientOperations ops = {
155 silc_channel_message,
156 silc_private_message,
160 silc_get_auth_method,
161 silc_verify_public_key,