@LINK=notifyargs.html:Arguments for <b>notify</b> Client Operation
@LINK=silcclient_unicode.html:Unicode and UTF-8 Strings in Client Library
@LINK=silcclient.html:Client Library Interface Reference
+@LINK=silcclient_entry.html:Client Entry Interface Reference
-->
<big><b>SILC Client Library</b></big>
When closing SilcClientConnection all threads must first be finished
before the connection machine is finished. This is done by finishing
all running command threads. That will also finish all waiting packet
- threads as they are always waiting for a command. If any thread is
- waiting for something else than a command (such as event threads) they
- must be explicitly finished. The threads are finished by continuing
- them synchronously. The threads will detect that we are disconnected
- (see below). SILC_FSM_YIELD must be returned in st_close() as that
- gives the FSM scheduler time to finish the threads first. After that
- the machine can be finished.
+ and notify threads as they are always waiting for a command. If any
+ thread is waiting for something else than a command (such as event
+ threads) they must be explicitly finished. The threads are finished by
+ continuing them synchronously. The threads will detect that we are
+ disconnected (see below). SILC_FSM_YIELD must be returned in
+ st_close() as that gives the FSM scheduler time to finish the threads
+ first. After that the machine can be finished.
Also, any thread that runs in SilcClientConnection machine must always
after returning from wait state to check if we are disconnected by doing
- if (conn->internal->disconnected)
+ if (conn->internal->disconnected) {
xxx;
+ return SILC_FSM_FINISH;
+ }
If disconnected the thread must finish immediately by returning
SILC_FSM_FINISH.
SILC_FSM_EVENT_SIGNAL(&conn->internal->wait_event);
/* Wait until this thread is terminated from the machine destructor */
- SILC_FSM_WAIT;
+ return SILC_FSM_WAIT;
}
/* Connection machine main state. This handles various connection related
silc_fsm_thread_init(thread, &conn->internal->fsm, conn,
NULL, NULL, FALSE);
silc_fsm_start_sync(thread, silc_client_st_connect);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
if (conn->internal->key_exchange) {
silc_fsm_thread_init(thread, &conn->internal->fsm, conn,
NULL, NULL, FALSE);
silc_fsm_start_sync(thread, silc_client_st_connect_set_stream);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
if (conn->internal->rekeying) {
silc_fsm_thread_init(thread, &conn->internal->fsm, conn,
NULL, NULL, FALSE);
silc_fsm_start_sync(thread, silc_client_st_rekey);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
if (conn->internal->disconnected) {
/** Event: disconnected */
SILC_LOG_DEBUG(("Event: disconnected"));
silc_fsm_next(fsm, silc_client_connection_st_close);
- SILC_FSM_YIELD;
+ return SILC_FSM_YIELD;
}
/* NOT REACHED */
SILC_ASSERT(FALSE);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/* Packet processor thread. Each incoming packet is processed in FSM
SILC_FSM_EVENT_SIGNAL(&conn->internal->wait_event);
silc_packet_free(packet);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
break;
default:
silc_packet_free(packet);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
break;
}
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/* Disconnection event to close remote connection. We close the connection
}
/* Give threads time to finish */
- SILC_FSM_YIELD;
+ return SILC_FSM_YIELD;
}
/* Abort ongoing event */
if (silc_fsm_is_started(&conn->internal->event_thread)) {
SILC_LOG_DEBUG(("Finish event thread"));
silc_fsm_continue_sync(&conn->internal->event_thread);
- SILC_FSM_YIELD;
+ return SILC_FSM_YIELD;
}
SILC_LOG_DEBUG(("Closing remote connection"));
silc_packet_stream_destroy(conn->stream);
SILC_LOG_DEBUG(("Finishing connection machine"));
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Received error packet from server. Send it to application. */
silc_free(msg);
silc_packet_free(packet);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Received disconnect packet from server. We close the connection and
if (silc_buffer_len(&packet->buffer) < 1) {
silc_packet_free(packet);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
status = (SilcStatus)packet->buffer.data[0];
SILC_FSM_EVENT_SIGNAL(&conn->internal->wait_event);
}
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/*************************** Main client machine ****************************/
SILC_LOG_DEBUG(("We are up, call running callback"));
client->internal->run_callback = FALSE;
client->internal->running(client, client->internal->running_context);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
if (client->internal->connection_closed) {
if (silc_atomic_get_int16(&client->internal->conns) == 0 &&
client->internal->stop)
SILC_FSM_EVENT_SIGNAL(&client->internal->wait_event);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
if (client->internal->stop) {
SILC_LOG_DEBUG(("Event: stop"));
if (silc_atomic_get_int16(&client->internal->conns) == 0)
silc_fsm_next(fsm, silc_client_st_stop);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/* NOT REACHED */
SILC_ASSERT(FALSE);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/* Stop event. Stops the client library. */
if (client->internal->running)
client->internal->running(client, client->internal->running_context);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/******************************* Private API ********************************/
return NULL;
}
- conn->internal->ftp_sessions = silc_dlist_init();
+ // conn->internal->ftp_sessions = silc_dlist_init();
/* Initialize our async operation so that application may abort us
while we're connecting. */
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2002 - 2004, 2006 Pekka Riikonen
+ Copyright (C) 2002 - 2007 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* Finally compute the digital signature of all the data we provided. */
if (silc_pkcs_sign(conn->private_key, silc_buffer_data(buffer),
silc_buffer_len(buffer), sign, sizeof(sign), &sign_len,
- conn->internal->sha1hash)) {
+ TRUE, conn->internal->sha1hash)) {
pk.type = NULL;
pk.data = sign;
pk.data_len = sign_len;
/* Delete one attribute */
SilcBool silc_client_attribute_del(SilcClient client,
- SilcClientConnection conn,
- SilcAttribute attribute,
- SilcAttributePayload attr)
+ SilcClientConnection conn,
+ SilcAttribute attribute,
+ SilcAttributePayload attr)
{
SilcBool ret;
if (!attribute)
return silc_client_attributes_request(SILC_ATTRIBUTE_USER_INFO,
+ SILC_ATTRIBUTE_USER_ICON,
SILC_ATTRIBUTE_SERVICE,
SILC_ATTRIBUTE_STATUS_MOOD,
SILC_ATTRIBUTE_STATUS_FREETEXT,
if (silc_unlikely(packet->dst_id_type != SILC_ID_CHANNEL)) {
/** Invalid packet */
silc_fsm_next(fsm, silc_client_channel_message_error);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
if (silc_unlikely(!silc_id_str2id(packet->src_id,
&remote_id, sizeof(remote_id)))) {
/** Invalid source ID */
silc_fsm_next(fsm, silc_client_channel_message_error);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/* Get sender client entry */
sizeof(channel_id)))) {
/** Invalid destination ID */
silc_fsm_next(fsm, silc_client_channel_message_error);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/* Find the channel */
if (silc_unlikely(!channel)) {
/** Unknown channel */
silc_fsm_next(fsm, silc_client_channel_message_error);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/* Check that user is on channel */
SILC_LOG_WARNING(("Message from user not on channel, client or "
"server bug"));
silc_fsm_next(fsm, silc_client_channel_message_error);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/* If there is no channel private key then just decrypt the message
silc_client_unref_channel(client, conn, channel);
if (payload)
silc_message_payload_free(payload);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Channel message error. */
{
SilcPacket packet = state_context;
silc_packet_free(packet);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/******************************* Channel Key ********************************/
silc_client_save_channel_key(client, conn, &packet->buffer, NULL);
silc_packet_free(packet);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/**************************** Channel Private Key ***************************/
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2001 - 2006 Pekka Riikonen
+ Copyright (C) 2001 - 2007 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
}
}
- /* Format the nickname */
- silc_client_nickname_format(client, conn, client_entry, FALSE);
-
silc_mutex_lock(conn->internal->lock);
/* Add client to cache, the normalized nickname is saved to cache */
silc_mutex_unlock(conn->internal->lock);
silc_client_ref_client(client, conn, client_entry);
+ /* Format the nickname */
+ silc_client_nickname_format(client, conn, client_entry, FALSE);
+
SILC_LOG_DEBUG(("Added %p", client_entry));
return client_entry;
SilcClientFileError
silc_client_file_send(SilcClient client,
- SilcClientConnection conn,
+ SilcClientEntry client_entry,
+ SilcClientConnectionParams *params,
+ SilcPublicKey public_key,
+ SilcPrivateKey private_key,
SilcClientFileMonitor monitor,
void *monitor_context,
- const char *local_ip,
- SilcUInt32 local_port,
- SilcBool do_not_bind,
- SilcClientEntry client_entry,
const char *filepath,
SilcUInt32 *session_id)
{
char *filename, *path;
int fd;
- assert(client && conn && client_entry);
+ SILC_LOG_DEBUG(("File send request (file: %s), filepath"));
- SILC_LOG_DEBUG(("Start"));
+ if (!client || !client_entry || !filepath)
+ return SILC_CLIENT_FILE_ERROR;
/* Check for existing session for `filepath'. */
- silc_dlist_start(conn->internal->ftp_sessions);
- while ((session = silc_dlist_get(conn->internal->ftp_sessions))
- != SILC_LIST_END) {
+ silc_dlist_start(client->internal->ftp_sessions);
+ while ((session = silc_dlist_get(client->internal->ftp_sessions))) {
if (session->filepath && !strcmp(session->filepath, filepath) &&
session->client_entry == client_entry)
return SILC_CLIENT_FILE_ALREADY_STARTED;
}
- /* See whether the file exists, and can be opened in generally speaking */
+ /* See whether the file exists and can be opened */
fd = silc_file_open(filepath, O_RDONLY);
if (fd < 0)
return SILC_CLIENT_FILE_NO_SUCH_FILE;
/* Add new session */
session = silc_calloc(1, sizeof(*session));
- session->session_id = ++conn->internal->next_session_id;
+ if (!session)
+ return SILC_CLIENT_FILE_ERROR;
+ session->session_id = ++client->internal->next_session_id;
session->client = client;
session->conn = conn;
session->server = TRUE;
session->filesize = silc_file_size(filepath);
- /* Create the listener for incoming key exchange protocol. */
- if (!do_not_bind) {
- session->listener = -1;
- if (local_ip)
- session->hostname = strdup(local_ip);
- else
- silc_net_check_local_by_sock(conn->sock->sock, NULL,
- &session->hostname);
- if (session->hostname)
- session->listener = silc_net_create_server(local_port,
- session->hostname);
- if (session->listener < 0) {
+ /* If local IP is provided, create listener for incoming key exchange */
+ if (params && (params->local_ip || params->bind_ip)) {
+ ke = silc_calloc(1, sizeof(*ke));
+ if (!ke) {
+ completion(client, conn, client_entry, SILC_KEY_AGREEMENT_NO_MEMORY,
+ NULL, context);
+ return;
+ }
+
+ /* TCP listener */
+ session->listener =
+ silc_net_tcp_create_listener(params->bind_ip ?
+ (const char **)¶ms->bind_ip :
+ (const char **)¶ms->local_ip,
+ 1, params->local_port, FALSE, FALSE,
+ conn->internal->schedule,
+ silc_client_tcp_accept,
+ client_entry);
+ if (!session->listener) {
/* Could not create listener. Do the second best thing; send empty
key agreement packet and let the remote client provide the point
for the key exchange. */
SILC_LOG_DEBUG(("Could not create listener"));
silc_free(session->hostname);
- session->listener = 0;
session->hostname = NULL;
session->port = 0;
} else {
- /* Listener ready */
SILC_LOG_DEBUG(("Bound listener"));
- session->port = silc_net_get_local_port(session->listener);
- silc_schedule_task_add(client->schedule, session->listener,
- silc_client_ftp_process_key_agreement, session,
- 0, 0, SILC_TASK_FD, SILC_TASK_PRI_NORMAL);
session->bound = TRUE;
+ session->port = params->local_port;
+ if (!session->port) {
+ /* Get listener port */
+ SilcUInt16 *ports;
+ ports = silc_net_listener_get_port(ke->tcp_listener, NULL);
+ session->port = ports[0];
+ silc_free(ports);
+ }
}
}
out:
silc_packet_free(packet);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
SilcPacketEngine packet_engine; /* Packet engine */
SilcMutex lock; /* Client lock */
SilcList commands; /* Registered commands */
+ SilcDList ftp_sessions; /* FTP sessions */
char *silc_client_version; /* Version set by application */
SilcClientRunning running; /* Running/Stopped callback */
void *running_context; /* Context for runnign callback */
SilcAtomic16 conns; /* Number of connections in client */
+ SilcUInt16 next_session_id; /* Next FTP session ID */
/* Events */
unsigned int stop : 1; /* Stop client */
unsigned int auth_request : 1; /* Set when requesting auth method */
SilcClientAway *away;
- SilcDList ftp_sessions;
- SilcUInt32 next_session_id;
SilcClientFtpSession active_session;
SilcHashTable privmsg_wait; /* Waited private messages */
};
if (packet->src_id_type != SILC_ID_CLIENT) {
/** Invalid packet */
silc_fsm_next(fsm, silc_client_key_agreement_error);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
if (!silc_id_str2id(packet->src_id, packet->src_id_len, SILC_ID_CLIENT,
&remote_id, sizeof(remote_id))) {
/** Invalid source ID */
silc_fsm_next(fsm, silc_client_key_agreement_error);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/* Check whether we know this client already */
/** Malformed Payload */
SILC_LOG_DEBUG(("Malformed key agreement payload"));
silc_fsm_next(fsm, silc_client_key_agreement_error);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/* If remote did not provide connection endpoint, we will assume that we
silc_key_agreement_payload_free(payload);
silc_packet_free(packet);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Key agreement packet processing error */
{
SilcPacket packet = state_context;
silc_packet_free(packet);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
if (!payload) {
SILC_LOG_DEBUG(("Malformed notify payload"));
silc_packet_free(packet);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
if (!silc_notify_get_args(payload)) {
SILC_LOG_DEBUG(("Malformed notify %d", silc_notify_get_type(payload)));
silc_notify_payload_free(payload);
silc_packet_free(packet);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
notify = silc_calloc(1, sizeof(*notify));
if (!notify) {
silc_notify_payload_free(payload);
silc_packet_free(packet);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
- /* Save notify payload to packet context during processing */
notify->packet = packet;
notify->payload = payload;
notify->fsm = fsm;
silc_notify_payload_free(payload);
silc_packet_free(packet);
silc_free(notify);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
break;
}
- SILC_FSM_YIELD;
+ return SILC_FSM_YIELD;
}
/* Notify processed, finish the packet processing thread */
silc_notify_payload_free(payload);
silc_packet_free(packet);
silc_free(notify);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/********************************** NONE ************************************/
/** Notify processed */
silc_fsm_next(fsm, silc_client_notify_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************* INVITE ***********************************/
/** Notify processed */
silc_client_unref_channel(client, conn, channel);
silc_fsm_next(fsm, silc_client_notify_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** JOIN ************************************/
/** Notify processed */
silc_client_unref_channel(client, conn, channel);
silc_fsm_next(fsm, silc_client_notify_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** LEAVE ***********************************/
/** Notify processed */
silc_client_unref_channel(client, conn, channel);
silc_fsm_next(fsm, silc_client_notify_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************* SIGNOFF **********************************/
out:
/** Notify processed */
silc_fsm_next(fsm, silc_client_notify_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/******************************** TOPIC_SET *********************************/
/** Notify processed */
silc_client_unref_channel(client, conn, channel);
silc_fsm_next(fsm, silc_client_notify_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/****************************** NICK_CHANGE *********************************/
/** Notify processed */
silc_client_unref_client(client, conn, client_entry);
silc_fsm_next(fsm, silc_client_notify_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/****************************** CMODE_CHANGE ********************************/
/** Notify processed */
silc_fsm_next(fsm, silc_client_notify_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/***************************** CUMODE_CHANGE ********************************/
/** Notify processed */
silc_fsm_next(fsm, silc_client_notify_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************* MOTD *************************************/
out:
/** Notify processed */
silc_fsm_next(fsm, silc_client_notify_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/**************************** CHANNEL CHANGE ********************************/
/** Notify processed */
silc_client_unref_channel(client, conn, channel);
silc_fsm_next(fsm, silc_client_notify_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/******************************** KICKED ************************************/
/** Notify processed */
silc_client_unref_channel(client, conn, channel);
silc_fsm_next(fsm, silc_client_notify_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/******************************** KILLED ************************************/
/** Notify processed */
silc_fsm_next(fsm, silc_client_notify_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/**************************** SERVER SIGNOFF ********************************/
/** Notify processed */
silc_client_list_free(client, conn, clients);
silc_fsm_next(fsm, silc_client_notify_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/******************************** ERROR *************************************/
out:
/** Notify processed */
silc_fsm_next(fsm, silc_client_notify_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/******************************** WATCH *************************************/
/** Notify processed */
silc_client_unref_client(client, conn, client_entry);
silc_fsm_next(fsm, silc_client_notify_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
out:
/** Packet processed */
silc_packet_free(packet);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
SILC_STR_END)) {
/** Error sending packet */
silc_fsm_next(fsm, silc_client_st_register_error);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/** Wait for new ID */
conn->internal->registering = TRUE;
silc_fsm_next_later(fsm, silc_client_st_register_complete,
conn->internal->retry_timer, 0);
- SILC_FSM_WAIT;
+ return SILC_FSM_WAIT;
}
/* Wait for NEW_ID packet to arrive */
if (conn->internal->disconnected) {
/** Disconnected */
silc_fsm_next(fsm, silc_client_st_register_error);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
if (!conn->local_id) {
conn->internal->retry_count = 0;
conn->internal->retry_timer = SILC_CLIENT_RETRY_MIN;
silc_fsm_next(fsm, silc_client_st_register_error);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/** Resend registering packet */
SILC_CLIENT_RETRY_MUL) +
(silc_rng_get_rn16(client->rng) %
SILC_CLIENT_RETRY_RAND));
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
SILC_LOG_DEBUG(("Registered to network"));
silc_schedule_task_del_by_all(conn->internal->schedule, 0,
silc_client_connect_timeout, conn);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Error registering to network */
silc_schedule_task_del_by_all(conn->internal->schedule, 0,
silc_client_connect_timeout, conn);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/************************* Resume detached session **************************/
if (!resume) {
/** Out of memory */
silc_fsm_next(fsm, silc_client_st_resume_error);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
silc_fsm_set_state_context(fsm, resume);
/** Malformed detach data */
SILC_LOG_DEBUG(("Malformed detachment data"));
silc_fsm_next(fsm, silc_client_st_resume_error);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
if (!silc_id_str2id(id, id_len, SILC_ID_CLIENT, &client_id,
/** Malformed ID */
SILC_LOG_DEBUG(("Malformed ID"));
silc_fsm_next(fsm, silc_client_st_resume_error);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/* Generate authentication data that server will verify */
if (!auth) {
/** Out of memory */
silc_fsm_next(fsm, silc_client_st_resume_error);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/* Send RESUME_CLIENT packet to resume to network */
/** Error sending packet */
SILC_LOG_DEBUG(("Error sending packet"));
silc_fsm_next(fsm, silc_client_st_resume_error);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/** Wait for new ID */
conn->internal->registering = TRUE;
silc_fsm_next_later(fsm, silc_client_st_resume_resolve_channels, 15, 0);
- SILC_FSM_WAIT;
+ return SILC_FSM_WAIT;
}
/* Resolve the old session information, user mode and joined channels. */
if (conn->internal->disconnected) {
/** Disconnected */
silc_fsm_next(fsm, silc_client_st_resume_error);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
if (!conn->local_id) {
/** Timeout, ID not received */
conn->internal->registering = FALSE;
silc_fsm_next(fsm, silc_client_st_resume_error);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/** Wait for channels */
silc_buffer_len(conn->internal->local_idp));
if (!resume->channel_count)
- SILC_FSM_YIELD;
+ return SILC_FSM_YIELD;
/* Send IDENTIFY command for all channels we know about. These are the
channels we've joined to according our detachment data. */
silc_free(res_argv_lens);
silc_free(res_argv_types);
- SILC_FSM_WAIT;
+ return SILC_FSM_WAIT;
}
/* Resolve joined channel modes, users and topics. */
if (conn->internal->disconnected) {
/** Disconnected */
silc_fsm_next(fsm, silc_client_st_resume_error);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
SILC_LOG_DEBUG(("Resolving channel details"));
silc_fsm_next(fsm, silc_client_st_resume_completed);
if (!silc_idcache_get_all(conn->internal->channel_cache, &channels))
- SILC_FSM_YIELD;
+ return SILC_FSM_YIELD;
/* Resolve channels' mode, users and topic */
resume->channel_count = silc_list_count(channels) * 3;
silc_buffer_free(idp);
}
- SILC_FSM_WAIT;
+ return SILC_FSM_WAIT;
}
/* Resuming completed */
if (conn->internal->disconnected) {
/** Disconnected */
silc_fsm_next(fsm, silc_client_st_resume_error);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
if (resume->channel_count > 0) {
resume->channel_count--;
if (resume->channel_count)
- SILC_FSM_WAIT;
+ return SILC_FSM_WAIT;
}
SILC_LOG_DEBUG(("Resuming completed"));
silc_free(resume->nickname);
silc_free(resume);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Error resuming to network */
silc_free(resume->nickname);
silc_free(resume);
}
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
SILC_LOG_DEBUG(("Error resuming to network"));
silc_free(resume);
}
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Generates the session detachment data. This data can be used later
SILC_FSM_STATE(silc_client_command_continue_error)
{
/* Destructor will free all resources */
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Command reply callback to continue with the execution of a command.
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
for (i = 1; i < cmd->argc; i++) {
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/******************************** WHOWAS ************************************/
"Usage: /WHOWAS <nickname>[@<server>] [<count>]");
COMMAND_ERROR((cmd->argc < 2 ? SILC_STATUS_ERR_NOT_ENOUGH_PARAMS :
SILC_STATUS_ERR_TOO_MANY_PARAMS));
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
if (cmd->argc == 2) {
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/******************************** IDENTIFY **********************************/
int c;
if (cmd->argc < 2 || cmd->argc > 3)
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
if (cmd->argc == 2) {
silc_client_command_send_va(conn, cmd, cmd->cmd, NULL, NULL,
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** NICK ************************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/********************************** LIST ************************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** TOPIC ***********************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/********************************* INVITE ***********************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
silc_free(nickname);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/********************************** QUIT ************************************/
SILC_FSM_EVENT_SIGNAL(&conn->internal->wait_event);
}
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Command QUIT. Closes connection with current server. */
/* We close the connection with a little timeout */
silc_fsm_next_later(fsm, silc_client_command_quit_final, 2, 0);
- SILC_FSM_WAIT;
+ return SILC_FSM_WAIT;
}
/********************************** KILL ************************************/
SAY(conn->client, conn, SILC_CLIENT_MESSAGE_INFO,
"Usage: /KILL <nickname> [<comment>] [-pubkey]");
COMMAND_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Parse the typed nickname. */
if (!silc_client_nickname_parse(client, conn, cmd->argv[1], &nickname))
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
/* Get the target client */
clients = silc_client_get_clients_local(client, conn, nickname,
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** INFO ************************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** STATS ***********************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** PING ************************************/
if (cmd->argc < 2) {
COMMAND_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Send the command */
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** JOIN ************************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
silc_client_unref_channel(client, conn, channel);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/********************************** MOTD ************************************/
"Usage: /MOTD [<server>]");
COMMAND_ERROR((cmd->argc < 1 ? SILC_STATUS_ERR_NOT_ENOUGH_PARAMS :
SILC_STATUS_ERR_TOO_MANY_PARAMS));
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Send the command */
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** UMODE ***********************************/
SAY(conn->client, conn, SILC_CLIENT_MESSAGE_INFO,
"Usage: /UMODE +|-<modes>");
COMMAND_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
mode = conn->local_entry->mode;
break;
default:
COMMAND_ERROR(SILC_STATUS_ERR_UNKNOWN_MODE);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
break;
}
}
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** CMODE ***********************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
silc_client_unref_channel(client, conn, channel);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/********************************* CUMODE ***********************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
silc_client_unref_channel(client, conn, channel);
silc_client_list_free(client, conn, clients);
silc_free(nickname);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/********************************** KICK ************************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
silc_client_unref_channel(client, conn, channel);
silc_free(nickname);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/***************************** OPER & SILCOPER ******************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/* OPER command. Used to obtain server operator privileges. */
SAY(conn->client, conn, SILC_CLIENT_MESSAGE_INFO,
"Usage: /OPER <username> [-pubkey]");
COMMAND_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Get passphrase */
if (cmd->argc < 3) {
oper = silc_calloc(1, sizeof(*oper));
if (!oper)
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
cmd->context = oper;
SILC_FSM_CALL(conn->client->internal->
ops->ask_passphrase(conn->client, conn,
}
silc_fsm_next(fsm, silc_client_command_oper_send);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/* SILCOPER command. Used to obtain router operator privileges. */
SAY(conn->client, conn, SILC_CLIENT_MESSAGE_INFO,
"Usage: /SILCOPER <username> [-pubkey]");
COMMAND_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Get passphrase */
if (cmd->argc < 3) {
oper = silc_calloc(1, sizeof(*oper));
if (!oper)
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
cmd->context = oper;
SILC_FSM_CALL(conn->client->internal->
ops->ask_passphrase(conn->client, conn,
}
silc_fsm_next(fsm, silc_client_command_oper_send);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/*********************************** BAN ************************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/********************************* DETACH ***********************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** WATCH ***********************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/********************************** LEAVE ***********************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/********************************** USERS ***********************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/********************************* GETKEY ***********************************/
client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_INFO,
"Usage: /GETKEY <nickname or server name>");
COMMAND_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Parse the typed nickname. */
if (!silc_client_nickname_parse(client, conn, cmd->argv[1], &nickname)) {
COMMAND_ERROR(SILC_STATUS_ERR_RESOURCE_LIMIT);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Find client entry */
errors are handled in the resolving callback. */
COMMAND_ERROR(SILC_STATUS_ERR_NO_SUCH_NICK);
COMMAND_ERROR(SILC_STATUS_ERR_NO_SUCH_SERVER);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* No client or server exist with this name, query for both. */
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************* SERVICE **********************************/
SAY(conn->client, conn, SILC_CLIENT_MESSAGE_INFO,
"Usage: /SERVICE [<service name>] [-pubkey]");
COMMAND_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
name = cmd->argv[1];
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/* Register all default commands provided by the client library for the
silc_buffer_len(&packet->buffer));
if (!payload) {
SILC_LOG_DEBUG(("Bad command packet"));
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Get arguments */
}
silc_command_payload_free(payload);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
ERROR_CALLBACK(cmd->error); \
silc_client_command_process_error(cmd, state_context, cmd->error); \
silc_fsm_next(fsm, silc_client_command_reply_processed); \
- SILC_FSM_CONTINUE; \
+ return SILC_FSM_CONTINUE; \
}
/* Check for correct arguments */
silc_argument_get_arg_num(args) > max) { \
ERROR_CALLBACK(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS); \
silc_fsm_next(fsm, silc_client_command_reply_processed); \
- SILC_FSM_CONTINUE; \
+ return SILC_FSM_CONTINUE; \
}
#define SAY cmd->conn->client->internal->ops->say
silc_packet_free(packet);
if (!payload) {
SILC_LOG_DEBUG(("Bad command reply packet"));
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
cmd_ident = silc_command_get_ident(payload);
SILC_LOG_DEBUG(("Unknown command reply %s, ident %d",
silc_get_command_name(command), cmd_ident));
silc_command_payload_free(payload);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Signal command thread that command reply has arrived */
silc_fsm_next(&cmd->thread, silc_client_command_reply_process);
silc_fsm_continue_sync(&cmd->thread);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Wait here for command reply to arrive from remote host */
silc_fsm_set_state_context(fsm, NULL);
silc_fsm_next_later(fsm, silc_client_command_reply_timeout,
cmd->cmd != SILC_COMMAND_PING ? 25 : 60, 0);
- SILC_FSM_WAIT;
+ return SILC_FSM_WAIT;
}
/* Timeout occurred while waiting command reply */
if (conn->internal->disconnected) {
SILC_LOG_DEBUG(("Command %s canceled", silc_get_command_name(cmd->cmd)));
silc_list_del(conn->internal->pending_commands, cmd);
- if (!cmd->called)
+ if (!cmd->called && cmd->cmd != SILC_COMMAND_PING)
ERROR_CALLBACK(SILC_STATUS_ERR_TIMEDOUT);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
SILC_LOG_DEBUG(("Command %s timeout", silc_get_command_name(cmd->cmd)));
/* Timeout, reply not received in timely fashion */
silc_list_del(conn->internal->pending_commands, cmd);
ERROR_CALLBACK(SILC_STATUS_ERR_TIMEDOUT);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Process received command reply payload */
silc_fsm_next(fsm, silc_client_command_reply_service);
break;
default:
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/* Completes command reply processing */
if (cmd->status == SILC_STATUS_OK || cmd->status == SILC_STATUS_LIST_END ||
SILC_STATUS_IS_ERROR(cmd->status))
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
/* Add back to pending command reply list */
silc_mutex_lock(conn->internal->lock);
/** Wait more command payloads */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/******************************** WHOIS *************************************/
out:
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/******************************** WHOWAS ************************************/
out:
silc_client_unref_client(client, conn, client_entry);
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/******************************** IDENTIFY **********************************/
out:
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** NICK ************************************/
out:
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** LIST ************************************/
/* There were no channels in the network. */
silc_client_command_callback(cmd, NULL, NULL, NULL, 0);
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
CHECK_ARGS(3, 5);
out:
silc_client_unref_channel(client, conn, channel_entry);
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************* TOPIC ************************************/
out:
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************* INVITE ***********************************/
out:
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** KILL ************************************/
out:
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** INFO ************************************/
out:
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** STATS ***********************************/
out:
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** PING ************************************/
silc_client_command_callback(cmd);
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** JOIN ************************************/
out:
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** MOTD ************************************/
out:
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** UMODE ***********************************/
out:
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** CMODE ***********************************/
if (public_key)
silc_pkcs_public_key_free(public_key);
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** CUMODE **********************************/
out:
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** KICK ************************************/
out:
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/******************************** SILCOPER **********************************/
silc_client_command_callback(cmd);
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** OPER ************************************/
silc_client_command_callback(cmd);
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************* DETACH ***********************************/
out:
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** WATCH ***********************************/
silc_client_command_callback(cmd);
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/*********************************** BAN ************************************/
out:
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** LEAVE ***********************************/
out:
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************* USERS ************************************/
out:
silc_client_unref_channel(client, conn, channel);
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** GETKEY **********************************/
if (public_key)
silc_pkcs_public_key_free(public_key);
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** SERVICE *********************************/
silc_client_command_callback(cmd, service_list, name);
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/*********************************** QUIT ***********************************/
SILC_FSM_STATE(silc_client_command_reply_quit)
{
silc_fsm_next(fsm, silc_client_command_reply_processed);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
***/
void silc_client_run_one(SilcClient client);
-
/****f* silcclient/SilcClientAPI/silc_client_stop
*
* SYNOPSIS
/* Rekey timeout in seconds. The client will perform rekey in this
time interval. If set to zero, the default value will be used
(3600 seconds, 1 hour). */
- unsigned int rekey_secs;
+ SilcUInt32 rekey_secs;
/* If this is set to TRUE then the client will ignore all incoming
Requested Attributes queries and does not reply anything back. This
void silc_client_close_connection(SilcClient client,
SilcClientConnection conn);
-/* Message sending functions (client_channel.c and client_prvmsg.c) */
+/* Message sending functions */
/****f* silcclient/SilcClientAPI/silc_client_send_channel_message
*
* private key) is used.
*
* If the `flags' includes SILC_MESSAGE_FLAG_SIGNED the message will be
- * digitally signed with the SILC key pair.
+ * digitally signed with the SILC key pair. In this case the `hash'
+ * pointer must be provided as well.
*
* Returns TRUE if the message was sent, and FALSE if error occurred or
* the sending is not allowed due to channel modes (like sending is
* not been set with this client then the message will be encrypted using
* normal session keys. If the `flags' includes SILC_MESSAGE_FLAG_SIGNED
* the message will be digitally signed with the SILC key pair. In this
- * case the caller must also provide the `hash' pointer. By default, the
- * hash function must be SHA-1.
+ * case the caller must also provide the `hash' pointer.
*
* Returns TRUE if the message was sent, and FALSE if error occurred.
* This function is thread safe and private messages can be sent from
SilcClientConnection conn,
const char *command_line, ...);
-/* If FALSE is returned the callback will not be called again, even if there
- is more data coming in in the command reply. If there are other pending
- commands waiting for the reply, they will receive it even if some other
- command reply has returned FALSE. */
+/****f* silcclient/SilcClientAPI/SilcClientCommandReply
+ *
+ * SYNOPSIS
+ *
+ * typedef SilcBool (*SilcClientCommandReply)(SilcClient client,
+ * SilcClientConnection conn,
+ * SilcCommand command,
+ * SilcStatus status,
+ * SilcStatus error,
+ * void *context,
+ * va_list ap);
+ *
+ * DESCRIPTION
+ *
+ * The command reply callback function given as argument to functions
+ * silc_client_command_send and silc_client_command_pending. This is
+ * called to deliver the command replies to the caller. Each command
+ * reply received from the server to the `command' will be delivered
+ * separately to the caller by calling this callback. The `status' will
+ * indicate whether there is only one reply or multiple replies. The
+ * `error' will indicate if an error occurred. The `ap' will include
+ * command reply arguments. They are the same arguments as for
+ * `command_reply' client operation in SilcClientOperations.
+ *
+ * If `status' is SILC_STATUS_OK only one reply was received and error
+ * did not occur. If it is SILC_STATUS_LIST_START, SILC_STATUS_LIST_ITEM
+ * or SILC_STATUS_LIST_END, there are will be two or more replies. The
+ * first reply is SILC_STATUS_LIST_START and last one SILC_STATUS_LIST_END.
+ *
+ * If FALSE is returned in this function this callback will not be called
+ * again for `command' even if there are more comand replies. By returning
+ * FALSE the caller my stop the command reply handling when needed.
+ *
+ ***/
typedef SilcBool (*SilcClientCommandReply)(SilcClient client,
SilcClientConnection conn,
SilcCommand command,
* The `reply' callback must be provided, and it is called when the
* command reply is received from the server. Note that, when using this
* function the default `command_reply' client operation will not be
- * called, when reply is received. Note however that, `reply' is almost
- * identical with `command_reply' callback, and application may forward
- * the reply from `reply' to `command_reply' callback, if desired.
+ * called, when reply is received.
*
* Returns command identifier for this sent command. It can be used
* to additionally attach to the command reply using the function
void *context);
-/* Private Message key management (client_prvmsg.c) */
+/* Private Message key management */
/****f* silcclient/SilcClientAPI/silc_client_add_private_message_key
*
SilcUInt32 key_count);
-/* Channel private key management (client_channel.c,
- SilcChannelPrivateKey is defined in idlist.h) */
+/* Channel private key management */
/****f* silcclient/SilcClientAPI/silc_client_add_channel_private_key
*
***/
SilcClientFileError
silc_client_file_send(SilcClient client,
- SilcClientConnection conn,
+ SilcClientEntry client_entry,
+ SilcClientConnectionParams *params,
+ SilcPublicKey public_key,
+ SilcPrivateKey private_key,
SilcClientFileMonitor monitor,
void *monitor_context,
- const char *local_ip,
- SilcUInt32 local_port,
- SilcBool do_not_bind,
- SilcClientEntry client_entry,
const char *filepath,
SilcUInt32 *session_id);