From: Pekka Riikonen Date: Sat, 22 Nov 2008 16:14:35 +0000 (+0200) Subject: Merge branch 'master' of git://valera-ext.nynaeve.net/silc into silc.1.1.branch X-Git-Tag: silc.toolkit.1.1.9~17 X-Git-Url: http://git.silcnet.org/gitweb/?a=commitdiff_plain;h=3192ac4ddd09cd3fabe10a88cd5c885f217650a4;hp=5c43a88e369950a34b1c40d655b598bedd16beda;p=silc.git Merge branch 'master' of git://valera-ext.nynaeve.net/silc into silc.1.1.branch Code cleanup during merge. Reverted External IP commit Reverted changes to silcsocketstream API. The user context can be now set to SilcClientConnectionParams. Increased shared library revision to avoid backwards incompatiblity. Signed-off-by: Pekka Riikonen --- diff --git a/apps/irssi/src/silc/core/client_ops.c b/apps/irssi/src/silc/core/client_ops.c index 2de86781..16feddc7 100644 --- a/apps/irssi/src/silc/core/client_ops.c +++ b/apps/irssi/src/silc/core/client_ops.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2001 - 2007 Pekka Riikonen + Copyright (C) 2001 - 2008 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 @@ -1440,17 +1440,18 @@ void silc_getkey_cb(bool success, void *context) } /* - * Drop our references as need be. - */ - switch (getkey->id_type) - { - case SILC_ID_CLIENT: - silc_client_unref_client(getkey->client, getkey->conn, (SilcClientEntry)getkey->entry); - break; - - case SILC_ID_SERVER: - silc_client_unref_server(getkey->client, getkey->conn, (SilcServerEntry)getkey->entry); - break; + * Drop our references as need be. + */ + switch (getkey->id_type) { + case SILC_ID_CLIENT: + silc_client_unref_client(getkey->client, getkey->conn, + (SilcClientEntry)getkey->entry); + break; + + case SILC_ID_SERVER: + silc_client_unref_server(getkey->client, getkey->conn, + (SilcServerEntry)getkey->entry); + break; } silc_free(getkey); @@ -2112,17 +2113,16 @@ void silc_command_reply(SilcClient client, SilcClientConnection conn, ((SilcClientEntry)entry)->nickname : ((SilcServerEntry)entry)->server_name); - switch (id_type) - { - case SILC_ID_CLIENT: - name = ((SilcClientEntry)entry)->nickname; - silc_client_ref_client(client, conn, (SilcClientEntry)entry); - break; - - case SILC_ID_SERVER: - name = ((SilcServerEntry)entry)->server_name; - silc_client_ref_server(client, conn, (SilcServerEntry)entry); - break; + switch (id_type) { + case SILC_ID_CLIENT: + name = ((SilcClientEntry)entry)->nickname; + silc_client_ref_client(client, conn, (SilcClientEntry)entry); + break; + + case SILC_ID_SERVER: + name = ((SilcServerEntry)entry)->server_name; + silc_client_ref_server(client, conn, (SilcServerEntry)entry); + break; } silc_verify_public_key_internal(client, conn, name, @@ -2395,10 +2395,10 @@ typedef struct { } *PublicKeyVerify; static void verify_public_key_completion(const char *line, void *context, - SilcKeyboardPromptStatus reason) + SilcKeyboardPromptStatus reason) { PublicKeyVerify verify = (PublicKeyVerify)context; - bool success = (reason == KeyboardCompletionSuccess); + SilcBool success = (reason == KeyboardCompletionSuccess); if (success && (line[0] == 'Y' || line[0] == 'y')) { /* Call the completion */ @@ -2426,21 +2426,17 @@ static void verify_public_key_completion(const char *line, void *context, * we failed due to an overlapping callback, in which case we shouldn't * overwrite the async context block pointer. */ - - if (reason != KeyboardCompletionFailed) - { + if (reason != KeyboardCompletionFailed) { /* - * Null out the completion context in the server record as this operation - * is done as far as we are concerned. The underlying keyboard library - * routine will take care of freeing the async context memory when the - * actual callback is called by irssi in the abort case. In the success - * case, it will free the async context memory after we return from this - * routine. - */ - - SILC_SERVER_REC *server = (SILC_SERVER_REC*)(verify->conn->context); - - server->prompt_op = NULL; + * Null out the completion context in the server record as this operation + * is done as far as we are concerned. The underlying keyboard library + * routine will take care of freeing the async context memory when the + * actual callback is called by irssi in the abort case. In the success + * case, it will free the async context memory after we return from this + * routine. + */ + SILC_SERVER_REC *server = (SILC_SERVER_REC*)(verify->conn->context); + server->prompt_op = NULL; } silc_free(verify->filename); @@ -2479,48 +2475,11 @@ silc_verify_public_key_internal(SilcClient client, SilcClientConnection conn, int i; server = (SILC_SERVER_REC*)conn->context; - - /* - * If we don't have a context yet, then we'll set it up based on the - * stream context associated with the SilcPacketStream that is attached - * to the SilcClientConnection. This is a bit ugly, but we need to have a - * per-connection context value to perform the public key verify operation, - * and the public API was not designed to let us have this in a particularly - * straightforward fashion. - */ - + SILC_VERIFY(server); if (!server) { - SilcPacketStream packet_stream; - SilcStream stream; - - packet_stream = conn->stream; - - if (!packet_stream) - { - if (completion) - completion(FALSE, context); - return; - } - - stream = silc_packet_stream_get_stream(packet_stream); - - if (!stream) - { - if (completion) - completion(FALSE, context); - return; - } - - server = (SILC_SERVER_REC*)(silc_socket_stream_get_context(stream)); - - if (!server) - { - if (completion) - completion(FALSE, context); - return; - } - - conn->context = (void *)server; + if (completion) + completion(FALSE, context); + return; } if (silc_pkcs_get_type(public_key) != SILC_PKCS_SILC) { @@ -2778,7 +2737,7 @@ typedef struct { } *AskPassphrase; void ask_passphrase_completion(const char *passphrase, void *context, - SilcKeyboardPromptStatus reason) + SilcKeyboardPromptStatus reason) { AskPassphrase p = (AskPassphrase)context; if (passphrase && passphrase[0] == '\0') @@ -2786,11 +2745,9 @@ void ask_passphrase_completion(const char *passphrase, void *context, p->completion((unsigned char *)passphrase, passphrase ? strlen(passphrase) : 0, p->context); - if (reason != KeyboardCompletionFailed) - { + if (reason != KeyboardCompletionFailed) { SILC_SERVER_REC *server = (SILC_SERVER_REC *)(p->conn->context); - - server->prompt_op = NULL; + server->prompt_op = NULL; } silc_free(p); @@ -2800,14 +2757,22 @@ void silc_ask_passphrase(SilcClient client, SilcClientConnection conn, SilcAskPassphrase completion, void *context) { SILC_SERVER_REC *server = (SILC_SERVER_REC*)(conn->context); - AskPassphrase p = silc_calloc(1, sizeof(*p)); - + AskPassphrase p; + + p = silc_calloc(1, sizeof(*p)); + if (!p) { + if (completion) + completion(NULL, 0, context); + return; + } + p->completion = completion; p->conn = conn; p->context = context; silc_keyboard_entry_redirect(ask_passphrase_completion, - "Passphrase: ", ENTRY_REDIRECT_FLAG_HIDDEN, p, &server->prompt_op); + "Passphrase: ", ENTRY_REDIRECT_FLAG_HIDDEN, + p, &server->prompt_op); } typedef struct { diff --git a/apps/irssi/src/silc/core/clientutil.c b/apps/irssi/src/silc/core/clientutil.c index 9a04df91..66c8eb9a 100644 --- a/apps/irssi/src/silc/core/clientutil.c +++ b/apps/irssi/src/silc/core/clientutil.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2006 Pekka Riikonen + Copyright (C) 1997 - 2006, 2008 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 @@ -341,7 +341,7 @@ int silc_client_load_keys(SilcClient client) { char pub[256], prv[256]; struct passwd *pw; - bool ret; + SilcBool ret; SILC_LOG_DEBUG(("Loading public and private keys")); @@ -370,203 +370,179 @@ int silc_client_load_keys(SilcClient client) return ret; } -static bool silc_keyboard_prompt_pending; +static SilcBool silc_keyboard_prompt_pending; -typedef struct -{ - SilcAsyncOperation async_context; - SILC_KEYBOARD_PROMPT_PROC user_prompt_proc; - void *user_context; - bool aborted; - bool *immediate_completion; -} * SilcKeyboardEntryRedirectContext; - -static void silc_keyboard_entry_redirect_abort( - SilcAsyncOperation op, - void *context) -{ - SilcKeyboardEntryRedirectContext ctx = (SilcKeyboardEntryRedirectContext)context; - - /* - * Flag ourselves as aborted so the irssi callback doesn't do any real - * work here. - */ - - ctx->aborted = TRUE; - - /* - * Call the user routine to notify it that we are aborting, so that it may - * clean up anything that needs cleaning up, e.g. references. The user - * may not reference the SilcAsyncOperation beyond this abort call. The - * recommended procedure is for the user prompt routine to null out its - * reference to the SilcAsyncOperation context. The underlying context - * structure will be released when the actual wrappered callback fires, - * though the wrappered callback will not call into user code now that - * the operation has been aborted. - */ - - ctx->user_prompt_proc(NULL, ctx->user_context, KeyboardCompletionAborted); -} +typedef struct { + SilcAsyncOperation async_context; + SILC_KEYBOARD_PROMPT_PROC user_prompt_proc; + void *user_context; + SilcBool aborted; + SilcBool *immediate_completion; +} *SilcKeyboardEntryRedirectContext; -static void silc_keyboard_entry_redirect_completion( - const char *line, - void *context) +static void silc_keyboard_entry_redirect_abort(SilcAsyncOperation op, + void *context) { - SilcKeyboardEntryRedirectContext ctx = (SilcKeyboardEntryRedirectContext)context; - - /* - * If we are aborted, then don't call the user routine. Note that we - * already notified the user that they were aborted when the abort - * call was made in the first place, so the user should not have any - * dangling references at this point. - * - * Otherwise, call the user routine. - */ - - if (!ctx->aborted) - { - ctx->user_prompt_proc(line, ctx->user_context, - KeyboardCompletionSuccess); - } + SilcKeyboardEntryRedirectContext ctx = context; - /* - * If there's a flag to set on completion, such that we can detect when the - * operation finished immediately instead of being processed as a callback, - * then set that now. - */ + /* + * Flag ourselves as aborted so the irssi callback doesn't do any real + * work here. + */ + ctx->aborted = TRUE; - if (ctx->immediate_completion) - *ctx->immediate_completion = TRUE; + /* + * Call the user routine to notify it that we are aborting, so that it may + * clean up anything that needs cleaning up, e.g. references. The user + * may not reference the SilcAsyncOperation beyond this abort call. The + * recommended procedure is for the user prompt routine to null out its + * reference to the SilcAsyncOperation context. The underlying context + * structure will be released when the actual wrappered callback fires, + * though the wrappered callback will not call into user code now that + * the operation has been aborted. + */ + ctx->user_prompt_proc(NULL, ctx->user_context, KeyboardCompletionAborted); +} - /* - * Clean up our internal context structures. Note that we are considered - * responsible for handling the SilcAsyncOperation release in this model, - * unless we were aborted, in which case the abort request has released it. - */ +static void silc_keyboard_entry_redirect_completion(const char *line, + void *context) +{ + SilcKeyboardEntryRedirectContext ctx = context; - if (!ctx->aborted) - silc_async_free(ctx->async_context); + /* + * If we are aborted, then don't call the user routine. Note that we + * already notified the user that they were aborted when the abort + * call was made in the first place, so the user should not have any + * dangling references at this point. + * + * Otherwise, call the user routine. + */ + if (!ctx->aborted) { + ctx->user_prompt_proc(line, ctx->user_context, + KeyboardCompletionSuccess); + } - silc_free(ctx); + /* + * If there's a flag to set on completion, such that we can detect when the + * operation finished immediately instead of being processed as a callback, + * then set that now. + */ + if (ctx->immediate_completion) + *ctx->immediate_completion = TRUE; + + /* + * Clean up our internal context structures. Note that we are considered + * responsible for handling the SilcAsyncOperation release in this model, + * unless we were aborted, in which case the abort request has released it. + */ + if (!ctx->aborted) + silc_async_free(ctx->async_context); - /* - * Mark us as not having a keyboard prompt pending. - */ + silc_free(ctx); - silc_keyboard_prompt_pending = FALSE; + /* + * Mark us as not having a keyboard prompt pending. + */ + silc_keyboard_prompt_pending = FALSE; } /* Prompt for user input. */ -bool silc_keyboard_entry_redirect( - SILC_KEYBOARD_PROMPT_PROC prompt_func, - const char *entry, - int flags, - void *data, - SilcAsyncOperation *async) +SilcBool silc_keyboard_entry_redirect(SILC_KEYBOARD_PROMPT_PROC prompt_func, + const char *entry, + int flags, + void *data, + SilcAsyncOperation *async) { - SilcKeyboardEntryRedirectContext ctx; - bool completed_now; - - /* - * Check if we already have a keyboard prompt pending. This sucks, but - * irssi stores the keyboard prompt data in a global, and if we request - * a prompt while there is already a prompt in progress, the old prompt - * data is leaked. If irssi gets its act together, this can (and should) - * go away. - */ - - if (silc_keyboard_prompt_pending) - { - prompt_func(NULL, data, KeyboardCompletionFailed); - return FALSE; - } + SilcKeyboardEntryRedirectContext ctx; + SilcBool completed_now; + + /* + * Check if we already have a keyboard prompt pending. This sucks, but + * irssi stores the keyboard prompt data in a global, and if we request + * a prompt while there is already a prompt in progress, the old prompt + * data is leaked. If irssi gets its act together, this can (and should) + * go away. + */ + if (silc_keyboard_prompt_pending) { + prompt_func(NULL, data, KeyboardCompletionFailed); + return FALSE; + } - /* - * Allocate our context blocks. - */ + /* + * Allocate our context blocks. + */ + ctx = (SilcKeyboardEntryRedirectContext)silc_calloc(1, sizeof(*ctx)); + if (!ctx) { + prompt_func(NULL, data, KeyboardCompletionFailed); + return FALSE; + } - ctx = (SilcKeyboardEntryRedirectContext)silc_calloc(1, sizeof(*ctx)); + ctx->async_context = silc_async_alloc(silc_keyboard_entry_redirect_abort, + NULL, ctx); + if (!ctx->async_context) { + silc_free(ctx); + prompt_func(NULL, data, KeyboardCompletionFailed); + return FALSE; + } - if (!ctx) - { - prompt_func(NULL, data, KeyboardCompletionFailed); - return FALSE; - } + /* + * Initially, we don't consider ourselves as having finished. + */ + completed_now = FALSE; - ctx->async_context = silc_async_alloc(silc_keyboard_entry_redirect_abort, - NULL, ctx); + /* + * Since irssi can't handle overlapping keyboard prompt requests, block + * future requests until we are finished. N.B. This should really be + * handled inside of irssi, but this requires a breaking change to how + * keyboard callbacks are processed from an API perspective. A problem + * exists where another user could call a keyboard redirect request + * external to silc while we have one pending, and cause ours to get + * lost, in which case we will get stuck denying future prompt requests. + * + * Fortunately, nobody else seems to use keyboard prompt requests, at least + * not that I can tell. + */ + silc_keyboard_prompt_pending = TRUE; - if (!ctx->async_context) - { - silc_free(ctx); - prompt_func(NULL, data, KeyboardCompletionFailed); - return FALSE; - } + /* + * Set up the call to the irssi keyboard entry redirection facility. + */ - /* - * Initially, we don't consider ourselves as having finished. - */ - - completed_now = FALSE; - - /* - * Since irssi can't handle overlapping keyboard prompt requests, block - * future requests until we are finished. N.B. This should really be - * handled inside of irssi, but this requires a breaking change to how - * keyboard callbacks are processed from an API perspective. A problem - * exists where another user could call a keyboard redirect request - * external to silc while we have one pending, and cause ours to get - * lost, in which case we will get stuck denying future prompt requests. - * - * Fortunately, nobody else seems to use keyboard prompt requests, at least - * not that I can tell. - */ - - silc_keyboard_prompt_pending = TRUE; - - /* - * Set up the call to the irssi keyboard entry redirection facility. - */ - - ctx->user_prompt_proc = prompt_func; - ctx->user_context = data; - ctx->aborted = FALSE; - ctx->immediate_completion = &completed_now; - - keyboard_entry_redirect((SIGNAL_FUNC)silc_keyboard_entry_redirect_completion, - entry, 0, ctx); - - ctx->immediate_completion = NULL; - - /* - * If we completed immediately, then there is nothing to return as the async - * context has already been released. In this case we have completed with a - * success status, but there is no SilcAsyncOperation context to return. - */ - - if (completed_now) - { - *async = NULL; - return TRUE; - } + ctx->user_prompt_proc = prompt_func; + ctx->user_context = data; + ctx->aborted = FALSE; + ctx->immediate_completion = &completed_now; - /* - * Otherwise, we must return an async operation context to the caller, and - * we must unset the immediate_completion flag as we don't want to be - * notified anymore since we're returning out. Note that this is not safe - * if keyboard_entry_redirect can call from a different thread, but we are - * assuming that it doesn't as there's already many other things that seem - * to make this assumption. - */ + keyboard_entry_redirect((SIGNAL_FUNC)silc_keyboard_entry_redirect_completion, + entry, 0, ctx); - *async = ctx->async_context; + ctx->immediate_completion = NULL; + + /* + * If we completed immediately, then there is nothing to return as the async + * context has already been released. In this case we have completed with a + * success status, but there is no SilcAsyncOperation context to return. + */ + if (completed_now) { + *async = NULL; + return TRUE; + } - /* - * All done. Irssi will invoke the callback on this thread at a later point - * in time. - */ + /* + * Otherwise, we must return an async operation context to the caller, and + * we must unset the immediate_completion flag as we don't want to be + * notified anymore since we're returning out. Note that this is not safe + * if keyboard_entry_redirect can call from a different thread, but we are + * assuming that it doesn't as there's already many other things that seem + * to make this assumption. + */ + *async = ctx->async_context; - return TRUE; + /* + * All done. Irssi will invoke the callback on this thread at a later point + * in time. + */ + return TRUE; } #ifdef SILC_PLUGIN @@ -578,12 +554,6 @@ void create_key_passphrase(const char *answer, CREATE_KEY_REC *rec) if ((rec->passphrase == NULL) && (answer) && (*answer != '\0')) { rec->passphrase = g_strdup(answer); - /* - * This can continue to use keyboard_entry_redirect as it's a one-time at - * initialization function. If create_key_passphrase is used - * somewhere else, then this needs to be ripped out and changed to use - * the new, more correct silc_keyboard_entry_redirect. - */ keyboard_entry_redirect((SIGNAL_FUNC) create_key_passphrase, format_get_text("fe-common/silc", NULL, NULL, NULL, SILCTXT_CONFIG_PASS_ASK2), @@ -629,12 +599,6 @@ void change_private_key_passphrase(const char *answer, CREATE_KEY_REC *rec) if (rec->old == NULL) { rec->old = g_strdup((answer == NULL ? "" : answer)); - /* - * This can continue to use keyboard_entry_redirect as it's a one-time at - * initialization function. If change_private_key_passphrase is used - * somewhere else, then this needs to be ripped out and changed to use - * the new, more correct silc_keyboard_entry_redirect. - */ keyboard_entry_redirect((SIGNAL_FUNC) change_private_key_passphrase, format_get_text("fe-common/silc", NULL, NULL, NULL, SILCTXT_CONFIG_PASS_ASK2), @@ -644,12 +608,6 @@ void change_private_key_passphrase(const char *answer, CREATE_KEY_REC *rec) if ((rec->passphrase == NULL) && (answer) && (*answer != '\0')) { rec->passphrase = g_strdup(answer); - /* - * This can continue to use keyboard_entry_redirect as it's a one-time at - * initialization function. If change_private_key_passphrase is used - * somewhere else, then this needs to be ripped out and changed to use - * the new, more correct silc_keyboard_entry_redirect. - */ keyboard_entry_redirect((SIGNAL_FUNC) change_private_key_passphrase, format_get_text("fe-common/silc", NULL, NULL, NULL, SILCTXT_CONFIG_PASS_ASK3), diff --git a/apps/irssi/src/silc/core/clientutil.h b/apps/irssi/src/silc/core/clientutil.h index dc60a049..4b925f2f 100644 --- a/apps/irssi/src/silc/core/clientutil.h +++ b/apps/irssi/src/silc/core/clientutil.h @@ -4,13 +4,13 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2000 Pekka Riikonen + Copyright (C) 1997 - 2000, 2008 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -31,17 +31,15 @@ void silc_client_list_pkcs(); int silc_client_check_silc_dir(); int silc_client_load_keys(SilcClient client); -typedef enum -{ - KeyboardCompletionSuccess, /* Success; keyboard data returned to callback. */ - KeyboardCompletionAborted, /* Operation was aborted after starting successfully. */ - KeyboardCompletionFailed /* Operation was not started successfully. */ +typedef enum { + KeyboardCompletionSuccess, /* Success; keyboard data returned to callback. */ + KeyboardCompletionAborted, /* Operation was aborted after starting successfully. */ + KeyboardCompletionFailed /* Operation was not started successfully. */ } SilcKeyboardPromptStatus; -typedef void (*SILC_KEYBOARD_PROMPT_PROC)( - const char *line, - void *context, - SilcKeyboardPromptStatus reason); +typedef void (*SILC_KEYBOARD_PROMPT_PROC)(const char *line, + void *context, + SilcKeyboardPromptStatus reason); /* * Prompt for keyboard input. @@ -82,12 +80,11 @@ typedef void (*SILC_KEYBOARD_PROMPT_PROC)( * keyboard redirect operation is aborted while we are still waiting for data, * then we abort all callbacks until that callback returns. */ -bool silc_keyboard_entry_redirect( - SILC_KEYBOARD_PROMPT_PROC prompt_func, - const char *entry, - int flags, - void *data, - SilcAsyncOperation *async); +SilcBool silc_keyboard_entry_redirect(SILC_KEYBOARD_PROMPT_PROC prompt_func, + const char *entry, + int flags, + void *data, + SilcAsyncOperation *async); #ifdef SILC_PLUGIN typedef struct { diff --git a/apps/irssi/src/silc/core/silc-queries.c b/apps/irssi/src/silc/core/silc-queries.c index 0da01d6b..ec29a2f3 100644 --- a/apps/irssi/src/silc/core/silc-queries.c +++ b/apps/irssi/src/silc/core/silc-queries.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2002 - 2007 Pekka Riikonen + Copyright (C) 2002 - 2008 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 @@ -33,7 +33,7 @@ #include "fe-common/core/keyboard.h" #include "fe-common/silc/module-formats.h" -static void silc_query_attributes_print_final(bool success, void *context); +static void silc_query_attributes_print_final(SilcBool success, void *context); static void silc_query_attributes_accept(const char *line, void *context, SilcKeyboardPromptStatus reason); @@ -70,7 +70,7 @@ void command_attr(const char *data, SILC_SERVER_REC *server, SilcUInt32 argc; SilcUInt32 *argv_lens, *argv_types; const char *sv; - bool allowed; + SilcBool allowed; /* Now parse all arguments */ tmp = g_strconcat("ATTR", " ", data, NULL); @@ -254,7 +254,7 @@ void silc_query_attributes_default(SilcClient client, SilcAttributeObjDevice dev; SilcAttributeObjPk pk; SilcVCardStruct vcard; - bool allowed; + SilcBool allowed; memset(&service, 0, sizeof(service)); memset(&geo, 0, sizeof(geo)); @@ -559,8 +559,8 @@ typedef struct { SilcVCardStruct vcard; SilcMime message; SilcMime extension; - bool nopk; - bool autoaccept; + SilcBool nopk; + SilcBool autoaccept; } *AttrVerify; void silc_query_attributes_print(SILC_SERVER_REC *server, @@ -920,7 +920,7 @@ void silc_query_attributes_print(SILC_SERVER_REC *server, } } -static void silc_query_attributes_print_final(bool success, void *context) +static void silc_query_attributes_print_final(SilcBool success, void *context) { AttrVerify verify = context; SILC_SERVER_REC *server = verify->server; @@ -970,7 +970,7 @@ static void silc_query_attributes_print_final(bool success, void *context) format, 0, verify, &server->prompt_op); } else { /* Save new data to existing directory */ - verify->autoaccept = TRUE; /* Ensure we don't twiddle the async context */ + verify->autoaccept = TRUE; /* Ensure we don't twiddle the async context */ silc_query_attributes_accept("Y", verify, KeyboardCompletionSuccess); } @@ -987,7 +987,7 @@ static void silc_query_attributes_accept(const char *line, void *context, unsigned char filename[256], filename2[256], *fingerprint = NULL, *tmp; SilcUInt32 len; int i; - bool success = (reason == KeyboardCompletionSuccess); + SilcBool success = (reason == KeyboardCompletionSuccess); if (success && (line[0] == 'Y' || line[0] == 'y')) { /* Save the attributes */ diff --git a/apps/irssi/src/silc/core/silc-servers.c b/apps/irssi/src/silc/core/silc-servers.c index e763b8ee..9dd1c8e2 100644 --- a/apps/irssi/src/silc/core/silc-servers.c +++ b/apps/irssi/src/silc/core/silc-servers.c @@ -1,7 +1,7 @@ /* silc-server.c : irssi - Copyright (C) 2000 - 2007 Timo Sirainen + Copyright (C) 2000 - 2008 Timo Sirainen Pekka Riikonen This program is free software; you can redistribute it and/or modify @@ -415,6 +415,7 @@ static void sig_connected_stream_created(SilcSocketStreamStatus status, params.timeout_secs = settings_get_int("key_exchange_timeout_secs"); params.rekey_secs = settings_get_int("key_exchange_rekey_secs"); params.pfs = settings_get_bool("key_exchange_rekey_pfs"); + params.context = server; /* Try to read detached session data and use it if found. */ file = silc_get_session_filename(server); @@ -426,22 +427,6 @@ static void sig_connected_stream_created(SilcSocketStreamStatus status, SILCTXT_REATTACH, server->tag); silc_free(file); - /* - * Store the SILC_SERVER_REC in the stream context so that we can fetch it - * from the verify key exchange prompt. There should have been an initial - * user parameter value for the SilcClientConnection that could have been - * passed to SilcClientConnectionParams, but because there's no version - * number or size field in SilcClientConnectionParams, it is fixed for all - * time and not extendable. - * - * Instead, we must revert to pulling the SilcStream out of the - * SilcPacketStream associated with the SilcClientConnection object in the - * verify key exchange prompt callback in order to get our per-connection - * context. Hence, the extra levels of indirection. - */ - - silc_socket_stream_set_context(stream, server); - /* Start key exchange */ server->op = silc_client_key_exchange(silc_client, ¶ms, irssi_pubkey, irssi_privkey, @@ -485,7 +470,7 @@ static void sig_disconnected(SILC_SERVER_REC *server) /* If we have a prompt in progress, then abort it. */ if (server->prompt_op) { silc_async_abort(server->prompt_op, NULL, NULL); - server->prompt_op = NULL; + server->prompt_op = NULL; } if (server->conn) { diff --git a/apps/silcd/packet_receive.c b/apps/silcd/packet_receive.c index 06e5bcd9..ab174e4f 100644 --- a/apps/silcd/packet_receive.c +++ b/apps/silcd/packet_receive.c @@ -20,7 +20,6 @@ #include "serverincludes.h" #include "server_internal.h" -#include /* Received notify packet. Server can receive notify packets from router. Server then relays the notify messages to clients if needed. */ @@ -327,7 +326,7 @@ static void silc_server_notify_process(SilcServer server, tmp_len = 128; /* Update statistics */ - assert(server->stat.clients > 0); + SILC_VERIFY(server->stat.clients > 0); server->stat.clients--; if (server->stat.cell_clients) server->stat.cell_clients--; @@ -1247,7 +1246,7 @@ static void silc_server_notify_process(SilcServer server, } /* Update statistics */ - assert(server->stat.clients > 0); + SILC_VERIFY(server->stat.clients > 0); server->stat.clients--; if (server->stat.cell_clients) server->stat.cell_clients--; @@ -1493,7 +1492,7 @@ static void silc_server_notify_process(SilcServer server, } /* Update statistics */ - assert(server->stat.clients > 0); + SILC_VERIFY(server->stat.clients > 0); server->stat.clients--; if (server->stat.cell_clients) server->stat.cell_clients--; @@ -3737,7 +3736,7 @@ void silc_server_resume_client(SilcServer server, /* Delete this current client entry since we're resuming to old one. */ server->stat.my_clients--; - assert(server->stat.clients > 0); + SILC_VERIFY(server->stat.clients > 0); server->stat.clients--; if (server->stat.cell_clients) server->stat.cell_clients--; diff --git a/apps/silcd/server.c b/apps/silcd/server.c index 0da85e54..c9825e00 100644 --- a/apps/silcd/server.c +++ b/apps/silcd/server.c @@ -19,7 +19,6 @@ #include "serverincludes.h" #include "server_internal.h" -#include /************************* Types and definitions ****************************/ @@ -768,7 +767,6 @@ SilcBool silc_server_init(SilcServer server) SilcNetListener listener; SilcUInt16 *port; char **ip; - char *external_ip; SILC_LOG_DEBUG(("Initializing server")); @@ -872,11 +870,8 @@ SilcBool silc_server_init(SilcServer server) /* Create a Server ID for the server. */ port = silc_net_listener_get_port(listener, NULL); ip = silc_net_listener_get_ip(listener, NULL); - external_ip = server->config->server_info->external_ip ? - server->config->server_info->external_ip : - server->config->server_info->primary->public_ip; - silc_id_create_server_id(external_ip ? - external_ip : + silc_id_create_server_id(server->config->server_info->primary->public_ip ? + server->config->server_info->primary->public_ip : ip[0], port[0], server->rng, &id); if (!id) goto err; @@ -3136,7 +3131,7 @@ void silc_server_free_client_data(SilcServer server, /* Update statistics */ server->stat.my_clients--; - assert(server->stat.clients > 0); + SILC_VERIFY(server->stat.clients > 0); server->stat.clients--; if (server->stat.cell_clients) server->stat.cell_clients--; diff --git a/apps/silcd/server_util.c b/apps/silcd/server_util.c index 28e33ed1..9bcc47b2 100644 --- a/apps/silcd/server_util.c +++ b/apps/silcd/server_util.c @@ -20,7 +20,6 @@ #include "serverincludes.h" #include "server_internal.h" -#include extern char *server_version; @@ -120,7 +119,7 @@ silc_server_remove_clients_channels(SilcServer server, silc_hash_table_add(channels, channel, channel); } silc_hash_table_list_reset(&htl); - assert(!silc_hash_table_count(client->channels)); + SILC_VERIFY(!silc_hash_table_count(client->channels)); } /* This function removes all client entries that are originated from @@ -206,7 +205,7 @@ SilcBool silc_server_remove_clients_by_server(SilcServer server, } /* Update statistics */ - assert(server->stat.clients > 0); + SILC_VERIFY(server->stat.clients > 0); server->stat.clients--; if (server->stat.cell_clients) server->stat.cell_clients--; @@ -270,7 +269,7 @@ SilcBool silc_server_remove_clients_by_server(SilcServer server, } /* Update statistics */ - assert(server->stat.clients > 0); + SILC_VERIFY(server->stat.clients > 0); server->stat.clients--; if (server->stat.cell_clients) server->stat.cell_clients--; @@ -1563,7 +1562,7 @@ void silc_server_kill_client(SilcServer server, } } else { /* Update statistics */ - assert(server->stat.clients > 0); + SILC_VERIFY(server->stat.clients > 0); server->stat.clients--; if (server->stat.cell_clients) server->stat.cell_clients--; diff --git a/apps/silcd/serverconfig.c b/apps/silcd/serverconfig.c index 6e49475a..30d76af3 100644 --- a/apps/silcd/serverconfig.c +++ b/apps/silcd/serverconfig.c @@ -595,10 +595,6 @@ SILC_CONFIG_CALLBACK(fetch_serverinfo) CONFIG_IS_DOUBLE(server_info->server_type); server_info->server_type = strdup((char *) val); } - else if (!strcmp(name, "externalip")) { - CONFIG_IS_DOUBLE(server_info->external_ip); - server_info->external_ip = strdup((char *) val); - } else if (!strcmp(name, "admin")) { CONFIG_IS_DOUBLE(server_info->admin); server_info->admin = strdup((char *) val); @@ -1260,7 +1256,6 @@ static const SilcConfigTable table_serverinfo[] = { { "primary", SILC_CONFIG_ARG_BLOCK, fetch_serverinfo, table_serverinfo_c}, { "secondary", SILC_CONFIG_ARG_BLOCK, fetch_serverinfo, table_serverinfo_c}, { "servertype", SILC_CONFIG_ARG_STR, fetch_serverinfo, NULL}, - { "externalip", SILC_CONFIG_ARG_STR, fetch_serverinfo, NULL}, { "location", SILC_CONFIG_ARG_STR, fetch_serverinfo, NULL}, { "admin", SILC_CONFIG_ARG_STR, fetch_serverinfo, NULL}, { "adminemail", SILC_CONFIG_ARG_STR, fetch_serverinfo, NULL}, @@ -1644,7 +1639,6 @@ void silc_server_config_destroy(SilcServerConfig config) silc_free(di); } silc_free(si->server_type); - silc_free(si->external_ip); silc_free(si->location); silc_free(si->admin); silc_free(si->email); diff --git a/apps/silcd/serverconfig.h b/apps/silcd/serverconfig.h index 5c77b8d2..183f6501 100644 --- a/apps/silcd/serverconfig.h +++ b/apps/silcd/serverconfig.h @@ -59,7 +59,6 @@ typedef struct SilcServerConfigServerInfoStruct { char *server_name; SilcServerConfigServerInfoInterface *primary; SilcServerConfigServerInfoInterface *secondary; - char *external_ip; /* E.g. public IP if we're in a NAT */ char *server_type; /* E.g. "Test Server" */ char *location; /* geographic location */ char *admin; /* admin full name */ diff --git a/lib/configure.ad b/lib/configure.ad index 6f381c7b..7badb52e 100644 --- a/lib/configure.ad +++ b/lib/configure.ad @@ -88,8 +88,8 @@ LIBSILC_REVISION=0 # prev = 1 LIBSILC_AGE=1 # prev = 1 # libsilcclient versions -LIBSILCCLIENT_CURRENT=2 # prev = 1 -LIBSILCCLIENT_REVISION=1 # prev = 1 +LIBSILCCLIENT_CURRENT=3 # prev = 2 +LIBSILCCLIENT_REVISION=0 # prev = 1 LIBSILCCLIENT_AGE=0 # prev = 0 # libsilcserver versions diff --git a/lib/silcclient/client.c b/lib/silcclient/client.c index 3ab7ba17..2c731ebd 100644 --- a/lib/silcclient/client.c +++ b/lib/silcclient/client.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2007 Pekka Riikonen + Copyright (C) 1997 - 2008 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 @@ -621,8 +621,10 @@ silc_client_add_connection(SilcClient client, } /* Set parameters */ - if (params) + if (params) { conn->internal->params = *params; + conn->context = params->context; + } if (!conn->internal->params.rekey_secs) conn->internal->params.rekey_secs = 3600; #ifndef SILC_DIST_INPLACE diff --git a/lib/silcclient/client.h b/lib/silcclient/client.h index 542b6329..8c989553 100644 --- a/lib/silcclient/client.h +++ b/lib/silcclient/client.h @@ -101,8 +101,9 @@ typedef struct SilcServerEntryInternalStruct { SilcRwLock lock; /* Read/write lock */ SilcUInt16 resolve_cmd_ident; /* Resolving identifier */ SilcAtomic32 refcnt; /* Reference counter */ - SilcAtomic32 deleted; /* Flag indicating whether the server object is - already scheduled for deletion.*/ + SilcAtomic32 deleted; /* Flag indicating whether the + server object is already + scheduled for deletion. */ } SilcServerEntryInternal; #endif /* CLIENT_H */ diff --git a/lib/silcclient/client_entry.c b/lib/silcclient/client_entry.c index 64810b75..a7ec24ee 100644 --- a/lib/silcclient/client_entry.c +++ b/lib/silcclient/client_entry.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2001 - 2007 Pekka Riikonen + Copyright (C) 2001 - 2008 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 @@ -815,9 +815,9 @@ SilcClientEntry silc_client_add_client(SilcClient client, NULL, NULL, NULL, TRUE); if (!client_entry->channels) { silc_free(client_entry->realname); - silc_atomic_uninit32(&client_entry->internal.deleted); - silc_atomic_uninit32(&client_entry->internal.refcnt); - silc_rwlock_free(client_entry->internal.lock); + silc_atomic_uninit32(&client_entry->internal.deleted); + silc_atomic_uninit32(&client_entry->internal.refcnt); + silc_rwlock_free(client_entry->internal.lock); silc_free(client_entry); return NULL; } @@ -829,9 +829,9 @@ SilcClientEntry silc_client_add_client(SilcClient client, if (!nick) { silc_hash_table_free(client_entry->channels); silc_free(client_entry->realname); - silc_atomic_uninit32(&client_entry->internal.deleted); - silc_atomic_uninit32(&client_entry->internal.refcnt); - silc_rwlock_free(client_entry->internal.lock); + silc_atomic_uninit32(&client_entry->internal.deleted); + silc_atomic_uninit32(&client_entry->internal.refcnt); + silc_rwlock_free(client_entry->internal.lock); silc_free(client_entry); return NULL; } @@ -845,9 +845,9 @@ SilcClientEntry silc_client_add_client(SilcClient client, silc_free(nick); silc_hash_table_free(client_entry->channels); silc_free(client_entry->realname); - silc_atomic_uninit32(&client_entry->internal.deleted); - silc_atomic_uninit32(&client_entry->internal.refcnt); - silc_rwlock_free(client_entry->internal.lock); + silc_atomic_uninit32(&client_entry->internal.deleted); + silc_atomic_uninit32(&client_entry->internal.refcnt); + silc_rwlock_free(client_entry->internal.lock); silc_free(client_entry); silc_mutex_unlock(conn->internal->lock); return NULL; @@ -1661,7 +1661,7 @@ SilcChannelEntry silc_client_add_channel(SilcClient client, if (!channel->channel_name) { silc_rwlock_free(channel->internal.lock); silc_atomic_uninit32(&channel->internal.refcnt); - silc_atomic_uninit32(&channel->internal.deleted); + silc_atomic_uninit32(&channel->internal.deleted); silc_free(channel); return NULL; } @@ -1671,7 +1671,7 @@ SilcChannelEntry silc_client_add_channel(SilcClient client, if (!channel->user_list) { silc_rwlock_free(channel->internal.lock); silc_atomic_uninit32(&channel->internal.refcnt); - silc_atomic_uninit32(&channel->internal.deleted); + silc_atomic_uninit32(&channel->internal.deleted); silc_free(channel->channel_name); silc_free(channel); return NULL; @@ -1683,7 +1683,7 @@ SilcChannelEntry silc_client_add_channel(SilcClient client, if (!channel_namec) { silc_rwlock_free(channel->internal.lock); silc_atomic_uninit32(&channel->internal.refcnt); - silc_atomic_uninit32(&channel->internal.deleted); + silc_atomic_uninit32(&channel->internal.deleted); silc_free(channel->channel_name); silc_hash_table_free(channel->user_list); silc_free(channel); @@ -1697,7 +1697,7 @@ SilcChannelEntry silc_client_add_channel(SilcClient client, &channel->id, channel)) { silc_rwlock_free(channel->internal.lock); silc_atomic_uninit32(&channel->internal.refcnt); - silc_atomic_uninit32(&channel->internal.deleted); + silc_atomic_uninit32(&channel->internal.deleted); silc_free(channel_namec); silc_free(channel->channel_name); silc_hash_table_free(channel->user_list); @@ -2149,11 +2149,7 @@ SilcBool silc_client_del_server(SilcClient client, SilcClientConnection conn, return FALSE; if (silc_atomic_sub_int32(&server->internal.deleted, 1) != 0) - { - SILC_LOG_DEBUG(("** WARNING ** Deleting a server twice %p", server)); -// asm("int3"); - return FALSE; - } + return FALSE; silc_client_unref_server(client, conn, server); return TRUE; diff --git a/lib/silcclient/silcclient.h b/lib/silcclient/silcclient.h index 898204a1..00d0b5e5 100644 --- a/lib/silcclient/silcclient.h +++ b/lib/silcclient/silcclient.h @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2000 - 2007 Pekka Riikonen + Copyright (C) 2000 - 2008 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 @@ -943,6 +943,10 @@ typedef struct SilcClientConnectionParamsStruct { silc_client_attribute_add for more information on attributes. */ SilcBool ignore_requested_attributes; + /* User context for SilcClientConnection. If non-NULL this context is + set to the 'context' field in SilcClientConnection when the connection + context is created. */ + void *context; } SilcClientConnectionParams; /***/ diff --git a/lib/silcserver/server_util.c b/lib/silcserver/server_util.c index ef85275c..6b5b38eb 100644 --- a/lib/silcserver/server_util.c +++ b/lib/silcserver/server_util.c @@ -21,7 +21,6 @@ #include "silc.h" #include "silcserver.h" #include "server_internal.h" -#include /* Return next available command identifier. */ diff --git a/lib/silcske/silcske.c b/lib/silcske/silcske.c index 1987ffc2..a4822e95 100644 --- a/lib/silcske/silcske.c +++ b/lib/silcske/silcske.c @@ -73,7 +73,41 @@ static SilcBool silc_ske_packet_send(SilcSKE ske, const unsigned char *data, SilcUInt32 data_len); -static void silc_ske_notify_failure(SilcSKE ske); +/* + * Notify the owner of the ske that we failed. Ensures that we don't make the + * same callout twice, as the notification callback routines are not designed + * to handle that case. + */ +static void silc_ske_notify_failure(SilcSKE ske) +{ + SILC_LOG_DEBUG(("Notifying SKE %p owner of failure (failure_notified = %lu)", + ske, ske->failure_notified)); + + /* + * First, check if we have already made a failure callout. If so, then we + * will stop here. + */ + if (ske->failure_notified) + return; + + /* + * Mark ourselves as having already sent the failure notification here and + * now. + */ + ske->failure_notified = TRUE; + + SILC_LOG_DEBUG(("Deliver failure notification for SKE %p (%s)", + ske, ske->responder ? "responder" : "initiator")); + + /* + * Finally, make the call to the owner's registered failure callback. + */ + if (ske->responder) + silc_fsm_next(&ske->fsm, silc_ske_st_responder_failure); + else + silc_fsm_next(&ske->fsm, silc_ske_st_initiator_failure); +} + /* Packet callback */ static SilcBool silc_ske_packet_receive(SilcPacketEngine engine, @@ -108,9 +142,8 @@ static SilcBool silc_ske_packet_receive(SilcPacketEngine engine, } /* See if received failure from remote */ - if (packet->type == SILC_PACKET_FAILURE) { + if (packet->type == SILC_PACKET_FAILURE) silc_ske_notify_failure(ske); - } /* Handle rekey and SUCCESS packets synchronously. After SUCCESS packets they keys are taken into use immediately, hence the synchronous @@ -968,8 +1001,7 @@ static void silc_ske_finished(SilcFSM fsm, void *fsm_context, void *destructor_context) { SilcSKE ske = fsm_context; - ske->fsm_finished = TRUE; - silc_ske_free(ske); + silc_ske_free(ske); } /* Key exchange timeout task callback */ @@ -1030,28 +1062,28 @@ void silc_ske_free(SilcSKE ske) if (!ske) return; - SILC_LOG_DEBUG(("Freeing Key Exchange object %p: aborted=%u refcount=%hu", ske, ske->aborted, ske->refcnt)); - - if (ske->aborted) { - /* - * If already aborted, destroy the session immediately. Only do the - * notification work if we have not already though, as doing so twice - * results in memory corruption. We may have silc_ske_free called - * twice, once when the abort is requested, and then again when the - * FSM finish routine is called. We have to be prepared to handle - * that case. - */ + SILC_LOG_DEBUG(("Freeing Key Exchange object %p: aborted=%u refcount=%hu", + ske, ske->aborted, ske->refcnt)); - ske->packet = NULL; - ske->status = SILC_SKE_STATUS_ERROR; + if (ske->aborted) { + /* + * If already aborted, destroy the session immediately. Only do the + * notification work if we have not already though, as doing so twice + * results in memory corruption. We may have silc_ske_free called + * twice, once when the abort is requested, and then again when the + * FSM finish routine is called. We have to be prepared to handle + * that case. + */ + ske->packet = NULL; + ske->status = SILC_SKE_STATUS_ERROR; - silc_ske_notify_failure(ske); + silc_ske_notify_failure(ske); - if (!ske->fsm_finished) - silc_fsm_continue_sync(&ske->fsm); - else - SILC_LOG_DEBUG(("Not continuing FSM as it's finished for SKE %p", ske)); - } + if (silc_fsm_is_started(&ske->fsm)) + silc_fsm_continue_sync(&ske->fsm); + else + SILC_LOG_DEBUG(("Not continuing FSM as it's finished for SKE %p", ske)); + } ske->refcnt--; if (ske->refcnt > 0) @@ -1801,7 +1833,8 @@ SilcAsyncOperation silc_ske_initiator(SilcSKE ske, SilcSKEParams params, SilcSKEStartPayload start_payload) { - SILC_LOG_DEBUG(("Start SKE %p as initiator; stream=%p; params=%p; start_payload=%p", ske, stream, params, start_payload)); + SILC_LOG_DEBUG(("Start SKE %p as initiator; stream=%p; params=%p; " + "start_payload=%p", ske, stream, params, start_payload)); if (!ske || !stream || !params || !params->version) return NULL; @@ -3497,40 +3530,3 @@ SilcSKEKeyMaterial silc_ske_get_key_material(SilcSKE ske) { return ske->keymat; } - -/* - * Notify the owner of the ske that we failed. Ensures that we don't make the - * same callout twice, as the notification callback routines are not designed - * to handle that case. - */ -static void silc_ske_notify_failure(SilcSKE ske) -{ - SILC_LOG_DEBUG(("Notifying SKE %p owner of failure (failure_notified = %lu)", ske, ske->failure_notified)); - - /* - * First, check if we have already made a failure callout. If so, then we - * will stop here. - */ - - if (ske->failure_notified) - return; - - /* - * Mark ourselves as having already sent the failure notification here and - * now. - */ - - ske->failure_notified = TRUE; - - SILC_LOG_DEBUG(("Actually calling real failure notify callback for SKE %p (responder = %s)", ske, ske->responder ? "TRUE" : "FALSE")); - - /* - * Finally, make the call to the owner's registered failure callback. - */ - - if (ske->responder) - silc_fsm_next(&ske->fsm, silc_ske_st_responder_failure); - else - silc_fsm_next(&ske->fsm, silc_ske_st_initiator_failure); -} - diff --git a/lib/silcske/silcske_i.h b/lib/silcske/silcske_i.h index 572b0837..b7b6e2e7 100644 --- a/lib/silcske/silcske_i.h +++ b/lib/silcske/silcske_i.h @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2005 - 2007 Pekka Riikonen + Copyright (C) 2005 - 2008 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 @@ -90,11 +90,11 @@ struct SilcSKEStruct { SilcUInt16 timeout; /* SKE timeout */ SilcUInt16 refcnt; /* Reference counter */ - unsigned int aborted : 1; /* Set when SKE aborted */ - unsigned int responder : 1; /* Set when we are responder side */ - unsigned int rekeying : 1; /* Set when rekeying */ - unsigned int failure_notified : 1; /* Set to indicate that we already called the failure notify routine */ - unsigned int fsm_finished : 1; /* Set when we're in FSM teardown */ + unsigned int aborted : 1; /* Set when SKE aborted */ + unsigned int responder : 1; /* Set when we are responder side */ + unsigned int rekeying : 1; /* Set when rekeying */ + unsigned int failure_notified : 1; /* Set to indicate that we already called + the failure notify routine */ }; #endif /* SILCSKE_I_H */ diff --git a/lib/silcutil/silcsocketstream.c b/lib/silcutil/silcsocketstream.c index 06d55484..af8f2c34 100644 --- a/lib/silcutil/silcsocketstream.c +++ b/lib/silcutil/silcsocketstream.c @@ -392,33 +392,6 @@ SilcSchedule silc_socket_stream_get_schedule(SilcStream stream) return socket_stream->schedule; } -/* Return associated context. */ - -void * -silc_socket_stream_get_context(SilcStream stream) -{ - SilcSocketStream socket_stream = stream; - - if (!SILC_IS_SOCKET_STREAM(socket_stream)) - return NULL; - - return socket_stream->user_context; -} - -/* Set associated context. */ - -void -silc_socket_stream_set_context(SilcStream stream, - void *context) -{ - SilcSocketStream socket_stream = stream; - - if (!SILC_IS_SOCKET_STREAM(socket_stream)) - return; - - socket_stream->user_context = context; -} - /* SILC Socket Stream ops. Functions are implemented under the platform specific subdirectories. */ const SilcStreamOps silc_socket_stream_ops = diff --git a/lib/silcutil/silcsocketstream.h b/lib/silcutil/silcsocketstream.h index 264668ca..e9fd4357 100644 --- a/lib/silcutil/silcsocketstream.h +++ b/lib/silcutil/silcsocketstream.h @@ -275,41 +275,6 @@ SilcBool silc_socket_stream_set_qos(SilcStream stream, SilcUInt32 limit_sec, SilcUInt32 limit_usec); - -/****f* silcutil/SilcSocketStreamAPI/silc_socket_stream_get_context - * - * SYNOPSIS - * - * void * - * silc_socket_stream_get_context(SilcSocketStream stream); - * - * DESCRIPTION - * - * Returns the context associated with a stream. This context is - * set via silc_socket_stream_set_context. - * - ***/ -void * -silc_socket_stream_get_context(SilcStream stream); - -/****f* silcutil/SilcSocketStreamAPI/silc_socket_stream_set_context - * - * SYNOPSIS - * - * void - * silc_socket_stream_set_context(SilcSocketStream stream, - * void *context); - * - * DESCRIPTION - * - * Returns the context associated with a stream. This context is - * set via silc_socket_stream_set_context. - * - ***/ -void -silc_socket_stream_set_context(SilcStream stream, - void *context); - #include "silcsocketstream_i.h" #endif /* SILCSOCKETSTREAM_H */ diff --git a/lib/silcutil/silcsocketstream_i.h b/lib/silcutil/silcsocketstream_i.h index 837cc239..13013f25 100644 --- a/lib/silcutil/silcsocketstream_i.h +++ b/lib/silcutil/silcsocketstream_i.h @@ -52,7 +52,6 @@ struct SilcSocketStreamStruct { SilcSocketQos qos; SilcStreamNotifier notifier; void *notifier_context; - void *user_context; unsigned int ipv6 : 1; /* UDP IPv6 */ unsigned int connected : 1; /* UDP connected state */ };