SilcClientConnection silc_client_add_connection(SilcClient client,
char *hostname,
int port,
- void *context);
+ void *context)
{
SilcClientConnection conn;
int i;
Usage: COMMAND_REPLY((ARGS, argument1, argument2, etc...)), */
#define COMMAND_REPLY(args) cmd->client->ops->command_reply args
#define ARGS cmd->client, cmd->sock->user_data, \
- cmd->payload, TRUE, silc_command_get(cmd->payload)
+ cmd->payload, TRUE, status, silc_command_get(cmd->payload)
/* Error reply to application. Usage: COMMAND_REPLY_ERROR; */
#define COMMAND_REPLY_ERROR cmd->client->ops->command_reply(cmd->client, \
- cmd->sock->user_data, cmd->payload, FALSE, silc_command_get(cmd->payload))
+ cmd->sock->user_data, cmd->payload, FALSE, status, \
+ silc_command_get(cmd->payload))
/* Process received command reply. */
SilcCommand command);
void (*command_reply)(SilcClient client, SilcClientConnection conn,
SilcCommandPayload cmd_payload, int success,
- SilcCommand command, ...);
+ SilcCommandStatus status, SilcCommand command, ...);
void (*connect)(SilcClient client, SilcClientConnection conn, int success);
void (*disconnect)(SilcClient client, SilcClientConnection conn);
int (*get_auth_method)(SilcClient client, SilcClientConnection conn,
void (*command_reply)(SilcClient client, SilcClientConnection conn,
SilcCommandPayload cmd_payload, int success,
- SilcCommand command, ...);
+ SilcCommandStatus status, SilcCommand command, ...);
Command reply handler. This function is called always in the command reply
function. If error occurs it will be called as well. Normal scenario
if the application would like to re-parse the received command data,
however, it must be noted that the data is parsed already by the library
thus the payload can be ignored. `success' is FALSE if error occured.
- In this case arguments are not sent to the application. `command' is the
- command reply being processed. The function has variable argument list
- and each command defines the number and type of arguments it passes to the
+ In this case arguments are not sent to the application. The `status' is
+ the command reply status server returned. The `command' is the command
+ reply being processed. The function has variable argument list and each
+ command defines the number and type of arguments it passes to the
application (on error they are not sent).
(SilcClientKEInternalContext *)protocol->context;
SilcClient client = (SilcClient)ctx->client;
SilcClientConnection conn = ctx->sock->user_data;
- SilcSKEStatus status;
+ SilcSKEStatus status = 0;
SILC_LOG_DEBUG(("Start"));
}
if (status != SILC_SKE_STATUS_OK) {
- switch(status) {
-
- default:
- break;
- }
+ SILC_LOG_WARNING(("Error (type %d) during Key Exchange protocol",
+ status));
+ SILC_LOG_DEBUG(("Error (type %d) during Key Exchange protocol",
+ status));
+
+ protocol->state = SILC_PROTOCOL_STATE_ERROR;
+ protocol->execute(client->timeout_queue, 0, protocol, fd, 0, 0);
+ return;
}
/* Advance the state of the protocol. */
status = silc_ske_initiator_phase_1(ctx->ske, ctx->packet, NULL, NULL);
}
- switch(status) {
- default:
- break;
+ if (status != SILC_SKE_STATUS_OK) {
+ SILC_LOG_WARNING(("Error (type %d) during Key Exchange protocol",
+ status));
+ SILC_LOG_DEBUG(("Error (type %d) during Key Exchange protocol",
+ status));
+
+ protocol->state = SILC_PROTOCOL_STATE_ERROR;
+ protocol->execute(client->timeout_queue, 0, protocol, fd, 0, 0);
+ return;
}
/* Advance the state of the protocol and call the next state. */
context);
}
- switch(status) {
- default:
- break;
+ if (status != SILC_SKE_STATUS_OK) {
+ SILC_LOG_WARNING(("Error (type %d) during Key Exchange protocol",
+ status));
+ SILC_LOG_DEBUG(("Error (type %d) during Key Exchange protocol",
+ status));
+
+ protocol->state = SILC_PROTOCOL_STATE_ERROR;
+ protocol->execute(client->timeout_queue, 0, protocol, fd, 0, 0);
+ return;
}
/* Advance the state of the protocol. */