[Pkg-silc-commits] r116 - in /silc-server/branches/upstream/current: ./ apps/ apps/silcd/ doc/ includes/ lib/ lib/contrib/ lib/silcapputil/ lib/silcasn1/ lib/silccore/ lib/silccrypt/ lib/silchttp/ lib/silcmath/ lib/silcsim/ lib/silcske/ lib/silcskr/ lib/silcutil/ lib/silcutil/unix/ lib/silcvcard/

lunar at users.alioth.debian.org lunar at users.alioth.debian.org
Sun Jul 1 19:18:19 UTC 2007


Author: lunar
Date: Sun Jul  1 19:18:19 2007
New Revision: 116

URL: http://svn.debian.org/wsvn/pkg-silc/?sc=1&rev=116
Log:
[svn-upgrade] Integrating new upstream version, silc-server (1.1~beta1)

Modified:
    silc-server/branches/upstream/current/CHANGES
    silc-server/branches/upstream/current/Makefile.am
    silc-server/branches/upstream/current/Makefile.in
    silc-server/branches/upstream/current/apps/Makefile.am
    silc-server/branches/upstream/current/apps/Makefile.in
    silc-server/branches/upstream/current/apps/silcd/Makefile.in
    silc-server/branches/upstream/current/apps/silcd/command.c
    silc-server/branches/upstream/current/apps/silcd/command_reply.c
    silc-server/branches/upstream/current/apps/silcd/idlist.c
    silc-server/branches/upstream/current/apps/silcd/idlist.h
    silc-server/branches/upstream/current/apps/silcd/packet_receive.c
    silc-server/branches/upstream/current/apps/silcd/server.c
    silc-server/branches/upstream/current/apps/silcd/server.h
    silc-server/branches/upstream/current/apps/silcd/server_backup.c
    silc-server/branches/upstream/current/apps/silcd/server_http.c
    silc-server/branches/upstream/current/apps/silcd/server_internal.h
    silc-server/branches/upstream/current/apps/silcd/server_query.c
    silc-server/branches/upstream/current/apps/silcd/server_util.c
    silc-server/branches/upstream/current/apps/silcd/server_util.h
    silc-server/branches/upstream/current/apps/silcd/serverconfig.c
    silc-server/branches/upstream/current/apps/silcd/serverconfig.h
    silc-server/branches/upstream/current/apps/silcd/serverid.c
    silc-server/branches/upstream/current/apps/silcd/silcd.c
    silc-server/branches/upstream/current/configure
    silc-server/branches/upstream/current/configure.ac
    silc-server/branches/upstream/current/doc/Makefile.am
    silc-server/branches/upstream/current/doc/Makefile.in
    silc-server/branches/upstream/current/includes/Makefile.am
    silc-server/branches/upstream/current/includes/Makefile.in
    silc-server/branches/upstream/current/includes/silcdistdefs.h
    silc-server/branches/upstream/current/includes/silcversion.h.in
    silc-server/branches/upstream/current/lib/Makefile.am
    silc-server/branches/upstream/current/lib/Makefile.in
    silc-server/branches/upstream/current/lib/contrib/Makefile.am
    silc-server/branches/upstream/current/lib/contrib/Makefile.in
    silc-server/branches/upstream/current/lib/silcapputil/Makefile.am
    silc-server/branches/upstream/current/lib/silcapputil/Makefile.in
    silc-server/branches/upstream/current/lib/silcapputil/silcapputil.c
    silc-server/branches/upstream/current/lib/silcapputil/silcidcache.c
    silc-server/branches/upstream/current/lib/silcapputil/silcidcache.h
    silc-server/branches/upstream/current/lib/silcasn1/Makefile.am
    silc-server/branches/upstream/current/lib/silcasn1/Makefile.in
    silc-server/branches/upstream/current/lib/silcasn1/silcasn1_decode.c
    silc-server/branches/upstream/current/lib/silcasn1/silcasn1_encode.c
    silc-server/branches/upstream/current/lib/silccore/Makefile.am
    silc-server/branches/upstream/current/lib/silccore/Makefile.in
    silc-server/branches/upstream/current/lib/silccore/silcargument.c
    silc-server/branches/upstream/current/lib/silccore/silcnotify.c
    silc-server/branches/upstream/current/lib/silccore/silcpacket.c
    silc-server/branches/upstream/current/lib/silccore/silcpacket.h
    silc-server/branches/upstream/current/lib/silccrypt/Makefile.am
    silc-server/branches/upstream/current/lib/silccrypt/Makefile.in
    silc-server/branches/upstream/current/lib/silchttp/Makefile.am
    silc-server/branches/upstream/current/lib/silchttp/Makefile.in
    silc-server/branches/upstream/current/lib/silcmath/Makefile.am
    silc-server/branches/upstream/current/lib/silcmath/Makefile.in
    silc-server/branches/upstream/current/lib/silcsim/Makefile.am
    silc-server/branches/upstream/current/lib/silcsim/Makefile.in
    silc-server/branches/upstream/current/lib/silcske/Makefile.am
    silc-server/branches/upstream/current/lib/silcske/Makefile.in
    silc-server/branches/upstream/current/lib/silcske/silcconnauth.c
    silc-server/branches/upstream/current/lib/silcske/silcske.c
    silc-server/branches/upstream/current/lib/silcske/silcske.h
    silc-server/branches/upstream/current/lib/silcskr/Makefile.am
    silc-server/branches/upstream/current/lib/silcskr/Makefile.in
    silc-server/branches/upstream/current/lib/silcskr/silcskr.c
    silc-server/branches/upstream/current/lib/silcutil/Makefile.am
    silc-server/branches/upstream/current/lib/silcutil/Makefile.in
    silc-server/branches/upstream/current/lib/silcutil/silcbuffer.h
    silc-server/branches/upstream/current/lib/silcutil/silcbuffmt.c
    silc-server/branches/upstream/current/lib/silcutil/silcdlist.h
    silc-server/branches/upstream/current/lib/silcutil/silcfsm.c
    silc-server/branches/upstream/current/lib/silcutil/silclog.c
    silc-server/branches/upstream/current/lib/silcutil/silcmime.c
    silc-server/branches/upstream/current/lib/silcutil/silcmutex.h
    silc-server/branches/upstream/current/lib/silcutil/silcnet.h
    silc-server/branches/upstream/current/lib/silcutil/silcstack.h
    silc-server/branches/upstream/current/lib/silcutil/unix/Makefile.in
    silc-server/branches/upstream/current/lib/silcutil/unix/silcunixnet.c
    silc-server/branches/upstream/current/lib/silcutil/unix/silcunixschedule.c
    silc-server/branches/upstream/current/lib/silcutil/unix/silcunixthread.c
    silc-server/branches/upstream/current/lib/silcvcard/Makefile.am
    silc-server/branches/upstream/current/lib/silcvcard/Makefile.in

Modified: silc-server/branches/upstream/current/CHANGES
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/CHANGES?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/CHANGES (original)
+++ silc-server/branches/upstream/current/CHANGES Sun Jul  1 19:18:19 2007
@@ -1,3 +1,128 @@
+Sun Jul  1 12:40:06 EEST 2007  Pekka Riikonen <priikone at silcnet.org>
+
+	* Added support for rekey with PFS when using CTR mode
+	  encryption.  Affected file is lib/silcske/silcske.c.
+
+	* Added silc_idcache_move that can be used to move entries
+	  between caches.  Affected files are
+	  lib/silcapputil/silcidcache.[ch].
+
+	* Added better checks for invalid argument and notify payloads.
+	  Affected files are lib/silccore/silcnotify.c and
+	  silcargument.c.
+
+	* Fixed SILC_PACKET_FLAG_LONG_PAD bitmask value.  Affected
+	  file lib/silccore/silcpacket.h.
+
+Sat Jun 30 21:48:08 EEST 2007  Pekka Riikonen <priikone at silcnet.org>
+
+	* Set the destination ID to packet stream as SKE responder
+	  if ID was present in key exchange packet.  Affected file
+	  is lib/silcske/silcske.[ch].
+
+	* Handle also zero timeouts in the scheduler notify callback
+	  to avoid problems with SILC Plugin.  Affected file is
+	  apps/irssi/src/silc/core/silc-core.c.
+
+Thu Jun 28 19:19:13 EEST 2007  Pekka Riikonen <priikone at silcnet.org>
+
+	* SILC Client 1.1.1.
+
+Sun Jun 24 18:47:55 EEST 2007  Pekka Riikonen <priikone at silcnet.org>
+
+	* SILC Toolkit 1.1.1.
+
+	* Compile sources with _GNU_SOURCE on Linux systems.  Affected
+	  file is configure.ad.
+
+Sun Jun 24 16:33:59 EEST 2007  Pekka Riikonen <priikone at silcnet.org>
+
+	* Fixed Unix signal task dispatching to not lock the signals
+	  when dispatching the callback to avoid deadlocks.  Affected
+	  file is lib/silcutil/unix/silcunixschedule.c.
+
+Sun Jun 24 14:43:21 CEST 2007  Jochen Eisinger <coffee at silcnet.org>
+
+	* Fix configure output for with-plugin.  Affected file is
+	  apps/irssi/configure.ad
+
+Tue Jun 19 17:05:48 EEST 2007  Pekka Riikonen <priikone at silcnet.org>
+
+	* Added SILC_VERSION macro for checking package versions at
+	  compile time.  Affected files are configure.ad,
+	  includes/silc.h.in and includes/silcversion.h.in.
+
+Mon Jun 18 23:47:22 EEST 2007  Pekka Riikonen <priikone at silcnet.org>
+
+	* Use SILC_VERIFY to assert that silc_rwlock_wrlock can be
+	  called only once per thread on Unix.  Affected file is
+	  lib/silcutil/unix/silcunixthread.c.  Added same for mutex
+	  as well.   Documented same on the API in 
+	  lib/silcutil/silcmutex.h.
+
+	* Fixed USERS command reply write-lock unlocking.  Affected file
+	  is lib/silcclient/command_reply.c.
+
+Mon Jun 18 08:14:26 EEST 2007  Pekka Riikonen <priikone at silcnet.org>
+
+	* Fixed silc_create_key_pair to check for valid identifier.
+	  Affected file is lib/silcapputil/silcapputil.c.
+
+Sun Jun 17 20:08:26 CEST 2007  Jochen Eisinger <coffee at silcnet.org>
+
+	* Rewrite signed public message handling, adopting the new
+	  hilight interface.  Affected file is
+	  apps/irssi/src/fe-common/silc/fe-silc-messages.c
+
+Thu Jun 14 21:15:31 CEST 2007  Jochen Eisinger <coffee at silcnet.org>
+
+	* Fix off by one error when loading modules.  Affected file is
+	  apps/irssi/src/core/modules-load.c
+
+	* Don't delete hilight entry (because it's just a pointer, not a
+	  copy).  Affected file is 
+	  apps/irssi/src/fe-common/silc/fe-silc-messages.c
+
+Mon Jun 11 22:10:17 EEST 2007  Pekka Riikonen <priikone at silcnet.org>
+
+	* Added __SILC_TOOLKIT_x_x_x macro to all Toolkit distribution
+	  which can be used to check for Toolkit version in third-party
+	  software.  Affected file is configure.ad, includes/silc.h.in.
+
+Sun Jun 10 17:32:15 EEST 2007  Pekka Riikonen <priikone at silcnet.org>
+
+	* Added support for channel at server channel name strings to
+	  client library (SILC protocol version 1.3 change).  Affected
+	  files are lib/silcclient/silcclient_entry.h, client_entry.c.
+
+	* Added full_nicknames and full_channel_names settings to
+	  SilcClientParams that can be used to specify whether client
+	  library returns full nickname and channel name strings.
+	  Full strings are nick at server and channel at server.  Affected
+	  file is lib/silcclient/client_entry.c and command.c.
+
+Sat Jun  9 19:43:25 EEST 2007  Pekka Riikonen <priikone at silcnet.org>
+
+	* Fixed unix connecting failure to return error code correctly.
+	  Affected file is lib/silcutil/unix/silcunixnet.c.
+
+Fri Jun  8 23:32:33 EEST 2007  Pekka Riikonen <priikone at silcnet.org>
+
+	* Fixed SKE timeout double free crash.  Affected file is
+	  lib/silcske/silcske.c.
+
+	* Fixed MIME multipart decoding buffer overflow.  Affected file
+	  is lib/silcutil/silcmime.c.  Thanks to Matt Miller for patch.
+
+Fri Jun  8 18:39:34 EEST 2007  Pekka Riikonen <priikone at silcnet.org>
+
+	* Fixed connection auth protocol timeout crash.  Affected
+	  file is lib/silcske/silconnauth.c.
+
+	* Fixed FSM machine finishing to check for existing threads
+	  at the final free callback to allow time for the threads to
+	  finish.  Affected file lib/silcutil/silcfsm.c.
+
 Thu Jun  7 21:25:31 EEST 2007  Pekka Riikonen <priikone at silcnet.org>
 
 	* Fixed silc_client_get_clients_local to check the nick's

Modified: silc-server/branches/upstream/current/Makefile.am
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/Makefile.am?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/Makefile.am (original)
+++ silc-server/branches/upstream/current/Makefile.am Sun Jul  1 19:18:19 2007
@@ -2,7 +2,7 @@
 # To make changes edit the ./Makefile.ad file in the source tree.
 
 # Source: ./Makefile.ad
-# Generated: Fri Jun  8 09:30:39 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 

Modified: silc-server/branches/upstream/current/Makefile.in
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/Makefile.in?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/Makefile.in (original)
+++ silc-server/branches/upstream/current/Makefile.in Sun Jul  1 19:18:19 2007
@@ -18,7 +18,7 @@
 # To make changes edit the ./Makefile.ad file in the source tree.
 
 # Source: ./Makefile.ad
-# Generated: Fri Jun  8 09:30:39 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 
@@ -230,6 +230,7 @@
 __SILC_ENABLE_DEBUG = @__SILC_ENABLE_DEBUG@
 __SILC_HAVE_PTHREAD = @__SILC_HAVE_PTHREAD@
 __SILC_HAVE_SIM = @__SILC_HAVE_SIM@
+__SILC_PACKAGE_VERSION = @__SILC_PACKAGE_VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@

Modified: silc-server/branches/upstream/current/apps/Makefile.am
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/apps/Makefile.am?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/apps/Makefile.am (original)
+++ silc-server/branches/upstream/current/apps/Makefile.am Sun Jul  1 19:18:19 2007
@@ -2,7 +2,7 @@
 # To make changes edit the ./apps/Makefile.ad file in the source tree.
 
 # Source: ./apps/Makefile.ad
-# Generated: Fri Jun  8 09:30:37 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:57 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 

Modified: silc-server/branches/upstream/current/apps/Makefile.in
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/apps/Makefile.in?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/apps/Makefile.in (original)
+++ silc-server/branches/upstream/current/apps/Makefile.in Sun Jul  1 19:18:19 2007
@@ -18,7 +18,7 @@
 # To make changes edit the ./apps/Makefile.ad file in the source tree.
 
 # Source: ./apps/Makefile.ad
-# Generated: Fri Jun  8 09:30:37 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:57 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 
@@ -176,6 +176,7 @@
 __SILC_ENABLE_DEBUG = @__SILC_ENABLE_DEBUG@
 __SILC_HAVE_PTHREAD = @__SILC_HAVE_PTHREAD@
 __SILC_HAVE_SIM = @__SILC_HAVE_SIM@
+__SILC_PACKAGE_VERSION = @__SILC_PACKAGE_VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@

Modified: silc-server/branches/upstream/current/apps/silcd/Makefile.in
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/apps/silcd/Makefile.in?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/apps/silcd/Makefile.in (original)
+++ silc-server/branches/upstream/current/apps/silcd/Makefile.in Sun Jul  1 19:18:19 2007
@@ -221,6 +221,7 @@
 __SILC_ENABLE_DEBUG = @__SILC_ENABLE_DEBUG@
 __SILC_HAVE_PTHREAD = @__SILC_HAVE_PTHREAD@
 __SILC_HAVE_SIM = @__SILC_HAVE_SIM@
+__SILC_PACKAGE_VERSION = @__SILC_PACKAGE_VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@

Modified: silc-server/branches/upstream/current/apps/silcd/command.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/apps/silcd/command.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/apps/silcd/command.c (original)
+++ silc-server/branches/upstream/current/apps/silcd/command.c Sun Jul  1 19:18:19 2007
@@ -16,7 +16,7 @@
   GNU General Public License for more details.
 
 */
-/* $Id: command.c,v 1.274 2007/04/28 15:10:28 priikone Exp $ */
+/* $Id: command.c,v 1.274.2.4 2007/07/01 16:06:57 priikone Exp $ */
 
 #include "serverincludes.h"
 #include "server_internal.h"
@@ -1325,9 +1325,8 @@
   if (client) {
     /* Free all client specific data, such as client entry and entires
        on channels this client may be on. */
-    silc_server_free_client_data(server, q->sock, client,
-			         TRUE, q->signoff);
-    silc_packet_set_context(q->sock, NULL);
+    silc_server_free_sock_user_data(server, q->sock, q->signoff);
+    silc_server_close_connection(server, q->sock);
   }
 
   silc_packet_stream_unref(q->sock);
@@ -2295,36 +2294,37 @@
 /* Server side of command JOIN. Joins client into requested channel. If
    the channel does not exist it will be created. */
 
-/* Ways of creating channel with dynamic connections:
-
-   1. If channels are not local (no local_channels in silcd.conf) then
-      /join silc, will create connection to default router if it is
-      specified in the silcd.conf.  If it isn't, it creates local channel.
-
-   2. If channels are not local then /join silc at silcnet.org, will create
-      connection to default if it is specified in the silcd.conf and if it
-      isn't or join fails it creates connection to silcnet.org and sends 
-      the JOIN command to that server/router.
-
-   3. If channels are local (local_channels set in silcd.conf) then
-      /join silc, will create local channel.  No connections are created
-      to anywhere.
-
-   4. If channels are local then /join silc at silcnet.org will create
-      connection to default router if it is specified in the silcd.conf and
-      if it isn't, or join fails it creates connection to silcnet.org and
-      send the JOIN command to that server/router.
-
-   5. If we create connection to a remote that already has a channel that
-      we also have as a local channel, should we merge those channels?
-      Should I announce my local channels when I connect to router?  Should
-      I keep local channels local, unless I say /join localch at silcnet.org
-      in which case the local channel 'localch' becomes global?
-
-   6. After we have connection established to router, depending on the
-      local_channels setting /join silc will join locally or globally.
-      /join silc at silcnet.org would always join globally.
-*/
+void silc_server_command_join_connected(SilcServer server,
+					SilcServerEntry server_entry,
+					void *context)
+{
+  SilcServerCommandContext cmd = (SilcServerCommandContext)context;
+
+  if (!server_entry) {
+    SilcUInt32 tmp_len;
+    unsigned char *tmp = silc_argument_get_arg_type(cmd->args, 1, &tmp_len);
+    char serv[256 + 1];
+
+    SILC_LOG_DEBUG(("Connecting to router failed"));
+    silc_parse_userfqdn(tmp, NULL, 0, serv, sizeof(serv));
+
+    if (serv[0]) {
+      silc_server_command_send_status_data(cmd, SILC_COMMAND_JOIN,
+					   SILC_STATUS_ERR_NO_SUCH_SERVER, 0,
+					   2, serv, strlen(serv));
+    } else {
+      silc_server_command_send_status_data(cmd, SILC_COMMAND_JOIN,
+					   SILC_STATUS_ERR_NO_SUCH_CHANNEL, 0,
+					   2, tmp, tmp_len);
+    }
+    silc_server_command_free(cmd);
+    return;
+  }
+
+  /* Reprocess command */
+  SILC_LOG_DEBUG(("Reprocess JOIN after connecting to router"));
+  silc_server_command_join(cmd, NULL);
+}
 
 SILC_SERVER_CMD_FUNC(join)
 {
@@ -2334,6 +2334,7 @@
   unsigned char *auth, *cauth;
   SilcUInt32 tmp_len, auth_len, cauth_len;
   char *tmp, *channel_name, *channel_namec = NULL, *cipher, *hmac;
+  char parsed[256 + 1], serv[256 + 1];
   SilcChannelEntry channel;
   SilcUInt32 umode = 0;
   SilcBool created = FALSE, create_key = TRUE;
@@ -2355,12 +2356,58 @@
     tmp_len = 256;
     tmp[tmp_len - 1] = '\0';
   }
-  channel_name = tmp;
+
+  /* Parse server name from the channel name */
+  silc_parse_userfqdn(tmp, parsed, sizeof(parsed), serv,
+		      sizeof(serv));
+  channel_name = parsed;
+
+  if (server->config->dynamic_server) {
+    /* If server name is not specified but local channels is FALSE then the
+       channel will be global, based on our router name. */
+    if (!serv[0] && !server->config->local_channels) {
+      if (!server->standalone) {
+	silc_snprintf(serv, sizeof(serv), server->router->server_name);
+      } else {
+	SilcServerConfigRouter *router;
+	router = silc_server_config_get_primary_router(server);
+	if (router) {
+	  /* Create connection to primary router */
+	  SILC_LOG_DEBUG(("Create dynamic connection to primary router %s:%d",
+			  router->host, router->port));
+	  silc_server_create_connection(server, FALSE, TRUE,
+				        router->host, router->port,
+				        silc_server_command_join_connected,
+					cmd);
+	  return;
+      	}
+      }
+    }
+
+    /* If server name is ours, ignore it. */
+    if (serv[0] && silc_utf8_strcasecmp(serv, server->server_name))
+      memset(serv, 0, sizeof(serv));
+
+    /* Create connection */
+    if (serv[0] && server->standalone) {
+      SilcServerConfigRouter *router;
+      router = silc_server_config_get_primary_router(server);
+      if (router) {
+	/* Create connection to primary router */
+	SILC_LOG_DEBUG(("Create dynamic connection to primary router %s:%d",
+			router->host, router->port));
+	silc_server_create_connection(server, FALSE, TRUE,
+				      router->host, router->port,
+				      silc_server_command_join_connected, cmd);
+	return;
+      }
+    }
+  }
 
   /* Check for valid channel name.  This is cached, the original is saved
      in the channel context. */
-  channel_namec = silc_channel_name_check(tmp, tmp_len, SILC_STRING_UTF8, 256,
-					  NULL);
+  channel_namec = silc_channel_name_check(channel_name, strlen(channel_name),
+					  SILC_STRING_UTF8, 256, NULL);
   if (!channel_namec) {
     silc_server_command_send_status_reply(cmd, SILC_COMMAND_JOIN,
 					  SILC_STATUS_ERR_BAD_CHANNEL, 0);
@@ -2416,10 +2463,22 @@
 	  channel = silc_server_create_new_channel(server, server->id, cipher,
 						   hmac, channel_name, TRUE);
 	  if (!channel) {
-	    silc_server_command_send_status_data(
-				  cmd, SILC_COMMAND_JOIN,
-				  SILC_STATUS_ERR_UNKNOWN_ALGORITHM,
-				  0, 2, cipher, strlen(cipher));
+	    if (cipher) {
+	      silc_server_command_send_status_data(
+				cmd, SILC_COMMAND_JOIN,
+				SILC_STATUS_ERR_UNKNOWN_ALGORITHM,
+				0, 2, cipher, strlen(cipher));
+	    } else if (hmac) {
+	      silc_server_command_send_status_data(
+				cmd, SILC_COMMAND_JOIN,
+				SILC_STATUS_ERR_UNKNOWN_ALGORITHM,
+				0, 2, hmac, strlen(hmac));
+	    } else {
+	      silc_server_command_send_status_reply(
+				cmd, SILC_COMMAND_JOIN,
+				SILC_STATUS_ERR_RESOURCE_LIMIT,
+				0);
+	    }
 	    goto out;
 	  }
 
@@ -2475,10 +2534,22 @@
 	  channel = silc_server_create_new_channel(server, server->id, cipher,
 						   hmac, channel_name, TRUE);
 	  if (!channel) {
-	    silc_server_command_send_status_data(
-				       cmd, SILC_COMMAND_JOIN,
-				       SILC_STATUS_ERR_UNKNOWN_ALGORITHM, 0,
-				       2, cipher, strlen(cipher));
+	    if (cipher) {
+	      silc_server_command_send_status_data(
+				      cmd, SILC_COMMAND_JOIN,
+				      SILC_STATUS_ERR_UNKNOWN_ALGORITHM,
+				      0, 2, cipher, strlen(cipher));
+	    } else if (hmac) {
+	      silc_server_command_send_status_data(
+				      cmd, SILC_COMMAND_JOIN,
+				      SILC_STATUS_ERR_UNKNOWN_ALGORITHM,
+				      0, 2, hmac, strlen(hmac));
+	    } else {
+	      silc_server_command_send_status_reply(
+				      cmd, SILC_COMMAND_JOIN,
+				      SILC_STATUS_ERR_RESOURCE_LIMIT,
+				      0);
+	    }
 	    goto out;
 	  }
 
@@ -2508,10 +2579,22 @@
 	channel = silc_server_create_new_channel(server, server->id, cipher,
 						 hmac, channel_name, TRUE);
 	if (!channel) {
-	  silc_server_command_send_status_data(
-				       cmd, SILC_COMMAND_JOIN,
-				       SILC_STATUS_ERR_UNKNOWN_ALGORITHM, 0,
-				       2, cipher, strlen(cipher));
+	  if (cipher) {
+	    silc_server_command_send_status_data(
+				      cmd, SILC_COMMAND_JOIN,
+				      SILC_STATUS_ERR_UNKNOWN_ALGORITHM,
+				      0, 2, cipher, strlen(cipher));
+	  } else if (hmac) {
+	    silc_server_command_send_status_data(
+				      cmd, SILC_COMMAND_JOIN,
+				      SILC_STATUS_ERR_UNKNOWN_ALGORITHM,
+				      0, 2, hmac, strlen(hmac));
+	  } else {
+	    silc_server_command_send_status_reply(
+				      cmd, SILC_COMMAND_JOIN,
+				      SILC_STATUS_ERR_RESOURCE_LIMIT,
+				      0);
+	  }
 	  goto out;
 	}
 
@@ -4415,7 +4498,7 @@
   username = silc_identifier_check(username, tmp_len, SILC_STRING_UTF8, 128,
 				   &tmp_len);
   if (!username) {
-    silc_server_command_send_status_reply(cmd, SILC_COMMAND_OPER,
+    silc_server_command_send_status_reply(cmd, SILC_COMMAND_SILCOPER,
 					  SILC_STATUS_ERR_BAD_USERNAME,
 					  0);
     goto out;
@@ -4464,7 +4547,7 @@
   }
   if (!result) {
     /* Authentication failed */
-    silc_server_command_send_status_reply(cmd, SILC_COMMAND_OPER,
+    silc_server_command_send_status_reply(cmd, SILC_COMMAND_SILCOPER,
 					  SILC_STATUS_ERR_AUTH_FAILED, 0);
     goto out;
   }

Modified: silc-server/branches/upstream/current/apps/silcd/command_reply.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/apps/silcd/command_reply.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/apps/silcd/command_reply.c (original)
+++ silc-server/branches/upstream/current/apps/silcd/command_reply.c Sun Jul  1 19:18:19 2007
@@ -16,7 +16,7 @@
   GNU General Public License for more details.
 
 */
-/* $Id: command_reply.c,v 1.116 2007/04/28 15:10:28 priikone Exp $ */
+/* $Id: command_reply.c,v 1.116.2.2 2007/06/10 19:32:58 priikone Exp $ */
 
 #include "serverincludes.h"
 #include "server_internal.h"
@@ -1199,7 +1199,8 @@
     silc_hmac_free(hmac);
   silc_server_command_reply_free(cmd);
 
-  silc_pkcs_public_key_free(founder_key);
+  if (founder_key)
+    silc_pkcs_public_key_free(founder_key);
   if (client_id_list)
     silc_buffer_free(client_id_list);
   if (client_mode_list)

Modified: silc-server/branches/upstream/current/apps/silcd/idlist.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/apps/silcd/idlist.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/apps/silcd/idlist.c (original)
+++ silc-server/branches/upstream/current/apps/silcd/idlist.c Sun Jul  1 19:18:19 2007
@@ -17,7 +17,7 @@
   GNU General Public License for more details.
 
 */
-/* $Id: idlist.c,v 1.89 2007/04/28 15:10:29 priikone Exp $ */
+/* $Id: idlist.c,v 1.89.2.2 2007/07/01 16:06:58 priikone Exp $ */
 
 #include "serverincludes.h"
 #include "idlist.h"
@@ -62,23 +62,6 @@
   idata->public_key = NULL;
 }
 
-/* Purges ID cache */
-
-SILC_TASK_CALLBACK(silc_idlist_purge)
-{
-  SilcServer server = app_context;
-  SilcIDListPurge i = (SilcIDListPurge)context;
-
-  SILC_LOG_DEBUG(("Purging cache"));
-
-#if 0
-  /* XXX */
-  silc_idcache_purge(i->cache);
-  silc_schedule_task_add_timeout(server->schedule, silc_idlist_purge, i,
-				 i->timeout, 0);
-#endif
-}
-
 /******************************************************************************
 
                           Server entry functions
@@ -575,28 +558,23 @@
 
   client = (SilcClientEntry)id_cache->context;
 
-  /* Remove the old entry and add a new one */
-
-  if (!silc_idcache_del_by_context(id_list->clients, client, server))
-    return NULL;
-
   /* Check if anyone is watching old nickname */
   if (server->server_type == SILC_ROUTER)
     silc_server_check_watcher_list(server, client, nickname,
 				   SILC_NOTIFY_TYPE_NICK_CHANGE);
 
+  /* Replace */
+  if (!silc_idcache_update(id_list->clients, id_cache, new_id, nicknamec,
+			   TRUE))
+    return NULL;
+
   silc_free(client->nickname);
-  *client->id = *new_id;
   client->nickname = nickname ? strdup(nickname) : NULL;
 
   /* Check if anyone is watching new nickname */
   if (server->server_type == SILC_ROUTER)
     silc_server_check_watcher_list(server, client, nickname,
 				   SILC_NOTIFY_TYPE_NICK_CHANGE);
-
-  if (!silc_idcache_add(id_list->clients, nicknamec, client->id,
-			client))
-    return NULL;
 
   SILC_LOG_DEBUG(("Replaced"));
 

Modified: silc-server/branches/upstream/current/apps/silcd/idlist.h
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/apps/silcd/idlist.h?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/apps/silcd/idlist.h (original)
+++ silc-server/branches/upstream/current/apps/silcd/idlist.h Sun Jul  1 19:18:19 2007
@@ -162,6 +162,9 @@
 
   /* Connection data */
   void *connection;
+
+  void *backup_proto;
+  unsigned int backup  : 1;	/* Set when executing backup protocol */
 };
 
 /*
@@ -543,6 +546,7 @@
 typedef struct {
   /* Generic data structure. DO NOT add anything before this! */
   SilcIDListDataStruct data;
+  SilcAsyncOperation op;
   SilcServerConfigRef cconfig;
   SilcServerConfigRef sconfig;
   SilcServerConfigRef rconfig;

Modified: silc-server/branches/upstream/current/apps/silcd/packet_receive.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/apps/silcd/packet_receive.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/apps/silcd/packet_receive.c (original)
+++ silc-server/branches/upstream/current/apps/silcd/packet_receive.c Sun Jul  1 19:18:19 2007
@@ -46,8 +46,17 @@
   SilcUInt32 tmp_len, tmp2_len;
   SilcBool local, ret;
 
-  if (idata->conn_type == SILC_CONN_CLIENT ||
-      packet->src_id_type != SILC_ID_SERVER || !packet->dst_id) {
+  if (idata->conn_type == SILC_CONN_CLIENT) {
+    SILC_LOG_DEBUG(("Notify received from client, drop it"));
+    return;
+  }
+
+  if (packet->src_id_type != SILC_ID_SERVER){
+    SILC_LOG_DEBUG(("Bad notify packet received"));
+    return;
+  }
+
+  if (!packet->dst_id) {
     SILC_LOG_DEBUG(("Bad notify packet received"));
     return;
   }
@@ -69,8 +78,10 @@
 
   /* Parse the Notify Payload */
   payload = silc_notify_payload_parse(buffer->data, silc_buffer_len(buffer));
-  if (!payload)
+  if (!payload) {
+    SILC_LOG_DEBUG(("Marlformed notify payload"));
     return;
+  }
 
   /* If we are router and this packet is not already broadcast packet
      we will broadcast it. The sending socket really cannot be router or
@@ -84,8 +95,10 @@
       /* Packet is destined to channel */
       if (!silc_id_str2id(packet->dst_id, packet->dst_id_len,
 			  packet->dst_id_type, &channel_id,
-			  sizeof(channel_id)))
-	goto out;
+			  sizeof(channel_id))) {
+	SILC_LOG_DEBUG(("Malformed destination ID in notify packet"));
+	goto out;
+      }
 
       silc_server_packet_send_dest(server, SILC_PRIMARY_ROUTE(server),
 				   packet->type, packet->flags |
@@ -112,8 +125,10 @@
 
   type = silc_notify_get_type(payload);
   args = silc_notify_get_args(payload);
-  if (!args)
+  if (!args) {
+    SILC_LOG_DEBUG(("Notify doesn't have any arguments, drop it"));
     goto out;
+  }
 
   switch(type) {
   case SILC_NOTIFY_TYPE_JOIN:
@@ -133,7 +148,8 @@
       channel = silc_idlist_find_channel_by_id(server->local_list,
 					       SILC_ID_GET_ID(id), NULL);
       if (!channel) {
-	SILC_LOG_DEBUG(("Notify for unknown channel"));
+	SILC_LOG_DEBUG(("Notify for unknown channel %s",
+			silc_id_render(SILC_ID_GET_ID(id), SILC_ID_CHANNEL)));
 	goto out;
       }
     }
@@ -251,7 +267,8 @@
       channel = silc_idlist_find_channel_by_id(server->local_list,
 					       &channel_id, NULL);
       if (!channel) {
-	SILC_LOG_DEBUG(("Notify for unknown channel"));
+	SILC_LOG_DEBUG(("Notify for unknown channel %s",
+			silc_id_render(&channel_id, SILC_ID_CHANNEL)));
 	goto out;
       }
     }
@@ -383,7 +400,8 @@
       channel = silc_idlist_find_channel_by_id(server->local_list,
 					       &channel_id, NULL);
       if (!channel) {
-	SILC_LOG_DEBUG(("Notify for unknown channel"));
+	SILC_LOG_DEBUG(("Notify for unknown channel %s",
+			silc_id_render(&channel_id, SILC_ID_CHANNEL)));
 	goto out;
       }
     }
@@ -503,7 +521,8 @@
       channel = silc_idlist_find_channel_by_id(server->local_list,
 					       &channel_id, NULL);
       if (!channel) {
-	SILC_LOG_DEBUG(("Notify for unknown channel"));
+	SILC_LOG_DEBUG(("Notify for unknown channel %s",
+			silc_id_render(&channel_id, SILC_ID_CHANNEL)));
 	goto out;
       }
     }
@@ -823,7 +842,8 @@
 	channel = silc_idlist_find_channel_by_id(server->local_list,
 						 &channel_id, NULL);
 	if (!channel) {
-	  SILC_LOG_DEBUG(("Notify for unknown channel"));
+	  SILC_LOG_DEBUG(("Notify for unknown channel %s",
+			  silc_id_render(&channel_id, SILC_ID_CHANNEL)));
 	  goto out;
 	}
       }
@@ -1010,7 +1030,8 @@
       channel = silc_idlist_find_channel_by_id(server->local_list,
 					       SILC_ID_GET_ID(id), NULL);
       if (!channel) {
-	SILC_LOG_DEBUG(("Notify for unknown channel"));
+	SILC_LOG_DEBUG(("Notify for unknown channel %s",
+			silc_id_render(SILC_ID_GET_ID(id), SILC_ID_CHANNEL)));
 	goto out;
       }
     }
@@ -1079,7 +1100,8 @@
       channel = silc_idlist_find_channel_by_id(server->global_list,
 					       SILC_ID_GET_ID(id), NULL);
       if (!channel) {
-	SILC_LOG_DEBUG(("Notify for unknown channel"));
+	SILC_LOG_DEBUG(("Notify for unknown channel %s",
+			silc_id_render(SILC_ID_GET_ID(id), SILC_ID_CHANNEL)));
 	goto out;
       }
     }
@@ -1208,12 +1230,12 @@
 
 	    /* Get client entry */
 	    client = silc_idlist_find_client_by_id(server->global_list,
-						   SILC_ID_GET_ID(id),
+						   SILC_ID_GET_ID(id2),
 						   TRUE, &cache);
 	    local = FALSE;
 	    if (!client) {
 	      client = silc_idlist_find_client_by_id(server->local_list,
-						     SILC_ID_GET_ID(id),
+						     SILC_ID_GET_ID(id2),
 						     TRUE, &cache);
 	      local = TRUE;
 	      if (!client)
@@ -1304,7 +1326,8 @@
       channel = silc_idlist_find_channel_by_id(server->local_list,
 					       &channel_id, NULL);
       if (!channel) {
-	SILC_LOG_DEBUG(("Notify for unknown channel"));
+	SILC_LOG_DEBUG(("Notify for unknown channel %s",
+			silc_id_render(SILC_ID_GET_ID(id), SILC_ID_CHANNEL)));
 	goto out;
       }
     }
@@ -1564,7 +1587,8 @@
       channel = silc_idlist_find_channel_by_id(server->local_list,
 					       SILC_ID_GET_ID(id), NULL);
       if (!channel) {
-	SILC_LOG_DEBUG(("Notify for unknown channel"));
+	SILC_LOG_DEBUG(("Notify for unknown channel %s",
+			silc_id_render(SILC_ID_GET_ID(id), SILC_ID_CHANNEL)));
 	goto out;
       }
     }
@@ -1652,6 +1676,7 @@
     break;
 
   default:
+    SILC_LOG_DEBUG(("Unsupported notify %d", type));
     break;
   }
 
@@ -2637,7 +2662,8 @@
 	 global list. Cell wide information however is kept in the local
 	 list. */
       entry = silc_idlist_add_client(id_list, NULL, NULL, NULL,
-				     &id, router, NULL);
+				     silc_id_dup(&id, SILC_ID_CLIENT),
+				     router, NULL);
       if (!entry) {
 	SILC_LOG_ERROR(("Could not add new client to the ID Cache"));
 
@@ -2716,7 +2742,8 @@
       /* As a router we keep information of all global information in our
 	 global list. Cell wide information however is kept in the local
 	 list. */
-      entry = silc_idlist_add_server(id_list, NULL, 0, &id, router,
+      entry = silc_idlist_add_server(id_list, NULL, 0,
+				     silc_id_dup(&id, SILC_ID_SERVER), router,
 				     router_sock);
       if (!entry) {
 	SILC_LOG_ERROR(("Could not add new server to the ID Cache"));
@@ -2958,9 +2985,12 @@
       }
 
       /* Create the channel with the provided Channel ID */
-      channel = silc_server_create_new_channel_with_id(server, NULL, NULL,
-						       channel_name,
-						       &channel_id, FALSE);
+      channel =
+	silc_server_create_new_channel_with_id(
+				     server, NULL, NULL,
+				     channel_name,
+				     silc_id_dup(&channel_id, SILC_ID_CHANNEL),
+				     FALSE);
       if (!channel) {
 	silc_channel_payload_free(payload);
 	return;

Modified: silc-server/branches/upstream/current/apps/silcd/server.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/apps/silcd/server.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/apps/silcd/server.c (original)
+++ silc-server/branches/upstream/current/apps/silcd/server.c Sun Jul  1 19:18:19 2007
@@ -24,6 +24,7 @@
 
 SILC_TASK_CALLBACK(silc_server_get_stats);
 SILC_TASK_CALLBACK(silc_server_connect_router);
+SILC_TASK_CALLBACK(silc_server_connect_to_router_retry);
 SILC_TASK_CALLBACK(silc_server_do_rekey);
 SILC_TASK_CALLBACK(silc_server_purge_expired_clients);
 static void silc_server_accept_new_connection(SilcNetStatus status,
@@ -78,6 +79,9 @@
 {
   SilcServer server = callback_context;
   SilcIDListData idata = stream_context;
+
+  if (!idata)
+    return FALSE;
 
   /* Packets we do not handle */
   switch (packet->type) {
@@ -211,6 +215,33 @@
   silc_server_close_connection(server, stream);
 }
 
+SILC_TASK_CALLBACK(silc_server_packet_error_timeout)
+{
+  SilcServer server = app_context;
+  SilcPacketStream stream = context;
+  SilcIDListData idata = silc_packet_get_context(stream);
+
+  if (!idata)
+    return;
+
+  if (server->router_conn && server->router_conn->sock == stream &&
+      !server->router && server->standalone) {
+    silc_server_create_connections(server);
+  } else {
+    /* If backup disconnected then mark that resuming will not be allowed */
+     if (server->server_type == SILC_ROUTER && !server->backup_router &&
+         idata->conn_type == SILC_CONN_SERVER) {
+      SilcServerEntry server_entry = (SilcServerEntry)idata;
+      if (server_entry->server_type == SILC_BACKUP_ROUTER)
+        server->backup_closed = TRUE;
+    }
+
+    silc_server_free_sock_user_data(server, stream, NULL);
+  }
+
+  silc_server_close_connection(server, stream);
+}
+
 /* Packet engine callback to indicate error */
 
 static void silc_server_packet_error(SilcPacketEngine engine,
@@ -219,6 +250,7 @@
 				     void *callback_context,
 				     void *stream_context)
 {
+  SilcServer server = callback_context;
   SilcIDListData idata = silc_packet_get_context(stream);
   SilcStream sock = silc_packet_stream_get_stream(stream);
   const char *ip;
@@ -230,9 +262,13 @@
   if (!silc_socket_stream_get_info(sock, NULL, NULL, &ip, &port))
     return;
 
-  SILC_LOG_ERROR(("Connection %s:%d [%s]: %s",
-		  SILC_CONNTYPE_STRING(idata->conn_type), ip, port,
+  SILC_LOG_ERROR(("Connection %s:%d [%s]: %s", ip, port,
+		  SILC_CONNTYPE_STRING(idata->conn_type),
 		  silc_packet_error_string(error)));
+
+  silc_schedule_task_add_timeout(server->schedule,
+				 silc_server_packet_error_timeout,
+				 stream, 0, 0);
 }
 
 /* Packet stream callbacks */
@@ -356,21 +392,18 @@
       server->backup_noswitch = (status == SILC_STATUS_OK ? FALSE : TRUE);
 
       /* If backup disconnected then mark that resuming will not be allowed */
-#if 0
       if (server->server_type == SILC_ROUTER && !server->backup_router &&
-	  sock->type == SILC_CONN_SERVER && sock->user_data) {
-	SilcServerEntry server_entry = sock->user_data;
+	  idata->conn_type == SILC_CONN_SERVER) {
+	SilcServerEntry server_entry = (SilcServerEntry)idata;
 	if (server_entry->server_type == SILC_BACKUP_ROUTER)
 	  server->backup_closed = TRUE;
       }
 
       /* Handle the disconnection from our end too */
-      if (sock->user_data && SILC_IS_LOCAL(sock->user_data))
+      if (SILC_IS_LOCAL(idata))
 	silc_server_free_sock_user_data(server, sock, NULL);
-      SILC_SET_DISCONNECTING(sock);
       silc_server_close_connection(server, sock);
       server->backup_noswitch = FALSE;
-#endif
     }
     break;
 
@@ -499,9 +532,7 @@
        router resuming protocol. */
     if (packet->flags & SILC_PACKET_FLAG_LIST)
       break;
-#if 0
     silc_server_backup_resume_router(server, sock, packet);
-#endif
     break;
 
   default:
@@ -652,14 +683,13 @@
   silc_skr_free(server->repository);
   silc_packet_engine_stop(server->packet_engine);
 
+  silc_schedule_task_del_by_context(server->schedule, server);
   silc_schedule_uninit(server->schedule);
   server->schedule = NULL;
 
   silc_free(server->local_list);
   silc_free(server->global_list);
   silc_free(server->server_name);
-  silc_free(server->purge_i);
-  silc_free(server->purge_g);
   silc_free(server);
 
   silc_hmac_unregister_all();
@@ -693,60 +723,19 @@
 
 SilcBool silc_server_init_secondary(SilcServer server)
 {
+  SilcServerConfigServerInfoInterface *interface;
+  SilcNetListener listener;
+
+  for (interface = server->config->server_info->secondary; interface;
+       interface = interface->next) {
+    listener = silc_server_listen(server, interface->server_ip,
+				  interface->port);
+    if (!listener)
+      return FALSE;
+    silc_dlist_add(server->listeners, listener);
+  }
+
   return TRUE;
-#if 0
-  int sock = 0;
-  SilcPacketStream newsocket = NULL;
-  SilcServerConfigServerInfoInterface *interface;
-
-  for (interface = server->config->server_info->secondary; interface;
-       interface = interface->next, sock++) {
-
-    if (!silc_server_listen(server,
-	interface->server_ip, interface->port, &sock_list[sock]))
-      goto err;
-
-    /* Set socket to non-blocking mode */
-    silc_net_set_socket_nonblock(sock_list[sock]);
-
-    /* Add ourselves also to the socket table. The entry allocated above
-       is sent as argument for fast referencing in the future. */
-    silc_socket_alloc(sock_list[sock],
-		      SILC_CONN_SERVER, NULL, &newsocket);
-    server->sockets[sock_list[sock]] = newsocket;
-    SILC_SET_LISTENER(newsocket);
-
-    /* Perform name and address lookups to resolve the listenning address
-       and port. */
-    if (!silc_net_check_local_by_sock(sock_list[sock], &newsocket->hostname,
-      			    &newsocket->ip)) {
-      if ((server->config->require_reverse_lookup && !newsocket->hostname) ||
-        !newsocket->ip) {
-        SILC_LOG_ERROR(("IP/DNS lookup failed for local host %s",
-        	      newsocket->hostname ? newsocket->hostname :
-        	      newsocket->ip ? newsocket->ip : ""));
-        server->stat.conn_failures++;
-        goto err;
-      }
-      if (!newsocket->hostname)
-        newsocket->hostname = strdup(newsocket->ip);
-    }
-    newsocket->port = silc_net_get_local_port(sock);
-
-    newsocket->user_data = (void *)server->id_entry;
-    silc_schedule_task_add(server->schedule, sock_list[sock],
-			   silc_server_accept_new_connection,
-			   (void *)server, 0, 0,
-			   SILC_TASK_FD,
-			   SILC_TASK_PRI_NORMAL);
-  }
-
-  return TRUE;
-
- err:
-  do silc_net_close_server(sock_list[sock--]); while (sock >= 0);
-#endif /* 0 */
-  return FALSE;
 }
 
 /* Initializes the entire SILC server. This is called always before running
@@ -760,7 +749,6 @@
 {
   SilcServerID *id;
   SilcServerEntry id_entry;
-  SilcIDListPurge purge;
   SilcNetListener listener;
   SilcUInt16 *port;
   char **ip;
@@ -862,7 +850,6 @@
 		   server->config->server_info->primary->port);
   if (!listener)
     goto err;
-
   silc_dlist_add(server->listeners, listener);
 
   /* Create a Server ID for the server. */
@@ -890,12 +877,16 @@
      the ID list. */
   id_entry =
     silc_idlist_add_server(server->local_list, strdup(server->server_name),
-			   server->server_type, server->id, NULL, NULL);
+			   server->server_type,
+			   silc_id_dup(server->id, SILC_ID_SERVER),
+			   NULL, NULL);
   if (!id_entry) {
     SILC_LOG_ERROR(("Could not add local server to cache"));
     goto err;
   }
   id_entry->data.status |= SILC_IDLIST_STATUS_REGISTERED;
+  id_entry->data.conn_type = (server->server_type == SILC_SERVER ?
+			      SILC_CONN_SERVER : SILC_CONN_ROUTER);
   server->id_entry = id_entry;
 
   /* Create secondary TCP listeners */
@@ -924,23 +915,6 @@
     }
   }
 
-  /* Register the ID Cache purge task. This periodically purges the ID cache
-     and removes the expired cache entries. */
-
-  /* Clients local list */
-  server->purge_i = purge = silc_calloc(1, sizeof(*purge));
-  purge->cache = server->local_list->clients;
-  purge->timeout = 600;
-  silc_schedule_task_add_timeout(server->schedule, silc_idlist_purge,
-				 (void *)purge, purge->timeout, 0);
-
-  /* Clients global list */
-  server->purge_g = purge = silc_calloc(1, sizeof(*purge));
-  purge->cache = server->global_list->clients;
-  purge->timeout = 300;
-  silc_schedule_task_add_timeout(server->schedule, silc_idlist_purge,
-				 (void *)purge, purge->timeout, 0);
-
   /* If we are normal server we'll retrieve network statisticial information
      once in a while from the router. */
   if (server->server_type != SILC_ROUTER)
@@ -960,7 +934,7 @@
   /* Register client entry expiration timeout */
   silc_schedule_task_add_timeout(server->schedule,
 				 silc_server_purge_expired_clients, server,
-				 600, 0);
+				 120, 0);
 
   /* Initialize HTTP server */
   silc_server_http_init(server);
@@ -975,32 +949,28 @@
   return FALSE;
 }
 
-#if 0
 /* Task callback to close a socket connection after rehash */
 
 SILC_TASK_CALLBACK(silc_server_rehash_close_connection)
 {
-  SilcServer server = context;
-  SilcPacketStream sock = server->sockets[fd];
-
-  if (!sock)
-    return;
+  SilcServer server = app_context;
+  SilcPacketStream sock = context;
+  SilcIDListData idata = silc_packet_get_context(sock);
+  const char *hostname;
+  SilcUInt16 port;
+
+  silc_socket_stream_get_info(silc_packet_stream_get_stream(sock),
+			      NULL, &hostname, NULL, &port);
 
   SILC_LOG_INFO(("Connection %s:%d [%s] is unconfigured",
-		 sock->hostname, sock->port,
-		 (sock->type == SILC_CONN_UNKNOWN ? "Unknown" :
-		  sock->type == SILC_CONN_CLIENT ? "Client" :
-		  sock->type == SILC_CONN_SERVER ? "Server" :
-		  "Router")));
+		 hostname, port, SILC_CONNTYPE_STRING(idata->conn_type)));
   silc_schedule_task_del_by_context(server->schedule, sock);
   silc_server_disconnect_remote(server, sock,
 				SILC_STATUS_ERR_BANNED_FROM_SERVER,
 				"This connection is removed from "
 				"configuration");
-  if (sock->user_data)
-    silc_server_free_sock_user_data(server, sock, NULL);
-}
-#endif /* 0 */
+  silc_server_free_sock_user_data(server, sock, NULL);
+}
 
 /* This function basically reads the config file again and switches the config
    object pointed by the server object. After that, we have to fix various
@@ -1009,7 +979,6 @@
 
 SilcBool silc_server_rehash(SilcServer server)
 {
-#if 0
   SilcServerConfig newconfig;
 
   SILC_LOG_INFO(("Rehashing server"));
@@ -1024,12 +993,6 @@
     SILC_LOG_ERROR(("Rehash FAILED."));
     return FALSE;
   }
-
-  /* Reinit scheduler if necessary */
-  if (newconfig->param.connections_max > server->config->param.connections_max)
-    if (!silc_schedule_reinit(server->schedule,
-			      newconfig->param.connections_max))
-      return FALSE;
 
   /* Fix the server_name field */
   if (strcmp(server->server_name, newconfig->server_info->server_name)) {
@@ -1049,13 +1012,10 @@
     /* Update the idcache list with a fresh pointer */
     silc_free(server->id_entry->server_name);
     server->id_entry->server_name = strdup(server->server_name);
-    if (!silc_idcache_del_by_context(server->local_list->servers,
-				     server->id_entry))
-      return FALSE;
-    if (!silc_idcache_add(server->local_list->servers,
-			  strdup(server->id_entry->server_name),
-			  server->id_entry->id, server->id_entry, 0, NULL))
-      return FALSE;
+    silc_idcache_update_by_context(server->local_list->servers,
+				   server->id_entry, NULL,
+				   strdup(server->id_entry->server_name),
+				   TRUE);
   }
 
   /* Set logging */
@@ -1071,13 +1031,6 @@
     server->private_key = newconfig->server_info->private_key;
     newconfig->server_info->public_key = NULL;
     newconfig->server_info->private_key = NULL;
-
-    /* Allocate PKCS context for local public and private keys */
-    silc_pkcs_free(server->pkcs);
-    if (!silc_pkcs_alloc(server->public_key->name, &server->pkcs))
-      return FALSE;
-    silc_pkcs_public_key_set(server->pkcs, server->public_key);
-    silc_pkcs_private_key_set(server->pkcs, server->private_key);
   }
 
   /* Check for unconfigured server and router connections and close
@@ -1106,11 +1059,10 @@
 	SilcPacketStream sock;
 	sock = silc_server_find_socket_by_host(server, SILC_CONN_ROUTER,
 					       ptr->host, ptr->port);
-	if (sock && !SILC_IS_LISTENER(sock))
-	  silc_schedule_task_add(server->schedule, sock->sock,
-				 silc_server_rehash_close_connection,
-				 server, 0, 1, SILC_TASK_TIMEOUT,
-				 SILC_TASK_PRI_NORMAL);
+	if (sock)
+	  silc_schedule_task_add_timeout(server->schedule,
+					 silc_server_rehash_close_connection,
+					 sock, 0, 1);
       }
     }
   }
@@ -1136,11 +1088,10 @@
 	SilcPacketStream sock;
 	sock = silc_server_find_socket_by_host(server, SILC_CONN_SERVER,
 					       ptr->host, 0);
-	if (sock && !SILC_IS_LISTENER(sock))
-	  silc_schedule_task_add(server->schedule, sock->sock,
-				 silc_server_rehash_close_connection,
-				 server, 0, 1, SILC_TASK_TIMEOUT,
-				 SILC_TASK_PRI_NORMAL);
+	if (sock)
+	  silc_schedule_task_add_timeout(server->schedule,
+					 silc_server_rehash_close_connection,
+					 sock, 0, 1);
       }
     }
   }
@@ -1167,10 +1118,9 @@
 	sock = silc_server_find_socket_by_host(server, SILC_CONN_CLIENT,
 					       ptr->host, 0);
 	if (sock)
-	  silc_schedule_task_add(server->schedule, sock->sock,
-				 silc_server_rehash_close_connection,
-				 server, 0, 1, SILC_TASK_TIMEOUT,
-				 SILC_TASK_PRI_NORMAL);
+	  silc_schedule_task_add_timeout(server->schedule,
+					 silc_server_rehash_close_connection,
+					 sock, 0, 1);
       }
     }
   }
@@ -1213,7 +1163,6 @@
 #endif /* SILC_DEBUG */
 
   SILC_LOG_DEBUG(("Server rehashed"));
-#endif /* 0 */
 
   return TRUE;
 }
@@ -1261,7 +1210,7 @@
       silc_server_free_sock_user_data(server, ps,
 				      "Server is shutting down");
     }
-    silc_dlist_uninit(list);
+    silc_packet_engine_free_streams_list(list);
   }
 
   /* We are not connected to network anymore */
@@ -1273,6 +1222,12 @@
 
   silc_server_http_uninit(server);
 
+  /* Cancel any possible retry timeouts */
+  silc_schedule_task_del_by_callback(server->schedule,
+				     silc_server_connect_router);
+  silc_schedule_task_del_by_callback(server->schedule,
+				     silc_server_connect_to_router_retry);
+
   silc_schedule_stop(server->schedule);
 
   SILC_LOG_DEBUG(("Server stopped"));
@@ -1285,6 +1240,7 @@
   SilcServer server = context;
   SilcClientEntry client;
   SilcIDList id_list;
+  SilcUInt64 curtime = silc_time();
 
   SILC_LOG_DEBUG(("Expire timeout"));
 
@@ -1293,6 +1249,12 @@
     if (client->data.status & SILC_IDLIST_STATUS_REGISTERED)
       continue;
 
+    /* For unregistered clients the created timestamp is actually
+       unregistered timestamp.  Make sure client remains in history
+       at least 500 seconds. */
+    if (curtime - client->data.created < 500)
+      continue;
+
     id_list = (client->data.status & SILC_IDLIST_STATUS_LOCAL ?
 	       server->local_list : server->global_list);
 
@@ -1303,7 +1265,7 @@
 
   silc_schedule_task_add_timeout(server->schedule,
 				 silc_server_purge_expired_clients, server,
-				 600, 0);
+				 120, 0);
 }
 
 
@@ -1311,8 +1273,9 @@
 
 /* Free connection context */
 
-static void silc_server_connection_free(SilcServerConnection sconn)
-{
+void silc_server_connection_free(SilcServerConnection sconn)
+{
+  SILC_LOG_DEBUG(("Free connection %p", sconn));
   silc_dlist_del(sconn->server->conns, sconn);
   silc_server_config_unref(&sconn->conn);
   silc_free(sconn->remote_host);
@@ -1343,6 +1306,8 @@
   sconn->no_conf = dynamic;
   sconn->server = server;
 
+  SILC_LOG_DEBUG(("Created connection %p", sconn));
+
   silc_schedule_task_add_timeout(server->schedule, silc_server_connect_router,
 				 sconn, 0, 0);
 }
@@ -1363,8 +1328,11 @@
   unsigned char id[32];
   SilcUInt32 id_len;
   SilcID remote_id;
+  const char *ip;
 
   SILC_LOG_DEBUG(("Connection authentication completed"));
+
+  sconn->op = NULL;
 
   if (success == FALSE) {
     /* Authentication failed */
@@ -1372,6 +1340,9 @@
 
     silc_server_disconnect_remote(server, sconn->sock,
 				  SILC_STATUS_ERR_AUTH_FAILED, NULL);
+    if (sconn->callback)
+      (*sconn->callback)(server, NULL, sconn->callback_context);
+    silc_server_connection_free(sconn);
     return;
   }
 
@@ -1395,6 +1366,8 @@
     if (!id_entry) {
       silc_server_disconnect_remote(server, sconn->sock,
 				    SILC_STATUS_ERR_RESOURCE_LIMIT, NULL);
+      if (sconn->callback)
+	(*sconn->callback)(server, NULL, sconn->callback_context);
       silc_server_connection_free(sconn);
       silc_free(entry);
       return;
@@ -1417,6 +1390,8 @@
 			     SILC_STR_END)) {
       silc_server_disconnect_remote(server, sconn->sock,
 				    SILC_STATUS_ERR_RESOURCE_LIMIT, NULL);
+      if (sconn->callback)
+	(*sconn->callback)(server, NULL, sconn->callback_context);
       silc_server_connection_free(sconn);
       silc_free(entry);
       return;
@@ -1454,6 +1429,8 @@
     if (!id_entry) {
       silc_server_disconnect_remote(server, sconn->sock,
 				    SILC_STATUS_ERR_RESOURCE_LIMIT, NULL);
+      if (sconn->callback)
+	(*sconn->callback)(server, NULL, sconn->callback_context);
       silc_server_connection_free(sconn);
       silc_free(entry);
       return;
@@ -1494,12 +1471,27 @@
 	  silc_server_announce_channels(server, 0, SILC_PRIMARY_ROUTE(server));
 	}
 
-#if 0
 	/* If we are backup router then this primary router is whom we are
 	   backing up. */
-	if (server->server_type == SILC_BACKUP_ROUTER)
-	  silc_server_backup_add(server, server->id_entry, sock->ip,
+	if (server->server_type == SILC_BACKUP_ROUTER) {
+	  silc_socket_stream_get_info(silc_packet_stream_get_stream(sconn->
+								    sock),
+				      NULL, NULL, &ip, NULL);
+	  silc_server_backup_add(server, server->id_entry, ip,
 				 sconn->remote_port, TRUE);
+	}
+#if 0
+      } else {
+	/* We already have primary router.  Disconnect this connection */
+	SILC_LOG_DEBUG(("We already have primary router, disconnect"));
+	silc_idlist_del_server(server->global_list, id_entry);
+	silc_server_disconnect_remote(server, sconn->sock,
+				      SILC_STATUS_ERR_RESOURCE_LIMIT, NULL);
+	if (sconn->callback)
+	  (*sconn->callback)(server, NULL, sconn->callback_context);
+	silc_server_connection_free(sconn);
+	silc_free(entry);
+	return;
 #endif /* 0 */
       }
     } else {
@@ -1514,6 +1506,8 @@
   default:
     silc_server_disconnect_remote(server, sconn->sock,
 				  SILC_STATUS_ERR_AUTH_FAILED, NULL);
+    if (sconn->callback)
+      (*sconn->callback)(server, NULL, sconn->callback_context);
     silc_server_connection_free(sconn);
     silc_free(entry);
     return;
@@ -1530,13 +1524,6 @@
   sconn->rekey_timeout = param->key_exchange_rekey;
   silc_schedule_task_add_timeout(server->schedule, silc_server_do_rekey,
 				 sconn->sock, sconn->rekey_timeout, 0);
-
-#if 0
-  /* Perform keepalive. */
-  silc_socket_set_heartbeat(sock, param->keepalive_secs, server,
-			    silc_server_perform_heartbeat,
-			    server->schedule);
-#endif /* 0 */
 
   /* Set the entry as packet stream context */
   silc_packet_set_context(sconn->sock, id_entry);
@@ -1547,17 +1534,8 @@
   if (sconn && sconn->callback)
     (*sconn->callback)(server, id_entry, sconn->callback_context);
 
-#if 0
-  /* Free the temporary connection data context */
-  if (sconn) {
-    silc_server_config_unref(&sconn->conn);
-    silc_free(sconn->remote_host);
-    silc_free(sconn->backup_replace_ip);
-    silc_free(sconn);
-  }
   if (sconn == server->router_conn)
     server->router_conn = NULL;
-#endif /* 0 */
 
   silc_free(entry);
 }
@@ -1583,6 +1561,8 @@
   SilcHmac hmac_send, hmac_receive;
   SilcHash hash;
 
+  sconn->op = NULL;
+
   if (status != SILC_SKE_STATUS_OK) {
     /* SKE failed */
     SILC_LOG_ERROR(("Error (%s) during Key Exchange protocol with %s (%s)",
@@ -1592,6 +1572,8 @@
     silc_ske_free(ske);
     silc_server_disconnect_remote(server, sconn->sock,
 				  SILC_STATUS_ERR_KEY_EXCHANGE_FAILED, NULL);
+    if (sconn->callback)
+      (*sconn->callback)(server, NULL, sconn->callback_context);
     silc_server_connection_free(sconn);
     return;
   }
@@ -1608,6 +1590,8 @@
     silc_ske_free(ske);
     silc_server_disconnect_remote(server, sconn->sock,
 				  SILC_STATUS_ERR_KEY_EXCHANGE_FAILED, NULL);
+    if (sconn->callback)
+      (*sconn->callback)(server, NULL, sconn->callback_context);
     silc_server_connection_free(sconn);
     return;
   }
@@ -1625,6 +1609,8 @@
     silc_ske_free(ske);
     silc_server_disconnect_remote(server, sconn->sock,
 				  SILC_STATUS_ERR_RESOURCE_LIMIT, NULL);
+    if (sconn->callback)
+      (*sconn->callback)(server, NULL, sconn->callback_context);
     silc_server_connection_free(sconn);
     return;
   }
@@ -1646,11 +1632,14 @@
     }
   }
 
+  entry->data.rekey = rekey;
+
   /* Start connection authentication */
-  silc_connauth_initiator(connauth, server->server_type == SILC_ROUTER ?
-			  SILC_CONN_ROUTER : SILC_CONN_SERVER, auth_meth,
-			  auth_data, auth_data_len,
-			  silc_server_ke_auth_compl, sconn);
+  sconn->op =
+    silc_connauth_initiator(connauth, server->server_type == SILC_SERVER ?
+			    SILC_CONN_SERVER : SILC_CONN_ROUTER, auth_meth,
+			    auth_data, auth_data_len,
+			    silc_server_ke_auth_compl, sconn);
 }
 
 /* Function that is called when the network connection to a router has
@@ -1674,6 +1663,8 @@
   if (!sconn->sock) {
     SILC_LOG_ERROR(("Cannot connect: cannot create packet stream"));
     silc_stream_destroy(sconn->stream);
+    if (sconn->callback)
+      (*sconn->callback)(server, NULL, sconn->callback_context);
     silc_server_connection_free(sconn);
     return;
   }
@@ -1683,6 +1674,8 @@
   if (!silc_packet_set_ids(sconn->sock, SILC_ID_SERVER, server->id,
 			   0, NULL)) {
     silc_packet_stream_destroy(sconn->sock);
+    if (sconn->callback)
+      (*sconn->callback)(server, NULL, sconn->callback_context);
     silc_server_connection_free(sconn);
     return;
   }
@@ -1711,6 +1704,8 @@
   if (!ske) {
     silc_free(entry);
     silc_packet_stream_destroy(sconn->sock);
+    if (sconn->callback)
+      (*sconn->callback)(server, NULL, sconn->callback_context);
     silc_server_connection_free(sconn);
     return;
   }
@@ -1720,7 +1715,7 @@
   /* Start key exchange protocol */
   params.version = silc_version_string;
   params.timeout_secs = server->config->key_exchange_timeout;
-  silc_ske_initiator(ske, sconn->sock, &params, NULL);
+  sconn->op = silc_ske_initiator(ske, sconn->sock, &params, NULL);
 }
 
 /* Timeout callback that will be called to retry connecting to remote
@@ -1755,6 +1750,9 @@
   if ((sconn->retry_count > param->reconnect_count) &&
       !param->reconnect_keep_trying) {
     SILC_LOG_ERROR(("Could not connect, giving up"));
+
+    if (sconn->callback)
+      (*sconn->callback)(server, NULL, sconn->callback_context);
     silc_server_connection_free(sconn);
     return;
   }
@@ -1797,6 +1795,9 @@
     SILC_LOG_ERROR(("Could not connect to %s:%d: %s",
 		    sconn->remote_host, sconn->remote_port,
 		    silc_net_get_error_string(status)));
+
+    if (sconn->callback)
+      (*sconn->callback)(server, NULL, sconn->callback_context);
     silc_server_connection_free(sconn);
     break;
 
@@ -1808,7 +1809,10 @@
       silc_schedule_task_add_timeout(sconn->server->schedule,
 				     silc_server_connect_to_router_retry,
 				     sconn, 1, 0);
+      silc_dlist_del(server->conns, sconn);
     } else {
+      if (sconn->callback)
+	(*sconn->callback)(server, NULL, sconn->callback_context);
       silc_server_connection_free(sconn);
     }
     break;
@@ -1827,6 +1831,8 @@
 
   /* Don't connect if we are shutting down. */
   if (server->server_shutdown) {
+    if (sconn->callback)
+      (*sconn->callback)(server, NULL, sconn->callback_context);
     silc_server_connection_free(sconn);
     return;
   }
@@ -1887,7 +1893,6 @@
 		   "normal server" : server->server_type == SILC_ROUTER ?
 		   "router" : "backup router/normal server")));
 
-  /* XXX */
   if (!server->config->routers) {
     /* There wasn't a configured router, we will continue but we don't
        have a connection to outside world.  We will be standalone server. */
@@ -1896,6 +1901,12 @@
     return;
   }
 
+  /* Cancel any possible retry timeouts */
+  silc_schedule_task_del_by_callback(server->schedule,
+				     silc_server_connect_router);
+  silc_schedule_task_del_by_callback(server->schedule,
+				     silc_server_connect_to_router_retry);
+
   /* Create the connections to all our routes */
   for (ptr = server->config->routers; ptr; ptr = ptr->next) {
 
@@ -1919,7 +1930,8 @@
 					  silc_net_is_ip(ptr->host) ?
 					  ptr->host : NULL,
 					  silc_net_is_ip(ptr->host) ?
-					  NULL : ptr->host, ptr->port)) {
+					  NULL : ptr->host, ptr->port,
+					  SILC_CONN_ROUTER)) {
       SILC_LOG_DEBUG(("We are already connected to %s:%d",
 		      ptr->host, ptr->port));
 
@@ -1937,11 +1949,8 @@
 	if (!sock)
 	  continue;
 	server->backup_noswitch = TRUE;
-#if 0
-	if (sock->user_data)
-	  silc_server_free_sock_user_data(server, sock, NULL);
+	silc_server_free_sock_user_data(server, sock, NULL);
 	silc_server_disconnect_remote(server, sock, 0, NULL);
-#endif /* 0 */
 	server->backup_noswitch = FALSE;
 	SILC_LOG_DEBUG(("Reconnecting to primary router"));
       } else {
@@ -1953,6 +1962,7 @@
     sconn = silc_calloc(1, sizeof(*sconn));
     if (!sconn)
       continue;
+    sconn->server = server;
     sconn->remote_host = strdup(ptr->host);
     sconn->remote_port = ptr->port;
     sconn->backup = ptr->backup_router;
@@ -1961,7 +1971,8 @@
       sconn->backup_replace_port = ptr->backup_replace_port;
     }
 
-    /* XXX */
+    SILC_LOG_DEBUG(("Created connection %p", sconn));
+
     if (!server->router_conn && !sconn->backup)
       server->router_conn = sconn;
 
@@ -2017,7 +2028,13 @@
 
   /* Remote end is server */
   if (conn_type == SILC_CONN_SERVER) {
-    SilcServerConfigServer *sconfig = entry->sconfig.ref_ptr;
+    SilcServerConfigServer *sconfig;
+
+    /* If we are normal server, don't accept the connection */
+    if (server->server_type == SILC_SERVER)
+      return FALSE;
+
+    sconfig = entry->sconfig.ref_ptr;
     if (!sconfig)
       return FALSE;
 
@@ -2061,11 +2078,12 @@
   SilcServerConfigConnParams *param = &server->config->param;
   SilcServerConnection sconn;
   void *id_entry;
-  const char *hostname;
+  const char *hostname, *ip;
   SilcUInt16 port;
 
+  entry->op = NULL;
   silc_socket_stream_get_info(silc_packet_stream_get_stream(sock),
-			      NULL, &hostname, NULL, &port);
+			      NULL, &hostname, &ip, &port);
 
   if (success == FALSE) {
     /* Authentication failed */
@@ -2185,7 +2203,7 @@
       SilcBool backup_router = FALSE;
       char *backup_replace_ip = NULL;
       SilcUInt16 backup_replace_port = 0;
-      SilcServerConfigServer *sconn = entry->sconfig.ref_ptr;
+      SilcServerConfigServer *srvconn = entry->sconfig.ref_ptr;
       SilcServerConfigRouter *rconn = entry->rconfig.ref_ptr;
 
       /* If we are backup router and this is incoming server connection
@@ -2244,14 +2262,14 @@
 	if (!silc_server_connection_allowed(server, sock,
 					    entry->data.conn_type,
 					    &server->config->param,
-					    sconn ? sconn->param : NULL,
+					    srvconn ? srvconn->param : NULL,
 					    silc_connauth_get_ske(connauth))) {
 	  server->stat.auth_failures++;
 	  goto out;
 	}
-	if (sconn) {
-	  if (sconn->param) {
-	    param = sconn->param;
+	if (srvconn) {
+	  if (srvconn->param) {
+	    param = srvconn->param;
 
 	    if (!param->keepalive_secs)
 	      param->keepalive_secs = server->config->param.keepalive_secs;
@@ -2265,14 +2283,13 @@
 	    }
 	  }
 
-	  backup_router = sconn->backup_router;
+	  backup_router = srvconn->backup_router;
 	}
       }
 
       /* If we are primary router and we have backup router configured
 	 but it has not connected to use yet, do not accept any other
 	 connection. */
-#if 0
       if (server->wait_backup && server->server_type == SILC_ROUTER &&
 	  !server->backup_router && !backup_router) {
 	SilcServerConfigRouter *router;
@@ -2297,7 +2314,6 @@
 	  goto out;
 	}
       }
-#endif /* 0 */
 
       SILC_LOG_DEBUG(("Remote host is %s",
 		      entry->data.conn_type == SILC_CONN_SERVER ?
@@ -2358,9 +2374,11 @@
       if (entry->data.conn_type == SILC_CONN_SERVER) {
 	server->stat.my_servers++;
 	server->stat.servers++;
+	SILC_LOG_DEBUG(("my_servers %d", server->stat.my_servers));
       } else {
 	server->stat.my_routers++;
 	server->stat.routers++;
+	SILC_LOG_DEBUG(("my_routers %d", server->stat.my_routers));
       }
 
       /* Check whether this connection is to be our primary router connection
@@ -2402,15 +2420,7 @@
   silc_packet_set_context(sock, id_entry);
 
   /* Connection has been fully established now. Everything is ok. */
-  SILC_LOG_DEBUG(("New connection authenticated"));
-
-#if 0
-  /* Perform keepalive. */
-  if (param->keepalive_secs)
-    silc_socket_set_heartbeat(sock, param->keepalive_secs, server,
-			      silc_server_perform_heartbeat,
-			      server->schedule);
-#endif
+  SILC_LOG_DEBUG(("New connection %p authenticated", sconn));
 
   /* Perform Quality of Service */
   if (param->qos)
@@ -2448,6 +2458,8 @@
   unsigned char *pk;
   SilcUInt32 pk_len;
 
+  entry->op = NULL;
+
   if (status != SILC_SKE_STATUS_OK) {
     /* SKE failed */
     SILC_LOG_ERROR(("Error (%s) during Key Exchange protocol with %s (%s)",
@@ -2491,8 +2503,9 @@
   }
 
   /* Start connection authentication */
-  silc_connauth_responder(connauth, silc_server_accept_get_auth,
-			  silc_server_accept_auth_compl, sock);
+  entry->op =
+    silc_connauth_responder(connauth, silc_server_accept_get_auth,
+			    silc_server_accept_auth_compl, sock);
 }
 
 /* Accept new TCP connection */
@@ -2597,6 +2610,7 @@
   entry->ip = ip;
   entry->port = port;
   entry->server = server;
+  entry->data.conn_type = SILC_CONN_UNKNOWN;
   silc_packet_set_context(packet_stream, entry);
 
   silc_server_config_ref(&entry->cconfig, server->config, cconfig);
@@ -2633,7 +2647,7 @@
   /* Start key exchange protocol */
   params.version = silc_version_string;
   params.timeout_secs = server->config->key_exchange_timeout;
-  silc_ske_responder(ske, packet_stream, &params);
+  entry->op = silc_ske_responder(ske, packet_stream, &params);
 }
 
 
@@ -2699,8 +2713,8 @@
 		  SILC_CONNTYPE_STRING(idata->conn_type)));
 
   /* Allocate SKE */
-  ske = silc_ske_alloc(server->rng, server->schedule, server->repository,
-		       server->public_key, server->private_key, sock);
+  ske = silc_ske_alloc(server->rng, server->schedule, NULL,
+		       server->public_key, NULL, sock);
   if (!ske)
     return;
 
@@ -2752,8 +2766,8 @@
 		  SILC_CONNTYPE_STRING(idata->conn_type)));
 
   /* Allocate SKE */
-  ske = silc_ske_alloc(server->rng, server->schedule, server->repository,
-		       server->public_key, server->private_key, sock);
+  ske = silc_ske_alloc(server->rng, server->schedule, NULL,
+		       server->public_key, NULL, sock);
   if (!ske) {
     silc_packet_free(packet);
     return;
@@ -2786,20 +2800,6 @@
   char tmp[128];
   const char *hostname;
   SilcUInt16 port;
-
-#if 0
-  /* If any protocol is active cancel its execution. It will call
-     the final callback which will finalize the disconnection. */
-  if (sock->protocol && sock->protocol->protocol &&
-      sock->protocol->protocol->type != SILC_PROTOCOL_SERVER_BACKUP) {
-    SILC_LOG_DEBUG(("Cancelling protocol, calling final callback"));
-    silc_protocol_cancel(sock->protocol, server->schedule);
-    sock->protocol->state = SILC_PROTOCOL_STATE_ERROR;
-    silc_protocol_execute_final(sock->protocol, server->schedule);
-    sock->protocol = NULL;
-    return;
-  }
-#endif
 
   memset(tmp, 0, sizeof(tmp));
   //  silc_socket_get_error(sock, tmp, sizeof(tmp));
@@ -2811,8 +2811,15 @@
 
   //  silc_socket_set_qos(sock, 0, 0, 0, 0, NULL);
 
+  if (idata && idata->sconn) {
+    silc_server_connection_free(idata->sconn);
+    idata->sconn = NULL;
+  }
+
   /* Close connection with timeout */
   server->stat.conn_num--;
+  silc_schedule_task_del_by_all(server->schedule, 0,
+				silc_server_close_connection_final, sock);
   silc_schedule_task_add_timeout(server->schedule,
 				 silc_server_close_connection_final,
 				 sock, 0, 1);
@@ -2848,16 +2855,6 @@
 
   /* Close connection */
   silc_server_close_connection(server, sock);
-}
-
-SILC_TASK_CALLBACK(silc_server_free_client_data_timeout)
-{
-  SilcClientEntry client = context;
-
-  assert(!silc_hash_table_count(client->channels));
-
-  silc_idlist_del_data(client);
-  //  silc_idcache_purge_by_context(server->local_list->clients, client);
 }
 
 /* Frees client data and notifies about client's signoff. */
@@ -2910,18 +2907,19 @@
   SILC_OPER_STATS_UPDATE(client, router, SILC_UMODE_ROUTER_OPERATOR);
   silc_schedule_task_del_by_context(server->schedule, client);
 
+  if (client->data.sconn)
+    silc_server_connection_free(client->data.sconn);
+
   /* We will not delete the client entry right away. We will take it
      into history (for WHOWAS command) for 5 minutes, unless we're
      shutting down server. */
   if (!server->server_shutdown) {
-    silc_schedule_task_add_timeout(server->schedule,
-				   silc_server_free_client_data_timeout,
-				   client, 600, 0);
     client->data.status &= ~SILC_IDLIST_STATUS_REGISTERED;
-    client->data.status &= ~SILC_IDLIST_STATUS_LOCAL;
     client->mode = 0;
     client->router = NULL;
     client->connection = NULL;
+    client->data.created = silc_time();
+    silc_dlist_add(server->expired_clients, client);
   } else {
     /* Delete directly since we're shutting down server */
     SILC_LOG_DEBUG(("Delete client directly"));
@@ -2939,6 +2937,8 @@
 				     const char *signoff_message)
 {
   SilcIDListData idata = silc_packet_get_context(sock);
+  const char *ip;
+  SilcUInt16 port;
 
   SILC_LOG_DEBUG(("Start"));
 
@@ -2946,6 +2946,19 @@
     return;
 
   silc_schedule_task_del_by_context(server->schedule, sock);
+
+  /* Cancel active protocols */
+  if (idata) {
+    if (idata->sconn && idata->sconn->op) {
+      SILC_LOG_DEBUG(("Abort active protocol"));
+      silc_async_abort(idata->sconn->op, NULL, NULL);
+    }
+    if (idata->conn_type == SILC_CONN_UNKNOWN &&
+        ((SilcUnknownEntry)idata)->op) {
+      SILC_LOG_DEBUG(("Abort active protocol"));
+      silc_async_abort(((SilcUnknownEntry)idata)->op, NULL, NULL);
+    }
+  }
 
   switch (idata->conn_type) {
   case SILC_CONN_CLIENT:
@@ -2975,6 +2988,9 @@
 
       if (server->server_shutdown || server->backup_noswitch)
       	backup_router = NULL;
+
+      silc_socket_stream_get_info(silc_packet_stream_get_stream(sock),
+				  NULL, NULL, &ip, &port);
 
       /* If this was our primary router connection then we're lost to
 	 the outside world. */
@@ -3012,17 +3028,15 @@
 	  /* We stop here to take a breath */
 	  sleep(2);
 
-#if 0
 	  if (server->backup_router) {
 	    server->server_type = SILC_ROUTER;
 
 	    /* We'll need to constantly try to reconnect to the primary
 	       router so that we'll see when it comes back online. */
-	    silc_server_backup_reconnect(server, sock->ip, sock->port,
+	    silc_server_create_connection(server, FALSE, FALSE, ip, port,
 					 silc_server_backup_connected,
 					 NULL);
 	  }
-#endif /* 0 */
 
 	  /* Mark this connection as replaced */
 	  silc_server_backup_replaced_add(server, user_data->id,
@@ -3114,21 +3128,28 @@
       }
       server->backup_noswitch = FALSE;
 
+      if (idata->sconn)
+	silc_server_connection_free(idata->sconn);
+
+      /* Statistics */
+      if (idata->conn_type == SILC_CONN_SERVER) {
+	server->stat.my_servers--;
+	server->stat.servers--;
+	SILC_LOG_DEBUG(("my_servers %d", server->stat.my_servers));
+      } else if (idata->conn_type == SILC_CONN_ROUTER) {
+	server->stat.my_routers--;
+	server->stat.routers--;
+	SILC_LOG_DEBUG(("my_routers %d", server->stat.my_routers));
+      }
+      if (server->server_type == SILC_ROUTER)
+	server->stat.cell_servers--;
+
       /* Free the server entry */
       silc_server_backup_del(server, user_data);
       silc_server_backup_replaced_del(server, user_data);
       silc_idlist_del_data(user_data);
       if (!silc_idlist_del_server(server->local_list, user_data))
 	silc_idlist_del_server(server->global_list, user_data);
-      if (idata->conn_type == SILC_CONN_SERVER) {
-	server->stat.my_servers--;
-	server->stat.servers--;
-      } else {
-	server->stat.my_routers--;
-	server->stat.routers--;
-      }
-      if (server->server_type == SILC_ROUTER)
-	server->stat.cell_servers--;
 
       if (backup_router && backup_router != server->id_entry) {
 	/* Announce all of our stuff that was created about 5 minutes ago.
@@ -3154,6 +3175,8 @@
 
       SILC_LOG_DEBUG(("Freeing unknown connection data"));
 
+      if (idata->sconn)
+	silc_server_connection_free(idata->sconn);
       silc_idlist_del_data(idata);
       silc_free(entry);
       silc_packet_set_context(sock, NULL);
@@ -3933,6 +3956,9 @@
 	continue;
       if (!client->connection && !client->router)
 	continue;
+
+      SILC_LOG_DEBUG(("Announce Client ID %s",
+		      silc_id_render(client->id, SILC_ID_CLIENT)));
 
       idp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
 
@@ -4161,6 +4187,9 @@
   while (silc_hash_table_get(&htl, NULL, (void *)&chl)) {
     clidp = silc_id_payload_encode(chl->client->id, SILC_ID_CLIENT);
 
+    SILC_LOG_DEBUG(("JOIN Client %s", silc_id_render(chl->client->id,
+						     SILC_ID_CLIENT)));
+
     /* JOIN Notify */
     tmp = silc_server_announce_encode_notify(SILC_NOTIFY_TYPE_JOIN, 2,
 					     clidp->data,
@@ -4254,6 +4283,9 @@
       else
 	announce = TRUE;
 
+      SILC_LOG_DEBUG(("Announce Channel ID %s",
+		      silc_id_render(channel->id, SILC_ID_CHANNEL)));
+
       silc_id_id2str(channel->id, SILC_ID_CHANNEL, cid, sizeof(cid), &id_len);
       name_len = strlen(channel->channel_name);
 
@@ -4558,10 +4590,10 @@
 /* Assembles user list and users mode list from the `channel'. */
 
 SilcBool silc_server_get_users_on_channel(SilcServer server,
-				      SilcChannelEntry channel,
-				      SilcBuffer *user_list,
-				      SilcBuffer *mode_list,
-				      SilcUInt32 *user_count)
+					  SilcChannelEntry channel,
+					  SilcBuffer *user_list,
+					  SilcBuffer *mode_list,
+					  SilcUInt32 *user_count)
 {
   SilcChannelClientEntry chl;
   SilcHashTableList htl;

Modified: silc-server/branches/upstream/current/apps/silcd/server.h
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/apps/silcd/server.h?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/apps/silcd/server.h (original)
+++ silc-server/branches/upstream/current/apps/silcd/server.h Sun Jul  1 19:18:19 2007
@@ -119,11 +119,6 @@
 			        type, 1, __fmt__, strlen(__fmt__));	\
   silc_free(__fmt__);							\
 } while(0)
-
-/* Check whether rekey protocol is active */
-#define SILC_SERVER_IS_REKEY(sock)					\
-  (sock->protocol && sock->protocol->protocol && 			\
-   sock->protocol->protocol->type == SILC_PROTOCOL_SERVER_REKEY)
 
 /* Output a message to stderr or to the appropriate log facility wether
    we are in the background or not. */

Modified: silc-server/branches/upstream/current/apps/silcd/server_backup.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/apps/silcd/server_backup.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/apps/silcd/server_backup.c (original)
+++ silc-server/branches/upstream/current/apps/silcd/server_backup.c Sun Jul  1 19:18:19 2007
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone at silcnet.org>
 
-  Copyright (C) 2001 - 2005, 2007 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
@@ -16,13 +16,12 @@
   GNU General Public License for more details.
 
 */
-/* $Id: server_backup.c,v 1.40 2007/04/22 18:27:13 priikone Exp $ */
+/* $Id: server_backup.c,v 1.40.2.4 2007/07/01 16:06:58 priikone Exp $ */
 
 #include "serverincludes.h"
 #include "server_internal.h"
 
 SILC_TASK_CALLBACK(silc_server_protocol_backup_done);
-SILC_TASK_CALLBACK(silc_server_backup_connect_to_router);
 SILC_TASK_CALLBACK(silc_server_backup_announce_watches);
 
 static void silc_server_backup_connect_primary(SilcServer server,
@@ -72,6 +71,7 @@
   SilcUInt32 sessions_count;
   SilcUInt32 initiator_restart;
   long start;
+  int state;
   unsigned int responder        : 1;
   unsigned int received_failure : 1;
   unsigned int timeout          : 1;
@@ -108,7 +108,8 @@
   }
 
   SILC_LOG_DEBUG(("Backup router %s will replace %s",
-		  backup_server->data.sconn->remote_host, ip, port));
+		  backup_server->data.sconn ?
+		  backup_server->data.sconn->remote_host : "(me)", ip));
 
   for (i = 0; i < server->backup->servers_count; i++) {
     if (!server->backup->servers[i].server) {
@@ -551,10 +552,10 @@
     /* The primary is not down, refuse to serve the server as primary */
     SILC_LOG_DEBUG(("PING received, primary is up"));
     silc_server_backup_send_start_use(pc->server, pc->sock, TRUE);
+    silc_packet_free(pc->packet);
   }
 
   silc_packet_stream_unref(pc->sock);
-  silc_packet_free(pc->packet);
   silc_free(pc);
 }
 
@@ -567,6 +568,7 @@
 				      SilcPacket packet)
 {
   SilcIDListData idata = silc_packet_get_context(sock);
+  SilcServerEntry router = (SilcServerEntry)idata;
   SilcUInt8 type, session;
   SilcServerBackupProtocolContext ctx;
   int i, ret;
@@ -644,7 +646,6 @@
 				      silc_server_backup_ping_reply, pc, 15);
     return;
   }
-
 
   /* Start the resuming protocol if requested. */
   if (type == SILC_SERVER_BACKUP_START) {
@@ -677,6 +678,8 @@
     proto_ctx->session = session;
     proto_ctx->start = time(0);
     silc_packet_stream_ref(sock);
+    router->backup = TRUE;
+    router->backup_proto = proto_ctx;
 
     SILC_LOG_DEBUG(("Starting backup resuming protocol as responder"));
     SILC_LOG_INFO(("Starting backup resuming protocol"));
@@ -704,39 +707,35 @@
     return;
   }
 
-#if 0
   /* Activate the shared protocol context for this socket connection
      if necessary */
   if (type == SILC_SERVER_BACKUP_RESUMED &&
-      idata->conn_type == SILC_CONN_ROUTER && !sock->protocol &&
+      idata->conn_type == SILC_CONN_ROUTER && !router->backup &&
       idata->status & SILC_IDLIST_STATUS_DISABLED) {
     SilcServerEntry backup_router;
 
-    if (silc_server_backup_replaced_get(server, ((SilcServerEntry)idata)->id,
-					&backup_router)) {
-      SilcPacketStream bsock =
-	(SilcSocketConnection)backup_router->connection;
-      if (bsock->protocol && bsock->protocol->protocol &&
-	  bsock->protocol->protocol->type == SILC_PROTOCOL_SERVER_BACKUP) {
-	sock->protocol = bsock->protocol;
-	ctx = sock->protocol->context;
-	if (ctx->sock)
-	  silc_socket_free(ctx->sock); /* unref */
-	ctx->sock = silc_socket_dup(sock);
-      }
-    }
-  }
-
+    if (silc_server_backup_replaced_get(server, router->id, &backup_router)) {
+      ctx = backup_router->backup_proto;
+      if (ctx->sock)
+	silc_packet_stream_unref(ctx->sock);
+      router->backup = TRUE;
+      router->backup_proto = ctx;
+      ctx->sock = sock;
+      silc_packet_stream_ref(sock);
+    }
+  }
 
   /* Call the resuming protocol if the protocol is active. */
-  if (SILC_SERVER_IS_BACKUP(sock)) {
-    ctx = sock->protocol->context;
+  if (router->backup) {
+    ctx = router->backup_proto;
     ctx->type = type;
 
     for (i = 0; i < ctx->sessions_count; i++) {
       if (session == ctx->sessions[i].session) {
 	ctx->session = session;
-	silc_protocol_execute(sock->protocol, server->schedule, 0, 0);
+	silc_schedule_task_add_timeout(server->schedule,
+				       silc_server_protocol_backup,
+				       ctx, 0, 1);
 	silc_packet_free(packet);
 	return;
       }
@@ -744,7 +743,9 @@
 
     /* If RESUMED received the session ID is zero, execute the protocol. */
     if (type == SILC_SERVER_BACKUP_RESUMED) {
-      silc_protocol_execute(sock->protocol, server->schedule, 0, 0);
+      silc_schedule_task_add_timeout(server->schedule,
+				     silc_server_protocol_backup,
+				     ctx, 0, 1);
       silc_packet_free(packet);
       return;
     }
@@ -753,7 +754,6 @@
     silc_packet_free(packet);
     return;
   }
-#endif /* 0 */
 
   silc_packet_free(packet);
 }
@@ -766,7 +766,6 @@
   SilcServerBackupProtocolContext proto_ctx =
     (SilcServerBackupProtocolContext)context;
   SilcServer server = proto_ctx->server;
-  SilcPacketStream sock = proto_ctx->sock;
 
   SILC_LOG_DEBUG(("Starting backup resuming protocol as initiator"));
   SILC_LOG_INFO(("Starting backup resuming protocol"));
@@ -813,7 +812,7 @@
     /* Try again */
     silc_schedule_task_add_timeout(server->schedule,
 				   silc_server_backup_connected_again,
-				   context, 0, 0);
+				   context, 5, 0);
     return;
   }
 
@@ -857,11 +856,11 @@
 					       SilcServerEntry server_entry,
 					       void *context)
 {
-#if 0
   SilcPacketStream backup_router = context;
+  SilcIDListData idata = silc_packet_get_context(backup_router);
+  SilcServerEntry router = (SilcServerEntry)idata;
   SilcServerBackupProtocolContext ctx;
   SilcPacketStream sock;
-  SilcIDListData idata;
   unsigned char data[2];
 
   if (!server_entry) {
@@ -872,16 +871,13 @@
     return;
   }
 
-  /* Unref */
-  silc_packet_stream_unref(backup_router);
-
-  if (!backup_router->protocol)
-    return;
-  if (!server_entry->connection)
-    return;
-
-  ctx = (SilcServerBackupProtocolContext)backup_router->protocol->context;
-  sock = (SilcSocketConnection)server_entry->connection;
+  if (!router->backup || !server_entry->connection) {
+    silc_packet_stream_unref(backup_router);
+    return;
+  }
+
+  ctx = router->backup_proto;
+  sock = server_entry->connection;
   idata = (SilcIDListData)server_entry;
 
   SILC_LOG_DEBUG(("Sending CONNECTED packet (session %d)", ctx->session));
@@ -892,7 +888,7 @@
   data[0] = SILC_SERVER_BACKUP_CONNECTED;
   data[1] = ctx->session;
   silc_server_packet_send(server, backup_router,
-			  SILC_PACKET_RESUME_ROUTER, 0, data, 2, FALSE);
+			  SILC_PACKET_RESUME_ROUTER, 0, data, 2);
 
   /* The primary connection is disabled until it sends the RESUMED packet
      to us. */
@@ -902,12 +898,17 @@
      the primary router connection since it will send the subsequent
      packets in this protocol. We don't talk with backup router
      anymore. */
-  sock->protocol = backup_router->protocol;
   if (ctx->sock)
-    silc_socket_free(ctx->sock); /* unref */
-  ctx->sock = silc_socket_dup(server_entry->connection);
-  backup_router->protocol = NULL;
-#endif /* 0 */x
+    silc_packet_stream_unref(ctx->sock);
+  ctx->sock = sock;
+  silc_packet_stream_ref(sock);
+  server_entry->backup = TRUE;
+  server_entry->backup_proto = ctx;
+  router->backup = FALSE;
+  router->backup_proto = NULL;
+
+  /* Unref */
+  silc_packet_stream_unref(backup_router);
 }
 
 /* Timeout callback used by the backup router to send the ENDING packet
@@ -916,7 +917,6 @@
 
 SILC_TASK_CALLBACK(silc_server_backup_send_resumed)
 {
-#if 0
   SilcServerBackupProtocolContext ctx = context;
   SilcServer server = ctx->server;
   unsigned char data[2];
@@ -925,7 +925,7 @@
   SILC_LOG_DEBUG(("Start"));
 
   for (i = 0; i < ctx->sessions_count; i++)
-    if (ctx->sessions[i].server_entry == ctx->sock->user_data)
+    if (ctx->sessions[i].server_entry == silc_packet_get_context(ctx->sock))
       ctx->session = ctx->sessions[i].session;
 
   /* We've received all the CONNECTED packets and now we'll send the
@@ -936,8 +936,7 @@
 			  data, sizeof(data));
 
   /* The protocol will go to END state. */
-  protocol->state = SILC_PROTOCOL_STATE_END;
-#endif /* 0 */
+  ctx->state = 250;
 }
 
 /* Backup resuming protocol. This protocol is executed when the primary
@@ -945,19 +944,19 @@
 
 SILC_TASK_CALLBACK(silc_server_protocol_backup)
 {
-#if 0
   SilcServerBackupProtocolContext ctx = context;
   SilcServer server = ctx->server;
-  SilcServerEntry server_entry;
+  SilcServerEntry server_entry = NULL;
   SilcPacketStream sock = NULL;
   unsigned char data[2];
+  SilcDList list;
   int i;
 
-  if (protocol->state == SILC_PROTOCOL_STATE_UNKNOWN)
-    protocol->state = SILC_PROTOCOL_STATE_START;
-
-  switch(protocol->state) {
-  case SILC_PROTOCOL_STATE_START:
+  if (!ctx->state)
+    ctx->state = 1;
+
+  switch(ctx->state) {
+  case 1:
     if (ctx->responder == FALSE) {
       /*
        * Initiator (backup router)
@@ -967,15 +966,19 @@
 	 packet will indicate to the primary router that it has been replaced
 	 by us.  For normal servers it means that we will be resigning as
 	 being primary router shortly. */
-      for (i = 0; i < server->config->param.connections_max; i++) {
-	sock = server->sockets[i];
-	if (!sock || !sock->user_data ||
-	    sock->user_data == server->id_entry ||
-	    (sock->type != SILC_CONN_ROUTER &&
-	     sock->type != SILC_CONN_SERVER))
+      list = silc_packet_engine_get_streams(server->packet_engine);
+      if (!list)
+	return;
+
+      silc_dlist_start(list);
+      while ((sock = silc_dlist_get(list))) {
+	server_entry = silc_packet_get_context(sock);
+
+	if (!server_entry || server_entry == server->id_entry ||
+	    (server_entry->data.conn_type != SILC_CONN_ROUTER &&
+	     server_entry->data.conn_type != SILC_CONN_SERVER))
 	  continue;
 
-	server_entry = sock->user_data;
 	if (server_entry->data.status & SILC_IDLIST_STATUS_DISABLED)
 	  continue;
 
@@ -992,21 +995,23 @@
 		       server_entry->server_name, ctx->sessions_count));
 
 	/* This connection is performing this protocol too now */
-	sock->protocol = protocol;
+	server_entry->backup = TRUE;
+	server_entry->backup_proto = ctx;
 
 	data[0] = SILC_SERVER_BACKUP_START;
 	data[1] = ctx->sessions_count;
 	silc_server_packet_send(server, sock, SILC_PACKET_RESUME_ROUTER, 0,
-				data, sizeof(data), FALSE);
+				data, sizeof(data));
 	ctx->sessions_count++;
       }
+      silc_packet_engine_free_streams_list(list);
 
       /* Announce data to the new primary to be. */
       silc_server_announce_servers(server, TRUE, 0, ctx->sock);
       silc_server_announce_clients(server, 0, ctx->sock);
       silc_server_announce_channels(server, 0, ctx->sock);
 
-      protocol->state++;
+      ctx->state++;
 
     } else {
       /*
@@ -1034,10 +1039,11 @@
 					     SILC_CONN_ROUTER)) {
 	SILC_LOG_DEBUG(("Received START (session %d), reconnect to router",
 			ctx->session));
+	silc_packet_stream_ref(ctx->sock);
 	silc_server_create_connection(server, FALSE, FALSE,
 				      primary->host, primary->port,
 				      silc_server_backup_connect_primary,
-				      silc_socket_dup(ctx->sock));
+				      ctx->sock);
       } else {
 	/* Nowhere to connect just return the CONNECTED packet */
 	SILC_LOG_DEBUG(("Received START (session %d), send CONNECTED back",
@@ -1050,7 +1056,7 @@
 	data[1] = ctx->session;
 	silc_server_packet_send(server, ctx->sock,
 				SILC_PACKET_RESUME_ROUTER, 0,
-				data, sizeof(data), FALSE);
+				data, sizeof(data));
       }
 
       /* Add this resuming session */
@@ -1064,9 +1070,9 @@
       if (server->server_type == SILC_ROUTER &&
 	  (!server->router ||
 	   server->router->data.status & SILC_IDLIST_STATUS_DISABLED))
-	protocol->state++;
+	ctx->state++;
       else
-	protocol->state = SILC_PROTOCOL_STATE_END;
+	ctx->state = 250;
     }
     break;
 
@@ -1105,10 +1111,9 @@
 
       /* The ENDING is sent with timeout, and then we continue to the
 	 END state in the protocol. */
-      silc_schedule_task_add(server->schedule, 0,
-			     silc_server_backup_send_resumed,
-			     protocol, 1, 0, SILC_TASK_TIMEOUT,
-			     SILC_TASK_PRI_NORMAL);
+      silc_schedule_task_add_timeout(server->schedule,
+				     silc_server_backup_send_resumed,
+				     ctx, 1, 0);
       return;
 
     } else {
@@ -1127,69 +1132,89 @@
       /* Switch announced informations to our primary router of using the
 	 backup router. */
       silc_server_local_servers_toggle_enabled(server, TRUE);
-      silc_server_update_servers_by_server(server, ctx->sock->user_data,
-					   server->router);
-      silc_server_update_clients_by_server(server, ctx->sock->user_data,
+      silc_server_update_servers_by_server(server,
+					   silc_packet_get_context(ctx->sock),
+ 					   server->router);
+      silc_server_update_clients_by_server(server,
+					   silc_packet_get_context(ctx->sock),
 					   server->router, TRUE);
 
       /* We as primary router now must send RESUMED packets to all servers
 	 and routers so that they know we are back.   For backup router we
 	 send the packet last so that we give the backup as much time as
 	 possible to deal with message routing at this critical moment. */
-      for (i = 0; i < server->config->param.connections_max; i++) {
-	sock = server->sockets[i];
-	if (!sock || !sock->user_data ||
-	    sock->user_data == server->id_entry ||
-	    (sock->type != SILC_CONN_ROUTER &&
-	     sock->type != SILC_CONN_SERVER))
+      list = silc_packet_engine_get_streams(server->packet_engine);
+      if (!list)
+	return;
+
+      silc_dlist_start(list);
+      while ((sock = silc_dlist_get(list))) {
+	server_entry = silc_packet_get_context(sock);
+
+	if (!server_entry || server_entry == server->id_entry ||
+	    (server_entry->data.conn_type != SILC_CONN_ROUTER &&
+	     server_entry->data.conn_type != SILC_CONN_SERVER))
 	  continue;
 
 	/* Send to backup last */
 	if (sock == ctx->sock)
 	  continue;
 
-      send_to_backup:
-	server_entry = sock->user_data;
+	server_entry = silc_packet_get_context(sock);
 	server_entry->data.status &= ~SILC_IDLIST_STATUS_DISABLED;
 
 	SILC_LOG_DEBUG(("Sending RESUMED to %s", server_entry->server_name));
 	SILC_LOG_INFO(("Sending RESUMED to %s", server_entry->server_name));
 
 	/* This connection is performing this protocol too now */
-	sock->protocol = protocol;
+	server_entry->backup = TRUE;
+	server_entry->backup_proto = ctx;
 
 	data[0] = SILC_SERVER_BACKUP_RESUMED;
 	data[1] = 0;
 	silc_server_packet_send(server, sock, SILC_PACKET_RESUME_ROUTER, 0,
-				data, sizeof(data), FALSE);
+				data, sizeof(data));
       }
 
       /* Now send the same packet to backup */
       if (sock != ctx->sock) {
 	sleep(1);
 	sock = ctx->sock;
-	goto send_to_backup;
+	server_entry = silc_packet_get_context(sock);
+	server_entry->data.status &= ~SILC_IDLIST_STATUS_DISABLED;
+
+	SILC_LOG_DEBUG(("Sending RESUMED to %s", server_entry->server_name));
+	SILC_LOG_INFO(("Sending RESUMED to %s", server_entry->server_name));
+
+	/* This connection is performing this protocol too now */
+	server_entry->backup = TRUE;
+	server_entry->backup_proto = ctx;
+
+	data[0] = SILC_SERVER_BACKUP_RESUMED;
+	data[1] = 0;
+	silc_server_packet_send(server, sock, SILC_PACKET_RESUME_ROUTER, 0,
+				data, sizeof(data));
       }
+      silc_packet_engine_free_streams_list(list);
 
       /* We are now resumed and are back as primary router in the cell. */
       SILC_LOG_INFO(("We are now the primary router of our cell again"));
       server->wait_backup = FALSE;
 
       /* Announce WATCH list a little later */
-      silc_schedule_task_add(server->schedule, 0,
-			     silc_server_backup_announce_watches,
-			     silc_socket_dup(ctx->sock), 4, 0,
-			     SILC_TASK_TIMEOUT, SILC_TASK_PRI_NORMAL);
+      silc_packet_stream_ref(ctx->sock);
+      silc_schedule_task_add_timeout(server->schedule,
+				     silc_server_backup_announce_watches,
+				     ctx->sock, 4, 0);
 
       /* For us this is the end of this protocol. */
-      if (protocol->final_callback)
-	silc_protocol_execute_final(protocol, server->schedule);
-      else
-	silc_protocol_free(protocol);
+      silc_schedule_task_add_timeout(server->schedule,
+				     silc_server_protocol_backup_done,
+				     ctx, 0, 1);
     }
     break;
 
-  case SILC_PROTOCOL_STATE_END:
+  case 250:
     {
       /*
        * Responder (backup router, servers, and remote router)
@@ -1210,7 +1235,7 @@
 	server->server_type = SILC_BACKUP_ROUTER;
 
       /* We have now new primary router. All traffic goes there from now on. */
-      router = ctx->sock->user_data;
+      router = silc_packet_get_context(ctx->sock);
       if (silc_server_backup_replaced_get(server, router->id,
 					  &backup_router)) {
 
@@ -1249,78 +1274,70 @@
 			      server->router->server_name));
 
       /* Protocol has ended, call the final callback */
-      if (protocol->final_callback)
-	silc_protocol_execute_final(protocol, server->schedule);
-      else
-	silc_protocol_free(protocol);
+      silc_schedule_task_add_timeout(server->schedule,
+				     silc_server_protocol_backup_done,
+				     ctx, 0, 1);
     }
     break;
 
-  case SILC_PROTOCOL_STATE_ERROR:
+  case 251:
     /* Protocol has ended, call the final callback */
-    if (protocol->final_callback)
-      silc_protocol_execute_final(protocol, server->schedule);
-    else
-      silc_protocol_free(protocol);
+    silc_schedule_task_add_timeout(server->schedule,
+				   silc_server_protocol_backup_done,
+				   ctx, 0, 1);
     break;
 
-  case SILC_PROTOCOL_STATE_FAILURE:
+  case 252:
     /* Protocol has ended, call the final callback */
     SILC_LOG_ERROR(("Error during backup resume: received Failure"));
     ctx->received_failure = TRUE;
-    if (protocol->final_callback)
-      silc_protocol_execute_final(protocol, server->schedule);
-    else
-      silc_protocol_free(protocol);
+    silc_schedule_task_add_timeout(server->schedule,
+				   silc_server_protocol_backup_done,
+				   ctx, 0, 1);
     break;
 
-  case SILC_PROTOCOL_STATE_UNKNOWN:
+  default:
     break;
   }
-#endif /* 0 */
 }
 
 /* Final resuming protocol completion callback */
 
 SILC_TASK_CALLBACK(silc_server_protocol_backup_done)
 {
-#if 0
   SilcServerBackupProtocolContext ctx = context;
   SilcServer server = ctx->server;
+  SilcDList list;
   SilcServerEntry server_entry;
   SilcPacketStream sock;
   SilcBool error;
-  int i;
-
-  silc_schedule_task_del_by_context(server->schedule, protocol);
+
+  silc_schedule_task_del_by_context(server->schedule, ctx);
 
   error = ctx->error;
 
-  if (error) {
+  if (error)
     SILC_LOG_ERROR(("Error occurred during backup router resuming protcool"));
-    if (server->server_type == SILC_SERVER)
-      silc_schedule_task_del_by_callback(server->schedule,
-					 silc_server_backup_connect_to_router);
-  }
 
   if (server->server_shutdown)
     return;
 
   /* Remove this protocol from all server entries that has it */
-  for (i = 0; i < server->config->param.connections_max; i++) {
-    sock = server->sockets[i];
-    if (!sock || !sock->user_data ||
-	(sock->type != SILC_CONN_ROUTER &&
-	 sock->type != SILC_CONN_SERVER))
+  list = silc_packet_engine_get_streams(server->packet_engine);
+  if (!list)
+    return;
+
+  silc_dlist_start(list);
+  while ((sock = silc_dlist_get(list))) {
+    server_entry = silc_packet_get_context(sock);
+    if (!server_entry)
       continue;
 
-    server_entry = sock->user_data;
-
-    /* The SilcProtocol context was shared between all connections, clear
-       it from all connections. */
-    if (sock->protocol == protocol) {
-      sock->protocol = NULL;
-
+    if (server_entry->data.conn_type != SILC_CONN_ROUTER &&
+	server_entry->data.conn_type != SILC_CONN_SERVER)
+      continue;
+
+    if (server_entry->backup_proto == ctx) {
       if (error) {
 
 	if (server->server_type == SILC_SERVER &&
@@ -1330,7 +1347,7 @@
 	/* Backup router */
 	if (SILC_PRIMARY_ROUTE(server) == sock && server->backup_router) {
 	  if (ctx->sock == sock) {
-	    silc_socket_free(sock); /* unref */
+	    silc_packet_stream_unref(sock);
 	    ctx->sock = NULL;
 	  }
 
@@ -1345,18 +1362,17 @@
 	    /* Restart the protocol. */
 	    proto_ctx = silc_calloc(1, sizeof(*proto_ctx));
 	    proto_ctx->server = server;
-	    proto_ctx->sock = silc_socket_dup(sock);
+	    proto_ctx->sock = sock;
 	    proto_ctx->responder = FALSE;
 	    proto_ctx->type = SILC_SERVER_BACKUP_START;
 	    proto_ctx->start = time(0);
 	    proto_ctx->initiator_restart = ctx->initiator_restart + 1;
+	    silc_packet_stream_ref(sock);
 
 	    /* Start through scheduler */
-	    silc_schedule_task_add(server->schedule, 0,
-				   silc_server_backup_connected_later,
-				   proto_ctx, 5, 0,
-				   SILC_TASK_TIMEOUT,
-				   SILC_TASK_PRI_NORMAL);
+	    silc_schedule_task_add_timeout(server->schedule,
+					   silc_server_backup_connected_later,
+					   proto_ctx, 5, 0);
 	  } else {
 	    /* If failure was received, switch back to normal backup router.
 	       For some reason primary wouldn't accept that we were supposed
@@ -1365,20 +1381,20 @@
 	    silc_server_local_servers_toggle_enabled(server, FALSE);
 	    server_entry->data.status &= ~SILC_IDLIST_STATUS_DISABLED;
 	    silc_server_update_servers_by_server(server, server->id_entry,
-						 sock->user_data);
+						 silc_packet_get_context(sock));
 	    silc_server_update_clients_by_server(server, NULL,
-						 sock->user_data, TRUE);
+						 silc_packet_get_context(sock),
+						 TRUE);
 
 	    /* Announce our clients and channels to the router */
 	    silc_server_announce_clients(server, 0, sock);
 	    silc_server_announce_channels(server, 0, sock);
 
 	    /* Announce WATCH list a little later */
-	    silc_schedule_task_add(server->schedule, 0,
-				   silc_server_backup_announce_watches,
-				   silc_socket_dup(sock), 5, 0,
-				   SILC_TASK_TIMEOUT,
-				   SILC_TASK_PRI_NORMAL);
+	    silc_packet_stream_ref(sock);
+	    silc_schedule_task_add_timeout(server->schedule,
+					   silc_server_backup_announce_watches,
+					   sock, 5, 0);
 	  }
 
 	  continue;
@@ -1388,6 +1404,7 @@
       server_entry->data.status &= ~SILC_IDLIST_STATUS_DISABLED;
     }
   }
+  silc_packet_engine_free_streams_list(list);
 
   if (!error) {
     SILC_LOG_INFO(("Backup resuming protocol ended successfully"));
@@ -1403,10 +1420,10 @@
       silc_server_announce_channels(server, 0, server->router->connection);
 
       /* Announce WATCH list a little later */
-      silc_schedule_task_add(server->schedule, 0,
-			     silc_server_backup_announce_watches,
-			     silc_socket_dup(server->router->connection), 4, 0,
-			     SILC_TASK_TIMEOUT, SILC_TASK_PRI_NORMAL);
+      silc_packet_stream_ref(server->router->connection);
+      silc_schedule_task_add_timeout(server->schedule,
+				     silc_server_backup_announce_watches,
+				     server->router->connection, 4, 0);
     }
   } else {
     /* Error */
@@ -1421,42 +1438,42 @@
 					  FALSE);
 
 	/* Check couple of times same START_USE just in case. */
-	silc_schedule_task_add(server->schedule, 0,
-			       silc_server_backup_check_status,
-			       silc_socket_dup(server->router->connection),
-			       5, 1, SILC_TASK_TIMEOUT,
-			       SILC_TASK_PRI_NORMAL);
-	silc_schedule_task_add(server->schedule, 0,
-			       silc_server_backup_check_status,
-			       silc_socket_dup(server->router->connection),
-			       20, 1, SILC_TASK_TIMEOUT,
-			       SILC_TASK_PRI_NORMAL);
-	silc_schedule_task_add(server->schedule, 0,
-			       silc_server_backup_check_status,
-			       silc_socket_dup(server->router->connection),
-			       60, 1, SILC_TASK_TIMEOUT,
-			       SILC_TASK_PRI_NORMAL);
+	silc_packet_stream_ref(server->router->connection);
+	silc_schedule_task_add_timeout(server->schedule,
+				       silc_server_backup_check_status,
+				       server->router->connection,
+				       5, 1);
+	silc_packet_stream_ref(server->router->connection);
+	silc_schedule_task_add_timeout(server->schedule,
+				       silc_server_backup_check_status,
+				       server->router->connection,
+				       20, 1);
+	silc_packet_stream_ref(server->router->connection);
+	silc_schedule_task_add_timeout(server->schedule,
+				       silc_server_backup_check_status,
+				       server->router->connection,
+				       60, 1);
       }
     }
   }
 
-  if (ctx->sock && ctx->sock->protocol)
-    ctx->sock->protocol = NULL;
-  if (ctx->sock)
-    silc_socket_free(ctx->sock); /* unref */
-  silc_protocol_free(protocol);
+  if (ctx->sock) {
+    SilcServerEntry r = silc_packet_get_context(ctx->sock);
+    if (r) {
+      r->backup = FALSE;
+      r->backup_proto = NULL;
+    }
+    silc_packet_stream_unref(ctx->sock);
+  }
   silc_free(ctx->sessions);
   silc_free(ctx);
-#endif /* 0 */
 }
 
 SILC_TASK_CALLBACK(silc_server_backup_announce_watches)
 {
-#if 0
   SilcPacketStream sock = context;
   SilcServer server = app_context;
-  if (sock->users > 1)
+  if (silc_packet_stream_is_valid(sock))
     silc_server_announce_watches(server, sock);
-  silc_socket_free(sock);
-#endif /* 0 */
-}
+  silc_packet_stream_unref(sock);
+}

Modified: silc-server/branches/upstream/current/apps/silcd/server_http.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/apps/silcd/server_http.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/apps/silcd/server_http.c (original)
+++ silc-server/branches/upstream/current/apps/silcd/server_http.c Sun Jul  1 19:18:19 2007
@@ -141,6 +141,9 @@
 
 void silc_server_http_init(SilcServer server)
 {
+  if (!server->config->httpd_ip)
+    return;
+
   /* Allocate HTTP server */
   server->httpd = silc_http_server_alloc(server->config->httpd_ip,
 					 server->config->httpd_port,

Modified: silc-server/branches/upstream/current/apps/silcd/server_internal.h
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/apps/silcd/server_internal.h?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/apps/silcd/server_internal.h (original)
+++ silc-server/branches/upstream/current/apps/silcd/server_internal.h Sun Jul  1 19:18:19 2007
@@ -119,10 +119,6 @@
 
   /* Pending command queue */
   SilcDList pending_commands;
-
-  /* Purge context for disconnected clients */
-  SilcIDListPurge purge_i;
-  SilcIDListPurge purge_g;
 
   unsigned int server_type    : 2;   /* Server type (server.h) */
   unsigned int standalone     : 1;   /* Set if server is standalone, and

Modified: silc-server/branches/upstream/current/apps/silcd/server_query.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/apps/silcd/server_query.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/apps/silcd/server_query.c (original)
+++ silc-server/branches/upstream/current/apps/silcd/server_query.c Sun Jul  1 19:18:19 2007
@@ -16,7 +16,7 @@
   GNU General Public License for more details.
 
 */
-/* $Id: server_query.c,v 1.30 2007/05/09 06:03:33 priikone Exp $ */
+/* $Id: server_query.c,v 1.30.2.3 2007/06/24 17:08:09 priikone Exp $ */
 
 #include "serverincludes.h"
 #include "server_internal.h"
@@ -76,6 +76,7 @@
   unsigned int dynamic_prim  : 1;   /* Dynamic connection attempt to primary */
   unsigned int dynamic_retry : 1;   /* Primary returned error, send to
 				       nick at serv server. */
+  unsigned int parsed        : 1;   /* Set when query is parsed */
 } *SilcServerQuery;
 
 
@@ -94,7 +95,8 @@
 				    void *id, SilcIdType id_type);
 void silc_server_query_send_router(SilcServer server, SilcServerQuery query);
 void silc_server_query_send_router_reply(void *context, void *reply);
-void silc_server_query_parse(SilcServer server, SilcServerQuery query);
+SilcBool silc_server_query_parse(SilcServer server, SilcServerQuery query,
+				 SilcBool parse_only);
 void silc_server_query_process(SilcServer server, SilcServerQuery query,
 			       SilcBool resolve);
 void silc_server_query_resolve(SilcServer server, SilcServerQuery query,
@@ -254,6 +256,8 @@
 	 (!silc_argument_get_arg_type(cmd->args, 1, NULL) &&
 	  !silc_argument_get_arg_type(cmd->args, 4, NULL) &&
 	  silc_argument_get_arg_type(cmd->args, 3, NULL)))) {
+      if (!silc_server_query_parse(server, query, TRUE))
+	return FALSE;
       silc_server_query_send_router(server, query);
       return TRUE;
     }
@@ -275,6 +279,8 @@
     if (server->server_type == SILC_SERVER && !server->standalone &&
 	cmd->sock != SILC_PRIMARY_ROUTE(server) &&
 	!silc_argument_get_arg_type(cmd->args, 5, NULL)) {
+      if (!silc_server_query_parse(server, query, TRUE))
+	return FALSE;
       silc_server_query_send_router(server, query);
       return TRUE;
     }
@@ -287,7 +293,7 @@
   }
 
   /* Now parse the request */
-  silc_server_query_parse(server, query);
+  silc_server_query_parse(server, query, FALSE);
 
   return TRUE;
 }
@@ -302,10 +308,12 @@
 
   if (!server_entry) {
     /* Connecting failed */
+    SilcConnectionType type = (server->server_type == SILC_ROUTER ?
+			       SILC_CONN_SERVER : SILC_CONN_ROUTER);
 
     if (query->dynamic_prim /* && @serv != prim.host.name */ &&
 	!silc_server_num_sockets_by_remote(server, query->nick_server,
-					   query->nick_server, 706)) {
+					   query->nick_server, 706, type)) {
       /* Connection attempt to primary router failed, now try to the one
 	 specified in nick at server. */
       silc_server_create_connection(server, FALSE, TRUE, query->nick_server,
@@ -382,16 +390,18 @@
   /* Check if router sent error reply */
   if (cmdr && !silc_command_get_status(cmdr->payload, NULL, NULL)) {
     SilcBuffer buffer;
+    SilcConnectionType type = (server->server_type == SILC_ROUTER ?
+			       SILC_CONN_SERVER : SILC_CONN_ROUTER);
 
     /* If this was nick at server query, retry to @serv if the primary router
        returned error. */
     if (query->nick_server[0] && !query->dynamic_retry &&
 	!silc_server_num_sockets_by_remote(server, query->nick_server,
-					   query->nick_server, 706)) {
+					   query->nick_server, 1334, type)) {
       SILC_LOG_DEBUG(("Retry query by connecting to %s:%d",
 		      query->nick_server, 706));
       silc_server_create_connection(server, FALSE, TRUE, query->nick_server,
-				    706, silc_server_query_connected,
+				    1334, silc_server_query_connected,
 				    query);
       query->dynamic_retry = TRUE;
       query->resolved = FALSE;
@@ -417,12 +427,13 @@
   }
 
   /* Continue with parsing */
-  silc_server_query_parse(server, query);
+  silc_server_query_parse(server, query, FALSE);
 }
 
 /* Parse the command query and start processing the queries in detail. */
 
-void silc_server_query_parse(SilcServer server, SilcServerQuery query)
+SilcBool silc_server_query_parse(SilcServer server, SilcServerQuery query,
+				 SilcBool parse_only)
 {
   SilcServerCommandContext cmd = query->cmd;
   SilcIDListData idata = silc_packet_get_context(cmd->sock);
@@ -434,6 +445,9 @@
   SILC_LOG_DEBUG(("Parsing %s query",
 		  silc_get_command_name(query->querycmd)));
 
+  if (query->parsed)
+    goto parsed;
+
   switch (query->querycmd) {
 
   case SILC_COMMAND_WHOIS:
@@ -460,7 +474,7 @@
 	silc_server_query_send_error(server, query,
 				     SILC_STATUS_ERR_NOT_ENOUGH_PARAMS, 0);
 	silc_server_query_free(query);
-	return;
+	return FALSE;
       }
 
       /* Get the nickname at server string and parse it */
@@ -472,7 +486,7 @@
 	silc_server_query_send_error(server, query,
 				     SILC_STATUS_ERR_BAD_NICKNAME, 0);
 	silc_server_query_free(query);
-	return;
+	return FALSE;
       }
 
       /* Check nickname */
@@ -483,43 +497,11 @@
 	  silc_server_query_send_error(server, query,
 				       SILC_STATUS_ERR_BAD_NICKNAME, 0);
 	  silc_server_query_free(query);
-	  return;
+	  return FALSE;
 	}
 	memset(query->nickname, 0, sizeof(query->nickname));
 	silc_snprintf(query->nickname, sizeof(query->nickname), "%s", tmp);
 	silc_free(tmp);
-      }
-
-      /* Check server name.  If we are open server and don't yet have
-	 connection to remote router, create it now. */
-      if (query->nick_server[0] && server->config->open_server &&
-	  !query->resolved) {
-	/* If primary router is specified, use that.  Otherwise connect
-	   to the server in nick at server string. */
-	SilcServerConfigRouter *router;
-
-	router = silc_server_config_get_primary_router(server);
-	if (router && server->standalone) {
-	  /* Create connection to primary router */
-	  SILC_LOG_DEBUG(("Create dynamic connection to primary router %s:%d",
-			  router->host, router->port));
-	  query->dynamic_prim = TRUE;
-	  silc_server_create_connection(server, FALSE, TRUE,
-					router->host, router->port,
-					silc_server_query_connected, query);
-	  return;
-	} else if (!silc_server_num_sockets_by_remote(server,
-						      query->nick_server,
-						      query->nick_server,
-						      706)) {
-	  /* Create connection and handle the query after connection */
-	  SILC_LOG_DEBUG(("Create dynamic connection to %s:%d",
-			  query->nick_server, 706));
-	  silc_server_create_connection(server, FALSE, TRUE,
-					query->nick_server, 706,
-					silc_server_query_connected, query);
-	  return;
-	}
       }
 
     } else {
@@ -552,7 +534,7 @@
 	      silc_free(query->ids);
 	      query->ids = NULL;
 	      query->ids_count = 0;
-	      return;
+	      return FALSE;
 	    }
 	  }
 	}
@@ -577,7 +559,7 @@
       silc_server_query_send_error(server, query,
 				   SILC_STATUS_ERR_NOT_ENOUGH_PARAMS, 0);
       silc_server_query_free(query);
-      return;
+      return FALSE;
     }
 
     /* Get the nickname at server string and parse it */
@@ -587,7 +569,7 @@
       silc_server_query_send_error(server, query,
 				   SILC_STATUS_ERR_BAD_NICKNAME, 0);
       silc_server_query_free(query);
-      return;
+      return FALSE;
     }
 
     /* Check nickname */
@@ -597,7 +579,7 @@
       silc_server_query_send_error(server, query,
 				   SILC_STATUS_ERR_BAD_NICKNAME, 0);
       silc_server_query_free(query);
-      return;
+      return FALSE;
     }
     memset(query->nickname, 0, sizeof(query->nickname));
     silc_snprintf(query->nickname, sizeof(query->nickname), "%s", tmp);
@@ -633,7 +615,7 @@
 	  silc_server_query_send_error(server, query,
 				       SILC_STATUS_ERR_BAD_NICKNAME, 0);
 	  silc_server_query_free(query);
-	  return;
+	  return FALSE;
 	}
 	memset(query->nickname, 0, sizeof(query->nickname));
 	silc_snprintf(query->nickname, sizeof(query->nickname), "%s", tmp);
@@ -650,7 +632,7 @@
 	  silc_server_query_send_error(server, query,
 				       SILC_STATUS_ERR_BAD_SERVER, 0);
 	  silc_server_query_free(query);
-	  return;
+	  return FALSE;
 	}
 	query->server_name = tmp;
       }
@@ -665,7 +647,7 @@
 	  silc_server_query_send_error(server, query,
 				       SILC_STATUS_ERR_BAD_CHANNEL, 0);
 	  silc_server_query_free(query);
-	  return;
+	  return FALSE;
 	}
 	query->channel_name = tmp;
       }
@@ -674,39 +656,7 @@
 	silc_server_query_send_error(server, query,
 				     SILC_STATUS_ERR_NOT_ENOUGH_PARAMS, 0);
 	silc_server_query_free(query);
-	return;
-      }
-
-      /* Check server name.  If we are open server and don't yet have
-	 connection to remote router, create it now. */
-      if (query->nick_server[0] && server->config->open_server &&
-	  !query->resolved) {
-	/* If primary router is specified, use that.  Otherwise connect
-	   to the server in nick at server string. */
-	SilcServerConfigRouter *router;
-
-	router = silc_server_config_get_primary_router(server);
-	if (router && server->standalone) {
-	  /* Create connection to primary router */
-	  SILC_LOG_DEBUG(("Create dynamic connection to primary router %s:%d",
-			  router->host, router->port));
-	  query->dynamic_prim = TRUE;
-	  silc_server_create_connection(server, FALSE, TRUE,
-					router->host, router->port,
-					silc_server_query_connected, query);
-	  return;
-	} else if (!silc_server_num_sockets_by_remote(server,
-						      query->nick_server,
-						      query->nick_server,
-						      706)) {
-	  /* Create connection and handle the query after connection */
-	  SILC_LOG_DEBUG(("Create dynamic connection to %s:%d",
-			  query->nick_server, 706));
-	  silc_server_create_connection(server, FALSE, TRUE,
-					query->nick_server, 706,
-					silc_server_query_connected, query);
-	  return;
-	}
+	return FALSE;
       }
 
     } else {
@@ -740,7 +690,7 @@
 		silc_free(query->ids);
 		query->ids = NULL;
 		query->ids_count = 0;
-		return;
+		return FALSE;
 	      }
 	    }
 	  } else {
@@ -752,7 +702,7 @@
 	    silc_free(query->ids);
 	    query->ids = NULL;
 	    query->ids_count = 0;
-	    return;
+	    return FALSE;
 	  }
 	}
 
@@ -777,8 +727,54 @@
     break;
   }
 
+  query->parsed = TRUE;
+
+ parsed:
+  if (!parse_only && query->nickname) {
+    switch (query->querycmd) {
+    case SILC_COMMAND_WHOIS:
+    case SILC_COMMAND_IDENTIFY:
+      /* Check server name.  If we are open server and don't yet have
+	 connection to remote router, create it now. */
+      if (query->nick_server[0] && server->config->dynamic_server &&
+	  !query->resolved) {
+	/* If primary router is specified, use that.  Otherwise connect
+	   to the server in nick at server string. */
+	SilcServerConfigRouter *router;
+	SilcConnectionType type = (server->server_type == SILC_ROUTER ?
+				   SILC_CONN_SERVER : SILC_CONN_ROUTER);
+
+	router = silc_server_config_get_primary_router(server);
+	if (router && server->standalone) {
+	  /* Create connection to primary router */
+	  SILC_LOG_DEBUG(("Create dynamic connection to primary router %s:%d",
+			  router->host, router->port));
+	  query->dynamic_prim = TRUE;
+	  silc_server_create_connection(server, FALSE, TRUE,
+					router->host, router->port,
+					silc_server_query_connected, query);
+	  return FALSE;
+	} else if (!silc_server_num_sockets_by_remote(server,
+						      query->nick_server,
+						      query->nick_server,
+						      706, type)) {
+	  /* Create connection and handle the query after connection */
+	  SILC_LOG_DEBUG(("Create dynamic connection to %s:%d",
+			  query->nick_server, 706));
+	  silc_server_create_connection(server, FALSE, TRUE,
+					query->nick_server, 706,
+					silc_server_query_connected, query);
+	  return FALSE;
+	}
+      }
+    }
+  }
+
   /* Start processing the query information */
-  silc_server_query_process(server, query, TRUE);
+  if (!parse_only)
+    silc_server_query_process(server, query, TRUE);
+
+  return TRUE;
 }
 
 /* Context for holding clients searched by public key. */

Modified: silc-server/branches/upstream/current/apps/silcd/server_util.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/apps/silcd/server_util.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/apps/silcd/server_util.c (original)
+++ silc-server/branches/upstream/current/apps/silcd/server_util.c Sun Jul  1 19:18:19 2007
@@ -16,7 +16,7 @@
   GNU General Public License for more details.
 
 */
-/* $Id: server_util.c,v 1.83 2007/05/09 06:03:33 priikone Exp $ */
+/* $Id: server_util.c,v 1.83.2.3 2007/07/01 16:06:58 priikone Exp $ */
 
 #include "serverincludes.h"
 #include "server_internal.h"
@@ -162,17 +162,15 @@
 
   if (server_signoff) {
     idp = silc_id_payload_encode(entry->id, SILC_ID_SERVER);
-    if (idp) {
-      argv = silc_realloc(argv, sizeof(*argv) * (argc + 1));
-      argv_lens = silc_realloc(argv_lens,  sizeof(*argv_lens) * (argc + 1));
-      argv_types = silc_realloc(argv_types, sizeof(*argv_types) * (argc + 1));
-      argv[argc] = silc_calloc(silc_buffer_len(idp), sizeof(*argv[0]));
-      memcpy(argv[argc], idp->data, silc_buffer_len(idp));
-      argv_lens[argc] = silc_buffer_len(idp);
-      argv_types[argc] = argc + 1;
-      argc++;
-      silc_buffer_free(idp);
-    }
+    argv = silc_realloc(argv, sizeof(*argv) * (argc + 1));
+    argv_lens = silc_realloc(argv_lens,  sizeof(*argv_lens) * (argc + 1));
+    argv_types = silc_realloc(argv_types, sizeof(*argv_types) * (argc + 1));
+    argv[argc] = silc_calloc(silc_buffer_len(idp), sizeof(*argv[0]));
+    memcpy(argv[argc], idp->data, silc_buffer_len(idp));
+    argv_lens[argc] = silc_buffer_len(idp);
+    argv_types[argc] = argc + 1;
+    argc++;
+    silc_buffer_free(idp);
   }
 
   if (silc_idcache_get_all(server->local_list->clients, &list)) {
@@ -415,10 +413,8 @@
 	   since the server is local. */
 	if (!local) {
 	  SILC_LOG_DEBUG(("Moving client to local list"));
-	  silc_idcache_add(server->local_list->clients, client_cache->name,
-			   client_cache->id, client_cache->context);
-	  silc_idcache_del_by_context(server->global_list->clients, client,
-				      NULL);
+	  silc_idcache_move(server->global_list->clients,
+			    server->local_list->clients, client_cache);
 	}
 	server_entry = server_entry->router;
       } else {
@@ -427,20 +423,16 @@
 	   since the server is local. */
 	if (server_entry->server_type != SILC_BACKUP_ROUTER && !local) {
 	  SILC_LOG_DEBUG(("Moving client to local list"));
-	  silc_idcache_add(server->local_list->clients, client_cache->name,
-			   client_cache->id, client_cache->context);
-	  silc_idcache_del_by_context(server->global_list->clients, client,
-				      NULL);
+	  silc_idcache_move(server->global_list->clients,
+			    server->local_list->clients, client_cache);
 
 	} else if (server->server_type == SILC_BACKUP_ROUTER && local) {
 	  /* If we are backup router and this client is on local list, we
 	     must move it to global list, as it is not currently local to
 	     us (we are not primary). */
 	  SILC_LOG_DEBUG(("Moving client to global list"));
-	  silc_idcache_add(server->global_list->clients, client_cache->name,
-			   client_cache->id, client_cache->context);
-	  silc_idcache_del_by_context(server->local_list->clients, client,
-				      NULL);
+	  silc_idcache_move(server->local_list->clients,
+			    server->global_list->clients, client_cache);
 	}
       }
 
@@ -467,10 +459,8 @@
 	   since the server is global. */
 	if (local) {
 	  SILC_LOG_DEBUG(("Moving client to global list"));
-	  silc_idcache_add(server->global_list->clients, client_cache->name,
-			   client_cache->id, client_cache->context);
-	  silc_idcache_del_by_context(server->local_list->clients, client,
-				      NULL);
+	  silc_idcache_move(server->local_list->clients,
+			    server->global_list->clients, client_cache);
 	}
 	server_entry = server_entry->router;
       } else {
@@ -479,10 +469,8 @@
 	   since the server is global. */
 	if (server_entry->server_type != SILC_BACKUP_ROUTER && local) {
 	  SILC_LOG_DEBUG(("Moving client to global list"));
-	  silc_idcache_add(server->global_list->clients, client_cache->name,
-			   client_cache->id, client_cache->context);
-	  silc_idcache_del_by_context(server->local_list->clients, client,
-				      NULL);
+	  silc_idcache_move(server->local_list->clients,
+			    server->global_list->clients, client_cache);
 	}
       }
       return server_entry;
@@ -1056,19 +1044,29 @@
 SilcUInt32 silc_server_num_sockets_by_remote(SilcServer server,
 					     const char *ip,
 					     const char *hostname,
-					     SilcUInt16 port)
+					     SilcUInt16 port,
+					     SilcConnectionType type)
 {
   SilcServerConnection conn;
+  SilcIDListData idata;
+  SilcConnectionType t = SILC_CONN_UNKNOWN;
   int count = 0;
 
   if (!ip && !hostname)
     return 0;
 
+  SILC_LOG_DEBUG(("Num connections %d", silc_dlist_count(server->conns)));
+
   silc_dlist_start(server->conns);
   while ((conn = silc_dlist_get(server->conns))) {
+    if (conn->sock) {
+      idata = silc_packet_get_context(conn->sock);
+      if (idata)
+	t = idata->conn_type;
+    }
     if (((ip && !strcmp(conn->remote_host, ip)) ||
 	 (hostname && !strcmp(conn->remote_host, hostname))) &&
-	conn->remote_port == port)
+	conn->remote_port == port && t == type)
       count++;
   }
 
@@ -1225,6 +1223,7 @@
 		  global->connections_max_per_host);
 
   if (max_hosts && conn_number >= max_hosts) {
+    SILC_LOG_DEBUG(("Server is full, %d >= %d", conn_number, max_hosts));
     SILC_LOG_INFO(("Server is full, closing %s (%s) connection",
 		   hostname, ip));
     silc_server_disconnect_remote(server, sock,
@@ -1234,6 +1233,8 @@
   }
 
   if (num_sockets >= max_per_host) {
+    SILC_LOG_DEBUG(("Too many connections, %d >= %d", num_sockets,
+		    max_per_host));
     SILC_LOG_INFO(("Too many connections from %s (%s), closing connection",
 		   hostname, ip));
     silc_server_disconnect_remote(server, sock,
@@ -1989,7 +1990,7 @@
   silc_schedule_task_del_by_callback(server->schedule,
 				     silc_server_connect_to_router);
   silc_schedule_task_add_timeout(server->schedule,
-				 silc_server_connect_to_router, server, 0, 1);
+				 silc_server_connect_to_router, server, 1, 0);
 }
 
 static void

Modified: silc-server/branches/upstream/current/apps/silcd/server_util.h
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/apps/silcd/server_util.h?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/apps/silcd/server_util.h (original)
+++ silc-server/branches/upstream/current/apps/silcd/server_util.h Sun Jul  1 19:18:19 2007
@@ -105,7 +105,8 @@
 SilcUInt32 silc_server_num_sockets_by_remote(SilcServer server,
 					     const char *ip,
 					     const char *hostname,
-					     SilcUInt16 port);
+					     SilcUInt16 port,
+					     SilcConnectionType type);
 
 /* Get public key by key usage and key context. */
 SilcPublicKey silc_server_get_public_key(SilcServer server,

Modified: silc-server/branches/upstream/current/apps/silcd/serverconfig.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/apps/silcd/serverconfig.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/apps/silcd/serverconfig.c (original)
+++ silc-server/branches/upstream/current/apps/silcd/serverconfig.c Sun Jul  1 19:18:19 2007
@@ -16,7 +16,7 @@
   GNU General Public License for more details.
 
 */
-/* $Id: serverconfig.c,v 1.78 2007/04/28 15:10:29 priikone Exp $ */
+/* $Id: serverconfig.c,v 1.78.2.4 2007/07/01 16:06:58 priikone Exp $ */
 
 #include "serverincludes.h"
 #include "server_internal.h"
@@ -150,7 +150,7 @@
     SilcPublicKey public_key;
     SilcSKR skr = *auth_data;
     SilcSKRFind find;
-    SilcSKRStatus status;
+    SilcSKRStatus status = SILC_SKR_NOT_FOUND;
 
     if (!silc_pkcs_load_public_key(p, &public_key)) {
       SILC_SERVER_LOG_ERROR(("Error while parsing config file: "
@@ -161,19 +161,20 @@
     find = silc_skr_find_alloc();
     silc_skr_find_set_public_key(find, public_key);
     silc_skr_find_set_usage(find, usage);
-    silc_skr_find_set_context(find, key_context ? key_context : (void *)usage);
+    if (!key_context)
+      silc_skr_find_set_context(find, SILC_32_TO_PTR(usage));
     silc_skr_find(skr, NULL, find, my_find_callback, &status);
-    if (status == SILC_SKR_ALREADY_EXIST) {
+    if (status == SILC_SKR_OK) {
+      /* Already added, ignore error */
       silc_pkcs_public_key_free(public_key);
-      SILC_SERVER_LOG_WARNING(("Warning: public key file \"%s\" already "
-			       "configured, ignoring this key", p));
-      return TRUE; /* non fatal error */
+      return TRUE;
     }
 
     /* Add the public key to repository */
-    if (silc_skr_add_public_key(skr, public_key, usage,
-				key_context ? key_context : (void *)usage,
-				NULL) != SILC_SKR_OK) {
+    status = silc_skr_add_public_key(skr, public_key, usage,
+				     key_context ? key_context :
+				     (void *)usage, NULL);
+    if (status != SILC_SKR_OK) {
       SILC_SERVER_LOG_ERROR(("Error while adding public key \"%s\"", p));
       return FALSE;
     }
@@ -338,8 +339,8 @@
     }
     config->httpd_port = (SilcUInt16)port;
   }
-  else if (!strcmp(name, "open_server")) {
-    config->open_server = *(SilcBool *)val;
+  else if (!strcmp(name, "dynamic_server")) {
+    config->dynamic_server = *(SilcBool *)val;
   }
   else if (!strcmp(name, "local_channels")) {
     config->local_channels = *(SilcBool *)val;
@@ -1217,7 +1218,7 @@
   { "http_server",    		SILC_CONFIG_ARG_TOGGLE,	fetch_generic,	NULL },
   { "http_server_ip",  		SILC_CONFIG_ARG_STRE,	fetch_generic,	NULL },
   { "http_server_port",		SILC_CONFIG_ARG_INT,	fetch_generic,	NULL },
-  { "open_server",    		SILC_CONFIG_ARG_TOGGLE,	fetch_generic,	NULL },
+  { "dynamic_server",  		SILC_CONFIG_ARG_TOGGLE,	fetch_generic,	NULL },
   { "local_channels",	        SILC_CONFIG_ARG_TOGGLE,	fetch_generic,	NULL },
   { 0, 0, 0, 0 }
 };
@@ -1414,6 +1415,24 @@
     ret = FALSE;
   }
 
+  if (!config->server_info->public_key ||
+      !config->server_info->private_key) {
+    SILC_SERVER_LOG_ERROR(("\nError: Server keypair is missing"));
+    ret = FALSE;
+  }
+
+  if (!config->server_info->primary) {
+    SILC_SERVER_LOG_ERROR(("\nError: Missing mandatory block `Primary' "
+			   "in `ServerInfo'"));
+    ret = FALSE;
+  }
+
+  if (!config->server_info->primary->server_ip) {
+    SILC_SERVER_LOG_ERROR(("\nError: Missing mandatory field `Ip' "
+			   "in `Primary' in `ServerInfo'"));
+    ret = FALSE;
+  }
+
   /* RouterConnection sanity checks */
 
   if (config->routers && config->routers->backup_router == TRUE &&
@@ -1423,15 +1442,6 @@
 	 "connection. You have marked it incorrectly as backup router."));
     ret = FALSE;
   }
-#if 0
-  if (config->routers && config->routers->initiator == FALSE &&
-      config->routers->backup_router == FALSE) {
-    SILC_SERVER_LOG_ERROR((
-         "\nError: First RouterConnection block must be primary router "
-	 "connection and it must be marked as Initiator."));
-    ret = FALSE;
-  }
-#endif
   if (config->routers && config->routers->backup_router == TRUE &&
       !config->servers && !config->routers->next) {
     SILC_SERVER_LOG_ERROR((

Modified: silc-server/branches/upstream/current/apps/silcd/serverconfig.h
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/apps/silcd/serverconfig.h?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/apps/silcd/serverconfig.h (original)
+++ silc-server/branches/upstream/current/apps/silcd/serverconfig.h Sun Jul  1 19:18:19 2007
@@ -182,7 +182,7 @@
   SilcBool httpd;
   char *httpd_ip;
   SilcUInt16 httpd_port;
-  SilcBool open_server;
+  SilcBool dynamic_server;
   SilcBool local_channels;
 
   /* Other configuration sections */

Modified: silc-server/branches/upstream/current/apps/silcd/serverid.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/apps/silcd/serverid.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/apps/silcd/serverid.c (original)
+++ silc-server/branches/upstream/current/apps/silcd/serverid.c Sun Jul  1 19:18:19 2007
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone at silcnet.org>
 
-  Copyright (C) 1997 - 2005 Pekka Riikonen
+  Copyright (C) 1997 - 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
@@ -17,7 +17,7 @@
   GNU General Public License for more details.
 
 */
-/* $Id: serverid.c,v 1.20 2007/04/22 18:27:13 priikone Exp $ */
+/* $Id: serverid.c,v 1.20.2.1 2007/06/10 16:11:21 priikone Exp $ */
 
 #include "serverincludes.h"
 #include "server_internal.h"
@@ -43,7 +43,7 @@
 
   (*new_id)->ip.data_len = silc_net_is_ip4(ip) ? 4 : 16;
   (*new_id)->port = SILC_SWAB_16(port);
-  (*new_id)->rnd = silc_rng_get_rn16(rng);
+  (*new_id)->rnd = 0xff;
 
   SILC_LOG_DEBUG(("New ID (%s)", silc_id_render(*new_id, SILC_ID_SERVER)));
 }

Modified: silc-server/branches/upstream/current/apps/silcd/silcd.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/apps/silcd/silcd.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/apps/silcd/silcd.c (original)
+++ silc-server/branches/upstream/current/apps/silcd/silcd.c Sun Jul  1 19:18:19 2007
@@ -22,7 +22,7 @@
  * This is the main program for the SILC daemon. This parses command
  * line arguments and creates the server object.
  */
-/* $Id: silcd.c,v 1.65 2007/04/28 15:10:29 priikone Exp $ */
+/* $Id: silcd.c,v 1.65.2.2 2007/07/01 16:06:58 priikone Exp $ */
 
 #include "serverincludes.h"
 #include "server_internal.h"
@@ -339,7 +339,7 @@
       SilcUInt16 port;
       SilcSocket sock;
       SilcIDListData idata = silc_packet_get_context(s);
-      if (!silc_socket_stream_get_info(silc_packet_stream_get_stream(s), 
+      if (!silc_socket_stream_get_info(silc_packet_stream_get_stream(s),
 				       &sock, &hostname, &ip, &port))
 	continue;
       fprintf(fdd, "  %d: host %s ip %s port %d type %d\n",
@@ -470,43 +470,43 @@
   { 15, "*silcd*,*serverid*,silc_server_*,*idlist*" },
 
   /* All from silcd/ and basic stuff from libs */
-  { 20, "*silcd*,*serverid*,silc_server_*,*idlist*,*silcauth*,*silcske*" },
+  { 20, "*silcd*,*serverid*,silc_server_*,*idlist*,*silcconauth*,*silcske*" },
 
   /* All from silcd/ and more stuff from libs */
-  { 25, "*silcd*,*serverid*,silc_server_*,*idlist*,*silcauth*,"
+  { 25, "*silcd*,*serverid*,silc_server_*,*idlist*,*silcconauth*,"
     "*silcpacket*,*ske*,*silcrng*" },
 
   /* All from silcd/ and even more stuff from libs */
-  { 30, "*silcd*,*serverid*,silc_server_*,*idlist*,*silcauth*,"
+  { 30, "*silcd*,*serverid*,silc_server_*,*idlist*,*silcconauth*,"
     "*silcpacket*,*ske*,*silcrng*,*command*,*channel*,*private*,*notify*" },
 
   /* All from silcd/ and even more stuff from libs + all from silccore */
-  { 35, "*silcd*,*serverid*,silc_server_*,*idlist*,*silcauth*,"
+  { 35, "*silcd*,*serverid*,silc_server_*,*idlist*,*silcconauth*,"
     "*silcpacket*,*ske*,*silcrng*,*command*,*channel*,*private*,*notify*"
     "*silcid*,*argument*" },
 
   /* All from silcd/, all from silccore, silccrypt and silcmath */
-  { 40, "*silcd*,*serverid*,silc_server_*,*idlist*,*silcauth*,"
+  { 40, "*silcd*,*serverid*,silc_server_*,*idlist*,*silcconauth*,"
     "*silcpacket*,*ske*,*silcrng*,*command*,*channel*,*private*,*notify*"
     "*silcid*,*argument*,*pkcs*,*hmac*,*hash*,*cipher*,silc_math*" },
 
   /* All from silcd/, all from silccore, silccrypt and silcmath + stuff
      from silcutil */
-  { 45, "*silcd*,*serverid*,silc_server_*,*idlist*,*silcauth*,"
+  { 45, "*silcd*,*serverid*,silc_server_*,*idlist*,*silcconauth*,"
     "*silcpacket*,*ske*,*silcrng*,*command*,*channel*,*private*,*notify*"
     "*silcid*,*argument*,*pkcs*,*hmac*,*hash*,*cipher*,silc_math*,*sim*"
     "*sockconn*" },
 
   /* All from silcd/, all from silccore, silccrypt and silcmath + more stuff
      from silcutil */
-  { 50, "*silcd*,*serverid*,silc_server_*,*idlist*,*silcauth*,"
+  { 50, "*silcd*,*serverid*,silc_server_*,*idlist*,*silcconauth*,"
     "*silcpacket*,*ske*,*silcrng*,*command*,*channel*,*private*,*notify*"
     "*silcid*,*argument*,*pkcs*,*hmac*,*hash*,*cipher*,silc_math*,*sim*"
     "*sockconn*,*net*" },
 
   /* All from silcd/, all from silccore, silccrypt and silcmath + more stuff
      from silcutil */
-  { 55, "*silcd*,*serverid*,silc_server_*,*idlist*,*silcauth*,"
+  { 55, "*silcd*,*serverid*,silc_server_*,*idlist*,*silcconauth*,"
     "*silcpacket*,*ske*,*silcrng*,*command*,*channel*,*private*,*notify*"
     "*silcid*,*argument*,*pkcs*,*hmac*,*hash*,*cipher*,silc_math*,*sim*"
     "*sockconn*,*net*,*log*,*config*" },
@@ -673,8 +673,9 @@
     silc_pkcs_register_default();
     silc_hash_register_default();
     silc_hmac_register_default();
-    silc_create_key_pair(opt_pkcs, opt_bits, pubfile, prvfile,
-			 opt_identifier, "", NULL, NULL, FALSE);
+    if (!silc_create_key_pair(opt_pkcs, opt_bits, pubfile, prvfile,
+			      opt_identifier, "", NULL, NULL, FALSE))
+      exit(1);
     exit(0);
   }
 

Modified: silc-server/branches/upstream/current/configure
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/configure?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/configure (original)
+++ silc-server/branches/upstream/current/configure Sun Jul  1 19:18:19 2007
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for Server 1.1-pre1.
+# Generated by GNU Autoconf 2.61 for Server 1.1-beta1.
 #
 # Report bugs to <silc-devel at lists.silcnet.org>.
 #
@@ -728,8 +728,8 @@
 # Identity of this package.
 PACKAGE_NAME='Server'
 PACKAGE_TARNAME='silc-server'
-PACKAGE_VERSION='1.1-pre1'
-PACKAGE_STRING='Server 1.1-pre1'
+PACKAGE_VERSION='1.1-beta1'
+PACKAGE_STRING='Server 1.1-beta1'
 PACKAGE_BUGREPORT='silc-devel at lists.silcnet.org'
 
 # Factoring default headers for most tests.
@@ -949,6 +949,7 @@
 __SILC_HAVE_PTHREAD
 __SILC_HAVE_SIM
 __SILC_ENABLE_DEBUG
+__SILC_PACKAGE_VERSION
 SILC_LIBTOOLFIX_TRUE
 SILC_LIBTOOLFIX_FALSE
 INCLUDE_DEFINES_INT
@@ -1475,7 +1476,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures Server 1.1-pre1 to adapt to many kinds of systems.
+\`configure' configures Server 1.1-beta1 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1546,7 +1547,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of Server 1.1-pre1:";;
+     short | recursive ) echo "Configuration of Server 1.1-beta1:";;
    esac
   cat <<\_ACEOF
 
@@ -1670,7 +1671,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-Server configure 1.1-pre1
+Server configure 1.1-beta1
 generated by GNU Autoconf 2.61
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1684,7 +1685,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by Server $as_me 1.1-pre1, which was
+It was created by Server $as_me 1.1-beta1, which was
 generated by GNU Autoconf 2.61.  Invocation command line was
 
   $ $0 $@
@@ -2500,7 +2501,7 @@
 
 # Define the identity of the package.
  PACKAGE='silc-server'
- VERSION='1.1-pre1'
+ VERSION='1.1-beta1'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -2979,6 +2980,10 @@
 # Put here any platform specific stuff
 #
 case "$target" in
+  *-*-linux*)
+    check_threads=true
+    CFLAGS=`echo $CFLAGS -D_GNU_SOURCE`
+    ;;
   *-*-freebsd*)
     check_threads=true
     ;;
@@ -4360,6 +4365,7 @@
 __SILC_HAVE_PTHREAD=""
 __SILC_HAVE_SIM=""
 __SILC_ENABLE_DEBUG=""
+
 
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
@@ -4999,7 +5005,7 @@
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 5002 "configure"' > conftest.$ac_ext
+  echo '#line 5008 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -7730,11 +7736,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7733: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7739: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:7737: \$? = $ac_status" >&5
+   echo "$as_me:7743: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -7998,11 +8004,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8001: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8007: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:8005: \$? = $ac_status" >&5
+   echo "$as_me:8011: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -8102,11 +8108,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8105: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8111: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8109: \$? = $ac_status" >&5
+   echo "$as_me:8115: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -9567,7 +9573,7 @@
   libsuff=
   case "$host_cpu" in
   x86_64*|s390x*|powerpc64*)
-    echo '#line 9570 "configure"' > conftest.$ac_ext
+    echo '#line 9576 "configure"' > conftest.$ac_ext
     if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -10431,7 +10437,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 10434 "configure"
+#line 10440 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10531,7 +10537,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 10534 "configure"
+#line 10540 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12870,11 +12876,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:12873: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:12879: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:12877: \$? = $ac_status" >&5
+   echo "$as_me:12883: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -12974,11 +12980,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:12977: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:12983: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:12981: \$? = $ac_status" >&5
+   echo "$as_me:12987: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -13510,7 +13516,7 @@
   libsuff=
   case "$host_cpu" in
   x86_64*|s390x*|powerpc64*)
-    echo '#line 13513 "configure"' > conftest.$ac_ext
+    echo '#line 13519 "configure"' > conftest.$ac_ext
     if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -14568,11 +14574,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14571: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:14577: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:14575: \$? = $ac_status" >&5
+   echo "$as_me:14581: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -14672,11 +14678,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14675: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:14681: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:14679: \$? = $ac_status" >&5
+   echo "$as_me:14685: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -16117,7 +16123,7 @@
   libsuff=
   case "$host_cpu" in
   x86_64*|s390x*|powerpc64*)
-    echo '#line 16120 "configure"' > conftest.$ac_ext
+    echo '#line 16126 "configure"' > conftest.$ac_ext
     if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -16894,11 +16900,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16897: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:16903: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:16901: \$? = $ac_status" >&5
+   echo "$as_me:16907: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -17162,11 +17168,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:17165: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:17171: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:17169: \$? = $ac_status" >&5
+   echo "$as_me:17175: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -17266,11 +17272,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:17269: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:17275: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:17273: \$? = $ac_status" >&5
+   echo "$as_me:17279: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -18731,7 +18737,7 @@
   libsuff=
   case "$host_cpu" in
   x86_64*|s390x*|powerpc64*)
-    echo '#line 18734 "configure"' > conftest.$ac_ext
+    echo '#line 18740 "configure"' > conftest.$ac_ext
     if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -30525,11 +30531,11 @@
 # libsilc versions
 LIBSILC_CURRENT=2		# prev = 1
 LIBSILC_REVISION=0		# prev = 0
-LIBSILC_AGE=1			# prev = 0
+LIBSILC_AGE=0			# prev = 0
 
 # libsilcclient versions
-LIBSILCCLIENT_CURRENT=1		# prev = 1
-LIBSILCCLIENT_REVISION=1	# prev = 0
+LIBSILCCLIENT_CURRENT=2		# prev = 1
+LIBSILCCLIENT_REVISION=0	# prev = 0
 LIBSILCCLIENT_AGE=0		# prev = 0
 
 # libsilcserver versions
@@ -31410,6 +31416,7 @@
 #
 # Substitutions
 #
+
 
 
 
@@ -31997,7 +32004,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by Server $as_me 1.1-pre1, which was
+This file was extended by Server $as_me 1.1-beta1, which was
 generated by GNU Autoconf 2.61.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -32050,7 +32057,7 @@
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-Server config.status 1.1-pre1
+Server config.status 1.1-beta1
 configured by $0, generated by GNU Autoconf 2.61,
   with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 
@@ -32473,6 +32480,7 @@
 __SILC_HAVE_PTHREAD!$__SILC_HAVE_PTHREAD$ac_delim
 __SILC_HAVE_SIM!$__SILC_HAVE_SIM$ac_delim
 __SILC_ENABLE_DEBUG!$__SILC_ENABLE_DEBUG$ac_delim
+__SILC_PACKAGE_VERSION!$__SILC_PACKAGE_VERSION$ac_delim
 SILC_LIBTOOLFIX_TRUE!$SILC_LIBTOOLFIX_TRUE$ac_delim
 SILC_LIBTOOLFIX_FALSE!$SILC_LIBTOOLFIX_FALSE$ac_delim
 INCLUDE_DEFINES_INT!$INCLUDE_DEFINES_INT$ac_delim
@@ -32480,7 +32488,7 @@
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 88; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 89; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5

Modified: silc-server/branches/upstream/current/configure.ac
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/configure.ac?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/configure.ac (original)
+++ silc-server/branches/upstream/current/configure.ac Sun Jul  1 19:18:19 2007
@@ -2,7 +2,7 @@
 # To make changes edit the configure.ad file in the source tree.
 
 # Source: configure.ad
-# Generated: Fri Jun  8 09:30:39 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 
@@ -23,7 +23,7 @@
 #  GNU General Public License for more details.
 #
 
-AC_INIT([Server], [1.1-pre1], [silc-devel at lists.silcnet.org], [silc-server])
+AC_INIT([Server], [1.1-beta1], [silc-devel at lists.silcnet.org], [silc-server])
 AC_CANONICAL_SYSTEM
 AM_INIT_AUTOMAKE
 AC_PREREQ(2.52)
@@ -40,6 +40,10 @@
 # Put here any platform specific stuff
 #
 case "$target" in
+  *-*-linux*)
+    check_threads=true
+    CFLAGS=`echo $CFLAGS -D_GNU_SOURCE`
+    ;;
   *-*-freebsd*)
     check_threads=true
     ;;
@@ -101,6 +105,7 @@
 __SILC_HAVE_SIM=""
 __SILC_ENABLE_DEBUG=""
 
+
 AC_PROG_RANLIB
 AC_DISABLE_SHARED
 AC_PROG_LIBTOOL
@@ -1413,11 +1418,11 @@
 # libsilc versions
 LIBSILC_CURRENT=2		# prev = 1
 LIBSILC_REVISION=0		# prev = 0
-LIBSILC_AGE=1			# prev = 0
+LIBSILC_AGE=0			# prev = 0
 
 # libsilcclient versions
-LIBSILCCLIENT_CURRENT=1		# prev = 1
-LIBSILCCLIENT_REVISION=1	# prev = 0
+LIBSILCCLIENT_CURRENT=2		# prev = 1
+LIBSILCCLIENT_REVISION=0	# prev = 0
 LIBSILCCLIENT_AGE=0		# prev = 0
 
 # libsilcserver versions
@@ -1625,6 +1630,7 @@
 AC_SUBST(__SILC_HAVE_PTHREAD)
 AC_SUBST(__SILC_HAVE_SIM)
 AC_SUBST(__SILC_ENABLE_DEBUG)
+AC_SUBST(__SILC_PACKAGE_VERSION)
 
 #
 # Fix the libtool to support run-time configuration.  This allows us

Modified: silc-server/branches/upstream/current/doc/Makefile.am
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/doc/Makefile.am?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/doc/Makefile.am (original)
+++ silc-server/branches/upstream/current/doc/Makefile.am Sun Jul  1 19:18:19 2007
@@ -2,7 +2,7 @@
 # To make changes edit the ./doc/Makefile.ad file in the source tree.
 
 # Source: ./doc/Makefile.ad
-# Generated: Fri Jun  8 09:30:37 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:57 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 

Modified: silc-server/branches/upstream/current/doc/Makefile.in
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/doc/Makefile.in?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/doc/Makefile.in (original)
+++ silc-server/branches/upstream/current/doc/Makefile.in Sun Jul  1 19:18:19 2007
@@ -18,7 +18,7 @@
 # To make changes edit the ./doc/Makefile.ad file in the source tree.
 
 # Source: ./doc/Makefile.ad
-# Generated: Fri Jun  8 09:30:37 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:57 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 
@@ -203,6 +203,7 @@
 __SILC_ENABLE_DEBUG = @__SILC_ENABLE_DEBUG@
 __SILC_HAVE_PTHREAD = @__SILC_HAVE_PTHREAD@
 __SILC_HAVE_SIM = @__SILC_HAVE_SIM@
+__SILC_PACKAGE_VERSION = @__SILC_PACKAGE_VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@

Modified: silc-server/branches/upstream/current/includes/Makefile.am
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/includes/Makefile.am?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/includes/Makefile.am (original)
+++ silc-server/branches/upstream/current/includes/Makefile.am Sun Jul  1 19:18:19 2007
@@ -2,7 +2,7 @@
 # To make changes edit the ./includes/Makefile.ad file in the source tree.
 
 # Source: ./includes/Makefile.ad
-# Generated: Fri Jun  8 09:30:37 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:57 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 

Modified: silc-server/branches/upstream/current/includes/Makefile.in
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/includes/Makefile.in?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/includes/Makefile.in (original)
+++ silc-server/branches/upstream/current/includes/Makefile.in Sun Jul  1 19:18:19 2007
@@ -18,7 +18,7 @@
 # To make changes edit the ./includes/Makefile.ad file in the source tree.
 
 # Source: ./includes/Makefile.ad
-# Generated: Fri Jun  8 09:30:37 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:57 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 
@@ -165,6 +165,7 @@
 __SILC_ENABLE_DEBUG = @__SILC_ENABLE_DEBUG@
 __SILC_HAVE_PTHREAD = @__SILC_HAVE_PTHREAD@
 __SILC_HAVE_SIM = @__SILC_HAVE_SIM@
+__SILC_PACKAGE_VERSION = @__SILC_PACKAGE_VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@

Modified: silc-server/branches/upstream/current/includes/silcdistdefs.h
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/includes/silcdistdefs.h?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/includes/silcdistdefs.h (original)
+++ silc-server/branches/upstream/current/includes/silcdistdefs.h Sun Jul  1 19:18:19 2007
@@ -1,7 +1,7 @@
 /*
   Automatically generated by Autodist 1.3.2.  Do not edit.
 
-  Generated: Fri Jun  8 09:30:35 EEST 2007 by priikone
+  Generated: Sun Jul  1 19:05:57 EEST 2007 by priikone
   Distribution: Server
   License: 
 */

Modified: silc-server/branches/upstream/current/includes/silcversion.h.in
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/includes/silcversion.h.in?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/includes/silcversion.h.in (original)
+++ silc-server/branches/upstream/current/includes/silcversion.h.in Sun Jul  1 19:18:19 2007
@@ -24,6 +24,11 @@
 extern "C" {
 #endif
 
+/* Version check macro.  Use this to check that package is of specific
+   version compile time.  Use the __SILC_XXX_VERSION below in comparison. */
+#define SILC_VERSION(a, b, c) (((a) << 24) + ((b) << 16) + ((c) << 8)
+ at __SILC_PACKAGE_VERSION@
+
 #define SILC_VERSION_STRING "@VERSION@"
 #define SILC_DIST_VERSION_STRING "@VERSION@"
 #define SILC_PROTOCOL_VERSION_STRING "SILC-1.2- at VERSION@ @PACKAGE@"

Modified: silc-server/branches/upstream/current/lib/Makefile.am
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/Makefile.am?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/Makefile.am (original)
+++ silc-server/branches/upstream/current/lib/Makefile.am Sun Jul  1 19:18:19 2007
@@ -2,7 +2,7 @@
 # To make changes edit the ./lib/Makefile.ad file in the source tree.
 
 # Source: ./lib/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 

Modified: silc-server/branches/upstream/current/lib/Makefile.in
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/Makefile.in?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/Makefile.in (original)
+++ silc-server/branches/upstream/current/lib/Makefile.in Sun Jul  1 19:18:19 2007
@@ -18,7 +18,7 @@
 # To make changes edit the ./lib/Makefile.ad file in the source tree.
 
 # Source: ./lib/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 
@@ -214,6 +214,7 @@
 __SILC_ENABLE_DEBUG = @__SILC_ENABLE_DEBUG@
 __SILC_HAVE_PTHREAD = @__SILC_HAVE_PTHREAD@
 __SILC_HAVE_SIM = @__SILC_HAVE_SIM@
+__SILC_PACKAGE_VERSION = @__SILC_PACKAGE_VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@

Modified: silc-server/branches/upstream/current/lib/contrib/Makefile.am
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/contrib/Makefile.am?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/contrib/Makefile.am (original)
+++ silc-server/branches/upstream/current/lib/contrib/Makefile.am Sun Jul  1 19:18:19 2007
@@ -2,7 +2,7 @@
 # To make changes edit the ./lib/contrib/Makefile.ad file in the source tree.
 
 # Source: ./lib/contrib/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 

Modified: silc-server/branches/upstream/current/lib/contrib/Makefile.in
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/contrib/Makefile.in?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/contrib/Makefile.in (original)
+++ silc-server/branches/upstream/current/lib/contrib/Makefile.in Sun Jul  1 19:18:19 2007
@@ -18,7 +18,7 @@
 # To make changes edit the ./lib/contrib/Makefile.ad file in the source tree.
 
 # Source: ./lib/contrib/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 
@@ -226,6 +226,7 @@
 __SILC_ENABLE_DEBUG = @__SILC_ENABLE_DEBUG@
 __SILC_HAVE_PTHREAD = @__SILC_HAVE_PTHREAD@
 __SILC_HAVE_SIM = @__SILC_HAVE_SIM@
+__SILC_PACKAGE_VERSION = @__SILC_PACKAGE_VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@

Modified: silc-server/branches/upstream/current/lib/silcapputil/Makefile.am
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcapputil/Makefile.am?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcapputil/Makefile.am (original)
+++ silc-server/branches/upstream/current/lib/silcapputil/Makefile.am Sun Jul  1 19:18:19 2007
@@ -2,7 +2,7 @@
 # To make changes edit the ./lib/silcapputil/Makefile.ad file in the source tree.
 
 # Source: ./lib/silcapputil/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 

Modified: silc-server/branches/upstream/current/lib/silcapputil/Makefile.in
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcapputil/Makefile.in?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcapputil/Makefile.in (original)
+++ silc-server/branches/upstream/current/lib/silcapputil/Makefile.in Sun Jul  1 19:18:19 2007
@@ -18,7 +18,7 @@
 # To make changes edit the ./lib/silcapputil/Makefile.ad file in the source tree.
 
 # Source: ./lib/silcapputil/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 
@@ -219,6 +219,7 @@
 __SILC_ENABLE_DEBUG = @__SILC_ENABLE_DEBUG@
 __SILC_HAVE_PTHREAD = @__SILC_HAVE_PTHREAD@
 __SILC_HAVE_SIM = @__SILC_HAVE_SIM@
+__SILC_PACKAGE_VERSION = @__SILC_PACKAGE_VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@

Modified: silc-server/branches/upstream/current/lib/silcapputil/silcapputil.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcapputil/silcapputil.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcapputil/silcapputil.c (original)
+++ silc-server/branches/upstream/current/lib/silcapputil/silcapputil.c Sun Jul  1 19:18:19 2007
@@ -16,7 +16,7 @@
   GNU General Public License for more details.
 
 */
-/* $Id: silcapputil.c,v 1.9.2.1 2007/06/01 21:56:21 priikone Exp $ */
+/* $Id: silcapputil.c,v 1.9.2.2 2007/06/18 05:21:06 priikone Exp $ */
 
 #include "silc.h"
 
@@ -144,6 +144,12 @@
     }
 
     silc_free(def);
+  }
+
+  if (!strstr(identifier, "UN=") || !strstr(identifier, "HN=")) {
+    fprintf(stderr, "Invalid public key identifier.  You must specify both "
+	    "UN and HN\n");
+    return FALSE;
   }
 
   rng = silc_rng_alloc();
@@ -202,12 +208,14 @@
     return FALSE;
 
   /* Save public key into file */
-  silc_pkcs_save_public_key(pkfile, public_key, SILC_PKCS_FILE_BASE64);
+  if (!silc_pkcs_save_public_key(pkfile, public_key, SILC_PKCS_FILE_BASE64))
+    return FALSE;
 
   /* Save private key into file */
-  silc_pkcs_save_private_key(prvfile, private_key,
-			     (const unsigned char *)pass, strlen(pass),
-			     SILC_PKCS_FILE_BIN, rng);
+  if (!silc_pkcs_save_private_key(prvfile, private_key,
+				  (const unsigned char *)pass, strlen(pass),
+				  SILC_PKCS_FILE_BIN, rng))
+    return FALSE;
 
   if (return_public_key)
     *return_public_key = public_key;

Modified: silc-server/branches/upstream/current/lib/silcapputil/silcidcache.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcapputil/silcidcache.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcapputil/silcidcache.c (original)
+++ silc-server/branches/upstream/current/lib/silcapputil/silcidcache.c Sun Jul  1 19:18:19 2007
@@ -16,7 +16,7 @@
   GNU General Public License for more details.
 
 */
-/* $Id: silcidcache.c,v 1.11 2007/04/24 17:31:23 priikone Exp $ */
+/* $Id: silcidcache.c,v 1.11.2.1 2007/07/01 11:12:05 priikone Exp $ */
 
 #include "silc.h"
 #include "silcidcache.h"
@@ -296,6 +296,70 @@
   return silc_idcache_update(cache, c, new_id, new_name, free_old_name);
 }
 
+/* Move entry to another cache */
+
+SilcBool silc_idcache_move(SilcIDCache from_cache, SilcIDCache to_cache,
+			   SilcIDCacheEntry entry)
+{
+  SilcIDCacheEntry c;
+
+  SILC_LOG_DEBUG(("Moving entry %p from %p cache to %p cache", entry,
+		  from_cache, to_cache));
+
+  if (!from_cache || !to_cache || !entry)
+    return FALSE;
+
+  if (from_cache->id_type != to_cache->id_type) {
+    SILC_LOG_ERROR(("Incompatible ID caches, cannot move entry"));
+    return FALSE;
+  }
+
+  if (entry->context) {
+    if (!silc_hash_table_find(from_cache->context_table, entry->context,
+			      NULL, (void *)&c))
+      return FALSE;
+  } else if (entry->name) {
+    if (!silc_hash_table_find(from_cache->name_table, entry->name,
+			      NULL, (void *)&c))
+      return FALSE;
+  } else if (entry->id) {
+    if (!silc_hash_table_find(from_cache->id_table, entry->id,
+			      NULL, (void *)&c))
+      return FALSE;
+  } else {
+    return FALSE;
+  }
+
+  if (entry != c)
+    return FALSE;
+
+  /* See if this entry is added already to cache */
+  if (c->id && silc_idcache_find_by_id_one(to_cache, c->id, NULL)) {
+    SILC_LOG_ERROR(("Attempted to add same ID twice to ID Cache, id %s",
+		    silc_id_render(c->id, to_cache->id_type)));
+    SILC_ASSERT(FALSE);
+    return FALSE;
+  }
+
+  /* Remove from original cache */
+  if (c->name)
+    silc_hash_table_del_by_context(from_cache->name_table, c->name, c);
+  if (c->context)
+    silc_hash_table_del_by_context(from_cache->context_table, c->context, c);
+  if (c->id)
+    silc_hash_table_del_by_context(from_cache->id_table, c->id, c);
+
+  /* Move to the other cache */
+  if (c->id)
+    silc_hash_table_add(to_cache->id_table, c->id, c);
+  if (c->name)
+    silc_hash_table_add(to_cache->name_table, c->name, c);
+  if (c->context)
+    silc_hash_table_add(to_cache->context_table, c->context, c);
+
+  return TRUE;
+}
+
 /* Returns all cache entrys from the ID cache to the `ret' ID Cache List. */
 
 SilcBool silc_idcache_get_all(SilcIDCache cache, SilcList *ret_list)

Modified: silc-server/branches/upstream/current/lib/silcapputil/silcidcache.h
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcapputil/silcidcache.h?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcapputil/silcidcache.h (original)
+++ silc-server/branches/upstream/current/lib/silcapputil/silcidcache.h Sun Jul  1 19:18:19 2007
@@ -240,6 +240,24 @@
 					void *new_id, char *new_name,
 					SilcBool free_old_name);
 
+/****f* silcapputil/SilcIDCacheAPI/silc_idcache_move
+ *
+ * SYNOPSIS
+ *
+ *    SilcBool silc_idcache_move(SilcIDCache from_cache, SilcIDCache to_cache,
+ *                               SilcIDCacheEntry entry);
+ *
+ * DESCRIPTION
+ *
+ *    Moves the ID cache entry indicated by `entry' from the `from_cache'
+ *    to `to_cache'.  After this returns TRUE the `entry' is available only
+ *    from the `to_cache'.  Return FALSE if `entry' is not in `from_cache'
+ *    or system is out of memory.
+ *
+ ***/
+SilcBool silc_idcache_move(SilcIDCache from_cache, SilcIDCache to_cache,
+			   SilcIDCacheEntry entry);
+
 /****f* silcapputil/SilcIDCacheAPI/silc_idcache_get_all
  *
  * SYNOPSIS

Modified: silc-server/branches/upstream/current/lib/silcasn1/Makefile.am
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcasn1/Makefile.am?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcasn1/Makefile.am (original)
+++ silc-server/branches/upstream/current/lib/silcasn1/Makefile.am Sun Jul  1 19:18:19 2007
@@ -2,7 +2,7 @@
 # To make changes edit the ./lib/silcasn1/Makefile.ad file in the source tree.
 
 # Source: ./lib/silcasn1/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 

Modified: silc-server/branches/upstream/current/lib/silcasn1/Makefile.in
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcasn1/Makefile.in?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcasn1/Makefile.in (original)
+++ silc-server/branches/upstream/current/lib/silcasn1/Makefile.in Sun Jul  1 19:18:19 2007
@@ -18,7 +18,7 @@
 # To make changes edit the ./lib/silcasn1/Makefile.ad file in the source tree.
 
 # Source: ./lib/silcasn1/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 
@@ -220,6 +220,7 @@
 __SILC_ENABLE_DEBUG = @__SILC_ENABLE_DEBUG@
 __SILC_HAVE_PTHREAD = @__SILC_HAVE_PTHREAD@
 __SILC_HAVE_SIM = @__SILC_HAVE_SIM@
+__SILC_PACKAGE_VERSION = @__SILC_PACKAGE_VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@

Modified: silc-server/branches/upstream/current/lib/silcasn1/silcasn1_decode.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcasn1/silcasn1_decode.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcasn1/silcasn1_decode.c (original)
+++ silc-server/branches/upstream/current/lib/silcasn1/silcasn1_decode.c Sun Jul  1 19:18:19 2007
@@ -230,7 +230,7 @@
     ret = FALSE;						\
     goto fail;							\
   }								\
-  *s = silc_smalloc_ua(stack1, *s_len + 1);			\
+  *s = silc_smalloc(stack1, *s_len + 1);			\
   if (*s) {							\
     silc_utf8_encode(rdata, rdata_len, (enc), *s, *s_len);	\
     (*s)[*s_len] = '\0';					\

Modified: silc-server/branches/upstream/current/lib/silcasn1/silcasn1_encode.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcasn1/silcasn1_encode.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcasn1/silcasn1_encode.c (original)
+++ silc-server/branches/upstream/current/lib/silcasn1/silcasn1_encode.c Sun Jul  1 19:18:19 2007
@@ -38,7 +38,7 @@
     goto fail;								\
   }									\
   silc_stack_push(asn1->stack2, &frame);				\
-  s = silc_smalloc_ua(stack2, s_len + 1);				\
+  s = silc_smalloc(stack2, s_len + 1);					\
   if (s) {								\
     silc_utf8_decode(d, d_len, (enc), s, s_len);			\
     s[s_len] = '\0';							\

Modified: silc-server/branches/upstream/current/lib/silccore/Makefile.am
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silccore/Makefile.am?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silccore/Makefile.am (original)
+++ silc-server/branches/upstream/current/lib/silccore/Makefile.am Sun Jul  1 19:18:19 2007
@@ -2,7 +2,7 @@
 # To make changes edit the ./lib/silccore/Makefile.ad file in the source tree.
 
 # Source: ./lib/silccore/Makefile.ad
-# Generated: Fri Jun  8 09:30:37 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 

Modified: silc-server/branches/upstream/current/lib/silccore/Makefile.in
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silccore/Makefile.in?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silccore/Makefile.in (original)
+++ silc-server/branches/upstream/current/lib/silccore/Makefile.in Sun Jul  1 19:18:19 2007
@@ -18,7 +18,7 @@
 # To make changes edit the ./lib/silccore/Makefile.ad file in the source tree.
 
 # Source: ./lib/silccore/Makefile.ad
-# Generated: Fri Jun  8 09:30:37 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 
@@ -221,6 +221,7 @@
 __SILC_ENABLE_DEBUG = @__SILC_ENABLE_DEBUG@
 __SILC_HAVE_PTHREAD = @__SILC_HAVE_PTHREAD@
 __SILC_HAVE_SIM = @__SILC_HAVE_SIM@
+__SILC_PACKAGE_VERSION = @__SILC_PACKAGE_VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@

Modified: silc-server/branches/upstream/current/lib/silccore/silcargument.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silccore/silcargument.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silccore/silcargument.c (original)
+++ silc-server/branches/upstream/current/lib/silccore/silcargument.c Sun Jul  1 19:18:19 2007
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone at 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
@@ -17,7 +17,7 @@
 
 */
 /* Implementation of Argument Payload routines */
-/* $Id: silcargument.c,v 1.18 2007/01/23 14:52:01 priikone Exp $ */
+/* $Id: silcargument.c,v 1.18.2.1 2007/07/01 13:56:39 priikone Exp $ */
 
 #include "silc.h"
 #include "silcargument.h"
@@ -67,8 +67,10 @@
 			       SILC_STR_UI_SHORT(&p_len),
 			       SILC_STR_UI_CHAR(&arg_type),
 			       SILC_STR_END);
-    if (ret == -1 || p_len > silc_buffer_len(&buffer) - 3)
+    if (ret == -1 || p_len > silc_buffer_len(&buffer) - 3) {
+      SILC_LOG_DEBUG(("Malformed argument payload"));
       goto err;
+    }
 
     newp->argv_lens[i] = p_len;
     newp->argv_types[i] = arg_type;
@@ -79,8 +81,10 @@
 			       SILC_STR_UI_XNSTRING_ALLOC(&newp->argv[i],
 							  p_len),
 			       SILC_STR_END);
-    if (ret == -1)
+    if (ret == -1) {
+      SILC_LOG_DEBUG(("Malformed argument payload"));
       goto err;
+    }
 
     silc_buffer_pull(&buffer, p_len);
     pull_len += 3 + p_len;

Modified: silc-server/branches/upstream/current/lib/silccore/silcnotify.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silccore/silcnotify.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silccore/silcnotify.c (original)
+++ silc-server/branches/upstream/current/lib/silccore/silcnotify.c Sun Jul  1 19:18:19 2007
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone at silcnet.org>
 
-  Copyright (C) 2000 - 2005 Pekka Riikonen
+  Copyright (C) 2000 - 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
@@ -16,7 +16,7 @@
   GNU General Public License for more details.
 
 */
-/* $Id: silcnotify.c,v 1.23 2006/11/06 16:26:43 priikone Exp $ */
+/* $Id: silcnotify.c,v 1.23.2.1 2007/07/01 13:56:39 priikone Exp $ */
 
 #include "silc.h"
 #include "silcnotify.h"
@@ -66,6 +66,8 @@
     newp->args = silc_argument_payload_parse(buffer.data,
 					     silc_buffer_len(&buffer),
 					     newp->argc);
+    if (!newp->args)
+      goto err;
     silc_buffer_push(&buffer, 5);
   }
 

Modified: silc-server/branches/upstream/current/lib/silccore/silcpacket.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silccore/silcpacket.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silccore/silcpacket.c (original)
+++ silc-server/branches/upstream/current/lib/silccore/silcpacket.c Sun Jul  1 19:18:19 2007
@@ -19,7 +19,7 @@
 /*
  * Created: Fri Jul 25 18:52:14 1997
  */
-/* $Id: silcpacket.c,v 1.106.2.2 2007/06/05 19:02:59 priikone Exp $ */
+/* $Id: silcpacket.c,v 1.106.2.5 2007/07/01 13:56:59 priikone Exp $ */
 
 #include "silc.h"
 
@@ -638,7 +638,7 @@
 const char *silc_packet_error_string(SilcPacketError error)
 {
   if (error < SILC_PACKET_ERR_READ || error > SILC_PACKET_ERR_NO_MEMORY)
-    return "";
+    return "<invalid error code>";
   return packet_error[error];
 }
 
@@ -655,11 +655,26 @@
 
   silc_mutex_lock(engine->lock);
   silc_list_start(engine->streams);
-  while ((ps = silc_list_get(engine->streams)))
+  while ((ps = silc_list_get(engine->streams))) {
+    silc_packet_stream_ref(ps);
     silc_dlist_add(list, ps);
+  }
   silc_mutex_unlock(engine->lock);
 
   return list;
+}
+
+/* Free list returned by silc_packet_engine_get_streams */
+
+void silc_packet_engine_free_streams_list(SilcDList streams)
+{
+  SilcPacketStream ps;
+
+  silc_dlist_start(streams);
+  while ((ps = silc_dlist_get(streams)))
+    silc_packet_stream_unref(ps);
+
+  silc_dlist_uninit(streams);
 }
 
 /* Create new packet stream */
@@ -1307,11 +1322,11 @@
   if (!src_id && !dst_id)
     return FALSE;
 
-  SILC_LOG_DEBUG(("Setting new IDs to packet stream"));
-
   silc_mutex_lock(stream->lock);
 
   if (src_id) {
+    SILC_LOG_DEBUG(("Setting source ID to packet stream %p", stream));
+
     silc_free(stream->src_id);
     if (!silc_id_id2str(src_id, src_id_type, tmp, sizeof(tmp), &len)) {
       silc_mutex_unlock(stream->lock);
@@ -1327,6 +1342,8 @@
   }
 
   if (dst_id) {
+    SILC_LOG_DEBUG(("Setting destination ID to packet stream %p", stream));
+
     silc_free(stream->dst_id);
     if (!silc_id_id2str(dst_id, dst_id_type, tmp, sizeof(tmp), &len)) {
       silc_mutex_unlock(stream->lock);
@@ -1955,8 +1972,8 @@
 		   silc_buffer_len(buffer)), buffer->head,
 		   silc_buffer_headlen(buffer) + silc_buffer_len(buffer));
 
-  SILC_LOG_DEBUG(("Incoming packet type: %d (%s)", packet->type,
-		  silc_get_packet_name(packet->type)));
+  SILC_LOG_DEBUG(("Incoming packet type: %d (%s), flags %d", packet->type,
+		  silc_get_packet_name(packet->type), packet->flags));
 
   return TRUE;
 }

Modified: silc-server/branches/upstream/current/lib/silccore/silcpacket.h
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silccore/silcpacket.h?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silccore/silcpacket.h (original)
+++ silc-server/branches/upstream/current/lib/silccore/silcpacket.h Sun Jul  1 19:18:19 2007
@@ -115,7 +115,7 @@
 #define SILC_PACKET_FLAG_ACK              0x10    /* Acknowledge packet */
 
 /* Impelemntation specific flags */
-#define SILC_PACKET_FLAG_LONG_PAD         0x12    /* Use maximum padding */
+#define SILC_PACKET_FLAG_LONG_PAD         0x20    /* Use maximum padding */
 /***/
 
 /****s* silccore/SilcPacketAPI/SilcPacketEngine
@@ -400,10 +400,23 @@
  * DESCRIPTION
  *
  *    Returns list of packet streams added to the packet engine.  The caller
- *    must free the list with silc_dlist_uninit.
+ *    must free the list with silc_packet_engine_free_streams_list.
  *
  ***/
 SilcDList silc_packet_engine_get_streams(SilcPacketEngine engine);
+
+/****f* silccore/SilcPacketAPI/silc_packet_engine_free_streams_list
+ *
+ * SYNOPSIS
+ *
+ *    void silc_packet_engine_free_streams_list(SilcDList streams);
+ *
+ * DESCRIPTION
+ *
+ *    Free's the streams list returned by silc_packet_engine_get_streams.
+ *
+ ***/
+void silc_packet_engine_free_streams_list(SilcDList streams);
 
 /****f* silccore/SilcPacketAPI/silc_packet_stream_create
  *

Modified: silc-server/branches/upstream/current/lib/silccrypt/Makefile.am
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silccrypt/Makefile.am?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silccrypt/Makefile.am (original)
+++ silc-server/branches/upstream/current/lib/silccrypt/Makefile.am Sun Jul  1 19:18:19 2007
@@ -2,7 +2,7 @@
 # To make changes edit the ./lib/silccrypt/Makefile.ad file in the source tree.
 
 # Source: ./lib/silccrypt/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 

Modified: silc-server/branches/upstream/current/lib/silccrypt/Makefile.in
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silccrypt/Makefile.in?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silccrypt/Makefile.in (original)
+++ silc-server/branches/upstream/current/lib/silccrypt/Makefile.in Sun Jul  1 19:18:19 2007
@@ -18,7 +18,7 @@
 # To make changes edit the ./lib/silccrypt/Makefile.ad file in the source tree.
 
 # Source: ./lib/silccrypt/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 
@@ -230,6 +230,7 @@
 __SILC_ENABLE_DEBUG = @__SILC_ENABLE_DEBUG@
 __SILC_HAVE_PTHREAD = @__SILC_HAVE_PTHREAD@
 __SILC_HAVE_SIM = @__SILC_HAVE_SIM@
+__SILC_PACKAGE_VERSION = @__SILC_PACKAGE_VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@

Modified: silc-server/branches/upstream/current/lib/silchttp/Makefile.am
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silchttp/Makefile.am?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silchttp/Makefile.am (original)
+++ silc-server/branches/upstream/current/lib/silchttp/Makefile.am Sun Jul  1 19:18:19 2007
@@ -2,7 +2,7 @@
 # To make changes edit the ./lib/silchttp/Makefile.ad file in the source tree.
 
 # Source: ./lib/silchttp/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 

Modified: silc-server/branches/upstream/current/lib/silchttp/Makefile.in
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silchttp/Makefile.in?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silchttp/Makefile.in (original)
+++ silc-server/branches/upstream/current/lib/silchttp/Makefile.in Sun Jul  1 19:18:19 2007
@@ -18,7 +18,7 @@
 # To make changes edit the ./lib/silchttp/Makefile.ad file in the source tree.
 
 # Source: ./lib/silchttp/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 
@@ -219,6 +219,7 @@
 __SILC_ENABLE_DEBUG = @__SILC_ENABLE_DEBUG@
 __SILC_HAVE_PTHREAD = @__SILC_HAVE_PTHREAD@
 __SILC_HAVE_SIM = @__SILC_HAVE_SIM@
+__SILC_PACKAGE_VERSION = @__SILC_PACKAGE_VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@

Modified: silc-server/branches/upstream/current/lib/silcmath/Makefile.am
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcmath/Makefile.am?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcmath/Makefile.am (original)
+++ silc-server/branches/upstream/current/lib/silcmath/Makefile.am Sun Jul  1 19:18:19 2007
@@ -2,7 +2,7 @@
 # To make changes edit the ./lib/silcmath/Makefile.ad file in the source tree.
 
 # Source: ./lib/silcmath/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 

Modified: silc-server/branches/upstream/current/lib/silcmath/Makefile.in
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcmath/Makefile.in?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcmath/Makefile.in (original)
+++ silc-server/branches/upstream/current/lib/silcmath/Makefile.in Sun Jul  1 19:18:19 2007
@@ -18,7 +18,7 @@
 # To make changes edit the ./lib/silcmath/Makefile.ad file in the source tree.
 
 # Source: ./lib/silcmath/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 
@@ -224,6 +224,7 @@
 __SILC_ENABLE_DEBUG = @__SILC_ENABLE_DEBUG@
 __SILC_HAVE_PTHREAD = @__SILC_HAVE_PTHREAD@
 __SILC_HAVE_SIM = @__SILC_HAVE_SIM@
+__SILC_PACKAGE_VERSION = @__SILC_PACKAGE_VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@

Modified: silc-server/branches/upstream/current/lib/silcsim/Makefile.am
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcsim/Makefile.am?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcsim/Makefile.am (original)
+++ silc-server/branches/upstream/current/lib/silcsim/Makefile.am Sun Jul  1 19:18:19 2007
@@ -2,7 +2,7 @@
 # To make changes edit the ./lib/silcsim/Makefile.ad file in the source tree.
 
 # Source: ./lib/silcsim/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 

Modified: silc-server/branches/upstream/current/lib/silcsim/Makefile.in
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcsim/Makefile.in?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcsim/Makefile.in (original)
+++ silc-server/branches/upstream/current/lib/silcsim/Makefile.in Sun Jul  1 19:18:19 2007
@@ -18,7 +18,7 @@
 # To make changes edit the ./lib/silcsim/Makefile.ad file in the source tree.
 
 # Source: ./lib/silcsim/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 
@@ -220,6 +220,7 @@
 __SILC_ENABLE_DEBUG = @__SILC_ENABLE_DEBUG@
 __SILC_HAVE_PTHREAD = @__SILC_HAVE_PTHREAD@
 __SILC_HAVE_SIM = @__SILC_HAVE_SIM@
+__SILC_PACKAGE_VERSION = @__SILC_PACKAGE_VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@

Modified: silc-server/branches/upstream/current/lib/silcske/Makefile.am
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcske/Makefile.am?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcske/Makefile.am (original)
+++ silc-server/branches/upstream/current/lib/silcske/Makefile.am Sun Jul  1 19:18:19 2007
@@ -2,7 +2,7 @@
 # To make changes edit the ./lib/silcske/Makefile.ad file in the source tree.
 
 # Source: ./lib/silcske/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 

Modified: silc-server/branches/upstream/current/lib/silcske/Makefile.in
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcske/Makefile.in?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcske/Makefile.in (original)
+++ silc-server/branches/upstream/current/lib/silcske/Makefile.in Sun Jul  1 19:18:19 2007
@@ -18,7 +18,7 @@
 # To make changes edit the ./lib/silcske/Makefile.ad file in the source tree.
 
 # Source: ./lib/silcske/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 
@@ -220,6 +220,7 @@
 __SILC_ENABLE_DEBUG = @__SILC_ENABLE_DEBUG@
 __SILC_HAVE_PTHREAD = @__SILC_HAVE_PTHREAD@
 __SILC_HAVE_SIM = @__SILC_HAVE_SIM@
+__SILC_PACKAGE_VERSION = @__SILC_PACKAGE_VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@

Modified: silc-server/branches/upstream/current/lib/silcske/silcconnauth.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcske/silcconnauth.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcske/silcconnauth.c (original)
+++ silc-server/branches/upstream/current/lib/silcske/silcconnauth.c Sun Jul  1 19:18:19 2007
@@ -487,7 +487,8 @@
 
   if (connauth->aborted) {
     /** Aborted */
-    silc_packet_free(connauth->packet);
+    if (connauth->packet)
+      silc_packet_free(connauth->packet);
     silc_fsm_next(fsm, silc_connauth_st_responder_failure);
     return SILC_FSM_CONTINUE;
   }

Modified: silc-server/branches/upstream/current/lib/silcske/silcske.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcske/silcske.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcske/silcske.c (original)
+++ silc-server/branches/upstream/current/lib/silcske/silcske.c Sun Jul  1 19:18:19 2007
@@ -16,7 +16,7 @@
   GNU General Public License for more details.
 
 */
-/* $Id: silcske.c,v 1.92 2007/05/01 16:49:42 priikone Exp $ */
+/* $Id: silcske.c,v 1.92.2.3 2007/07/01 11:12:46 priikone Exp $ */
 
 #include "silc.h"
 #include "silcske.h"
@@ -671,19 +671,23 @@
 {
   SilcSKEStatus status = SILC_SKE_STATUS_OK;
   SilcBuffer buf;
-  unsigned char *e, *f, *KEY;
-  SilcUInt32 e_len, f_len, KEY_len;
+  unsigned char *e, *f, *KEY, *s_data;
+  SilcUInt32 e_len, f_len, KEY_len, s_len;
   int ret;
 
   SILC_LOG_DEBUG(("Start"));
 
   if (initiator == FALSE) {
+    s_data = (ske->start_payload_copy ?
+	     silc_buffer_data(ske->start_payload_copy) : NULL);
+    s_len = (ske->start_payload_copy ?
+	     silc_buffer_len(ske->start_payload_copy) : 0);
     e = silc_mp_mp2bin(&ske->ke1_payload->x, 0, &e_len);
     f = silc_mp_mp2bin(&ske->ke2_payload->x, 0, &f_len);
     KEY = silc_mp_mp2bin(ske->KEY, 0, &KEY_len);
 
     /* Format the buffer used to compute the hash value */
-    buf = silc_buffer_alloc_size(silc_buffer_len(ske->start_payload_copy) +
+    buf = silc_buffer_alloc_size(s_len +
 				 ske->ke2_payload->pk_len +
 				 ske->ke1_payload->pk_len +
 				 e_len + f_len + KEY_len);
@@ -694,28 +698,24 @@
     if (!ske->ke1_payload->pk_data) {
       ret =
 	silc_buffer_format(buf,
-			   SILC_STR_UI_XNSTRING(
-				   ske->start_payload_copy->data,
-				   silc_buffer_len(ske->start_payload_copy)),
-			   SILC_STR_UI_XNSTRING(ske->ke2_payload->pk_data,
-						ske->ke2_payload->pk_len),
-			   SILC_STR_UI_XNSTRING(e, e_len),
-			   SILC_STR_UI_XNSTRING(f, f_len),
-			   SILC_STR_UI_XNSTRING(KEY, KEY_len),
+			   SILC_STR_DATA(s_data, s_len),
+			   SILC_STR_DATA(ske->ke2_payload->pk_data,
+					 ske->ke2_payload->pk_len),
+			   SILC_STR_DATA(e, e_len),
+			   SILC_STR_DATA(f, f_len),
+			   SILC_STR_DATA(KEY, KEY_len),
 			   SILC_STR_END);
     } else {
       ret =
 	silc_buffer_format(buf,
-			   SILC_STR_UI_XNSTRING(
-				   ske->start_payload_copy->data,
-				   silc_buffer_len(ske->start_payload_copy)),
-			   SILC_STR_UI_XNSTRING(ske->ke2_payload->pk_data,
-						ske->ke2_payload->pk_len),
-			   SILC_STR_UI_XNSTRING(ske->ke1_payload->pk_data,
-						ske->ke1_payload->pk_len),
-			   SILC_STR_UI_XNSTRING(e, e_len),
-			   SILC_STR_UI_XNSTRING(f, f_len),
-			   SILC_STR_UI_XNSTRING(KEY, KEY_len),
+			   SILC_STR_DATA(s_data, s_len),
+			   SILC_STR_DATA(ske->ke2_payload->pk_data,
+					 ske->ke2_payload->pk_len),
+			   SILC_STR_DATA(ske->ke1_payload->pk_data,
+					 ske->ke1_payload->pk_len),
+			   SILC_STR_DATA(e, e_len),
+			   SILC_STR_DATA(f, f_len),
+			   SILC_STR_DATA(KEY, KEY_len),
 			   SILC_STR_END);
     }
     if (ret == -1) {
@@ -736,21 +736,23 @@
     silc_free(f);
     silc_free(KEY);
   } else {
+    s_data = (ske->start_payload_copy ?
+	     silc_buffer_data(ske->start_payload_copy) : NULL);
+    s_len = (ske->start_payload_copy ?
+	     silc_buffer_len(ske->start_payload_copy) : 0);
     e = silc_mp_mp2bin(&ske->ke1_payload->x, 0, &e_len);
 
-    buf = silc_buffer_alloc_size(silc_buffer_len(ske->start_payload_copy) +
-				 ske->ke1_payload->pk_len + e_len);
+    buf = silc_buffer_alloc_size(s_len + ske->ke1_payload->pk_len + e_len);
     if (!buf)
       return SILC_SKE_STATUS_OUT_OF_MEMORY;
 
     /* Format the buffer used to compute the hash value */
     ret =
       silc_buffer_format(buf,
-			 SILC_STR_UI_XNSTRING(ske->start_payload_copy->data,
-		       	             silc_buffer_len(ske->start_payload_copy)),
-			 SILC_STR_UI_XNSTRING(ske->ke1_payload->pk_data,
-					      ske->ke1_payload->pk_len),
-			 SILC_STR_UI_XNSTRING(e, e_len),
+			 SILC_STR_DATA(s_data, s_len),
+			 SILC_STR_DATA(ske->ke1_payload->pk_data,
+				       ske->ke1_payload->pk_len),
+			 SILC_STR_DATA(e, e_len),
 			 SILC_STR_END);
     if (ret == -1) {
       silc_buffer_free(buf);
@@ -1611,14 +1613,16 @@
 
   payload = ske->ke2_payload;
 
+  /* Compute the HASH value */
+  SILC_LOG_DEBUG(("Computing HASH value"));
+  status = silc_ske_make_hash(ske, hash, &hash_len, FALSE);
+  if (status != SILC_SKE_STATUS_OK)
+    goto err;
+  ske->hash = silc_memdup(hash, hash_len);
+  ske->hash_len = hash_len;
+
   if (ske->prop->public_key) {
     SILC_LOG_DEBUG(("Public key is authentic"));
-
-    /* Compute the hash value */
-    status = silc_ske_make_hash(ske, hash, &hash_len, FALSE);
-    if (status != SILC_SKE_STATUS_OK)
-      goto err;
-
     SILC_LOG_DEBUG(("Verifying signature (HASH)"));
 
     /* Verify signature */
@@ -1630,9 +1634,6 @@
     }
 
     SILC_LOG_DEBUG(("Signature is Ok"));
-
-    ske->hash = silc_memdup(hash, hash_len);
-    ske->hash_len = hash_len;
     memset(hash, 'F', hash_len);
   }
 
@@ -1884,6 +1885,7 @@
   SilcSKEStatus status;
   SilcSKEStartPayload remote_payload = NULL;
   SilcBuffer packet_buf = &ske->packet->buffer;
+  SilcID id;
 
   SILC_LOG_DEBUG(("Start"));
 
@@ -1896,6 +1898,19 @@
     ske->status = status;
     silc_fsm_next(fsm, silc_ske_st_responder_error);
     return SILC_FSM_CONTINUE;
+  }
+
+  /* Get remote ID and set it to stream */
+  if (ske->packet->src_id_len) {
+    silc_id_str2id(ske->packet->src_id, ske->packet->src_id_len,
+		   ske->packet->src_id_type,
+		   (ske->packet->src_id_type == SILC_ID_SERVER ?
+		    (void *)&id.u.server_id : (void *)&id.u.client_id),
+		   (ske->packet->src_id_type == SILC_ID_SERVER ?
+		    sizeof(id.u.server_id) : sizeof(id.u.client_id)));
+    silc_packet_set_ids(ske->stream, 0, NULL, ske->packet->src_id_type,
+			(ske->packet->src_id_type == SILC_ID_SERVER ?
+			 (void *)&id.u.server_id : (void *)&id.u.client_id));
   }
 
   /* Take a copy of the payload buffer for future use. It is used to
@@ -2209,22 +2224,23 @@
     }
     ske->ke2_payload->pk_data = pk;
     ske->ke2_payload->pk_len = pk_len;
-
-    SILC_LOG_DEBUG(("Computing HASH value"));
-
-    /* Compute the hash value */
-    memset(hash, 0, sizeof(hash));
-    status = silc_ske_make_hash(ske, hash, &hash_len, FALSE);
-    if (status != SILC_SKE_STATUS_OK) {
-      /** Error computing hash */
-      ske->status = status;
-      silc_fsm_next(fsm, silc_ske_st_responder_error);
-      return SILC_FSM_CONTINUE;
-    }
-
-    ske->hash = silc_memdup(hash, hash_len);
-    ske->hash_len = hash_len;
-
+  }
+
+  SILC_LOG_DEBUG(("Computing HASH value"));
+
+  /* Compute the hash value */
+  memset(hash, 0, sizeof(hash));
+  status = silc_ske_make_hash(ske, hash, &hash_len, FALSE);
+  if (status != SILC_SKE_STATUS_OK) {
+    /** Error computing hash */
+    ske->status = status;
+    silc_fsm_next(fsm, silc_ske_st_responder_error);
+    return SILC_FSM_CONTINUE;
+  }
+  ske->hash = silc_memdup(hash, hash_len);
+  ske->hash_len = hash_len;
+
+  if (ske->public_key && ske->private_key) {
     SILC_LOG_DEBUG(("Signing HASH value"));
 
     /* Sign the hash value */
@@ -2262,7 +2278,7 @@
 
   silc_buffer_free(payload_buf);
 
-  /* In case we are doing rekey move to finish it.  */
+  /* In case we are doing rekey move to finish it. */
   if (ske->rekey) {
     /** Finish rekey */
     silc_fsm_next(fsm, silc_ske_st_rekey_responder_done);
@@ -2461,6 +2477,13 @@
     return SILC_FSM_CONTINUE;
   }
 
+  if (!silc_hash_alloc(ske->rekey->hash, &ske->prop->hash)) {
+    /** Cannot allocate hash */
+    ske->status = SILC_SKE_STATUS_OUT_OF_MEMORY;
+    silc_fsm_next(fsm, silc_ske_st_initiator_error);
+    return SILC_FSM_CONTINUE;
+  }
+
   /* Send REKEY packet to start rekey protocol */
   if (!silc_ske_packet_send(ske, SILC_PACKET_REKEY, 0, NULL, 0)) {
     /** Error sending packet */
@@ -2506,13 +2529,7 @@
   silc_packet_get_keys(ske->stream, &send_key, NULL, &hmac_send, NULL);
   key_len = silc_cipher_get_key_len(send_key);
   block_len = silc_cipher_get_block_len(send_key);
-
-  if (!silc_hash_alloc(ske->rekey->hash, &hash)) {
-    /** Cannot allocate hash */
-    ske->status = SILC_SKE_STATUS_OUT_OF_MEMORY;
-    silc_fsm_next(fsm, silc_ske_st_initiator_error);
-    return SILC_FSM_CONTINUE;
-  }
+  hash = ske->prop->hash;
   hash_len = silc_hash_len(hash);
 
   /* Process key material */
@@ -2543,16 +2560,20 @@
 
   ske->prop->cipher = send_key;
   ske->prop->hmac = hmac_send;
-  ske->prop->hash = hash;
 
   /* Get sending keys */
   if (!silc_ske_set_keys(ske, ske->keymat, ske->prop, &send_key, NULL,
 			 &hmac_send, NULL, NULL)) {
     /** Cannot get keys */
     ske->status = SILC_SKE_STATUS_ERROR;
+    ske->prop->cipher = NULL;
+    ske->prop->hmac = NULL;
     silc_fsm_next(fsm, silc_ske_st_initiator_error);
     return SILC_FSM_CONTINUE;
   }
+
+  ske->prop->cipher = NULL;
+  ske->prop->hmac = NULL;
 
   /* Set the new keys into use.  This will also send REKEY_DONE packet.  Any
      packet sent after this call will be protected with the new keys. */
@@ -2561,6 +2582,8 @@
     /** Cannot set keys */
     SILC_LOG_DEBUG(("Cannot set new keys, error sending REKEY_DONE"));
     ske->status = SILC_SKE_STATUS_ERROR;
+    silc_cipher_free(send_key);
+    silc_hmac_free(hmac_send);
     silc_fsm_next(fsm, silc_ske_st_initiator_error);
     return SILC_FSM_CONTINUE;
   }
@@ -2597,6 +2620,8 @@
 			 NULL, &hmac_receive, NULL)) {
     /** Cannot get keys */
     ske->status = SILC_SKE_STATUS_ERROR;
+    ske->prop->cipher = NULL;
+    ske->prop->hmac = NULL;
     silc_fsm_next(fsm, silc_ske_st_initiator_error);
     return SILC_FSM_CONTINUE;
   }
@@ -2608,6 +2633,8 @@
     /** Cannot set keys */
     SILC_LOG_DEBUG(("Cannot set new keys"));
     ske->status = SILC_SKE_STATUS_ERROR;
+    silc_cipher_free(receive_key);
+    silc_hmac_free(hmac_receive);
     silc_fsm_next(fsm, silc_ske_st_initiator_error);
     return SILC_FSM_CONTINUE;
   }
@@ -2619,6 +2646,8 @@
   if (!rekey) {
     /** No memory */
     ske->status = SILC_SKE_STATUS_OUT_OF_MEMORY;
+    ske->prop->cipher = NULL;
+    ske->prop->hmac = NULL;
     silc_fsm_next(fsm, silc_ske_st_initiator_error);
     return SILC_FSM_CONTINUE;
   }
@@ -2647,8 +2676,11 @@
 {
   SILC_LOG_DEBUG(("Start SKE rekey as initator"));
 
-  if (!ske || !stream || !rekey)
+  if (!ske || !stream || !rekey) {
+    SILC_LOG_ERROR(("Missing arguments to silc_ske_rekey_initiator"));
+    SILC_ASSERT(rekey);
     return NULL;
+  }
 
   if (!silc_async_init(&ske->op, silc_ske_abort, NULL, ske))
     return NULL;
@@ -2696,7 +2728,6 @@
   silc_schedule_task_add_timeout(ske->schedule, silc_ske_timeout,
 				 ske, 30, 0);
 
-
   silc_fsm_next(fsm, silc_ske_st_rekey_responder_start);
 
   /* If REKEY packet already received process it directly */
@@ -2727,6 +2758,13 @@
   ske->prop = silc_calloc(1, sizeof(*ske->prop));
   if (!ske->prop) {
     /** No memory */
+    ske->status = SILC_SKE_STATUS_OUT_OF_MEMORY;
+    silc_fsm_next(fsm, silc_ske_st_responder_error);
+    return SILC_FSM_CONTINUE;
+  }
+
+  if (!silc_hash_alloc(ske->rekey->hash, &ske->prop->hash)) {
+    /** Cannot allocate hash */
     ske->status = SILC_SKE_STATUS_OUT_OF_MEMORY;
     silc_fsm_next(fsm, silc_ske_st_responder_error);
     return SILC_FSM_CONTINUE;
@@ -2768,13 +2806,7 @@
   silc_packet_get_keys(ske->stream, &send_key, NULL, &hmac_send, NULL);
   key_len = silc_cipher_get_key_len(send_key);
   block_len = silc_cipher_get_block_len(send_key);
-
-  if (!silc_hash_alloc(ske->rekey->hash, &hash)) {
-    /** Cannot allocate hash */
-    ske->status = SILC_SKE_STATUS_OUT_OF_MEMORY;
-    silc_fsm_next(fsm, silc_ske_st_responder_error);
-    return SILC_FSM_CONTINUE;
-  }
+  hash = ske->prop->hash;
   hash_len = silc_hash_len(hash);
 
   /* Process key material */
@@ -2805,16 +2837,20 @@
 
   ske->prop->cipher = send_key;
   ske->prop->hmac = hmac_send;
-  ske->prop->hash = hash;
 
   /* Get sending keys */
   if (!silc_ske_set_keys(ske, ske->keymat, ske->prop, &send_key, NULL,
 			 &hmac_send, NULL, NULL)) {
     /** Cannot get keys */
     ske->status = SILC_SKE_STATUS_ERROR;
+    ske->prop->cipher = NULL;
+    ske->prop->hmac = NULL;
     silc_fsm_next(fsm, silc_ske_st_responder_error);
     return SILC_FSM_CONTINUE;
   }
+
+  ske->prop->cipher = NULL;
+  ske->prop->hmac = NULL;
 
   /* Set the new keys into use.  This will also send REKEY_DONE packet.  Any
      packet sent after this call will be protected with the new keys. */
@@ -2823,6 +2859,8 @@
     /** Cannot set keys */
     SILC_LOG_DEBUG(("Cannot set new keys, error sending REKEY_DONE"));
     ske->status = SILC_SKE_STATUS_ERROR;
+    silc_cipher_free(send_key);
+    silc_hmac_free(hmac_send);
     silc_fsm_next(fsm, silc_ske_st_responder_error);
     return SILC_FSM_CONTINUE;
   }
@@ -2859,6 +2897,8 @@
 			 NULL, &hmac_receive, NULL)) {
     /** Cannot get keys */
     ske->status = SILC_SKE_STATUS_ERROR;
+    ske->prop->cipher = NULL;
+    ske->prop->hmac = NULL;
     silc_fsm_next(fsm, silc_ske_st_responder_error);
     return SILC_FSM_CONTINUE;
   }
@@ -2870,6 +2910,10 @@
     /** Cannot set keys */
     SILC_LOG_DEBUG(("Cannot set new keys"));
     ske->status = SILC_SKE_STATUS_ERROR;
+    ske->prop->cipher = NULL;
+    ske->prop->hmac = NULL;
+    silc_cipher_free(receive_key);
+    silc_hmac_free(hmac_receive);
     silc_fsm_next(fsm, silc_ske_st_responder_error);
     return SILC_FSM_CONTINUE;
   }
@@ -2881,6 +2925,8 @@
   if (!rekey) {
     /** No memory */
     ske->status = SILC_SKE_STATUS_OUT_OF_MEMORY;
+    ske->prop->cipher = NULL;
+    ske->prop->hmac = NULL;
     silc_fsm_next(fsm, silc_ske_st_responder_error);
     return SILC_FSM_CONTINUE;
   }
@@ -2971,7 +3017,7 @@
     return NULL;
   silc_buffer_format(buf,
 		     SILC_STR_UI_CHAR(0),
-		     SILC_STR_UI_XNSTRING(data, data_len),
+		     SILC_STR_DATA(data, data_len),
 		     SILC_STR_END);
 
   /* Take IVs */
@@ -3010,8 +3056,8 @@
     if (!dist)
       return NULL;
     silc_buffer_format(dist,
-		       SILC_STR_UI_XNSTRING(data, data_len),
-		       SILC_STR_UI_XNSTRING(k1, hash_len),
+		       SILC_STR_DATA(data, data_len),
+		       SILC_STR_DATA(k1, hash_len),
 		       SILC_STR_END);
     memset(k2, 0, sizeof(k2));
     silc_hash_make(hash, dist->data, silc_buffer_len(dist), k2);
@@ -3021,7 +3067,7 @@
     silc_buffer_pull_tail(dist, hash_len);
     silc_buffer_pull(dist, data_len + hash_len);
     silc_buffer_format(dist,
-		       SILC_STR_UI_XNSTRING(k2, hash_len),
+		       SILC_STR_DATA(k2, hash_len),
 		       SILC_STR_END);
     silc_buffer_push(dist, data_len + hash_len);
     memset(k3, 0, sizeof(k3));
@@ -3073,8 +3119,8 @@
     if (!dist)
       return NULL;
     silc_buffer_format(dist,
-		       SILC_STR_UI_XNSTRING(data, data_len),
-		       SILC_STR_UI_XNSTRING(k1, hash_len),
+		       SILC_STR_DATA(data, data_len),
+		       SILC_STR_DATA(k1, hash_len),
 		       SILC_STR_END);
     memset(k2, 0, sizeof(k2));
     silc_hash_make(hash, dist->data, silc_buffer_len(dist), k2);
@@ -3084,7 +3130,7 @@
     silc_buffer_pull_tail(dist, hash_len);
     silc_buffer_pull(dist, data_len + hash_len);
     silc_buffer_format(dist,
-		       SILC_STR_UI_XNSTRING(k2, hash_len),
+		       SILC_STR_DATA(k2, hash_len),
 		       SILC_STR_END);
     silc_buffer_push(dist, data_len + hash_len);
     memset(k3, 0, sizeof(k3));
@@ -3160,8 +3206,8 @@
   if (!buf)
     return NULL;
   silc_buffer_format(buf,
-		     SILC_STR_UI_XNSTRING(tmpbuf, klen),
-		     SILC_STR_UI_XNSTRING(ske->hash, ske->hash_len),
+		     SILC_STR_DATA(tmpbuf, klen),
+		     SILC_STR_DATA(ske->hash, ske->hash_len),
 		     SILC_STR_END);
 
   /* Process the key material */

Modified: silc-server/branches/upstream/current/lib/silcske/silcske.h
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcske/silcske.h?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcske/silcske.h (original)
+++ silc-server/branches/upstream/current/lib/silcske/silcske.h Sun Jul  1 19:18:19 2007
@@ -352,6 +352,10 @@
  *    SILC_SKE_SP_FLAG_MUTUAL is not set and you are initiator.  For
  *    responder both `public_key' and `private_key' must be set.
  *
+ *    When allocating SKE session for rekey, the `repository' and `private_key'
+ *    pointers must be NULL and the SilcSKEVerifyCb callback must not be
+ *    set with silc_ske_set_callbacks.
+ *
  * EXMPALE
  *
  *    // Initiator example
@@ -443,8 +447,9 @@
  *    the protocol has completed.  The `stream' is the network connection
  *    to the remote host.  The SKE library will handle all key exchange
  *    packets sent and received in the `stream' connection.  The library will
- *    also set the remote host's ID automatically to the `stream'.  The
- *    `params' include SKE parameters, and it must be provided.
+ *    also set the remote host's ID automatically to the `stream' if it is
+ *    present in the exchanged packets.  The `params' include SKE parameters,
+ *    and it must be provided.
  *
  *    If the `start_payload' is NULL the library will generate it
  *    automatically.  Caller may provide it if it wants to send its own
@@ -478,8 +483,10 @@
  *    callback that was set in silc_ske_set_callbacks will be called once
  *    the protocol has completed.  The `stream' is the network connection
  *    to the remote host.  The SKE library will handle all key exchange
- *    packets sent and received in the `stream' connection.  The `params'
- *    include SKE parameters, and must be provided.
+ *    packets sent and received in the `stream' connection.  The library will
+ *    also set the remote hosts's ID automatically to the `stream' if it is
+ *    present in the exchanged packets.  The `params' include SKE parameters,
+ *    and must be provided.
  *
  *    This function returns SilcAsyncOperation operation context which can
  *    be used to control the protocol from the application.  Application may

Modified: silc-server/branches/upstream/current/lib/silcskr/Makefile.am
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcskr/Makefile.am?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcskr/Makefile.am (original)
+++ silc-server/branches/upstream/current/lib/silcskr/Makefile.am Sun Jul  1 19:18:19 2007
@@ -2,7 +2,7 @@
 # To make changes edit the ./lib/silcskr/Makefile.ad file in the source tree.
 
 # Source: ./lib/silcskr/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 

Modified: silc-server/branches/upstream/current/lib/silcskr/Makefile.in
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcskr/Makefile.in?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcskr/Makefile.in (original)
+++ silc-server/branches/upstream/current/lib/silcskr/Makefile.in Sun Jul  1 19:18:19 2007
@@ -18,7 +18,7 @@
 # To make changes edit the ./lib/silcskr/Makefile.ad file in the source tree.
 
 # Source: ./lib/silcskr/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 
@@ -219,6 +219,7 @@
 __SILC_ENABLE_DEBUG = @__SILC_ENABLE_DEBUG@
 __SILC_HAVE_PTHREAD = @__SILC_HAVE_PTHREAD@
 __SILC_HAVE_SIM = @__SILC_HAVE_SIM@
+__SILC_PACKAGE_VERSION = @__SILC_PACKAGE_VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@

Modified: silc-server/branches/upstream/current/lib/silcskr/silcskr.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcskr/silcskr.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcskr/silcskr.c (original)
+++ silc-server/branches/upstream/current/lib/silcskr/silcskr.c Sun Jul  1 19:18:19 2007
@@ -51,16 +51,16 @@
 
 #if defined(SILC_DEBUG)
 static const char *find_name[] = {
-  "PKCS TYPE",
-  "USERNAME",
-  "HOST",
-  "REALNAME",
-  "EMAIL",
-  "ORG",
-  "COUNTRY",
+  "PKCS TYPE ",
+  "USERNAME  ",
+  "HOST      ",
+  "REALNAME  ",
+  "EMAIL     ",
+  "ORG       ",
+  "COUNTRY   ",
   "PUBLIC KEY",
-  "CONTEXT",
-  "USAGE",
+  "CONTEXT   ",
+  "USAGE     ",
   NULL
 };
 #endif /* SILC_DEBUG */
@@ -78,7 +78,7 @@
   case SILC_SKR_FIND_PKCS_TYPE:
   case SILC_SKR_FIND_USAGE:
     silc_snprintf(retbuf, retbuf_size, "[%s] [%d]", find_name[type],
-	     (int)SILC_PTR_TO_32(data));
+		  (int)SILC_PTR_TO_32(data));
     break;
 
   case SILC_SKR_FIND_PUBLIC_KEY:
@@ -88,7 +88,7 @@
 
   default:
     silc_snprintf(retbuf, retbuf_size, "[%s] [%s]", find_name[type],
-	     (char *)data);
+		  (char *)data);
   }
 }
 #endif /* SILC_DEBUG */
@@ -270,6 +270,13 @@
 				   void *type_data, SilcSKRKeyInternal key)
 {
   SilcSKREntry entry;
+
+#if defined(SILC_DEBUG)
+  char tmp[256];
+  memset(tmp, 0, sizeof(tmp));
+  silc_skr_type_string(type, type_data, tmp, sizeof(tmp) - 1);
+  SILC_LOG_DEBUG(("Search constraint %s", tmp));
+#endif /* SILC_DEBUG */
 
   entry = silc_calloc(1, sizeof(*entry));
   if (!entry)
@@ -363,12 +370,16 @@
   SilcSKRStatus status = SILC_SKR_ERROR;
   SilcPublicKeyIdentifier ident;
   SilcSILCPublicKey silc_pubkey;
+#if defined(SILC_DEBUG)
+  char tmp[256];
+#endif /* SILC_DEBUG */
 
   /* Get the SILC public key */
   silc_pubkey = silc_pkcs_get_context(SILC_PKCS_SILC, public_key);
   ident = &silc_pubkey->identifier;
 
-  SILC_LOG_DEBUG(("Adding SILC public key [%s]", ident->username));
+  SILC_LOG_DEBUG(("Adding SILC public key %p [%s], context %p",
+		  public_key, ident->username, key_context));
 
   silc_mutex_lock(skr->lock);
 
@@ -390,6 +401,12 @@
   key->key.usage = usage;
   key->key.key = public_key;
   key->key.key_context = key_context;
+
+#if defined(SILC_DEBUG)
+  silc_skr_type_string(SILC_SKR_FIND_USAGE, SILC_32_TO_PTR(usage),
+		       tmp, sizeof(tmp) - 1);
+  SILC_LOG_DEBUG((" Search constraint %s", tmp));
+#endif /* SILC_DEBUG */
 
   /* Add key specifics */
 
@@ -854,6 +871,8 @@
 
 SilcBool silc_skr_find_set_context(SilcSKRFind find, void *context)
 {
+  if (!context)
+    return TRUE;
   return silc_hash_table_add(find->constr,
 			     SILC_32_TO_PTR(SILC_SKR_FIND_CONTEXT), context);
 }
@@ -882,6 +901,9 @@
   SilcHashTableList htl;
   SilcDList list, results = NULL;
   void *type, *ctx, *usage = NULL;
+#if defined(SILC_DEBUG)
+  char tmp[256];
+#endif /* SILC_DEBUG */
 
   SILC_LOG_DEBUG(("Finding key from repository"));
 
@@ -894,20 +916,27 @@
   silc_hash_table_find(find->constr, SILC_32_TO_PTR(SILC_SKR_FIND_USAGE),
 		       NULL, &usage);
 
+#if defined(SILC_DEBUG)
+  if (usage) {
+    memset(tmp, 0, sizeof(tmp));
+    silc_skr_type_string(SILC_SKR_FIND_USAGE, usage, tmp, sizeof(tmp) - 1);
+    SILC_LOG_DEBUG(("Finding key by %s", tmp));
+  }
+#endif /* SILC_DEBUG */
+
   silc_hash_table_list(find->constr, &htl);
   while (silc_hash_table_get(&htl, &type, &ctx)) {
 
+    /* SILC_SKR_FIND_USAGE is handled separately while searching the keys. */
+    if ((SilcSKRFindType)SILC_32_TO_PTR(type) == SILC_SKR_FIND_USAGE)
+      continue;
+
 #if defined(SILC_DEBUG)
-    char tmp[256];
     memset(tmp, 0, sizeof(tmp));
     silc_skr_type_string((SilcSKRFindType)SILC_32_TO_PTR(type),
 			 ctx, tmp, sizeof(tmp) - 1);
     SILC_LOG_DEBUG(("Finding key by %s", tmp));
 #endif /* SILC_DEBUG */
-
-    /* SILC_SKR_FIND_USAGE is handled separately while searching the keys. */
-    if ((SilcSKRFindType)SILC_32_TO_PTR(type) == SILC_SKR_FIND_USAGE)
-      continue;
 
     /* Find entries by this search constraint */
     if (!silc_skr_find_entry(skr, &status,

Modified: silc-server/branches/upstream/current/lib/silcutil/Makefile.am
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcutil/Makefile.am?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcutil/Makefile.am (original)
+++ silc-server/branches/upstream/current/lib/silcutil/Makefile.am Sun Jul  1 19:18:19 2007
@@ -2,7 +2,7 @@
 # To make changes edit the ./lib/silcutil/Makefile.ad file in the source tree.
 
 # Source: ./lib/silcutil/Makefile.ad
-# Generated: Fri Jun  8 09:30:37 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 

Modified: silc-server/branches/upstream/current/lib/silcutil/Makefile.in
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcutil/Makefile.in?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcutil/Makefile.in (original)
+++ silc-server/branches/upstream/current/lib/silcutil/Makefile.in Sun Jul  1 19:18:19 2007
@@ -18,7 +18,7 @@
 # To make changes edit the ./lib/silcutil/Makefile.ad file in the source tree.
 
 # Source: ./lib/silcutil/Makefile.ad
-# Generated: Fri Jun  8 09:30:37 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 
@@ -233,6 +233,7 @@
 __SILC_ENABLE_DEBUG = @__SILC_ENABLE_DEBUG@
 __SILC_HAVE_PTHREAD = @__SILC_HAVE_PTHREAD@
 __SILC_HAVE_SIM = @__SILC_HAVE_SIM@
+__SILC_PACKAGE_VERSION = @__SILC_PACKAGE_VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@

Modified: silc-server/branches/upstream/current/lib/silcutil/silcbuffer.h
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcutil/silcbuffer.h?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcutil/silcbuffer.h (original)
+++ silc-server/branches/upstream/current/lib/silcutil/silcbuffer.h Sun Jul  1 19:18:19 2007
@@ -16,7 +16,7 @@
   GNU General Public License for more details.
 
 */
-/* $Id: silcbuffer.h,v 1.34 2007/05/16 16:02:29 priikone Exp $ */
+/* $Id: silcbuffer.h,v 1.34.2.1 2007/06/17 10:16:39 priikone Exp $ */
 
 /****h* silcutil/SILC Buffer Interface
  *
@@ -977,7 +977,7 @@
     return NULL;
 
   /* Allocate the actual data area */
-  sb->head = (unsigned char *)silc_smalloc_ua(stack, len);
+  sb->head = (unsigned char *)silc_smalloc(stack, len);
   if (silc_unlikely(!sb->head))
     return NULL;
 
@@ -1054,12 +1054,12 @@
 
   hlen = silc_buffer_headlen(sb);
   dlen = silc_buffer_len(sb);
-  h = (unsigned char *)silc_srealloc_ua(stack, silc_buffer_truelen(sb),
-					sb->head, newsize);
+  h = (unsigned char *)silc_srealloc(stack, silc_buffer_truelen(sb),
+				     sb->head, newsize);
   if (!h) {
     /* Do slow and stack wasting realloc.  The old sb->head is lost and
        is freed eventually. */
-    h = (unsigned char *)silc_smalloc_ua(stack, newsize);
+    h = (unsigned char *)silc_smalloc(stack, newsize);
     if (silc_unlikely(!h))
       return NULL;
     memcpy(h, sb->head, silc_buffer_truelen(sb));

Modified: silc-server/branches/upstream/current/lib/silcutil/silcbuffmt.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcutil/silcbuffmt.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcutil/silcbuffmt.c (original)
+++ silc-server/branches/upstream/current/lib/silcutil/silcbuffmt.c Sun Jul  1 19:18:19 2007
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone at silcnet.org>
 
-  Copyright (C) 1997 - 2006 Pekka Riikonen
+  Copyright (C) 1997 - 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
@@ -16,7 +16,7 @@
   GNU General Public License for more details.
 
 */
-/* $Id: silcbuffmt.c,v 1.36 2007/04/22 18:23:16 priikone Exp $ */
+/* $Id: silcbuffmt.c,v 1.36.2.1 2007/06/17 10:16:39 priikone Exp $ */
 
 #include "silc.h"
 
@@ -747,8 +747,8 @@
       goto ok;
 
     slen = strlen(string);
-    d = silc_srealloc_ua(stack, len + 1, dst->head,
-			 sizeof(*dst->head) * (slen + len + 1));
+    d = silc_srealloc(stack, len + 1, dst->head,
+		      sizeof(*dst->head) * (slen + len + 1));
     if (silc_unlikely(!d))
       return -1;
     dst->head = d;

Modified: silc-server/branches/upstream/current/lib/silcutil/silcdlist.h
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcutil/silcdlist.h?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcutil/silcdlist.h (original)
+++ silc-server/branches/upstream/current/lib/silcutil/silcdlist.h Sun Jul  1 19:18:19 2007
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone at silcnet.org>
 
-  Copyright (C) 2000 - 2006 Pekka Riikonen
+  Copyright (C) 2000 - 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
@@ -50,14 +50,12 @@
  *    Application defines this object and adds contexts to this list with
  *    Dynamic List Interface functions.
  *
- * SOURCE
- */
+ ***/
 typedef struct SilcDListStruct {
   SilcList list;
   void *current;
   void *prev;
 } *SilcDList;
-/***/
 
 /* SilcDListEntry structure, one entry in the list. This MUST NOT be used
    directly by the application. */
@@ -239,22 +237,22 @@
  * SYNOPSIS
  *
  *    static inline
- *    void silc_dlist_del(SilcDList list, void *context);
- *
- * DESCRIPTION
- *
- *    Remove entry from the list. Returns < 0 on error, 0 otherwise.
- *
- ***/
-
-static inline
-void silc_dlist_del(SilcDList list, void *context)
+ *    void silc_dlist_del(SilcDList list, void *entry);
+ *
+ * DESCRIPTION
+ *
+ *    Remove entry from the list.
+ *
+ ***/
+
+static inline
+void silc_dlist_del(SilcDList list, void *entry)
 {
   SilcDListEntry e;
 
   silc_list_start(list->list);
   while ((e = (SilcDListEntry)silc_list_get(list->list)) != SILC_LIST_END) {
-    if (e->context == context) {
+    if (e->context == entry) {
       silc_list_del(list->list, e);
 #if defined(SILC_DEBUG)
       memset(e, 'F', sizeof(*e));

Modified: silc-server/branches/upstream/current/lib/silcutil/silcfsm.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcutil/silcfsm.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcutil/silcfsm.c (original)
+++ silc-server/branches/upstream/current/lib/silcutil/silcfsm.c Sun Jul  1 19:18:19 2007
@@ -317,10 +317,6 @@
 
   SILC_ASSERT(!f->finished);
 
-  /* Machine must not have active threads */
-  if (!f->thread && silc_atomic_get_int32(&f->u.m.threads))
-    assert(silc_atomic_get_int32(&f->u.m.threads) == 0);
-
   f->started = FALSE;
   f->finished = TRUE;
 
@@ -484,6 +480,9 @@
       fsm->destructor(fsm, fsm->fsm_context, fsm->destructor_context);
 
   } else {
+    /* Machine must not have active threads */
+    assert(silc_atomic_get_int32(&fsm->u.m.threads) == 0);
+
     if (fsm->u.m.lock) {
       silc_mutex_free(fsm->u.m.lock);
       fsm->u.m.lock = NULL;

Modified: silc-server/branches/upstream/current/lib/silcutil/silclog.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcutil/silclog.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcutil/silclog.c (original)
+++ silc-server/branches/upstream/current/lib/silcutil/silclog.c Sun Jul  1 19:18:19 2007
@@ -16,7 +16,7 @@
   GNU General Public License for more details.
 
 */
-/* $Id: silclog.c,v 1.44.2.1 2007/06/06 14:31:30 priikone Exp $ */
+/* $Id: silclog.c,v 1.44.2.2 2007/06/08 15:45:20 priikone Exp $ */
 
 #include "silc.h"
 
@@ -513,8 +513,9 @@
 #ifdef SILC_SYMBIAN
   silc_symbian_debug(function, line, string);
 #else
-  fprintf(stderr, "%02d:%02d.%d %s:%d: %s\n", curtime.minute, curtime.second,
-	  curtime.msecond, function, line, string);
+  fprintf(stderr, "%02d:%02d:%02d %s:%d: %s\n", curtime.hour,
+	  curtime.minute, curtime.second, function, line,
+	  string);
   fflush(stderr);
 #endif /* SILC_SYMBIAN */
 

Modified: silc-server/branches/upstream/current/lib/silcutil/silcmime.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcutil/silcmime.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcutil/silcmime.c (original)
+++ silc-server/branches/upstream/current/lib/silcutil/silcmime.c Sun Jul  1 19:18:19 2007
@@ -198,6 +198,7 @@
   if (field && strstr(field, "multipart")) {
     char b[1024];
     SilcMime p;
+    unsigned int len;
 
     mime->multiparts = silc_dlist_init();
     if (!mime->multiparts)
@@ -213,7 +214,10 @@
     if (!strchr(field, ';'))
       goto err;
     memset(b, 0, sizeof(b));
-    strncat(b, value, strchr(field, ';') - value);
+    len = (unsigned int)(strchr(field, ';') - value);
+    if (len > sizeof(b) - 1)
+      goto err;
+    strncpy(b, value, len);
     if (strchr(b, '"'))
       *strchr(b, '"') = '\0';
     mime->multitype = silc_memdup(b, strlen(b));

Modified: silc-server/branches/upstream/current/lib/silcutil/silcmutex.h
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcutil/silcmutex.h?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcutil/silcmutex.h (original)
+++ silc-server/branches/upstream/current/lib/silcutil/silcmutex.h Sun Jul  1 19:18:19 2007
@@ -190,7 +190,7 @@
  *    is locked by a writer the current thread will block until the other
  *    thread has issued silc_rwlock_unlock for the `rwlock'.  This function
  *    may be called multiple times to acquire the read lock.  There must be
- *    same amount of silc_rwlock_unlock calls.  If `rwlock' is NULL this
+ *    same number of silc_rwlock_unlock calls.  If `rwlock' is NULL this
  *    function has no effect.
  *
  ***/
@@ -207,7 +207,9 @@
  *    Acquires write lock of the read/write lock `rwlock'.  If the `rwlock'
  *    is locked by a writer or a reader the current thread will block until
  *    the other thread(s) have issued silc_rwlock_unlock for the `rwlock'.
- *    If `rwlock' is NULL this function has no effect.
+ *    A thread may acquire the write lock only once.  A deadlock may occur
+ *    if thread attempts to acquire the write lock when it has already done
+ *    so.  If `rwlock' is NULL this function has no effect.
  *
  ***/
 void silc_rwlock_wrlock(SilcRwLock rwlock);

Modified: silc-server/branches/upstream/current/lib/silcutil/silcnet.h
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcutil/silcnet.h?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcutil/silcnet.h (original)
+++ silc-server/branches/upstream/current/lib/silcutil/silcnet.h Sun Jul  1 19:18:19 2007
@@ -118,7 +118,7 @@
  *
  *    This function creates TCP listener.  This is used to create network
  *    listener for incoming connections, and `callback' will be called
- *    everytime new connection is received.  If `local_ip_addr' is NULL any
+ *    everytime new connection is received.  If `local_ip_addr' is NULL 'any'
  *    address is used.  If provided it can be used bind the listener to
  *    `local_ip_count' many IP addresses provided in `local_ip_addr' table.
  *    On success returns the SilcNetListener context, or NULL on error.
@@ -504,7 +504,7 @@
  * SYNOPSIS
  *
  *    SilcBool silc_net_gethostbyname(const char *name, SilcBool prefer_ipv6,
- *                                char *address, SilcUInt32 address_len);
+ *                                    char *address, SilcUInt32 address_len);
  *
  * DESCRIPTION
  *
@@ -553,9 +553,9 @@
  * SYNOPSIS
  *
  *   SilcBool silc_net_gethostbyaddr(const char *addr, char *name,
- *                               SilcUInt32 name_len);
- *
- * DESCRIPTION
+ *                                   SilcUInt32 name_len);
+ *
+x * DESCRIPTION
  *
  *    Resolves the hostname for the IP address indicated by the `addr'
  *    This returns TRUE and the resolved hostname to the `name' buffer,

Modified: silc-server/branches/upstream/current/lib/silcutil/silcstack.h
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcutil/silcstack.h?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcutil/silcstack.h (original)
+++ silc-server/branches/upstream/current/lib/silcutil/silcstack.h Sun Jul  1 19:18:19 2007
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone at silcnet.org>
 
-  Copyright (C) 2003 - 2006 Pekka Riikonen
+  Copyright (C) 2003 - 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
@@ -48,6 +48,7 @@
  *
  * The data stack is not thread-safe.  If the same stack context must be
  * used in multithreaded environment concurrency control must be employed.
+ * Each thread should allocate their own SilcStack.
  *
  ***/
 
@@ -81,11 +82,11 @@
  *    Static stack frame context that optionally can be used as stack
  *    frame in SilcStack.  By default silc_stack_push use pre-allocated
  *    stack frame (or allocates new one if all frames are reserved), but
- *    user may also use staticly allocated SilcStackFrame instead.  This
+ *    user may also use statically allocated SilcStackFrame instead.  This
  *    is recommended when using SilcStack in recursive routine and the
  *    recursion may become deep.  Using static frame assures that during
  *    recursion frames never run out and silc_stack_push never allocates
- *    any memory.  In other normal usage staticly allocated SilcStackFrame
+ *    any memory.  In other normal usage statically allocated SilcStackFrame
  *    is not needed, unless performance is critical.
  *
  ***/
@@ -142,10 +143,10 @@
  *    If this returns zero (0) the system is out of memory.
  *
  *    If the `frame' is non-NULL then that SilcStackFrame is used as
- *    stack frame.  Usually `frame' is set to NULL by user.  Staticly
+ *    stack frame.  Usually `frame' is set to NULL by user.  Statically
  *    allocated SilcStackFrame should be used when using silc_stack_push
  *    in recursive function and the recursion may become deep.  In this
- *    case using staticly allocated SilcStackFrame is recommended since
+ *    case using statically allocated SilcStackFrame is recommended since
  *    it assures that frames never run out and silc_stack_push never
  *    allocates any memory.  If your routine is not recursive then
  *    setting `frame' to NULL is recommended, unless performance is
@@ -169,8 +170,8 @@
  *    silc_foo_parse_packet(packet, stack);
  *    silc_stack_pop(stack);
  *
- *    Another example with recursion and using staticly allocated
- *    SilcStackFrame.  After popping the staticly allocated frame can
+ *    Another example with recursion and using statically allocated
+ *    SilcStackFrame.  After popping the statically allocated frame can
  *    be reused if necessary.
  *
  *    void silc_foo_this_function(SilcStack stack)

Modified: silc-server/branches/upstream/current/lib/silcutil/unix/Makefile.in
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcutil/unix/Makefile.in?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcutil/unix/Makefile.in (original)
+++ silc-server/branches/upstream/current/lib/silcutil/unix/Makefile.in Sun Jul  1 19:18:19 2007
@@ -213,6 +213,7 @@
 __SILC_ENABLE_DEBUG = @__SILC_ENABLE_DEBUG@
 __SILC_HAVE_PTHREAD = @__SILC_HAVE_PTHREAD@
 __SILC_HAVE_SIM = @__SILC_HAVE_SIM@
+__SILC_PACKAGE_VERSION = @__SILC_PACKAGE_VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@

Modified: silc-server/branches/upstream/current/lib/silcutil/unix/silcunixnet.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcutil/unix/silcunixnet.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcutil/unix/silcunixnet.c (original)
+++ silc-server/branches/upstream/current/lib/silcutil/unix/silcunixnet.c Sun Jul  1 19:18:19 2007
@@ -16,7 +16,7 @@
   GNU General Public License for more details.
 
 */
-/* $Id: silcunixnet.c,v 1.37 2007/05/10 15:28:38 priikone Exp $ */
+/* $Id: silcunixnet.c,v 1.37.2.2 2007/06/24 14:13:11 priikone Exp $ */
 
 #include "silc.h"
 #include "silcnet.h"
@@ -164,8 +164,8 @@
 
   /* Bind to local addresses */
   for (i = 0; i < local_ip_count; i++) {
-    SILC_LOG_DEBUG(("Binding to local address %s",
-		    local_ip_addr ? local_ip_addr[i] : ipany));
+    SILC_LOG_DEBUG(("Binding to local address %s:%d",
+		    local_ip_addr ? local_ip_addr[i] : ipany, port));
 
     /* Set sockaddr for server */
     if (!silc_net_set_sockaddr(&server,
@@ -628,20 +628,20 @@
     }
 
 #if defined(ECONNREFUSED)
-    if (errno == ECONNREFUSED)
+    if (opt == ECONNREFUSED)
       conn->status = SILC_NET_CONNECTION_REFUSED;
 #endif /* ECONNREFUSED */
 #if defined(ETIMEDOUT)
-    if (errno == ETIMEDOUT)
+    if (opt == ETIMEDOUT)
       conn->status = SILC_NET_CONNECTION_TIMEOUT;
 #endif /* ETIMEDOUT */
 #if defined(ENETUNREACH)
-    if (errno == ENETUNREACH)
+    if (opt == ENETUNREACH)
       conn->status = SILC_NET_HOST_UNREACHABLE;
 #endif /* ENETUNREACH */
 
     /** Connecting failed */
-    SILC_LOG_DEBUG(("Connecting failed"));
+    SILC_LOG_DEBUG(("Connecting failed, error %s", strerror(opt)));
     silc_fsm_next(fsm, silc_net_connect_st_finish);
     return SILC_FSM_CONTINUE;
   }

Modified: silc-server/branches/upstream/current/lib/silcutil/unix/silcunixschedule.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcutil/unix/silcunixschedule.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcutil/unix/silcunixschedule.c (original)
+++ silc-server/branches/upstream/current/lib/silcutil/unix/silcunixschedule.c Sun Jul  1 19:18:19 2007
@@ -16,7 +16,7 @@
   GNU General Public License for more details.
 
 */
-/* $Id: silcunixschedule.c,v 1.28.2.3 2007/06/06 14:32:17 priikone Exp $ */
+/* $Id: silcunixschedule.c,v 1.28.2.4 2007/06/24 14:12:26 priikone Exp $ */
 
 #include "silc.h"
 
@@ -459,6 +459,8 @@
 {
   int i;
 
+  SILC_LOG_DEBUG(("Start"));
+
   for (i = 0; i < SIGNAL_COUNT; i++) {
     if (signal_call[i].sig == signal) {
       signal_call[i].call = TRUE;
@@ -548,11 +550,13 @@
         signal_call[i].callback) {
       SILC_LOG_DEBUG(("Calling signal %d callback",
 		      signal_call[i].sig));
+      silc_schedule_internal_signals_unblock(schedule, context);
       signal_call[i].callback(schedule, internal->app_context,
 			      SILC_TASK_INTERRUPT,
 			      signal_call[i].sig,
 			      signal_call[i].context);
       signal_call[i].call = FALSE;
+      silc_schedule_internal_signals_block(schedule, context);
     }
   }
 

Modified: silc-server/branches/upstream/current/lib/silcutil/unix/silcunixthread.c
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcutil/unix/silcunixthread.c?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcutil/unix/silcunixthread.c (original)
+++ silc-server/branches/upstream/current/lib/silcutil/unix/silcunixthread.c Sun Jul  1 19:18:19 2007
@@ -16,7 +16,7 @@
   GNU General Public License for more details.
 
 */
-/* $Id: silcunixthread.c,v 1.15 2007/03/14 15:31:19 priikone Exp $ */
+/* $Id: silcunixthread.c,v 1.15.2.1 2007/06/18 21:04:41 priikone Exp $ */
 
 #include "silc.h"
 
@@ -144,8 +144,7 @@
 {
 #ifdef SILC_THREADS
   if (mutex) {
-    if (pthread_mutex_lock(&mutex->mutex))
-      SILC_ASSERT(FALSE);
+    SILC_VERIFY(pthread_mutex_lock(&mutex->mutex) == 0);
     mutex->locked = TRUE;
   }
 #endif /* SILC_THREADS */
@@ -155,8 +154,7 @@
 {
 #ifdef SILC_THREADS
   if (mutex) {
-    if (pthread_mutex_unlock(&mutex->mutex))
-      SILC_ASSERT(FALSE);
+    SILC_VERIFY(pthread_mutex_unlock(&mutex->mutex) == 0);
     mutex->locked = FALSE;
   }
 #endif /* SILC_THREADS */
@@ -166,7 +164,7 @@
 {
 #ifdef SILC_THREADS
   if (mutex)
-    SILC_ASSERT(mutex->locked);
+    SILC_VERIFY(mutex->locked);
 #endif /* SILC_THREADS */
 }
 
@@ -216,7 +214,7 @@
 {
 #ifdef SILC_THREADS
   if (rwlock)
-    pthread_rwlock_wrlock(&rwlock->rwlock);
+    SILC_VERIFY(pthread_rwlock_wrlock(&rwlock->rwlock) == 0);
 #endif /* SILC_THREADS */
 }
 
@@ -224,7 +222,7 @@
 {
 #ifdef SILC_THREADS
   if (rwlock)
-    pthread_rwlock_unlock(&rwlock->rwlock);
+    SILC_VERIFY(pthread_rwlock_unlock(&rwlock->rwlock) == 0);
 #endif /* SILC_THREADS */
 }
 

Modified: silc-server/branches/upstream/current/lib/silcvcard/Makefile.am
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcvcard/Makefile.am?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcvcard/Makefile.am (original)
+++ silc-server/branches/upstream/current/lib/silcvcard/Makefile.am Sun Jul  1 19:18:19 2007
@@ -2,7 +2,7 @@
 # To make changes edit the ./lib/silcvcard/Makefile.ad file in the source tree.
 
 # Source: ./lib/silcvcard/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 

Modified: silc-server/branches/upstream/current/lib/silcvcard/Makefile.in
URL: http://svn.debian.org/wsvn/pkg-silc/silc-server/branches/upstream/current/lib/silcvcard/Makefile.in?rev=116&op=diff
==============================================================================
--- silc-server/branches/upstream/current/lib/silcvcard/Makefile.in (original)
+++ silc-server/branches/upstream/current/lib/silcvcard/Makefile.in Sun Jul  1 19:18:19 2007
@@ -18,7 +18,7 @@
 # To make changes edit the ./lib/silcvcard/Makefile.ad file in the source tree.
 
 # Source: ./lib/silcvcard/Makefile.ad
-# Generated: Fri Jun  8 09:30:38 EEST 2007 by priikone
+# Generated: Sun Jul  1 19:05:58 EEST 2007 by priikone
 # Distribution: Server
 # License: 
 
@@ -219,6 +219,7 @@
 __SILC_ENABLE_DEBUG = @__SILC_ENABLE_DEBUG@
 __SILC_HAVE_PTHREAD = @__SILC_HAVE_PTHREAD@
 __SILC_HAVE_SIM = @__SILC_HAVE_SIM@
+__SILC_PACKAGE_VERSION = @__SILC_PACKAGE_VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@




More information about the Pkg-silc-commits mailing list